@wordpress/components 25.2.0 → 25.4.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 (208) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/build/button/index.js +13 -4
  3. package/build/button/index.js.map +1 -1
  4. package/build/button/index.native.js +9 -6
  5. package/build/button/index.native.js.map +1 -1
  6. package/build/confirm-dialog/component.js +9 -1
  7. package/build/confirm-dialog/component.js.map +1 -1
  8. package/build/font-size-picker/index.js +5 -3
  9. package/build/font-size-picker/index.js.map +1 -1
  10. package/build/font-size-picker/styles.js +19 -26
  11. package/build/font-size-picker/styles.js.map +1 -1
  12. package/build/form-token-field/styles.js +4 -2
  13. package/build/form-token-field/styles.js.map +1 -1
  14. package/build/guide/icons.js +2 -5
  15. package/build/guide/icons.js.map +1 -1
  16. package/build/guide/index.js +14 -11
  17. package/build/guide/index.js.map +1 -1
  18. package/build/guide/page-control.js +1 -3
  19. package/build/guide/page-control.js.map +1 -1
  20. package/build/item-group/item/hook.js +1 -1
  21. package/build/item-group/item/hook.js.map +1 -1
  22. package/build/item-group/styles.js +13 -10
  23. package/build/item-group/styles.js.map +1 -1
  24. package/build/mobile/bottom-sheet/cell.native.js +2 -1
  25. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  26. package/build/mobile/image/index.native.js +4 -3
  27. package/build/mobile/image/index.native.js.map +1 -1
  28. package/build/navigator/navigator-provider/component.js +18 -10
  29. package/build/navigator/navigator-provider/component.js.map +1 -1
  30. package/build/number-control/index.js +8 -4
  31. package/build/number-control/index.js.map +1 -1
  32. package/build/number-control/styles/number-control-styles.js +9 -15
  33. package/build/number-control/styles/number-control-styles.js.map +1 -1
  34. package/build/query-controls/index.js +1 -0
  35. package/build/query-controls/index.js.map +1 -1
  36. package/build/query-controls/index.native.js +1 -0
  37. package/build/query-controls/index.native.js.map +1 -1
  38. package/build/range-control/index.js +7 -1
  39. package/build/range-control/index.js.map +1 -1
  40. package/build/range-control/input-range.js.map +1 -1
  41. package/build/range-control/styles/range-control-styles.js +35 -36
  42. package/build/range-control/styles/range-control-styles.js.map +1 -1
  43. package/build/select-control/index.js +2 -1
  44. package/build/select-control/index.js.map +1 -1
  45. package/build/text-control/index.js +2 -2
  46. package/build/text-control/index.js.map +1 -1
  47. package/build/toolbar/toolbar-group/toolbar-group-container.native.js +10 -7
  48. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  49. package/build/unit-control/index.js +4 -2
  50. package/build/unit-control/index.js.map +1 -1
  51. package/build/z-stack/component.js +5 -3
  52. package/build/z-stack/component.js.map +1 -1
  53. package/build/z-stack/styles.js +23 -42
  54. package/build/z-stack/styles.js.map +1 -1
  55. package/build-module/button/index.js +13 -4
  56. package/build-module/button/index.js.map +1 -1
  57. package/build-module/button/index.native.js +8 -6
  58. package/build-module/button/index.native.js.map +1 -1
  59. package/build-module/confirm-dialog/component.js +10 -2
  60. package/build-module/confirm-dialog/component.js.map +1 -1
  61. package/build-module/font-size-picker/index.js +5 -4
  62. package/build-module/font-size-picker/index.js.map +1 -1
  63. package/build-module/font-size-picker/styles.js +17 -23
  64. package/build-module/font-size-picker/styles.js.map +1 -1
  65. package/build-module/form-token-field/styles.js +3 -2
  66. package/build-module/form-token-field/styles.js.map +1 -1
  67. package/build-module/guide/icons.js +2 -5
  68. package/build-module/guide/icons.js.map +1 -1
  69. package/build-module/guide/index.js +14 -10
  70. package/build-module/guide/index.js.map +1 -1
  71. package/build-module/guide/page-control.js +1 -3
  72. package/build-module/guide/page-control.js.map +1 -1
  73. package/build-module/item-group/item/hook.js +1 -1
  74. package/build-module/item-group/item/hook.js.map +1 -1
  75. package/build-module/item-group/styles.js +13 -11
  76. package/build-module/item-group/styles.js.map +1 -1
  77. package/build-module/mobile/bottom-sheet/cell.native.js +2 -1
  78. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  79. package/build-module/mobile/image/index.native.js +4 -3
  80. package/build-module/mobile/image/index.native.js.map +1 -1
  81. package/build-module/navigator/navigator-provider/component.js +18 -10
  82. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  83. package/build-module/number-control/index.js +8 -5
  84. package/build-module/number-control/index.js.map +1 -1
  85. package/build-module/number-control/styles/number-control-styles.js +7 -14
  86. package/build-module/number-control/styles/number-control-styles.js.map +1 -1
  87. package/build-module/query-controls/index.js +1 -0
  88. package/build-module/query-controls/index.js.map +1 -1
  89. package/build-module/query-controls/index.native.js +1 -0
  90. package/build-module/query-controls/index.native.js.map +1 -1
  91. package/build-module/range-control/index.js +6 -1
  92. package/build-module/range-control/index.js.map +1 -1
  93. package/build-module/range-control/input-range.js.map +1 -1
  94. package/build-module/range-control/styles/range-control-styles.js +35 -36
  95. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  96. package/build-module/select-control/index.js +2 -1
  97. package/build-module/select-control/index.js.map +1 -1
  98. package/build-module/text-control/index.js +2 -2
  99. package/build-module/text-control/index.js.map +1 -1
  100. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js +11 -7
  101. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  102. package/build-module/unit-control/index.js +3 -2
  103. package/build-module/unit-control/index.js.map +1 -1
  104. package/build-module/z-stack/component.js +5 -3
  105. package/build-module/z-stack/component.js.map +1 -1
  106. package/build-module/z-stack/styles.js +22 -44
  107. package/build-module/z-stack/styles.js.map +1 -1
  108. package/build-style/style-rtl.css +22 -35
  109. package/build-style/style.css +22 -35
  110. package/build-types/button/deprecated.d.ts +6 -6
  111. package/build-types/button/index.d.ts.map +1 -1
  112. package/build-types/button/types.d.ts +16 -9
  113. package/build-types/button/types.d.ts.map +1 -1
  114. package/build-types/color-picker/styles.d.ts +2 -1
  115. package/build-types/color-picker/styles.d.ts.map +1 -1
  116. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  117. package/build-types/font-size-picker/index.d.ts.map +1 -1
  118. package/build-types/font-size-picker/styles.d.ts +0 -6
  119. package/build-types/font-size-picker/styles.d.ts.map +1 -1
  120. package/build-types/form-token-field/styles.d.ts.map +1 -1
  121. package/build-types/guide/icons.d.ts +1 -3
  122. package/build-types/guide/icons.d.ts.map +1 -1
  123. package/build-types/guide/index.d.ts.map +1 -1
  124. package/build-types/guide/page-control.d.ts.map +1 -1
  125. package/build-types/item-group/item/hook.d.ts.map +1 -1
  126. package/build-types/item-group/stories/index.d.ts.map +1 -1
  127. package/build-types/item-group/styles.d.ts +1 -1
  128. package/build-types/item-group/styles.d.ts.map +1 -1
  129. package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
  130. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -1
  131. package/build-types/navigator/navigator-button/component.d.ts +1 -1
  132. package/build-types/navigator/navigator-button/hook.d.ts +1 -1
  133. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  134. package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -1
  135. package/build-types/navigator/types.d.ts +3 -1
  136. package/build-types/navigator/types.d.ts.map +1 -1
  137. package/build-types/number-control/index.d.ts.map +1 -1
  138. package/build-types/number-control/styles/number-control-styles.d.ts +5 -3
  139. package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
  140. package/build-types/query-controls/index.d.ts.map +1 -1
  141. package/build-types/range-control/index.d.ts +15 -2
  142. package/build-types/range-control/index.d.ts.map +1 -1
  143. package/build-types/range-control/input-range.d.ts.map +1 -1
  144. package/build-types/range-control/styles/range-control-styles.d.ts +4 -2
  145. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  146. package/build-types/range-control/types.d.ts +6 -0
  147. package/build-types/range-control/types.d.ts.map +1 -1
  148. package/build-types/select-control/index.d.ts.map +1 -1
  149. package/build-types/select-control/types.d.ts +6 -0
  150. package/build-types/select-control/types.d.ts.map +1 -1
  151. package/build-types/text-control/test/text-control.d.ts +2 -0
  152. package/build-types/text-control/test/text-control.d.ts.map +1 -0
  153. package/build-types/toolbar/toolbar-button/index.d.ts +6 -6
  154. package/build-types/unit-control/index.d.ts.map +1 -1
  155. package/build-types/z-stack/component.d.ts.map +1 -1
  156. package/build-types/z-stack/stories/index.d.ts.map +1 -1
  157. package/build-types/z-stack/styles.d.ts +5 -4
  158. package/build-types/z-stack/styles.d.ts.map +1 -1
  159. package/package.json +22 -22
  160. package/src/button/README.md +15 -0
  161. package/src/button/index.native.js +9 -3
  162. package/src/button/index.tsx +11 -4
  163. package/src/button/style.native.scss +9 -0
  164. package/src/button/style.scss +13 -12
  165. package/src/button/test/index.tsx +13 -0
  166. package/src/button/types.ts +17 -9
  167. package/src/confirm-dialog/component.tsx +12 -2
  168. package/src/confirm-dialog/stories/index.js +8 -15
  169. package/src/confirm-dialog/test/index.js +42 -0
  170. package/src/dropdown-menu/style.scss +9 -13
  171. package/src/font-size-picker/index.tsx +9 -5
  172. package/src/font-size-picker/styles.ts +0 -10
  173. package/src/form-token-field/styles.ts +2 -0
  174. package/src/guide/icons.tsx +2 -7
  175. package/src/guide/index.tsx +14 -13
  176. package/src/guide/page-control.tsx +1 -5
  177. package/src/guide/style.scss +8 -24
  178. package/src/item-group/item/hook.ts +2 -1
  179. package/src/item-group/stories/index.tsx +8 -3
  180. package/src/item-group/styles.ts +39 -28
  181. package/src/mobile/bottom-sheet/cell.native.js +1 -0
  182. package/src/mobile/image/index.native.js +8 -6
  183. package/src/mobile/image/style.native.scss +5 -1
  184. package/src/modal/style.scss +3 -2
  185. package/src/navigator/navigator-provider/component.tsx +30 -23
  186. package/src/navigator/types.ts +4 -1
  187. package/src/number-control/index.tsx +6 -4
  188. package/src/number-control/styles/number-control-styles.ts +8 -16
  189. package/src/placeholder/style.scss +5 -0
  190. package/src/query-controls/index.native.js +1 -0
  191. package/src/query-controls/index.tsx +1 -0
  192. package/src/range-control/index.tsx +14 -2
  193. package/src/range-control/input-range.tsx +0 -1
  194. package/src/range-control/styles/range-control-styles.ts +12 -3
  195. package/src/range-control/types.ts +6 -0
  196. package/src/select-control/index.tsx +1 -0
  197. package/src/select-control/types.ts +6 -0
  198. package/src/text-control/index.tsx +2 -2
  199. package/src/text-control/test/text-control.tsx +61 -0
  200. package/src/toolbar/toolbar-group/style.native.scss +2 -3
  201. package/src/toolbar/toolbar-group/toolbar-group-container.native.js +12 -17
  202. package/src/tooltip/README.md +1 -1
  203. package/src/unit-control/index.tsx +3 -2
  204. package/src/unit-control/test/index.tsx +5 -2
  205. package/src/z-stack/component.tsx +4 -2
  206. package/src/z-stack/stories/index.tsx +6 -13
  207. package/src/z-stack/styles.ts +23 -24
  208. package/tsconfig.tsbuildinfo +1 -1
