@wordpress/components 30.9.0 → 31.0.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 (233) hide show
  1. package/CHANGELOG.md +26 -4
  2. package/build/alignment-matrix-control/cell.js +131 -3
  3. package/build/alignment-matrix-control/cell.js.map +4 -4
  4. package/build/alignment-matrix-control/index.js +134 -6
  5. package/build/alignment-matrix-control/index.js.map +3 -3
  6. package/build/angle-picker-control/angle-circle.js +119 -15
  7. package/build/angle-picker-control/angle-circle.js.map +4 -4
  8. package/build/angle-picker-control/index.js +12 -7
  9. package/build/angle-picker-control/index.js.map +3 -3
  10. package/build/dropdown-menu/index.js +1 -1
  11. package/build/dropdown-menu/index.js.map +2 -2
  12. package/build/form-token-field/index.js +1 -13
  13. package/build/form-token-field/index.js.map +3 -3
  14. package/build/menu/styles.js +17 -17
  15. package/build/menu/styles.js.map +2 -2
  16. package/build/menu-item/index.js +1 -1
  17. package/build/menu-item/index.js.map +2 -2
  18. package/build/notice/index.js +1 -1
  19. package/build/notice/index.js.map +2 -2
  20. package/build/query-controls/index.js +0 -1
  21. package/build/query-controls/index.js.map +2 -2
  22. package/build/snackbar/index.js +1 -1
  23. package/build/snackbar/index.js.map +1 -1
  24. package/build/validated-form-controls/components/checkbox-control.js +0 -10
  25. package/build/validated-form-controls/components/checkbox-control.js.map +2 -2
  26. package/build/validated-form-controls/components/combobox-control.js +1 -11
  27. package/build/validated-form-controls/components/combobox-control.js.map +2 -2
  28. package/build/validated-form-controls/components/custom-select-control.js +0 -10
  29. package/build/validated-form-controls/components/custom-select-control.js.map +2 -2
  30. package/build/validated-form-controls/components/form-token-field.js +2 -13
  31. package/build/validated-form-controls/components/form-token-field.js.map +2 -2
  32. package/build/validated-form-controls/components/input-control.js +0 -10
  33. package/build/validated-form-controls/components/input-control.js.map +2 -2
  34. package/build/validated-form-controls/components/number-control.js +0 -10
  35. package/build/validated-form-controls/components/number-control.js.map +2 -2
  36. package/build/validated-form-controls/components/radio-control.js +0 -10
  37. package/build/validated-form-controls/components/radio-control.js.map +2 -2
  38. package/build/validated-form-controls/components/range-control.js +0 -10
  39. package/build/validated-form-controls/components/range-control.js.map +2 -2
  40. package/build/validated-form-controls/components/select-control.js +0 -10
  41. package/build/validated-form-controls/components/select-control.js.map +2 -2
  42. package/build/validated-form-controls/components/text-control.js +0 -10
  43. package/build/validated-form-controls/components/text-control.js.map +2 -2
  44. package/build/validated-form-controls/components/textarea-control.js +0 -10
  45. package/build/validated-form-controls/components/textarea-control.js.map +2 -2
  46. package/build/validated-form-controls/components/toggle-control.js +0 -10
  47. package/build/validated-form-controls/components/toggle-control.js.map +2 -2
  48. package/build/validated-form-controls/components/toggle-group-control.js +0 -10
  49. package/build/validated-form-controls/components/toggle-group-control.js.map +2 -2
  50. package/build/validated-form-controls/control-with-error.js +53 -58
  51. package/build/validated-form-controls/control-with-error.js.map +2 -2
  52. package/build-module/alignment-matrix-control/cell.js +131 -3
  53. package/build-module/alignment-matrix-control/cell.js.map +3 -3
  54. package/build-module/alignment-matrix-control/index.js +134 -6
  55. package/build-module/alignment-matrix-control/index.js.map +3 -3
  56. package/build-module/angle-picker-control/angle-circle.js +109 -15
  57. package/build-module/angle-picker-control/angle-circle.js.map +3 -3
  58. package/build-module/angle-picker-control/index.js +12 -7
  59. package/build-module/angle-picker-control/index.js.map +2 -2
  60. package/build-module/dropdown-menu/index.js +1 -1
  61. package/build-module/dropdown-menu/index.js.map +2 -2
  62. package/build-module/form-token-field/index.js +1 -13
  63. package/build-module/form-token-field/index.js.map +2 -2
  64. package/build-module/menu/styles.js +17 -17
  65. package/build-module/menu/styles.js.map +2 -2
  66. package/build-module/menu-item/index.js +1 -1
  67. package/build-module/menu-item/index.js.map +2 -2
  68. package/build-module/notice/index.js +1 -1
  69. package/build-module/notice/index.js.map +2 -2
  70. package/build-module/query-controls/index.js +0 -1
  71. package/build-module/query-controls/index.js.map +2 -2
  72. package/build-module/snackbar/index.js +1 -1
  73. package/build-module/snackbar/index.js.map +1 -1
  74. package/build-module/validated-form-controls/components/checkbox-control.js +0 -10
  75. package/build-module/validated-form-controls/components/checkbox-control.js.map +2 -2
  76. package/build-module/validated-form-controls/components/combobox-control.js +1 -11
  77. package/build-module/validated-form-controls/components/combobox-control.js.map +2 -2
  78. package/build-module/validated-form-controls/components/custom-select-control.js +0 -10
  79. package/build-module/validated-form-controls/components/custom-select-control.js.map +2 -2
  80. package/build-module/validated-form-controls/components/form-token-field.js +2 -13
  81. package/build-module/validated-form-controls/components/form-token-field.js.map +2 -2
  82. package/build-module/validated-form-controls/components/input-control.js +0 -10
  83. package/build-module/validated-form-controls/components/input-control.js.map +2 -2
  84. package/build-module/validated-form-controls/components/number-control.js +0 -10
  85. package/build-module/validated-form-controls/components/number-control.js.map +2 -2
  86. package/build-module/validated-form-controls/components/radio-control.js +0 -10
  87. package/build-module/validated-form-controls/components/radio-control.js.map +2 -2
  88. package/build-module/validated-form-controls/components/range-control.js +0 -10
  89. package/build-module/validated-form-controls/components/range-control.js.map +2 -2
  90. package/build-module/validated-form-controls/components/select-control.js +0 -10
  91. package/build-module/validated-form-controls/components/select-control.js.map +2 -2
  92. package/build-module/validated-form-controls/components/text-control.js +0 -10
  93. package/build-module/validated-form-controls/components/text-control.js.map +2 -2
  94. package/build-module/validated-form-controls/components/textarea-control.js +0 -10
  95. package/build-module/validated-form-controls/components/textarea-control.js.map +2 -2
  96. package/build-module/validated-form-controls/components/toggle-control.js +0 -10
  97. package/build-module/validated-form-controls/components/toggle-control.js.map +2 -2
  98. package/build-module/validated-form-controls/components/toggle-group-control.js +0 -10
  99. package/build-module/validated-form-controls/components/toggle-group-control.js.map +2 -2
  100. package/build-module/validated-form-controls/control-with-error.js +53 -58
  101. package/build-module/validated-form-controls/control-with-error.js.map +2 -2
  102. package/build-style/style-rtl.css +21 -33
  103. package/build-style/style.css +21 -33
  104. package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
  105. package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
  106. package/build-types/angle-picker-control/angle-circle.d.ts +1 -1
  107. package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
  108. package/build-types/angle-picker-control/index.d.ts.map +1 -1
  109. package/build-types/form-token-field/index.d.ts.map +1 -1
  110. package/build-types/form-token-field/stories/index.story.d.ts.map +1 -1
  111. package/build-types/form-token-field/types.d.ts +0 -6
  112. package/build-types/form-token-field/types.d.ts.map +1 -1
  113. package/build-types/notice/index.d.ts.map +1 -1
  114. package/build-types/notice/stories/index.story.d.ts.map +1 -1
  115. package/build-types/query-controls/index.d.ts.map +1 -1
  116. package/build-types/validated-form-controls/components/checkbox-control.d.ts +1 -1
  117. package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -1
  118. package/build-types/validated-form-controls/components/combobox-control.d.ts +2 -3
  119. package/build-types/validated-form-controls/components/combobox-control.d.ts.map +1 -1
  120. package/build-types/validated-form-controls/components/custom-select-control.d.ts +1 -2
  121. package/build-types/validated-form-controls/components/custom-select-control.d.ts.map +1 -1
  122. package/build-types/validated-form-controls/components/form-token-field.d.ts +1 -2
  123. package/build-types/validated-form-controls/components/form-token-field.d.ts.map +1 -1
  124. package/build-types/validated-form-controls/components/input-control.d.ts +1 -2
  125. package/build-types/validated-form-controls/components/input-control.d.ts.map +1 -1
  126. package/build-types/validated-form-controls/components/number-control.d.ts +1 -1
  127. package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
  128. package/build-types/validated-form-controls/components/radio-control.d.ts +1 -1
  129. package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -1
  130. package/build-types/validated-form-controls/components/range-control.d.ts +1 -1
  131. package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
  132. package/build-types/validated-form-controls/components/select-control.d.ts +2 -3
  133. package/build-types/validated-form-controls/components/select-control.d.ts.map +1 -1
  134. package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts.map +1 -1
  135. package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts.map +1 -1
  136. package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts.map +1 -1
  137. package/build-types/validated-form-controls/components/stories/form-token-field.story.d.ts.map +1 -1
  138. package/build-types/validated-form-controls/components/stories/input-control.story.d.ts.map +1 -1
  139. package/build-types/validated-form-controls/components/stories/number-control.story.d.ts.map +1 -1
  140. package/build-types/validated-form-controls/components/stories/overview.story.d.ts +7 -0
  141. package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
  142. package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts.map +1 -1
  143. package/build-types/validated-form-controls/components/stories/range-control.story.d.ts.map +1 -1
  144. package/build-types/validated-form-controls/components/stories/select-control.story.d.ts.map +1 -1
  145. package/build-types/validated-form-controls/components/stories/text-control.story.d.ts.map +1 -1
  146. package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts.map +1 -1
  147. package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts.map +1 -1
  148. package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts.map +1 -1
  149. package/build-types/validated-form-controls/components/text-control.d.ts +1 -1
  150. package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -1
  151. package/build-types/validated-form-controls/components/textarea-control.d.ts +1 -1
  152. package/build-types/validated-form-controls/components/textarea-control.d.ts.map +1 -1
  153. package/build-types/validated-form-controls/components/toggle-control.d.ts +1 -1
  154. package/build-types/validated-form-controls/components/toggle-control.d.ts.map +1 -1
  155. package/build-types/validated-form-controls/components/toggle-group-control.d.ts +1 -1
  156. package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -1
  157. package/build-types/validated-form-controls/components/types.d.ts +1 -9
  158. package/build-types/validated-form-controls/components/types.d.ts.map +1 -1
  159. package/build-types/validated-form-controls/control-with-error.d.ts +4 -5
  160. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
  161. package/package.json +20 -20
  162. package/src/alignment-matrix-control/cell.tsx +14 -3
  163. package/src/alignment-matrix-control/index.tsx +15 -6
  164. package/src/alignment-matrix-control/style.module.scss +84 -0
  165. package/src/angle-picker-control/angle-circle.tsx +27 -12
  166. package/src/angle-picker-control/index.tsx +8 -7
  167. package/src/angle-picker-control/style.module.scss +40 -0
  168. package/src/button/style.scss +1 -1
  169. package/src/dropdown-menu/index.tsx +1 -1
  170. package/src/dropdown-menu/style.scss +1 -1
  171. package/src/form-token-field/README.md +0 -2
  172. package/src/form-token-field/index.tsx +1 -13
  173. package/src/form-token-field/stories/index.story.tsx +0 -2
  174. package/src/form-token-field/test/index.tsx +0 -1
  175. package/src/form-token-field/types.ts +0 -6
  176. package/src/guide/style.scss +3 -3
  177. package/src/menu/styles.ts +2 -2
  178. package/src/menu-item/index.tsx +1 -1
  179. package/src/menu-item/test/__snapshots__/index.js.snap +4 -4
  180. package/src/modal/style.scss +5 -5
  181. package/src/notice/index.tsx +53 -46
  182. package/src/notice/stories/index.story.tsx +17 -1
  183. package/src/notice/style.scss +3 -20
  184. package/src/query-controls/index.tsx +0 -1
  185. package/src/snackbar/index.tsx +1 -1
  186. package/src/validated-form-controls/components/checkbox-control.tsx +1 -14
  187. package/src/validated-form-controls/components/combobox-control.tsx +1 -14
  188. package/src/validated-form-controls/components/custom-select-control.tsx +1 -19
  189. package/src/validated-form-controls/components/form-token-field.tsx +4 -21
  190. package/src/validated-form-controls/components/input-control.tsx +1 -14
  191. package/src/validated-form-controls/components/number-control.tsx +1 -16
  192. package/src/validated-form-controls/components/radio-control.tsx +2 -18
  193. package/src/validated-form-controls/components/range-control.tsx +1 -14
  194. package/src/validated-form-controls/components/select-control.tsx +1 -23
  195. package/src/validated-form-controls/components/stories/checkbox-control.story.tsx +11 -20
  196. package/src/validated-form-controls/components/stories/combobox-control.story.tsx +8 -17
  197. package/src/validated-form-controls/components/stories/custom-select-control.story.tsx +8 -17
  198. package/src/validated-form-controls/components/stories/form-token-field.story.tsx +14 -26
  199. package/src/validated-form-controls/components/stories/input-control.story.tsx +25 -50
  200. package/src/validated-form-controls/components/stories/number-control.story.tsx +10 -19
  201. package/src/validated-form-controls/components/stories/overview.mdx +3 -3
  202. package/src/validated-form-controls/components/stories/overview.story.tsx +94 -79
  203. package/src/validated-form-controls/components/stories/radio-control.story.tsx +11 -20
  204. package/src/validated-form-controls/components/stories/range-control.story.tsx +8 -17
  205. package/src/validated-form-controls/components/stories/select-control.story.tsx +9 -18
  206. package/src/validated-form-controls/components/stories/text-control.story.tsx +11 -17
  207. package/src/validated-form-controls/components/stories/textarea-control.story.tsx +12 -16
  208. package/src/validated-form-controls/components/stories/toggle-control.story.tsx +11 -20
  209. package/src/validated-form-controls/components/stories/toggle-group-control.story.tsx +8 -17
  210. package/src/validated-form-controls/components/text-control.tsx +1 -14
  211. package/src/validated-form-controls/components/textarea-control.tsx +1 -14
  212. package/src/validated-form-controls/components/toggle-control.tsx +1 -14
  213. package/src/validated-form-controls/components/toggle-group-control.tsx +1 -14
  214. package/src/validated-form-controls/components/types.ts +1 -9
  215. package/src/validated-form-controls/control-with-error.tsx +57 -84
  216. package/src/validated-form-controls/style.scss +7 -7
  217. package/src/validated-form-controls/test/control-with-error.tsx +66 -5
  218. package/tsconfig.json +1 -0
  219. package/tsconfig.tsbuildinfo +1 -1
  220. package/build/alignment-matrix-control/styles.js +0 -105
  221. package/build/alignment-matrix-control/styles.js.map +0 -7
  222. package/build/angle-picker-control/styles/angle-picker-control-styles.js +0 -88
  223. package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +0 -7
  224. package/build-module/alignment-matrix-control/styles.js +0 -67
  225. package/build-module/alignment-matrix-control/styles.js.map +0 -7
  226. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +0 -50
  227. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +0 -7
  228. package/build-types/alignment-matrix-control/styles.d.ts +0 -21
  229. package/build-types/alignment-matrix-control/styles.d.ts.map +0 -1
  230. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +0 -18
  231. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +0 -1
  232. package/src/alignment-matrix-control/styles.ts +0 -113
  233. package/src/angle-picker-control/styles/angle-picker-control-styles.tsx +0 -58
