@wordpress/components 25.15.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 (236) hide show
  1. package/CHANGELOG.md +26 -0
  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-palette/index.native.js +11 -7
  34. package/build/color-palette/index.native.js.map +1 -1
  35. package/build/color-picker/hsl-input.js +55 -33
  36. package/build/color-picker/hsl-input.js.map +1 -1
  37. package/build/custom-select-control-v2/index.js +3 -2
  38. package/build/custom-select-control-v2/index.js.map +1 -1
  39. package/build/mobile/color-settings/palette.screen.native.js +8 -4
  40. package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
  41. package/build/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
  42. package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
  43. package/build/theme/styles.js +11 -6
  44. package/build/theme/styles.js.map +1 -1
  45. package/build/toggle-group-control/toggle-group-control/utils.js +7 -1
  46. package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  47. package/build/tooltip/index.js +35 -8
  48. package/build/tooltip/index.js.map +1 -1
  49. package/build/tooltip/types.js.map +1 -1
  50. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  51. package/build-module/border-box-control/border-box-control/hook.js +3 -1
  52. package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
  53. package/build-module/border-box-control/types.js.map +1 -1
  54. package/build-module/border-control/border-control/component.js +5 -1
  55. package/build-module/border-control/border-control/component.js.map +1 -1
  56. package/build-module/border-control/border-control/hook.js +18 -15
  57. package/build-module/border-control/border-control/hook.js.map +1 -1
  58. package/build-module/border-control/border-control-dropdown/component.js +2 -1
  59. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  60. package/build-module/border-control/border-control-style-picker/component.js +21 -48
  61. package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
  62. package/build-module/border-control/styles.js +14 -24
  63. package/build-module/border-control/styles.js.map +1 -1
  64. package/build-module/border-control/types.js.map +1 -1
  65. package/build-module/box-control/all-input-control.js +38 -28
  66. package/build-module/box-control/all-input-control.js.map +1 -1
  67. package/build-module/box-control/axial-input-controls.js +42 -57
  68. package/build-module/box-control/axial-input-controls.js.map +1 -1
  69. package/build-module/box-control/index.js +22 -25
  70. package/build-module/box-control/index.js.map +1 -1
  71. package/build-module/box-control/input-controls.js +47 -40
  72. package/build-module/box-control/input-controls.js.map +1 -1
  73. package/build-module/box-control/styles/box-control-styles.js +45 -105
  74. package/build-module/box-control/styles/box-control-styles.js.map +1 -1
  75. package/build-module/box-control/types.js.map +1 -1
  76. package/build-module/box-control/utils.js +121 -7
  77. package/build-module/box-control/utils.js.map +1 -1
  78. package/build-module/button/index.js +14 -16
  79. package/build-module/button/index.js.map +1 -1
  80. package/build-module/button/types.js.map +1 -1
  81. package/build-module/color-palette/index.native.js +11 -7
  82. package/build-module/color-palette/index.native.js.map +1 -1
  83. package/build-module/color-picker/hsl-input.js +55 -33
  84. package/build-module/color-picker/hsl-input.js.map +1 -1
  85. package/build-module/custom-select-control-v2/index.js +3 -2
  86. package/build-module/custom-select-control-v2/index.js.map +1 -1
  87. package/build-module/mobile/color-settings/palette.screen.native.js +8 -4
  88. package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
  89. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
  90. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
  91. package/build-module/theme/styles.js +11 -2
  92. package/build-module/theme/styles.js.map +1 -1
  93. package/build-module/toggle-group-control/toggle-group-control/utils.js +7 -1
  94. package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  95. package/build-module/tooltip/index.js +34 -9
  96. package/build-module/tooltip/index.js.map +1 -1
  97. package/build-module/tooltip/types.js.map +1 -1
  98. package/build-style/style-rtl.css +6 -4
  99. package/build-style/style.css +6 -4
  100. package/build-types/border-box-control/border-box-control/component.d.ts +1 -0
  101. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  102. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  103. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +3 -3
  104. package/build-types/border-box-control/stories/index.story.d.ts +2 -1
  105. package/build-types/border-box-control/stories/index.story.d.ts.map +1 -1
  106. package/build-types/border-box-control/types.d.ts +6 -0
  107. package/build-types/border-box-control/types.d.ts.map +1 -1
  108. package/build-types/border-control/border-control/component.d.ts +1 -0
  109. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  110. package/build-types/border-control/border-control/hook.d.ts +2 -0
  111. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  112. package/build-types/border-control/border-control-dropdown/component.d.ts +1 -0
  113. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  114. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
  115. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  116. package/build-types/border-control/border-control-style-picker/component.d.ts +3 -4
  117. package/build-types/border-control/border-control-style-picker/component.d.ts.map +1 -1
  118. package/build-types/border-control/stories/index.story.d.ts +12 -6
  119. package/build-types/border-control/stories/index.story.d.ts.map +1 -1
  120. package/build-types/border-control/styles.d.ts +0 -2
  121. package/build-types/border-control/styles.d.ts.map +1 -1
  122. package/build-types/border-control/types.d.ts +12 -1
  123. package/build-types/border-control/types.d.ts.map +1 -1
  124. package/build-types/box-control/all-input-control.d.ts +1 -1
  125. package/build-types/box-control/all-input-control.d.ts.map +1 -1
  126. package/build-types/box-control/axial-input-controls.d.ts +1 -1
  127. package/build-types/box-control/axial-input-controls.d.ts.map +1 -1
  128. package/build-types/box-control/index.d.ts +1 -1
  129. package/build-types/box-control/index.d.ts.map +1 -1
  130. package/build-types/box-control/input-controls.d.ts +1 -1
  131. package/build-types/box-control/input-controls.d.ts.map +1 -1
  132. package/build-types/box-control/stories/index.story.d.ts +24 -18
  133. package/build-types/box-control/stories/index.story.d.ts.map +1 -1
  134. package/build-types/box-control/styles/box-control-styles.d.ts +49 -23
  135. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
  136. package/build-types/box-control/types.d.ts +12 -12
  137. package/build-types/box-control/types.d.ts.map +1 -1
  138. package/build-types/box-control/utils.d.ts +2 -1
  139. package/build-types/box-control/utils.d.ts.map +1 -1
  140. package/build-types/button/deprecated.d.ts +1 -1
  141. package/build-types/button/index.d.ts.map +1 -1
  142. package/build-types/button/types.d.ts +7 -3
  143. package/build-types/button/types.d.ts.map +1 -1
  144. package/build-types/color-picker/hsl-input.d.ts.map +1 -1
  145. package/build-types/color-picker/styles.d.ts +1 -1
  146. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  147. package/build-types/date-time/time/styles.d.ts +4 -4
  148. package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
  149. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  150. package/build-types/navigation/styles/navigation-styles.d.ts +1 -1
  151. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
  152. package/build-types/navigator/navigator-button/hook.d.ts +2 -2
  153. package/build-types/number-control/index.d.ts +1 -1
  154. package/build-types/number-control/stories/index.story.d.ts +1 -1
  155. package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
  156. package/build-types/search-control/index.d.ts +1 -1
  157. package/build-types/search-control/stories/index.story.d.ts +2 -2
  158. package/build-types/text-control/index.d.ts +1 -1
  159. package/build-types/textarea-control/index.d.ts +1 -1
  160. package/build-types/theme/styles.d.ts.map +1 -1
  161. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +1 -1
  162. package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +1 -1
  163. package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -1
  164. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
  165. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
  166. package/build-types/toolbar/toolbar-button/index.d.ts +1 -1
  167. package/build-types/tooltip/index.d.ts +1 -1
  168. package/build-types/tooltip/index.d.ts.map +1 -1
  169. package/build-types/tooltip/stories/index.story.d.ts +10 -1
  170. package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
  171. package/build-types/tooltip/types.d.ts +3 -0
  172. package/build-types/tooltip/types.d.ts.map +1 -1
  173. package/build-types/unit-control/index.d.ts +1 -1
  174. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
  175. package/package.json +19 -19
  176. package/src/border-box-control/border-box-control/component.tsx +0 -1
  177. package/src/border-box-control/border-box-control/hook.ts +5 -1
  178. package/src/border-box-control/types.ts +6 -0
  179. package/src/border-control/border-control/component.tsx +4 -0
  180. package/src/border-control/border-control/hook.ts +22 -16
  181. package/src/border-control/border-control-dropdown/component.tsx +2 -1
  182. package/src/border-control/border-control-style-picker/component.tsx +31 -66
  183. package/src/border-control/styles.ts +0 -15
  184. package/src/border-control/types.ts +15 -1
  185. package/src/box-control/all-input-control.tsx +57 -34
  186. package/src/box-control/axial-input-controls.tsx +79 -69
  187. package/src/box-control/index.tsx +47 -54
  188. package/src/box-control/input-controls.tsx +114 -83
  189. package/src/box-control/styles/box-control-styles.ts +21 -61
  190. package/src/box-control/test/index.tsx +126 -18
  191. package/src/box-control/types.ts +10 -21
  192. package/src/box-control/utils.ts +43 -8
  193. package/src/button/README.md +1 -1
  194. package/src/button/index.tsx +21 -33
  195. package/src/button/test/index.tsx +122 -0
  196. package/src/button/types.ts +7 -3
  197. package/src/circular-option-picker/test/index.tsx +10 -16
  198. package/src/color-palette/index.native.js +18 -7
  199. package/src/color-picker/hsl-input.tsx +56 -30
  200. package/src/color-picker/test/index.tsx +190 -16
  201. package/src/custom-select-control-v2/index.tsx +5 -2
  202. package/src/mobile/color-settings/palette.screen.native.js +7 -5
  203. package/src/palette-edit/test/index.tsx +326 -10
  204. package/src/slot-fill/bubbles-virtually/use-slot-fills.ts +1 -1
  205. package/src/tabs/test/index.tsx +3 -1
  206. package/src/theme/styles.ts +3 -1
  207. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +6 -6
  208. package/src/toggle-group-control/test/index.tsx +73 -36
  209. package/src/toggle-group-control/toggle-group-control/utils.ts +8 -3
  210. package/src/tooltip/README.md +4 -0
  211. package/src/tooltip/index.tsx +46 -8
  212. package/src/tooltip/stories/index.story.tsx +18 -1
  213. package/src/tooltip/test/index.tsx +77 -12
  214. package/src/tooltip/types.ts +4 -0
  215. package/tsconfig.tsbuildinfo +1 -1
  216. package/build/border-control/border-control-style-picker/hook.js +0 -41
  217. package/build/border-control/border-control-style-picker/hook.js.map +0 -1
  218. package/build/box-control/styles/box-control-visualizer-styles.js +0 -93
  219. package/build/box-control/styles/box-control-visualizer-styles.js.map +0 -1
  220. package/build/box-control/unit-control.js +0 -76
  221. package/build/box-control/unit-control.js.map +0 -1
  222. package/build-module/border-control/border-control-style-picker/hook.js +0 -32
  223. package/build-module/border-control/border-control-style-picker/hook.js.map +0 -1
  224. package/build-module/box-control/styles/box-control-visualizer-styles.js +0 -86
  225. package/build-module/box-control/styles/box-control-visualizer-styles.js.map +0 -1
  226. package/build-module/box-control/unit-control.js +0 -68
  227. package/build-module/box-control/unit-control.js.map +0 -1
  228. package/build-types/border-control/border-control-style-picker/hook.d.ts +0 -267
  229. package/build-types/border-control/border-control-style-picker/hook.d.ts.map +0 -1
  230. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +0 -46
  231. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +0 -1
  232. package/build-types/box-control/unit-control.d.ts +0 -4
  233. package/build-types/box-control/unit-control.d.ts.map +0 -1
  234. package/src/border-control/border-control-style-picker/hook.ts +0 -35
  235. package/src/box-control/styles/box-control-visualizer-styles.ts +0 -75
  236. package/src/box-control/unit-control.tsx +0 -74