@@ -39,20 +39,25 @@ Default.args = {
39
39
  children: (
40
40
  [
41
41
  {
42
- children: 'First item',
42
+ children: 'First button item',
43
43
  // eslint-disable-next-line no-alert
44
44
  onClick: () => alert( 'First item clicked' ),
45
45
  },
46
46
  {
47
- children: 'Second item',
47
+ children: 'Second button item',
48
48
  // eslint-disable-next-line no-alert
49
49
  onClick: () => alert( 'Second item clicked' ),
50
50
  },
51
51
  {
52
- children: 'Third item',
52
+ children: 'Third button item',
53
53
  // eslint-disable-next-line no-alert
54
54
  onClick: () => alert( 'Third item clicked' ),
55
55
  },
56
+ {
57
+ children: 'Anchor item',
58
+ as: 'a',
59
+ href: 'https://wordpress.org',
60
+ },
56
61
  ] as ItemProps[]
57
62
  ).map( mapPropsToItem ),
58
63
  };
@@ -6,34 +6,45 @@ import { css } from '@emotion/react';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
- import { CONFIG, COLORS } from '../utils';
10
-
11
- export const unstyledButton = css`
12
- appearance: none;
13
- border: 1px solid transparent;
14
- cursor: pointer;
15
- background: none;
16
- text-align: start;
17
-
18
- svg,
19
- path {
20
- fill: currentColor;
21
- }
22
-
23
- &:hover {
24
- color: ${ COLORS.ui.theme };
25
- }
26
-
27
- &:focus {
28
- box-shadow: 0 0 0 var( --wp-admin-border-width-focus )
29
- var(
30
- --wp-components-color-accent,
31
- var( --wp-admin-theme-color, ${ COLORS.ui.theme } )
32
- );
33
- // Windows high contrast mode.
34
- outline: 2px solid transparent;
35
- }
36
- `;
9
+ import { CONFIG, COLORS, font } from '../utils';
10
+
11
+ export const unstyledButton = ( as: 'a' | 'button' ) => {
12
+ return css`
13
+ font-size: ${ font( 'default.fontSize' ) };
14
+ font-family: inherit;
15
+ appearance: none;
16
+ border: 1px solid transparent;
17
+ cursor: pointer;
18
+ background: none;
19
+ text-align: start;
20
+ text-decoration: ${ as === 'a' ? 'none' : undefined };
21
+
22
+ svg,
23
+ path {
24
+ fill: currentColor;
25
+ }
26
+
27
+ &:hover {
28
+ color: ${ COLORS.ui.theme };
29
+ }
30
+
31
+ &:focus {
32
+ box-shadow: none;
33
+ outline: none;
34
+ }
35
+
36
+ &:focus-visible {
37
+ box-shadow: 0 0 0 var( --wp-admin-border-width-focus )
38
+ var(
39
+ --wp-components-color-accent,
40
+ var( --wp-admin-theme-color, ${ COLORS.ui.theme } )
41
+ );
42
+ // Windows high contrast mode.
43
+ outline: 2px solid transparent;
44
+ outline-offset: 0;
45
+ }
46
+ `;
47
+ };
37
48
 
