@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
|
@@ -7,21 +7,28 @@ import {
|
|
|
7
7
|
getValidParsedQuantityAndUnit,
|
|
8
8
|
getUnitsWithCurrentUnit,
|
|
9
9
|
} from '../utils';
|
|
10
|
+
import type { WPUnitControlUnit } from '../types';
|
|
10
11
|
|
|
11
12
|
describe( 'UnitControl utils', () => {
|
|
12
13
|
describe( 'useCustomUnits', () => {
|
|
13
14
|
it( 'should return filtered css units', () => {
|
|
14
|
-
const cssUnits = [
|
|
15
|
+
const cssUnits = [
|
|
16
|
+
{ value: 'px', label: 'pixel' },
|
|
17
|
+
{ value: '%', label: 'percent' },
|
|
18
|
+
];
|
|
15
19
|
const units = useCustomUnits( {
|
|
16
20
|
availableUnits: [ 'em', 'px' ],
|
|
17
21
|
units: cssUnits,
|
|
18
22
|
} );
|
|
19
23
|
|
|
20
|
-
expect( units ).toEqual( [ { value: 'px' } ] );
|
|
24
|
+
expect( units ).toEqual( [ { value: 'px', label: 'pixel' } ] );
|
|
21
25
|
} );
|
|
22
26
|
|
|
23
27
|
it( 'should add default values to available units', () => {
|
|
24
|
-
const cssUnits = [
|
|
28
|
+
const cssUnits = [
|
|
29
|
+
{ value: 'px', label: 'pixel' },
|
|
30
|
+
{ value: '%', label: 'percent' },
|
|
31
|
+
];
|
|
25
32
|
const units = useCustomUnits( {
|
|
26
33
|
availableUnits: [ '%', 'px' ],
|
|
27
34
|
defaultValues: { '%': 10, px: 10 },
|
|
@@ -29,8 +36,8 @@ describe( 'UnitControl utils', () => {
|
|
|
29
36
|
} );
|
|
30
37
|
|
|
31
38
|
expect( units ).toEqual( [
|
|
32
|
-
{ value: 'px', default: 10 },
|
|
33
|
-
{ value: '%', default: 10 },
|
|
39
|
+
{ value: 'px', label: 'pixel', default: 10 },
|
|
40
|
+
{ value: '%', label: 'percent', default: 10 },
|
|
34
41
|
] );
|
|
35
42
|
} );
|
|
36
43
|
|
|
@@ -38,24 +45,32 @@ describe( 'UnitControl utils', () => {
|
|
|
38
45
|
// Although the public APIs of the component expect a `number` as the type of the
|
|
39
46
|
// default values, it's still good to test for strings (as it can happen in un-typed
|
|
40
47
|
// environments)
|
|
41
|
-
const cssUnits = [
|
|
48
|
+
const cssUnits = [
|
|
49
|
+
{ value: 'px', label: 'pixel' },
|
|
50
|
+
{ value: '%', label: 'percent' },
|
|
51
|
+
];
|
|
42
52
|
const units = useCustomUnits( {
|
|
43
53
|
availableUnits: [ '%', 'px' ],
|
|
44
54
|
defaultValues: {
|
|
55
|
+
// @ts-expect-error (passing a string instead of a number is the point of the test)
|
|
45
56
|
'%': '14',
|
|
57
|
+
// @ts-expect-error (passing a string instead of a number is the point of the test)
|
|
46
58
|
px: 'not a valid numeric quantity',
|
|
47
59
|
},
|
|
48
60
|
units: cssUnits,
|
|
49
61
|
} );
|
|
50
62
|
|
|
51
63
|
expect( units ).toEqual( [
|
|
52
|
-
{ value: 'px', default: undefined },
|
|
53
|
-
{ value: '%', default: 14 },
|
|
64
|
+
{ value: 'px', label: 'pixel', default: undefined },
|
|
65
|
+
{ value: '%', label: 'percent', default: 14 },
|
|
54
66
|
] );
|
|
55
67
|
} );
|
|
56
68
|
|
|
57
69
|
it( 'should return an empty array where availableUnits match no preferred css units', () => {
|
|
58
|
-
const cssUnits = [
|
|
70
|
+
const cssUnits = [
|
|
71
|
+
{ value: 'em', label: 'em' },
|
|
72
|
+
{ value: 'vh', label: 'vh' },
|
|
73
|
+
];
|
|
59
74
|
const units = useCustomUnits( {
|
|
60
75
|
availableUnits: [ '%', 'px' ],
|
|
61
76
|
defaultValues: { '%': 10, px: 10 },
|
|
@@ -69,16 +84,19 @@ describe( 'UnitControl utils', () => {
|
|
|
69
84
|
describe( 'filterUnitsWithSettings', () => {
|
|
70
85
|
it( 'should return filtered units array', () => {
|
|
71
86
|
const preferredUnits = [ '%', 'px' ];
|
|
72
|
-
const availableUnits = [
|
|
87
|
+
const availableUnits = [
|
|
88
|
+
{ value: 'px', label: 'pixel' },
|
|
89
|
+
{ value: 'em', label: 'em' },
|
|
90
|
+
];
|
|
73
91
|
|
|
74
92
|
expect(
|
|
75
93
|
filterUnitsWithSettings( preferredUnits, availableUnits )
|
|
76
|
-
).toEqual( [ { value: 'px' } ] );
|
|
94
|
+
).toEqual( [ { value: 'px', label: 'pixel' } ] );
|
|
77
95
|
} );
|
|
78
96
|
|
|
79
97
|
it( 'should return empty array where preferred units match no available css unit', () => {
|
|
80
98
|
const preferredUnits = [ '%', 'px' ];
|
|
81
|
-
const availableUnits = [ { value: 'em' } ];
|
|
99
|
+
const availableUnits = [ { value: 'em', label: 'em' } ];
|
|
82
100
|
|
|
83
101
|
expect(
|
|
84
102
|
filterUnitsWithSettings( preferredUnits, availableUnits )
|
|
@@ -92,13 +110,14 @@ describe( 'UnitControl utils', () => {
|
|
|
92
110
|
const availableUnits = false;
|
|
93
111
|
|
|
94
112
|
expect(
|
|
113
|
+
// @ts-expect-error (passing `false` instead of a valid array of units is the point of the test)
|
|
95
114
|
filterUnitsWithSettings( preferredUnits, availableUnits )
|
|
96
115
|
).toEqual( [] );
|
|
97
116
|
} );
|
|
98
117
|
|
|
99
118
|
it( 'should return empty array where available units is set to an empty array', () => {
|
|
100
119
|
const preferredUnits = [ '%', 'px' ];
|
|
101
|
-
const availableUnits = [];
|
|
120
|
+
const availableUnits: WPUnitControlUnit[] = [];
|
|
102
121
|
|
|
103
122
|
expect(
|
|
104
123
|
filterUnitsWithSettings( preferredUnits, availableUnits )
|
|
@@ -127,7 +146,7 @@ describe( 'UnitControl utils', () => {
|
|
|
127
146
|
|
|
128
147
|
it( 'should return fallback value', () => {
|
|
129
148
|
const nextValue = 'thirteen';
|
|
130
|
-
const preferredUnits = [ { value: 'em' } ];
|
|
149
|
+
const preferredUnits = [ { value: 'em', label: 'em' } ];
|
|
131
150
|
const fallbackValue = 13;
|
|
132
151
|
|
|
133
152
|
expect(
|
|
@@ -155,7 +174,7 @@ describe( 'UnitControl utils', () => {
|
|
|
155
174
|
|
|
156
175
|
it( 'should return first unit in preferred units collection as second fallback unit', () => {
|
|
157
176
|
const nextValue = 101;
|
|
158
|
-
const preferredUnits = [ { value: 'px' } ];
|
|
177
|
+
const preferredUnits = [ { value: 'px', label: 'pixel' } ];
|
|
159
178
|
|
|
160
179
|
expect(
|
|
161
180
|
getValidParsedQuantityAndUnit( nextValue, preferredUnits )
|
|
@@ -185,8 +204,8 @@ describe( 'UnitControl utils', () => {
|
|
|
185
204
|
expect( result ).toHaveLength( 3 );
|
|
186
205
|
|
|
187
206
|
const currentUnit = result.shift();
|
|
188
|
-
expect( currentUnit
|
|
189
|
-
expect( currentUnit
|
|
207
|
+
expect( currentUnit?.value ).toBe( '%' );
|
|
208
|
+
expect( currentUnit?.label ).toBe( '%' );
|
|
190
209
|
expect( result ).toEqual( limitedUnits );
|
|
191
210
|
} );
|
|
192
211
|
|
|
@@ -196,8 +215,8 @@ describe( 'UnitControl utils', () => {
|
|
|
196
215
|
expect( result ).toHaveLength( 3 );
|
|
197
216
|
|
|
198
217
|
const currentUnit = result.shift();
|
|
199
|
-
expect( currentUnit
|
|
200
|
-
expect( currentUnit
|
|
218
|
+
expect( currentUnit?.value ).toBe( '%' );
|
|
219
|
+
expect( currentUnit?.label ).toBe( '%' );
|
|
201
220
|
expect( result ).toEqual( limitedUnits );
|
|
202
221
|
} );
|
|
203
222
|
|
|
@@ -74,7 +74,10 @@ export type UnitSelectControlProps = {
|
|
|
74
74
|
|
|
75
75
|
// TODO: when available, should (partially) extend `NumberControl` props.
|
|
76
76
|
export type UnitControlProps = Omit< UnitSelectControlProps, 'unit' > &
|
|
77
|
-
Pick<
|
|
77
|
+
Pick<
|
|
78
|
+
InputControlProps,
|
|
79
|
+
'hideLabelFromVision' | '__next36pxDefaultSize'
|
|
80
|
+
> & {
|
|
78
81
|
__unstableStateReducer?: StateReducer;
|
|
79
82
|
__unstableInputWidth?: CSSProperties[ 'width' ];
|
|
80
83
|
/**
|
|
@@ -155,7 +155,9 @@ export function getParsedQuantityAndUnit(
|
|
|
155
155
|
* @param units List of units.
|
|
156
156
|
* @return Whether the list actually contains any units.
|
|
157
157
|
*/
|
|
158
|
-
export function hasUnits(
|
|
158
|
+
export function hasUnits(
|
|
159
|
+
units?: WPUnitControlUnit[]
|
|
160
|
+
): units is WPUnitControlUnit[] {
|
|
159
161
|
// Although the `isArray` check shouldn't be necessary (given the signature of
|
|
160
162
|
// this typed function), it's better to stay on the side of caution, since
|
|
161
163
|
// this function may be called from un-typed environments.
|
|
@@ -218,7 +220,7 @@ export function parseQuantityAndUnitFromRawValue(
|
|
|
218
220
|
*/
|
|
219
221
|
export function getValidParsedQuantityAndUnit(
|
|
220
222
|
rawValue: string | number,
|
|
221
|
-
allowedUnits
|
|
223
|
+
allowedUnits?: WPUnitControlUnit[],
|
|
222
224
|
fallbackQuantity?: number,
|
|
223
225
|
fallbackUnit?: string
|
|
224
226
|
): [ number | undefined, string | undefined ] {
|
|
@@ -295,7 +297,7 @@ export const useCustomUnits = ( {
|
|
|
295
297
|
}: {
|
|
296
298
|
units?: WPUnitControlUnit[];
|
|
297
299
|
availableUnits?: string[];
|
|
298
|
-
defaultValues
|
|
300
|
+
defaultValues?: Record< string, number >;
|
|
299
301
|
} ): WPUnitControlUnit[] => {
|
|
300
302
|
const customUnitsToReturn = filterUnitsWithSettings(
|
|
301
303
|
availableUnits,
|
|
@@ -8,18 +8,12 @@ import { merge } from 'lodash';
|
|
|
8
8
|
*/
|
|
9
9
|
import { rgba } from './colors';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const BASE = {
|
|
12
12
|
black: '#000',
|
|
13
13
|
white: '#fff',
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
* TODO: Continue to update values as "G2" design evolves.
|
|
18
|
-
*
|
|
19
|
-
* "G2" refers to the movement to advance the interface of the block editor.
|
|
20
|
-
* https://github.com/WordPress/gutenberg/issues/18667
|
|
21
|
-
*/
|
|
22
|
-
export const G2 = {
|
|
16
|
+
const G2 = {
|
|
23
17
|
blue: {
|
|
24
18
|
medium: {
|
|
25
19
|
focus: '#007cba',
|
|
@@ -35,10 +29,6 @@ export const G2 = {
|
|
|
35
29
|
200: '#e0e0e0', // Used sparingly for light borders.
|
|
36
30
|
100: '#f0f0f0', // Used for light gray backgrounds.
|
|
37
31
|
},
|
|
38
|
-
darkGray: {
|
|
39
|
-
primary: '#1e1e1e',
|
|
40
|
-
heading: '#050505',
|
|
41
|
-
},
|
|
42
32
|
mediumGray: {
|
|
43
33
|
text: '#757575',
|
|
44
34
|
},
|
|
@@ -49,7 +39,7 @@ export const G2 = {
|
|
|
49
39
|
},
|
|
50
40
|
};
|
|
51
41
|
|
|
52
|
-
|
|
42
|
+
const DARK_GRAY = {
|
|
53
43
|
900: '#191e23',
|
|
54
44
|
800: '#23282d',
|
|
55
45
|
700: '#32373c',
|
|
@@ -63,7 +53,7 @@ export const DARK_GRAY = {
|
|
|
63
53
|
placeholder: rgba( G2.gray[ 900 ], 0.62 ),
|
|
64
54
|
};
|
|
65
55
|
|
|
66
|
-
|
|
56
|
+
const DARK_OPACITY = {
|
|
67
57
|
900: rgba( '#000510', 0.9 ),
|
|
68
58
|
800: rgba( '#00000a', 0.85 ),
|
|
69
59
|
700: rgba( '#06060b', 0.8 ),
|
|
@@ -76,7 +66,7 @@ export const DARK_OPACITY = {
|
|
|
76
66
|
backgroundFill: rgba( DARK_GRAY[ 700 ], 0.7 ),
|
|
77
67
|
};
|
|
78
68
|
|
|
79
|
-
|
|
69
|
+
const DARK_OPACITY_LIGHT = {
|
|
80
70
|
900: rgba( '#304455', 0.45 ),
|
|
81
71
|
800: rgba( '#425863', 0.4 ),
|
|
82
72
|
700: rgba( '#667886', 0.35 ),
|
|
@@ -88,7 +78,7 @@ export const DARK_OPACITY_LIGHT = {
|
|
|
88
78
|
100: rgba( '#747474', 0.05 ),
|
|
89
79
|
};
|
|
90
80
|
|
|
91
|
-
|
|
81
|
+
const LIGHT_GRAY = {
|
|
92
82
|
900: '#a2aab2',
|
|
93
83
|
800: '#b5bcc2',
|
|
94
84
|
700: '#ccd0d4',
|
|
@@ -101,7 +91,7 @@ export const LIGHT_GRAY = {
|
|
|
101
91
|
placeholder: rgba( BASE.white, 0.65 ),
|
|
102
92
|
};
|
|
103
93
|
|
|
104
|
-
|
|
94
|
+
const LIGHT_OPACITY_LIGHT = {
|
|
105
95
|
900: rgba( BASE.white, 0.5 ),
|
|
106
96
|
800: rgba( BASE.white, 0.45 ),
|
|
107
97
|
700: rgba( BASE.white, 0.4 ),
|
|
@@ -117,7 +107,7 @@ export const LIGHT_OPACITY_LIGHT = {
|
|
|
117
107
|
// Additional colors.
|
|
118
108
|
// Some are from https://make.wordpress.org/design/handbook/foundations/colors/.
|
|
119
109
|
|
|
120
|
-
|
|
110
|
+
const BLUE = {
|
|
121
111
|
wordpress: {
|
|
122
112
|
700: '#00669b',
|
|
123
113
|
},
|
|
@@ -139,19 +129,19 @@ export const BLUE = {
|
|
|
139
129
|
},
|
|
140
130
|
};
|
|
141
131
|
|
|
142
|
-
|
|
132
|
+
const ALERT = {
|
|
143
133
|
yellow: '#f0b849',
|
|
144
134
|
red: '#d94f4f',
|
|
145
135
|
green: '#4ab866',
|
|
146
136
|
};
|
|
147
137
|
|
|
148
|
-
|
|
138
|
+
const ADMIN = {
|
|
149
139
|
theme: `var( --wp-admin-theme-color, ${ BLUE.wordpress[ 700 ] })`,
|
|
150
140
|
themeDark10: `var( --wp-admin-theme-color-darker-10, ${ BLUE.medium.focus })`,
|
|
151
141
|
};
|
|
152
142
|
|
|
153
143
|
// Namespaced values for raw colors hex codes.
|
|
154
|
-
|
|
144
|
+
const UI = {
|
|
155
145
|
theme: ADMIN.theme,
|
|
156
146
|
background: BASE.white,
|
|
157
147
|
backgroundDisabled: LIGHT_GRAY[ 200 ],
|
|
@@ -169,10 +159,16 @@ export const UI = {
|
|
|
169
159
|
// Using Object.assign instead of { ...spread } syntax helps TypeScript
|
|
170
160
|
// to extract the correct type defs here.
|
|
171
161
|
export const COLORS = Object.assign( {}, BASE, {
|
|
172
|
-
darkGray:
|
|
162
|
+
darkGray: DARK_GRAY,
|
|
173
163
|
darkOpacity: DARK_OPACITY,
|
|
174
164
|
darkOpacityLight: DARK_OPACITY_LIGHT,
|
|
175
165
|
mediumGray: G2.mediumGray,
|
|
166
|
+
/**
|
|
167
|
+
* The main gray color object (since Apr 16, 2022).
|
|
168
|
+
*
|
|
169
|
+
* We are in the process of simplifying the colors in this file,
|
|
170
|
+
* please prefer this `gray` object in the meantime.
|
|
171
|
+
*/
|
|
176
172
|
gray: G2.gray,
|
|
177
173
|
lightGray: merge( {}, LIGHT_GRAY, G2.lightGray ),
|
|
178
174
|
lightGrayLight: LIGHT_OPACITY_LIGHT,
|
package/tsconfig.json
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"rootDir": "src",
|
|
5
5
|
"declarationDir": "build-types",
|
|
6
|
-
"types": [
|
|
6
|
+
"types": [
|
|
7
|
+
"gutenberg-env",
|
|
8
|
+
"gutenberg-test-env",
|
|
9
|
+
"jest",
|
|
10
|
+
"@testing-library/jest-dom",
|
|
11
|
+
"snapshot-diff"
|
|
12
|
+
],
|
|
7
13
|
// Some errors in Reakit types with TypeScript 4.3
|
|
8
14
|
// Remove the following line when they've been addressed.
|
|
9
15
|
"skipLibCheck": true,
|
|
@@ -71,6 +77,7 @@
|
|
|
71
77
|
"src/spinner/**/*",
|
|
72
78
|
"src/surface/**/*",
|
|
73
79
|
"src/text/**/*",
|
|
80
|
+
"src/text-control/**/*",
|
|
74
81
|
"src/tip/**/*",
|
|
75
82
|
"src/toggle-group-control/**/*",
|
|
76
83
|
"src/tools-panel/**/*",
|
|
@@ -90,7 +97,7 @@
|
|
|
90
97
|
"src/**/*.native.js",
|
|
91
98
|
"src/**/react-native-*",
|
|
92
99
|
"src/**/stories/**.js", // only exclude js files, tsx files should be checked
|
|
93
|
-
"src/**/test",
|
|
100
|
+
"src/**/test/**.js", // only exclude js files, ts{x} files should be checked
|
|
94
101
|
"src/ui/__storybook-utils",
|
|
95
102
|
"src/ui/font-size-control"
|
|
96
103
|
]
|