@wordpress/components 21.0.2 → 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 +31 -4
- package/build/autocomplete/get-default-use-items.js +3 -3
- package/build/autocomplete/get-default-use-items.js.map +1 -1
- package/build/box-control/unit-control.js +0 -1
- package/build/box-control/unit-control.js.map +1 -1
- package/build/button/index.js +5 -1
- package/build/button/index.js.map +1 -1
- package/build/draggable/index.js +3 -6
- package/build/draggable/index.js.map +1 -1
- package/build/drop-zone/index.js +7 -1
- package/build/drop-zone/index.js.map +1 -1
- package/build/higher-order/with-filters/index.js +1 -1
- package/build/higher-order/with-filters/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 +15 -6
- 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 +6 -4
- 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/range-control/input-range.js +1 -15
- package/build/range-control/input-range.js.map +1 -1
- package/build/range-control/tooltip.js +1 -1
- package/build/range-control/tooltip.js.map +1 -1
- package/build/range-control/utils.js +2 -58
- package/build/range-control/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/tree-grid/index.js +13 -8
- package/build/tree-grid/index.js.map +1 -1
- package/build/unit-control/index.js +2 -2
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/index.native.js +10 -2
- package/build/unit-control/index.native.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +21 -32
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/utils/hooks/use-controlled-state.js +2 -3
- package/build/utils/hooks/use-controlled-state.js.map +1 -1
- package/build-module/autocomplete/get-default-use-items.js +1 -1
- package/build-module/autocomplete/get-default-use-items.js.map +1 -1
- package/build-module/box-control/unit-control.js +0 -1
- package/build-module/box-control/unit-control.js.map +1 -1
- package/build-module/button/index.js +5 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/draggable/index.js +2 -5
- package/build-module/draggable/index.js.map +1 -1
- package/build-module/drop-zone/index.js +7 -1
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/higher-order/with-filters/index.js +2 -2
- package/build-module/higher-order/with-filters/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 +13 -4
- 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 +4 -2
- 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/range-control/input-range.js +1 -14
- package/build-module/range-control/input-range.js.map +1 -1
- package/build-module/range-control/tooltip.js +1 -1
- package/build-module/range-control/tooltip.js.map +1 -1
- package/build-module/range-control/utils.js +2 -57
- package/build-module/range-control/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-module/tree-grid/index.js +13 -8
- package/build-module/tree-grid/index.js.map +1 -1
- package/build-module/unit-control/index.js +2 -2
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/index.native.js +10 -2
- package/build-module/unit-control/index.native.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +20 -31
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/utils/hooks/use-controlled-state.js +3 -4
- package/build-module/utils/hooks/use-controlled-state.js.map +1 -1
- package/build-style/style-rtl.css +13 -2
- package/build-style/style.css +13 -2
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/draggable/index.d.ts.map +1 -1
- package/build-types/drop-zone/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/stories/e2e/index.d.ts +8 -0
- package/build-types/popover/stories/e2e/index.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/input-range.d.ts.map +1 -1
- package/build-types/range-control/stories/index.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +0 -34
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/range-control/utils.d.ts +1 -12
- package/build-types/range-control/utils.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/build-types/unit-control/styles/unit-control-styles.d.ts +1 -4
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/autocomplete/get-default-use-items.js +1 -1
- package/src/box-control/unit-control.js +0 -1
- package/src/button/index.js +7 -1
- package/src/button/test/index.js +36 -0
- package/src/color-palette/test/__snapshots__/index.js.snap +169 -1106
- package/src/color-palette/test/index.js +107 -61
- package/src/draggable/index.js +2 -5
- package/src/drop-zone/index.tsx +4 -1
- package/src/font-size-picker/stories/e2e/index.js +47 -0
- package/src/higher-order/with-filters/index.js +2 -2
- 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 +12 -2
- 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 +4 -1
- 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/stories/e2e/index.tsx +25 -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/README.md +6 -7
- package/src/range-control/input-range.tsx +1 -21
- package/src/range-control/stories/index.tsx +2 -1
- package/src/range-control/tooltip.tsx +1 -1
- package/src/range-control/types.ts +0 -35
- package/src/range-control/utils.ts +3 -75
- 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/src/tree-grid/index.js +23 -14
- package/src/tree-grid/test/__snapshots__/cell.js.snap +21 -17
- package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
- package/src/unit-control/index.native.js +8 -0
- package/src/unit-control/index.tsx +2 -2
- package/src/unit-control/styles/unit-control-styles.ts +0 -20
- package/src/unit-control/test/index.tsx +6 -3
- package/src/utils/hooks/use-controlled-state.js +9 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/src/popover/test/__snapshots__/index.js.snap +0 -34
- package/src/popover/test/index.js +0 -164
- package/src/unit-control/test/__snapshots__/index.tsx.snap +0 -31
|
@@ -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,
|
package/src/tools-panel/types.ts
CHANGED
package/src/tree-grid/index.js
CHANGED
|
@@ -36,12 +36,13 @@ function getRowFocusables( rowElement ) {
|
|
|
36
36
|
* Renders both a table and tbody element, used to create a tree hierarchy.
|
|
37
37
|
*
|
|
38
38
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/components/src/tree-grid/README.md
|
|
39
|
-
* @param {Object} props
|
|
40
|
-
* @param {WPElement} props.children
|
|
41
|
-
* @param {Function} props.onExpandRow
|
|
42
|
-
* @param {Function} props.onCollapseRow
|
|
43
|
-
* @param {Function} props.onFocusRow
|
|
44
|
-
* @param {
|
|
39
|
+
* @param {Object} props Component props.
|
|
40
|
+
* @param {WPElement} props.children Children to be rendered.
|
|
41
|
+
* @param {Function} props.onExpandRow Callback to fire when row is expanded.
|
|
42
|
+
* @param {Function} props.onCollapseRow Callback to fire when row is collapsed.
|
|
43
|
+
* @param {Function} props.onFocusRow Callback to fire when moving focus to a different row.
|
|
44
|
+
* @param {string} props.applicationAriaLabel Label to use for the application role.
|
|
45
|
+
* @param {Object} ref A ref to the underlying DOM table element.
|
|
45
46
|
*/
|
|
46
47
|
function TreeGrid(
|
|
47
48
|
{
|
|
@@ -49,6 +50,7 @@ function TreeGrid(
|
|
|
49
50
|
onExpandRow = () => {},
|
|
50
51
|
onCollapseRow = () => {},
|
|
51
52
|
onFocusRow = () => {},
|
|
53
|
+
applicationAriaLabel,
|
|
52
54
|
...props
|
|
53
55
|
},
|
|
54
56
|
ref
|
|
@@ -286,14 +288,21 @@ function TreeGrid(
|
|
|
286
288
|
/* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */
|
|
287
289
|
return (
|
|
288
290
|
<RovingTabIndexContainer>
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
role=
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
>
|
|
295
|
-
<
|
|
296
|
-
|
|
291
|
+
{
|
|
292
|
+
// Prevent browser mode from triggering in NVDA by wrapping List View
|
|
293
|
+
// in a role=application wrapper.
|
|
294
|
+
// see: https://github.com/WordPress/gutenberg/issues/43729
|
|
295
|
+
}
|
|
296
|
+
<div role="application" aria-label={ applicationAriaLabel }>
|
|
297
|
+
<table
|
|
298
|
+
{ ...props }
|
|
299
|
+
role="treegrid"
|
|
300
|
+
onKeyDown={ onKeyDown }
|
|
301
|
+
ref={ ref }
|
|
302
|
+
>
|
|
303
|
+
<tbody>{ children }</tbody>
|
|
304
|
+
</table>
|
|
305
|
+
</div>
|
|
297
306
|
</RovingTabIndexContainer>
|
|
298
307
|
);
|
|
299
308
|
/* eslint-enable jsx-a11y/no-noninteractive-element-to-interactive-role */
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`TreeGridCell uses a child render function to render children 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
role="treegrid"
|
|
4
|
+
<div
|
|
5
|
+
role="application"
|
|
7
6
|
>
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
<table
|
|
8
|
+
onKeyDown={[Function]}
|
|
9
|
+
role="treegrid"
|
|
10
|
+
>
|
|
11
|
+
<tbody>
|
|
12
|
+
<tr>
|
|
13
|
+
<td
|
|
14
|
+
role="gridcell"
|
|
16
15
|
>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</
|
|
16
|
+
<button
|
|
17
|
+
className="my-button"
|
|
18
|
+
onFocus={[Function]}
|
|
19
|
+
>
|
|
20
|
+
Click Me!
|
|
21
|
+
</button>
|
|
22
|
+
</td>
|
|
23
|
+
</tr>
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
</div>
|
|
23
27
|
`;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`TreeGrid simple rendering renders a table, tbody and any child elements 1`] = `"<table role=\\"treegrid\\"><tbody><tr role=\\"row\\" aria-level=\\"1\\" aria-posinset=\\"1\\" aria-setsize=\\"1\\"><td role=\\"gridcell\\">Test</td></tr></tbody></table>"`;
|
|
3
|
+
exports[`TreeGrid simple rendering renders a table, tbody and any child elements 1`] = `"<div role=\\"application\\"><table role=\\"treegrid\\"><tbody><tr role=\\"row\\" aria-level=\\"1\\" aria-posinset=\\"1\\" aria-setsize=\\"1\\"><td role=\\"gridcell\\">Test</td></tr></tbody></table></div>"`;
|
|
@@ -47,6 +47,10 @@ function UnitControl( {
|
|
|
47
47
|
if ( pickerRef?.current ) {
|
|
48
48
|
pickerRef.current.presentPicker();
|
|
49
49
|
}
|
|
50
|
+
// Disable reason: this should be fixed by the native team.
|
|
51
|
+
// It would be great if this could be done in the context of
|
|
52
|
+
// https://github.com/WordPress/gutenberg/pull/39218
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
54
|
}, [ pickerRef?.current ] );
|
|
51
55
|
|
|
52
56
|
const currentInputValue = currentInput === null ? value : currentInput;
|
|
@@ -102,6 +106,10 @@ function UnitControl( {
|
|
|
102
106
|
anchorNodeRef?.current
|
|
103
107
|
? findNodeHandle( anchorNodeRef?.current )
|
|
104
108
|
: undefined,
|
|
109
|
+
// Disable reason: this should be fixed by the native team.
|
|
110
|
+
// It would be great if this could be done in the context of
|
|
111
|
+
// https://github.com/WordPress/gutenberg/pull/39218
|
|
112
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
113
|
[ anchorNodeRef?.current ]
|
|
106
114
|
);
|
|
107
115
|
|
|
@@ -100,7 +100,7 @@ function UnforwardedUnitControl(
|
|
|
100
100
|
if ( parsedUnit !== undefined ) {
|
|
101
101
|
setUnit( parsedUnit );
|
|
102
102
|
}
|
|
103
|
-
}, [ parsedUnit ] );
|
|
103
|
+
}, [ parsedUnit, setUnit ] );
|
|
104
104
|
|
|
105
105
|
// Stores parsed value for hand-off in state reducer.
|
|
106
106
|
const refParsedQuantity = useRef< number | undefined >( undefined );
|
|
@@ -265,7 +265,7 @@ function UnforwardedUnitControl(
|
|
|
265
265
|
autoComplete={ autoComplete }
|
|
266
266
|
className={ classes }
|
|
267
267
|
disabled={ disabled }
|
|
268
|
-
|
|
268
|
+
hideHTMLArrows
|
|
269
269
|
isPressEnterToChange={ isPressEnterToChange }
|
|
270
270
|
label={ label }
|
|
271
271
|
onBlur={ handleOnBlur }
|
|
@@ -18,10 +18,6 @@ type SelectProps = {
|
|
|
18
18
|
selectSize: SelectSize;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
type InputProps = {
|
|
22
|
-
disableUnits?: boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
21
|
export const Root = styled.div`
|
|
26
22
|
box-sizing: border-box;
|
|
27
23
|
position: relative;
|
|
@@ -32,30 +28,14 @@ export const Root = styled.div`
|
|
|
32
28
|
}
|
|
33
29
|
`;
|
|
34
30
|
|
|
35
|
-
const arrowStyles = ( { disableUnits }: InputProps ) => {
|
|
36
|
-
if ( disableUnits ) return '';
|
|
37
|
-
|
|
38
|
-
return css`
|
|
39
|
-
&::-webkit-outer-spin-button,
|
|
40
|
-
&::-webkit-inner-spin-button {
|
|
41
|
-
-webkit-appearance: none;
|
|
42
|
-
margin: 0;
|
|
43
|
-
}
|
|
44
|
-
`;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
31
|
// TODO: Resolve need to use &&& to increase specificity
|
|
48
32
|
// https://github.com/WordPress/gutenberg/issues/18483
|
|
49
33
|
|
|
50
34
|
export const ValueInput = styled( NumberControl )`
|
|
51
35
|
&&& {
|
|
52
36
|
input {
|
|
53
|
-
appearance: none;
|
|
54
|
-
-moz-appearance: textfield;
|
|
55
37
|
display: block;
|
|
56
38
|
width: 100%;
|
|
57
|
-
|
|
58
|
-
${ arrowStyles };
|
|
59
39
|
}
|
|
60
40
|
}
|
|
61
41
|
`;
|
|
@@ -111,9 +111,12 @@ describe( 'UnitControl', () => {
|
|
|
111
111
|
<UnitControl className="hello" />
|
|
112
112
|
);
|
|
113
113
|
|
|
114
|
-
expect(
|
|
115
|
-
|
|
116
|
-
);
|
|
114
|
+
expect(
|
|
115
|
+
withoutClassName.querySelector( '.components-unit-control' )
|
|
116
|
+
).not.toHaveClass( 'hello' );
|
|
117
|
+
expect(
|
|
118
|
+
withClassName.querySelector( '.components-unit-control' )
|
|
119
|
+
).toHaveClass( 'hello' );
|
|
117
120
|
} );
|
|
118
121
|
|
|
119
122
|
it( 'should not render select, if units are disabled', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useEffect, useState } from '@wordpress/element';
|
|
4
|
+
import { useEffect, useState, useCallback } from '@wordpress/element';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -70,11 +70,14 @@ function useControlledState( currentState, options = defaultOptions ) {
|
|
|
70
70
|
|
|
71
71
|
/* eslint-disable jsdoc/no-undefined-types */
|
|
72
72
|
/** @type {(nextState: T) => void} */
|
|
73
|
-
const setState = (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
const setState = useCallback(
|
|
74
|
+
( nextState ) => {
|
|
75
|
+
if ( ! hasCurrentState ) {
|
|
76
|
+
setInternalState( nextState );
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
[ hasCurrentState ]
|
|
80
|
+
);
|
|
78
81
|
/* eslint-enable jsdoc/no-undefined-types */
|
|
79
82
|
|
|
80
83
|
return [ state, setState ];
|