38
49
  export const itemWrapper = css`
39
50
  width: 100%;
@@ -431,6 +431,7 @@ class BottomSheetCell extends Component {
431
431
  <Icon
432
432
  icon={ check }
433
433
  fill={ platformStyles.isSelected.color }
434
+ testID="bottom-sheet-cell-selected-icon"
434
435
  />
435
436
  ) }
436
437
  { showValue && getValueComponent() }
@@ -185,6 +185,13 @@ const ImageComponent = ( {
185
185
  imageHeight && { height: imageHeight },
186
186
  shapeStyle,
187
187
  ];
188
+ const imageSelectedStyles = [
189
+ usePreferredColorSchemeStyle(
190
+ styles.imageBorder,
191
+ styles.imageBorderDark
192
+ ),
193
+ { height: containerSize?.height },
194
+ ];
188
195
 
189
196
  return (
190
197
  <View
@@ -210,12 +217,7 @@ const ImageComponent = ( {
210
217
  { isSelected &&
211
218
  highlightSelected &&
212
219
  ! ( isUploadInProgress || isUploadFailed ) && (
213
- <View
214
- style={ [
215
- styles.imageBorder,
216
- { height: containerSize?.height },
217
- ] }
218
- />
220
+ <View style={ imageSelectedStyles } />
219
221
  ) }
220
222
 
221
223
  { ! imageData ? (
@@ -7,7 +7,7 @@
7
7
  }
8
8
 
9
9
  .imageBorder {
10
- border-color: $blue-medium;
10
+ border-color: $blue-40;
11
11
  border-width: 2px;
12
12
  border-style: solid;
13
13
  position: absolute;
@@ -16,6 +16,10 @@
16
16
  height: 100%;
17
17
  }
18
18
 
19
+ .imageBorderDark {
20
+ border-color: $blue-50;
21
+ }
22
+
19
23
  .retryIcon {
20
24
  width: 80px;
21
25
  height: 80px;
@@ -72,7 +72,7 @@
72
72
  .components-modal__header {
73
73
  box-sizing: border-box;
74
74
  border-bottom: $border-width solid transparent;
75
- padding: $grid-unit-30 $grid-unit-40 $grid-unit-15;
75
+ padding: $grid-unit-30 $grid-unit-40 $grid-unit-10;
76
76
  display: flex;
77
77
  flex-direction: row;
78
78
  justify-content: space-between;
@@ -130,7 +130,8 @@
130
130
  .components-modal__content {
131
131
  flex: 1;
132
132
  margin-top: $header-height + $grid-unit-15;
133
- padding: 0 $grid-unit-40 $grid-unit-40;
133
+ // Small top padding required to avoid cutting off the visible outline when the first child element is focusable.
134
+ padding: $grid-unit-05 $grid-unit-40 $grid-unit-40;
134
135
  overflow: auto;
135
136
 
136
137
  &.hide-header {
@@ -148,6 +148,7 @@ function UnconnectedNavigatorProvider(
148
148
  focusTargetSelector,
149
149
  isBack = false,
150
150
  skipFocus = false,
151
+ replace = false,
151
152
  ...restOptions
152
153
  } = options;
153
154
 
@@ -172,34 +173,38 @@ function UnconnectedNavigatorProvider(
172
173
  skipFocus,
173
174
  };
174
175
 
175
- if ( prevLocationHistory.length < 1 ) {
176
- return [ newLocation ];
176
+ if ( prevLocationHistory.length === 0 ) {
177
+ return replace ? [] : [ newLocation ];
177
178
  }
178
179
 
179
- return [
180
- ...prevLocationHistory.slice(
181
- prevLocationHistory.length > MAX_HISTORY_LENGTH - 1
182
- ? 1
183
- : 0,
184
- -1
185
- ),
186
- // Assign `focusTargetSelector` to the previous location in history
187
- // (the one we just navigated from).
188
- {
189
- ...prevLocationHistory[
190
- prevLocationHistory.length - 1
191
- ],
192
- focusTargetSelector,
193
- },
194
- newLocation,
195
- ];
180
+ const newLocationHistory = prevLocationHistory.slice(
181
+ prevLocationHistory.length > MAX_HISTORY_LENGTH - 1 ? 1 : 0,
182
+ -1
183
+ );
184
+
185
+ if ( ! replace ) {
186
+ newLocationHistory.push(
187
+ // Assign `focusTargetSelector` to the previous location in history
188
+ // (the one we just navigated from).
189
+ {
190
+ ...prevLocationHistory[
191
+ prevLocationHistory.length - 1
192
+ ],
193
+ focusTargetSelector,
194
+ }
195
+ );
196
+ }
197
+
198
+ newLocationHistory.push( newLocation );
199
+
200
+ return newLocationHistory;
196
201
  } );
197
202
  },
198
203
  [ goBack ]
199
204
  );
200
205
 
201
- const goToParent: NavigatorContextType[ 'goToParent' ] =
202
- useCallback( () => {
206
+ const goToParent: NavigatorContextType[ 'goToParent' ] = useCallback(
207
+ ( options = {} ) => {
203
208
  const currentPath =
204
209
  currentLocationHistory.current[
205
210
  currentLocationHistory.current.length - 1
@@ -214,8 +219,10 @@ function UnconnectedNavigatorProvider(
214
219
  if ( parentPath === undefined ) {
215
220
  return;
216
221
  }
217
- goTo( parentPath, { isBack: true } );
218
- }, [ goTo ] );
222
+ goTo( parentPath, { ...options, isBack: true } );
223
+ },
224
+ [ goTo ]
225
+ );
219
226
 
220
227
  const navigatorContextValue: NavigatorContextType = useMemo(
221
228
  () => ( {
@@ -14,8 +14,11 @@ export type NavigateOptions = {
14
14
  focusTargetSelector?: string;
15
15
  isBack?: boolean;
16
16
  skipFocus?: boolean;
17
+ replace?: boolean;
17
18
  };
18
19
 
20
+ export type NavigateToParentOptions = Omit< NavigateOptions, 'isBack' >;
21
+
19
22
  export type NavigatorLocation = NavigateOptions & {
20
23
  isInitial?: boolean;
21
24
  path?: string;
@@ -28,7 +31,7 @@ export type Navigator = {
28
31
  params: MatchParams;
29
32
  goTo: ( path: string, options?: NavigateOptions ) => void;
30
33
  goBack: () => void;
31
- goToParent: () => void;
34
+ goToParent: ( options?: NavigateToParentOptions ) => void;
32
35
  };
33
36
 
34
37
  export type NavigatorContext = Navigator & {
@@ -16,7 +16,7 @@ import deprecated from '@wordpress/deprecated';
16
16
  /**
17
17
  * Internal dependencies
18
18
  */
19
- import { Input, SpinButton } from './styles/number-control-styles';
19
+ import { Input, SpinButton, styles } from './styles/number-control-styles';
20
20
  import * as inputControlActionTypes from '../input-control/reducer/actions';
21
21
  import { add, subtract, roundClamp } from '../utils/math';
22
22
  import { ensureNumber, isValueEmpty } from '../utils/values';
@@ -24,6 +24,7 @@ import type { WordPressComponentProps } from '../ui/context/wordpress-component'
24
24
  import type { NumberControlProps } from './types';
25
25
  import { HStack } from '../h-stack';
26
26
  import { Spacer } from '../spacer';
27
+ import { useCx } from '../utils';
27
28
 
28
29
  const noop = () => {};
29
30
 
@@ -59,7 +60,6 @@ function UnforwardedNumberControl(
59
60
  } );
60
61
  spinControls = 'none';
61
62
  }
62
-
63
63
  const inputRef = useRef< HTMLInputElement >();
64
64
  const mergedRef = useMergeRefs( [ inputRef, forwardedRef ] );
65
65
 
@@ -78,6 +78,8 @@ function UnforwardedNumberControl(
78
78
 
79
79
  const autoComplete = typeProp === 'number' ? 'off' : undefined;
80
80
  const classes = classNames( 'components-number-control', className );
81
+ const cx = useCx();
82
+ const spinButtonClasses = cx( size === 'small' && styles.smallSpinButtons );
81
83
 
82
84
  const spinValue = (
83
85
  value: string | number | undefined,
@@ -236,6 +238,7 @@ function UnforwardedNumberControl(
236
238
  <Spacer marginBottom={ 0 } marginRight={ 2 }>
237
239
  <HStack spacing={ 1 }>
238
240
  <SpinButton
241
+ className={ spinButtonClasses }
239
242
  icon={ plusIcon }
240
243
  isSmall
241
244
  aria-hidden="true"
@@ -244,9 +247,9 @@ function UnforwardedNumberControl(
244
247
  onClick={ buildSpinButtonClickHandler(
245
248
  'up'
246
249
  ) }
247
- size={ size }
248
250
  />
249
251
  <SpinButton
252
+ className={ spinButtonClasses }
250
253
  icon={ resetIcon }
251
254
  isSmall
252
255
  aria-hidden="true"
@@ -255,7 +258,6 @@ function UnforwardedNumberControl(
255
258
  onClick={ buildSpinButtonClickHandler(
256
259
  'down'
257
260
  ) }
258
- size={ size }
259
261
  />
260
262
  </HStack>
261
263
  </Spacer>
@@ -11,7 +11,6 @@ import InputControl from '../../input-control';
11
11
  import { COLORS } from '../../utils';
12
12
  import Button from '../../button';
13
13
  import { space } from '../../ui/utils/space';
14
- import type { NumberControlProps } from '../types';
15
14
 
16
15
  const htmlArrowStyles = ( { hideHTMLArrows }: { hideHTMLArrows: boolean } ) => {
17
16
  if ( ! hideHTMLArrows ) {
@@ -35,23 +34,16 @@ export const Input = styled( InputControl )`
35
34
  ${ htmlArrowStyles };
