@wordpress/components 25.15.1-next.79a6196f.0 → 25.16.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 (259) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/build/border-box-control/border-box-control/component.js.map +1 -1
  3. package/build/border-box-control/border-box-control/hook.js +3 -1
  4. package/build/border-box-control/border-box-control/hook.js.map +1 -1
  5. package/build/border-box-control/types.js.map +1 -1
  6. package/build/border-control/border-control/component.js +5 -1
  7. package/build/border-control/border-control/component.js.map +1 -1
  8. package/build/border-control/border-control/hook.js +18 -15
  9. package/build/border-control/border-control/hook.js.map +1 -1
  10. package/build/border-control/border-control-dropdown/component.js +2 -1
  11. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  12. package/build/border-control/border-control-style-picker/component.js +21 -49
  13. package/build/border-control/border-control-style-picker/component.js.map +1 -1
  14. package/build/border-control/styles.js +15 -27
  15. package/build/border-control/styles.js.map +1 -1
  16. package/build/border-control/types.js.map +1 -1
  17. package/build/box-control/all-input-control.js +35 -29
  18. package/build/box-control/all-input-control.js.map +1 -1
  19. package/build/box-control/axial-input-controls.js +40 -54
  20. package/build/box-control/axial-input-controls.js.map +1 -1
  21. package/build/box-control/index.js +21 -24
  22. package/build/box-control/index.js.map +1 -1
  23. package/build/box-control/input-controls.js +45 -37
  24. package/build/box-control/input-controls.js.map +1 -1
  25. package/build/box-control/styles/box-control-styles.js +50 -112
  26. package/build/box-control/styles/box-control-styles.js.map +1 -1
  27. package/build/box-control/types.js.map +1 -1
  28. package/build/box-control/utils.js +123 -8
  29. package/build/box-control/utils.js.map +1 -1
  30. package/build/button/index.js +14 -16
  31. package/build/button/index.js.map +1 -1
  32. package/build/button/types.js.map +1 -1
  33. package/build/color-picker/hsl-input.js +55 -33
  34. package/build/color-picker/hsl-input.js.map +1 -1
  35. package/build/custom-select-control-v2/index.js +3 -2
  36. package/build/custom-select-control-v2/index.js.map +1 -1
  37. package/build/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
  38. package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
  39. package/build/theme/styles.js +11 -6
  40. package/build/theme/styles.js.map +1 -1
  41. package/build/toggle-group-control/toggle-group-control/utils.js +7 -1
  42. package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  43. package/build/tooltip/index.js +15 -12
  44. package/build/tooltip/index.js.map +1 -1
  45. package/build/tooltip/types.js.map +1 -1
  46. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  47. package/build-module/border-box-control/border-box-control/hook.js +3 -1
  48. package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
  49. package/build-module/border-box-control/types.js.map +1 -1
  50. package/build-module/border-control/border-control/component.js +5 -1
  51. package/build-module/border-control/border-control/component.js.map +1 -1
  52. package/build-module/border-control/border-control/hook.js +18 -15
  53. package/build-module/border-control/border-control/hook.js.map +1 -1
  54. package/build-module/border-control/border-control-dropdown/component.js +2 -1
  55. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  56. package/build-module/border-control/border-control-style-picker/component.js +21 -48
  57. package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
  58. package/build-module/border-control/styles.js +14 -24
  59. package/build-module/border-control/styles.js.map +1 -1
  60. package/build-module/border-control/types.js.map +1 -1
  61. package/build-module/box-control/all-input-control.js +38 -28
  62. package/build-module/box-control/all-input-control.js.map +1 -1
  63. package/build-module/box-control/axial-input-controls.js +42 -57
  64. package/build-module/box-control/axial-input-controls.js.map +1 -1
  65. package/build-module/box-control/index.js +22 -25
  66. package/build-module/box-control/index.js.map +1 -1
  67. package/build-module/box-control/input-controls.js +47 -40
  68. package/build-module/box-control/input-controls.js.map +1 -1
  69. package/build-module/box-control/styles/box-control-styles.js +45 -105
  70. package/build-module/box-control/styles/box-control-styles.js.map +1 -1
  71. package/build-module/box-control/types.js.map +1 -1
  72. package/build-module/box-control/utils.js +121 -7
  73. package/build-module/box-control/utils.js.map +1 -1
  74. package/build-module/button/index.js +14 -16
  75. package/build-module/button/index.js.map +1 -1
  76. package/build-module/button/types.js.map +1 -1
  77. package/build-module/color-picker/hsl-input.js +55 -33
  78. package/build-module/color-picker/hsl-input.js.map +1 -1
  79. package/build-module/custom-select-control-v2/index.js +3 -2
  80. package/build-module/custom-select-control-v2/index.js.map +1 -1
  81. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
  82. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
  83. package/build-module/theme/styles.js +11 -2
  84. package/build-module/theme/styles.js.map +1 -1
  85. package/build-module/toggle-group-control/toggle-group-control/utils.js +7 -1
  86. package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  87. package/build-module/tooltip/index.js +16 -13
  88. package/build-module/tooltip/index.js.map +1 -1
  89. package/build-module/tooltip/types.js.map +1 -1
  90. package/build-style/style-rtl.css +6 -4
  91. package/build-style/style.css +6 -4
  92. package/build-types/border-box-control/border-box-control/component.d.ts +1 -0
  93. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  94. package/build-types/border-box-control/border-box-control/hook.d.ts +4 -4
  95. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  96. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +5 -5
  97. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +4 -4
  98. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +4 -4
  99. package/build-types/border-box-control/stories/index.story.d.ts +2 -1
  100. package/build-types/border-box-control/stories/index.story.d.ts.map +1 -1
  101. package/build-types/border-box-control/types.d.ts +6 -0
  102. package/build-types/border-box-control/types.d.ts.map +1 -1
  103. package/build-types/border-control/border-control/component.d.ts +1 -0
  104. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  105. package/build-types/border-control/border-control/hook.d.ts +6 -4
  106. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  107. package/build-types/border-control/border-control-dropdown/component.d.ts +1 -0
  108. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  109. package/build-types/border-control/border-control-dropdown/hook.d.ts +5 -4
  110. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  111. package/build-types/border-control/border-control-style-picker/component.d.ts +3 -4
  112. package/build-types/border-control/border-control-style-picker/component.d.ts.map +1 -1
  113. package/build-types/border-control/stories/index.story.d.ts +12 -6
  114. package/build-types/border-control/stories/index.story.d.ts.map +1 -1
  115. package/build-types/border-control/styles.d.ts +0 -2
  116. package/build-types/border-control/styles.d.ts.map +1 -1
  117. package/build-types/border-control/types.d.ts +12 -1
  118. package/build-types/border-control/types.d.ts.map +1 -1
  119. package/build-types/box-control/all-input-control.d.ts +1 -1
  120. package/build-types/box-control/all-input-control.d.ts.map +1 -1
  121. package/build-types/box-control/axial-input-controls.d.ts +1 -1
  122. package/build-types/box-control/axial-input-controls.d.ts.map +1 -1
  123. package/build-types/box-control/index.d.ts +1 -1
  124. package/build-types/box-control/index.d.ts.map +1 -1
  125. package/build-types/box-control/input-controls.d.ts +1 -1
  126. package/build-types/box-control/input-controls.d.ts.map +1 -1
  127. package/build-types/box-control/stories/index.story.d.ts +42 -36
  128. package/build-types/box-control/stories/index.story.d.ts.map +1 -1
  129. package/build-types/box-control/styles/box-control-styles.d.ts +49 -23
  130. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
  131. package/build-types/box-control/types.d.ts +12 -12
  132. package/build-types/box-control/types.d.ts.map +1 -1
  133. package/build-types/box-control/utils.d.ts +2 -1
  134. package/build-types/box-control/utils.d.ts.map +1 -1
  135. package/build-types/button/deprecated.d.ts +3 -3
  136. package/build-types/button/index.d.ts.map +1 -1
  137. package/build-types/button/types.d.ts +7 -3
  138. package/build-types/button/types.d.ts.map +1 -1
  139. package/build-types/card/card/hook.d.ts +4 -4
  140. package/build-types/card/card-body/hook.d.ts +4 -4
  141. package/build-types/card/card-divider/hook.d.ts +4 -4
  142. package/build-types/card/card-footer/hook.d.ts +4 -4
  143. package/build-types/card/card-header/hook.d.ts +4 -4
  144. package/build-types/card/card-media/hook.d.ts +4 -4
  145. package/build-types/color-palette/styles.d.ts +2 -2
  146. package/build-types/color-picker/component.d.ts +1 -1
  147. package/build-types/color-picker/hsl-input.d.ts.map +1 -1
  148. package/build-types/color-picker/stories/index.story.d.ts +1 -1
  149. package/build-types/color-picker/styles.d.ts +3 -3
  150. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  151. package/build-types/date-time/date/styles.d.ts +3 -3
  152. package/build-types/date-time/date-time/styles.d.ts +1 -1
  153. package/build-types/date-time/time/styles.d.ts +4 -4
  154. package/build-types/elevation/hook.d.ts +4 -4
  155. package/build-types/flex/flex/hook.d.ts +4 -4
  156. package/build-types/flex/flex-block/hook.d.ts +4 -4
  157. package/build-types/flex/flex-item/hook.d.ts +4 -4
  158. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  159. package/build-types/font-size-picker/styles.d.ts +1 -1
  160. package/build-types/grid/hook.d.ts +4 -4
  161. package/build-types/h-stack/hook.d.ts +4 -4
  162. package/build-types/heading/component.d.ts +1 -1
  163. package/build-types/heading/hook.d.ts +4 -4
  164. package/build-types/item-group/item/hook.d.ts +4 -4
  165. package/build-types/item-group/item-group/hook.d.ts +4 -4
  166. package/build-types/menu-item/index.d.ts +1 -1
  167. package/build-types/menu-item/stories/index.story.d.ts +4 -4
  168. package/build-types/navigation/styles/navigation-styles.d.ts +2 -2
  169. package/build-types/navigator/navigator-back-button/hook.d.ts +4 -4
  170. package/build-types/navigator/navigator-button/hook.d.ts +4 -4
  171. package/build-types/number-control/index.d.ts +1 -1
  172. package/build-types/number-control/stories/index.story.d.ts +1 -1
  173. package/build-types/palette-edit/styles.d.ts +3 -3
  174. package/build-types/range-control/index.d.ts +1 -1
  175. package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
  176. package/build-types/resizable-box/index.d.ts +1 -1
  177. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  178. package/build-types/resizable-box/stories/index.story.d.ts +2 -2
  179. package/build-types/scrollable/hook.d.ts +4 -4
  180. package/build-types/spacer/hook.d.ts +4 -4
  181. package/build-types/surface/hook.d.ts +4 -4
  182. package/build-types/text/hook.d.ts +4 -4
  183. package/build-types/theme/styles.d.ts.map +1 -1
  184. package/build-types/toggle-control/stories/index.story.d.ts +2 -2
  185. package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -1
  186. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
  187. package/build-types/toolbar/toolbar-button/index.d.ts +3 -3
  188. package/build-types/tools-panel/tools-panel/hook.d.ts +4 -4
  189. package/build-types/tools-panel/tools-panel-header/hook.d.ts +4 -4
  190. package/build-types/tools-panel/tools-panel-item/hook.d.ts +4 -4
  191. package/build-types/tooltip/index.d.ts +1 -1
  192. package/build-types/tooltip/index.d.ts.map +1 -1
  193. package/build-types/tooltip/stories/index.story.d.ts +1 -1
  194. package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
  195. package/build-types/tooltip/types.d.ts +1 -1
  196. package/build-types/tooltip/types.d.ts.map +1 -1
  197. package/build-types/truncate/hook.d.ts +4 -4
  198. package/build-types/unit-control/index.d.ts +1 -1
  199. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
  200. package/build-types/v-stack/hook.d.ts +4 -4
  201. package/build-types/v-stack/stories/index.story.d.ts +1 -1
  202. package/package.json +19 -19
  203. package/src/border-box-control/border-box-control/component.tsx +0 -1
  204. package/src/border-box-control/border-box-control/hook.ts +5 -1
  205. package/src/border-box-control/types.ts +6 -0
  206. package/src/border-control/border-control/component.tsx +4 -0
  207. package/src/border-control/border-control/hook.ts +22 -16
  208. package/src/border-control/border-control-dropdown/component.tsx +2 -1
  209. package/src/border-control/border-control-style-picker/component.tsx +31 -66
  210. package/src/border-control/styles.ts +0 -15
  211. package/src/border-control/types.ts +15 -1
  212. package/src/box-control/all-input-control.tsx +57 -34
  213. package/src/box-control/axial-input-controls.tsx +79 -69
  214. package/src/box-control/index.tsx +47 -54
  215. package/src/box-control/input-controls.tsx +114 -83
  216. package/src/box-control/styles/box-control-styles.ts +21 -61
  217. package/src/box-control/test/index.tsx +126 -18
  218. package/src/box-control/types.ts +10 -21
  219. package/src/box-control/utils.ts +43 -8
  220. package/src/button/README.md +1 -1
  221. package/src/button/index.tsx +21 -33
  222. package/src/button/test/index.tsx +122 -0
  223. package/src/button/types.ts +7 -3
  224. package/src/circular-option-picker/test/index.tsx +10 -16
  225. package/src/color-picker/hsl-input.tsx +56 -30
  226. package/src/color-picker/test/index.tsx +190 -16
  227. package/src/custom-select-control-v2/index.tsx +5 -2
  228. package/src/palette-edit/test/index.tsx +326 -10
  229. package/src/slot-fill/bubbles-virtually/use-slot-fills.ts +1 -1
  230. package/src/tabs/test/index.tsx +3 -1
  231. package/src/theme/styles.ts +3 -1
  232. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +6 -6
  233. package/src/toggle-group-control/test/index.tsx +73 -36
  234. package/src/toggle-group-control/toggle-group-control/utils.ts +8 -3
  235. package/src/tooltip/index.tsx +29 -29
  236. package/src/tooltip/test/index.tsx +32 -13
  237. package/src/tooltip/types.ts +1 -1
  238. package/tsconfig.tsbuildinfo +1 -1
  239. package/build/border-control/border-control-style-picker/hook.js +0 -41
  240. package/build/border-control/border-control-style-picker/hook.js.map +0 -1
  241. package/build/box-control/styles/box-control-visualizer-styles.js +0 -93
  242. package/build/box-control/styles/box-control-visualizer-styles.js.map +0 -1
  243. package/build/box-control/unit-control.js +0 -76
  244. package/build/box-control/unit-control.js.map +0 -1
  245. package/build-module/border-control/border-control-style-picker/hook.js +0 -32
  246. package/build-module/border-control/border-control-style-picker/hook.js.map +0 -1
  247. package/build-module/box-control/styles/box-control-visualizer-styles.js +0 -86
  248. package/build-module/box-control/styles/box-control-visualizer-styles.js.map +0 -1
  249. package/build-module/box-control/unit-control.js +0 -68
  250. package/build-module/box-control/unit-control.js.map +0 -1
  251. package/build-types/border-control/border-control-style-picker/hook.d.ts +0 -267
  252. package/build-types/border-control/border-control-style-picker/hook.d.ts.map +0 -1
  253. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +0 -46
  254. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +0 -1
  255. package/build-types/box-control/unit-control.d.ts +0 -4
  256. package/build-types/box-control/unit-control.d.ts.map +0 -1
  257. package/src/border-control/border-control-style-picker/hook.ts +0 -35
  258. package/src/box-control/styles/box-control-visualizer-styles.ts +0 -75
  259. package/src/box-control/unit-control.tsx +0 -74
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { render, screen } from '@testing-library/react';
4
+ import { fireEvent, render, screen } from '@testing-library/react';
5
5
  import userEvent from '@testing-library/user-event';
