@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.
- package/CHANGELOG.md +6 -1
- package/build/border-control/border-control-dropdown/component.cjs +33 -33
- package/build/border-control/border-control-dropdown/component.cjs.map +3 -3
- package/build/disabled/index.cjs +1 -1
- package/build/disabled/index.cjs.map +2 -2
- package/build/higher-order/with-notices/index.cjs +15 -3
- package/build/higher-order/with-notices/index.cjs.map +2 -2
- package/build/input-control/input-base.cjs +34 -31
- package/build/input-control/input-base.cjs.map +2 -2
- package/build/responsive-wrapper/index.cjs +3 -4
- package/build/responsive-wrapper/index.cjs.map +2 -2
- package/build/tooltip/index.cjs +1 -2
- package/build/tooltip/index.cjs.map +2 -2
- package/build-module/border-control/border-control-dropdown/component.mjs +34 -34
- package/build-module/border-control/border-control-dropdown/component.mjs.map +2 -2
- package/build-module/disabled/index.mjs +1 -1
- package/build-module/disabled/index.mjs.map +2 -2
- package/build-module/higher-order/with-notices/index.mjs +16 -4
- package/build-module/higher-order/with-notices/index.mjs.map +2 -2
- package/build-module/input-control/input-base.mjs +34 -31
- package/build-module/input-control/input-base.mjs.map +2 -2
- package/build-module/responsive-wrapper/index.mjs +3 -4
- package/build-module/responsive-wrapper/index.mjs.map +2 -2
- package/build-module/tooltip/index.mjs +1 -2
- package/build-module/tooltip/index.mjs.map +2 -2
- package/build-types/border-box-control/border-box-control/hook.d.ts +10 -24
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +12 -26
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +10 -24
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +11 -25
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +10 -24
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +9 -23
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +2 -2
- package/build-types/card/card/hook.d.ts +11 -25
- package/build-types/card/card/hook.d.ts.map +1 -1
- package/build-types/card/card-body/hook.d.ts +11 -25
- package/build-types/card/card-body/hook.d.ts.map +1 -1
- package/build-types/card/card-divider/hook.d.ts +12 -26
- package/build-types/card/card-divider/hook.d.ts.map +1 -1
- package/build-types/card/card-footer/hook.d.ts +11 -25
- package/build-types/card/card-footer/hook.d.ts.map +1 -1
- package/build-types/card/card-header/hook.d.ts +11 -25
- package/build-types/card/card-header/hook.d.ts.map +1 -1
- package/build-types/card/card-media/hook.d.ts +11 -25
- package/build-types/card/card-media/hook.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +2 -2
- package/build-types/composite/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/styles.d.ts +12 -4
- package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
- package/build-types/date-time/time-picker/styles.d.ts +4 -4
- package/build-types/elevation/hook.d.ts +11 -25
- package/build-types/elevation/hook.d.ts.map +1 -1
- package/build-types/flex/flex/hook.d.ts +11 -25
- package/build-types/flex/flex/hook.d.ts.map +1 -1
- package/build-types/flex/flex-block/hook.d.ts +11 -25
- package/build-types/flex/flex-block/hook.d.ts.map +1 -1
- package/build-types/flex/flex-item/hook.d.ts +11 -25
- package/build-types/flex/flex-item/hook.d.ts.map +1 -1
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/grid/hook.d.ts +11 -25
- package/build-types/grid/hook.d.ts.map +1 -1
- package/build-types/h-stack/hook.d.ts +11 -25
- package/build-types/h-stack/hook.d.ts.map +1 -1
- package/build-types/heading/hook.d.ts +11 -25
- package/build-types/heading/hook.d.ts.map +1 -1
- package/build-types/higher-order/with-fallback-styles/index.d.ts +3 -1
- package/build-types/higher-order/with-filters/index.d.ts +6 -1
- package/build-types/higher-order/with-filters/index.d.ts.map +1 -1
- package/build-types/higher-order/with-notices/index.d.ts +4 -2
- package/build-types/higher-order/with-notices/index.d.ts.map +1 -1
- package/build-types/input-control/reducer/reducer.d.ts +1 -1
- package/build-types/item-group/item/hook.d.ts +11 -25
- package/build-types/item-group/item/hook.d.ts.map +1 -1
- package/build-types/item-group/item-group/hook.d.ts +11 -25
- package/build-types/item-group/item-group/hook.d.ts.map +1 -1
- package/build-types/menu/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/styles.d.ts +21 -7
- package/build-types/menu/styles.d.ts.map +1 -1
- package/build-types/modal/use-modal-exit-animation.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +12 -26
- package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +12 -26
- package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts +1 -1
- package/build-types/number-control/stories/index.story.d.ts.map +1 -1
- package/build-types/popover/types.d.ts +2 -2
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
- package/build-types/range-control/types.d.ts +1 -1
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/responsive-wrapper/index.d.ts.map +1 -1
- package/build-types/scrollable/hook.d.ts +11 -25
- package/build-types/scrollable/hook.d.ts.map +1 -1
- package/build-types/snackbar/index.d.ts +2 -2
- package/build-types/snackbar/types.d.ts +2 -2
- package/build-types/snackbar/types.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +11 -25
- package/build-types/spacer/hook.d.ts.map +1 -1
- package/build-types/surface/hook.d.ts +11 -25
- package/build-types/surface/hook.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts +9 -3
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +11 -25
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +11 -25
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +11 -25
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +11 -25
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +11 -25
- package/build-types/truncate/hook.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
- package/build-types/utils/get-node-text.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +11 -25
- package/build-types/v-stack/hook.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/number-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts +1 -1
- package/build-types/validated-form-controls/control-with-error.d.ts +1 -4
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
- package/package.json +26 -26
- package/src/autocomplete/README.md +1 -1
- package/src/border-control/border-control-dropdown/component.tsx +37 -36
- package/src/composite/stories/index.story.tsx +1 -0
- package/src/disabled/index.tsx +1 -1
- package/src/form-file-upload/README.md +1 -1
- package/src/h-stack/hook.tsx +1 -1
- package/src/higher-order/with-notices/index.tsx +21 -4
- package/src/higher-order/with-notices/test/index.tsx +18 -0
- package/src/input-control/input-base.tsx +2 -2
- package/src/menu/README.md +7 -7
- package/src/menu/stories/index.story.tsx +1 -0
- package/src/popover/index.tsx +1 -1
- package/src/popover/types.ts +4 -2
- package/src/range-control/types.ts +1 -1
- package/src/responsive-wrapper/index.tsx +3 -7
- package/src/snackbar/README.md +1 -1
- package/src/snackbar/types.ts +2 -2
- package/src/tabs/README.md +1 -1
- package/src/tabs/stories/index.story.tsx +1 -0
- package/src/tabs/tablist.tsx +1 -1
- package/src/tooltip/index.tsx +1 -7
- package/src/tree-grid/test/cell.tsx +1 -0
- package/src/tree-grid/test/roving-tab-index-item.tsx +1 -0
- package/src/tree-select/README.md +1 -1
- package/src/utils/get-node-text.ts +1 -7
- 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: {
|
package/src/disabled/index.tsx
CHANGED
|
@@ -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
|
|
68
|
+
- Type: `ChangeEventHandler<HTMLInputElement> | undefined`
|
|
69
69
|
- Required: Yes
|
|
70
70
|
|
|
71
71
|
Callback function passed directly to the `input` file element.
|
package/src/h-stack/hook.tsx
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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?:
|
|
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 ) }
|
package/src/menu/README.md
CHANGED
|
@@ -120,7 +120,7 @@ make disabled elements still accessible via keyboard.
|
|
|
120
120
|
|
|
121
121
|
##### `render`
|
|
122
122
|
|
|
123
|
-
- Type: `ReactElement<
|
|
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<
|
|
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
|
|
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<
|
|
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
|
|
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<
|
|
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<
|
|
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,
|
package/src/popover/index.tsx
CHANGED
|
@@ -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 );
|
package/src/popover/types.ts
CHANGED
|
@@ -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 {
|
|
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 =
|
|
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' > & {
|
|
@@ -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(
|
|
51
|
+
{ cloneElement( children, {
|
|
56
52
|
className: clsx(
|
|
57
53
|
'components-responsive-wrapper__content',
|
|
58
|
-
|
|
54
|
+
children.props.className
|
|
59
55
|
),
|
|
60
56
|
style: {
|
|
61
|
-
...
|
|
57
|
+
...children.props.style,
|
|
62
58
|
aspectRatio,
|
|
63
59
|
},
|
|
64
60
|
} ) }
|
package/src/snackbar/README.md
CHANGED
package/src/snackbar/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
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?:
|
|
28
|
+
listRef?: MutableRefObject< HTMLDivElement | null >;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export type SnackbarProps = Pick<
|
package/src/tabs/README.md
CHANGED
|
@@ -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<
|
|
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' ],
|
package/src/tabs/tablist.tsx
CHANGED
|
@@ -133,7 +133,7 @@ export const TabList = forwardRef<
|
|
|
133
133
|
<StyledTabList
|
|
134
134
|
ref={ refs }
|
|
135
135
|
store={ store }
|
|
136
|
-
render={ ( props
|
|
136
|
+
render={ ( props ) => (
|
|
137
137
|
<div
|
|
138
138
|
{ ...props }
|
|
139
139
|
// Fallback to -1 to prevent browsers from making the tablist
|
package/src/tooltip/index.tsx
CHANGED
|
@@ -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(
|
|
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 &&
|
|
@@ -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
|
|
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,
|