@wordpress/components 34.0.0 → 35.0.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 (161) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/build/border-control/border-control-dropdown/component.cjs +33 -33
  3. package/build/border-control/border-control-dropdown/component.cjs.map +3 -3
  4. package/build/disabled/index.cjs +1 -1
  5. package/build/disabled/index.cjs.map +2 -2
  6. package/build/higher-order/with-notices/index.cjs +15 -3
  7. package/build/higher-order/with-notices/index.cjs.map +2 -2
  8. package/build/input-control/input-base.cjs +34 -31
  9. package/build/input-control/input-base.cjs.map +2 -2
  10. package/build/responsive-wrapper/index.cjs +3 -4
  11. package/build/responsive-wrapper/index.cjs.map +2 -2
  12. package/build/tooltip/index.cjs +1 -2
  13. package/build/tooltip/index.cjs.map +2 -2
  14. package/build-module/border-control/border-control-dropdown/component.mjs +34 -34
  15. package/build-module/border-control/border-control-dropdown/component.mjs.map +2 -2
  16. package/build-module/disabled/index.mjs +1 -1
  17. package/build-module/disabled/index.mjs.map +2 -2
  18. package/build-module/higher-order/with-notices/index.mjs +16 -4
  19. package/build-module/higher-order/with-notices/index.mjs.map +2 -2
  20. package/build-module/input-control/input-base.mjs +34 -31
  21. package/build-module/input-control/input-base.mjs.map +2 -2
  22. package/build-module/responsive-wrapper/index.mjs +3 -4
  23. package/build-module/responsive-wrapper/index.mjs.map +2 -2
  24. package/build-module/tooltip/index.mjs +1 -2
  25. package/build-module/tooltip/index.mjs.map +2 -2
  26. package/build-types/border-box-control/border-box-control/hook.d.ts +10 -24
  27. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  28. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +12 -26
  29. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  30. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +10 -24
  31. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
  32. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +11 -25
  33. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
  34. package/build-types/border-control/border-control/hook.d.ts +10 -24
  35. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  36. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  37. package/build-types/border-control/border-control-dropdown/hook.d.ts +9 -23
  38. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  39. package/build-types/box-control/styles/box-control-styles.d.ts +2 -2
  40. package/build-types/card/card/hook.d.ts +11 -25
  41. package/build-types/card/card/hook.d.ts.map +1 -1
  42. package/build-types/card/card-body/hook.d.ts +11 -25
  43. package/build-types/card/card-body/hook.d.ts.map +1 -1
  44. package/build-types/card/card-divider/hook.d.ts +12 -26
  45. package/build-types/card/card-divider/hook.d.ts.map +1 -1
  46. package/build-types/card/card-footer/hook.d.ts +11 -25
  47. package/build-types/card/card-footer/hook.d.ts.map +1 -1
  48. package/build-types/card/card-header/hook.d.ts +11 -25
  49. package/build-types/card/card-header/hook.d.ts.map +1 -1
  50. package/build-types/card/card-media/hook.d.ts +11 -25
  51. package/build-types/card/card-media/hook.d.ts.map +1 -1
  52. package/build-types/color-picker/styles.d.ts +2 -2
  53. package/build-types/composite/stories/index.story.d.ts.map +1 -1
  54. package/build-types/custom-select-control-v2/styles.d.ts +12 -4
  55. package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
  56. package/build-types/date-time/time-picker/styles.d.ts +4 -4
  57. package/build-types/elevation/hook.d.ts +11 -25
  58. package/build-types/elevation/hook.d.ts.map +1 -1
  59. package/build-types/flex/flex/hook.d.ts +11 -25
  60. package/build-types/flex/flex/hook.d.ts.map +1 -1
  61. package/build-types/flex/flex-block/hook.d.ts +11 -25
  62. package/build-types/flex/flex-block/hook.d.ts.map +1 -1
  63. package/build-types/flex/flex-item/hook.d.ts +11 -25
  64. package/build-types/flex/flex-item/hook.d.ts.map +1 -1
  65. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  66. package/build-types/grid/hook.d.ts +11 -25
  67. package/build-types/grid/hook.d.ts.map +1 -1
  68. package/build-types/h-stack/hook.d.ts +11 -25
  69. package/build-types/h-stack/hook.d.ts.map +1 -1
  70. package/build-types/heading/hook.d.ts +11 -25
  71. package/build-types/heading/hook.d.ts.map +1 -1
  72. package/build-types/higher-order/with-fallback-styles/index.d.ts +3 -1
  73. package/build-types/higher-order/with-filters/index.d.ts +6 -1
  74. package/build-types/higher-order/with-filters/index.d.ts.map +1 -1
  75. package/build-types/higher-order/with-notices/index.d.ts +4 -2
  76. package/build-types/higher-order/with-notices/index.d.ts.map +1 -1
  77. package/build-types/input-control/reducer/reducer.d.ts +1 -1
  78. package/build-types/item-group/item/hook.d.ts +11 -25
  79. package/build-types/item-group/item/hook.d.ts.map +1 -1
  80. package/build-types/item-group/item-group/hook.d.ts +11 -25
  81. package/build-types/item-group/item-group/hook.d.ts.map +1 -1
  82. package/build-types/menu/stories/index.story.d.ts.map +1 -1
  83. package/build-types/menu/styles.d.ts +21 -7
  84. package/build-types/menu/styles.d.ts.map +1 -1
  85. package/build-types/modal/use-modal-exit-animation.d.ts +1 -1
  86. package/build-types/navigator/navigator-back-button/hook.d.ts +12 -26
  87. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  88. package/build-types/navigator/navigator-button/hook.d.ts +12 -26
  89. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  90. package/build-types/number-control/index.d.ts +1 -1
  91. package/build-types/number-control/index.d.ts.map +1 -1
  92. package/build-types/number-control/stories/index.story.d.ts +1 -1
  93. package/build-types/number-control/stories/index.story.d.ts.map +1 -1
  94. package/build-types/popover/types.d.ts +2 -2
  95. package/build-types/popover/types.d.ts.map +1 -1
  96. package/build-types/range-control/index.d.ts +1 -1
  97. package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
  98. package/build-types/range-control/types.d.ts +1 -1
  99. package/build-types/range-control/types.d.ts.map +1 -1
  100. package/build-types/responsive-wrapper/index.d.ts.map +1 -1
  101. package/build-types/scrollable/hook.d.ts +11 -25
  102. package/build-types/scrollable/hook.d.ts.map +1 -1
  103. package/build-types/snackbar/index.d.ts +2 -2
  104. package/build-types/snackbar/types.d.ts +2 -2
  105. package/build-types/snackbar/types.d.ts.map +1 -1
  106. package/build-types/spacer/hook.d.ts +11 -25
  107. package/build-types/spacer/hook.d.ts.map +1 -1
  108. package/build-types/surface/hook.d.ts +11 -25
  109. package/build-types/surface/hook.d.ts.map +1 -1
  110. package/build-types/tabs/stories/index.story.d.ts.map +1 -1
  111. package/build-types/tabs/styles.d.ts +9 -3
  112. package/build-types/tabs/styles.d.ts.map +1 -1
  113. package/build-types/text/hook.d.ts +11 -25
  114. package/build-types/text/hook.d.ts.map +1 -1
  115. package/build-types/tools-panel/tools-panel/hook.d.ts +11 -25
  116. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  117. package/build-types/tools-panel/tools-panel-header/hook.d.ts +11 -25
  118. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  119. package/build-types/tools-panel/tools-panel-item/hook.d.ts +11 -25
  120. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  121. package/build-types/tooltip/index.d.ts.map +1 -1
  122. package/build-types/truncate/hook.d.ts +11 -25
  123. package/build-types/truncate/hook.d.ts.map +1 -1
  124. package/build-types/unit-control/index.d.ts +1 -1
  125. package/build-types/unit-control/index.d.ts.map +1 -1
  126. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
  127. package/build-types/utils/get-node-text.d.ts.map +1 -1
  128. package/build-types/v-stack/hook.d.ts +11 -25
  129. package/build-types/v-stack/hook.d.ts.map +1 -1
  130. package/build-types/validated-form-controls/components/number-control.d.ts +1 -1
  131. package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
  132. package/build-types/validated-form-controls/components/range-control.d.ts +1 -1
  133. package/build-types/validated-form-controls/control-with-error.d.ts +1 -4
  134. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
  135. package/package.json +26 -26
  136. package/src/autocomplete/README.md +1 -1
  137. package/src/border-control/border-control-dropdown/component.tsx +37 -36
  138. package/src/composite/stories/index.story.tsx +1 -0
  139. package/src/disabled/index.tsx +1 -1
  140. package/src/form-file-upload/README.md +1 -1
  141. package/src/h-stack/hook.tsx +1 -1
  142. package/src/higher-order/with-notices/index.tsx +21 -4
  143. package/src/higher-order/with-notices/test/index.tsx +18 -0
  144. package/src/input-control/input-base.tsx +2 -2
  145. package/src/menu/README.md +7 -7
  146. package/src/menu/stories/index.story.tsx +1 -0
  147. package/src/popover/index.tsx +1 -1
  148. package/src/popover/types.ts +4 -2
  149. package/src/range-control/types.ts +1 -1
  150. package/src/responsive-wrapper/index.tsx +3 -7
  151. package/src/snackbar/README.md +1 -1
  152. package/src/snackbar/types.ts +2 -2
  153. package/src/tabs/README.md +1 -1
  154. package/src/tabs/stories/index.story.tsx +1 -0
  155. package/src/tabs/tablist.tsx +1 -1
  156. package/src/tooltip/index.tsx +1 -7
  157. package/src/tree-grid/test/cell.tsx +1 -0
  158. package/src/tree-grid/test/roving-tab-index-item.tsx +1 -0
  159. package/src/tree-select/README.md +1 -1
  160. package/src/utils/get-node-text.ts +1 -7
  161. package/src/validated-form-controls/control-with-error.tsx +1 -6