6
6
 
7
7
  /**
@@ -33,7 +33,10 @@ describe( 'BoxControl', () => {
33
33
  render( <BoxControl onChange={ () => {} } /> );
34
34
 
35
35
  expect(
36
- screen.getByRole( 'textbox', { name: 'Box Control' } )
36
+ screen.getByRole( 'group', { name: 'Box Control' } )
37
+ ).toBeVisible();
38
+ expect(
39
+ screen.getByRole( 'textbox', { name: 'All sides' } )
37
40
  ).toBeVisible();
38
41
  } );
39
42
 
@@ -42,15 +45,41 @@ describe( 'BoxControl', () => {
42
45
 
43
46
  render( <BoxControl onChange={ () => {} } /> );
44
47
 
45
- const input = screen.getByRole( 'textbox', {
46
- name: 'Box Control',
47
- } );
48
+ const input = screen.getByRole( 'textbox', { name: 'All sides' } );
48
49
 
49
50
  await user.type( input, '100' );
50
51
  await user.keyboard( '{Enter}' );
51
52
 
52
53
  expect( input ).toHaveValue( '100' );
53
54
  } );
55
+
56
+ it( 'should update input values when interacting with slider', () => {
57
+ render( <BoxControl onChange={ () => {} } /> );
58
+
59
+ const slider = screen.getByRole( 'slider' );
60
+
61
+ fireEvent.change( slider, { target: { value: 50 } } );
62
+
63
+ expect( slider ).toHaveValue( '50' );
64
+ expect(
65
+ screen.getByRole( 'textbox', { name: 'All sides' } )
66
+ ).toHaveValue( '50' );
67
+ } );
68
+
69
+ it( 'should update slider values when interacting with input', async () => {
70
+ const user = userEvent.setup();
71
+ render( <BoxControl onChange={ () => {} } /> );
72
+
73
+ const input = screen.getByRole( 'textbox', {
74
+ name: 'All sides',
75
+ } );
76
+
77
+ await user.type( input, '50' );
78
+ await user.keyboard( '{Enter}' );
79
+
80
+ expect( input ).toHaveValue( '50' );
81
+ expect( screen.getByRole( 'slider' ) ).toHaveValue( '50' );
82
+ } );
54
83
  } );
55
84
 
56
85
  describe( 'Reset', () => {
@@ -60,7 +89,7 @@ describe( 'BoxControl', () => {
60
89
  render( <BoxControl onChange={ () => {} } /> );
61
90
 
62
91
  const input = screen.getByRole( 'textbox', {
63
- name: 'Box Control',
92
+ name: 'All sides',
64
93
  } );
65
94
 
66
95
  await user.type( input, '100' );
@@ -79,7 +108,7 @@ describe( 'BoxControl', () => {
79
108
  render( <Example /> );
80
109
 
81
110
  const input = screen.getByRole( 'textbox', {
82
- name: 'Box Control',
111
+ name: 'All sides',
83
112
  } );
84
113
 
85
114
  await user.type( input, '100' );
@@ -98,7 +127,7 @@ describe( 'BoxControl', () => {
98
127
  render( <Example /> );
99
128
 
100
129
  const input = screen.getByRole( 'textbox', {
101
- name: 'Box Control',
130
+ name: 'All sides',
102
131
  } );
103
132
 
104
133
  await user.type( input, '100' );
@@ -118,7 +147,7 @@ describe( 'BoxControl', () => {
118
147
  render( <BoxControl onChange={ ( v ) => spyChange( v ) } /> );
119
148
 
120
149
  const input = screen.getByRole( 'textbox', {
121
- name: 'Box Control',
150
+ name: 'All sides',
122
151
  } );
123
152
 
124
153
  await user.type( input, '100' );
@@ -152,21 +181,49 @@ describe( 'BoxControl', () => {
152
181
  );
153
182
 
154
183
  await user.type(
155
- screen.getByRole( 'textbox', { name: 'Top' } ),
184
+ screen.getByRole( 'textbox', { name: 'Top side' } ),
156
185
  '100'
157
186
  );
158
187
 
159
188
  expect(
160
- screen.getByRole( 'textbox', { name: 'Top' } )
189
+ screen.getByRole( 'textbox', { name: 'Top side' } )
161
190
  ).toHaveValue( '100' );
162
191
  expect(
163
- screen.getByRole( 'textbox', { name: 'Right' } )
192
+ screen.getByRole( 'textbox', { name: 'Right side' } )
164
193
  ).not.toHaveValue();
165
194
  expect(
166
- screen.getByRole( 'textbox', { name: 'Bottom' } )
195
+ screen.getByRole( 'textbox', { name: 'Bottom side' } )
167
196
  ).not.toHaveValue();
168
197
  expect(
169
- screen.getByRole( 'textbox', { name: 'Left' } )
198
+ screen.getByRole( 'textbox', { name: 'Left side' } )
199
+ ).not.toHaveValue();
200
+ } );
201
+
202
+ it( 'should update a single side value when using slider unlinked', async () => {
203
+ const user = userEvent.setup();
204
+
205
+ render( <Example /> );
206
+
207
+ await user.click(
208
+ screen.getByRole( 'button', { name: 'Unlink sides' } )
209
+ );
210
+
211
+ const slider = screen.getByRole( 'slider', { name: 'Right side' } );
212
+
213
+ fireEvent.change( slider, { target: { value: 50 } } );
214
+
215
+ expect( slider ).toHaveValue( '50' );
216
+ expect(
217
+ screen.getByRole( 'textbox', { name: 'Top side' } )
218
+ ).not.toHaveValue();
219
+ expect(
220
+ screen.getByRole( 'textbox', { name: 'Right side' } )
221
+ ).toHaveValue( '50' );
222
+ expect(
223
+ screen.getByRole( 'textbox', { name: 'Bottom side' } )
224
+ ).not.toHaveValue();
225
+ expect(
226
+ screen.getByRole( 'textbox', { name: 'Left side' } )
170
227
  ).not.toHaveValue();
171
228
  } );
172
229
 
@@ -181,17 +238,68 @@ describe( 'BoxControl', () => {
181
238
 
182
239
  await user.type(
183
240
  screen.getByRole( 'textbox', {
184
- name: 'Vertical',
241
+ name: 'Top and bottom sides',
185
242
  } ),
186
243
  '100'
187
244
  );
188
245
 
189
246
  expect(
190
- screen.getByRole( 'textbox', { name: 'Vertical' } )
247
+ screen.getByRole( 'textbox', { name: 'Top and bottom sides' } )
191
248
  ).toHaveValue( '100' );
192
249
  expect(
193
- screen.getByRole( 'textbox', { name: 'Horizontal' } )
250
+ screen.getByRole( 'textbox', { name: 'Left and right sides' } )
251
+ ).not.toHaveValue();
252
+ } );
253
+
254
+ it( 'should update a whole axis using a slider when value is changed when unlinked', async () => {
255
+ const user = userEvent.setup();
256
+
257
+ render( <Example splitOnAxis /> );
258
+
259
+ await user.click(
260
+ screen.getByRole( 'button', { name: 'Unlink sides' } )
261
+ );
262
+
263
+ const slider = screen.getByRole( 'slider', {
264
+ name: 'Left and right sides',
265
+ } );
266
+
267
+ fireEvent.change( slider, { target: { value: 50 } } );
268
+
269
+ expect( slider ).toHaveValue( '50' );
270
+ expect(
271
+ screen.getByRole( 'textbox', { name: 'Top and bottom sides' } )
194
272
  ).not.toHaveValue();
273
+ expect(
274
+ screen.getByRole( 'textbox', { name: 'Left and right sides' } )
275
+ ).toHaveValue( '50' );
276
+ } );
277
+
278
+ it( 'should show "Mixed" label when sides have different values but are linked', async () => {
279
+ const user = userEvent.setup();
280
+
281
+ render( <Example /> );
282
+
283
+ const unlinkButton = screen.getByRole( 'button', {
284
+ name: 'Unlink sides',
285
+ } );
286
+
287
+ await user.click( unlinkButton );
288
+
289
+ await user.type(
290
+ screen.getByRole( 'textbox', {
291
+ name: 'Right side',
292
+ } ),
293
+ '13'
294
+ );
295
+
296
+ expect(
297
+ screen.getByRole( 'textbox', { name: 'Right side' } )
298
+ ).toHaveValue( '13' );
299
+
300
+ await user.click( unlinkButton );
301
+
302
+ expect( screen.getByPlaceholderText( 'Mixed' ) ).toHaveValue( '' );
195
303
  } );
196
304
  } );
197
305
 
@@ -287,7 +395,7 @@ describe( 'BoxControl', () => {
287
395
  render( <BoxControl onChange={ onChangeSpy } /> );
288
396
 
289
397
  const valueInput = screen.getByRole( 'textbox', {
290
- name: 'Box Control',
398
+ name: 'All sides',
291
399
  } );
292
400
  const unitSelect = screen.getByRole( 'combobox', {
293
401
  name: 'Select unit',
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import type { useHover } from '@use-gesture/react';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
@@ -16,6 +11,10 @@ export type BoxControlValue = {
16
11
  left?: string;
17
12
  };
18
13
 
14
+ export type CustomValueUnits = {
15
+ [ key: string ]: { max: number; step: number };
16
+ };
17
+
19
18
  type UnitControlPassthroughProps = Omit<
20
19
  UnitControlProps,
21
20
  'label' | 'onChange' | 'onFocus' | 'onMouseOver' | 'onMouseOut' | 'units'
@@ -72,6 +71,12 @@ export type BoxControlProps = Pick<
72
71
  * The current values of the control, expressed as an object of `top`, `right`, `bottom`, and `left` values.
73
72
  */
