@wordpress/components 21.0.2 → 21.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -7
- 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/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/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -3
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +3 -3
- package/build/mobile/link-picker/link-picker-results.native.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/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/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/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.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/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-types/button/index.d.ts.map +1 -1
- package/build-types/drop-zone/index.d.ts.map +1 -1
- 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/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 -2
- 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/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/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/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -2
- package/src/mobile/link-picker/link-picker-results.native.js +1 -1
- package/src/popover/stories/e2e/index.tsx +25 -0
- 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 -2
- package/src/range-control/utils.ts +3 -75
- 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/unit-control/test/__snapshots__/index.tsx.snap +0 -31
|
@@ -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 ];
|