@@ -27,6 +27,7 @@ const meta: Meta< typeof Composite > = {
27
27
  'Composite.Item': Composite.Item,
28
28
  'Composite.Hover': Composite.Hover,
29
29
  'Composite.Typeahead': Composite.Typeahead,
30
+ // @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
30
31
  'Composite.Context': Composite.Context,
31
32
  },
32
33
  argTypes: {
@@ -61,7 +61,7 @@ function Disabled( {
61
61
  <Provider value={ isDisabled }>
62
62
  <div
63
63
  // @ts-ignore Reason: inert is a recent HTML attribute
64
- inert={ isDisabled ? true : undefined }
64
+ inert={ isDisabled ? 'true' : undefined }
65
65
  className={
66
66
  isDisabled
67
67
  ? cx( disabledStyles, className, 'components-disabled' )
@@ -65,7 +65,7 @@ Whether to allow multiple selection of files or not.
65
65
 
66
66
  ### `onChange`
67
67
 
68
- - Type: `ChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefined`
68
+ - Type: `ChangeEventHandler<HTMLInputElement> | undefined`
69
69
  - Required: Yes
70
70
 
71
71
  Callback function passed directly to the `input` file element.
@@ -29,7 +29,7 @@ export function useHStack( props: WordPressComponentProps< Props, 'div' > ) {
29
29
  const _isSpacer = hasConnectNamespace( child, [ 'Spacer' ] );
30
30
 
31
31
  if ( _isSpacer ) {
32
- const childElement = child as ReactElement< typeof FlexItem >;
32
+ const childElement = child as ReactElement;
33
33
  const _key = childElement.key || `hstack-${ index }`;
34
34
 
35
35
  return <FlexItem isBlock key={ _key } { ...childElement.props } />;
@@ -6,7 +6,7 @@ import { v4 as uuid } from 'uuid';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useState, useMemo } from '@wordpress/element';
9
+ import { forwardRef, useState, useMemo } from '@wordpress/element';
10
10
  import { createHigherOrderComponent } from '@wordpress/compose';
11
11
 
12
12
  /**
@@ -45,7 +45,10 @@ import type { WithNoticeProps } from './types';
45
45
  * @return Wrapped component.
46
46
  */
47
47
  export default createHigherOrderComponent( ( OriginalComponent ) => {
48
- return function Component( props: { [ key: string ]: any } ) {
48
+ function Component(
49
+ props: { [ key: string ]: any },
50
+ ref: React.ForwardedRef< any >
51
+ ) {
49
52
  const [ noticeList, setNoticeList ] = useState<
50
53
  WithNoticeProps[ 'noticeList' ]
51
54
  >( [] );
@@ -94,6 +97,20 @@ export default createHigherOrderComponent( ( OriginalComponent ) => {
94
97
  ),
95
98
  };
96
99
 
97
- return <OriginalComponent { ...propsOut } />;
98
- };
100
+ return isForwardRef ? (
101
+ <OriginalComponent { ...propsOut } ref={ ref } />
102
+ ) : (
103
+ <OriginalComponent { ...propsOut } />
104
+ );
105
+ }
106
+
107
+ let isForwardRef: boolean;
108
+ // @ts-expect-error - `render` will only be present when OriginalComponent was wrapped with forwardRef().
109
+ const { render } = OriginalComponent;
110
+ // Returns a forwardRef if OriginalComponent appears to be a forwardRef.
111
+ if ( typeof render === 'function' ) {
112
+ isForwardRef = true;
113
+ return forwardRef( Component );
114
+ }
115
+ return Component;
99
116
  }, 'withNotices' );
@@ -33,6 +33,14 @@ function noticesFrom( list: string[] ) {
33
33
  return list.map( ( item ) => ( { id: item, content: item } ) );
34
34
  }
35
35
 
36
+ function isComponentLike( object: any ) {
37
+ return typeof object === 'function';
38
+ }
39
+
40
+ function isForwardRefLike( { render: renderMethod }: any ) {
41
+ return typeof renderMethod === 'function';
42
+ }
43
+
36
44
  const content = 'Base content';
37
45
 
38
46
  const BaseComponent = ( {
@@ -72,6 +80,16 @@ const TestNoticeOperations = withNotices(
72
80
  } )
73
81
  );
74
82
 
83
+ describe( 'withNotices return type', () => {
84
+ it( 'should be a component given a component', () => {
85
+ expect( isComponentLike( TestComponent ) ).toBe( true );
86
+ } );
87
+
88
+ it( 'should be a forwardRef given a forwardRef', () => {
89
+ expect( isForwardRefLike( TestNoticeOperations ) ).toBe( true );
90
+ } );
91
+ } );
92
+
75
93
  describe( 'withNotices operations', () => {
76
94
  function setup( props: any = {} ) {
77
95
  const handle = createRef< any >();
@@ -23,7 +23,6 @@ import {
23
23
  useContextSystem,
24
24
  } from '../context';
25
25
  import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
26
- import type { FlexDirection } from '../flex/types';
27
26
 
28
27
  function useUniqueId( idProp?: string ) {
29
28
  const instanceId = useInstanceId( InputBase );
@@ -35,7 +34,7 @@ function useUniqueId( idProp?: string ) {
35
34
  // Adapter to map props for the new ui/flex component.
36
35
  function getUIFlexProps( labelPosition?: LabelPosition ) {
37
36
  const props: {
38
- direction?: FlexDirection;
37
+ direction?: string;
39
38
  gap?: number;
40
39
  justify?: string;
41
40
  expanded?: boolean;
@@ -93,6 +92,7 @@ function InputBase(
93
92
  }, [ __next40pxDefaultSize, size ] );
94
93
 
95
94
  return (
95
+ // @ts-expect-error The `direction` prop from Flex (FlexDirection) conflicts with legacy SVGAttributes `direction` (string) that come from React intrinsic prop definitions.
96
96
  <Root
97
97
  { ...restProps }
98
98
  { ...getUIFlexProps( labelPosition ) }
@@ -120,7 +120,7 @@ make disabled elements still accessible via keyboard.
120
120
 
121
121
  ##### `render`
122
122
 
123
- - Type: `ReactElement<unknown, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
123
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
124
124
  - Required: No
125
125
 
126
126
  Allows the component to be rendered as a different HTML element or React
@@ -245,7 +245,7 @@ The contents of the menu item's prefix, such as an icon.
245
245
 
246
246
  ##### `render`
247
247
 
248
- - Type: `ReactElement<unknown, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
248
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
249
249
  - Required: No
250
250
 
251
251
  Allows the component to be rendered as a different HTML element or React
@@ -329,14 +329,14 @@ The radio item's name.
329
329
 
330
330
  ##### `onChange`
331
331
 
332
- - Type: `BivariantCallback<(event: ChangeEvent<HTMLInputElement, Element>) => void>`
332
+ - Type: `BivariantCallback<(event: ChangeEvent<HTMLInputElement>) => void>`
333
333
  - Required: No
334
334
 
335
335
  A function that is called when the checkbox's checked state changes.
336
336
 
337
337
  ##### `render`
338
338
 
339
- - Type: `ReactElement<unknown, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
339
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
340
340
  - Required: No
341
341
 
342
342
  Allows the component to be rendered as a different HTML element or React
@@ -427,14 +427,14 @@ The checkbox menu item's name.
427
427
 
428
428
  ##### `onChange`
429
429
 
430
- - Type: `ChangeEventHandler<HTMLInputElement, HTMLInputElement>`
430
+ - Type: `ChangeEventHandler<HTMLInputElement>`
431
431
  - Required: No
432
432
 
433
433
  A function that is called when the checkbox's checked state changes.
434
434
 
435
435
  ##### `render`
436
436
 
437
- - Type: `ReactElement<unknown, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
437
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
438
438
  - Required: No
439
439
 
440
440
  Allows the component to be rendered as a different HTML element or React
@@ -575,7 +575,7 @@ The contents of the menu item's prefix, such as an icon.
575
575
 
576
576
  ##### `render`
577
577
 
578
- - Type: `ReactElement<unknown, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
578
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
579
579
  - Required: No
580
580
 
581
581
  Allows the component to be rendered as a different HTML element or React
@@ -33,6 +33,7 @@ const meta: Meta< typeof Menu > = {
33
33
  Group: Menu.Group,
34
34
  GroupLabel: Menu.GroupLabel,
35
35
  Separator: Menu.Separator,
36
+ // @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
36
37
  Context: Menu.Context,
37
38
  RadioItem: Menu.RadioItem,
38
39
  ItemLabel: Menu.ItemLabel,
@@ -199,7 +199,7 @@ const UnforwardedPopover = (
199
199
  } );
200
200
  }
201
201
 
202
- const arrowRef = useRef< HTMLElement >( null );
202
+ const arrowRef = useRef< HTMLElement | null >( null );
203
203
 
204
204
  const [ fallbackReferenceElement, setFallbackReferenceElement ] =
205
205
  useState< HTMLSpanElement | null >( null );
@@ -1,6 +1,6 @@
1
1
  import type { Placement } from '@floating-ui/react-dom';
2
2
  import type { useFocusOnMount } from '@wordpress/compose';
3
- import type { RefObject, ReactNode, SyntheticEvent } from 'react';
3
+ import type { MutableRefObject, ReactNode, SyntheticEvent } from 'react';
4
4
 
5
5
  type PositionYAxis = 'top' | 'middle' | 'bottom';
6
6
  type PositionXAxis = 'left' | 'center' | 'right';
@@ -12,7 +12,9 @@ type DomRectWithOwnerDocument = DOMRect & {
12
12
 
13
13
  type PopoverPlacement = Placement | 'overlay';
14
14
 
15
- export type PopoverAnchorRefReference = RefObject< Element | null | undefined >;
15
+ export type PopoverAnchorRefReference = MutableRefObject<
16
+ Element | null | undefined
17
+ >;
16
18
  export type PopoverAnchorRefTopBottom = { top: Element; bottom: Element };
17
19
 
18
20
  export type VirtualElement = Pick< Element, 'getBoundingClientRect' > & {
@@ -149,7 +149,7 @@ export type RangeControlProps = Pick<
149
149
  *
150
150
  * @default () => void
151
151
  */
152
- onChange?: ( value: number | undefined ) => void;
152
+ onChange?: ( value?: number ) => void;
153
153
  /**
154
154
  * Callback for when `RangeControl` input gains focus.
155
155
  *
@@ -45,20 +45,16 @@ function ResponsiveWrapper( {
45
45
  aspectRatio = `${ naturalWidth } / ${ naturalHeight }`;
46
46
  }
47
47
 
48
- const ch = children as React.ReactElement<
49
- Pick< React.HTMLAttributes< Element >, 'className' | 'style' >
50
- >;
51
-
52
48
  return (
53
49
  <TagName className="components-responsive-wrapper">
54
50
  <div>
55
- { cloneElement( ch, {
51
+ { cloneElement( children, {
56
52
  className: clsx(
57
53
  'components-responsive-wrapper__content',
58
- ch.props.className
54
+ children.props.className
59
55
  ),
60
56
  style: {
61
- ...ch.props.style,
57
+ ...children.props.style,
62
58
  aspectRatio,
63
59
  },
64
60
  } ) }
@@ -61,7 +61,7 @@ The icon to render in the snackbar.
61
61
  - Required: No
62
62
  - Default: `null`
63
63
 
64
- #### `listRef`: `RefObject< HTMLDivElement | null >`
64
+ #### `listRef`: `MutableRefObject< HTMLDivElement | null >`
65
65
 
66
66
  A ref to the list that contains the snackbar.
67
67
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import type { RefObject, ReactNode } from 'react';
4
+ import type { MutableRefObject, ReactNode } from 'react';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -25,7 +25,7 @@ type SnackbarOnlyProps = {
25
25
  /**
26
26
  * A ref to the list that contains the snackbar.
27
27
  */
28
- listRef?: RefObject< HTMLDivElement | null >;
28
+ listRef?: MutableRefObject< HTMLDivElement | null >;
29
29
  };
30
30
 
31
31
  export type SnackbarProps = Pick<
@@ -164,7 +164,7 @@ still be accessed via the keyboard when navigating through the tablist.
164
164
 
165
165
  ##### `render`
166
166
 
167
- - Type: `RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }> | ReactElement<unknown, string | JSXElementConstructor<any>>`
167
+ - Type: `RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }> | ReactElement<any, string | JSXElementConstructor<any>>`
168
168
  - Required: No
169
169
 
170
170
  Allows the component to be rendered as a different HTML element or React
@@ -16,6 +16,7 @@ const meta: Meta< typeof Tabs > = {
16
16
  'Tabs.TabList': Tabs.TabList,
17
17
  'Tabs.Tab': Tabs.Tab,
18
18
  'Tabs.TabPanel': Tabs.TabPanel,
19
+ // @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
19
20
  'Tabs.Context': Tabs.Context,
20
21
  },
21
22
  tags: [ 'status-private' ],
@@ -133,7 +133,7 @@ export const TabList = forwardRef<
133
133
  <StyledTabList
134
134
  ref={ refs }
135
135
  store={ store }
136
- render={ ( props: React.HTMLAttributes< HTMLDivElement > ) => (
136
+ render={ ( props ) => (
137
137
  <div
138
138
  { ...props }
139
139
  // Fallback to -1 to prevent browsers from making the tablist
@@ -93,13 +93,7 @@ function UnforwardedTooltip(
93
93
  // `aria-label`
94
94
  // See: https://github.com/WordPress/gutenberg/pull/64066
95
95
  // See: https://github.com/WordPress/gutenberg/pull/65989
96
- function addDescribedById( el: React.ReactElement ) {
97
- const element = el as React.ReactElement<
98
- Pick<
99
- React.HTMLAttributes< Element >,
100
- 'aria-describedby' | 'aria-label'
101
- >
102
- >;
96
+ function addDescribedById( element: React.ReactElement ) {
103
97
  return describedById &&
104
98
  mounted &&
105
99
  element.props[ 'aria-describedby' ] === undefined &&
@@ -34,6 +34,7 @@ describe( 'TreeGridCell', () => {
34
34
  </TreeGridCell>
35
35
  )
36
36
  ).toThrow();
37
+ expect( console ).toHaveErrored();
37
38
  } );
38
39
 
39
40
  it( 'uses a child render function to render children', () => {
@@ -26,6 +26,7 @@ describe( 'RovingTabIndexItem', () => {
26
26
  expect( () =>
27
27
  render( <RovingTabIndexItem as={ TestButton } /> )
28
28
  ).toThrow();
29
+ expect( console ).toHaveErrored();
29
30
  } );
30
31
 
31
32
  it( 'allows another component to be specified as the rendered component using the `as` prop', () => {
@@ -118,7 +118,7 @@ If this property is added, an option will be added with this label to represent
118
118
 
119
119
  ### `onChange`
120
120
 
121
- - Type: `((value: string, extra?: { event?: ChangeEvent<HTMLSelectElement, Element>; }) => void) | undefined`
121
+ - Type: `((value: string, extra?: { event?: ChangeEvent<HTMLSelectElement>; }) => void) | undefined`
122
122
  - Required: No
123
123
 
124
124
  A function that receives the value of the new option that is being selected as input.
@@ -12,13 +12,7 @@ const getNodeText = ( node: React.ReactNode ): string => {
12
12
  return node.map( getNodeText ).join( '' );
13
13
  }
14
14
  if ( 'props' in node ) {
15
- return getNodeText(
16
- (
17
- node as React.ReactElement<
18
- React.PropsWithChildren< unknown >
19
- >
20
- ).props.children
21
- );
15
+ return getNodeText( node.props.children );
22
16
  }
23
17
  return '';
24
18
  }
@@ -60,12 +60,7 @@ type ValidityTarget =
60
60
  | HTMLSelectElement
61
61
  | HTMLTextAreaElement;
62
62
 
63
- function UnforwardedControlWithError<
64
- C extends React.ReactElement< {
65
- label: React.ReactNode;
66
- required: boolean;
67
- } >,
68
- >(
63
+ function UnforwardedControlWithError< C extends React.ReactElement >(
69
64
  {
70
65
  required,
71
66
  markWhenOptional,