@wordpress/components 21.0.1 → 21.1.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 (103) hide show
  1. package/CHANGELOG.md +16 -7
  2. package/build/autocomplete/get-default-use-items.js +3 -3
  3. package/build/autocomplete/get-default-use-items.js.map +1 -1
  4. package/build/box-control/unit-control.js +0 -1
  5. package/build/box-control/unit-control.js.map +1 -1
  6. package/build/button/index.js +5 -1
  7. package/build/button/index.js.map +1 -1
  8. package/build/drop-zone/index.js +7 -1
  9. package/build/drop-zone/index.js.map +1 -1
  10. package/build/higher-order/with-filters/index.js +1 -1
  11. package/build/higher-order/with-filters/index.js.map +1 -1
  12. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -3
  13. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  14. package/build/mobile/link-picker/link-picker-results.native.js +3 -3
  15. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  16. package/build/range-control/input-range.js +1 -15
  17. package/build/range-control/input-range.js.map +1 -1
  18. package/build/range-control/tooltip.js +1 -1
  19. package/build/range-control/tooltip.js.map +1 -1
  20. package/build/range-control/utils.js +2 -58
  21. package/build/range-control/utils.js.map +1 -1
  22. package/build/tree-grid/index.js +13 -8
  23. package/build/tree-grid/index.js.map +1 -1
  24. package/build/unit-control/index.js +2 -2
  25. package/build/unit-control/index.js.map +1 -1
  26. package/build/unit-control/index.native.js +10 -2
  27. package/build/unit-control/index.native.js.map +1 -1
  28. package/build/unit-control/styles/unit-control-styles.js +21 -32
  29. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  30. package/build/utils/hooks/use-controlled-state.js +2 -3
  31. package/build/utils/hooks/use-controlled-state.js.map +1 -1
  32. package/build-module/autocomplete/get-default-use-items.js +1 -1
  33. package/build-module/autocomplete/get-default-use-items.js.map +1 -1
  34. package/build-module/box-control/unit-control.js +0 -1
  35. package/build-module/box-control/unit-control.js.map +1 -1
  36. package/build-module/button/index.js +5 -1
  37. package/build-module/button/index.js.map +1 -1
  38. package/build-module/drop-zone/index.js +7 -1
  39. package/build-module/drop-zone/index.js.map +1 -1
  40. package/build-module/higher-order/with-filters/index.js +2 -2
  41. package/build-module/higher-order/with-filters/index.js.map +1 -1
  42. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
  43. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  44. package/build-module/mobile/link-picker/link-picker-results.native.js +1 -1
  45. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  46. package/build-module/range-control/input-range.js +1 -14
  47. package/build-module/range-control/input-range.js.map +1 -1
  48. package/build-module/range-control/tooltip.js +1 -1
  49. package/build-module/range-control/tooltip.js.map +1 -1
  50. package/build-module/range-control/utils.js +2 -57
  51. package/build-module/range-control/utils.js.map +1 -1
  52. package/build-module/tree-grid/index.js +13 -8
  53. package/build-module/tree-grid/index.js.map +1 -1
  54. package/build-module/unit-control/index.js +2 -2
  55. package/build-module/unit-control/index.js.map +1 -1
  56. package/build-module/unit-control/index.native.js +10 -2
  57. package/build-module/unit-control/index.native.js.map +1 -1
  58. package/build-module/unit-control/styles/unit-control-styles.js +20 -31
  59. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  60. package/build-module/utils/hooks/use-controlled-state.js +3 -4
  61. package/build-module/utils/hooks/use-controlled-state.js.map +1 -1
  62. package/build-types/button/index.d.ts.map +1 -1
  63. package/build-types/drop-zone/index.d.ts.map +1 -1
  64. package/build-types/popover/stories/e2e/index.d.ts +8 -0
  65. package/build-types/popover/stories/e2e/index.d.ts.map +1 -0
  66. package/build-types/range-control/input-range.d.ts.map +1 -1
  67. package/build-types/range-control/stories/index.d.ts.map +1 -1
  68. package/build-types/range-control/types.d.ts +0 -2
  69. package/build-types/range-control/types.d.ts.map +1 -1
  70. package/build-types/range-control/utils.d.ts +1 -12
  71. package/build-types/range-control/utils.d.ts.map +1 -1
  72. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -4
  73. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  74. package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
  75. package/package.json +17 -17
  76. package/src/autocomplete/get-default-use-items.js +1 -1
  77. package/src/box-control/unit-control.js +0 -1
  78. package/src/button/index.js +7 -1
  79. package/src/button/test/index.js +36 -0
  80. package/src/color-palette/test/__snapshots__/index.js.snap +169 -1106
  81. package/src/color-palette/test/index.js +107 -61
  82. package/src/drop-zone/index.tsx +4 -1
  83. package/src/font-size-picker/stories/e2e/index.js +47 -0
  84. package/src/higher-order/with-filters/index.js +2 -2
  85. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -2
  86. package/src/mobile/link-picker/link-picker-results.native.js +1 -1
  87. package/src/popover/stories/e2e/index.tsx +25 -0
  88. package/src/range-control/README.md +6 -7
  89. package/src/range-control/input-range.tsx +1 -21
  90. package/src/range-control/stories/index.tsx +2 -1
  91. package/src/range-control/tooltip.tsx +1 -1
  92. package/src/range-control/types.ts +0 -2
  93. package/src/range-control/utils.ts +3 -75
  94. package/src/tree-grid/index.js +23 -14
  95. package/src/tree-grid/test/__snapshots__/cell.js.snap +21 -17
  96. package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
  97. package/src/unit-control/index.native.js +8 -0
  98. package/src/unit-control/index.tsx +2 -2
  99. package/src/unit-control/styles/unit-control-styles.ts +0 -20
  100. package/src/unit-control/test/index.tsx +6 -3
  101. package/src/utils/hooks/use-controlled-state.js +9 -6
  102. package/tsconfig.tsbuildinfo +1 -1
  103. package/src/unit-control/test/__snapshots__/index.tsx.snap +0 -31