@@ -12,7 +12,6 @@ import { __, _n, sprintf } from '@wordpress/i18n';
12
12
  import { useDebounce, useInstanceId, usePrevious } from '@wordpress/compose';
13
13
  import { speak } from '@wordpress/a11y';
14
14
  import isShallowEqual from '@wordpress/is-shallow-equal';
15
- import deprecated from '@wordpress/deprecated';
16
15
 
17
16
  /**
18
17
  * Internal dependencies
@@ -27,7 +26,6 @@ import {
27
26
  StyledHelp,
28
27
  StyledLabel,
29
28
  } from '../base-control/styles/base-control-styles';
30
- import { Spacer } from '../spacer';
31
29
  import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
32
30
  import { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';
33
31
  import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';
@@ -75,18 +73,9 @@ export function FormTokenField( props: FormTokenFieldProps ) {
75
73
  __experimentalShowHowTo = true,
76
74
  __next40pxDefaultSize = false,
77
75
  __experimentalAutoSelectFirstMatch = false,
78
- __nextHasNoMarginBottom = false,
79
76
  tokenizeOnBlur = false,
80
77
  } = useDeprecated36pxDefaultSizeProp< FormTokenFieldProps >( props );
81
78
 
82
- if ( ! __nextHasNoMarginBottom ) {
83
- deprecated( 'Bottom margin styles for wp.components.FormTokenField', {
84
- since: '6.7',
85
- version: '7.0',
86
- hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.',
87
- } );
88
- }
89
-
90
79
  maybeWarnDeprecated36pxSize( {
91
80
  componentName: 'FormTokenField',
92
81
  size: undefined,
@@ -760,12 +749,11 @@ export function FormTokenField( props: FormTokenFieldProps ) {
760
749
  />
761
750
  ) }
762
751
  </div>
763
- { ! __nextHasNoMarginBottom && <Spacer marginBottom={ 2 } /> }
764
752
  { __experimentalShowHowTo && (
765
753
  <StyledHelp
766
754
  id={ `components-form-token-suggestions-howto-${ instanceId }` }
767
755
  className="components-form-token-field__help"
768
- __nextHasNoMarginBottom={ __nextHasNoMarginBottom }
756
+ __nextHasNoMarginBottom
769
757
  >
770
758
  { tokenizeOnSpace
771
759
  ? __(
@@ -63,7 +63,6 @@ export const Default: StoryFn< typeof FormTokenField > = DefaultTemplate.bind(
63
63
  Default.args = {
64
64
  label: 'Type a continent',
65
65
  suggestions: continents,
66
- __nextHasNoMarginBottom: true,
67
66
  __next40pxDefaultSize: true,
68
67
  };
69
68
 
@@ -102,7 +101,6 @@ export const Async: StoryFn< typeof FormTokenField > = ( {
102
101
  Async.args = {
103
102
  label: 'Type a continent',
104
103
  suggestions: continents,
105
- __nextHasNoMarginBottom: true,
106
104
  __next40pxDefaultSize: true,
107
105
  };
108
106
 
@@ -48,7 +48,6 @@ const FormTokenFieldWithState = ( {
48
48
  setSelectedValue( tokens );
49
49
  onChange?.( tokens );
50
50
  } }
51
- __nextHasNoMarginBottom
52
51
  />
53
52
  );
54
53
  };
@@ -178,12 +178,6 @@ export interface FormTokenFieldProps
178
178
  * Custom renderer for suggestions.
179
179
  */
