@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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { render as RTLrender, screen } from '@testing-library/react';
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
- function render( jsx ) {
18
- return {
19
- user: userEvent.setup( {
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
- const { user } = render(
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
- const { user } = render(
73
+ render(
71
74
  <FormFileUpload
72
75
  onClick={ jest.fn( ( e ) => ( e.target.value = '' ) ) }
73
76
  onChange={ onChange }
@@ -70,7 +70,7 @@ export function useHeading(
70
70
  }
71
71
 
72
72
  const textProps = useText( {
73
- color: COLORS.darkGray.heading,
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: #050505;
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": "#050505",
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": "#050505",
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 | Number`
109
- - Required: Yes
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 InputControl(
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
- const ForwardedComponent = forwardRef( InputControl );
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 ForwardedComponent;
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 = ( { inputSize: size }: InputProps ) => {
144
+ const sizeStyles = ( {
145
+ inputSize: size,
146
+ __next36pxDefaultSize,
147
+ }: InputProps ) => {
144
148
  const sizes = {
145
149
  default: {
146
- height: 30,
150
+ height: 36,
147
151
  lineHeight: 1,
148
- minHeight: 30,
149
- paddingLeft: 8,
150
- paddingRight: 8,
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.black };
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
@@ -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
- jest.useFakeTimers( 'legacy' );
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(
@@ -82,6 +82,7 @@ const BottomSheetSelectControl = ( {
82
82
  customActionButton
83
83
  separatorType="none"
84
84
  label={ item.label }
85
+ icon={ item.icon }
85
86
  onPress={ onChangeValue( item.value ) }
86
87
  leftAlign={ true }
87
88
  key={ index }
@@ -14,6 +14,7 @@
14
14
  padding-right: $padding;
15
15
  padding-top: $padding;
16
16
  padding-bottom: $padding;
17
+ margin-top: $padding * 2;
17
18
  }
18
19
 
19
20
  .scrollView {
@@ -20,4 +20,5 @@ $title-height: 32;
20
20
  padding-top: $padding;
21
21
  padding-bottom: $padding;
22
22
  height: $title-height;
23
+ margin-top: $padding * 2;
23
24
  }
@@ -9,7 +9,15 @@ import { render, fireEvent, waitFor } from 'test/helpers';
9
9
  */
10
10
  import LinkSettingsNavigation from '../link-settings-navigation';
11
11
 
12
- jest.useFakeTimers( 'legacy' );
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 { BASE, G2, UI } from '../../utils/colors-values';
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: ${ UI.theme };
159
- color: ${ BASE.white };
158
+ background-color: ${ COLORS.ui.theme };
159
+ color: ${ COLORS.white };
160
160
 
161
161
  > button,
162
162
  > a {
163
- color: ${ BASE.white };
163
+ color: ${ COLORS.white };
164
164
  opacity: 1;
165
165
  }
166
166
  }
167
167
 
168
168
  > svg path {
169
- color: ${ G2.lightGray.ui };
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
- Dimensions,
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, useState } from '@wordpress/element';
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 Notice = ( { onNoticeHidden, content, id, status } ) => {
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
- }, [ visible, id ] );
38
+ }, [] );
54
39
 
55
- const onHide = () => {
56
- setVisible( false );
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
- const startAnimation = () => {
53
+ function startAnimation() {
60
54
  Animated.timing( animationValue, {
61
- toValue: visible ? 1 : 0,
62
- duration: visible ? 300 : 150,
55
+ toValue: 1,
56
+ duration: 300,
63
57
  useNativeDriver: true,
64
58
  easing: Easing.out( Easing.quad ),
65
- } ).start( () => {
66
- if ( visible && onNoticeHidden ) {
59
+ } ).start( ( { finished } ) => {
60
+ if ( finished && onNoticeHidden ) {
67
61
  timer.current = setTimeout( () => {
68
62
  onHide();
69
- }, 3000 );
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"