74
73
  values?: BoxControlValue;
74
+ /**
75
+ * Start opting into the larger default height that will become the default size in a future version.
76
+ *
77
+ * @default false
78
+ */
79
+ __next40pxDefaultSize?: boolean;
75
80
  };
76
81
 
77
82
  export type BoxControlInputControlProps = UnitControlPassthroughProps & {
@@ -92,22 +97,6 @@ export type BoxControlInputControlProps = UnitControlPassthroughProps & {
92
97
  values: BoxControlValue;
93
98
  };
94
99
 
95
- export type BoxUnitControlProps = UnitControlPassthroughProps &
96
- Pick< UnitControlProps, 'onChange' | 'onFocus' > & {
97
- isFirst?: boolean;
98
- isLast?: boolean;
99
- isOnly?: boolean;
100
- label?: string;
101
- onHoverOff?: (
102
- event: ReturnType< typeof useHover >[ 'event' ],
103
- state: Omit< ReturnType< typeof useHover >, 'event' >
104
- ) => void;
105
- onHoverOn?: (
106
- event: ReturnType< typeof useHover >[ 'event' ],
107
- state: Omit< ReturnType< typeof useHover >, 'event' >
108
- ) => void;
109
- };
110
-
111
100
  export type BoxControlIconProps = {
112
101
  /**
113
102
  * @default 24
@@ -7,17 +7,52 @@ import { __ } from '@wordpress/i18n';
7
7
  * Internal dependencies
8
8
  */
9
9
  import { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';
10
- import type { BoxControlProps, BoxControlValue } from './types';
10
+ import type {
11
+ BoxControlProps,
12
+ BoxControlValue,
13
+ CustomValueUnits,
14
+ } from './types';
15
+
16
+ export const CUSTOM_VALUE_SETTINGS: CustomValueUnits = {
17
+ px: { max: 300, step: 1 },
18
+ '%': { max: 100, step: 1 },
19
+ vw: { max: 100, step: 1 },
20
+ vh: { max: 100, step: 1 },
21
+ em: { max: 10, step: 0.1 },
22
+ rm: { max: 10, step: 0.1 },
23
+ svw: { max: 100, step: 1 },
24
+ lvw: { max: 100, step: 1 },
25
+ dvw: { max: 100, step: 1 },
26
+ svh: { max: 100, step: 1 },
27
+ lvh: { max: 100, step: 1 },
28
+ dvh: { max: 100, step: 1 },
29
+ vi: { max: 100, step: 1 },
30
+ svi: { max: 100, step: 1 },
31
+ lvi: { max: 100, step: 1 },
32
+ dvi: { max: 100, step: 1 },
33
+ vb: { max: 100, step: 1 },
34
+ svb: { max: 100, step: 1 },
35
+ lvb: { max: 100, step: 1 },
36
+ dvb: { max: 100, step: 1 },
37
+ vmin: { max: 100, step: 1 },
38
+ svmin: { max: 100, step: 1 },
39
+ lvmin: { max: 100, step: 1 },
40
+ dvmin: { max: 100, step: 1 },
41
+ vmax: { max: 100, step: 1 },
42
+ svmax: { max: 100, step: 1 },
43
+ lvmax: { max: 100, step: 1 },
44
+ dvmax: { max: 100, step: 1 },
45
+ };
11
46
 
12
47
  export const LABELS = {
13
- all: __( 'All' ),
14
- top: __( 'Top' ),
15
- bottom: __( 'Bottom' ),
16
- left: __( 'Left' ),
17
- right: __( 'Right' ),
48
+ all: __( 'All sides' ),
49
+ top: __( 'Top side' ),
50
+ bottom: __( 'Bottom side' ),
51
+ left: __( 'Left side' ),
52
+ right: __( 'Right side' ),
18
53
  mixed: __( 'Mixed' ),
19
- vertical: __( 'Vertical' ),
20
- horizontal: __( 'Horizontal' ),
54
+ vertical: __( 'Top and bottom sides' ),
55
+ horizontal: __( 'Left and right sides' ),
21
56
  };
22
57
 
23
58
  export const DEFAULT_VALUES = {
@@ -135,7 +135,7 @@ An accessible description for the button.
135
135
 
136
136
  #### `disabled`: `boolean`
137
137
 
138
- Whether the button is disabled. If `true`, this will force a `button` element to be rendered.
138
+ Whether the button is disabled. If `true`, this will force a `button` element to be rendered, even when an `href` is given.
139
139
 
140
140
  - Required: No
141
141
 
@@ -195,9 +195,9 @@ export function UnforwardedButton(
195
195
  const shouldShowTooltip =
196
196
  ! trulyDisabled &&
197
197
  // An explicit tooltip is passed or...
198
- ( ( showTooltip && label ) ||
198
+ ( ( showTooltip && !! label ) ||
199
199
  // There's a shortcut or...
200
- shortcut ||
200
+ !! shortcut ||
201
201
  // There's a label and...
202
202
  ( !! label &&
203
203
  // The children are empty and...
@@ -249,40 +249,28 @@ export function UnforwardedButton(
249
249
  </button>
250
250
  );
251
251
 
252
- // Convert legacy `position` values to be used with the new `placement` prop
253
- let computedPlacement;
254
- // if `tooltipPosition` is defined, compute value to `placement`
255
- if ( tooltipPosition !== undefined ) {
256
- computedPlacement = positionToPlacement( tooltipPosition );
257
- }
258
-
259
- if ( ! shouldShowTooltip ) {
260
- return (
261
- <>
262
- { element }
263
- { describedBy && (
264
- <VisuallyHidden>
265
- <span id={ descriptionId }>{ describedBy }</span>
266
- </VisuallyHidden>
267
- ) }
268
- </>
269
- );
270
- }
271
-
272
- return (
273
- <>
274
- <Tooltip
275
- text={
252
+ // In order to avoid some React reconciliation issues, we are always rendering
253
+ // the `Tooltip` component even when `shouldShowTooltip` is `false`.
254
+ // In order to make sure that the tooltip doesn't show when it shouldn't,
255
+ // we don't pass the props to the `Tooltip` component.
256
+ const tooltipProps = shouldShowTooltip
257
+ ? {
258
+ text:
276
259
  ( children as string | ReactElement[] )?.length &&
277
260
  describedBy
278
261
  ? describedBy
279
- : label
280
- }
281
- shortcut={ shortcut }
282
- placement={ computedPlacement }
283
- >
284
- { element }
285
- </Tooltip>
262
+ : label,
263
+ shortcut,
264
+ placement:
265
+ tooltipPosition &&
266
+ // Convert legacy `position` values to be used with the new `placement` prop
267
+ positionToPlacement( tooltipPosition ),
268
+ }
269
+ : {};
270
+
271
+ return (
272
+ <>
273
+ <Tooltip { ...tooltipProps }>{ element }</Tooltip>
286
274
  { describedBy && (
287
275
  <VisuallyHidden>
288
276
  <span id={ descriptionId }>{ describedBy }</span>
@@ -112,6 +112,128 @@ describe( 'Button', () => {
112
112
  );
113
113
  } );
114
114
 
115
+ it( 'should render correctly as a tooltip anchor', async () => {
116
+ const user = userEvent.setup();
117
+
118
+ render(
119
+ <>
120
+ <Tooltip text="Tooltip text">
121
+ <Button icon={ plusCircle } label="Tooltip anchor" />
122
+ </Tooltip>
123
+ <Button>Focus me</Button>
124
+ </>
125
+ );
126
+
127
+ const anchor = screen.getByRole( 'button', {
128
+ name: 'Tooltip anchor',
129
+ } );
130
+
131
+ await user.tab();
132
+
133
+ expect( anchor ).toHaveFocus();
134
+
135
+ const tooltip = await screen.findByRole( 'tooltip', {
136
+ name: 'Tooltip text',
137
+ } );
138
+
139
+ expect( tooltip ).toBeVisible();
140
+
141
+ await user.tab();
142
+
143
+ expect(
144
+ screen.getByRole( 'button', { name: 'Focus me' } )
145
+ ).toHaveFocus();
146
+
147
+ expect(
148
+ screen.queryByRole( 'tooltip', {
149
+ name: 'Tooltip text',
150
+ } )
151
+ ).not.toBeInTheDocument();
152
+ } );
153
+
154
+ it( 'should render correctly as a tooltip anchor, ignoring its internal tooltip in favour of the external tooltip', async () => {
155
+ const user = userEvent.setup();
156
+
157
+ render(
158
+ <>
159
+ <Tooltip text="Tooltip text">
160
+ <Button icon={ plusCircle } label="Button label" />
161
+ </Tooltip>
162
+ <Button>Focus me</Button>
163
+ </>
164
+ );
165
+
166
+ const anchor = screen.getByRole( 'button', {
167
+ name: 'Button label',
168
+ } );
169
+
170
+ await user.tab();
171
+
172
+ expect( anchor ).toHaveFocus();
173
+
174
+ const tooltip = await screen.findByRole( 'tooltip', {
175
+ name: 'Tooltip text',
176
+ } );
177
+
178
+ expect( tooltip ).toBeVisible();
179
+ // Check that the tooltip that would be normally rendered internally by
180
+ // the `Button` component is ignored, because of an outer tooltip.
181
+ expect(
182
+ screen.queryByRole( 'tooltip', {
183
+ name: 'Button label',
184
+ } )
185
+ ).not.toBeInTheDocument();
186
+
187
+ await user.tab();
188
+
189
+ expect(
190
+ screen.getByRole( 'button', { name: 'Focus me' } )
191
+ ).toHaveFocus();
192
+
193
+ expect(
194
+ screen.queryByRole( 'tooltip', {
195
+ name: 'Tooltip text',
196
+ } )
197
+ ).not.toBeInTheDocument();
198
+ } );
199
+
200
+ it( 'should not trash the rendered HTML elements when toggling between showing and not showing a tooltip', async () => {
201
+ const user = userEvent.setup();
202
+
203
+ const { rerender } = render(
204
+ <Button label="Button label">Test button</Button>
205
+ );
206
+
207
+ const button = screen.getByRole( 'button', {
208
+ name: 'Button label',
209
+ } );
210
+
211
+ expect( button ).toBeVisible();
212
+
213
+ await user.tab();
214
+
215
+ expect( button ).toHaveFocus();
216
+
217
+ // Re-render the button, but this time change the settings so that it
218
+ // shows a tooltip.
219
+ rerender(
220
+ <Button label="Button label" showTooltip>
221
+ Test button
222
+ </Button>
223
+ );
224
+
225
+ // The same button element that we referenced before should still be
226
+ // in the document and have focus.
227
+ expect( button ).toHaveFocus();
228
+
229
+ // Re-render the button, but stop showing a tooltip.
230
+ rerender( <Button label="Button label">Test button</Button> );
231
+
232
+ // The same button element that we referenced before should still be
233
+ // in the document and have focus.
234
+ expect( button ).toHaveFocus();
235
+ } );
236
+
115
237
  it( 'should add a disabled prop to the button', () => {
116
238
  render( <Button disabled /> );
117
239
 
@@ -115,7 +115,9 @@ type BaseButtonProps = {
115
115
  */
116
116
  variant?: 'primary' | 'secondary' | 'tertiary' | 'link';
117
117
  /**
118
- * Whether this is focusable.
118
+ * Whether to keep the button focusable when disabled.
119
+ *
120
+ * @default false
119
121
  */
120
122
  __experimentalIsFocusable?: boolean;
121
123
  };
@@ -123,7 +125,8 @@ type BaseButtonProps = {
123
125
  type _ButtonProps = {
124
126
  /**
125
127
  * Whether the button is disabled.
126
- * If `true`, this will force a `button` element to be rendered.
128
+ *
129
+ * If `true`, this will force a `button` element to be rendered, even when an `href` is given.
127
130
  */
128
131
  disabled?: boolean;
129
132
  };
@@ -131,7 +134,8 @@ type _ButtonProps = {
131
134
  type AnchorProps = {
132
135
  /**
133
136
  * Whether the button is disabled.
134
- * If `true`, this will force a `button` element to be rendered.
137
+ *
138
+ * If `true`, this will force a `button` element to be rendered, even when an `href` is given.
135
139
  */
136
140
  disabled?: false;
137
141
  /**
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { render, screen } from '@testing-library/react';
5
- import userEvent from '@testing-library/user-event';
5
+ import { press } from '@ariakit/test';
6
6
 
7
7
  /**
8
8
  * Internal dependencies
@@ -71,8 +71,6 @@ describe( 'CircularOptionPicker', () => {
71
71
 
72
72
  describe( 'when `loop` is not set', () => {
73
73
  it( 'should loop', async () => {
74
- const user = userEvent.setup();
75
-
76
74
  render(
77
75
  <CircularOptionPicker
78
76
  { ...DEFAULT_PROPS }
@@ -80,19 +78,17 @@ describe( 'CircularOptionPicker', () => {
80
78
  />
81
79
  );
82
80
 
83
- await user.tab();
81
+ await press.Tab();
84
82
  expect( getOption( 'Option One' ) ).toHaveFocus();
85
- await user.keyboard( '[ArrowRight]' );
83
+ await press.ArrowRight();
86
84
  expect( getOption( 'Option Two' ) ).toHaveFocus();
87
- await user.keyboard( '[ArrowRight]' );
85
+ await press.ArrowRight();
88
86
  expect( getOption( 'Option One' ) ).toHaveFocus();
89
87
  } );
90
88
  } );
91
89
 
92
90
  describe( 'when `loop` is true', () => {
93
91
  it( 'should loop', async () => {
94
- const user = userEvent.setup();
95
-
96
92
  render(
97
93
  <CircularOptionPicker
98
94
  { ...DEFAULT_PROPS }
@@ -101,19 +97,17 @@ describe( 'CircularOptionPicker', () => {
101
97
  />
102
98
  );
103
99
 
104
- await user.tab();
100
+ await press.Tab();
105
101
  expect( getOption( 'Option One' ) ).toHaveFocus();
106
- await user.keyboard( '[ArrowRight]' );
102
+ await press.ArrowRight();
107
103
  expect( getOption( 'Option Two' ) ).toHaveFocus();
108
- await user.keyboard( '[ArrowRight]' );
104
+ await press.ArrowRight();
109
105
  expect( getOption( 'Option One' ) ).toHaveFocus();
110
106
  } );
111
107
  } );
112
108
 
113
109
  describe( 'when `loop` is false', () => {
114
110
  it( 'should not loop', async () => {
115
- const user = userEvent.setup();
116
-
117
111
  render(
118
112
  <CircularOptionPicker
119
113
  { ...DEFAULT_PROPS }
@@ -122,11 +116,11 @@ describe( 'CircularOptionPicker', () => {
122
116
  />
123
117
  );
124
118
 
125
- await user.tab();
119
+ await press.Tab();
126
120
  expect( getOption( 'Option One' ) ).toHaveFocus();
127
- await user.keyboard( '[ArrowRight]' );
121
+ await press.ArrowRight();
128
122
  expect( getOption( 'Option Two' ) ).toHaveFocus();
129
- await user.keyboard( '[ArrowRight]' );
123
+ await press.ArrowRight();
130
124
  expect( getOption( 'Option Two' ) ).toHaveFocus();
131
125
  } );
132
126
  } );