180
180
  __experimentalRenderItem?: ( args: { item: string } ) => ReactNode;
181
- /**
182
- * Start opting into the new margin-free styles that will become the default in a future version.
183
- *
184
- * @default false
185
- */
186
- __nextHasNoMarginBottom?: boolean;
187
181
  /**
188
182
  * If true, add any incompleteTokenValue as a new token when the field loses focus.
189
183
  *
@@ -59,7 +59,7 @@
59
59
  height: $button-size;
60
60
  justify-content: center;
61
61
  margin: 0 0 $grid-unit-30 0;
62
- padding: 0 $grid-unit-40;
62
+ padding: 0 $grid-unit-30;
63
63
  position: relative;
64
64
  width: 100%;
65
65
  }
@@ -103,11 +103,11 @@
103
103
  }
104
104
 
105
105
  &.components-guide__back-button {
106
- left: $grid-unit-40;
106
+ left: $grid-unit-30;
107
107
  }
108
108
 
109
109
  &.components-guide__forward-button,
110
110
  &.components-guide__finish-button {
111
- right: $grid-unit-40;
111
+ right: $grid-unit-30;
112
112
  }
113
113
  }
@@ -25,7 +25,7 @@ const ANIMATION_PARAMS = {
25
25
  };
26
26
 
27
27
  const CONTENT_WRAPPER_PADDING = space( 1 );
28
- const ITEM_PADDING_BLOCK = space( 2 );
28
+ const ITEM_PADDING_BLOCK = space( 1 );
29
29
  const ITEM_PADDING_INLINE = space( 3 );
30
30
 
31
31
  // TODO:
@@ -152,7 +152,7 @@ const baseItem = css`
152
152
  all: unset;
153
153
 
154
154
  position: relative;
155
- min-height: ${ space( 10 ) };
155
+ min-height: ${ space( 8 ) };
156
156
  box-sizing: border-box;
157
157
 
158
158
  /* Occupy the width of all grid columns (ie. full width) */