@@ -47,6 +47,10 @@ function UnitControl( {
47
47
  if ( pickerRef?.current ) {
48
48
  pickerRef.current.presentPicker();
49
49
  }
50
+ // Disable reason: this should be fixed by the native team.
51
+ // It would be great if this could be done in the context of
52
+ // https://github.com/WordPress/gutenberg/pull/39218
53
+ // eslint-disable-next-line react-hooks/exhaustive-deps
50
54
  }, [ pickerRef?.current ] );
51
55
 
52
56
  const currentInputValue = currentInput === null ? value : currentInput;
@@ -102,6 +106,10 @@ function UnitControl( {
102
106
  anchorNodeRef?.current
103
107
  ? findNodeHandle( anchorNodeRef?.current )
104
108
  : undefined,
109
+ // Disable reason: this should be fixed by the native team.
110
+ // It would be great if this could be done in the context of
111
+ // https://github.com/WordPress/gutenberg/pull/39218
112
+ // eslint-disable-next-line react-hooks/exhaustive-deps
105
113
  [ anchorNodeRef?.current ]
106
114
  );
107
115
 
@@ -100,7 +100,7 @@ function UnforwardedUnitControl(
100
100
  if ( parsedUnit !== undefined ) {
101
101
  setUnit( parsedUnit );
102
102
  }
103
- }, [ parsedUnit ] );
103
+ }, [ parsedUnit, setUnit ] );
104
104
 
105
105
  // Stores parsed value for hand-off in state reducer.
106
106
  const refParsedQuantity = useRef< number | undefined >( undefined );
@@ -265,7 +265,7 @@ function UnforwardedUnitControl(
265
265
  autoComplete={ autoComplete }
266
266
  className={ classes }
267
267
  disabled={ disabled }
268
- disableUnits={ disableUnits }
268
+ hideHTMLArrows
269
269
  isPressEnterToChange={ isPressEnterToChange }
270
270
  label={ label }
271
271
  onBlur={ handleOnBlur }
@@ -18,10 +18,6 @@ type SelectProps = {
18
18
  selectSize: SelectSize;
19
19
  };
20
20
 
21
- type InputProps = {
22
- disableUnits?: boolean;
23
- };
24
-
25
21
  export const Root = styled.div`
26
22
  box-sizing: border-box;
27
23
  position: relative;
@@ -32,30 +28,14 @@ export const Root = styled.div`
32
28
  }
33
29
  `;
34
30
 
35
- const arrowStyles = ( { disableUnits }: InputProps ) => {
36
- if ( disableUnits ) return '';
37
-
38
- return css`
39
- &::-webkit-outer-spin-button,
40
- &::-webkit-inner-spin-button {
41
- -webkit-appearance: none;
42
- margin: 0;
43
- }
44
- `;
45
- };
46
-
47
31
  // TODO: Resolve need to use &&& to increase specificity
48
32
  // https://github.com/WordPress/gutenberg/issues/18483
49
33
 
50
34
  export const ValueInput = styled( NumberControl )`
51
35
  &&& {
52
36
  input {
53
- appearance: none;
54
- -moz-appearance: textfield;
55
37
  display: block;
56
38
  width: 100%;
57
-
58
- ${ arrowStyles };
59
39
  }
60
40
  }
61
41
  `;
@@ -111,9 +111,12 @@ describe( 'UnitControl', () => {
111
111
  <UnitControl className="hello" />
112
112
  );
113
113
 
114
- expect( withoutClassName.firstChild ).toMatchDiffSnapshot(
115
- withClassName.firstChild
116
- );
114
+ expect(
115
+ withoutClassName.querySelector( '.components-unit-control' )
116
+ ).not.toHaveClass( 'hello' );
117
+ expect(
118
+ withClassName.querySelector( '.components-unit-control' )
119
+ ).toHaveClass( 'hello' );
117
120
  } );
118
121
 
119
122
  it( 'should not render select, if units are disabled', () => {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useEffect, useState } from '@wordpress/element';
4
+ import { useEffect, useState, useCallback } from '@wordpress/element';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -70,11 +70,14 @@ function useControlledState( currentState, options = defaultOptions ) {
70
70
 
71
71
  /* eslint-disable jsdoc/no-undefined-types */
72
72
  /** @type {(nextState: T) => void} */
73
- const setState = ( nextState ) => {
74
- if ( ! hasCurrentState ) {
75
- setInternalState( nextState );
76
- }
77
- };
73
+ const setState = useCallback(
74
+ ( nextState ) => {
75
+ if ( ! hasCurrentState ) {
76
+ setInternalState( nextState );
77
+ }
78
+ },
79
+ [ hasCurrentState ]
80
+ );
78
81
  /* eslint-enable jsdoc/no-undefined-types */
79
82
 
80
83
  return [ state, setState ];