@wordpress/components 19.8.3 → 19.10.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 +42 -0
- package/CONTRIBUTING.md +80 -7
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build/angle-picker-control/angle-circle.js +5 -7
- package/build/angle-picker-control/angle-circle.js.map +1 -1
- package/build/box-control/index.js +0 -21
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/utils.js +1 -8
- package/build/box-control/utils.js.map +1 -1
- package/build/button/index.js +3 -5
- package/build/button/index.js.map +1 -1
- package/build/circular-option-picker/index.js +1 -2
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/disabled/index.js +4 -76
- package/build/disabled/index.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/input-control/index.js +27 -4
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +42 -30
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +1 -0
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/navigation/styles/navigation-styles.js +12 -12
- package/build/navigation/styles/navigation-styles.js.map +1 -1
- package/build/notice/index.native.js +44 -40
- package/build/notice/index.native.js.map +1 -1
- package/build/notice/list.native.js +27 -45
- package/build/notice/list.native.js.map +1 -1
- package/build/popover/index.js +6 -52
- package/build/popover/index.js.map +1 -1
- package/build/sandbox/index.js +2 -2
- package/build/sandbox/index.js.map +1 -1
- package/build/select-control/index.js +31 -4
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +8 -8
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/surface/styles.js +8 -8
- package/build/surface/styles.js.map +1 -1
- package/build/text/hook.js +5 -5
- package/build/text/hook.js.map +1 -1
- package/build/text/styles/text-mixins.native.js +1 -1
- package/build/text/styles/text-mixins.native.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/text-control/index.js +35 -28
- package/build/text-control/index.js.map +1 -1
- package/build/text-control/types.js +6 -0
- package/build/text-control/types.js.map +1 -0
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js +6 -4
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +52 -36
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/ui/spinner/component.js +1 -1
- package/build/ui/spinner/component.js.map +1 -1
- package/build/unit-control/index.js +3 -3
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +11 -20
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/unit-control/utils.js.map +1 -1
- package/build/utils/colors-values.js +9 -24
- package/build/utils/colors-values.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build-module/angle-picker-control/angle-circle.js +5 -7
- package/build-module/angle-picker-control/angle-circle.js.map +1 -1
- package/build-module/box-control/index.js +1 -20
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/utils.js +0 -6
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button/index.js +3 -4
- package/build-module/button/index.js.map +1 -1
- package/build-module/circular-option-picker/index.js +1 -2
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/disabled/index.js +5 -76
- package/build-module/disabled/index.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/input-control/index.js +24 -3
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +42 -30
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +1 -0
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/navigation/styles/navigation-styles.js +13 -13
- package/build-module/navigation/styles/navigation-styles.js.map +1 -1
- package/build-module/notice/index.native.js +45 -41
- package/build-module/notice/index.native.js.map +1 -1
- package/build-module/notice/list.native.js +28 -46
- package/build-module/notice/list.native.js.map +1 -1
- package/build-module/popover/index.js +6 -52
- package/build-module/popover/index.js.map +1 -1
- package/build-module/sandbox/index.js +2 -2
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/select-control/index.js +29 -3
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +8 -8
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/surface/styles.js +8 -8
- package/build-module/surface/styles.js.map +1 -1
- package/build-module/text/hook.js +5 -5
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/styles/text-mixins.native.js +2 -2
- package/build-module/text/styles/text-mixins.native.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/text-control/index.js +35 -27
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/text-control/types.js +2 -0
- package/build-module/text-control/types.js.map +1 -0
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -5
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +51 -36
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/ui/spinner/component.js +1 -1
- package/build-module/ui/spinner/component.js.map +1 -1
- package/build-module/unit-control/index.js +3 -3
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +11 -20
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-module/utils/colors-values.js +19 -23
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-style/style-rtl.css +24 -0
- package/build-style/style.css +24 -0
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -3
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +23 -3
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/stories/index.d.ts +5 -5
- package/build-types/input-control/styles/input-control-styles.d.ts +1 -0
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +79 -3
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/popover/index.d.ts +0 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +30 -26
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/stories/index.d.ts +23 -0
- package/build-types/select-control/stories/index.d.ts.map +1 -0
- package/build-types/select-control/styles/select-control-styles.d.ts +3 -4
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/test/select-control.d.ts +2 -0
- package/build-types/select-control/test/select-control.d.ts.map +1 -0
- package/build-types/select-control/types.d.ts +52 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +32 -0
- package/build-types/text-control/index.d.ts.map +1 -0
- package/build-types/text-control/stories/index.d.ts +13 -0
- package/build-types/text-control/stories/index.d.ts.map +1 -0
- package/build-types/text-control/types.d.ts +25 -0
- package/build-types/text-control/types.d.ts.map +1 -0
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +0 -1
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +2 -2
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/test/index.d.ts +2 -0
- package/build-types/unit-control/test/index.d.ts.map +1 -0
- package/build-types/unit-control/test/utils.d.ts +2 -0
- package/build-types/unit-control/test/utils.d.ts.map +1 -0
- package/build-types/unit-control/types.d.ts +1 -1
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/unit-control/utils.d.ts +3 -3
- package/build-types/unit-control/utils.d.ts.map +1 -1
- package/build-types/utils/colors-values.d.ts +6 -146
- package/build-types/utils/colors-values.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
- package/src/angle-picker-control/angle-circle.js +3 -3
- package/src/box-control/README.md +0 -74
- package/src/box-control/index.js +0 -15
- package/src/box-control/stories/index.js +0 -29
- package/src/box-control/utils.js +0 -7
- package/src/button/index.js +2 -4
- package/src/button/test/index.js +16 -1
- package/src/circular-option-picker/index.js +1 -2
- package/src/color-palette/README.md +0 -1
- package/src/color-palette/test/__snapshots__/index.js.snap +2 -3
- package/src/confirm-dialog/stories/index.js +87 -99
- package/src/date-time/stories/index.js +19 -0
- package/src/date-time/test/date.js +107 -78
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
- package/src/disabled/index.js +5 -90
- package/src/form-file-upload/test/index.js +15 -12
- package/src/heading/hook.ts +1 -1
- package/src/heading/test/__snapshots__/index.js.snap +3 -3
- package/src/input-control/README.md +3 -3
- package/src/input-control/index.tsx +23 -3
- package/src/input-control/stories/index.tsx +63 -0
- package/src/input-control/styles/input-control-styles.tsx +20 -7
- package/src/input-control/types.ts +79 -2
- package/src/menu-item/style.scss +10 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +8 -1
- package/src/mobile/bottom-sheet-select-control/index.native.js +1 -0
- package/src/mobile/html-text-input/style.android.scss +1 -0
- package/src/mobile/html-text-input/style.ios.scss +1 -0
- package/src/mobile/link-settings/test/link-settings-navigation.native.js +9 -1
- package/src/navigation/styles/navigation-styles.js +5 -5
- package/src/notice/index.native.js +44 -54
- package/src/notice/list.native.js +27 -51
- package/src/notice/style.native.scss +1 -0
- package/src/popover/index.js +5 -51
- package/src/query-controls/README.md +2 -2
- package/src/sandbox/index.js +2 -2
- package/src/select-control/README.md +2 -2
- package/src/select-control/index.tsx +30 -29
- package/src/select-control/stories/index.tsx +90 -0
- package/src/select-control/styles/select-control-styles.ts +10 -9
- package/src/select-control/test/{select-control.js → select-control.tsx} +2 -2
- package/src/select-control/types.ts +66 -1
- package/src/surface/styles.js +1 -1
- package/src/text/hook.js +1 -1
- package/src/text/styles/text-mixins.native.js +2 -2
- package/src/text/styles.js +1 -1
- package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
- package/src/text/test/{index.js → index.tsx} +12 -6
- package/src/text-control/index.tsx +84 -0
- package/src/text-control/stories/index.tsx +66 -0
- package/src/text-control/types.ts +29 -0
- package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -5
- package/src/toolbar-group/style.scss +20 -0
- package/src/tools-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/tools-panel/test/index.js +71 -18
- package/src/tools-panel/tools-panel-header/component.tsx +75 -33
- package/src/tools-panel/types.ts +0 -1
- package/src/tooltip/test/index.js +6 -0
- package/src/ui/spinner/component.js +1 -1
- package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
- package/src/unit-control/index.tsx +2 -5
- package/src/unit-control/styles/unit-control-styles.ts +3 -13
- package/src/unit-control/test/__snapshots__/index.tsx.snap +33 -0
- package/src/unit-control/test/{index.js → index.tsx} +214 -165
- package/src/unit-control/test/{utils.js → utils.ts} +38 -19
- package/src/unit-control/types.ts +4 -1
- package/src/unit-control/utils.ts +5 -3
- package/src/utils/colors-values.js +18 -22
- package/tsconfig.json +9 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/box-control/visualizer.js +0 -165
- package/build/box-control/visualizer.js.map +0 -1
- package/build-module/box-control/visualizer.js +0 -154
- package/build-module/box-control/visualizer.js.map +0 -1
- package/src/box-control/visualizer.js +0 -116
- package/src/input-control/stories/index.js +0 -71
- package/src/select-control/stories/index.js +0 -104
- package/src/text-control/index.js +0 -72
- package/src/text-control/stories/index.js +0 -46
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
import userEvent from '@testing-library/user-event';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -14,15 +14,9 @@ import FormFileUpload from '../';
|
|
|
14
14
|
*/
|
|
15
15
|
const { File } = window;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// Avoids timeout errors (https://github.com/testing-library/user-event/issues/565#issuecomment-1064579531).
|
|
21
|
-
delay: null,
|
|
22
|
-
} ),
|
|
23
|
-
...RTLrender( jsx ),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
17
|
+
const user = userEvent.setup( {
|
|
18
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
19
|
+
} );
|
|
26
20
|
|
|
27
21
|
// @testing-library/user-event considers changing <input type="file"> to a string as a change, but it do not occur on real browsers, so the comparisons will be against this result
|
|
28
22
|
const fakePath = expect.objectContaining( {
|
|
@@ -32,6 +26,15 @@ const fakePath = expect.objectContaining( {
|
|
|
32
26
|
} );
|
|
33
27
|
|
|
34
28
|
describe( 'FormFileUpload', () => {
|
|
29
|
+
beforeEach( () => {
|
|
30
|
+
jest.useFakeTimers();
|
|
31
|
+
} );
|
|
32
|
+
|
|
33
|
+
afterEach( () => {
|
|
34
|
+
jest.runOnlyPendingTimers();
|
|
35
|
+
jest.useRealTimers();
|
|
36
|
+
} );
|
|
37
|
+
|
|
35
38
|
it( 'should show an Icon Button and a hidden input', () => {
|
|
36
39
|
render( <FormFileUpload>My Upload Button</FormFileUpload> );
|
|
37
40
|
|
|
@@ -44,7 +47,7 @@ describe( 'FormFileUpload', () => {
|
|
|
44
47
|
it( 'should not fire a change event after selecting the same file', async () => {
|
|
45
48
|
const onChange = jest.fn();
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
render(
|
|
48
51
|
<FormFileUpload onChange={ onChange }>
|
|
49
52
|
My Upload Button
|
|
50
53
|
</FormFileUpload>
|
|
@@ -67,7 +70,7 @@ describe( 'FormFileUpload', () => {
|
|
|
67
70
|
it( 'should fire a change event after selecting the same file if the value was reset in between', async () => {
|
|
68
71
|
const onChange = jest.fn();
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
render(
|
|
71
74
|
<FormFileUpload
|
|
72
75
|
onClick={ jest.fn( ( e ) => ( e.target.value = '' ) ) }
|
|
73
76
|
onChange={ onChange }
|
package/src/heading/hook.ts
CHANGED
|
@@ -70,7 +70,7 @@ export function useHeading(
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const textProps = useText( {
|
|
73
|
-
color: COLORS.
|
|
73
|
+
color: COLORS.gray[ 900 ],
|
|
74
74
|
size: getHeadingFontSize( level ),
|
|
75
75
|
isBlock: true,
|
|
76
76
|
weight: CONFIG.fontWeightHeading as import('react').CSSProperties[ 'fontWeight' ],
|
|
@@ -5,7 +5,7 @@ exports[`props should render correctly 1`] = `
|
|
|
5
5
|
color: #1e1e1e;
|
|
6
6
|
line-height: 1.2;
|
|
7
7
|
margin: 0;
|
|
8
|
-
color: #
|
|
8
|
+
color: #1e1e1e;
|
|
9
9
|
font-size: calc(1.95 * 13px);
|
|
10
10
|
font-weight: 600;
|
|
11
11
|
display: block;
|
|
@@ -27,7 +27,7 @@ Snapshot Diff:
|
|
|
27
27
|
|
|
28
28
|
Array [
|
|
29
29
|
Object {
|
|
30
|
-
"color": "#
|
|
30
|
+
"color": "#1e1e1e",
|
|
31
31
|
"display": "block",
|
|
32
32
|
- "font-size": "calc(1.25 * 13px)",
|
|
33
33
|
+ "font-size": "calc(1.95 * 13px)",
|
|
@@ -45,7 +45,7 @@ Snapshot Diff:
|
|
|
45
45
|
|
|
46
46
|
Array [
|
|
47
47
|
Object {
|
|
48
|
-
"color": "#
|
|
48
|
+
"color": "#1e1e1e",
|
|
49
49
|
"display": "block",
|
|
50
50
|
- "font-size": "calc(1.25 * 13px)",
|
|
51
51
|
+ "font-size": "calc(1.95 * 13px)",
|
|
@@ -18,7 +18,7 @@ const Example = () => {
|
|
|
18
18
|
return (
|
|
19
19
|
<InputControl
|
|
20
20
|
value={ value }
|
|
21
|
-
onChange={ ( nextValue ) => setValue( nextValue ) }
|
|
21
|
+
onChange={ ( nextValue ) => setValue( nextValue ?? '' ) }
|
|
22
22
|
/>
|
|
23
23
|
);
|
|
24
24
|
};
|
|
@@ -105,5 +105,5 @@ Type of the input element to render. Defaults to "text".
|
|
|
105
105
|
|
|
106
106
|
The current value of the input.
|
|
107
107
|
|
|
108
|
-
- Type: `String
|
|
109
|
-
- Required:
|
|
108
|
+
- Type: `String`
|
|
109
|
+
- Required: No
|
|
@@ -25,7 +25,7 @@ function useUniqueId( idProp?: string ) {
|
|
|
25
25
|
return idProp || id;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function
|
|
28
|
+
export function UnforwardedInputControl(
|
|
29
29
|
{
|
|
30
30
|
__unstableStateReducer: stateReducer = ( state ) => state,
|
|
31
31
|
__unstableInputWidth,
|
|
@@ -88,6 +88,26 @@ export function InputControl(
|
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
/**
|
|
92
|
+
* InputControl components let users enter and edit text. This is an experimental component
|
|
93
|
+
* intended to (in time) merge with or replace `TextControl`.
|
|
94
|
+
*
|
|
95
|
+
* ```jsx
|
|
96
|
+
* import { __experimentalInputControl as InputControl } from '@wordpress/components';
|
|
97
|
+
* import { useState } from '@wordpress/compose';
|
|
98
|
+
*
|
|
99
|
+
* const Example = () => {
|
|
100
|
+
* const [ value, setValue ] = useState( '' );
|
|
101
|
+
*
|
|
102
|
+
* return (
|
|
103
|
+
* <InputControl
|
|
104
|
+
* value={ value }
|
|
105
|
+
* onChange={ ( nextValue ) => setValue( nextValue ?? '' ) }
|
|
106
|
+
* />
|
|
107
|
+
* );
|
|
108
|
+
* };
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export const InputControl = forwardRef( UnforwardedInputControl );
|
|
92
112
|
|
|
93
|
-
export default
|
|
113
|
+
export default InputControl;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import InputControl from '..';
|
|
10
|
+
|
|
11
|
+
const meta: ComponentMeta< typeof InputControl > = {
|
|
12
|
+
title: 'Components (Experimental)/InputControl',
|
|
13
|
+
component: InputControl,
|
|
14
|
+
argTypes: {
|
|
15
|
+
__unstableInputWidth: { control: { type: 'text' } },
|
|
16
|
+
__unstableStateReducer: { control: { type: null } },
|
|
17
|
+
onChange: { control: { type: null } },
|
|
18
|
+
prefix: { control: { type: null } },
|
|
19
|
+
suffix: { control: { type: null } },
|
|
20
|
+
type: { control: { type: 'text' } },
|
|
21
|
+
value: { control: { disable: true } },
|
|
22
|
+
},
|
|
23
|
+
parameters: {
|
|
24
|
+
controls: { expanded: true },
|
|
25
|
+
docs: { source: { state: 'open' } },
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export default meta;
|
|
29
|
+
|
|
30
|
+
const Template: ComponentStory< typeof InputControl > = ( args ) => (
|
|
31
|
+
<InputControl { ...args } />
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export const Default = Template.bind( {} );
|
|
35
|
+
Default.args = {
|
|
36
|
+
label: 'Value',
|
|
37
|
+
placeholder: 'Placeholder',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const WithPrefix = Template.bind( {} );
|
|
41
|
+
WithPrefix.args = {
|
|
42
|
+
...Default.args,
|
|
43
|
+
prefix: <span style={ { paddingLeft: 8 } }>@</span>,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const WithSuffix = Template.bind( {} );
|
|
47
|
+
WithSuffix.args = {
|
|
48
|
+
...Default.args,
|
|
49
|
+
suffix: <button style={ { marginRight: 4 } }>Send</button>,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const WithSideLabel = Template.bind( {} );
|
|
53
|
+
WithSideLabel.args = {
|
|
54
|
+
...Default.args,
|
|
55
|
+
labelPosition: 'side',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const WithEdgeLabel = Template.bind( {} );
|
|
59
|
+
WithEdgeLabel.args = {
|
|
60
|
+
...Default.args,
|
|
61
|
+
__unstableInputWidth: '20em',
|
|
62
|
+
labelPosition: 'edge',
|
|
63
|
+
};
|
|
@@ -105,6 +105,7 @@ export const Container = styled.div< ContainerProps >`
|
|
|
105
105
|
`;
|
|
106
106
|
|
|
107
107
|
type InputProps = {
|
|
108
|
+
__next36pxDefaultSize?: boolean;
|
|
108
109
|
disabled?: boolean;
|
|
109
110
|
inputSize?: Size;
|
|
110
111
|
isDragging?: boolean;
|
|
@@ -140,14 +141,17 @@ const fontSizeStyles = ( { inputSize: size }: InputProps ) => {
|
|
|
140
141
|
`;
|
|
141
142
|
};
|
|
142
143
|
|
|
143
|
-
const sizeStyles = ( {
|
|
144
|
+
const sizeStyles = ( {
|
|
145
|
+
inputSize: size,
|
|
146
|
+
__next36pxDefaultSize,
|
|
147
|
+
}: InputProps ) => {
|
|
144
148
|
const sizes = {
|
|
145
149
|
default: {
|
|
146
|
-
height:
|
|
150
|
+
height: 36,
|
|
147
151
|
lineHeight: 1,
|
|
148
|
-
minHeight:
|
|
149
|
-
paddingLeft:
|
|
150
|
-
paddingRight:
|
|
152
|
+
minHeight: 36,
|
|
153
|
+
paddingLeft: 16,
|
|
154
|
+
paddingRight: 16,
|
|
151
155
|
},
|
|
152
156
|
small: {
|
|
153
157
|
height: 24,
|
|
@@ -165,6 +169,16 @@ const sizeStyles = ( { inputSize: size }: InputProps ) => {
|
|
|
165
169
|
},
|
|
166
170
|
};
|
|
167
171
|
|
|
172
|
+
if ( ! __next36pxDefaultSize ) {
|
|
173
|
+
sizes.default = {
|
|
174
|
+
height: 30,
|
|
175
|
+
lineHeight: 1,
|
|
176
|
+
minHeight: 30,
|
|
177
|
+
paddingLeft: 8,
|
|
178
|
+
paddingRight: 8,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
168
182
|
const style = sizes[ size as Size ] || sizes.default;
|
|
169
183
|
|
|
170
184
|
return css( style );
|
|
@@ -210,7 +224,7 @@ export const Input = styled.input< InputProps >`
|
|
|
210
224
|
box-sizing: border-box;
|
|
211
225
|
border: none;
|
|
212
226
|
box-shadow: none !important;
|
|
213
|
-
color: ${ COLORS.
|
|
227
|
+
color: ${ COLORS.gray[ 900 ] };
|
|
214
228
|
display: block;
|
|
215
229
|
font-family: inherit;
|
|
216
230
|
margin: 0;
|
|
@@ -245,7 +259,6 @@ const labelMargin = ( {
|
|
|
245
259
|
const BaseLabel = styled( Text )< { labelPosition?: LabelPosition } >`
|
|
246
260
|
&&& {
|
|
247
261
|
box-sizing: border-box;
|
|
248
|
-
color: currentColor;
|
|
249
262
|
display: block;
|
|
250
263
|
padding-top: 0;
|
|
251
264
|
padding-bottom: 0;
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
ChangeEvent,
|
|
8
8
|
SyntheticEvent,
|
|
9
9
|
PointerEvent,
|
|
10
|
+
HTMLInputTypeAttribute,
|
|
10
11
|
} from 'react';
|
|
11
12
|
import type { useDrag } from '@use-gesture/react';
|
|
12
13
|
|
|
@@ -14,8 +15,8 @@ import type { useDrag } from '@use-gesture/react';
|
|
|
14
15
|
* Internal dependencies
|
|
15
16
|
*/
|
|
16
17
|
import type { StateReducer } from './reducer/state';
|
|
17
|
-
import type { FlexProps } from '../flex/types';
|
|
18
18
|
import type { WordPressComponentProps } from '../ui/context';
|
|
19
|
+
import type { FlexProps } from '../flex/types';
|
|
19
20
|
|
|
20
21
|
export type LabelPosition = 'top' | 'bottom' | 'side' | 'edge';
|
|
21
22
|
|
|
@@ -26,10 +27,38 @@ export type DragProps = Parameters< Parameters< typeof useDrag >[ 0 ] >[ 0 ];
|
|
|
26
27
|
export type Size = 'default' | 'small' | '__unstable-large';
|
|
27
28
|
|
|
28
29
|
interface BaseProps {
|
|
30
|
+
/**
|
|
31
|
+
* Start opting into the larger default height that will become the default size in a future version.
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
__next36pxDefaultSize?: boolean;
|
|
29
36
|
__unstableInputWidth?: CSSProperties[ 'width' ];
|
|
37
|
+
/**
|
|
38
|
+
* If true, the label will only be visible to screen readers.
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
30
42
|
hideLabelFromVision?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the component should be in a focused state.
|
|
45
|
+
* Used to coordinate focus states when the actual focused element and the component handling
|
|
46
|
+
* visual focus are separate.
|
|
47
|
+
*
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
31
50
|
isFocused: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The position of the label.
|
|
53
|
+
*
|
|
54
|
+
* @default 'top'
|
|
55
|
+
*/
|
|
32
56
|
labelPosition?: LabelPosition;
|
|
57
|
+
/**
|
|
58
|
+
* Adjusts the size of the input.
|
|
59
|
+
*
|
|
60
|
+
* @default 'default'
|
|
61
|
+
*/
|
|
33
62
|
size?: Size;
|
|
34
63
|
}
|
|
35
64
|
|
|
@@ -39,10 +68,35 @@ export type InputChangeCallback<
|
|
|
39
68
|
> = ( nextValue: string | undefined, extra: { event: E } & P ) => void;
|
|
40
69
|
|
|
41
70
|
export interface InputFieldProps extends BaseProps {
|
|
71
|
+
/**
|
|
72
|
+
* Determines the drag axis.
|
|
73
|
+
*
|
|
74
|
+
* @default 'n'
|
|
75
|
+
*/
|
|
42
76
|
dragDirection?: DragDirection;
|
|
77
|
+
/**
|
|
78
|
+
* If `isDragEnabled` is true, this controls the amount of `px` to have been dragged before
|
|
79
|
+
* the drag gesture is actually triggered.
|
|
80
|
+
*
|
|
81
|
+
* @default 10
|
|
82
|
+
*/
|
|
43
83
|
dragThreshold?: number;
|
|
84
|
+
/**
|
|
85
|
+
* If true, enables mouse drag gestures.
|
|
86
|
+
*
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
44
89
|
isDragEnabled?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* If true, the `ENTER` key press is required in order to trigger an `onChange`.
|
|
92
|
+
* If enabled, a change is also triggered when tabbing away (`onBlur`).
|
|
93
|
+
*
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
45
96
|
isPressEnterToChange?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* A function that receives the value of the input.
|
|
99
|
+
*/
|
|
46
100
|
onChange?: InputChangeCallback;
|
|
47
101
|
onValidate?: (
|
|
48
102
|
nextValue: string,
|
|
@@ -50,24 +104,47 @@ export interface InputFieldProps extends BaseProps {
|
|
|
50
104
|
) => void;
|
|
51
105
|
setIsFocused: ( isFocused: boolean ) => void;
|
|
52
106
|
stateReducer?: StateReducer;
|
|
107
|
+
/**
|
|
108
|
+
* The current value of the input.
|
|
109
|
+
*/
|
|
53
110
|
value?: string;
|
|
54
111
|
onDragEnd?: ( dragProps: DragProps ) => void;
|
|
55
112
|
onDragStart?: ( dragProps: DragProps ) => void;
|
|
56
113
|
onDrag?: ( dragProps: DragProps ) => void;
|
|
114
|
+
/**
|
|
115
|
+
* Type of the input element to render.
|
|
116
|
+
*
|
|
117
|
+
* @default 'text'
|
|
118
|
+
*/
|
|
119
|
+
type?: HTMLInputTypeAttribute;
|
|
57
120
|
}
|
|
58
121
|
|
|
59
122
|
export interface InputBaseProps extends BaseProps, FlexProps {
|
|
60
123
|
children: ReactNode;
|
|
124
|
+
/**
|
|
125
|
+
* Renders an element on the left side of the input.
|
|
126
|
+
*/
|
|
61
127
|
prefix?: ReactNode;
|
|
128
|
+
/**
|
|
129
|
+
* Renders an element on the right side of the input.
|
|
130
|
+
*/
|
|
62
131
|
suffix?: ReactNode;
|
|
132
|
+
/**
|
|
133
|
+
* If true, the `input` will be disabled.
|
|
134
|
+
*
|
|
135
|
+
* @default false
|
|
136
|
+
*/
|
|
63
137
|
disabled?: boolean;
|
|
64
138
|
className?: string;
|
|
65
139
|
id?: string;
|
|
140
|
+
/**
|
|
141
|
+
* If this property is added, a label will be generated using label property as the content.
|
|
142
|
+
*/
|
|
66
143
|
label?: ReactNode;
|
|
67
144
|
}
|
|
68
145
|
|
|
69
146
|
export interface InputControlProps
|
|
70
|
-
extends Omit< InputBaseProps, 'children' | 'isFocused' >,
|
|
147
|
+
extends Omit< InputBaseProps, 'children' | 'isFocused' | keyof FlexProps >,
|
|
71
148
|
/**
|
|
72
149
|
* The `prefix` prop in `WordPressComponentProps< InputFieldProps, 'input', false >` comes from the
|
|
73
150
|
* `HTMLInputAttributes` and clashes with the one from `InputBaseProps`. So we have to omit it from
|
package/src/menu-item/style.scss
CHANGED
|
@@ -38,6 +38,16 @@
|
|
|
38
38
|
margin-right: 0;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
&:disabled,
|
|
43
|
+
&[aria-disabled="true"] {
|
|
44
|
+
// Override the button component's tertiary background and color.
|
|
45
|
+
&.is-tertiary {
|
|
46
|
+
background: none;
|
|
47
|
+
color: var(--wp-admin-theme-color-darker-10);
|
|
48
|
+
opacity: 0.3;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
.components-menu-item__info-wrapper {
|
|
@@ -27,7 +27,14 @@ const TestScreen = ( { fullScreen, name, navigateTo } ) => {
|
|
|
27
27
|
);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
beforeAll( () => {
|
|
31
|
+
jest.useFakeTimers( 'legacy' );
|
|
32
|
+
} );
|
|
33
|
+
|
|
34
|
+
afterAll( () => {
|
|
35
|
+
jest.runOnlyPendingTimers();
|
|
36
|
+
jest.useRealTimers();
|
|
37
|
+
} );
|
|
31
38
|
|
|
32
39
|
it( 'animates height transitioning from non-full-screen to full-screen', async () => {
|
|
33
40
|
const screen = render(
|
|
@@ -9,7 +9,15 @@ import { render, fireEvent, waitFor } from 'test/helpers';
|
|
|
9
9
|
*/
|
|
10
10
|
import LinkSettingsNavigation from '../link-settings-navigation';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
beforeAll( () => {
|
|
13
|
+
jest.useFakeTimers( 'legacy' );
|
|
14
|
+
} );
|
|
15
|
+
|
|
16
|
+
afterAll( () => {
|
|
17
|
+
jest.runOnlyPendingTimers();
|
|
18
|
+
jest.useRealTimers();
|
|
19
|
+
} );
|
|
20
|
+
|
|
13
21
|
jest.spyOn( Keyboard, 'dismiss' );
|
|
14
22
|
|
|
15
23
|
const subject = (
|
|
@@ -11,7 +11,7 @@ import { isRTL } from '@wordpress/i18n';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { COLORS } from '../../utils/colors-values';
|
|
15
15
|
import Button from '../../button';
|
|
16
16
|
import { Text } from '../../text';
|
|
17
17
|
import { Heading } from '../../heading';
|
|
@@ -155,18 +155,18 @@ export const ItemBaseUI = styled.li`
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
&.is-active {
|
|
158
|
-
background-color: ${
|
|
159
|
-
color: ${
|
|
158
|
+
background-color: ${ COLORS.ui.theme };
|
|
159
|
+
color: ${ COLORS.white };
|
|
160
160
|
|
|
161
161
|
> button,
|
|
162
162
|
> a {
|
|
163
|
-
color: ${
|
|
163
|
+
color: ${ COLORS.white };
|
|
164
164
|
opacity: 1;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
> svg path {
|
|
169
|
-
color: ${
|
|
169
|
+
color: ${ COLORS.gray[ 600 ] };
|
|
170
170
|
}
|
|
171
171
|
`;
|
|
172
172
|
|
|
@@ -7,15 +7,14 @@ import {
|
|
|
7
7
|
Text,
|
|
8
8
|
TouchableWithoutFeedback,
|
|
9
9
|
View,
|
|
10
|
-
|
|
11
|
-
Platform,
|
|
10
|
+
useWindowDimensions,
|
|
12
11
|
} from 'react-native';
|
|
13
12
|
import { BlurView } from '@react-native-community/blur';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* WordPress dependencies
|
|
17
16
|
*/
|
|
18
|
-
import { useEffect, useRef,
|
|
17
|
+
import { useEffect, useRef, Platform } from '@wordpress/element';
|
|
19
18
|
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
20
19
|
|
|
21
20
|
/**
|
|
@@ -23,57 +22,48 @@ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
|
23
22
|
*/
|
|
24
23
|
import styles from './style.scss';
|
|
25
24
|
|
|
26
|
-
const
|
|
27
|
-
const [ width, setWidth ] = useState( Dimensions.get( 'window' ).width );
|
|
28
|
-
const [ visible, setVisible ] = useState( true );
|
|
25
|
+
const HIDE_TIMER = 3000;
|
|
29
26
|
|
|
27
|
+
const Notice = ( { onNoticeHidden, content, id, status } ) => {
|
|
28
|
+
const { width } = useWindowDimensions();
|
|
30
29
|
const animationValue = useRef( new Animated.Value( 0 ) ).current;
|
|
31
30
|
const timer = useRef( null );
|
|
32
|
-
const isIOS = Platform.OS === 'ios';
|
|
33
|
-
|
|
34
|
-
const onDimensionsChange = () => {
|
|
35
|
-
setWidth( Dimensions.get( 'window' ).width );
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
useEffect( () => {
|
|
39
|
-
const dimensionsChangeSubscription = Dimensions.addEventListener(
|
|
40
|
-
'change',
|
|
41
|
-
onDimensionsChange
|
|
42
|
-
);
|
|
43
|
-
return () => {
|
|
44
|
-
dimensionsChangeSubscription.remove();
|
|
45
|
-
};
|
|
46
|
-
}, [] );
|
|
47
31
|
|
|
48
32
|
useEffect( () => {
|
|
49
33
|
startAnimation();
|
|
34
|
+
|
|
50
35
|
return () => {
|
|
51
36
|
clearTimeout( timer?.current );
|
|
52
37
|
};
|
|
53
|
-
}, [
|
|
38
|
+
}, [] );
|
|
54
39
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
function onHide() {
|
|
41
|
+
Animated.timing( animationValue, {
|
|
42
|
+
toValue: 0,
|
|
43
|
+
duration: 150,
|
|
44
|
+
useNativeDriver: true,
|
|
45
|
+
easing: Easing.out( Easing.quad ),
|
|
46
|
+
} ).start( ( { finished } ) => {
|
|
47
|
+
if ( finished && onNoticeHidden ) {
|
|
48
|
+
onNoticeHidden( id );
|
|
49
|
+
}
|
|
50
|
+
} );
|
|
51
|
+
}
|
|
58
52
|
|
|
59
|
-
|
|
53
|
+
function startAnimation() {
|
|
60
54
|
Animated.timing( animationValue, {
|
|
61
|
-
toValue:
|
|
62
|
-
duration:
|
|
55
|
+
toValue: 1,
|
|
56
|
+
duration: 300,
|
|
63
57
|
useNativeDriver: true,
|
|
64
58
|
easing: Easing.out( Easing.quad ),
|
|
65
|
-
} ).start( () => {
|
|
66
|
-
if (
|
|
59
|
+
} ).start( ( { finished } ) => {
|
|
60
|
+
if ( finished && onNoticeHidden ) {
|
|
67
61
|
timer.current = setTimeout( () => {
|
|
68
62
|
onHide();
|
|
69
|
-
},
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if ( ! visible && onNoticeHidden ) {
|
|
73
|
-
onNoticeHidden( id );
|
|
63
|
+
}, HIDE_TIMER );
|
|
74
64
|
}
|
|
75
65
|
} );
|
|
76
|
-
}
|
|
66
|
+
}
|
|
77
67
|
|
|
78
68
|
const noticeSolidStyles = usePreferredColorSchemeStyle(
|
|
79
69
|
styles.noticeSolid,
|
|
@@ -95,25 +85,25 @@ const Notice = ( { onNoticeHidden, content, id, status } ) => {
|
|
|
95
85
|
status === 'error' && errorTextStyles,
|
|
96
86
|
];
|
|
97
87
|
|
|
88
|
+
const containerStyles = [
|
|
89
|
+
styles.notice,
|
|
90
|
+
! Platform.isIOS && noticeSolidStyles,
|
|
91
|
+
{
|
|
92
|
+
width,
|
|
93
|
+
transform: [
|
|
94
|
+
{
|
|
95
|
+
translateY: animationValue.interpolate( {
|
|
96
|
+
inputRange: [ 0, 1 ],
|
|
97
|
+
outputRange: [ -24, 0 ],
|
|
98
|
+
} ),
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
|
|
98
104
|
return (
|
|
99
105
|
<>
|
|
100
|
-
<Animated.View
|
|
101
|
-
style={ [
|
|
102
|
-
styles.notice,
|
|
103
|
-
! isIOS && noticeSolidStyles,
|
|
104
|
-
{
|
|
105
|
-
width,
|
|
106
|
-
transform: [
|
|
107
|
-
{
|
|
108
|
-
translateY: animationValue.interpolate( {
|
|
109
|
-
inputRange: [ 0, 1 ],
|
|
110
|
-
outputRange: [ -24, 0 ],
|
|
111
|
-
} ),
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
},
|
|
115
|
-
] }
|
|
116
|
-
>
|
|
106
|
+
<Animated.View style={ containerStyles }>
|
|
117
107
|
<TouchableWithoutFeedback onPress={ onHide }>
|
|
118
108
|
<View style={ styles.noticeContent }>
|
|
119
109
|
<Text numberOfLines={ 3 } style={ textStyles }>
|
|
@@ -121,7 +111,7 @@ const Notice = ( { onNoticeHidden, content, id, status } ) => {
|
|
|
121
111
|
</Text>
|
|
122
112
|
</View>
|
|
123
113
|
</TouchableWithoutFeedback>
|
|
124
|
-
{ isIOS && (
|
|
114
|
+
{ Platform.isIOS && (
|
|
125
115
|
<BlurView
|
|
126
116
|
style={ styles.blurBackground }
|
|
127
117
|
blurType="prominent"
|