@@ -56,7 +56,7 @@ function UnforwardedMenuItem(
56
56
 
57
57
  return (
58
58
  <Button
59
- __next40pxDefaultSize
59
+ size="compact"
60
60
  ref={ ref }
61
61
  // Make sure aria-checked matches spec https://www.w3.org/TR/wai-aria-1.1/#aria-checked
62
62
  aria-checked={
@@ -3,7 +3,7 @@
3
3
  exports[`MenuItem should match snapshot when all props provided 1`] = `
4
4
  <button
5
5
  aria-checked="true"
6
- class="components-button components-menu-item__button my-class is-next-40px-default-size"
6
+ class="components-button components-menu-item__button my-class is-compact"
7
7
  role="menuitemcheckbox"
8
8
  type="button"
9
9
  >
@@ -35,7 +35,7 @@ exports[`MenuItem should match snapshot when all props provided 1`] = `
35
35
 
36
36
  exports[`MenuItem should match snapshot when info is provided 1`] = `
37
37
  <button
38
- class="components-button components-menu-item__button is-next-40px-default-size"
38
+ class="components-button components-menu-item__button is-compact"
39
39
  role="menuitem"
40
40
  type="button"
41
41
  >
@@ -62,7 +62,7 @@ exports[`MenuItem should match snapshot when info is provided 1`] = `
62
62
 
63
63
  exports[`MenuItem should match snapshot when isSelected and role are optionally provided 1`] = `
64
64
  <button
65
- class="components-button components-menu-item__button my-class is-next-40px-default-size"
65
+ class="components-button components-menu-item__button my-class is-compact"
66
66
  role="menuitem"
67
67
  type="button"
68
68
  >
@@ -94,7 +94,7 @@ exports[`MenuItem should match snapshot when isSelected and role are optionally
94
94
 
95
95
  exports[`MenuItem should match snapshot when only label provided 1`] = `
96
96
  <button
97
- class="components-button components-menu-item__button is-next-40px-default-size"
97
+ class="components-button components-menu-item__button is-compact"
98
98
  role="menuitem"
99
99
  type="button"
100
100
  >
@@ -109,10 +109,10 @@
109
109
 
110
110
  &.is-full-screen {
111
111
  // When full screen, make sure the children container is full height.
112
- .components-modal__content {
112
+ :where(.components-modal__content) {
113
113
  display: flex;
114
114
  // If this container is scrollable, bottom padding won't apply so we use margin instead.
115
- margin-bottom: $grid-unit-40;
115
+ margin-bottom: $grid-unit-30;
116
116
  padding-bottom: 0;
117
117
 
118
118
  > :last-child {
@@ -152,7 +152,7 @@
152
152
  .components-modal__header {
153
153
  box-sizing: border-box;
154
154
  border-bottom: $border-width solid transparent;
155
- padding: $grid-unit-30 $grid-unit-40 $grid-unit-10;
155
+ padding: $grid-unit-30;
156
156
  display: flex;
157
157
  flex-direction: row;
158
158
  justify-content: space-between;
@@ -206,12 +206,12 @@
206
206
  flex: 1;
207
207
  margin-top: $header-height + $grid-unit-10;
208
208
  // Small top padding required to avoid cutting off the visible outline when the first child element is focusable.
209
- padding: $grid-unit-05 $grid-unit-40 $grid-unit-40;
209
+ padding: $grid-unit-05 $grid-unit-30 $grid-unit-30;
210
210
  overflow: auto;
211
211
 
212
212
  &.hide-header {
213
213
  margin-top: 0;
214
- padding-top: $grid-unit-40;
214
+ padding-top: $grid-unit-30;
215
215
  }
216
216
 
217
217
  &.is-scrollable:focus-visible {
@@ -111,53 +111,60 @@ function Notice( {
111
111
  <VisuallyHidden>{ getStatusLabel( status ) }</VisuallyHidden>
112
112
  <div className="components-notice__content">
113
113
  { children }
114
- <div className="components-notice__actions">
115
- { actions.map(
116
- (
117
- {
118
- className: buttonCustomClasses,
119
- label,
120
- isPrimary,
121
- variant,
122
- noDefaultClasses = false,
123
- onClick,
124
- url,
125
- }: NoticeAction &
126
- // `isPrimary` is a legacy prop included for
127
- // backcompat, but `variant` should be used
128
- // instead.
129
- Pick< DeprecatedButtonProps, 'isPrimary' >,
130
- index
131
- ) => {
132
- let computedVariant = variant;
133
- if ( variant !== 'primary' && ! noDefaultClasses ) {
134
- computedVariant = ! url ? 'secondary' : 'link';
135
- }
136
- if (
137
- typeof computedVariant === 'undefined' &&
138
- isPrimary
139
- ) {
140
- computedVariant = 'primary';
141
- }
114
+ { actions.length > 0 && (
115
+ <div className="components-notice__actions">
116
+ { actions.map(
117
+ (
118
+ {
119
+ className: buttonCustomClasses,
120
+ label,
121
+ isPrimary,
122
+ variant,
123
+ noDefaultClasses = false,
124
+ onClick,
125
+ url,
126
+ }: NoticeAction &
127
+ // `isPrimary` is a legacy prop included for
128
+ // backcompat, but `variant` should be used
129
+ // instead.
130
+ Pick< DeprecatedButtonProps, 'isPrimary' >,
131
+ index
132
+ ) => {
133
+ let computedVariant = variant;
134
+ if (
135
+ variant !== 'primary' &&
136
+ ! noDefaultClasses
137
+ ) {
138
+ computedVariant = ! url
139
+ ? 'secondary'
140
+ : 'link';
141
+ }
142
+ if (
143
+ typeof computedVariant === 'undefined' &&
144
+ isPrimary
145
+ ) {
146
+ computedVariant = 'primary';
147
+ }
142
148
 
143
- return (
144
- <Button
145
- __next40pxDefaultSize
146
- key={ index }
147
- href={ url }
148
- variant={ computedVariant }
149
- onClick={ url ? undefined : onClick }
150
- className={ clsx(
151
- 'components-notice__action',
152
- buttonCustomClasses
153
- ) }
154
- >
155
- { label }
156
- </Button>
157
- );
158
- }
159
- ) }
160
- </div>
149
+ return (
150
+ <Button
151
+ __next40pxDefaultSize
152
+ key={ index }
153
+ href={ url }
154
+ variant={ computedVariant }
155
+ onClick={ url ? undefined : onClick }
156
+ className={ clsx(
157
+ 'components-notice__action',
158
+ buttonCustomClasses
159
+ ) }
160
+ >
161
+ { label }
162
+ </Button>
163
+ );
164
+ }
165
+ ) }
166
+ </div>
167
+ ) }
161
168
  </div>
162
169
  { isDismissible && (
163
170
  <Button
@@ -89,7 +89,7 @@ WithActions.args = {
89
89
  };
90
90
 
91
91
  export const NoticeListSubcomponent: StoryFn< typeof NoticeList > = () => {
92
- const exampleNotices = [
92
+ const exampleNotices: NoticeListProps[ 'notices' ] = [
93
93
  {
94
94
  id: 'second-notice',
95
95
  content: 'second notice content',
@@ -97,6 +97,22 @@ export const NoticeListSubcomponent: StoryFn< typeof NoticeList > = () => {
97
97
  {
98
98
  id: 'first-notice',
99
99
  content: 'first notice content',
100
+ actions: [
101
+ {
102
+ label: 'Click me!',
103
+ onClick: () => {},
104
+ variant: 'primary',
105
+ },
106
+ {
107
+ label: 'Or click me instead!',
108
+ onClick: () => {},
109
+ },
110
+ {
111
+ label: 'Or visit a link for more info',
112
+ url: 'https://wordpress.org',
113
+ variant: 'link',
114
+ },
115
+ ],
100
116
  },
101
117
  ];
102
118
  const [ notices, setNotices ] = useState( exampleNotices );
@@ -41,20 +41,9 @@
41
41
  .components-notice__actions {
42
42
  display: flex;
43
43
  flex-wrap: wrap;
44
- }
45
-
46
- .components-notice__action.components-button {
47
- &,
48
- &.is-link {
49
- margin-left: $grid-unit-15;
50
- }
51
- &.is-secondary {
52
- vertical-align: initial;
53
- }
54
-
55
- // When it has better support, this can be replaced
56
- // with column-gap since these are flex items.
57
- margin-right: $grid-unit-10;
44
+ align-items: center;
45
+ gap: $grid-unit-15;
46
+ margin-top: $grid-unit-15;
58
47
  }
59
48
 
60
49
  .components-notice__dismiss {
@@ -86,10 +75,4 @@
86
75
  margin-bottom: $grid-unit-15;
87
76
  line-height: 2;
88
77
  }
89
-
90
- .components-notice__action.components-button {
91
- display: block;
92
- margin-left: 0;
93
- margin-top: $grid-unit-10;
94
- }
95
78
  }
@@ -154,7 +154,6 @@ export function QueryControls( {
154
154
  props.onCategoryChange && (
155
155
  <FormTokenField
156
156
  __next40pxDefaultSize
157
- __nextHasNoMarginBottom
158
157
  key="query-controls-categories-select"
159
158
  label={ __( 'Categories' ) }
160
159
  value={
@@ -27,7 +27,7 @@ import type { SnackbarProps } from './types';
27
27
  import type { NoticeAction } from '../notice/types';
28
28
  import type { WordPressComponentProps } from '../context';
29
29
 
30
- const NOTICE_TIMEOUT = 10000;
30
+ const NOTICE_TIMEOUT = 6000;
31
31
 
32
32
  /**
33
33
  * Custom hook which announces the message with the given politeness, if a
@@ -10,37 +10,28 @@ import { forwardRef, useRef } from '@wordpress/element';
10
10
  import { ControlWithError } from '../control-with-error';
11
11
  import type { ValidatedControlProps } from './types';
12
12
  import CheckboxControl from '../../checkbox-control';
13
- import type { CheckboxControlProps } from '../../checkbox-control/types';
14
-
15
- type Value = CheckboxControlProps[ 'checked' ];
16
13
 
17
14
  const UnforwardedValidatedCheckboxControl = (
18
15
  {
19
16
  required,
20
- onValidate,
21
17
  customValidity,
22
- onChange,
23
18
  markWhenOptional,
24
19
  ...restProps
25
20
  }: Omit<
26
21
  React.ComponentProps< typeof CheckboxControl >,
27
22
  '__nextHasNoMarginBottom'
28
23
  > &
29
- ValidatedControlProps< Value >,
24
+ ValidatedControlProps,
30
25
  forwardedRef: React.ForwardedRef< HTMLInputElement >
31
26
  ) => {
32
27
  const validityTargetRef = useRef< HTMLDivElement >( null );
33
28
  const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
34
- const valueRef = useRef< Value >( restProps.checked );
35
29
 
36
30
  return (
37
31
  <ControlWithError
38
32
  required={ required }
39
33
  markWhenOptional={ markWhenOptional }
40
34
  ref={ mergedRefs }
41
- onValidate={ () => {
42
- return onValidate?.( valueRef.current );
43
- } }
44
35
  customValidity={ customValidity }
45
36
  getValidityTarget={ () =>
46
37
  validityTargetRef.current?.querySelector< HTMLInputElement >(
@@ -50,10 +41,6 @@ const UnforwardedValidatedCheckboxControl = (
50
41
  >
51
42
  <CheckboxControl
52
43
  __nextHasNoMarginBottom
53
- onChange={ ( value ) => {
54
- valueRef.current = value;
55
- onChange?.( value );
56
- } }
57
44
  // TODO: Upstream limitation - CheckboxControl doesn't support uncontrolled mode, visually.
58
45
  { ...restProps }
59
46
  />
@@ -10,28 +10,22 @@ import { forwardRef, useEffect, useRef } from '@wordpress/element';
10
10
  import { ControlWithError } from '../control-with-error';
11
11
  import type { ValidatedControlProps } from './types';
12
12
  import ComboboxControl from '../../combobox-control';
13
- import type { ComboboxControlProps } from '../../combobox-control/types';
14
-
15
- type Value = ComboboxControlProps[ 'value' ];
16
13
 
17
14
  const UnforwardedValidatedComboboxControl = (
18
15
  {
19
16
  required,
20
- onValidate,
21
17
  customValidity,
22
- onChange,
23
18
  markWhenOptional,
24
19
  ...restProps
25
20
  }: Omit<
26
21
  React.ComponentProps< typeof ComboboxControl >,
27
22
  '__next40pxDefaultSize' | '__nextHasNoMarginBottom'
28
23
  > &
29
- ValidatedControlProps< Value >,
24
+ ValidatedControlProps,
30
25
  forwardedRef: React.ForwardedRef< HTMLInputElement >
31
26
  ) => {
32
27
  const validityTargetRef = useRef< HTMLInputElement >( null );
33
28
  const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
34
- const valueRef = useRef< Value >( restProps.value );
35
29
 
36
30
  // TODO: Upstream limitation - The `required` attribute is not passed down to the input,
37
31
  // so we need to set it manually.
@@ -51,9 +45,6 @@ const UnforwardedValidatedComboboxControl = (
51
45
  required={ required }
52
46
  markWhenOptional={ markWhenOptional }
53
47
  ref={ mergedRefs }
54
- onValidate={ () => {
55
- return onValidate?.( valueRef.current );
56
- } }
57
48
  customValidity={ customValidity }
58
49
  getValidityTarget={ () =>
59
50
  validityTargetRef.current?.querySelector< HTMLInputElement >(
@@ -65,10 +56,6 @@ const UnforwardedValidatedComboboxControl = (
65
56
  __nextHasNoMarginBottom
66
57
  __next40pxDefaultSize
67
58
  { ...restProps }
68
- onChange={ ( value ) => {
69
- valueRef.current = value;
70
- onChange?.( value );
71
- } }
72
59
  />
73
60
  </ControlWithError>
74
61
  );
@@ -9,32 +9,21 @@ import { forwardRef, useRef } from '@wordpress/element';
9
9
  import { ControlWithError } from '../control-with-error';
10
10
  import type { ValidatedControlProps } from './types';
11
11
  import CustomSelectControl from '../../custom-select-control';
12
- import type {
13
- CustomSelectOption,
14
- CustomSelectProps,
15
- } from '../../custom-select-control/types';
16
-
17
- type CustomSelectControlProps = CustomSelectProps< CustomSelectOption >;
18
-
19
- type Value = CustomSelectControlProps[ 'value' ];
20
12
 
21
13
  const UnforwardedValidatedCustomSelectControl = (
22
14
  {
23
15
  required,
24
- onValidate,
25
16
  customValidity,
26
- onChange,
27
17
  markWhenOptional,
28
18
  ...restProps
29
19
  }: Omit<
30
20
  React.ComponentProps< typeof CustomSelectControl >,
31
21
  '__next40pxDefaultSize'
32
22
  > &
33
- ValidatedControlProps< Value >,
23
+ ValidatedControlProps,
34
24
  forwardedRef: React.ForwardedRef< HTMLDivElement >
35
25
  ) => {
36
26
  const validityTargetRef = useRef< HTMLSelectElement >( null );
37
- const valueRef = useRef< Value >( restProps.value );
38
27
 
39
28
  return (
40
29
  <div
@@ -44,9 +33,6 @@ const UnforwardedValidatedCustomSelectControl = (
44
33
  <ControlWithError
45
34
  required={ required }
46
35
  markWhenOptional={ markWhenOptional }
47
- onValidate={ () => {
48
- return onValidate?.( valueRef.current );
49
- } }
50
36
  customValidity={ customValidity }
51
37
  getValidityTarget={ () => validityTargetRef.current }
52
38
  >
@@ -54,10 +40,6 @@ const UnforwardedValidatedCustomSelectControl = (
54
40
  // TODO: Upstream limitation - Required isn't passed down correctly,
55
41
  // so it needs to be set on a delegate element.
56
42
  __next40pxDefaultSize
57
- onChange={ ( value ) => {
58
- valueRef.current = value.selectedItem;
59
- onChange?.( value );
60
- } }
61
43
  { ...restProps }
62
44
  />
63
45
  </ControlWithError>
@@ -9,27 +9,21 @@ import { forwardRef, useRef } from '@wordpress/element';
9
9
  import { ControlWithError } from '../control-with-error';
10
10
  import type { ValidatedControlProps } from './types';
11
11
  import { FormTokenField } from '../../form-token-field';
12
- import type { FormTokenFieldProps } from '../../form-token-field/types';
13
-
14
- type Value = FormTokenFieldProps[ 'value' ];
15
12
 
16
13
  const UnforwardedValidatedFormTokenField = (
17
14
  {
18
15
  required,
19
- onValidate,
20
16
  customValidity,
21
- onChange,
22
17
  markWhenOptional,
23
18
  ...restProps
24
19
  }: Omit<
25
20
  React.ComponentProps< typeof FormTokenField >,
26
- '__next40pxDefaultSize' | '__nextHasNoMarginBottom'
21
+ '__next40pxDefaultSize'
27
22
  > &
28
- ValidatedControlProps< FormTokenFieldProps[ 'value' ] >,
23
+ ValidatedControlProps,
29
24
  forwardedRef: React.ForwardedRef< HTMLDivElement >
30
25
  ) => {
31
26
  const validityTargetRef = useRef< HTMLInputElement >( null );
32
- const valueRef = useRef< Value >( restProps.value );
33
27
 
34
28
  return (
35
29
  <div
@@ -39,21 +33,10 @@ const UnforwardedValidatedFormTokenField = (
39
33
  <ControlWithError
40
34
  required={ required }
41
35
  markWhenOptional={ markWhenOptional }
42
- onValidate={ () => {
43
- return onValidate?.( valueRef.current );
44
- } }
45
36
  customValidity={ customValidity }
46
37
  getValidityTarget={ () => validityTargetRef.current }
47
38
  >
48
- <FormTokenField
49
- __next40pxDefaultSize
50
- __nextHasNoMarginBottom
51
- { ...restProps }
52
- onChange={ ( value, ...args ) => {
53
- valueRef.current = value;
54
- onChange?.( value, ...args );
55
- } }
56
- />
39
+ <FormTokenField __next40pxDefaultSize { ...restProps } />
57
40
  </ControlWithError>
58
41
  <input
59
42
  className="components-validated-control__error-delegate"
@@ -61,7 +44,7 @@ const UnforwardedValidatedFormTokenField = (
61
44
  ref={ validityTargetRef }
62
45
  required={ required }
63
46
  value={
64
- valueRef.current && valueRef.current.length > 0
47
+ restProps.value && restProps.value.length > 0
65
48
  ? 'hasvalue'
66
49
  : ''
67
50
  }
@@ -10,46 +10,33 @@ import { useMergeRefs } from '@wordpress/compose';
10
10
  import { ControlWithError } from '../control-with-error';
11
11
  import type { ValidatedControlProps } from './types';
12
12
  import InputControl from '../../input-control';
13
- import type { InputControlProps } from '../../input-control/types';
14
-
15
- type Value = InputControlProps[ 'value' ];
16
13
 
17
14
  const UnforwardedValidatedInputControl = (
18
15
  {
19
16
  required,
20
- onValidate,
21
17
  customValidity,
22
- onChange,
23
18
  markWhenOptional,
24
19
  ...restProps
25
20
  }: Omit<
26
21
  React.ComponentProps< typeof InputControl >,
27
22
  '__next40pxDefaultSize'
28
23
  > &
29
- ValidatedControlProps< InputControlProps[ 'value' ] >,
24
+ ValidatedControlProps,
30
25
  forwardedRef: React.ForwardedRef< HTMLInputElement >
31
26
  ) => {
32
27
  const validityTargetRef = useRef< HTMLInputElement >( null );
33
28
  const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
34
- const valueRef = useRef< Value >( restProps.value );
35
29
 
36
30
  return (
37
31
  <ControlWithError
38
32
  required={ required }
39
33
  markWhenOptional={ markWhenOptional }
40
- onValidate={ () => {
41
- return onValidate?.( valueRef.current );
42
- } }
43
34
  customValidity={ customValidity }
44
35
  getValidityTarget={ () => validityTargetRef.current }
45
36
  >
46
37
  <InputControl
47
38
  __next40pxDefaultSize
48
39
  ref={ mergedRefs }
49
- onChange={ ( value, ...args ) => {
50
- valueRef.current = value;
51
- onChange?.( value, ...args );
52
- } }
53
40
  { ...restProps }
54
41
  />
55
42
  </ControlWithError>