@wordpress/components 19.8.3 → 19.10.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 +42 -0
- package/CONTRIBUTING.md +80 -7
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build/angle-picker-control/angle-circle.js +5 -7
- package/build/angle-picker-control/angle-circle.js.map +1 -1
- package/build/box-control/index.js +0 -21
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/utils.js +1 -8
- package/build/box-control/utils.js.map +1 -1
- package/build/button/index.js +3 -5
- package/build/button/index.js.map +1 -1
- package/build/circular-option-picker/index.js +1 -2
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/disabled/index.js +4 -76
- package/build/disabled/index.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/input-control/index.js +27 -4
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +42 -30
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +1 -0
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/navigation/styles/navigation-styles.js +12 -12
- package/build/navigation/styles/navigation-styles.js.map +1 -1
- package/build/notice/index.native.js +44 -40
- package/build/notice/index.native.js.map +1 -1
- package/build/notice/list.native.js +27 -45
- package/build/notice/list.native.js.map +1 -1
- package/build/popover/index.js +6 -52
- package/build/popover/index.js.map +1 -1
- package/build/sandbox/index.js +2 -2
- package/build/sandbox/index.js.map +1 -1
- package/build/select-control/index.js +31 -4
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +8 -8
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/surface/styles.js +8 -8
- package/build/surface/styles.js.map +1 -1
- package/build/text/hook.js +5 -5
- package/build/text/hook.js.map +1 -1
- package/build/text/styles/text-mixins.native.js +1 -1
- package/build/text/styles/text-mixins.native.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/text-control/index.js +35 -28
- package/build/text-control/index.js.map +1 -1
- package/build/text-control/types.js +6 -0
- package/build/text-control/types.js.map +1 -0
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js +6 -4
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +52 -36
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/ui/spinner/component.js +1 -1
- package/build/ui/spinner/component.js.map +1 -1
- package/build/unit-control/index.js +3 -3
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +11 -20
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/unit-control/utils.js.map +1 -1
- package/build/utils/colors-values.js +9 -24
- package/build/utils/colors-values.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build-module/angle-picker-control/angle-circle.js +5 -7
- package/build-module/angle-picker-control/angle-circle.js.map +1 -1
- package/build-module/box-control/index.js +1 -20
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/utils.js +0 -6
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button/index.js +3 -4
- package/build-module/button/index.js.map +1 -1
- package/build-module/circular-option-picker/index.js +1 -2
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/disabled/index.js +5 -76
- package/build-module/disabled/index.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/input-control/index.js +24 -3
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +42 -30
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +1 -0
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/navigation/styles/navigation-styles.js +13 -13
- package/build-module/navigation/styles/navigation-styles.js.map +1 -1
- package/build-module/notice/index.native.js +45 -41
- package/build-module/notice/index.native.js.map +1 -1
- package/build-module/notice/list.native.js +28 -46
- package/build-module/notice/list.native.js.map +1 -1
- package/build-module/popover/index.js +6 -52
- package/build-module/popover/index.js.map +1 -1
- package/build-module/sandbox/index.js +2 -2
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/select-control/index.js +29 -3
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +8 -8
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/surface/styles.js +8 -8
- package/build-module/surface/styles.js.map +1 -1
- package/build-module/text/hook.js +5 -5
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/styles/text-mixins.native.js +2 -2
- package/build-module/text/styles/text-mixins.native.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/text-control/index.js +35 -27
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/text-control/types.js +2 -0
- package/build-module/text-control/types.js.map +1 -0
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -5
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +51 -36
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/ui/spinner/component.js +1 -1
- package/build-module/ui/spinner/component.js.map +1 -1
- package/build-module/unit-control/index.js +3 -3
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +11 -20
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-module/utils/colors-values.js +19 -23
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-style/style-rtl.css +24 -0
- package/build-style/style.css +24 -0
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -3
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +23 -3
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/stories/index.d.ts +5 -5
- package/build-types/input-control/styles/input-control-styles.d.ts +1 -0
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +79 -3
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/popover/index.d.ts +0 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +30 -26
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/stories/index.d.ts +23 -0
- package/build-types/select-control/stories/index.d.ts.map +1 -0
- package/build-types/select-control/styles/select-control-styles.d.ts +3 -4
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/test/select-control.d.ts +2 -0
- package/build-types/select-control/test/select-control.d.ts.map +1 -0
- package/build-types/select-control/types.d.ts +52 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +32 -0
- package/build-types/text-control/index.d.ts.map +1 -0
- package/build-types/text-control/stories/index.d.ts +13 -0
- package/build-types/text-control/stories/index.d.ts.map +1 -0
- package/build-types/text-control/types.d.ts +25 -0
- package/build-types/text-control/types.d.ts.map +1 -0
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +0 -1
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +2 -2
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/test/index.d.ts +2 -0
- package/build-types/unit-control/test/index.d.ts.map +1 -0
- package/build-types/unit-control/test/utils.d.ts +2 -0
- package/build-types/unit-control/test/utils.d.ts.map +1 -0
- package/build-types/unit-control/types.d.ts +1 -1
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/unit-control/utils.d.ts +3 -3
- package/build-types/unit-control/utils.d.ts.map +1 -1
- package/build-types/utils/colors-values.d.ts +6 -146
- package/build-types/utils/colors-values.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
- package/src/angle-picker-control/angle-circle.js +3 -3
- package/src/box-control/README.md +0 -74
- package/src/box-control/index.js +0 -15
- package/src/box-control/stories/index.js +0 -29
- package/src/box-control/utils.js +0 -7
- package/src/button/index.js +2 -4
- package/src/button/test/index.js +16 -1
- package/src/circular-option-picker/index.js +1 -2
- package/src/color-palette/README.md +0 -1
- package/src/color-palette/test/__snapshots__/index.js.snap +2 -3
- package/src/confirm-dialog/stories/index.js +87 -99
- package/src/date-time/stories/index.js +19 -0
- package/src/date-time/test/date.js +107 -78
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
- package/src/disabled/index.js +5 -90
- package/src/form-file-upload/test/index.js +15 -12
- package/src/heading/hook.ts +1 -1
- package/src/heading/test/__snapshots__/index.js.snap +3 -3
- package/src/input-control/README.md +3 -3
- package/src/input-control/index.tsx +23 -3
- package/src/input-control/stories/index.tsx +63 -0
- package/src/input-control/styles/input-control-styles.tsx +20 -7
- package/src/input-control/types.ts +79 -2
- package/src/menu-item/style.scss +10 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +8 -1
- package/src/mobile/bottom-sheet-select-control/index.native.js +1 -0
- package/src/mobile/html-text-input/style.android.scss +1 -0
- package/src/mobile/html-text-input/style.ios.scss +1 -0
- package/src/mobile/link-settings/test/link-settings-navigation.native.js +9 -1
- package/src/navigation/styles/navigation-styles.js +5 -5
- package/src/notice/index.native.js +44 -54
- package/src/notice/list.native.js +27 -51
- package/src/notice/style.native.scss +1 -0
- package/src/popover/index.js +5 -51
- package/src/query-controls/README.md +2 -2
- package/src/sandbox/index.js +2 -2
- package/src/select-control/README.md +2 -2
- package/src/select-control/index.tsx +30 -29
- package/src/select-control/stories/index.tsx +90 -0
- package/src/select-control/styles/select-control-styles.ts +10 -9
- package/src/select-control/test/{select-control.js → select-control.tsx} +2 -2
- package/src/select-control/types.ts +66 -1
- package/src/surface/styles.js +1 -1
- package/src/text/hook.js +1 -1
- package/src/text/styles/text-mixins.native.js +2 -2
- package/src/text/styles.js +1 -1
- package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
- package/src/text/test/{index.js → index.tsx} +12 -6
- package/src/text-control/index.tsx +84 -0
- package/src/text-control/stories/index.tsx +66 -0
- package/src/text-control/types.ts +29 -0
- package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -5
- package/src/toolbar-group/style.scss +20 -0
- package/src/tools-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/tools-panel/test/index.js +71 -18
- package/src/tools-panel/tools-panel-header/component.tsx +75 -33
- package/src/tools-panel/types.ts +0 -1
- package/src/tooltip/test/index.js +6 -0
- package/src/ui/spinner/component.js +1 -1
- package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
- package/src/unit-control/index.tsx +2 -5
- package/src/unit-control/styles/unit-control-styles.ts +3 -13
- package/src/unit-control/test/__snapshots__/index.tsx.snap +33 -0
- package/src/unit-control/test/{index.js → index.tsx} +214 -165
- package/src/unit-control/test/{utils.js → utils.ts} +38 -19
- package/src/unit-control/types.ts +4 -1
- package/src/unit-control/utils.ts +5 -3
- package/src/utils/colors-values.js +18 -22
- package/tsconfig.json +9 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/box-control/visualizer.js +0 -165
- package/build/box-control/visualizer.js.map +0 -1
- package/build-module/box-control/visualizer.js +0 -154
- package/build-module/box-control/visualizer.js.map +0 -1
- package/src/box-control/visualizer.js +0 -116
- package/src/input-control/stories/index.js +0 -71
- package/src/select-control/stories/index.js +0 -104
- package/src/text-control/index.js +0 -72
- package/src/text-control/stories/index.js +0 -46
|
@@ -59,14 +59,20 @@ describe( 'Text', () => {
|
|
|
59
59
|
|
|
60
60
|
test( 'should render as another element', () => {
|
|
61
61
|
const { container } = render( <Text as="div">Lorem ipsum.</Text> );
|
|
62
|
-
expect( container.firstChild
|
|
62
|
+
expect( container.firstChild?.nodeName ).toBe( 'DIV' );
|
|
63
63
|
} );
|
|
64
64
|
|
|
65
65
|
test( 'should render align', () => {
|
|
66
|
-
const { container } = render(
|
|
66
|
+
const { container: centerAlignedContainer } = render(
|
|
67
67
|
<Text align="center">Lorem ipsum.</Text>
|
|
68
68
|
);
|
|
69
|
-
|
|
69
|
+
const { container: defaultAlignedContainer } = render(
|
|
70
|
+
<Text>Lorem ipsum.</Text>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(
|
|
74
|
+
defaultAlignedContainer.children[ 0 ]
|
|
75
|
+
).toMatchStyleDiffSnapshot( centerAlignedContainer.children[ 0 ] );
|
|
70
76
|
} );
|
|
71
77
|
|
|
72
78
|
test( 'should render color', () => {
|
|
@@ -89,7 +95,7 @@ describe( 'Text', () => {
|
|
|
89
95
|
const wrapper = render(
|
|
90
96
|
<Text highlightWords={ [ 'm' ] }>Lorem ipsum.</Text>
|
|
91
97
|
);
|
|
92
|
-
expect( wrapper.container.firstChild
|
|
98
|
+
expect( wrapper.container.firstChild?.childNodes ).toHaveLength( 5 );
|
|
93
99
|
const words = await wrapper.findAllByText( 'm' );
|
|
94
100
|
expect( words ).toHaveLength( 2 );
|
|
95
101
|
words.forEach( ( word ) => expect( word.tagName ).toEqual( 'MARK' ) );
|
|
@@ -100,7 +106,7 @@ describe( 'Text', () => {
|
|
|
100
106
|
<Text highlightWords={ undefined }>Lorem ipsum.</Text>
|
|
101
107
|
);
|
|
102
108
|
// It'll have a length of 1 because there shouldn't be anything but the single span being rendered.
|
|
103
|
-
expect( container.firstChild
|
|
109
|
+
expect( container.firstChild?.childNodes ).toHaveLength( 1 );
|
|
104
110
|
} );
|
|
105
111
|
|
|
106
112
|
test( 'should render highlighted words with highlightCaseSensitive', () => {
|
|
@@ -112,7 +118,7 @@ describe( 'Text', () => {
|
|
|
112
118
|
|
|
113
119
|
expect( container.firstChild ).toMatchSnapshot();
|
|
114
120
|
// It'll have a length of 1 because there shouldn't be anything but the single span being rendered.
|
|
115
|
-
expect( container.firstChild
|
|
121
|
+
expect( container.firstChild?.childNodes ).toHaveLength( 1 );
|
|
116
122
|
} );
|
|
117
123
|
|
|
118
124
|
test( 'should render isBlock', () => {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ChangeEvent, ForwardedRef } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
10
|
+
import { forwardRef } from '@wordpress/element';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import BaseControl from '../base-control';
|
|
16
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
17
|
+
import type { TextControlProps } from './types';
|
|
18
|
+
|
|
19
|
+
function UnforwardedTextControl(
|
|
20
|
+
props: WordPressComponentProps< TextControlProps, 'input', false >,
|
|
21
|
+
ref: ForwardedRef< HTMLInputElement >
|
|
22
|
+
) {
|
|
23
|
+
const {
|
|
24
|
+
label,
|
|
25
|
+
hideLabelFromVision,
|
|
26
|
+
value,
|
|
27
|
+
help,
|
|
28
|
+
className,
|
|
29
|
+
onChange,
|
|
30
|
+
type = 'text',
|
|
31
|
+
...additionalProps
|
|
32
|
+
} = props;
|
|
33
|
+
const instanceId = useInstanceId( TextControl );
|
|
34
|
+
const id = `inspector-text-control-${ instanceId }`;
|
|
35
|
+
const onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) =>
|
|
36
|
+
onChange( event.target.value );
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<BaseControl
|
|
40
|
+
label={ label }
|
|
41
|
+
hideLabelFromVision={ hideLabelFromVision }
|
|
42
|
+
id={ id }
|
|
43
|
+
help={ help }
|
|
44
|
+
className={ className }
|
|
45
|
+
>
|
|
46
|
+
<input
|
|
47
|
+
className="components-text-control__input"
|
|
48
|
+
type={ type }
|
|
49
|
+
id={ id }
|
|
50
|
+
value={ value }
|
|
51
|
+
onChange={ onChangeValue }
|
|
52
|
+
aria-describedby={ !! help ? id + '__help' : undefined }
|
|
53
|
+
ref={ ref }
|
|
54
|
+
{ ...additionalProps }
|
|
55
|
+
/>
|
|
56
|
+
</BaseControl>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* TextControl components let users enter and edit text.
|
|
62
|
+
*
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```jsx
|
|
66
|
+
* import { TextControl } from '@wordpress/components';
|
|
67
|
+
* import { useState } from '@wordpress/element';
|
|
68
|
+
*
|
|
69
|
+
* const MyTextControl = () => {
|
|
70
|
+
* const [ className, setClassName ] = useState( '' );
|
|
71
|
+
*
|
|
72
|
+
* return (
|
|
73
|
+
* <TextControl
|
|
74
|
+
* label="Additional CSS Class"
|
|
75
|
+
* value={ className }
|
|
76
|
+
* onChange={ ( value ) => setClassName( value ) }
|
|
77
|
+
* />
|
|
78
|
+
* );
|
|
79
|
+
* };
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export const TextControl = forwardRef( UnforwardedTextControl );
|
|
83
|
+
|
|
84
|
+
export default TextControl;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import TextControl from '..';
|
|
15
|
+
|
|
16
|
+
const meta: ComponentMeta< typeof TextControl > = {
|
|
17
|
+
component: TextControl,
|
|
18
|
+
title: 'Components/TextControl',
|
|
19
|
+
argTypes: {
|
|
20
|
+
onChange: {
|
|
21
|
+
action: 'onChange',
|
|
22
|
+
},
|
|
23
|
+
value: {
|
|
24
|
+
control: { type: null },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
parameters: {
|
|
28
|
+
controls: {
|
|
29
|
+
expanded: true,
|
|
30
|
+
},
|
|
31
|
+
docs: { source: { state: 'open' } },
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export default meta;
|
|
35
|
+
|
|
36
|
+
const DefaultTemplate: ComponentStory< typeof TextControl > = ( {
|
|
37
|
+
onChange,
|
|
38
|
+
...args
|
|
39
|
+
} ) => {
|
|
40
|
+
const [ value, setValue ] = useState( '' );
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<TextControl
|
|
44
|
+
{ ...args }
|
|
45
|
+
value={ value }
|
|
46
|
+
onChange={ ( v ) => {
|
|
47
|
+
setValue( v );
|
|
48
|
+
onChange( v );
|
|
49
|
+
} }
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Default: ComponentStory<
|
|
55
|
+
typeof TextControl
|
|
56
|
+
> = DefaultTemplate.bind( {} );
|
|
57
|
+
Default.args = {};
|
|
58
|
+
|
|
59
|
+
export const WithLabelAndHelpText: ComponentStory<
|
|
60
|
+
typeof TextControl
|
|
61
|
+
> = DefaultTemplate.bind( {} );
|
|
62
|
+
WithLabelAndHelpText.args = {
|
|
63
|
+
...Default.args,
|
|
64
|
+
label: 'Label Text',
|
|
65
|
+
help: 'Help text to explain the input.',
|
|
66
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { HTMLInputTypeAttribute } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { BaseControlProps } from '../base-control/types';
|
|
10
|
+
|
|
11
|
+
export type TextControlProps = Pick<
|
|
12
|
+
BaseControlProps,
|
|
13
|
+
'className' | 'hideLabelFromVision' | 'help' | 'label'
|
|
14
|
+
> & {
|
|
15
|
+
/**
|
|
16
|
+
* A function that receives the value of the input.
|
|
17
|
+
*/
|
|
18
|
+
onChange: ( value: string ) => void;
|
|
19
|
+
/**
|
|
20
|
+
* The current value of the input.
|
|
21
|
+
*/
|
|
22
|
+
value: string | number;
|
|
23
|
+
/**
|
|
24
|
+
* Type of the input element to render. Defaults to "text".
|
|
25
|
+
*
|
|
26
|
+
* @default 'text'
|
|
27
|
+
*/
|
|
28
|
+
type?: HTMLInputTypeAttribute;
|
|
29
|
+
};
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Icon } from '@wordpress/icons';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
9
4
|
import type { WordPressComponentProps } from '../../ui/context';
|
|
10
5
|
import type { ToggleGroupControlOptionIconProps } from '../types';
|
|
11
6
|
import { ToggleGroupControlOptionBase } from '../toggle-group-control-option-base';
|
|
7
|
+
import Icon from '../../icon';
|
|
12
8
|
|
|
13
9
|
export default function ToggleGroupControlOptionIcon(
|
|
14
10
|
props: WordPressComponentProps<
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
display: inline-flex;
|
|
6
6
|
flex-shrink: 0;
|
|
7
7
|
flex-wrap: wrap;
|
|
8
|
+
padding-left: $grid-unit-15 * 0.5; // 6px.
|
|
9
|
+
padding-right: $grid-unit-15 * 0.5;
|
|
8
10
|
|
|
9
11
|
// Unset for nested toolbar groups. Increase specificity.
|
|
10
12
|
& .components-toolbar-group.components-toolbar-group {
|
|
@@ -13,6 +15,24 @@
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
line-height: 0;
|
|
18
|
+
|
|
19
|
+
// Size multiple sequential buttons to be optically balanced.
|
|
20
|
+
// Icons are 36px, as set by a 24px icon and 12px padding.
|
|
21
|
+
.components-button.components-button, // This needs specificity to override padding values inherited from the button component.
|
|
22
|
+
.components-button.has-icon.has-icon {
|
|
23
|
+
min-width: $block-toolbar-height - $grid-unit-15;
|
|
24
|
+
padding-left: $grid-unit-15 * 0.5; // 6px.
|
|
25
|
+
padding-right: $grid-unit-15 * 0.5;
|
|
26
|
+
|
|
27
|
+
svg {
|
|
28
|
+
min-width: $button-size-small; // This is the optimal icon size, and we size the whole button after this.
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&::before {
|
|
32
|
+
left: 2px;
|
|
33
|
+
right: 2px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
16
36
|
}
|
|
17
37
|
|
|
18
38
|
// Legacy toolbar group
|
|
@@ -64,7 +64,7 @@ exports[`ToolsPanel first and last panel items should apply first/last classes t
|
|
|
64
64
|
color: #1e1e1e;
|
|
65
65
|
line-height: 1.2;
|
|
66
66
|
margin: 0;
|
|
67
|
-
color: #
|
|
67
|
+
color: #1e1e1e;
|
|
68
68
|
font-size: calc(1.95 * 13px);
|
|
69
69
|
font-weight: 600;
|
|
70
70
|
display: block;
|
|
@@ -167,7 +167,7 @@ exports[`ToolsPanel first and last panel items should apply first/last classes t
|
|
|
167
167
|
<button
|
|
168
168
|
aria-expanded="false"
|
|
169
169
|
aria-haspopup="true"
|
|
170
|
-
aria-label="
|
|
170
|
+
aria-label="Panel header options"
|
|
171
171
|
class="components-button components-dropdown-menu__toggle is-small has-icon"
|
|
172
172
|
type="button"
|
|
173
173
|
>
|
|
@@ -161,7 +161,7 @@ const renderPanel = () => {
|
|
|
161
161
|
*/
|
|
162
162
|
const getMenuButton = () => {
|
|
163
163
|
return screen.getByRole( 'button', {
|
|
164
|
-
name: /
|
|
164
|
+
name: /Panel([\w\s]+)header([\w\s]+)options/i,
|
|
165
165
|
} );
|
|
166
166
|
};
|
|
167
167
|
|
|
@@ -178,7 +178,6 @@ const openDropdownMenu = () => {
|
|
|
178
178
|
|
|
179
179
|
// Opens dropdown then selects the menu item by label before simulating a click.
|
|
180
180
|
const selectMenuItem = async ( label ) => {
|
|
181
|
-
openDropdownMenu();
|
|
182
181
|
const menuItem = await screen.findByText( label );
|
|
183
182
|
fireEvent.click( menuItem );
|
|
184
183
|
};
|
|
@@ -289,18 +288,30 @@ describe( 'ToolsPanel', () => {
|
|
|
289
288
|
|
|
290
289
|
it( 'should render panel item when corresponding menu item is selected', async () => {
|
|
291
290
|
renderPanel();
|
|
291
|
+
await openDropdownMenu();
|
|
292
292
|
await selectMenuItem( altControlProps.label );
|
|
293
293
|
const control = await screen.findByText( 'Alt control' );
|
|
294
294
|
|
|
295
295
|
expect( control ).toBeInTheDocument();
|
|
296
|
+
|
|
297
|
+
// Test the aria live announcement.
|
|
298
|
+
const announcement = await screen.getByText( 'Alt is now visible' );
|
|
299
|
+
expect( announcement ).toHaveAttribute( 'aria-live', 'assertive' );
|
|
296
300
|
} );
|
|
297
301
|
|
|
298
302
|
it( 'should prevent optional panel item rendering when toggled off via menu item', async () => {
|
|
299
303
|
renderPanel();
|
|
304
|
+
await openDropdownMenu();
|
|
300
305
|
await selectMenuItem( controlProps.label );
|
|
301
306
|
const control = screen.queryByText( 'Example control' );
|
|
302
307
|
|
|
303
308
|
expect( control ).not.toBeInTheDocument();
|
|
309
|
+
|
|
310
|
+
// Test the aria live announcement.
|
|
311
|
+
const announcement = await screen.getByText(
|
|
312
|
+
'Example hidden and reset to default'
|
|
313
|
+
);
|
|
314
|
+
expect( announcement ).toHaveAttribute( 'aria-live', 'assertive' );
|
|
304
315
|
} );
|
|
305
316
|
|
|
306
317
|
it( 'should continue to render shown by default item after it is toggled off via menu item', async () => {
|
|
@@ -319,10 +330,17 @@ describe( 'ToolsPanel', () => {
|
|
|
319
330
|
|
|
320
331
|
expect( control ).toBeInTheDocument();
|
|
321
332
|
|
|
333
|
+
await openDropdownMenu();
|
|
322
334
|
await selectMenuItem( controlProps.label );
|
|
323
335
|
const resetControl = screen.getByText( 'Default control' );
|
|
324
336
|
|
|
325
337
|
expect( resetControl ).toBeInTheDocument();
|
|
338
|
+
|
|
339
|
+
// Test the aria live announcement.
|
|
340
|
+
const announcement = await screen.getByText(
|
|
341
|
+
'Example reset to default'
|
|
342
|
+
);
|
|
343
|
+
expect( announcement ).toHaveAttribute( 'aria-live', 'assertive' );
|
|
326
344
|
} );
|
|
327
345
|
|
|
328
346
|
it( 'should render appropriate menu groups', async () => {
|
|
@@ -657,6 +675,8 @@ describe( 'ToolsPanel', () => {
|
|
|
657
675
|
|
|
658
676
|
it( 'should call onDeselect callback when menu item is toggled off', async () => {
|
|
659
677
|
renderPanel();
|
|
678
|
+
|
|
679
|
+
await openDropdownMenu();
|
|
660
680
|
await selectMenuItem( controlProps.label );
|
|
661
681
|
|
|
662
682
|
expect( controlProps.onSelect ).not.toHaveBeenCalled();
|
|
@@ -665,6 +685,8 @@ describe( 'ToolsPanel', () => {
|
|
|
665
685
|
|
|
666
686
|
it( 'should call onSelect callback when menu item is toggled on', async () => {
|
|
667
687
|
renderPanel();
|
|
688
|
+
|
|
689
|
+
await openDropdownMenu();
|
|
668
690
|
await selectMenuItem( altControlProps.label );
|
|
669
691
|
|
|
670
692
|
expect( altControlProps.onSelect ).toHaveBeenCalledTimes( 1 );
|
|
@@ -673,6 +695,8 @@ describe( 'ToolsPanel', () => {
|
|
|
673
695
|
|
|
674
696
|
it( 'should call resetAll callback when its menu item is selected', async () => {
|
|
675
697
|
renderPanel();
|
|
698
|
+
|
|
699
|
+
await openDropdownMenu();
|
|
676
700
|
await selectMenuItem( 'Reset all' );
|
|
677
701
|
|
|
678
702
|
expect( resetAll ).toHaveBeenCalledTimes( 1 );
|
|
@@ -688,6 +712,7 @@ describe( 'ToolsPanel', () => {
|
|
|
688
712
|
it( 'should call onDeselect after previous reset all', async () => {
|
|
689
713
|
renderPanel();
|
|
690
714
|
|
|
715
|
+
await openDropdownMenu();
|
|
691
716
|
await selectMenuItem( 'Reset all' ); // Initial control is displayed by default.
|
|
692
717
|
await selectMenuItem( controlProps.label ); // Re-display control.
|
|
693
718
|
|
|
@@ -715,9 +740,8 @@ describe( 'ToolsPanel', () => {
|
|
|
715
740
|
openDropdownMenu();
|
|
716
741
|
|
|
717
742
|
const defaultItem = screen.getByText( 'Nested Control 1' );
|
|
718
|
-
const defaultMenuItem = screen.getByRole( '
|
|
743
|
+
const defaultMenuItem = screen.getByRole( 'menuitem', {
|
|
719
744
|
name: 'Reset Nested Control 1',
|
|
720
|
-
checked: true,
|
|
721
745
|
} );
|
|
722
746
|
|
|
723
747
|
const altItem = screen.getByText( 'Nested Control 2' );
|
|
@@ -754,9 +778,8 @@ describe( 'ToolsPanel', () => {
|
|
|
754
778
|
openDropdownMenu();
|
|
755
779
|
|
|
756
780
|
const defaultItem = screen.getByText( 'Nested Control 1' );
|
|
757
|
-
const defaultMenuItem = screen.getByRole( '
|
|
781
|
+
const defaultMenuItem = screen.getByRole( 'menuitem', {
|
|
758
782
|
name: 'Reset Nested Control 1',
|
|
759
|
-
checked: true,
|
|
760
783
|
} );
|
|
761
784
|
|
|
762
785
|
const altItem = screen.getByText( 'Nested Control 2' );
|
|
@@ -807,6 +830,7 @@ describe( 'ToolsPanel', () => {
|
|
|
807
830
|
expect( secondItem ).toBeInTheDocument();
|
|
808
831
|
|
|
809
832
|
// Toggle on the first item.
|
|
833
|
+
await openDropdownMenu();
|
|
810
834
|
await selectMenuItem( altControlProps.label );
|
|
811
835
|
|
|
812
836
|
// The order of items should be as per their original source order.
|
|
@@ -964,7 +988,7 @@ describe( 'ToolsPanel', () => {
|
|
|
964
988
|
isShownByDefault: false,
|
|
965
989
|
};
|
|
966
990
|
|
|
967
|
-
it( 'should render appropriate
|
|
991
|
+
it( 'should render appropriate labels and descriptions for the dropdown menu where there are default controls', async () => {
|
|
968
992
|
render(
|
|
969
993
|
<ToolsPanel { ...defaultProps }>
|
|
970
994
|
<ToolsPanelItem { ...defaultControls }>
|
|
@@ -977,13 +1001,18 @@ describe( 'ToolsPanel', () => {
|
|
|
977
1001
|
);
|
|
978
1002
|
|
|
979
1003
|
const optionsDisplayedIcon = screen.getByRole( 'button', {
|
|
980
|
-
name: '
|
|
1004
|
+
name: 'Panel header options',
|
|
981
1005
|
} );
|
|
982
1006
|
|
|
983
1007
|
expect( optionsDisplayedIcon ).toBeInTheDocument();
|
|
1008
|
+
|
|
1009
|
+
// The dropdown toggle doesn't have a description when an option is displayed.
|
|
1010
|
+
// In this case the default control is displayed.
|
|
1011
|
+
expect( optionsDisplayedIcon ).not.toHaveAccessibleDescription();
|
|
984
1012
|
} );
|
|
985
1013
|
|
|
986
|
-
it( 'should render appropriate
|
|
1014
|
+
it( 'should render appropriate labels and descriptions for the dropdown menu where there are no default controls', async () => {
|
|
1015
|
+
// All options are inactive.
|
|
987
1016
|
render(
|
|
988
1017
|
<ToolsPanel { ...defaultProps }>
|
|
989
1018
|
<ToolsPanelItem { ...optionalControls }>
|
|
@@ -992,25 +1021,49 @@ describe( 'ToolsPanel', () => {
|
|
|
992
1021
|
</ToolsPanel>
|
|
993
1022
|
);
|
|
994
1023
|
|
|
995
|
-
// There are unactivated, optional menu items in the Tools Panel dropdown.
|
|
996
1024
|
const optionsHiddenIcon = screen.getByRole( 'button', {
|
|
997
|
-
name: '
|
|
1025
|
+
name: 'Panel header options',
|
|
998
1026
|
} );
|
|
999
1027
|
|
|
1028
|
+
// The dropdown toggle has a description indicating that all options are hidden.
|
|
1000
1029
|
expect( optionsHiddenIcon ).toBeInTheDocument();
|
|
1030
|
+
expect( optionsHiddenIcon ).toHaveAccessibleDescription(
|
|
1031
|
+
'All options are currently hidden'
|
|
1032
|
+
);
|
|
1001
1033
|
|
|
1034
|
+
// Activate one of the options.
|
|
1035
|
+
await openDropdownMenu();
|
|
1002
1036
|
await selectMenuItem( optionalControls.label );
|
|
1003
1037
|
|
|
1004
|
-
// There are now NO unactivated, optional menu items in the Tools Panel dropdown.
|
|
1005
|
-
expect(
|
|
1006
|
-
screen.queryByRole( 'button', { name: 'View and add options' } )
|
|
1007
|
-
).not.toBeInTheDocument();
|
|
1008
|
-
|
|
1009
1038
|
const optionsDisplayedIcon = screen.getByRole( 'button', {
|
|
1010
|
-
name: '
|
|
1039
|
+
name: 'Panel header options',
|
|
1011
1040
|
} );
|
|
1012
1041
|
|
|
1013
|
-
|
|
1042
|
+
// The dropdown toggle no longer has a description.
|
|
1043
|
+
expect( optionsDisplayedIcon ).not.toHaveAccessibleDescription();
|
|
1044
|
+
} );
|
|
1045
|
+
} );
|
|
1046
|
+
|
|
1047
|
+
describe( 'reset all button', () => {
|
|
1048
|
+
it( "should disable the reset all button when there's nothing to reset", async () => {
|
|
1049
|
+
await renderPanel();
|
|
1050
|
+
await openDropdownMenu();
|
|
1051
|
+
|
|
1052
|
+
const resetAllItem = await screen.findByRole( 'menuitem', {
|
|
1053
|
+
disabled: false,
|
|
1054
|
+
} );
|
|
1055
|
+
expect( resetAllItem ).toBeInTheDocument();
|
|
1056
|
+
|
|
1057
|
+
await selectMenuItem( 'Reset all' );
|
|
1058
|
+
|
|
1059
|
+
// Test the aria live announcement.
|
|
1060
|
+
const announcement = await screen.getByText( 'All options reset' );
|
|
1061
|
+
expect( announcement ).toHaveAttribute( 'aria-live', 'assertive' );
|
|
1062
|
+
|
|
1063
|
+
const disabledResetAllItem = await screen.findByRole( 'menuitem', {
|
|
1064
|
+
disabled: true,
|
|
1065
|
+
} );
|
|
1066
|
+
expect( disabledResetAllItem ).toBeInTheDocument();
|
|
1014
1067
|
} );
|
|
1015
1068
|
} );
|
|
1016
1069
|
|
|
@@ -6,6 +6,7 @@ import type { ForwardedRef } from 'react';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { speak } from '@wordpress/a11y';
|
|
9
10
|
import { check, reset, moreVertical, plus } from '@wordpress/icons';
|
|
10
11
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
11
12
|
|
|
@@ -24,11 +25,8 @@ import type {
|
|
|
24
25
|
ToolsPanelHeaderProps,
|
|
25
26
|
} from '../types';
|
|
26
27
|
|
|
27
|
-
const noop = () => {};
|
|
28
|
-
|
|
29
28
|
const DefaultControlsGroup = ( {
|
|
30
29
|
items,
|
|
31
|
-
onClose,
|
|
32
30
|
toggleItem,
|
|
33
31
|
}: ToolsPanelControlsGroupProps ) => {
|
|
34
32
|
if ( ! items.length ) {
|
|
@@ -38,27 +36,41 @@ const DefaultControlsGroup = ( {
|
|
|
38
36
|
return (
|
|
39
37
|
<MenuGroup>
|
|
40
38
|
{ items.map( ( [ label, hasValue ] ) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
if ( hasValue ) {
|
|
40
|
+
return (
|
|
41
|
+
<MenuItem
|
|
42
|
+
key={ label }
|
|
43
|
+
role="menuitem"
|
|
44
|
+
icon={ reset }
|
|
45
|
+
label={ sprintf(
|
|
46
|
+
// translators: %s: The name of the control being reset e.g. "Padding".
|
|
47
|
+
__( 'Reset %s' ),
|
|
48
|
+
label
|
|
49
|
+
) }
|
|
50
|
+
onClick={ () => {
|
|
51
|
+
toggleItem( label );
|
|
52
|
+
speak(
|
|
53
|
+
sprintf(
|
|
54
|
+
// translators: %s: The name of the control being reset e.g. "Padding".
|
|
55
|
+
__( '%s reset to default' ),
|
|
56
|
+
label
|
|
57
|
+
),
|
|
58
|
+
'assertive'
|
|
59
|
+
);
|
|
60
|
+
} }
|
|
61
|
+
>
|
|
62
|
+
{ label }
|
|
63
|
+
</MenuItem>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
49
66
|
|
|
50
67
|
return (
|
|
51
68
|
<MenuItem
|
|
52
69
|
key={ label }
|
|
53
|
-
icon={ icon }
|
|
54
|
-
isSelected={ true }
|
|
55
|
-
disabled={ ! hasValue }
|
|
56
|
-
label={ itemLabel }
|
|
57
|
-
onClick={ () => {
|
|
58
|
-
toggleItem( label );
|
|
59
|
-
onClose();
|
|
60
|
-
} }
|
|
61
70
|
role="menuitemcheckbox"
|
|
71
|
+
icon={ check }
|
|
72
|
+
isSelected
|
|
73
|
+
aria-disabled
|
|
62
74
|
>
|
|
63
75
|
{ label }
|
|
64
76
|
</MenuItem>
|
|
@@ -70,7 +82,6 @@ const DefaultControlsGroup = ( {
|
|
|
70
82
|
|
|
71
83
|
const OptionalControlsGroup = ( {
|
|
72
84
|
items,
|
|
73
|
-
onClose,
|
|
74
85
|
toggleItem,
|
|
75
86
|
}: ToolsPanelControlsGroupProps ) => {
|
|
76
87
|
if ( ! items.length ) {
|
|
@@ -99,8 +110,26 @@ const OptionalControlsGroup = ( {
|
|
|
99
110
|
isSelected={ isSelected }
|
|
100
111
|
label={ itemLabel }
|
|
101
112
|
onClick={ () => {
|
|
113
|
+
if ( isSelected ) {
|
|
114
|
+
speak(
|
|
115
|
+
sprintf(
|
|
116
|
+
// translators: %s: The name of the control being reset e.g. "Padding".
|
|
117
|
+
__( '%s hidden and reset to default' ),
|
|
118
|
+
label
|
|
119
|
+
),
|
|
120
|
+
'assertive'
|
|
121
|
+
);
|
|
122
|
+
} else {
|
|
123
|
+
speak(
|
|
124
|
+
sprintf(
|
|
125
|
+
// translators: %s: The name of the control being reset e.g. "Padding".
|
|
126
|
+
__( '%s is now visible' ),
|
|
127
|
+
label
|
|
128
|
+
),
|
|
129
|
+
'assertive'
|
|
130
|
+
);
|
|
131
|
+
}
|
|
102
132
|
toggleItem( label );
|
|
103
|
-
onClose();
|
|
104
133
|
} }
|
|
105
134
|
role="menuitemcheckbox"
|
|
106
135
|
>
|
|
@@ -135,12 +164,18 @@ const ToolsPanelHeader = (
|
|
|
135
164
|
const defaultItems = Object.entries( menuItems?.default || {} );
|
|
136
165
|
const optionalItems = Object.entries( menuItems?.optional || {} );
|
|
137
166
|
const dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;
|
|
138
|
-
const dropDownMenuLabelText =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
167
|
+
const dropDownMenuLabelText = sprintf(
|
|
168
|
+
// translators: %s: The name of the tool e.g. "Color" or "Typography".
|
|
169
|
+
_x( '%s options', 'Button label to reveal tool panel options' ),
|
|
170
|
+
labelText
|
|
171
|
+
);
|
|
172
|
+
const dropdownMenuDescriptionText = areAllOptionalControlsHidden
|
|
173
|
+
? __( 'All options are currently hidden' )
|
|
174
|
+
: undefined;
|
|
175
|
+
|
|
176
|
+
const canResetAll = [ ...defaultItems, ...optionalItems ].some(
|
|
177
|
+
( [ , isSelected ] ) => isSelected
|
|
178
|
+
);
|
|
144
179
|
|
|
145
180
|
return (
|
|
146
181
|
<HStack { ...headerProps } ref={ forwardedRef }>
|
|
@@ -152,26 +187,33 @@ const ToolsPanelHeader = (
|
|
|
152
187
|
icon={ dropDownMenuIcon }
|
|
153
188
|
label={ dropDownMenuLabelText }
|
|
154
189
|
menuProps={ { className: dropdownMenuClassName } }
|
|
155
|
-
toggleProps={ {
|
|
190
|
+
toggleProps={ {
|
|
191
|
+
isSmall: true,
|
|
192
|
+
describedBy: dropdownMenuDescriptionText,
|
|
193
|
+
} }
|
|
156
194
|
>
|
|
157
|
-
{ (
|
|
195
|
+
{ () => (
|
|
158
196
|
<>
|
|
159
197
|
<DefaultControlsGroup
|
|
160
198
|
items={ defaultItems }
|
|
161
|
-
onClose={ onClose }
|
|
162
199
|
toggleItem={ toggleItem }
|
|
163
200
|
/>
|
|
164
201
|
<OptionalControlsGroup
|
|
165
202
|
items={ optionalItems }
|
|
166
|
-
onClose={ onClose }
|
|
167
203
|
toggleItem={ toggleItem }
|
|
168
204
|
/>
|
|
169
205
|
<MenuGroup>
|
|
170
206
|
<MenuItem
|
|
207
|
+
aria-disabled={ ! canResetAll }
|
|
171
208
|
variant={ 'tertiary' }
|
|
172
209
|
onClick={ () => {
|
|
173
|
-
|
|
174
|
-
|
|
210
|
+
if ( canResetAll ) {
|
|
211
|
+
resetAll();
|
|
212
|
+
speak(
|
|
213
|
+
__( 'All options reset' ),
|
|
214
|
+
'assertive'
|
|
215
|
+
);
|
|
216
|
+
}
|
|
175
217
|
} }
|
|
176
218
|
>
|
|
177
219
|
{ __( 'Reset all' ) }
|