@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.
Files changed (256) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/CONTRIBUTING.md +80 -7
  3. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
  4. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  5. package/build/angle-picker-control/angle-circle.js +5 -7
  6. package/build/angle-picker-control/angle-circle.js.map +1 -1
  7. package/build/box-control/index.js +0 -21
  8. package/build/box-control/index.js.map +1 -1
  9. package/build/box-control/utils.js +1 -8
  10. package/build/box-control/utils.js.map +1 -1
  11. package/build/button/index.js +3 -5
  12. package/build/button/index.js.map +1 -1
  13. package/build/circular-option-picker/index.js +1 -2
  14. package/build/circular-option-picker/index.js.map +1 -1
  15. package/build/disabled/index.js +4 -76
  16. package/build/disabled/index.js.map +1 -1
  17. package/build/heading/hook.js +1 -1
  18. package/build/heading/hook.js.map +1 -1
  19. package/build/input-control/index.js +27 -4
  20. package/build/input-control/index.js.map +1 -1
  21. package/build/input-control/styles/input-control-styles.js +42 -30
  22. package/build/input-control/styles/input-control-styles.js.map +1 -1
  23. package/build/mobile/bottom-sheet-select-control/index.native.js +1 -0
  24. package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  25. package/build/navigation/styles/navigation-styles.js +12 -12
  26. package/build/navigation/styles/navigation-styles.js.map +1 -1
  27. package/build/notice/index.native.js +44 -40
  28. package/build/notice/index.native.js.map +1 -1
  29. package/build/notice/list.native.js +27 -45
  30. package/build/notice/list.native.js.map +1 -1
  31. package/build/popover/index.js +6 -52
  32. package/build/popover/index.js.map +1 -1
  33. package/build/sandbox/index.js +2 -2
  34. package/build/sandbox/index.js.map +1 -1
  35. package/build/select-control/index.js +31 -4
  36. package/build/select-control/index.js.map +1 -1
  37. package/build/select-control/styles/select-control-styles.js +8 -8
  38. package/build/select-control/styles/select-control-styles.js.map +1 -1
  39. package/build/surface/styles.js +8 -8
  40. package/build/surface/styles.js.map +1 -1
  41. package/build/text/hook.js +5 -5
  42. package/build/text/hook.js.map +1 -1
  43. package/build/text/styles/text-mixins.native.js +1 -1
  44. package/build/text/styles/text-mixins.native.js.map +1 -1
  45. package/build/text/styles.js +7 -7
  46. package/build/text/styles.js.map +1 -1
  47. package/build/text-control/index.js +35 -28
  48. package/build/text-control/index.js.map +1 -1
  49. package/build/text-control/types.js +6 -0
  50. package/build/text-control/types.js.map +1 -0
  51. package/build/toggle-group-control/toggle-group-control-option-icon/component.js +6 -4
  52. package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  53. package/build/tools-panel/tools-panel-header/component.js +52 -36
  54. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  55. package/build/ui/spinner/component.js +1 -1
  56. package/build/ui/spinner/component.js.map +1 -1
  57. package/build/unit-control/index.js +3 -3
  58. package/build/unit-control/index.js.map +1 -1
  59. package/build/unit-control/styles/unit-control-styles.js +11 -20
  60. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  61. package/build/unit-control/utils.js.map +1 -1
  62. package/build/utils/colors-values.js +9 -24
  63. package/build/utils/colors-values.js.map +1 -1
  64. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
  65. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  66. package/build-module/angle-picker-control/angle-circle.js +5 -7
  67. package/build-module/angle-picker-control/angle-circle.js.map +1 -1
  68. package/build-module/box-control/index.js +1 -20
  69. package/build-module/box-control/index.js.map +1 -1
  70. package/build-module/box-control/utils.js +0 -6
  71. package/build-module/box-control/utils.js.map +1 -1
  72. package/build-module/button/index.js +3 -4
  73. package/build-module/button/index.js.map +1 -1
  74. package/build-module/circular-option-picker/index.js +1 -2
  75. package/build-module/circular-option-picker/index.js.map +1 -1
  76. package/build-module/disabled/index.js +5 -76
  77. package/build-module/disabled/index.js.map +1 -1
  78. package/build-module/heading/hook.js +1 -1
  79. package/build-module/heading/hook.js.map +1 -1
  80. package/build-module/input-control/index.js +24 -3
  81. package/build-module/input-control/index.js.map +1 -1
  82. package/build-module/input-control/styles/input-control-styles.js +42 -30
  83. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  84. package/build-module/mobile/bottom-sheet-select-control/index.native.js +1 -0
  85. package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  86. package/build-module/navigation/styles/navigation-styles.js +13 -13
  87. package/build-module/navigation/styles/navigation-styles.js.map +1 -1
  88. package/build-module/notice/index.native.js +45 -41
  89. package/build-module/notice/index.native.js.map +1 -1
  90. package/build-module/notice/list.native.js +28 -46
  91. package/build-module/notice/list.native.js.map +1 -1
  92. package/build-module/popover/index.js +6 -52
  93. package/build-module/popover/index.js.map +1 -1
  94. package/build-module/sandbox/index.js +2 -2
  95. package/build-module/sandbox/index.js.map +1 -1
  96. package/build-module/select-control/index.js +29 -3
  97. package/build-module/select-control/index.js.map +1 -1
  98. package/build-module/select-control/styles/select-control-styles.js +8 -8
  99. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  100. package/build-module/surface/styles.js +8 -8
  101. package/build-module/surface/styles.js.map +1 -1
  102. package/build-module/text/hook.js +5 -5
  103. package/build-module/text/hook.js.map +1 -1
  104. package/build-module/text/styles/text-mixins.native.js +2 -2
  105. package/build-module/text/styles/text-mixins.native.js.map +1 -1
  106. package/build-module/text/styles.js +7 -7
  107. package/build-module/text/styles.js.map +1 -1
  108. package/build-module/text-control/index.js +35 -27
  109. package/build-module/text-control/index.js.map +1 -1
  110. package/build-module/text-control/types.js +2 -0
  111. package/build-module/text-control/types.js.map +1 -0
  112. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -5
  113. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  114. package/build-module/tools-panel/tools-panel-header/component.js +51 -36
  115. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  116. package/build-module/ui/spinner/component.js +1 -1
  117. package/build-module/ui/spinner/component.js.map +1 -1
  118. package/build-module/unit-control/index.js +3 -3
  119. package/build-module/unit-control/index.js.map +1 -1
  120. package/build-module/unit-control/styles/unit-control-styles.js +11 -20
  121. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  122. package/build-module/unit-control/utils.js.map +1 -1
  123. package/build-module/utils/colors-values.js +19 -23
  124. package/build-module/utils/colors-values.js.map +1 -1
  125. package/build-style/style-rtl.css +24 -0
  126. package/build-style/style.css +24 -0
  127. package/build-types/button/index.d.ts.map +1 -1
  128. package/build-types/circular-option-picker/index.d.ts.map +1 -1
  129. package/build-types/color-picker/styles.d.ts +3 -3
  130. package/build-types/disabled/index.d.ts.map +1 -1
  131. package/build-types/input-control/index.d.ts +23 -3
  132. package/build-types/input-control/index.d.ts.map +1 -1
  133. package/build-types/input-control/input-field.d.ts +1 -1
  134. package/build-types/input-control/input-field.d.ts.map +1 -1
  135. package/build-types/input-control/stories/index.d.ts +5 -5
  136. package/build-types/input-control/styles/input-control-styles.d.ts +1 -0
  137. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  138. package/build-types/input-control/types.d.ts +79 -3
  139. package/build-types/input-control/types.d.ts.map +1 -1
  140. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  141. package/build-types/popover/index.d.ts +0 -1
  142. package/build-types/popover/index.d.ts.map +1 -1
  143. package/build-types/select-control/index.d.ts +30 -26
  144. package/build-types/select-control/index.d.ts.map +1 -1
  145. package/build-types/select-control/stories/index.d.ts +23 -0
  146. package/build-types/select-control/stories/index.d.ts.map +1 -0
  147. package/build-types/select-control/styles/select-control-styles.d.ts +3 -4
  148. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  149. package/build-types/select-control/test/select-control.d.ts +2 -0
  150. package/build-types/select-control/test/select-control.d.ts.map +1 -0
  151. package/build-types/select-control/types.d.ts +52 -1
  152. package/build-types/select-control/types.d.ts.map +1 -1
  153. package/build-types/text-control/index.d.ts +32 -0
  154. package/build-types/text-control/index.d.ts.map +1 -0
  155. package/build-types/text-control/stories/index.d.ts +13 -0
  156. package/build-types/text-control/stories/index.d.ts.map +1 -0
  157. package/build-types/text-control/types.d.ts +25 -0
  158. package/build-types/text-control/types.d.ts.map +1 -0
  159. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
  160. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  161. package/build-types/tools-panel/types.d.ts +0 -1
  162. package/build-types/tools-panel/types.d.ts.map +1 -1
  163. package/build-types/unit-control/index.d.ts +2 -2
  164. package/build-types/unit-control/index.d.ts.map +1 -1
  165. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  166. package/build-types/unit-control/test/index.d.ts +2 -0
  167. package/build-types/unit-control/test/index.d.ts.map +1 -0
  168. package/build-types/unit-control/test/utils.d.ts +2 -0
  169. package/build-types/unit-control/test/utils.d.ts.map +1 -0
  170. package/build-types/unit-control/types.d.ts +1 -1
  171. package/build-types/unit-control/types.d.ts.map +1 -1
  172. package/build-types/unit-control/utils.d.ts +3 -3
  173. package/build-types/unit-control/utils.d.ts.map +1 -1
  174. package/build-types/utils/colors-values.d.ts +6 -146
  175. package/build-types/utils/colors-values.d.ts.map +1 -1
  176. package/package.json +17 -17
  177. package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
  178. package/src/angle-picker-control/angle-circle.js +3 -3
  179. package/src/box-control/README.md +0 -74
  180. package/src/box-control/index.js +0 -15
  181. package/src/box-control/stories/index.js +0 -29
  182. package/src/box-control/utils.js +0 -7
  183. package/src/button/index.js +2 -4
  184. package/src/button/test/index.js +16 -1
  185. package/src/circular-option-picker/index.js +1 -2
  186. package/src/color-palette/README.md +0 -1
  187. package/src/color-palette/test/__snapshots__/index.js.snap +2 -3
  188. package/src/confirm-dialog/stories/index.js +87 -99
  189. package/src/date-time/stories/index.js +19 -0
  190. package/src/date-time/test/date.js +107 -78
  191. package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
  192. package/src/disabled/index.js +5 -90
  193. package/src/form-file-upload/test/index.js +15 -12
  194. package/src/heading/hook.ts +1 -1
  195. package/src/heading/test/__snapshots__/index.js.snap +3 -3
  196. package/src/input-control/README.md +3 -3
  197. package/src/input-control/index.tsx +23 -3
  198. package/src/input-control/stories/index.tsx +63 -0
  199. package/src/input-control/styles/input-control-styles.tsx +20 -7
  200. package/src/input-control/types.ts +79 -2
  201. package/src/menu-item/style.scss +10 -0
  202. package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +8 -1
  203. package/src/mobile/bottom-sheet-select-control/index.native.js +1 -0
  204. package/src/mobile/html-text-input/style.android.scss +1 -0
  205. package/src/mobile/html-text-input/style.ios.scss +1 -0
  206. package/src/mobile/link-settings/test/link-settings-navigation.native.js +9 -1
  207. package/src/navigation/styles/navigation-styles.js +5 -5
  208. package/src/notice/index.native.js +44 -54
  209. package/src/notice/list.native.js +27 -51
  210. package/src/notice/style.native.scss +1 -0
  211. package/src/popover/index.js +5 -51
  212. package/src/query-controls/README.md +2 -2
  213. package/src/sandbox/index.js +2 -2
  214. package/src/select-control/README.md +2 -2
  215. package/src/select-control/index.tsx +30 -29
  216. package/src/select-control/stories/index.tsx +90 -0
  217. package/src/select-control/styles/select-control-styles.ts +10 -9
  218. package/src/select-control/test/{select-control.js → select-control.tsx} +2 -2
  219. package/src/select-control/types.ts +66 -1
  220. package/src/surface/styles.js +1 -1
  221. package/src/text/hook.js +1 -1
  222. package/src/text/styles/text-mixins.native.js +2 -2
  223. package/src/text/styles.js +1 -1
  224. package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
  225. package/src/text/test/{index.js → index.tsx} +12 -6
  226. package/src/text-control/index.tsx +84 -0
  227. package/src/text-control/stories/index.tsx +66 -0
  228. package/src/text-control/types.ts +29 -0
  229. package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -5
  230. package/src/toolbar-group/style.scss +20 -0
  231. package/src/tools-panel/test/__snapshots__/index.js.snap +2 -2
  232. package/src/tools-panel/test/index.js +71 -18
  233. package/src/tools-panel/tools-panel-header/component.tsx +75 -33
  234. package/src/tools-panel/types.ts +0 -1
  235. package/src/tooltip/test/index.js +6 -0
  236. package/src/ui/spinner/component.js +1 -1
  237. package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
  238. package/src/unit-control/index.tsx +2 -5
  239. package/src/unit-control/styles/unit-control-styles.ts +3 -13
  240. package/src/unit-control/test/__snapshots__/index.tsx.snap +33 -0
  241. package/src/unit-control/test/{index.js → index.tsx} +214 -165
  242. package/src/unit-control/test/{utils.js → utils.ts} +38 -19
  243. package/src/unit-control/types.ts +4 -1
  244. package/src/unit-control/utils.ts +5 -3
  245. package/src/utils/colors-values.js +18 -22
  246. package/tsconfig.json +9 -2
  247. package/tsconfig.tsbuildinfo +1 -1
  248. package/build/box-control/visualizer.js +0 -165
  249. package/build/box-control/visualizer.js.map +0 -1
  250. package/build-module/box-control/visualizer.js +0 -154
  251. package/build-module/box-control/visualizer.js.map +0 -1
  252. package/src/box-control/visualizer.js +0 -116
  253. package/src/input-control/stories/index.js +0 -71
  254. package/src/select-control/stories/index.js +0 -104
  255. package/src/text-control/index.js +0 -72
  256. 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 = [ { value: 'px' }, { value: '%' } ];
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 = [ { value: 'px' }, { value: '%' } ];
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 = [ { value: 'px' }, { value: '%' } ];
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 = [ { value: 'em' }, { value: 'vh' } ];
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 = [ { value: 'px' }, { value: 'em' } ];
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.value ).toBe( '%' );
189
- expect( currentUnit.label ).toBe( '%' );
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.value ).toBe( '%' );
200
- expect( currentUnit.label ).toBe( '%' );
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< InputControlProps, 'hideLabelFromVision' > & {
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( units?: WPUnitControlUnit[] ): boolean {
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: WPUnitControlUnit[],
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: Record< string, number >;
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
- export const BASE = {
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
- export const DARK_GRAY = {
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
- export const DARK_OPACITY = {
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
- export const DARK_OPACITY_LIGHT = {
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
- export const LIGHT_GRAY = {
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
- export const LIGHT_OPACITY_LIGHT = {
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
- export const BLUE = {
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
- export const ALERT = {
132
+ const ALERT = {
143
133
  yellow: '#f0b849',
144
134
  red: '#d94f4f',
145
135
  green: '#4ab866',
146
136
  };
147
137
 
148
- export const ADMIN = {
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
- export const UI = {
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: merge( {}, DARK_GRAY, G2.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": [ "gutenberg-env" ],
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
  ]