@wordpress/components 21.1.0 → 21.1.2-next.4d3b314fd5.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 +18 -0
- package/build/draggable/index.js +3 -6
- package/build/draggable/index.js.map +1 -1
- package/build/index.js +6 -0
- package/build/index.js.map +1 -1
- package/build/menu-item/index.js +4 -3
- package/build/menu-item/index.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +12 -3
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build/mobile/color-settings/index.native.js +3 -1
- package/build/mobile/color-settings/index.native.js.map +1 -1
- package/build/mobile/color-settings/picker-screen.native.js +3 -1
- package/build/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build/mobile/image/index.native.js +3 -1
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-avoiding-view/index.ios.js +3 -1
- package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build/mobile/link-picker/index.native.js +3 -1
- package/build/mobile/link-picker/index.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +3 -1
- package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-screen.native.js +3 -1
- package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build/mobile/link-settings/index.native.js +24 -6
- package/build/mobile/link-settings/index.native.js.map +1 -1
- package/build/mobile/link-settings/link-settings-screen.native.js +3 -1
- package/build/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build/mobile/segmented-control/index.native.js +6 -2
- package/build/mobile/segmented-control/index.native.js.map +1 -1
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build/notice/index.native.js +15 -19
- package/build/notice/index.native.js.map +1 -1
- package/build/notice/list.native.js +2 -3
- package/build/notice/list.native.js.map +1 -1
- package/build/palette-edit/index.js +1 -1
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +29 -32
- package/build/popover/index.js.map +1 -1
- package/build/popover/limit-shift.js +145 -0
- package/build/popover/limit-shift.js.map +1 -0
- package/build/popover/utils.js +55 -15
- package/build/popover/utils.js.map +1 -1
- package/build/tools-panel/styles.js +27 -12
- package/build/tools-panel/styles.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +19 -6
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/hook.js +4 -0
- package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build-module/draggable/index.js +2 -5
- package/build-module/draggable/index.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/menu-item/index.js +4 -3
- package/build-module/menu-item/index.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +12 -3
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/index.native.js +3 -1
- package/build-module/mobile/color-settings/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/picker-screen.native.js +3 -1
- package/build-module/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +3 -1
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js +3 -1
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build-module/mobile/link-picker/index.native.js +3 -1
- package/build-module/mobile/link-picker/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js +3 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build-module/mobile/link-settings/index.native.js +24 -6
- package/build-module/mobile/link-settings/index.native.js.map +1 -1
- package/build-module/mobile/link-settings/link-settings-screen.native.js +3 -1
- package/build-module/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build-module/mobile/segmented-control/index.native.js +6 -2
- package/build-module/mobile/segmented-control/index.native.js.map +1 -1
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build-module/notice/index.native.js +16 -21
- package/build-module/notice/index.native.js.map +1 -1
- package/build-module/notice/list.native.js +3 -3
- package/build-module/notice/list.native.js.map +1 -1
- package/build-module/palette-edit/index.js +1 -1
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +31 -35
- package/build-module/popover/index.js.map +1 -1
- package/build-module/popover/limit-shift.js +136 -0
- package/build-module/popover/limit-shift.js.map +1 -0
- package/build-module/popover/utils.js +55 -15
- package/build-module/popover/utils.js.map +1 -1
- package/build-module/tools-panel/styles.js +23 -12
- package/build-module/tools-panel/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +19 -7
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/hook.js +4 -0
- package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build-style/style-rtl.css +13 -2
- package/build-style/style.css +13 -2
- package/build-types/draggable/index.d.ts.map +1 -1
- package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
- package/build-types/focal-point-picker/styles/focal-point-style.d.ts +3 -3
- package/build-types/menu-item/index.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/limit-shift.d.ts +87 -0
- package/build-types/popover/limit-shift.d.ts.map +1 -0
- package/build-types/popover/test/index.d.ts +2 -0
- package/build-types/popover/test/index.d.ts.map +1 -0
- package/build-types/popover/types.d.ts +1 -1
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/popover/utils.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +0 -32
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/spinner/index.d.ts +1 -1
- package/build-types/tools-panel/styles.d.ts +6 -0
- package/build-types/tools-panel/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -0
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +1 -0
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/draggable/index.js +2 -5
- package/src/index.js +1 -1
- package/src/menu-item/README.md +7 -0
- package/src/menu-item/index.js +11 -5
- package/src/menu-item/style.scss +1 -0
- package/src/menu-item/test/index.js +36 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +9 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +11 -0
- package/src/mobile/bottom-sheet/sub-sheet/index.native.js +3 -0
- package/src/mobile/color-settings/index.native.js +3 -0
- package/src/mobile/color-settings/picker-screen.native.js +3 -0
- package/src/mobile/image/index.native.js +3 -0
- package/src/mobile/keyboard-avoiding-view/index.ios.js +3 -0
- package/src/mobile/link-picker/index.native.js +3 -0
- package/src/mobile/link-picker/link-picker-results.native.js +3 -0
- package/src/mobile/link-picker/link-picker-screen.native.js +3 -0
- package/src/mobile/link-settings/index.native.js +18 -0
- package/src/mobile/link-settings/link-settings-screen.native.js +3 -0
- package/src/mobile/segmented-control/index.native.js +6 -0
- package/src/mobile/utils/use-unit-converter-to-mobile.native.js +6 -0
- package/src/notice/index.native.js +17 -20
- package/src/notice/list.native.js +7 -3
- package/src/palette-edit/index.js +1 -1
- package/src/placeholder/style.scss +1 -1
- package/src/popover/index.tsx +26 -42
- package/src/popover/limit-shift.ts +205 -0
- package/src/popover/test/index.tsx +230 -0
- package/src/popover/types.ts +1 -0
- package/src/popover/utils.ts +58 -16
- package/src/range-control/types.ts +0 -33
- package/src/tools-panel/stories/index.js +27 -0
- package/src/tools-panel/styles.ts +28 -1
- package/src/tools-panel/tools-panel-header/component.tsx +12 -5
- package/src/tools-panel/tools-panel-header/hook.ts +5 -0
- package/src/tools-panel/types.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/popover/test/__snapshots__/index.js.snap +0 -34
- package/src/popover/test/index.js +0 -164
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Popover Component should pass additional props to portaled element 1`] = `
|
|
4
|
-
<span>
|
|
5
|
-
<div
|
|
6
|
-
class="components-popover"
|
|
7
|
-
role="tooltip"
|
|
8
|
-
style="position: absolute; opacity: 0; transform: translateY(-2em) scale(0) translateZ(0); transform-origin: 0% 0% 0;"
|
|
9
|
-
tabindex="-1"
|
|
10
|
-
>
|
|
11
|
-
<div
|
|
12
|
-
class="components-popover__content"
|
|
13
|
-
>
|
|
14
|
-
Hello
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
</span>
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
exports[`Popover Component should render content 1`] = `
|
|
21
|
-
<span>
|
|
22
|
-
<div
|
|
23
|
-
class="components-popover"
|
|
24
|
-
style="position: absolute; opacity: 0; transform: translateY(-2em) scale(0) translateZ(0); transform-origin: 0% 0% 0;"
|
|
25
|
-
tabindex="-1"
|
|
26
|
-
>
|
|
27
|
-
<div
|
|
28
|
-
class="components-popover__content"
|
|
29
|
-
>
|
|
30
|
-
Hello
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
</span>
|
|
34
|
-
`;
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { act, render, screen } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import Popover from '../';
|
|
15
|
-
|
|
16
|
-
import { positionToPlacement, placementToMotionAnimationProps } from '../utils';
|
|
17
|
-
|
|
18
|
-
describe( 'Popover', () => {
|
|
19
|
-
describe( 'Component', () => {
|
|
20
|
-
afterEach( () => {
|
|
21
|
-
if ( document.activeElement ) {
|
|
22
|
-
document.activeElement.blur();
|
|
23
|
-
}
|
|
24
|
-
} );
|
|
25
|
-
|
|
26
|
-
it( 'should allow focus-on-open behavior to be disabled', () => {
|
|
27
|
-
expect( document.activeElement ).toBe( document.body );
|
|
28
|
-
|
|
29
|
-
act( () => {
|
|
30
|
-
render( <Popover focusOnMount={ false } /> );
|
|
31
|
-
|
|
32
|
-
jest.advanceTimersByTime( 1 );
|
|
33
|
-
} );
|
|
34
|
-
|
|
35
|
-
expect( document.activeElement ).toBe( document.body );
|
|
36
|
-
} );
|
|
37
|
-
|
|
38
|
-
it( 'should render content', () => {
|
|
39
|
-
let result;
|
|
40
|
-
act( () => {
|
|
41
|
-
result = render( <Popover>Hello</Popover> );
|
|
42
|
-
} );
|
|
43
|
-
|
|
44
|
-
expect(
|
|
45
|
-
result.container.querySelector( 'span' )
|
|
46
|
-
).toMatchSnapshot();
|
|
47
|
-
} );
|
|
48
|
-
|
|
49
|
-
it( 'should pass additional props to portaled element', () => {
|
|
50
|
-
let result;
|
|
51
|
-
act( () => {
|
|
52
|
-
result = render( <Popover role="tooltip">Hello</Popover> );
|
|
53
|
-
} );
|
|
54
|
-
|
|
55
|
-
expect(
|
|
56
|
-
result.container.querySelector( 'span' )
|
|
57
|
-
).toMatchSnapshot();
|
|
58
|
-
} );
|
|
59
|
-
|
|
60
|
-
it( 'should render correctly when anchor is provided', () => {
|
|
61
|
-
const PopoverWithAnchor = ( args ) => {
|
|
62
|
-
// Use internal state instead of a ref to make sure that the component
|
|
63
|
-
// re-renders when the popover's anchor updates.
|
|
64
|
-
const [ anchor, setAnchor ] = useState( null );
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<div>
|
|
68
|
-
<p ref={ setAnchor }>Anchor</p>
|
|
69
|
-
<Popover { ...args } anchor={ anchor } />
|
|
70
|
-
</div>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
render( <PopoverWithAnchor>Popover content</PopoverWithAnchor> );
|
|
75
|
-
|
|
76
|
-
expect( screen.getByText( 'Popover content' ) ).toBeInTheDocument();
|
|
77
|
-
} );
|
|
78
|
-
} );
|
|
79
|
-
|
|
80
|
-
describe( 'positionToPlacement', () => {
|
|
81
|
-
it.each( [
|
|
82
|
-
[ 'top left', 'top-end' ],
|
|
83
|
-
[ 'top center', 'top' ],
|
|
84
|
-
[ 'top right', 'top-start' ],
|
|
85
|
-
[ 'middle left', 'left' ],
|
|
86
|
-
[ 'middle center', 'center' ],
|
|
87
|
-
[ 'middle right', 'right' ],
|
|
88
|
-
[ 'bottom left', 'bottom-end' ],
|
|
89
|
-
[ 'bottom center', 'bottom' ],
|
|
90
|
-
[ 'bottom right', 'bottom-start' ],
|
|
91
|
-
] )( 'converts `%s` to `%s`', ( inputPosition, expectedPlacement ) => {
|
|
92
|
-
expect( positionToPlacement( inputPosition ) ).toEqual(
|
|
93
|
-
expectedPlacement
|
|
94
|
-
);
|
|
95
|
-
} );
|
|
96
|
-
} );
|
|
97
|
-
|
|
98
|
-
describe( 'placementToMotionAnimationProps', () => {
|
|
99
|
-
describe( 'animation origin', () => {
|
|
100
|
-
it.each( [
|
|
101
|
-
[ 'top', 0.5, 1 ],
|
|
102
|
-
[ 'top-start', 0, 1 ],
|
|
103
|
-
[ 'top-end', 1, 1 ],
|
|
104
|
-
[ 'right', 0, 0.5 ],
|
|
105
|
-
[ 'right-start', 0, 0 ],
|
|
106
|
-
[ 'right-end', 0, 1 ],
|
|
107
|
-
[ 'bottom', 0.5, 0 ],
|
|
108
|
-
[ 'bottom-start', 0, 0 ],
|
|
109
|
-
[ 'bottom-end', 1, 0 ],
|
|
110
|
-
[ 'left', 1, 0.5 ],
|
|
111
|
-
[ 'left-start', 1, 0 ],
|
|
112
|
-
[ 'left-end', 1, 1 ],
|
|
113
|
-
] )(
|
|
114
|
-
'for the `%s` placement computes an animation origin of (%d, %d)',
|
|
115
|
-
( inputPlacement, expectedOriginX, expectedOriginY ) => {
|
|
116
|
-
expect(
|
|
117
|
-
placementToMotionAnimationProps( inputPlacement )
|
|
118
|
-
).toEqual(
|
|
119
|
-
expect.objectContaining( {
|
|
120
|
-
style: expect.objectContaining( {
|
|
121
|
-
originX: expectedOriginX,
|
|
122
|
-
originY: expectedOriginY,
|
|
123
|
-
} ),
|
|
124
|
-
} )
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
);
|
|
128
|
-
} );
|
|
129
|
-
describe( 'initial translation', () => {
|
|
130
|
-
it.each( [
|
|
131
|
-
[ 'top', 'translateY', '2em' ],
|
|
132
|
-
[ 'top-start', 'translateY', '2em' ],
|
|
133
|
-
[ 'top-end', 'translateY', '2em' ],
|
|
134
|
-
[ 'right', 'translateX', '-2em' ],
|
|
135
|
-
[ 'right-start', 'translateX', '-2em' ],
|
|
136
|
-
[ 'right-end', 'translateX', '-2em' ],
|
|
137
|
-
[ 'bottom', 'translateY', '-2em' ],
|
|
138
|
-
[ 'bottom-start', 'translateY', '-2em' ],
|
|
139
|
-
[ 'bottom-end', 'translateY', '-2em' ],
|
|
140
|
-
[ 'left', 'translateX', '2em' ],
|
|
141
|
-
[ 'left-start', 'translateX', '2em' ],
|
|
142
|
-
[ 'left-end', 'translateX', '2em' ],
|
|
143
|
-
] )(
|
|
144
|
-
'for the `%s` placement computes an initial `%s` of `%s',
|
|
145
|
-
(
|
|
146
|
-
inputPlacement,
|
|
147
|
-
expectedTranslationProp,
|
|
148
|
-
expectedTranslationValue
|
|
149
|
-
) => {
|
|
150
|
-
expect(
|
|
151
|
-
placementToMotionAnimationProps( inputPlacement )
|
|
152
|
-
).toEqual(
|
|
153
|
-
expect.objectContaining( {
|
|
154
|
-
initial: expect.objectContaining( {
|
|
155
|
-
[ expectedTranslationProp ]:
|
|
156
|
-
expectedTranslationValue,
|
|
157
|
-
} ),
|
|
158
|
-
} )
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
} );
|
|
163
|
-
} );
|
|
164
|
-
} );
|