@wordpress/components 21.2.0 → 21.3.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 +35 -3
- package/CONTRIBUTING.md +20 -0
- package/build/border-box-control/border-box-control/component.js +2 -0
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +4 -1
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-control/border-control/component.js +2 -0
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/disabled/index.js +6 -26
- package/build/disabled/index.js.map +1 -1
- package/build/font-size-picker/index.js +1 -1
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/styles.js +5 -13
- package/build/font-size-picker/styles.js.map +1 -1
- package/build/font-size-picker/utils.js +1 -1
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/form-token-field/suggestions-list.js +5 -5
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/higher-order/with-fallback-styles/index.js +1 -1
- package/build/higher-order/with-fallback-styles/index.js.map +1 -1
- package/build/index.js +8 -6
- package/build/index.js.map +1 -1
- package/build/modal/aria-helper.js +2 -3
- package/build/modal/aria-helper.js.map +1 -1
- package/build/modal/index.js +42 -11
- package/build/modal/index.js.map +1 -1
- package/build/modal/types.js +6 -0
- package/build/modal/types.js.map +1 -0
- package/build/navigator/index.js +8 -8
- package/build/navigator/index.js.map +1 -1
- package/build/navigator/navigator-back-button/component.js +5 -4
- package/build/navigator/navigator-back-button/component.js.map +1 -1
- package/build/navigator/navigator-back-button/index.js +1 -1
- package/build/navigator/navigator-back-button/index.js.map +1 -1
- package/build/navigator/navigator-button/component.js +5 -4
- package/build/navigator/navigator-button/component.js.map +1 -1
- package/build/navigator/navigator-button/index.js +1 -1
- package/build/navigator/navigator-button/index.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +10 -7
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-provider/index.js +1 -1
- package/build/navigator/navigator-provider/index.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +24 -27
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/navigator/navigator-screen/index.js +1 -1
- package/build/navigator/navigator-screen/index.js.map +1 -1
- package/build/sandbox/index.js +55 -59
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +63 -62
- package/build/sandbox/index.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/tab-panel/index.js +4 -4
- package/build/tab-panel/index.js.map +1 -1
- package/build/theme/index.js +62 -0
- package/build/theme/index.js.map +1 -0
- package/build/theme/styles.js +33 -0
- package/build/theme/styles.js.map +1 -0
- package/build/theme/types.js +6 -0
- package/build/theme/types.js.map +1 -0
- package/build/tools-panel/tools-panel/hook.js +3 -3
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +6 -6
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tooltip/index.js +4 -1
- package/build/tooltip/index.js.map +1 -1
- package/build/tooltip/index.native.js +17 -4
- package/build/tooltip/index.native.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +2 -0
- 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 +4 -1
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-control/border-control/component.js +2 -0
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/disabled/index.js +7 -26
- package/build-module/disabled/index.js.map +1 -1
- package/build-module/font-size-picker/index.js +1 -1
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/styles.js +5 -13
- package/build-module/font-size-picker/styles.js.map +1 -1
- package/build-module/font-size-picker/utils.js +1 -1
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/form-token-field/suggestions-list.js +5 -5
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/higher-order/with-fallback-styles/index.js +2 -2
- package/build-module/higher-order/with-fallback-styles/index.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/modal/aria-helper.js +2 -3
- package/build-module/modal/aria-helper.js.map +1 -1
- package/build-module/modal/index.js +44 -12
- package/build-module/modal/index.js.map +1 -1
- package/build-module/modal/types.js +2 -0
- package/build-module/modal/types.js.map +1 -0
- package/build-module/navigator/index.js +4 -4
- package/build-module/navigator/index.js.map +1 -1
- package/build-module/navigator/navigator-back-button/component.js +3 -3
- package/build-module/navigator/navigator-back-button/component.js.map +1 -1
- package/build-module/navigator/navigator-back-button/index.js +1 -1
- package/build-module/navigator/navigator-back-button/index.js.map +1 -1
- package/build-module/navigator/navigator-button/component.js +3 -3
- package/build-module/navigator/navigator-button/component.js.map +1 -1
- package/build-module/navigator/navigator-button/index.js +1 -1
- package/build-module/navigator/navigator-button/index.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +8 -6
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-provider/index.js +1 -1
- package/build-module/navigator/navigator-provider/index.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +12 -26
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/index.js +1 -1
- package/build-module/navigator/navigator-screen/index.js.map +1 -1
- package/build-module/sandbox/index.js +56 -59
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +54 -52
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/tab-panel/index.js +4 -4
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/theme/index.js +52 -0
- package/build-module/theme/index.js.map +1 -0
- package/build-module/theme/styles.js +25 -0
- package/build-module/theme/styles.js.map +1 -0
- package/build-module/theme/types.js +2 -0
- package/build-module/theme/types.js.map +1 -0
- package/build-module/tools-panel/tools-panel/hook.js +3 -3
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +6 -6
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tooltip/index.js +4 -1
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tooltip/index.native.js +17 -4
- package/build-module/tooltip/index.native.js.map +1 -1
- package/build-style/style-rtl.css +26 -22
- package/build-style/style.css +26 -22
- 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 +1 -0
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -0
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +1 -0
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/stories/index.d.ts +6 -0
- package/build-types/border-control/stories/index.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +4 -0
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/confirm-dialog/types.d.ts +5 -1
- package/build-types/confirm-dialog/types.d.ts.map +1 -1
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/font-size-picker/styles.d.ts.map +1 -1
- package/build-types/modal/aria-helper.d.ts +4 -4
- package/build-types/modal/aria-helper.d.ts.map +1 -1
- package/build-types/modal/index.d.ts +35 -2
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.d.ts +9 -0
- package/build-types/modal/stories/index.d.ts.map +1 -0
- package/build-types/modal/test/aria-helper.d.ts +2 -0
- package/build-types/modal/test/aria-helper.d.ts.map +1 -0
- package/build-types/modal/test/index.d.ts +2 -0
- package/build-types/modal/test/index.d.ts.map +1 -0
- package/build-types/modal/types.d.ts +134 -0
- package/build-types/modal/types.d.ts.map +1 -0
- package/build-types/navigator/index.d.ts +4 -4
- package/build-types/navigator/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/component.d.ts +4 -2
- package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
- package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/index.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/component.d.ts +4 -2
- package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +1 -0
- package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/index.d.ts +1 -1
- package/build-types/navigator/navigator-button/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/component.d.ts +2 -2
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/index.d.ts +1 -1
- package/build-types/navigator/navigator-provider/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +2 -2
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/index.d.ts +1 -1
- package/build-types/navigator/navigator-screen/index.d.ts.map +1 -1
- package/build-types/navigator/stories/index.d.ts +9 -0
- package/build-types/navigator/stories/index.d.ts.map +1 -0
- package/build-types/navigator/test/index.d.ts +2 -0
- package/build-types/navigator/test/index.d.ts.map +1 -0
- package/build-types/navigator/types.d.ts +4 -1
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/theme/index.d.ts +31 -0
- package/build-types/theme/index.d.ts.map +1 -0
- package/build-types/theme/stories/index.d.ts +13 -0
- package/build-types/theme/stories/index.d.ts.map +1 -0
- package/build-types/theme/styles.d.ts +10 -0
- package/build-types/theme/styles.d.ts.map +1 -0
- package/build-types/theme/test/index.d.ts +2 -0
- package/build-types/theme/test/index.d.ts.map +1 -0
- package/build-types/theme/types.d.ts +21 -0
- package/build-types/theme/types.d.ts.map +1 -0
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- 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/package.json +17 -17
- package/src/base-field/test/index.js +4 -6
- package/src/border-box-control/border-box-control/component.tsx +2 -0
- package/src/border-box-control/border-box-control/hook.ts +4 -0
- package/src/border-box-control/test/index.js +7 -2
- package/src/border-control/border-control/README.md +6 -0
- package/src/border-control/border-control/component.tsx +2 -0
- package/src/border-control/types.ts +4 -0
- package/src/button/style.scss +25 -25
- package/src/button/test/index.js +3 -5
- package/src/combobox-control/test/index.js +1 -1
- package/src/confirm-dialog/types.ts +6 -0
- package/src/date-time/time/test/index.tsx +2 -6
- package/src/disabled/index.tsx +11 -33
- package/src/disabled/test/index.tsx +14 -82
- package/src/dropdown/test/index.js +4 -3
- package/src/font-size-picker/index.tsx +1 -1
- package/src/font-size-picker/styles.ts +3 -1
- package/src/font-size-picker/test/index.tsx +2 -2
- package/src/font-size-picker/test/utils.ts +5 -5
- package/src/font-size-picker/utils.ts +1 -1
- package/src/form-file-upload/test/index.tsx +1 -1
- package/src/form-token-field/suggestions-list.tsx +5 -5
- package/src/higher-order/with-fallback-styles/index.js +6 -2
- package/src/higher-order/with-focus-outside/test/index.js +44 -45
- package/src/higher-order/with-focus-return/test/index.js +34 -30
- package/src/higher-order/with-notices/test/index.js +1 -1
- package/src/index.js +2 -1
- package/src/input-control/test/index.js +2 -2
- package/src/item-group/test/index.js +2 -2
- package/src/menu-item/test/index.js +0 -3
- package/src/mobile/bottom-sheet/test/range-cell.native.js +16 -14
- package/src/modal/README.md +53 -54
- package/src/modal/{aria-helper.js → aria-helper.ts} +5 -7
- package/src/modal/{index.js → index.tsx} +48 -12
- package/src/modal/stories/{index.js → index.tsx} +47 -42
- package/src/modal/test/{aria-helper.js → aria-helper.ts} +0 -0
- package/src/modal/test/{index.js → index.tsx} +13 -3
- package/src/modal/types.ts +144 -0
- package/src/navigation/test/index.js +1 -1
- package/src/navigator/index.ts +4 -4
- package/src/navigator/navigator-back-button/component.tsx +4 -4
- package/src/navigator/navigator-back-button/index.ts +1 -1
- package/src/navigator/navigator-button/component.tsx +4 -4
- package/src/navigator/navigator-button/index.ts +1 -1
- package/src/navigator/navigator-provider/component.tsx +6 -4
- package/src/navigator/navigator-provider/index.ts +1 -1
- package/src/navigator/navigator-screen/component.tsx +20 -26
- package/src/navigator/navigator-screen/index.ts +1 -1
- package/src/navigator/stories/index.tsx +210 -0
- package/src/navigator/test/index.tsx +509 -0
- package/src/navigator/types.ts +2 -0
- package/src/notice/test/__snapshots__/index.js.snap +39 -38
- package/src/notice/test/index.js +15 -36
- package/src/notice/test/list.js +6 -14
- package/src/number-control/test/index.js +3 -2
- package/src/panel/test/body.js +2 -2
- package/src/placeholder/style.scss +5 -0
- package/src/sandbox/index.js +62 -47
- package/src/sandbox/index.native.js +72 -52
- package/src/sandbox/test/index.js +7 -10
- package/src/shortcut/test/index.tsx +1 -1
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +5 -3
- package/src/style.scss +4 -0
- package/src/tab-panel/index.tsx +4 -7
- package/src/text-highlight/test/index.tsx +1 -3
- package/src/theme/README.md +34 -0
- package/src/theme/index.tsx +51 -0
- package/src/theme/stories/index.tsx +47 -0
- package/src/theme/styles.ts +28 -0
- package/src/theme/test/index.tsx +101 -0
- package/src/theme/types.ts +21 -0
- package/src/toolbar/test/index.js +2 -2
- package/src/toolbar-group/test/index.js +6 -10
- package/src/tools-panel/test/index.js +4 -6
- package/src/tools-panel/tools-panel/hook.ts +2 -9
- package/src/tools-panel/tools-panel-item/hook.ts +17 -3
- package/src/tooltip/index.js +3 -0
- package/src/tooltip/index.native.js +15 -0
- package/src/tooltip/test/index.native.js +1 -2
- package/src/tree-grid/test/__snapshots__/cell.js.snap +1 -3
- package/src/tree-grid/test/__snapshots__/roving-tab-index-item.js.snap +17 -15
- package/src/tree-grid/test/__snapshots__/row.js.snap +25 -21
- package/src/tree-grid/test/cell.js +4 -4
- package/src/tree-grid/test/roving-tab-index-item.js +8 -8
- package/src/tree-grid/test/roving-tab-index.js +3 -3
- package/src/tree-grid/test/row.js +20 -16
- package/src/truncate/test/index.tsx +4 -4
- package/src/ui/shortcut/test/index.js +2 -1
- package/src/ui/spinner/test/index.js +14 -13
- package/src/ui/tooltip/test/index.js +16 -14
- package/src/utils/theme-variables.scss +8 -0
- package/src/visually-hidden/README.md +4 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/navigator/stories/index.js +0 -194
- package/src/navigator/test/index.js +0 -472
package/src/notice/test/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
import { create } from 'react-test-renderer';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
9
8
|
*/
|
|
10
|
-
import TokenList from '@wordpress/token-list';
|
|
11
9
|
import { speak } from '@wordpress/a11y';
|
|
12
10
|
|
|
13
11
|
/**
|
|
@@ -23,9 +21,7 @@ describe( 'Notice', () => {
|
|
|
23
21
|
} );
|
|
24
22
|
|
|
25
23
|
it( 'should match snapshot', () => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
renderer.render(
|
|
24
|
+
const { container } = render(
|
|
29
25
|
<Notice
|
|
30
26
|
status="success"
|
|
31
27
|
actions={ [
|
|
@@ -38,63 +34,47 @@ describe( 'Notice', () => {
|
|
|
38
34
|
</Notice>
|
|
39
35
|
);
|
|
40
36
|
|
|
41
|
-
expect(
|
|
37
|
+
expect( container ).toMatchSnapshot();
|
|
42
38
|
} );
|
|
43
39
|
|
|
44
40
|
it( 'should not have is-dismissible class when isDismissible prop is false', () => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
renderer.render( <Notice isDismissible={ false } /> );
|
|
41
|
+
const { container } = render( <Notice isDismissible={ false } /> );
|
|
48
42
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
expect( classes.contains( 'components-notice' ) ).toBe( true );
|
|
53
|
-
expect( classes.contains( 'is-dismissible' ) ).toBe( false );
|
|
43
|
+
expect( container.firstChild ).toHaveClass( 'components-notice' );
|
|
44
|
+
expect( container.firstChild ).not.toHaveClass( 'is-dismissible' );
|
|
54
45
|
} );
|
|
55
46
|
|
|
56
47
|
it( 'should default to info status', () => {
|
|
57
|
-
const
|
|
48
|
+
const { container } = render( <Notice /> );
|
|
58
49
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const classes = new TokenList(
|
|
62
|
-
renderer.getRenderOutput().props.className
|
|
63
|
-
);
|
|
64
|
-
expect( classes.contains( 'is-info' ) ).toBe( true );
|
|
50
|
+
expect( container.firstChild ).toHaveClass( 'is-info' );
|
|
65
51
|
} );
|
|
66
52
|
|
|
67
53
|
describe( 'useSpokenMessage', () => {
|
|
68
54
|
it( 'should speak the given message', () => {
|
|
69
|
-
|
|
70
|
-
tree.update();
|
|
55
|
+
render( <Notice>FYI</Notice> );
|
|
71
56
|
|
|
72
57
|
expect( speak ).toHaveBeenCalledWith( 'FYI', 'polite' );
|
|
73
58
|
} );
|
|
74
59
|
|
|
75
60
|
it( 'should speak the given message by explicit politeness', () => {
|
|
76
|
-
|
|
77
|
-
<Notice politeness="assertive">Uh oh!</Notice>
|
|
78
|
-
);
|
|
79
|
-
tree.update();
|
|
61
|
+
render( <Notice politeness="assertive">Uh oh!</Notice> );
|
|
80
62
|
|
|
81
63
|
expect( speak ).toHaveBeenCalledWith( 'Uh oh!', 'assertive' );
|
|
82
64
|
} );
|
|
83
65
|
|
|
84
66
|
it( 'should speak the given message by implicit politeness by status', () => {
|
|
85
|
-
|
|
86
|
-
tree.update();
|
|
67
|
+
render( <Notice status="error">Uh oh!</Notice> );
|
|
87
68
|
|
|
88
69
|
expect( speak ).toHaveBeenCalledWith( 'Uh oh!', 'assertive' );
|
|
89
70
|
} );
|
|
90
71
|
|
|
91
72
|
it( 'should speak the given message, preferring explicit to implicit politeness', () => {
|
|
92
|
-
|
|
73
|
+
render(
|
|
93
74
|
<Notice politeness="polite" status="error">
|
|
94
75
|
No need to panic
|
|
95
76
|
</Notice>
|
|
96
77
|
);
|
|
97
|
-
tree.update();
|
|
98
78
|
|
|
99
79
|
expect( speak ).toHaveBeenCalledWith(
|
|
100
80
|
'No need to panic',
|
|
@@ -105,12 +85,11 @@ describe( 'Notice', () => {
|
|
|
105
85
|
it( 'should coerce a message to a string', () => {
|
|
106
86
|
// This test assumes that `@wordpress/a11y` is capable of handling
|
|
107
87
|
// markup strings appropriately.
|
|
108
|
-
|
|
88
|
+
render(
|
|
109
89
|
<Notice>
|
|
110
90
|
With <em>emphasis</em> this time.
|
|
111
91
|
</Notice>
|
|
112
92
|
);
|
|
113
|
-
tree.update();
|
|
114
93
|
|
|
115
94
|
expect( speak ).toHaveBeenCalledWith(
|
|
116
95
|
'With <em>emphasis</em> this time.',
|
|
@@ -119,12 +98,12 @@ describe( 'Notice', () => {
|
|
|
119
98
|
} );
|
|
120
99
|
|
|
121
100
|
it( 'should not re-speak an effectively equivalent element message', () => {
|
|
122
|
-
const
|
|
101
|
+
const { rerender } = render(
|
|
123
102
|
<Notice>
|
|
124
103
|
With <em>emphasis</em> this time.
|
|
125
104
|
</Notice>
|
|
126
105
|
);
|
|
127
|
-
|
|
106
|
+
rerender(
|
|
128
107
|
<Notice>
|
|
129
108
|
With <em>emphasis</em> this time.
|
|
130
109
|
</Notice>
|
package/src/notice/test/list.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import TokenList from '@wordpress/token-list';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
10
5
|
|
|
11
6
|
/**
|
|
12
7
|
* Internal dependencies
|
|
@@ -15,14 +10,11 @@ import NoticeList from '../list';
|
|
|
15
10
|
|
|
16
11
|
describe( 'NoticeList', () => {
|
|
17
12
|
it( 'should merge className', () => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
renderer.render( <NoticeList notices={ [] } className="is-ok" /> );
|
|
21
|
-
|
|
22
|
-
const classes = new TokenList(
|
|
23
|
-
renderer.getRenderOutput().props.className
|
|
13
|
+
const { container } = render(
|
|
14
|
+
<NoticeList notices={ [] } className="is-ok" />
|
|
24
15
|
);
|
|
25
|
-
|
|
26
|
-
expect(
|
|
16
|
+
|
|
17
|
+
expect( container.firstChild ).toHaveClass( 'is-ok' );
|
|
18
|
+
expect( container.firstChild ).toHaveClass( 'components-notice-list' );
|
|
27
19
|
} );
|
|
28
20
|
} );
|
|
@@ -90,9 +90,10 @@ describe( 'NumberControl', () => {
|
|
|
90
90
|
// After the blur, the `onChange` callback fires asynchronously.
|
|
91
91
|
await waitFor( () => {
|
|
92
92
|
expect( spy ).toHaveBeenCalledTimes( 2 );
|
|
93
|
-
expect( spy ).toHaveBeenNthCalledWith( 1, '1' );
|
|
94
|
-
expect( spy ).toHaveBeenNthCalledWith( 2, 4 );
|
|
95
93
|
} );
|
|
94
|
+
|
|
95
|
+
expect( spy ).toHaveBeenNthCalledWith( 1, '1' );
|
|
96
|
+
expect( spy ).toHaveBeenNthCalledWith( 2, 4 );
|
|
96
97
|
} );
|
|
97
98
|
|
|
98
99
|
it( 'should call onChange callback when value is not valid', () => {
|
package/src/panel/test/body.js
CHANGED
|
@@ -67,7 +67,7 @@ describe( 'PanelBody', () => {
|
|
|
67
67
|
let panelContent = getPanelBodyContent( container );
|
|
68
68
|
|
|
69
69
|
expect( panelContent ).toBeTruthy();
|
|
70
|
-
expect( panelContent.
|
|
70
|
+
expect( panelContent ).toHaveAttribute( 'hidden', '' );
|
|
71
71
|
|
|
72
72
|
rerender(
|
|
73
73
|
<PanelBody opened={ false }>
|
|
@@ -77,7 +77,7 @@ describe( 'PanelBody', () => {
|
|
|
77
77
|
panelContent = getPanelBodyContent( container );
|
|
78
78
|
|
|
79
79
|
expect( panelContent ).toBeTruthy();
|
|
80
|
-
expect( panelContent.
|
|
80
|
+
expect( panelContent ).not.toHaveAttribute( 'hidden' );
|
|
81
81
|
} );
|
|
82
82
|
} );
|
|
83
83
|
|
|
@@ -182,6 +182,9 @@
|
|
|
182
182
|
backdrop-filter: blur(100px);
|
|
183
183
|
background-color: transparent;
|
|
184
184
|
|
|
185
|
+
// This appears to fix an occasional Chrome bug where the blurred background would have an incorrect color.
|
|
186
|
+
backface-visibility: hidden;
|
|
187
|
+
|
|
185
188
|
// Invert the colors in themes deemed dark.
|
|
186
189
|
.is-dark-theme & {
|
|
187
190
|
background-color: rgba($black, 0.1);
|
|
@@ -201,6 +204,7 @@
|
|
|
201
204
|
.components-placeholder__instructions,
|
|
202
205
|
.components-button {
|
|
203
206
|
opacity: 0;
|
|
207
|
+
pointer-events: none;
|
|
204
208
|
transition: opacity 0.1s linear;
|
|
205
209
|
@include reduce-motion("transition");
|
|
206
210
|
}
|
|
@@ -210,6 +214,7 @@
|
|
|
210
214
|
.components-placeholder__instructions,
|
|
211
215
|
.components-button {
|
|
212
216
|
opacity: 1;
|
|
217
|
+
pointer-events: auto;
|
|
213
218
|
}
|
|
214
219
|
}
|
|
215
220
|
|
package/src/sandbox/index.js
CHANGED
|
@@ -9,64 +9,79 @@ import {
|
|
|
9
9
|
} from '@wordpress/element';
|
|
10
10
|
import { useFocusableIframe, useMergeRefs } from '@wordpress/compose';
|
|
11
11
|
|
|
12
|
-
const observeAndResizeJS =
|
|
13
|
-
|
|
14
|
-
var observer;
|
|
12
|
+
const observeAndResizeJS = function () {
|
|
13
|
+
const { MutationObserver } = window;
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
if ( ! MutationObserver || ! document.body || ! window.parent ) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
function sendResize() {
|
|
20
|
+
const clientBoundingRect = document.body.getBoundingClientRect();
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
window.parent.postMessage(
|
|
23
|
+
{
|
|
24
24
|
action: 'resize',
|
|
25
25
|
width: clientBoundingRect.width,
|
|
26
26
|
height: clientBoundingRect.height,
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
},
|
|
28
|
+
'*'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
32
|
+
const observer = new MutationObserver( sendResize );
|
|
33
|
+
observer.observe( document.body, {
|
|
34
|
+
attributes: true,
|
|
35
|
+
attributeOldValue: false,
|
|
36
|
+
characterData: true,
|
|
37
|
+
characterDataOldValue: false,
|
|
38
|
+
childList: true,
|
|
39
|
+
subtree: true,
|
|
40
|
+
} );
|
|
41
|
+
|
|
42
|
+
window.addEventListener( 'load', sendResize, true );
|
|
43
|
+
|
|
44
|
+
// Hack: Remove viewport unit styles, as these are relative
|
|
45
|
+
// the iframe root and interfere with our mechanism for
|
|
46
|
+
// determining the unconstrained page bounds.
|
|
47
|
+
function removeViewportStyles( ruleOrNode ) {
|
|
48
|
+
if ( ruleOrNode.style ) {
|
|
49
|
+
[ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function (
|
|
50
|
+
style
|
|
51
|
+
) {
|
|
52
|
+
if (
|
|
53
|
+
/^\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )
|
|
54
|
+
) {
|
|
55
|
+
ruleOrNode.style[ style ] = '';
|
|
56
|
+
}
|
|
57
|
+
} );
|
|
53
58
|
}
|
|
59
|
+
}
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
Array.prototype.forEach.call(
|
|
62
|
+
document.querySelectorAll( '[style]' ),
|
|
63
|
+
removeViewportStyles
|
|
64
|
+
);
|
|
65
|
+
Array.prototype.forEach.call(
|
|
66
|
+
document.styleSheets,
|
|
67
|
+
function ( stylesheet ) {
|
|
68
|
+
Array.prototype.forEach.call(
|
|
69
|
+
stylesheet.cssRules || stylesheet.rules,
|
|
70
|
+
removeViewportStyles
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
59
74
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
document.body.style.position = 'absolute';
|
|
76
|
+
document.body.style.width = '100%';
|
|
77
|
+
document.body.setAttribute( 'data-resizable-iframe-connected', '' );
|
|
63
78
|
|
|
64
|
-
|
|
79
|
+
sendResize();
|
|
65
80
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
81
|
+
// Resize events can change the width of elements with 100% width, but we don't
|
|
82
|
+
// get an DOM mutations for that, so do the resize when the window is resized, too.
|
|
83
|
+
window.addEventListener( 'resize', sendResize, true );
|
|
84
|
+
};
|
|
70
85
|
|
|
71
86
|
const style = `
|
|
72
87
|
body {
|
|
@@ -153,7 +168,7 @@ export default function Sandbox( {
|
|
|
153
168
|
<script
|
|
154
169
|
type="text/javascript"
|
|
155
170
|
dangerouslySetInnerHTML={ {
|
|
156
|
-
__html: observeAndResizeJS
|
|
171
|
+
__html: `(${ observeAndResizeJS.toString() })();`,
|
|
157
172
|
} }
|
|
158
173
|
/>
|
|
159
174
|
{ scripts.map( ( src ) => (
|
|
@@ -22,67 +22,85 @@ import { usePreferredColorScheme } from '@wordpress/compose';
|
|
|
22
22
|
*/
|
|
23
23
|
import sandboxStyles from './style.scss';
|
|
24
24
|
|
|
25
|
-
const observeAndResizeJS =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
const observeAndResizeJS = function () {
|
|
26
|
+
// Hermes requires a special directive to preserve the original source code
|
|
27
|
+
// when using `Function.prototype.toString()` below.
|
|
28
|
+
// https://github.com/facebook/hermes/issues/114#issuecomment-887106990
|
|
29
|
+
'show source';
|
|
30
|
+
const { MutationObserver } = window;
|
|
31
|
+
|
|
32
|
+
if ( ! MutationObserver || ! document.body || ! window.parent ) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
function sendResize() {
|
|
37
|
+
const clientBoundingRect = document.body.getBoundingClientRect();
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
// The function postMessage is exposed by the react-native-webview library
|
|
40
|
+
// to communicate between React Native and the WebView, in this case,
|
|
41
|
+
// we use it for notifying resize changes.
|
|
42
|
+
window.ReactNativeWebView.postMessage(
|
|
43
|
+
JSON.stringify( {
|
|
44
|
+
action: 'resize',
|
|
41
45
|
width: clientBoundingRect.width,
|
|
42
46
|
height: clientBoundingRect.height,
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
} )
|
|
48
|
+
);
|
|
49
|
+
}
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
const observer = new MutationObserver( sendResize );
|
|
52
|
+
observer.observe( document.body, {
|
|
53
|
+
attributes: true,
|
|
54
|
+
attributeOldValue: false,
|
|
55
|
+
characterData: true,
|
|
56
|
+
characterDataOldValue: false,
|
|
57
|
+
childList: true,
|
|
58
|
+
subtree: true,
|
|
59
|
+
} );
|
|
60
|
+
|
|
61
|
+
window.addEventListener( 'load', sendResize, true );
|
|
62
|
+
|
|
63
|
+
// Hack: Remove viewport unit styles, as these are relative
|
|
64
|
+
// the iframe root and interfere with our mechanism for
|
|
65
|
+
// determining the unconstrained page bounds.
|
|
66
|
+
function removeViewportStyles( ruleOrNode ) {
|
|
67
|
+
if ( ruleOrNode.style ) {
|
|
68
|
+
[ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function (
|
|
69
|
+
style
|
|
70
|
+
) {
|
|
71
|
+
if (
|
|
72
|
+
/^\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )
|
|
73
|
+
) {
|
|
74
|
+
ruleOrNode.style[ style ] = '';
|
|
75
|
+
}
|
|
76
|
+
} );
|
|
69
77
|
}
|
|
78
|
+
}
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
Array.prototype.forEach.call(
|
|
81
|
+
document.querySelectorAll( '[style]' ),
|
|
82
|
+
removeViewportStyles
|
|
83
|
+
);
|
|
84
|
+
Array.prototype.forEach.call(
|
|
85
|
+
document.styleSheets,
|
|
86
|
+
function ( stylesheet ) {
|
|
87
|
+
Array.prototype.forEach.call(
|
|
88
|
+
stylesheet.cssRules || stylesheet.rules,
|
|
89
|
+
removeViewportStyles
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
75
93
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
94
|
+
document.body.style.position = 'absolute';
|
|
95
|
+
document.body.style.width = '100%';
|
|
96
|
+
document.body.setAttribute( 'data-resizable-iframe-connected', '' );
|
|
79
97
|
|
|
80
|
-
|
|
98
|
+
sendResize();
|
|
81
99
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
100
|
+
// Resize events can change the width of elements with 100% width, but we don't
|
|
101
|
+
// get an DOM mutations for that, so do the resize when the window is resized, too.
|
|
102
|
+
window.addEventListener( 'resize', sendResize, true );
|
|
103
|
+
};
|
|
86
104
|
|
|
87
105
|
const style = `
|
|
88
106
|
body {
|
|
@@ -215,7 +233,9 @@ function Sandbox( {
|
|
|
215
233
|
<script
|
|
216
234
|
type="text/javascript"
|
|
217
235
|
dangerouslySetInnerHTML={ {
|
|
218
|
-
__html:
|
|
236
|
+
__html:
|
|
237
|
+
customJS ||
|
|
238
|
+
`(${ observeAndResizeJS.toString() })();`,
|
|
219
239
|
} }
|
|
220
240
|
/>
|
|
221
241
|
{ scripts.map( ( src ) => (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -39,28 +39,25 @@ describe( 'Sandbox', () => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
it( 'should rerender with new emdeded content if html prop changes', () => {
|
|
42
|
-
|
|
43
|
-
act( () => {
|
|
44
|
-
result = render( <TestWrapper /> );
|
|
45
|
-
} );
|
|
42
|
+
const result = render( <TestWrapper /> );
|
|
46
43
|
|
|
47
44
|
const iframe = result.container.querySelector( '.components-sandbox' );
|
|
48
45
|
|
|
49
46
|
let sandboxedIframe =
|
|
50
47
|
iframe.contentWindow.document.body.querySelector( '.mock-iframe' );
|
|
51
48
|
|
|
52
|
-
expect( sandboxedIframe
|
|
49
|
+
expect( sandboxedIframe ).toHaveAttribute(
|
|
50
|
+
'src',
|
|
53
51
|
'https://super.embed'
|
|
54
52
|
);
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
fireEvent.click( result.getByRole( 'button' ) );
|
|
58
|
-
} );
|
|
54
|
+
fireEvent.click( screen.getByRole( 'button' ) );
|
|
59
55
|
|
|
60
56
|
sandboxedIframe =
|
|
61
57
|
iframe.contentWindow.document.body.querySelector( '.mock-iframe' );
|
|
62
58
|
|
|
63
|
-
expect( sandboxedIframe
|
|
59
|
+
expect( sandboxedIframe ).toHaveAttribute(
|
|
60
|
+
'src',
|
|
64
61
|
'https://another.super.embed'
|
|
65
62
|
);
|
|
66
63
|
} );
|
|
@@ -11,7 +11,7 @@ import Shortcut from '..';
|
|
|
11
11
|
describe( 'Shortcut', () => {
|
|
12
12
|
it( 'does not render anything if no shortcut prop is provided', () => {
|
|
13
13
|
const { container } = render( <Shortcut /> );
|
|
14
|
-
expect( container
|
|
14
|
+
expect( container ).toBeEmptyDOMElement();
|
|
15
15
|
} );
|
|
16
16
|
|
|
17
17
|
it( 'renders the shortcut display text when a string is passed as the shortcut', () => {
|
|
@@ -67,9 +67,11 @@ function useSlotRegistry() {
|
|
|
67
67
|
if ( fills.current.get( name ) ) {
|
|
68
68
|
fills.current.set(
|
|
69
69
|
name,
|
|
70
|
-
|
|
71
|
-
.
|
|
72
|
-
|
|
70
|
+
valRef(
|
|
71
|
+
fills.current
|
|
72
|
+
.get( name )
|
|
73
|
+
.filter( ( fillRef ) => fillRef !== ref )
|
|
74
|
+
)
|
|
73
75
|
);
|
|
74
76
|
}
|
|
75
77
|
}, [] );
|
package/src/style.scss
CHANGED
package/src/tab-panel/index.tsx
CHANGED
|
@@ -85,7 +85,7 @@ export function TabPanel( {
|
|
|
85
85
|
const instanceId = useInstanceId( TabPanel, 'tab-panel' );
|
|
86
86
|
const [ selected, setSelected ] = useState< string >();
|
|
87
87
|
|
|
88
|
-
const
|
|
88
|
+
const handleTabSelection = ( tabKey: string ) => {
|
|
89
89
|
setSelected( tabKey );
|
|
90
90
|
onSelect?.( tabKey );
|
|
91
91
|
};
|
|
@@ -98,11 +98,8 @@ export function TabPanel( {
|
|
|
98
98
|
|
|
99
99
|
useEffect( () => {
|
|
100
100
|
const newSelectedTab = find( tabs, { name: selected } );
|
|
101
|
-
if ( ! newSelectedTab ) {
|
|
102
|
-
|
|
103
|
-
initialTabName ||
|
|
104
|
-
( tabs.length > 0 ? tabs[ 0 ].name : undefined )
|
|
105
|
-
);
|
|
101
|
+
if ( ! newSelectedTab && tabs.length > 0 ) {
|
|
102
|
+
handleTabSelection( initialTabName || tabs[ 0 ].name );
|
|
106
103
|
}
|
|
107
104
|
}, [ tabs ] );
|
|
108
105
|
|
|
@@ -127,7 +124,7 @@ export function TabPanel( {
|
|
|
127
124
|
aria-controls={ `${ instanceId }-${ tab.name }-view` }
|
|
128
125
|
selected={ tab.name === selected }
|
|
129
126
|
key={ tab.name }
|
|
130
|
-
onClick={ () =>
|
|
127
|
+
onClick={ () => handleTabSelection( tab.name ) }
|
|
131
128
|
>
|
|
132
129
|
{ tab.title }
|
|
133
130
|
</TabButton>
|
|
@@ -50,9 +50,7 @@ describe( 'TextHighlight', () => {
|
|
|
50
50
|
expect( highlightedEls ).toHaveLength( 2 );
|
|
51
51
|
|
|
52
52
|
highlightedEls.forEach( ( el ) => {
|
|
53
|
-
expect( el
|
|
54
|
-
expect.stringContaining( highlight )
|
|
55
|
-
);
|
|
53
|
+
expect( el ).toHaveTextContent( highlight );
|
|
56
54
|
} );
|
|
57
55
|
} );
|
|
58
56
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Theme
|
|
2
|
+
|
|
3
|
+
<div class="callout callout-alert">
|
|
4
|
+
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
`Theme` allows defining theme variables for components in the `@wordpress/components` package.
|
|
8
|
+
|
|
9
|
+
Multiple `Theme` components can be nested in order to override specific theme variables.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { __experimentalTheme as Theme } from '@wordpress/components';
|
|
15
|
+
|
|
16
|
+
const Example = () => {
|
|
17
|
+
return (
|
|
18
|
+
<Theme accent="red">
|
|
19
|
+
<Button variant="primary">I'm red</Button>
|
|
20
|
+
<Theme accent="blue">
|
|
21
|
+
<Button variant="primary">I'm blue</Button>
|
|
22
|
+
</Theme>
|
|
23
|
+
</Theme>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Props
|
|
29
|
+
|
|
30
|
+
### `accent`: `string`
|
|
31
|
+
|
|
32
|
+
Used to set the accent color (used by components as the primary color). If an accent color is not defined, the default fallback value is the original WP Admin main theme color. No all valid CSS color syntaxes are supported — in particular, keywords (like `'currentcolor'`, `'inherit'`, `'initial'`, `'revert'`, `'unset'`...) and CSS custom properties (e.g. `var(--my-custom-property)`) are _not_ supported values for this property.
|
|
33
|
+
|
|
34
|
+
- Required: No
|