@wordpress/components 25.8.0 → 25.8.2
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 +11 -0
- package/build/date-time/time/index.js +6 -1
- package/build/date-time/time/index.js.map +1 -1
- package/build/modal/index.js +12 -3
- package/build/modal/index.js.map +1 -1
- package/build/modal/types.js.map +1 -1
- package/build/placeholder/index.js +10 -4
- package/build/placeholder/index.js.map +1 -1
- package/build-module/date-time/time/index.js +6 -1
- package/build-module/date-time/time/index.js.map +1 -1
- package/build-module/modal/index.js +12 -3
- package/build-module/modal/index.js.map +1 -1
- package/build-module/modal/types.js.map +1 -1
- package/build-module/placeholder/index.js +11 -4
- package/build-module/placeholder/index.js.map +1 -1
- package/build-style/style-rtl.css +0 -10
- package/build-style/style.css +0 -10
- package/build-types/date-time/time/index.d.ts.map +1 -1
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/modal/types.d.ts +1 -1
- package/build-types/modal/types.d.ts.map +1 -1
- package/build-types/placeholder/index.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/date-time/time/index.tsx +8 -1
- package/src/modal/README.md +7 -1
- package/src/modal/index.tsx +27 -3
- package/src/modal/stories/index.story.tsx +2 -1
- package/src/modal/test/index.tsx +124 -0
- package/src/modal/types.ts +3 -1
- package/src/placeholder/index.tsx +15 -8
- package/src/placeholder/style.scss +0 -12
- package/src/placeholder/test/index.tsx +34 -15
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -72,18 +72,6 @@
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// Overrides for browser and editor fieldset styles.
|
|
76
|
-
.components-placeholder__fieldset.components-placeholder__fieldset {
|
|
77
|
-
border: none;
|
|
78
|
-
padding: 0;
|
|
79
|
-
|
|
80
|
-
.components-placeholder__instructions {
|
|
81
|
-
padding: 0;
|
|
82
|
-
font-weight: normal;
|
|
83
|
-
font-size: 1em;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
75
|
.components-placeholder__fieldset.is-column-layout,
|
|
88
76
|
.components-placeholder__fieldset.is-column-layout form {
|
|
89
77
|
flex-direction: column;
|
|
@@ -8,6 +8,7 @@ import { render, screen, within } from '@testing-library/react';
|
|
|
8
8
|
*/
|
|
9
9
|
import { useResizeObserver } from '@wordpress/compose';
|
|
10
10
|
import { SVG, Path } from '@wordpress/primitives';
|
|
11
|
+
import { speak } from '@wordpress/a11y';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
@@ -41,6 +42,9 @@ const Placeholder = (
|
|
|
41
42
|
|
|
42
43
|
const getPlaceholder = () => screen.getByTestId( 'placeholder' );
|
|
43
44
|
|
|
45
|
+
jest.mock( '@wordpress/a11y', () => ( { speak: jest.fn() } ) );
|
|
46
|
+
const mockedSpeak = jest.mocked( speak );
|
|
47
|
+
|
|
44
48
|
describe( 'Placeholder', () => {
|
|
45
49
|
beforeEach( () => {
|
|
46
50
|
// @ts-ignore
|
|
@@ -48,10 +52,11 @@ describe( 'Placeholder', () => {
|
|
|
48
52
|
<div key="1" />,
|
|
49
53
|
{ width: 320 },
|
|
50
54
|
] );
|
|
55
|
+
mockedSpeak.mockReset();
|
|
51
56
|
} );
|
|
52
57
|
|
|
53
58
|
describe( 'basic rendering', () => {
|
|
54
|
-
it( 'should by default render label section and
|
|
59
|
+
it( 'should by default render label section and content section.', () => {
|
|
55
60
|
render( <Placeholder /> );
|
|
56
61
|
const placeholder = getPlaceholder();
|
|
57
62
|
|
|
@@ -74,9 +79,12 @@ describe( 'Placeholder', () => {
|
|
|
74
79
|
);
|
|
75
80
|
expect( placeholderInstructions ).not.toBeInTheDocument();
|
|
76
81
|
|
|
77
|
-
// Test for empty
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
// Test for empty content. When the content is empty,
|
|
83
|
+
// the only way to query the div is with `querySelector`
|
|
84
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
85
|
+
const placeholderFieldset = placeholder.querySelector(
|
|
86
|
+
'.components-placeholder__fieldset'
|
|
87
|
+
);
|
|
80
88
|
expect( placeholderFieldset ).toBeInTheDocument();
|
|
81
89
|
expect( placeholderFieldset ).toBeEmptyDOMElement();
|
|
82
90
|
} );
|
|
@@ -104,27 +112,38 @@ describe( 'Placeholder', () => {
|
|
|
104
112
|
expect( placeholderLabel ).toBeInTheDocument();
|
|
105
113
|
} );
|
|
106
114
|
|
|
107
|
-
it( 'should display
|
|
108
|
-
const content = '
|
|
115
|
+
it( 'should display content from the children property', () => {
|
|
116
|
+
const content = 'Placeholder content';
|
|
109
117
|
render( <Placeholder>{ content }</Placeholder> );
|
|
110
|
-
const
|
|
118
|
+
const placeholder = screen.getByText( content );
|
|
111
119
|
|
|
112
|
-
expect(
|
|
113
|
-
expect(
|
|
120
|
+
expect( placeholder ).toBeInTheDocument();
|
|
121
|
+
expect( placeholder ).toHaveTextContent( content );
|
|
114
122
|
} );
|
|
115
123
|
|
|
116
|
-
it( 'should display
|
|
124
|
+
it( 'should display instructions when provided', () => {
|
|
117
125
|
const instructions = 'Choose an option.';
|
|
118
126
|
render(
|
|
119
127
|
<Placeholder instructions={ instructions }>
|
|
120
|
-
<div>
|
|
128
|
+
<div>Placeholder content</div>
|
|
129
|
+
</Placeholder>
|
|
130
|
+
);
|
|
131
|
+
const placeholder = getPlaceholder();
|
|
132
|
+
const instructionsContainer =
|
|
133
|
+
within( placeholder ).getByText( instructions );
|
|
134
|
+
|
|
135
|
+
expect( instructionsContainer ).toBeInTheDocument();
|
|
136
|
+
} );
|
|
137
|
+
|
|
138
|
+
it( 'should announce instructions to screen readers', () => {
|
|
139
|
+
const instructions = 'Awesome block placeholder instructions.';
|
|
140
|
+
render(
|
|
141
|
+
<Placeholder instructions={ instructions }>
|
|
142
|
+
<div>Placeholder content</div>
|
|
121
143
|
</Placeholder>
|
|
122
144
|
);
|
|
123
|
-
const captionedFieldset = screen.getByRole( 'group', {
|
|
124
|
-
name: instructions,
|
|
125
|
-
} );
|
|
126
145
|
|
|
127
|
-
expect(
|
|
146
|
+
expect( speak ).toHaveBeenCalledWith( instructions );
|
|
128
147
|
} );
|
|
129
148
|
|
|
130
149
|
it( 'should add an additional className to the top container', () => {
|