@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
|
@@ -290,39 +290,6 @@ export type UseControlledRangeValueArgs = {
|
|
|
290
290
|
value: number | null;
|
|
291
291
|
};
|
|
292
292
|
|
|
293
|
-
export type UseDebouncedHoverInteractionArgs = {
|
|
294
|
-
/**
|
|
295
|
-
* A callback function invoked when the element is hidden.
|
|
296
|
-
*
|
|
297
|
-
* @default () => {}
|
|
298
|
-
*/
|
|
299
|
-
onHide?: () => void;
|
|
300
|
-
/**
|
|
301
|
-
* A callback function invoked when the mouse is moved out of the element.
|
|
302
|
-
*
|
|
303
|
-
* @default () => {}
|
|
304
|
-
*/
|
|
305
|
-
onMouseLeave?: MouseEventHandler< HTMLInputElement >;
|
|
306
|
-
/**
|
|
307
|
-
* A callback function invoked when the mouse is moved.
|
|
308
|
-
*
|
|
309
|
-
* @default () => {}
|
|
310
|
-
*/
|
|
311
|
-
onMouseMove?: MouseEventHandler< HTMLInputElement >;
|
|
312
|
-
/**
|
|
313
|
-
* A callback function invoked when the element is shown.
|
|
314
|
-
*
|
|
315
|
-
* @default () => {}
|
|
316
|
-
*/
|
|
317
|
-
onShow?: () => void;
|
|
318
|
-
/**
|
|
319
|
-
* Timeout before the element is shown or hidden.
|
|
320
|
-
*
|
|
321
|
-
* @default 300
|
|
322
|
-
*/
|
|
323
|
-
timeout?: number;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
293
|
export type UseMarksArgs = NumericProps & {
|
|
327
294
|
marks: RangeMarks;
|
|
328
295
|
step: number;
|
|
@@ -29,11 +29,13 @@ export const _default = () => {
|
|
|
29
29
|
const [ height, setHeight ] = useState();
|
|
30
30
|
const [ minHeight, setMinHeight ] = useState();
|
|
31
31
|
const [ width, setWidth ] = useState();
|
|
32
|
+
const [ scale, setScale ] = useState();
|
|
32
33
|
|
|
33
34
|
const resetAll = () => {
|
|
34
35
|
setHeight( undefined );
|
|
35
36
|
setWidth( undefined );
|
|
36
37
|
setMinHeight( undefined );
|
|
38
|
+
setScale( undefined );
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
return (
|
|
@@ -79,6 +81,31 @@ export const _default = () => {
|
|
|
79
81
|
onChange={ ( next ) => setMinHeight( next ) }
|
|
80
82
|
/>
|
|
81
83
|
</ToolsPanelItem>
|
|
84
|
+
<ToolsPanelItem
|
|
85
|
+
hasValue={ () => !! scale }
|
|
86
|
+
label="Scale"
|
|
87
|
+
onDeselect={ () => setScale( undefined ) }
|
|
88
|
+
>
|
|
89
|
+
<ToggleGroupControl
|
|
90
|
+
label="Scale"
|
|
91
|
+
value={ scale }
|
|
92
|
+
onChange={ ( next ) => setScale( next ) }
|
|
93
|
+
isBlock
|
|
94
|
+
>
|
|
95
|
+
<ToggleGroupControlOption
|
|
96
|
+
value="cover"
|
|
97
|
+
label="Cover"
|
|
98
|
+
/>
|
|
99
|
+
<ToggleGroupControlOption
|
|
100
|
+
value="contain"
|
|
101
|
+
label="Contain"
|
|
102
|
+
/>
|
|
103
|
+
<ToggleGroupControlOption
|
|
104
|
+
value="fill"
|
|
105
|
+
label="Fill"
|
|
106
|
+
/>
|
|
107
|
+
</ToggleGroupControl>
|
|
108
|
+
</ToolsPanelItem>
|
|
82
109
|
</ToolsPanel>
|
|
83
110
|
</Panel>
|
|
84
111
|
</PanelWrapperView>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
+
import styled from '@emotion/styled';
|
|
4
5
|
import { css } from '@emotion/react';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
Wrapper as BaseControlWrapper,
|
|
13
14
|
} from '../base-control/styles/base-control-styles';
|
|
14
15
|
import { LabelWrapper } from '../input-control/styles/input-control-styles';
|
|
15
|
-
import { COLORS, CONFIG } from '../utils';
|
|
16
|
+
import { COLORS, CONFIG, rtl } from '../utils';
|
|
16
17
|
import { space } from '../ui/utils/space';
|
|
17
18
|
|
|
18
19
|
const toolsPanelGrid = {
|
|
@@ -145,3 +146,29 @@ export const ToolsPanelItemPlaceholder = css`
|
|
|
145
146
|
export const DropdownMenu = css`
|
|
146
147
|
min-width: 200px;
|
|
147
148
|
`;
|
|
149
|
+
|
|
150
|
+
export const ResetLabel = styled.span`
|
|
151
|
+
color: var( --wp-admin-theme-color-darker-10 );
|
|
152
|
+
font-size: 11px;
|
|
153
|
+
font-weight: 500;
|
|
154
|
+
line-height: 1.4;
|
|
155
|
+
${ rtl( { marginLeft: space( 3 ) } ) }
|
|
156
|
+
text-transform: uppercase;
|
|
157
|
+
`;
|
|
158
|
+
|
|
159
|
+
export const DefaultControlsItem = css`
|
|
160
|
+
color: ${ COLORS.gray[ 900 ] };
|
|
161
|
+
|
|
162
|
+
&&[aria-disabled='true'] {
|
|
163
|
+
color: ${ COLORS.gray[ 700 ] };
|
|
164
|
+
opacity: 1;
|
|
165
|
+
|
|
166
|
+
&:hover {
|
|
167
|
+
color: ${ COLORS.gray[ 700 ] };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
${ ResetLabel } {
|
|
171
|
+
opacity: 0.3;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
`;
|
|
@@ -7,7 +7,7 @@ import type { ForwardedRef } from 'react';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { speak } from '@wordpress/a11y';
|
|
10
|
-
import { check,
|
|
10
|
+
import { check, moreVertical, plus } from '@wordpress/icons';
|
|
11
11
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -20,12 +20,14 @@ import { HStack } from '../../h-stack';
|
|
|
20
20
|
import { Heading } from '../../heading';
|
|
21
21
|
import { useToolsPanelHeader } from './hook';
|
|
22
22
|
import { contextConnect, WordPressComponentProps } from '../../ui/context';
|
|
23
|
+
import { ResetLabel } from '../styles';
|
|
23
24
|
import type {
|
|
24
25
|
ToolsPanelControlsGroupProps,
|
|
25
26
|
ToolsPanelHeaderProps,
|
|
26
27
|
} from '../types';
|
|
27
28
|
|
|
28
29
|
const DefaultControlsGroup = ( {
|
|
30
|
+
itemClassName,
|
|
29
31
|
items,
|
|
30
32
|
toggleItem,
|
|
31
33
|
}: ToolsPanelControlsGroupProps ) => {
|
|
@@ -33,15 +35,17 @@ const DefaultControlsGroup = ( {
|
|
|
33
35
|
return null;
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
const resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;
|
|
39
|
+
|
|
36
40
|
return (
|
|
37
|
-
<MenuGroup>
|
|
41
|
+
<MenuGroup label={ __( 'Defaults' ) }>
|
|
38
42
|
{ items.map( ( [ label, hasValue ] ) => {
|
|
39
43
|
if ( hasValue ) {
|
|
40
44
|
return (
|
|
41
45
|
<MenuItem
|
|
42
46
|
key={ label }
|
|
47
|
+
className={ itemClassName }
|
|
43
48
|
role="menuitem"
|
|
44
|
-
icon={ reset }
|
|
45
49
|
label={ sprintf(
|
|
46
50
|
// translators: %s: The name of the control being reset e.g. "Padding".
|
|
47
51
|
__( 'Reset %s' ),
|
|
@@ -58,6 +62,7 @@ const DefaultControlsGroup = ( {
|
|
|
58
62
|
'assertive'
|
|
59
63
|
);
|
|
60
64
|
} }
|
|
65
|
+
suffix={ resetSuffix }
|
|
61
66
|
>
|
|
62
67
|
{ label }
|
|
63
68
|
</MenuItem>
|
|
@@ -67,8 +72,8 @@ const DefaultControlsGroup = ( {
|
|
|
67
72
|
return (
|
|
68
73
|
<MenuItem
|
|
69
74
|
key={ label }
|
|
75
|
+
className={ itemClassName }
|
|
70
76
|
role="menuitemcheckbox"
|
|
71
|
-
icon={ check }
|
|
72
77
|
isSelected
|
|
73
78
|
aria-disabled
|
|
74
79
|
>
|
|
@@ -89,7 +94,7 @@ const OptionalControlsGroup = ( {
|
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
return (
|
|
92
|
-
<MenuGroup>
|
|
97
|
+
<MenuGroup label={ __( 'Tools' ) }>
|
|
93
98
|
{ items.map( ( [ label, isSelected ] ) => {
|
|
94
99
|
const itemLabel = isSelected
|
|
95
100
|
? sprintf(
|
|
@@ -147,6 +152,7 @@ const ToolsPanelHeader = (
|
|
|
147
152
|
) => {
|
|
148
153
|
const {
|
|
149
154
|
areAllOptionalControlsHidden,
|
|
155
|
+
defaultControlsItemClassName,
|
|
150
156
|
dropdownMenuClassName,
|
|
151
157
|
hasMenuItems,
|
|
152
158
|
headingClassName,
|
|
@@ -197,6 +203,7 @@ const ToolsPanelHeader = (
|
|
|
197
203
|
<DefaultControlsGroup
|
|
198
204
|
items={ defaultItems }
|
|
199
205
|
toggleItem={ toggleItem }
|
|
206
|
+
itemClassName={ defaultControlsItemClassName }
|
|
200
207
|
/>
|
|
201
208
|
<OptionalControlsGroup
|
|
202
209
|
items={ optionalItems }
|
|
@@ -33,12 +33,17 @@ export function useToolsPanelHeader(
|
|
|
33
33
|
return cx( styles.ToolsPanelHeading );
|
|
34
34
|
}, [ cx ] );
|
|
35
35
|
|
|
36
|
+
const defaultControlsItemClassName = useMemo( () => {
|
|
37
|
+
return cx( styles.DefaultControlsItem );
|
|
38
|
+
}, [ cx ] );
|
|
39
|
+
|
|
36
40
|
const { menuItems, hasMenuItems, areAllOptionalControlsHidden } =
|
|
37
41
|
useToolsPanelContext();
|
|
38
42
|
|
|
39
43
|
return {
|
|
40
44
|
...otherProps,
|
|
41
45
|
areAllOptionalControlsHidden,
|
|
46
|
+
defaultControlsItemClassName,
|
|
42
47
|
dropdownMenuClassName,
|
|
43
48
|
hasMenuItems,
|
|
44
49
|
headingClassName,
|