36
35
  `;
37
36
 
38
- const spinButtonSizeStyles = ( {
39
- size,
40
- }: Pick< NumberControlProps, 'size' > ) => {
41
- if ( size !== 'small' ) {
42
- return ``;
43
- }
44
-
45
- return css`
46
- width: ${ space( 5 ) };
47
- min-width: ${ space( 5 ) };
48
- height: ${ space( 5 ) };
49
- `;
50
- };
51
-
52
37
  export const SpinButton = styled( Button )`
53
38
  &&&&& {
54
39
  color: ${ COLORS.ui.theme };
55
- ${ spinButtonSizeStyles }
56
40
  }
57
41
  `;
42
+
43
+ const smallSpinButtons = css`
44
+ width: ${ space( 5 ) };
45
+ min-width: ${ space( 5 ) };
46
+ height: ${ space( 5 ) };
47
+ `;
48
+
49
+ export const styles = { smallSpinButtons };
@@ -161,6 +161,11 @@
161
161
  padding: 0 $grid-unit-10 2px;
162
162
  }
163
163
  }
164
+ .components-placeholder__learn-more {
165
+ .components-external-link {
166
+ color: var(--wp-admin-theme-color);
167
+ }
168
+ }
164
169
  }
165
170
 
166
171
 
@@ -84,6 +84,7 @@ const QueryControls = memo(
84
84
  ) }
85
85
  { onNumberOfItemsChange && (
86
86
  <RangeControl
87
+ __next40pxDefaultSize
87
88
  label={ __( 'Number of items' ) }
88
89
  value={ numberOfItems }
89
90
  onChange={ onNumberOfItemsChange }
@@ -177,6 +177,7 @@ export function QueryControls( {
177
177
  onNumberOfItemsChange && (
178
178
  <RangeControl
179
179
  __nextHasNoMarginBottom
180
+ __next40pxDefaultSize
180
181
  key="query-controls-range-control"
181
182
  label={ __( 'Number of items' ) }
182
183
  value={ numberOfItems }
@@ -37,6 +37,7 @@ import {
37
37
 
38
38
  import type { RangeControlProps } from './types';
39
39
  import type { WordPressComponentProps } from '../ui/context';
40
+ import { space } from '../ui/utils/space';
40
41
 
41
42
  const noop = () => {};
42
43
 
@@ -69,6 +70,7 @@ function UnforwardedRangeControl(
69
70
  railColor,
70
71
  renderTooltipContent = ( v ) => v,
71
72
  resetFallbackValue,
73
+ __next40pxDefaultSize = false,
72
74
  shiftStep = 10,
73
75
  showTooltip: showTooltipProp,
74
76
  step = 1,
@@ -208,7 +210,6 @@ function UnforwardedRangeControl(
208
210
  const offsetStyle = {
209
211
  [ isRTL() ? 'right' : 'left' ]: fillValueOffset,
210
212
  };
211
-
212
213
  return (
213
214
  <BaseControl
214
215
  __nextHasNoMarginBottom={ __nextHasNoMarginBottom }
@@ -218,7 +219,10 @@ function UnforwardedRangeControl(
218
219
  id={ `${ id }` }
219
220
  help={ help }
220
221
  >
221
- <Root className="components-range-control__root">
222
+ <Root
223
+ className="components-range-control__root"
224
+ __next40pxDefaultSize={ __next40pxDefaultSize }
225
+ >
222
226
  { beforeIcon && (
223
227
  <BeforeIconWrapper>
224
228
  <Icon icon={ beforeIcon } />
@@ -305,6 +309,14 @@ function UnforwardedRangeControl(
305
309
  onBlur={ handleOnInputNumberBlur }
306
310
  onChange={ handleOnChange }
307
311
  shiftStep={ shiftStep }
312
+ size={
313
+ __next40pxDefaultSize
314
+ ? '__unstable-large'
315
+ : 'default'
316
+ }
317
+ __unstableInputWidth={
318
+ __next40pxDefaultSize ? space( 20 ) : space( 16 )
319
+ }
308
320
  step={ step }
309
321
  // @ts-expect-error TODO: Investigate if the `null` value is necessary
310
322
  value={ inputSliderValue }
@@ -16,7 +16,6 @@ function InputRange(
16
16
  ref: React.ForwardedRef< HTMLInputElement >
17
17
  ) {
18
18
  const { describedBy, label, value, ...otherProps } = props;
19
-
20
19
  return (
21
20
  <BaseInputRange
22
21
  { ...otherProps }
@@ -18,6 +18,7 @@ import type {
18
18
  TooltipProps,
19
19
  TrackProps,
20
20
  WrapperProps,
21
+ RangeControlProps,
21
22
  } from '../types';
22
23
 
23
24
  const rangeHeightValue = 30;
@@ -26,15 +27,24 @@ const rangeHeight = () =>
26
27
  css( { height: rangeHeightValue, minHeight: rangeHeightValue } );
27
28
  const thumbSize = 12;
28
29
 
29
- export const Root = styled.div`
30
+ const deprecatedHeight = ( {
31
+ __next40pxDefaultSize,
32
+ }: Pick< RangeControlProps, '__next40pxDefaultSize' > ) =>
33
+ ! __next40pxDefaultSize && css( { minHeight: rangeHeightValue } );
34
+
35
+ type RootProps = Pick< RangeControlProps, '__next40pxDefaultSize' >;
36
+ export const Root = styled.div< RootProps >`
30
37
  -webkit-tap-highlight-color: transparent;
31
- align-items: flex-start;
38
+ align-items: center;
32
39
  display: flex;
33
40
  justify-content: flex-start;
34
41
  padding: 0;
35
42
  position: relative;
36
43
  touch-action: none;
37
44
  width: 100%;
45
+ min-height: 40px;
46
+ /* TODO: remove after removing the __next40pxDefaultSize prop */
47
+ ${ deprecatedHeight };
38
48
  `;