@@ -1,42 +1,56 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useInstanceId } from '@wordpress/compose';
1
5
  /**
2
6
  * Internal dependencies
3
7
  */
4
8
  import type { UnitControlProps } from '../unit-control/types';
9
+ import {
10
+ FlexedRangeControl,
11
+ StyledUnitControl,
12
+ } from './styles/box-control-styles';
13
+ import { HStack } from '../h-stack';
5
14
  import type { BoxControlInputControlProps } from './types';
6
- import UnitControl from './unit-control';
15
+ import { parseQuantityAndUnitFromRawValue } from '../unit-control';
7
16
  import {
8
17
  LABELS,
9
18
  applyValueToSides,
10
19
  getAllValue,
11
20
  isValuesMixed,
12
21
  isValuesDefined,
22
+ CUSTOM_VALUE_SETTINGS,
13
23
  } from './utils';
14
24
 
15
25
  const noop = () => {};
16
26
 
17
27
  export default function AllInputControl( {
28
+ __next40pxDefaultSize,
18
29
  onChange = noop,
19
30
  onFocus = noop,
20
- onHoverOn = noop,
21
- onHoverOff = noop,
22
31
  values,
23
32
  sides,
24
33
  selectedUnits,
25
34
  setSelectedUnits,
26
35
  ...props
27
36
  }: BoxControlInputControlProps ) {
37
+ const inputId = useInstanceId( AllInputControl, 'box-control-input-all' );
38
+
28
39
  const allValue = getAllValue( values, selectedUnits, sides );
29
40
  const hasValues = isValuesDefined( values );
30
41
  const isMixed = hasValues && isValuesMixed( values, selectedUnits, sides );
31
42
  const allPlaceholder = isMixed ? LABELS.mixed : undefined;
32
43
 
44
+ const [ parsedQuantity, parsedUnit ] =
45
+ parseQuantityAndUnitFromRawValue( allValue );
46
+
33
47
  const handleOnFocus: React.FocusEventHandler< HTMLInputElement > = (
34
48
  event
35
49
  ) => {
36
50
  onFocus( event, { side: 'all' } );
37
51
  };
38
52
 
39
- const handleOnChange: UnitControlProps[ 'onChange' ] = ( next ) => {
53
+ const onValueChange = ( next?: string ) => {
40
54
  const isNumeric = next !== undefined && ! isNaN( parseFloat( next ) );
41
55
  const nextValue = isNumeric ? next : undefined;
42
56
  const nextValues = applyValueToSides( values, nextValue, sides );
@@ -44,6 +58,12 @@ export default function AllInputControl( {
44
58
  onChange( nextValues );
45
59
  };
46
60
 
61
+ const sliderOnChange = ( next?: number ) => {
62
+ onValueChange(
63
+ next !== undefined ? [ next, parsedUnit ].join( '' ) : undefined
64
+ );
65
+ };
66
+
47
67
  // Set selected unit so it can be used as fallback by unlinked controls
48
68
  // when individual sides do not have a value containing a unit.
49
69
  const handleOnUnitChange: UnitControlProps[ 'onUnitChange' ] = ( unit ) => {
@@ -51,36 +71,39 @@ export default function AllInputControl( {
51
71
  setSelectedUnits( newUnits );
52
72
  };
53
73
 
54
- const handleOnHoverOn = () => {
55
- onHoverOn( {
56
- top: true,
57
- bottom: true,
58
- left: true,
59
- right: true,
60
- } );
61
- };
62
-
63
- const handleOnHoverOff = () => {
64
- onHoverOff( {
65
- top: false,
66
- bottom: false,
67
- left: false,
68
- right: false,
69
- } );
70
- };
71
-
72
74
  return (
73
- <UnitControl
74
- { ...props }
75
- disableUnits={ isMixed }
76
- isOnly
77
- value={ allValue }
78
- onChange={ handleOnChange }
79
- onUnitChange={ handleOnUnitChange }
80
- onFocus={ handleOnFocus }
81
- onHoverOn={ handleOnHoverOn }
82
- onHoverOff={ handleOnHoverOff }
83
- placeholder={ allPlaceholder }
84
- />
75
+ <HStack>
76
+ <StyledUnitControl
77
+ { ...props }
78
+ __next40pxDefaultSize={ __next40pxDefaultSize }
79
+ className="component-box-control__unit-control"
80
+ disableUnits={ isMixed }
81
+ id={ inputId }
82
+ isPressEnterToChange
83
+ value={ allValue }
84
+ onChange={ onValueChange }
85
+ onUnitChange={ handleOnUnitChange }
86
+ onFocus={ handleOnFocus }
87
+ placeholder={ allPlaceholder }
88
+ label={ LABELS.all }
89
+ hideLabelFromVision
90
+ />
91
+
92
+ <FlexedRangeControl
93
+ __nextHasNoMarginBottom
94
+ __next40pxDefaultSize={ __next40pxDefaultSize }
95
+ aria-controls={ inputId }
96
+ label={ LABELS.all }
97
+ hideLabelFromVision
98
+ onChange={ sliderOnChange }
99
+ min={ 0 }
100
+ max={ CUSTOM_VALUE_SETTINGS[ parsedUnit ?? 'px' ]?.max ?? 10 }
101
+ step={
102
+ CUSTOM_VALUE_SETTINGS[ parsedUnit ?? 'px' ]?.step ?? 0.1
103
+ }
104
+ value={ parsedQuantity ?? 0 }
105
+ withInputField={ false }
106
+ />
107
+ </HStack>
85
108
  );
86
109
  }
@@ -1,26 +1,39 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useInstanceId } from '@wordpress/compose';
1
5
  /**
2
6
  * Internal dependencies
3
7
  */
4
8
  import { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';
5
- import UnitControl from './unit-control';
6
- import { LABELS } from './utils';
7
- import { Layout } from './styles/box-control-styles';
9
+ import Tooltip from '../tooltip';
10
+ import { CUSTOM_VALUE_SETTINGS, LABELS } from './utils';
11
+ import {
12
+ FlexedBoxControlIcon,
13
+ FlexedRangeControl,
14
+ InputWrapper,
15
+ StyledUnitControl,
16
+ } from './styles/box-control-styles';
8
17
  import type { BoxControlInputControlProps } from './types';
9
18
 
10
19
  const groupedSides = [ 'vertical', 'horizontal' ] as const;
11
20
  type GroupedSide = ( typeof groupedSides )[ number ];
12
21
 
13
22
  export default function AxialInputControls( {
23
+ __next40pxDefaultSize,
14
24
  onChange,
15
25
  onFocus,
16
- onHoverOn,
17
- onHoverOff,
18
26
  values,
19
27
  selectedUnits,
20
28
  setSelectedUnits,
21
29
  sides,
22
30
  ...props
23
31
  }: BoxControlInputControlProps ) {
32
+ const generatedId = useInstanceId(
33
+ AxialInputControls,
34
+ `box-control-input`
35
+ );
36
+
24
37
  const createHandleOnFocus =
25
38
  ( side: GroupedSide ) =>
26
39
  ( event: React.FocusEvent< HTMLInputElement > ) => {
@@ -30,43 +43,7 @@ export default function AxialInputControls( {
30
43
  onFocus( event, { side } );
31
44
  };
32
45
 
33
- const createHandleOnHoverOn = ( side: GroupedSide ) => () => {
34
- if ( ! onHoverOn ) {
35
- return;
36
- }
37
- if ( side === 'vertical' ) {
38
- onHoverOn( {
39
- top: true,
40
- bottom: true,
41
- } );
42
- }
43
- if ( side === 'horizontal' ) {
44
- onHoverOn( {
45
- left: true,
46
- right: true,
47
- } );
48
- }
49
- };
50
-
51
- const createHandleOnHoverOff = ( side: GroupedSide ) => () => {
52
- if ( ! onHoverOff ) {
53
- return;
54
- }
55
- if ( side === 'vertical' ) {
56
- onHoverOff( {
57
- top: false,
58
- bottom: false,
59
- } );
60
- }
61
- if ( side === 'horizontal' ) {
62
- onHoverOff( {
63
- left: false,
64
- right: false,
65
- } );
66
- }
67
- };
68
-
69
- const createHandleOnChange = ( side: GroupedSide ) => ( next?: string ) => {
46
+ const handleOnValueChange = ( side: GroupedSide, next?: string ) => {
70
47
  if ( ! onChange ) {
71
48
  return;
72
49
  }
@@ -109,16 +86,8 @@ export default function AxialInputControls( {
109
86
  ? groupedSides.filter( ( side ) => sides.includes( side ) )
110
87
  : groupedSides;
111
88
 
112
- const first = filteredSides[ 0 ];
113
- const last = filteredSides[ filteredSides.length - 1 ];
114
- const only = first === last && first;
115
-
116
89
  return (
117
- <Layout
118
- gap={ 0 }
119
- align="top"
120
- className="component-box-control__vertical-horizontal-input-controls"
121
- >
90
+ <>
122
91
  { filteredSides.map( ( side ) => {
123
92
  const [ parsedQuantity, parsedUnit ] =
124
93
  parseQuantityAndUnitFromRawValue(
@@ -128,26 +97,67 @@ export default function AxialInputControls( {
128
97
  side === 'vertical'
129
98
  ? selectedUnits.top
130
99
  : selectedUnits.left;
100
+
101
+ const inputId = [ generatedId, side ].join( '-' );
102
+
131
103
  return (
132
- <UnitControl
133
- { ...props }
134
- isFirst={ first === side }
135
- isLast={ last === side }
136
- isOnly={ only === side }
137
- value={ [
138
- parsedQuantity,
139
- selectedUnit ?? parsedUnit,
140
- ].join( '' ) }
141
- onChange={ createHandleOnChange( side ) }
142
- onUnitChange={ createHandleOnUnitChange( side ) }
143
- onFocus={ createHandleOnFocus( side ) }
144
- onHoverOn={ createHandleOnHoverOn( side ) }
145
- onHoverOff={ createHandleOnHoverOff( side ) }
146
- label={ LABELS[ side ] }
147
- key={ side }
148
- />
104
+ <InputWrapper key={ side }>
105
+ <FlexedBoxControlIcon side={ side } sides={ sides } />
106
+ <Tooltip placement="top-end" text={ LABELS[ side ] }>
107
+ <StyledUnitControl
108
+ { ...props }
109
+ __next40pxDefaultSize={ __next40pxDefaultSize }
110
+ className="component-box-control__unit-control"
111
+ id={ inputId }
112
+ isPressEnterToChange
113
+ value={ [
114
+ parsedQuantity,
115
+ selectedUnit ?? parsedUnit,
116
+ ].join( '' ) }
117
+ onChange={ ( newValue ) =>
118
+ handleOnValueChange( side, newValue )
119
+ }
120
+ onUnitChange={ createHandleOnUnitChange(
121
+ side
122
+ ) }
123
+ onFocus={ createHandleOnFocus( side ) }
124
+ label={ LABELS[ side ] }
125
+ hideLabelFromVision
126
+ key={ side }
127
+ />
128
+ </Tooltip>
129
+ <FlexedRangeControl
130
+ __nextHasNoMarginBottom
131
+ __next40pxDefaultSize={ __next40pxDefaultSize }
132
+ aria-controls={ inputId }
133
+ label={ LABELS[ side ] }
134
+ hideLabelFromVision
135
+ onChange={ ( newValue ) =>
136
+ handleOnValueChange(
137
+ side,
138
+ newValue !== undefined
139
+ ? [
140
+ newValue,
141
+ selectedUnit ?? parsedUnit,
142
+ ].join( '' )
143
+ : undefined
144
+ )
145
+ }
146
+ min={ 0 }
147
+ max={
148
+ CUSTOM_VALUE_SETTINGS[ selectedUnit ?? 'px' ]
149
+ ?.max ?? 10
150
+ }
151
+ step={
152
+ CUSTOM_VALUE_SETTINGS[ selectedUnit ?? 'px' ]
153
+ ?.step ?? 0.1
154
+ }
155
+ value={ parsedQuantity ?? 0 }
156
+ withInputField={ false }
157
+ />
158
+ </InputWrapper>
149
159
  );
150
160
  } ) }
151
- </Layout>
161
+ </>
152
162
  );
153
163
  }
@@ -9,17 +9,16 @@ import { __ } from '@wordpress/i18n';
9
9
  * Internal dependencies
10
10
  */
11
11
  import { BaseControl } from '../base-control';
12
- import Button from '../button';
13
- import { FlexItem, FlexBlock } from '../flex';
14
12
  import AllInputControl from './all-input-control';
15
13
  import InputControls from './input-controls';
16
14
  import AxialInputControls from './axial-input-controls';
17
- import BoxControlIcon from './icon';
18
15
  import LinkedButton from './linked-button';
16
+ import { Grid } from '../grid';
19
17
  import {
20
- Root,
21
- Header,
22
- HeaderControlWrapper,
18
+ FlexedBoxControlIcon,
19
+ InputWrapper,
20
+ ResetButton,
21
+ LinkedButtonWrapper,
23
22
  } from './styles/box-control-styles';
24
23
  import { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';
25
24
  import {
@@ -73,6 +72,7 @@ function useUniqueId( idProp?: string ) {
73
72
  * ```
74
73
  */
75
74
  function BoxControl( {
75
+ __next40pxDefaultSize = false,
76
76
  id: idProp,
77
77
  inputProps = defaultInputProps,
78
78
  onChange = noop,
@@ -152,60 +152,53 @@ function BoxControl( {
152
152
  values: inputValues,
153
153
  onMouseOver,
154
154
  onMouseOut,
155
+ __next40pxDefaultSize,
155
156
  };
156
157
 
157
158
  return (
158
- <Root id={ id } role="group" aria-labelledby={ headingId }>
159
- <Header className="component-box-control__header">
160
- <FlexItem>
161
- <BaseControl.VisualLabel id={ headingId }>
162
- { label }
163
- </BaseControl.VisualLabel>
164
- </FlexItem>
165
- { allowReset && (
166
- <FlexItem>
167
- <Button
168
- className="component-box-control__reset-button"
169
- variant="secondary"
170
- size="small"
171
- onClick={ handleOnReset }
172
- disabled={ ! isDirty }
173
- >
174
- { __( 'Reset' ) }
175
- </Button>
176
- </FlexItem>
177
- ) }
178
- </Header>
179
- <HeaderControlWrapper className="component-box-control__header-control-wrapper">
180
- <FlexItem>
181
- <BoxControlIcon side={ side } sides={ sides } />
182
- </FlexItem>
183
- { isLinked && (
184
- <FlexBlock>
185
- <AllInputControl
186
- aria-label={ label }
187
- { ...inputControlProps }
188
- />
189
- </FlexBlock>
190
- ) }
191
- { ! isLinked && splitOnAxis && (
192
- <FlexBlock>
193
- <AxialInputControls { ...inputControlProps } />
194
- </FlexBlock>
195
- ) }
196
- { ! hasOneSide && (
197
- <FlexItem>
198
- <LinkedButton
199
- onClick={ toggleLinked }
200
- isLinked={ isLinked }
201
- />
202
- </FlexItem>
203
- ) }
204
- </HeaderControlWrapper>
159
+ <Grid
160
+ id={ id }
161
+ columns={ 3 }
162
+ templateColumns="1fr min-content min-content"
163
+ role="group"
164
+ aria-labelledby={ headingId }
165
+ >
166
+ <BaseControl.VisualLabel id={ headingId }>
167
+ { label }
168
+ </BaseControl.VisualLabel>
169
+ { isLinked && (
170
+ <InputWrapper>
171
+ <FlexedBoxControlIcon side={ side } sides={ sides } />
172
+ <AllInputControl { ...inputControlProps } />
173
+ </InputWrapper>
174
+ ) }
175
+ { ! hasOneSide && (
176
+ <LinkedButtonWrapper>
177
+ <LinkedButton
178
+ onClick={ toggleLinked }
179
+ isLinked={ isLinked }
180
+ />
181
+ </LinkedButtonWrapper>
182
+ ) }
183
+
184
+ { ! isLinked && splitOnAxis && (
185
+ <AxialInputControls { ...inputControlProps } />
186
+ ) }
205
187
  { ! isLinked && ! splitOnAxis && (
206
188
  <InputControls { ...inputControlProps } />
207
189
  ) }
208
- </Root>
190
+ { allowReset && (
191
+ <ResetButton
192
+ className="component-box-control__reset-button"
193
+ variant="secondary"
194
+ size="small"
195
+ onClick={ handleOnReset }
196
+ disabled={ ! isDirty }
197
+ >
198
+ { __( 'Reset' ) }
199
+ </ResetButton>
200
+ ) }
201
+ </Grid>
209
202
  );
210
203
  }
211
204