@wordpress/components 23.0.0 → 23.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/CONTRIBUTING.md +0 -21
- package/build/autocomplete/index.js +1 -3
- package/build/autocomplete/index.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js +0 -3
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +0 -2
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +0 -2
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/hook.js +0 -2
- package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build/border-control/border-control/component.js +0 -2
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +0 -2
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +6 -11
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +0 -2
- package/build/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build/color-palette/index.js +5 -8
- package/build/color-palette/index.js.map +1 -1
- package/build/dimension-control/index.js.map +1 -1
- package/build/dropdown/index.js +45 -10
- package/build/dropdown/index.js.map +1 -1
- package/build/gradient-picker/index.js +1 -2
- package/build/gradient-picker/index.js.map +1 -1
- package/build/higher-order/navigate-regions/index.js +4 -3
- package/build/higher-order/navigate-regions/index.js.map +1 -1
- package/build/index.js +0 -8
- package/build/index.js.map +1 -1
- package/build/mobile/bottom-sheet/picker-cell.native.js +1 -9
- package/build/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +30 -12
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/tab-panel/index.js +5 -4
- package/build/tab-panel/index.js.map +1 -1
- package/build-module/autocomplete/index.js +1 -2
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +0 -3
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control/hook.js +0 -2
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +0 -2
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/hook.js +0 -2
- package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build-module/border-control/border-control/component.js +0 -2
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +0 -2
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +6 -11
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +0 -2
- package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build-module/color-palette/index.js +5 -8
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/dimension-control/index.js +1 -2
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/dropdown/index.js +44 -10
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/gradient-picker/index.js +1 -2
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/higher-order/navigate-regions/index.js +4 -3
- package/build-module/higher-order/navigate-regions/index.js.map +1 -1
- package/build-module/index.js +0 -1
- package/build-module/index.js.map +1 -1
- package/build-module/mobile/bottom-sheet/picker-cell.native.js +1 -8
- package/build-module/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +31 -13
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/tab-panel/index.js +5 -3
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-style/style-rtl.css +18 -31
- package/build-style/style.css +18 -31
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +0 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +0 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/stories/index.d.ts +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -1
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +0 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts +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 +0 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/stories/index.d.ts +6 -6
- package/build-types/border-control/stories/index.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +1 -1
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts +2 -3
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.d.ts +2 -9
- package/build-types/color-palette/stories/index.d.ts.map +1 -1
- package/build-types/color-palette/types.d.ts +3 -16
- package/build-types/color-palette/types.d.ts.map +1 -1
- package/build-types/disabled/stories/index.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts +29 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.d.ts +23 -0
- package/build-types/dropdown/stories/index.d.ts.map +1 -0
- package/build-types/dropdown/test/index.d.ts +2 -0
- package/build-types/dropdown/test/index.d.ts.map +1 -0
- package/build-types/dropdown/types.d.ts +101 -0
- package/build-types/dropdown/types.d.ts.map +1 -1
- package/build-types/icon/stories/index.d.ts +22 -0
- package/build-types/icon/stories/index.d.ts.map +1 -0
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/autocomplete/index.js +1 -3
- package/src/autocomplete/test/index.js +2 -0
- package/src/base-control/test/index.tsx +1 -0
- package/src/border-box-control/border-box-control/component.tsx +0 -7
- package/src/border-box-control/border-box-control/hook.ts +0 -2
- package/src/border-box-control/border-box-control-split-controls/component.tsx +0 -2
- package/src/border-box-control/border-box-control-split-controls/hook.ts +0 -2
- package/src/border-box-control/test/index.js +2 -0
- package/src/border-control/border-control/component.tsx +0 -4
- package/src/border-control/border-control/hook.ts +0 -2
- package/src/border-control/border-control-dropdown/component.tsx +11 -17
- package/src/border-control/border-control-dropdown/hook.ts +0 -2
- package/src/border-control/stories/index.tsx +0 -1
- package/src/border-control/test/index.js +70 -67
- package/src/border-control/types.ts +1 -4
- package/src/box-control/test/index.js +2 -0
- package/src/checkbox-control/test/index.tsx +2 -0
- package/src/color-palette/index.tsx +12 -12
- package/src/color-palette/stories/index.tsx +0 -13
- package/src/color-palette/test/index.tsx +2 -0
- package/src/color-palette/types.ts +3 -17
- package/src/color-picker/test/index.js +2 -0
- package/src/combobox-control/test/index.js +2 -0
- package/src/confirm-dialog/test/index.js +2 -0
- package/src/date-time/date/test/index.tsx +2 -0
- package/src/date-time/time/test/index.tsx +2 -0
- package/src/dimension-control/index.js +2 -3
- package/src/dimension-control/test/index.test.js +2 -0
- package/src/disabled/stories/index.tsx +6 -2
- package/src/disabled/test/index.tsx +2 -0
- package/src/dropdown/README.md +41 -46
- package/src/dropdown/{index.js → index.tsx} +57 -13
- package/src/dropdown/stories/{index.js → index.tsx} +21 -8
- package/src/dropdown/test/{index.js → index.tsx} +9 -9
- package/src/dropdown/types.ts +107 -0
- package/src/dropdown-menu/README.md +2 -3
- package/src/dropdown-menu/test/index.js +2 -0
- package/src/external-link/test/index.tsx +2 -0
- package/src/focal-point-picker/test/index.js +2 -0
- package/src/font-size-picker/test/index.tsx +2 -0
- package/src/form-file-upload/test/index.tsx +2 -0
- package/src/form-toggle/test/index.tsx +2 -0
- package/src/form-token-field/test/index.tsx +3 -0
- package/src/gradient-picker/index.js +1 -2
- package/src/gradient-picker/stories/index.js +0 -1
- package/src/guide/test/index.js +2 -0
- package/src/higher-order/navigate-regions/index.js +5 -2
- package/src/higher-order/navigate-regions/style.scss +13 -39
- package/src/higher-order/with-filters/test/index.js +70 -74
- package/src/higher-order/with-focus-outside/test/index.js +2 -0
- package/src/higher-order/with-focus-return/test/index.js +2 -0
- package/src/higher-order/with-notices/test/index.js +1 -0
- package/src/icon/stories/index.tsx +103 -0
- package/src/index.js +0 -1
- package/src/input-control/test/index.js +3 -0
- package/src/isolated-event-container/test/index.js +2 -0
- package/src/mobile/bottom-sheet/picker-cell.native.js +1 -6
- package/src/mobile/global-styles-context/utils.native.js +17 -16
- package/src/modal/test/index.tsx +1 -3
- package/src/navigable-container/test/navigable-menu.js +2 -0
- package/src/navigable-container/test/tababble-container.js +2 -0
- package/src/navigation/test/index.js +2 -0
- package/src/navigator/test/index.tsx +2 -0
- package/src/notice/test/index.js +8 -3
- package/src/number-control/test/index.tsx +2 -0
- package/src/panel/test/__snapshots__/body.js.snap +9 -0
- package/src/panel/test/body.js +71 -62
- package/src/placeholder/test/index.tsx +3 -0
- package/src/select-control/test/select-control.tsx +2 -0
- package/src/tab-panel/index.tsx +1 -2
- package/src/tab-panel/test/index.tsx +2 -0
- package/src/text-highlight/test/index.tsx +1 -0
- package/src/toggle-group-control/test/index.tsx +2 -0
- package/src/toolbar/style.scss +1 -1
- package/src/toolbar-group/test/index.js +2 -0
- package/src/tooltip/stories/index.js +68 -78
- package/src/tooltip/test/index.js +2 -0
- package/src/unit-control/test/index.tsx +3 -0
- package/src/utils/hooks/test/use-latest-ref.js +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/icon/stories/index.js +0 -128
package/src/index.js
CHANGED
|
@@ -148,7 +148,6 @@ export { Text as __experimentalText } from './text';
|
|
|
148
148
|
export { default as TextControl } from './text-control';
|
|
149
149
|
export { default as TextareaControl } from './textarea-control';
|
|
150
150
|
export { default as TextHighlight } from './text-highlight';
|
|
151
|
-
export { default as __experimentalTheme } from './theme';
|
|
152
151
|
export { default as Tip } from './tip';
|
|
153
152
|
export { default as ToggleControl } from './toggle-control';
|
|
154
153
|
export {
|
|
@@ -14,6 +14,8 @@ import { useState } from '@wordpress/element';
|
|
|
14
14
|
*/
|
|
15
15
|
import BaseInputControl from '../';
|
|
16
16
|
|
|
17
|
+
jest.useFakeTimers();
|
|
18
|
+
|
|
17
19
|
const setupUser = () =>
|
|
18
20
|
userEvent.setup( {
|
|
19
21
|
advanceTimers: jest.advanceTimersByTime,
|
|
@@ -65,6 +67,7 @@ describe( 'InputControl', () => {
|
|
|
65
67
|
const help = screen.getByRole( 'link', { name: 'My help text' } );
|
|
66
68
|
|
|
67
69
|
expect(
|
|
70
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
68
71
|
help.closest( `#${ input.getAttribute( 'aria-details' ) }` )
|
|
69
72
|
).toBeVisible();
|
|
70
73
|
} );
|
|
@@ -9,6 +9,8 @@ import userEvent from '@testing-library/user-event';
|
|
|
9
9
|
*/
|
|
10
10
|
import IsolatedEventContainer from '../';
|
|
11
11
|
|
|
12
|
+
jest.useFakeTimers();
|
|
13
|
+
|
|
12
14
|
describe( 'IsolatedEventContainer', () => {
|
|
13
15
|
it( 'should pass props to container', async () => {
|
|
14
16
|
const user = userEvent.setup( {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { find } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
@@ -23,7 +18,7 @@ export default function BottomSheetPickerCell( props ) {
|
|
|
23
18
|
onChangeValue( newValue );
|
|
24
19
|
};
|
|
25
20
|
|
|
26
|
-
const option = find(
|
|
21
|
+
const option = options.find( ( opt ) => opt.value === value );
|
|
27
22
|
const label = option ? option.label : value;
|
|
28
23
|
|
|
29
24
|
return (
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { camelCase } from 'change-case';
|
|
5
|
-
import {
|
|
5
|
+
import { get } from 'lodash';
|
|
6
6
|
import { Dimensions } from 'react-native';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -113,9 +113,9 @@ export function getBlockColors(
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
if ( ! isCustomColor ) {
|
|
116
|
-
const mappedColor =
|
|
117
|
-
slug
|
|
118
|
-
|
|
116
|
+
const mappedColor = Object.values( defaultColors ?? {} ).find(
|
|
117
|
+
( { slug } ) => slug === value
|
|
118
|
+
);
|
|
119
119
|
|
|
120
120
|
if ( mappedColor ) {
|
|
121
121
|
blockStyles[ styleKey ] = mappedColor.color;
|
|
@@ -143,6 +143,7 @@ export function getBlockTypography(
|
|
|
143
143
|
const typographyStyles = {};
|
|
144
144
|
const customBlockStyles = blockStyleAttributes?.style?.typography || {};
|
|
145
145
|
const blockGlobalStyles = baseGlobalStyles?.blocks?.[ blockName ];
|
|
146
|
+
const parsedFontSizes = Object.values( fontSizes ?? {} );
|
|
146
147
|
|
|
147
148
|
// Global styles.
|
|
148
149
|
if ( blockGlobalStyles?.typography ) {
|
|
@@ -153,9 +154,9 @@ export function getBlockTypography(
|
|
|
153
154
|
if ( parseInt( fontSize, 10 ) ) {
|
|
154
155
|
typographyStyles.fontSize = fontSize;
|
|
155
156
|
} else {
|
|
156
|
-
const mappedFontSize = find(
|
|
157
|
-
slug
|
|
158
|
-
|
|
157
|
+
const mappedFontSize = parsedFontSizes.find(
|
|
158
|
+
( { slug } ) => slug === fontSize
|
|
159
|
+
);
|
|
159
160
|
|
|
160
161
|
if ( mappedFontSize ) {
|
|
161
162
|
typographyStyles.fontSize = mappedFontSize?.size;
|
|
@@ -169,9 +170,9 @@ export function getBlockTypography(
|
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
if ( blockStyleAttributes?.fontSize && baseGlobalStyles ) {
|
|
172
|
-
const mappedFontSize = find(
|
|
173
|
-
slug
|
|
174
|
-
|
|
173
|
+
const mappedFontSize = parsedFontSizes.find(
|
|
174
|
+
( { slug } ) => slug === blockStyleAttributes?.fontSize
|
|
175
|
+
);
|
|
175
176
|
|
|
176
177
|
if ( mappedFontSize ) {
|
|
177
178
|
typographyStyles.fontSize = mappedFontSize?.size;
|
|
@@ -212,9 +213,9 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
|
212
213
|
const path = $2.split( '--' );
|
|
213
214
|
const mappedPresetValue = mappedValues[ path[ 0 ] ];
|
|
214
215
|
if ( mappedPresetValue && mappedPresetValue.slug ) {
|
|
215
|
-
const matchedValue =
|
|
216
|
-
|
|
217
|
-
} );
|
|
216
|
+
const matchedValue = Object.values(
|
|
217
|
+
mappedPresetValue.values ?? {}
|
|
218
|
+
).find( ( { slug } ) => slug === path[ 1 ] );
|
|
218
219
|
return matchedValue?.[ mappedPresetValue.slug ];
|
|
219
220
|
}
|
|
220
221
|
return UNKNOWN_VALUE;
|
|
@@ -244,9 +245,9 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
|
244
245
|
if ( variable === 'var' ) {
|
|
245
246
|
stylesBase = stylesBase.replace( varRegex, ( _$1, $2 ) => {
|
|
246
247
|
if ( mappedValues?.color ) {
|
|
247
|
-
const matchedValue =
|
|
248
|
-
slug
|
|
249
|
-
|
|
248
|
+
const matchedValue = mappedValues.color?.values?.find(
|
|
249
|
+
( { slug } ) => slug === $2
|
|
250
|
+
);
|
|
250
251
|
return `"${ matchedValue?.color }"`;
|
|
251
252
|
}
|
|
252
253
|
return UNKNOWN_VALUE;
|
package/src/modal/test/index.tsx
CHANGED
|
@@ -72,9 +72,7 @@ describe( 'Modal', () => {
|
|
|
72
72
|
} );
|
|
73
73
|
|
|
74
74
|
it( 'should call onRequestClose when the escape key is pressed', async () => {
|
|
75
|
-
const user = userEvent.setup(
|
|
76
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
77
|
-
} );
|
|
75
|
+
const user = userEvent.setup();
|
|
78
76
|
const onRequestClose = jest.fn();
|
|
79
77
|
render(
|
|
80
78
|
<Modal onRequestClose={ onRequestClose }>
|
|
@@ -16,6 +16,8 @@ import Navigation from '..';
|
|
|
16
16
|
import NavigationItem from '../item';
|
|
17
17
|
import NavigationMenu from '../menu';
|
|
18
18
|
|
|
19
|
+
jest.useFakeTimers();
|
|
20
|
+
|
|
19
21
|
const TestNavigation = ( { activeItem, rootTitle, showBadge } = {} ) => (
|
|
20
22
|
<Navigation activeItem={ activeItem }>
|
|
21
23
|
<NavigationMenu title={ rootTitle }>
|
package/src/notice/test/index.js
CHANGED
|
@@ -15,6 +15,10 @@ import Notice from '../index';
|
|
|
15
15
|
|
|
16
16
|
jest.mock( '@wordpress/a11y', () => ( { speak: jest.fn() } ) );
|
|
17
17
|
|
|
18
|
+
function getNoticeWrapper( container ) {
|
|
19
|
+
return container.firstChild;
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
describe( 'Notice', () => {
|
|
19
23
|
beforeEach( () => {
|
|
20
24
|
speak.mockReset();
|
|
@@ -39,15 +43,16 @@ describe( 'Notice', () => {
|
|
|
39
43
|
|
|
40
44
|
it( 'should not have is-dismissible class when isDismissible prop is false', () => {
|
|
41
45
|
const { container } = render( <Notice isDismissible={ false } /> );
|
|
46
|
+
const wrapper = getNoticeWrapper( container );
|
|
42
47
|
|
|
43
|
-
expect(
|
|
44
|
-
expect(
|
|
48
|
+
expect( wrapper ).toHaveClass( 'components-notice' );
|
|
49
|
+
expect( wrapper ).not.toHaveClass( 'is-dismissible' );
|
|
45
50
|
} );
|
|
46
51
|
|
|
47
52
|
it( 'should default to info status', () => {
|
|
48
53
|
const { container } = render( <Notice /> );
|
|
49
54
|
|
|
50
|
-
expect( container
|
|
55
|
+
expect( getNoticeWrapper( container ) ).toHaveClass( 'is-info' );
|
|
51
56
|
} );
|
|
52
57
|
|
|
53
58
|
describe( 'useSpokenMessage', () => {
|
|
@@ -15,6 +15,8 @@ import { useState } from '@wordpress/element';
|
|
|
15
15
|
import NumberControl from '..';
|
|
16
16
|
import type { NumberControlProps } from '../types';
|
|
17
17
|
|
|
18
|
+
jest.useFakeTimers();
|
|
19
|
+
|
|
18
20
|
function StatefulNumberControl( props: NumberControlProps ) {
|
|
19
21
|
const [ value, setValue ] = useState( props.value );
|
|
20
22
|
const handleOnChange = ( v: string | undefined ) => setValue( v );
|
package/src/panel/test/body.js
CHANGED
|
@@ -1,154 +1,163 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render,
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import { PanelBody } from '../body';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
container.querySelector( '.components-panel__body' );
|
|
13
|
-
const getPanelBodyContent = ( container ) =>
|
|
14
|
-
container.querySelector( '.components-panel__body > div' );
|
|
15
|
-
const getPanelToggle = ( container ) =>
|
|
16
|
-
container.querySelector( '.components-panel__body-toggle' );
|
|
12
|
+
jest.useFakeTimers();
|
|
17
13
|
|
|
18
14
|
describe( 'PanelBody', () => {
|
|
19
15
|
describe( 'basic rendering', () => {
|
|
20
16
|
it( 'should render an empty div with the matching className', () => {
|
|
21
17
|
const { container } = render( <PanelBody /> );
|
|
22
|
-
const panelBody = getPanelBody( container );
|
|
23
18
|
|
|
24
|
-
expect(
|
|
25
|
-
expect( panelBody.tagName ).toBe( 'DIV' );
|
|
19
|
+
expect( container ).toMatchSnapshot();
|
|
26
20
|
} );
|
|
27
21
|
|
|
28
22
|
it( 'should render inner content, if opened', () => {
|
|
29
|
-
|
|
30
|
-
<PanelBody opened
|
|
31
|
-
<div
|
|
23
|
+
render(
|
|
24
|
+
<PanelBody opened>
|
|
25
|
+
<div data-testid="inner-content">Content</div>
|
|
32
26
|
</PanelBody>
|
|
33
27
|
);
|
|
34
|
-
const panelContent = getPanelBodyContent( container );
|
|
35
28
|
|
|
36
|
-
expect(
|
|
29
|
+
expect( screen.getByTestId( 'inner-content' ) ).toBeVisible();
|
|
37
30
|
} );
|
|
38
31
|
|
|
39
32
|
it( 'should be opened by default', () => {
|
|
40
|
-
|
|
33
|
+
render(
|
|
41
34
|
<PanelBody>
|
|
42
|
-
<div>Content</div>
|
|
35
|
+
<div data-testid="inner-content">Content</div>
|
|
43
36
|
</PanelBody>
|
|
44
37
|
);
|
|
45
|
-
const panelContent = getPanelBodyContent( container );
|
|
46
38
|
|
|
47
|
-
expect(
|
|
39
|
+
expect( screen.getByTestId( 'inner-content' ) ).toBeVisible();
|
|
48
40
|
} );
|
|
49
41
|
|
|
50
42
|
it( 'should render as initially opened, if specified', () => {
|
|
51
|
-
|
|
52
|
-
<PanelBody initialOpen
|
|
53
|
-
<div>Content</div>
|
|
43
|
+
render(
|
|
44
|
+
<PanelBody initialOpen>
|
|
45
|
+
<div data-testid="inner-content">Content</div>
|
|
54
46
|
</PanelBody>
|
|
55
47
|
);
|
|
56
|
-
const panelContent = getPanelBodyContent( container );
|
|
57
48
|
|
|
58
|
-
expect(
|
|
49
|
+
expect( screen.getByTestId( 'inner-content' ) ).toBeVisible();
|
|
59
50
|
} );
|
|
60
51
|
|
|
61
52
|
it( 'should call the children function, if specified', () => {
|
|
62
|
-
const {
|
|
63
|
-
<PanelBody opened
|
|
64
|
-
{ ( { opened } ) =>
|
|
53
|
+
const { rerender } = render(
|
|
54
|
+
<PanelBody opened>
|
|
55
|
+
{ ( { opened } ) => (
|
|
56
|
+
<div hidden={ opened } data-testid="inner-content">
|
|
57
|
+
Content
|
|
58
|
+
</div>
|
|
59
|
+
) }
|
|
65
60
|
</PanelBody>
|
|
66
61
|
);
|
|
67
|
-
let panelContent = getPanelBodyContent( container );
|
|
68
62
|
|
|
69
|
-
|
|
63
|
+
let panelContent = screen.getByTestId( 'inner-content' );
|
|
64
|
+
|
|
65
|
+
expect( panelContent ).toBeInTheDocument();
|
|
66
|
+
expect( panelContent ).not.toBeVisible();
|
|
70
67
|
expect( panelContent ).toHaveAttribute( 'hidden', '' );
|
|
71
68
|
|
|
72
69
|
rerender(
|
|
73
70
|
<PanelBody opened={ false }>
|
|
74
|
-
{ ( { opened } ) =>
|
|
71
|
+
{ ( { opened } ) => (
|
|
72
|
+
<div hidden={ opened } data-testid="inner-content">
|
|
73
|
+
Content
|
|
74
|
+
</div>
|
|
75
|
+
) }
|
|
75
76
|
</PanelBody>
|
|
76
77
|
);
|
|
77
|
-
panelContent = getPanelBodyContent( container );
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
panelContent = screen.getByTestId( 'inner-content' );
|
|
80
|
+
|
|
81
|
+
expect( panelContent ).toBeVisible();
|
|
80
82
|
expect( panelContent ).not.toHaveAttribute( 'hidden' );
|
|
81
83
|
} );
|
|
82
84
|
} );
|
|
83
85
|
|
|
84
86
|
describe( 'toggling', () => {
|
|
85
87
|
it( 'should toggle collapse with opened prop', () => {
|
|
86
|
-
const {
|
|
87
|
-
<PanelBody opened
|
|
88
|
-
<div>Content</div>
|
|
88
|
+
const { rerender } = render(
|
|
89
|
+
<PanelBody opened>
|
|
90
|
+
<div data-testid="inner-content">Content</div>
|
|
89
91
|
</PanelBody>
|
|
90
92
|
);
|
|
91
|
-
let panelContent = getPanelBodyContent( container );
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
let panelContent = screen.getByTestId( 'inner-content' );
|
|
95
|
+
|
|
96
|
+
expect( panelContent ).toBeVisible();
|
|
94
97
|
|
|
95
98
|
rerender(
|
|
96
99
|
<PanelBody opened={ false }>
|
|
97
|
-
<div>Content</div>
|
|
100
|
+
<div data-testid="inner-content">Content</div>
|
|
98
101
|
</PanelBody>
|
|
99
102
|
);
|
|
100
103
|
|
|
101
|
-
panelContent =
|
|
104
|
+
panelContent = screen.queryByTestId( 'inner-content' );
|
|
102
105
|
|
|
103
|
-
expect( panelContent ).
|
|
106
|
+
expect( panelContent ).not.toBeInTheDocument();
|
|
104
107
|
|
|
105
108
|
rerender(
|
|
106
|
-
<PanelBody opened
|
|
107
|
-
<div>Content</div>
|
|
109
|
+
<PanelBody opened>
|
|
110
|
+
<div data-testid="inner-content">Content</div>
|
|
108
111
|
</PanelBody>
|
|
109
112
|
);
|
|
110
113
|
|
|
111
|
-
panelContent =
|
|
114
|
+
panelContent = screen.getByTestId( 'inner-content' );
|
|
112
115
|
|
|
113
|
-
expect( panelContent ).
|
|
116
|
+
expect( panelContent ).toBeVisible();
|
|
114
117
|
} );
|
|
115
118
|
|
|
116
|
-
it( 'should toggle when clicking header', () => {
|
|
117
|
-
const
|
|
119
|
+
it( 'should toggle when clicking header', async () => {
|
|
120
|
+
const user = userEvent.setup( {
|
|
121
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
122
|
+
} );
|
|
123
|
+
|
|
124
|
+
render(
|
|
118
125
|
<PanelBody title="Panel" initialOpen={ false }>
|
|
119
|
-
<div>Content</div>
|
|
126
|
+
<div data-testid="inner-content">Content</div>
|
|
120
127
|
</PanelBody>
|
|
121
128
|
);
|
|
122
|
-
let panelContent = getPanelBodyContent( container );
|
|
123
|
-
const panelToggle = getPanelToggle( container );
|
|
124
129
|
|
|
125
|
-
|
|
130
|
+
let panelContent = screen.queryByTestId( 'inner-content' );
|
|
131
|
+
const panelToggle = screen.getByRole( 'button', { name: 'Panel' } );
|
|
132
|
+
|
|
133
|
+
expect( panelContent ).not.toBeInTheDocument();
|
|
126
134
|
|
|
127
|
-
|
|
135
|
+
await user.click( panelToggle );
|
|
128
136
|
|
|
129
|
-
panelContent =
|
|
137
|
+
panelContent = screen.getByTestId( 'inner-content' );
|
|
130
138
|
|
|
131
|
-
expect( panelContent ).
|
|
139
|
+
expect( panelContent ).toBeVisible();
|
|
132
140
|
|
|
133
|
-
|
|
141
|
+
await user.click( panelToggle );
|
|
134
142
|
|
|
135
|
-
panelContent =
|
|
143
|
+
panelContent = screen.queryByTestId( 'inner-content' );
|
|
136
144
|
|
|
137
|
-
expect( panelContent ).
|
|
145
|
+
expect( panelContent ).not.toBeInTheDocument();
|
|
138
146
|
} );
|
|
139
147
|
|
|
140
|
-
it( 'should pass button props to panel title', () => {
|
|
148
|
+
it( 'should pass button props to panel title', async () => {
|
|
149
|
+
const user = userEvent.setup( {
|
|
150
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
151
|
+
} );
|
|
141
152
|
const mock = jest.fn();
|
|
142
153
|
|
|
143
|
-
|
|
154
|
+
render(
|
|
144
155
|
<PanelBody title="Panel" buttonProps={ { onClick: mock } }>
|
|
145
|
-
<div>Content</div>
|
|
156
|
+
<div data-testid="inner-content">Content</div>
|
|
146
157
|
</PanelBody>
|
|
147
158
|
);
|
|
148
159
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
fireEvent.click( panelToggle );
|
|
160
|
+
await user.click( screen.getByRole( 'button', { name: 'Panel' } ) );
|
|
152
161
|
|
|
153
162
|
expect( mock ).toHaveBeenCalled();
|
|
154
163
|
} );
|
|
@@ -59,6 +59,7 @@ describe( 'Placeholder', () => {
|
|
|
59
59
|
|
|
60
60
|
// Test for empty label. When the label is empty, the only way to
|
|
61
61
|
// query the div is with `querySelector`.
|
|
62
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
62
63
|
const label = placeholder.querySelector(
|
|
63
64
|
'.components-placeholder__label'
|
|
64
65
|
);
|
|
@@ -67,6 +68,7 @@ describe( 'Placeholder', () => {
|
|
|
67
68
|
|
|
68
69
|
// Test for non existent instructions. When the instructions is
|
|
69
70
|
// empty, the only way to query the div is with `querySelector`.
|
|
71
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
70
72
|
const placeholderInstructions = placeholder.querySelector(
|
|
71
73
|
'.components-placeholder__instructions'
|
|
72
74
|
);
|
|
@@ -84,6 +86,7 @@ describe( 'Placeholder', () => {
|
|
|
84
86
|
|
|
85
87
|
const placeholder = getPlaceholder();
|
|
86
88
|
const icon = within( placeholder ).getByTestId( 'icon' );
|
|
89
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
87
90
|
expect( icon.parentNode ).toHaveClass(
|
|
88
91
|
'components-placeholder__label'
|
|
89
92
|
);
|
package/src/tab-panel/index.tsx
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { find } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -102,7 +101,7 @@ export function TabPanel( {
|
|
|
102
101
|
) => {
|
|
103
102
|
child.click();
|
|
104
103
|
};
|
|
105
|
-
const selectedTab = find(
|
|
104
|
+
const selectedTab = tabs.find( ( { name } ) => name === selected );
|
|
106
105
|
const selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;
|
|
107
106
|
|
|
108
107
|
useEffect( () => {
|
|
@@ -11,6 +11,7 @@ import TextHighlight from '..';
|
|
|
11
11
|
const getMarks = ( container: Element ) =>
|
|
12
12
|
// Use querySelectorAll because the `mark` role is not officially supported
|
|
13
13
|
// yet. This should be changed to `getByRole` when it is.
|
|
14
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
14
15
|
Array.from( container.querySelectorAll( 'mark' ) );
|
|
15
16
|
|
|
16
17
|
const defaultText =
|
package/src/toolbar/style.scss
CHANGED
|
@@ -81,9 +81,11 @@ describe( 'ToolbarGroup', () => {
|
|
|
81
81
|
const buttons = screen.getAllByRole( 'button' );
|
|
82
82
|
|
|
83
83
|
expect( buttons ).toHaveLength( 2 );
|
|
84
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
84
85
|
expect( buttons[ 0 ].parentElement ).not.toHaveClass(
|
|
85
86
|
'has-left-divider'
|
|
86
87
|
);
|
|
88
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
87
89
|
expect( buttons[ 1 ].parentElement ).toHaveClass(
|
|
88
90
|
'has-left-divider'
|
|
89
91
|
);
|