39
49
 
40
50
  const wrapperColor = ( { color = COLORS.ui.borderFocus }: WrapperProps ) =>
@@ -296,7 +306,6 @@ export const InputNumber = styled( NumberControl )`
296
306
  display: inline-block;
297
307
  font-size: 13px;
298
308
  margin-top: 0;
299
- width: ${ space( 16 ) } !important;
300
309
 
301
310
  input[type='number']& {
302
311
  ${ rangeHeight };
@@ -203,6 +203,12 @@ export type RangeControlProps = Pick<
203
203
  * @default 10
204
204
  */
205
205
  shiftStep?: number;
206
+ /**
207
+ * Start opting into the larger default height that will become the default size in a future version.
208
+ *
209
+ * @default false
210
+ */
211
+ __next40pxDefaultSize?: boolean;
206
212
  /**
207
213
  * Forcing the Tooltip UI to show or hide. This is overridden to `false`
208
214
  * when `step` is set to the special string value `any`.
@@ -135,6 +135,7 @@ function UnforwardedSelectControl(
135
135
  key={ key }
136
136
  value={ option.value }
137
137
  disabled={ option.disabled }
138
+ hidden={ option.hidden }
138
139
  >
139
140
  { option.label }
140
141
  </option>
@@ -40,6 +40,12 @@ type SelectControlBaseProps = Pick<
40
40
  * @default false
41
41
  */
42
42
  disabled?: boolean;
43
+ /**
44
+ * Whether or not the option should be hidden.
45
+ *
46
+ * @default false
47
+ */
48
+ hidden?: boolean;
43
49
  }[];
44
50
  /**
45
51
  * As an alternative to the `options` prop, `optgroup`s and `options` can be
@@ -26,13 +26,13 @@ function UnforwardedTextControl(
26
26
  hideLabelFromVision,
27
27
  value,
28
28
  help,
29
+ id: idProp,
29
30
  className,
30
31
  onChange,
31
32
  type = 'text',
32
33
  ...additionalProps
33
34
  } = props;
34
- const instanceId = useInstanceId( TextControl );
35
- const id = `inspector-text-control-${ instanceId }`;
35
+ const id = useInstanceId( TextControl, 'inspector-text-control', idProp );
36
36
  const onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) =>
37
37
  onChange( event.target.value );
38
38
 
@@ -0,0 +1,61 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { render, screen } from '@testing-library/react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import TextControl from '..';
10
+
11
+ const noop = () => {};
12
+
13
+ describe( 'TextControl', () => {
14
+ describe( 'When no ID prop is provided', () => {
15
+ it( 'should generate an ID', () => {
16
+ render( <TextControl onChange={ noop } value="" /> );
17
+
18
+ expect( screen.getByRole( 'textbox' ) ).toHaveAttribute(
19
+ 'id',
20
+ expect.stringMatching( /^inspector-text-control-/ )
21
+ );
22
+ } );
23
+
24
+ it( 'should be labelled correctly', () => {
25
+ const labelValue = 'Test Label';
26
+ render(
27
+ <TextControl label={ labelValue } onChange={ noop } value="" />
28
+ );
29
+
30
+ expect(
31
+ screen.getByRole( 'textbox', { name: labelValue } )
32
+ ).toBeVisible();
33
+ } );
34
+ } );
35
+
36
+ describe( 'When an ID prop is provided', () => {
37
+ const id = 'test-id';
38
+
39
+ it( 'should use the passed ID prop if provided', () => {
40
+ render( <TextControl id={ id } onChange={ noop } value="" /> );
41
+
42
+ expect( screen.getByRole( 'textbox' ) ).toHaveAttribute( 'id', id );
43
+ } );
44
+
45
+ it( 'should be labelled correctly', () => {
46
+ const labelValue = 'Test Label';
47
+ render(
48
+ <TextControl
49
+ label={ labelValue }
50
+ id={ id }
51
+ onChange={ noop }
52
+ value=""
53
+ />
54
+ );
55
+
56
+ expect(
57
+ screen.getByRole( 'textbox', { name: labelValue } )
58
+ ).toBeVisible();
59
+ } );
60
+ } );
61
+ } );
@@ -1,11 +1,10 @@
1
1
  .container {
2
2
  flex-direction: row;
3
- border-left-width: 1px;
4
- border-color: #e9eff3;
3
+ border-color: $light-quaternary;
5
4
  padding-left: 5px;
6
5
  padding-right: 5px;
7
6
  }
8
7
 
9
8
  .containerDark {
10
- border-color: #525354;
9
+ border-color: $dark-quaternary;
11
10
  }