@wordpress/components 21.0.2 → 21.1.2-next.4d3b314fd5.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 (255) hide show
  1. package/CHANGELOG.md +31 -4
  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/draggable/index.js +3 -6
  9. package/build/draggable/index.js.map +1 -1
  10. package/build/drop-zone/index.js +7 -1
  11. package/build/drop-zone/index.js.map +1 -1
  12. package/build/higher-order/with-filters/index.js +1 -1
  13. package/build/higher-order/with-filters/index.js.map +1 -1
  14. package/build/index.js +6 -0
  15. package/build/index.js.map +1 -1
  16. package/build/menu-item/index.js +4 -3
  17. package/build/menu-item/index.js.map +1 -1
  18. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
  19. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  20. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +15 -6
  21. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  22. package/build/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
  23. package/build/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
  24. package/build/mobile/color-settings/index.native.js +3 -1
  25. package/build/mobile/color-settings/index.native.js.map +1 -1
  26. package/build/mobile/color-settings/picker-screen.native.js +3 -1
  27. package/build/mobile/color-settings/picker-screen.native.js.map +1 -1
  28. package/build/mobile/image/index.native.js +3 -1
  29. package/build/mobile/image/index.native.js.map +1 -1
  30. package/build/mobile/keyboard-avoiding-view/index.ios.js +3 -1
  31. package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  32. package/build/mobile/link-picker/index.native.js +3 -1
  33. package/build/mobile/link-picker/index.native.js.map +1 -1
  34. package/build/mobile/link-picker/link-picker-results.native.js +6 -4
  35. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  36. package/build/mobile/link-picker/link-picker-screen.native.js +3 -1
  37. package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  38. package/build/mobile/link-settings/index.native.js +24 -6
  39. package/build/mobile/link-settings/index.native.js.map +1 -1
  40. package/build/mobile/link-settings/link-settings-screen.native.js +3 -1
  41. package/build/mobile/link-settings/link-settings-screen.native.js.map +1 -1
  42. package/build/mobile/segmented-control/index.native.js +6 -2
  43. package/build/mobile/segmented-control/index.native.js.map +1 -1
  44. package/build/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
  45. package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  46. package/build/notice/index.native.js +15 -19
  47. package/build/notice/index.native.js.map +1 -1
  48. package/build/notice/list.native.js +2 -3
  49. package/build/notice/list.native.js.map +1 -1
  50. package/build/palette-edit/index.js +1 -1
  51. package/build/palette-edit/index.js.map +1 -1
  52. package/build/popover/index.js +29 -32
  53. package/build/popover/index.js.map +1 -1
  54. package/build/popover/limit-shift.js +145 -0
  55. package/build/popover/limit-shift.js.map +1 -0
  56. package/build/popover/utils.js +55 -15
  57. package/build/popover/utils.js.map +1 -1
  58. package/build/range-control/input-range.js +1 -15
  59. package/build/range-control/input-range.js.map +1 -1
  60. package/build/range-control/tooltip.js +1 -1
  61. package/build/range-control/tooltip.js.map +1 -1
  62. package/build/range-control/utils.js +2 -58
  63. package/build/range-control/utils.js.map +1 -1
  64. package/build/tools-panel/styles.js +27 -12
  65. package/build/tools-panel/styles.js.map +1 -1
  66. package/build/tools-panel/tools-panel-header/component.js +19 -6
  67. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  68. package/build/tools-panel/tools-panel-header/hook.js +4 -0
  69. package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
  70. package/build/tree-grid/index.js +13 -8
  71. package/build/tree-grid/index.js.map +1 -1
  72. package/build/unit-control/index.js +2 -2
  73. package/build/unit-control/index.js.map +1 -1
  74. package/build/unit-control/index.native.js +10 -2
  75. package/build/unit-control/index.native.js.map +1 -1
  76. package/build/unit-control/styles/unit-control-styles.js +21 -32
  77. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  78. package/build/utils/hooks/use-controlled-state.js +2 -3
  79. package/build/utils/hooks/use-controlled-state.js.map +1 -1
  80. package/build-module/autocomplete/get-default-use-items.js +1 -1
  81. package/build-module/autocomplete/get-default-use-items.js.map +1 -1
  82. package/build-module/box-control/unit-control.js +0 -1
  83. package/build-module/box-control/unit-control.js.map +1 -1
  84. package/build-module/button/index.js +5 -1
  85. package/build-module/button/index.js.map +1 -1
  86. package/build-module/draggable/index.js +2 -5
  87. package/build-module/draggable/index.js.map +1 -1
  88. package/build-module/drop-zone/index.js +7 -1
  89. package/build-module/drop-zone/index.js.map +1 -1
  90. package/build-module/higher-order/with-filters/index.js +2 -2
  91. package/build-module/higher-order/with-filters/index.js.map +1 -1
  92. package/build-module/index.js +1 -1
  93. package/build-module/index.js.map +1 -1
  94. package/build-module/menu-item/index.js +4 -3
  95. package/build-module/menu-item/index.js.map +1 -1
  96. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
  97. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  98. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +13 -4
  99. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  100. package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
  101. package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
  102. package/build-module/mobile/color-settings/index.native.js +3 -1
  103. package/build-module/mobile/color-settings/index.native.js.map +1 -1
  104. package/build-module/mobile/color-settings/picker-screen.native.js +3 -1
  105. package/build-module/mobile/color-settings/picker-screen.native.js.map +1 -1
  106. package/build-module/mobile/image/index.native.js +3 -1
  107. package/build-module/mobile/image/index.native.js.map +1 -1
  108. package/build-module/mobile/keyboard-avoiding-view/index.ios.js +3 -1
  109. package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  110. package/build-module/mobile/link-picker/index.native.js +3 -1
  111. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  112. package/build-module/mobile/link-picker/link-picker-results.native.js +4 -2
  113. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  114. package/build-module/mobile/link-picker/link-picker-screen.native.js +3 -1
  115. package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  116. package/build-module/mobile/link-settings/index.native.js +24 -6
  117. package/build-module/mobile/link-settings/index.native.js.map +1 -1
  118. package/build-module/mobile/link-settings/link-settings-screen.native.js +3 -1
  119. package/build-module/mobile/link-settings/link-settings-screen.native.js.map +1 -1
  120. package/build-module/mobile/segmented-control/index.native.js +6 -2
  121. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  122. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
  123. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  124. package/build-module/notice/index.native.js +16 -21
  125. package/build-module/notice/index.native.js.map +1 -1
  126. package/build-module/notice/list.native.js +3 -3
  127. package/build-module/notice/list.native.js.map +1 -1
  128. package/build-module/palette-edit/index.js +1 -1
  129. package/build-module/palette-edit/index.js.map +1 -1
  130. package/build-module/popover/index.js +31 -35
  131. package/build-module/popover/index.js.map +1 -1
  132. package/build-module/popover/limit-shift.js +136 -0
  133. package/build-module/popover/limit-shift.js.map +1 -0
  134. package/build-module/popover/utils.js +55 -15
  135. package/build-module/popover/utils.js.map +1 -1
  136. package/build-module/range-control/input-range.js +1 -14
  137. package/build-module/range-control/input-range.js.map +1 -1
  138. package/build-module/range-control/tooltip.js +1 -1
  139. package/build-module/range-control/tooltip.js.map +1 -1
  140. package/build-module/range-control/utils.js +2 -57
  141. package/build-module/range-control/utils.js.map +1 -1
  142. package/build-module/tools-panel/styles.js +23 -12
  143. package/build-module/tools-panel/styles.js.map +1 -1
  144. package/build-module/tools-panel/tools-panel-header/component.js +19 -7
  145. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  146. package/build-module/tools-panel/tools-panel-header/hook.js +4 -0
  147. package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
  148. package/build-module/tree-grid/index.js +13 -8
  149. package/build-module/tree-grid/index.js.map +1 -1
  150. package/build-module/unit-control/index.js +2 -2
  151. package/build-module/unit-control/index.js.map +1 -1
  152. package/build-module/unit-control/index.native.js +10 -2
  153. package/build-module/unit-control/index.native.js.map +1 -1
  154. package/build-module/unit-control/styles/unit-control-styles.js +20 -31
  155. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  156. package/build-module/utils/hooks/use-controlled-state.js +3 -4
  157. package/build-module/utils/hooks/use-controlled-state.js.map +1 -1
  158. package/build-style/style-rtl.css +13 -2
  159. package/build-style/style.css +13 -2
  160. package/build-types/button/index.d.ts.map +1 -1
  161. package/build-types/draggable/index.d.ts.map +1 -1
  162. package/build-types/drop-zone/index.d.ts.map +1 -1
  163. package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
  164. package/build-types/focal-point-picker/styles/focal-point-style.d.ts +3 -3
  165. package/build-types/menu-item/index.d.ts.map +1 -1
  166. package/build-types/popover/index.d.ts.map +1 -1
  167. package/build-types/popover/limit-shift.d.ts +87 -0
  168. package/build-types/popover/limit-shift.d.ts.map +1 -0
  169. package/build-types/popover/stories/e2e/index.d.ts +8 -0
  170. package/build-types/popover/stories/e2e/index.d.ts.map +1 -0
  171. package/build-types/popover/test/index.d.ts +2 -0
  172. package/build-types/popover/test/index.d.ts.map +1 -0
  173. package/build-types/popover/types.d.ts +1 -1
  174. package/build-types/popover/types.d.ts.map +1 -1
  175. package/build-types/popover/utils.d.ts.map +1 -1
  176. package/build-types/range-control/input-range.d.ts.map +1 -1
  177. package/build-types/range-control/stories/index.d.ts.map +1 -1
  178. package/build-types/range-control/types.d.ts +0 -34
  179. package/build-types/range-control/types.d.ts.map +1 -1
  180. package/build-types/range-control/utils.d.ts +1 -12
  181. package/build-types/range-control/utils.d.ts.map +1 -1
  182. package/build-types/spinner/index.d.ts +1 -1
  183. package/build-types/tools-panel/styles.d.ts +6 -0
  184. package/build-types/tools-panel/styles.d.ts.map +1 -1
  185. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  186. package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -0
  187. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  188. package/build-types/tools-panel/types.d.ts +1 -0
  189. package/build-types/tools-panel/types.d.ts.map +1 -1
  190. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -4
  191. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  192. package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
  193. package/package.json +17 -17
  194. package/src/autocomplete/get-default-use-items.js +1 -1
  195. package/src/box-control/unit-control.js +0 -1
  196. package/src/button/index.js +7 -1
  197. package/src/button/test/index.js +36 -0
  198. package/src/color-palette/test/__snapshots__/index.js.snap +169 -1106
  199. package/src/color-palette/test/index.js +107 -61
  200. package/src/draggable/index.js +2 -5
  201. package/src/drop-zone/index.tsx +4 -1
  202. package/src/font-size-picker/stories/e2e/index.js +47 -0
  203. package/src/higher-order/with-filters/index.js +2 -2
  204. package/src/index.js +1 -1
  205. package/src/menu-item/README.md +7 -0
  206. package/src/menu-item/index.js +11 -5
  207. package/src/menu-item/style.scss +1 -0
  208. package/src/menu-item/test/index.js +36 -0
  209. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +9 -0
  210. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +12 -2
  211. package/src/mobile/bottom-sheet/sub-sheet/index.native.js +3 -0
  212. package/src/mobile/color-settings/index.native.js +3 -0
  213. package/src/mobile/color-settings/picker-screen.native.js +3 -0
  214. package/src/mobile/image/index.native.js +3 -0
  215. package/src/mobile/keyboard-avoiding-view/index.ios.js +3 -0
  216. package/src/mobile/link-picker/index.native.js +3 -0
  217. package/src/mobile/link-picker/link-picker-results.native.js +4 -1
  218. package/src/mobile/link-picker/link-picker-screen.native.js +3 -0
  219. package/src/mobile/link-settings/index.native.js +18 -0
  220. package/src/mobile/link-settings/link-settings-screen.native.js +3 -0
  221. package/src/mobile/segmented-control/index.native.js +6 -0
  222. package/src/mobile/utils/use-unit-converter-to-mobile.native.js +6 -0
  223. package/src/notice/index.native.js +17 -20
  224. package/src/notice/list.native.js +7 -3
  225. package/src/palette-edit/index.js +1 -1
  226. package/src/placeholder/style.scss +1 -1
  227. package/src/popover/index.tsx +26 -42
  228. package/src/popover/limit-shift.ts +205 -0
  229. package/src/popover/stories/e2e/index.tsx +25 -0
  230. package/src/popover/test/index.tsx +230 -0
  231. package/src/popover/types.ts +1 -0
  232. package/src/popover/utils.ts +58 -16
  233. package/src/range-control/README.md +6 -7
  234. package/src/range-control/input-range.tsx +1 -21
  235. package/src/range-control/stories/index.tsx +2 -1
  236. package/src/range-control/tooltip.tsx +1 -1
  237. package/src/range-control/types.ts +0 -35
  238. package/src/range-control/utils.ts +3 -75
  239. package/src/tools-panel/stories/index.js +27 -0
  240. package/src/tools-panel/styles.ts +28 -1
  241. package/src/tools-panel/tools-panel-header/component.tsx +12 -5
  242. package/src/tools-panel/tools-panel-header/hook.ts +5 -0
  243. package/src/tools-panel/types.ts +1 -0
  244. package/src/tree-grid/index.js +23 -14
  245. package/src/tree-grid/test/__snapshots__/cell.js.snap +21 -17
  246. package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
  247. package/src/unit-control/index.native.js +8 -0
  248. package/src/unit-control/index.tsx +2 -2
  249. package/src/unit-control/styles/unit-control-styles.ts +0 -20
  250. package/src/unit-control/test/index.tsx +6 -3
  251. package/src/utils/hooks/use-controlled-state.js +9 -6
  252. package/tsconfig.tsbuildinfo +1 -1
  253. package/src/popover/test/__snapshots__/index.js.snap +0 -34
  254. package/src/popover/test/index.js +0 -164
  255. package/src/unit-control/test/__snapshots__/index.tsx.snap +0 -31
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { mount, shallow } from 'enzyme';
4
+ import { render, screen, within } from '@testing-library/react';
5
+ import userEvent from '@testing-library/user-event';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -17,102 +18,147 @@ describe( 'ColorPalette', () => {
17
18
  const currentColor = '#f00';
18
19
  const onChange = jest.fn();
19
20
 
20
- const wrapper = mount(
21
- <ColorPalette
22
- colors={ colors }
23
- value={ currentColor }
24
- onChange={ onChange }
25
- />
26
- );
27
- const buttons = wrapper.find( 'Option button' );
28
-
29
21
  beforeEach( () => {
30
22
  onChange.mockClear();
31
23
  } );
32
24
 
33
25
  test( 'should render a dynamic toolbar of colors', () => {
34
- expect( wrapper ).toMatchSnapshot();
26
+ const { container } = render(
27
+ <ColorPalette
28
+ colors={ colors }
29
+ value={ currentColor }
30
+ onChange={ onChange }
31
+ />
32
+ );
33
+
34
+ expect( container ).toMatchSnapshot();
35
35
  } );
36
36
 
37
37
  test( 'should render three color button options', () => {
38
- expect( buttons ).toHaveLength( 3 );
38
+ render(
39
+ <ColorPalette
40
+ colors={ colors }
41
+ value={ currentColor }
42
+ onChange={ onChange }
43
+ />
44
+ );
45
+
46
+ expect(
47
+ screen.getAllByRole( 'button', { name: /^Color:/ } )
48
+ ).toHaveLength( 3 );
39
49
  } );
40
50
 
41
- test( 'should call onClick on an active button with undefined', () => {
42
- const activeButton = buttons.findWhere( ( button ) =>
43
- button.hasClass( 'is-pressed' )
51
+ test( 'should call onClick on an active button with undefined', async () => {
52
+ const user = userEvent.setup( {
53
+ advanceTimers: jest.advanceTimersByTime,
54
+ } );
55
+
56
+ render(
57
+ <ColorPalette
58
+ colors={ colors }
59
+ value={ currentColor }
60
+ onChange={ onChange }
61
+ />
62
+ );
63
+
64
+ await user.click(
65
+ screen.getByRole( 'button', { name: /^Color:/, pressed: true } )
44
66
  );
45
- activeButton.simulate( 'click' );
46
67
 
47
68
  expect( onChange ).toHaveBeenCalledTimes( 1 );
48
69
  expect( onChange ).toHaveBeenCalledWith( undefined );
49
70
  } );
50
71
 
51
- test( 'should call onClick on an inactive button', () => {
52
- const inactiveButton = buttons
53
- .findWhere( ( button ) => ! button.hasClass( 'is-pressed' ) )
54
- .first();
55
- inactiveButton.simulate( 'click' );
72
+ test( 'should call onClick on an inactive button', async () => {
73
+ const user = userEvent.setup( {
74
+ advanceTimers: jest.advanceTimersByTime,
75
+ } );
76
+
77
+ render(
78
+ <ColorPalette
79
+ colors={ colors }
80
+ value={ currentColor }
81
+ onChange={ onChange }
82
+ />
83
+ );
84
+
85
+ await user.click(
86
+ screen.getAllByRole( 'button', {
87
+ name: /^Color:/,
88
+ pressed: false,
89
+ } )[ 0 ]
90
+ );
56
91
 
57
92
  expect( onChange ).toHaveBeenCalledTimes( 1 );
93
+ expect( onChange ).toHaveBeenCalledWith( '#fff' );
58
94
  } );
59
95
 
60
- test( 'should call onClick with undefined, when the clearButton onClick is triggered', () => {
61
- const clearButton = wrapper.find( 'ButtonAction button' );
96
+ test( 'should call onClick with undefined, when the clearButton onClick is triggered', async () => {
97
+ const user = userEvent.setup( {
98
+ advanceTimers: jest.advanceTimersByTime,
99
+ } );
62
100
 
63
- expect( clearButton ).toHaveLength( 1 );
101
+ render(
102
+ <ColorPalette
103
+ colors={ colors }
104
+ value={ currentColor }
105
+ onChange={ onChange }
106
+ />
107
+ );
64
108
 
65
- clearButton.simulate( 'click' );
109
+ await user.click( screen.getByRole( 'button', { name: 'Clear' } ) );
66
110
 
67
111
  expect( onChange ).toHaveBeenCalledTimes( 1 );
68
112
  expect( onChange ).toHaveBeenCalledWith( undefined );
69
113
  } );
70
114
 
71
115
  test( 'should allow disabling custom color picker', () => {
72
- expect(
73
- shallow(
74
- <ColorPalette
75
- colors={ colors }
76
- disableCustomColors={ true }
77
- value={ currentColor }
78
- onChange={ onChange }
79
- />
80
- )
81
- ).toMatchSnapshot();
82
- } );
116
+ const { container } = render(
117
+ <ColorPalette
118
+ colors={ colors }
119
+ disableCustomColors
120
+ value={ currentColor }
121
+ onChange={ onChange }
122
+ />
123
+ );
83
124
 
84
- describe( 'Dropdown', () => {
85
- const dropdown = wrapper.find( 'Dropdown' );
125
+ expect( container ).toMatchSnapshot();
126
+ } );
86
127
 
87
- test( 'should render it correctly', () => {
88
- expect( dropdown ).toMatchSnapshot();
128
+ test( 'should render dropdown and its content', async () => {
129
+ const user = userEvent.setup( {
130
+ advanceTimers: jest.advanceTimersByTime,
89
131
  } );
90
132
 
91
- describe( '.renderToggle', () => {
92
- const isOpen = true;
93
- const onToggle = jest.fn();
94
-
95
- const renderedToggleButton = mount(
96
- dropdown.props().renderToggle( { isOpen, onToggle } )
97
- );
98
-
99
- test( 'should render dropdown content', () => {
100
- expect( renderedToggleButton ).toMatchSnapshot();
101
- } );
133
+ render(
134
+ <ColorPalette
135
+ colors={ colors }
136
+ value={ currentColor }
137
+ onChange={ onChange }
138
+ />
139
+ );
102
140
 
103
- test( 'should call onToggle on click.', () => {
104
- renderedToggleButton.find( 'button' ).simulate( 'click' );
141
+ await user.click(
142
+ screen.getByRole( 'button', {
143
+ name: /^Custom color picker/,
144
+ expanded: false,
145
+ } )
146
+ );
105
147
 
106
- expect( onToggle ).toHaveBeenCalledTimes( 1 );
107
- } );
148
+ const dropdownButton = screen.getByRole( 'button', {
149
+ name: /^Custom color picker/,
150
+ expanded: true,
108
151
  } );
109
152
 
110
- describe( '.renderContent', () => {
111
- const renderedContent = shallow( dropdown.props().renderContent() );
153
+ expect( dropdownButton ).toBeVisible();
112
154
 
113
- test( 'should render dropdown content', () => {
114
- expect( renderedContent ).toMatchSnapshot();
115
- } );
116
- } );
155
+ expect(
156
+ within( dropdownButton ).getByText( colors[ 0 ].name )
157
+ ).toBeVisible();
158
+ expect(
159
+ within( dropdownButton ).getByText(
160
+ colors[ 0 ].color.replace( '#', '' )
161
+ )
162
+ ).toBeVisible();
117
163
  } );
118
164
  } );
@@ -1,13 +1,9 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
+ import { throttle } from '@wordpress/compose';
4
5
  import { useEffect, useRef } from '@wordpress/element';
5
6
 
6
- /**
7
- * External dependencies
8
- */
9
- import { throttle } from 'lodash';
10
-
11
7
  const dragImageClass = 'components-draggable__invisible-drag-image';
12
8
  const cloneWrapperClass = 'components-draggable__clone';
13
9
  const clonePadding = 0;
@@ -180,6 +176,7 @@ export default function Draggable( {
180
176
 
181
177
  // Aim for 60fps (16 ms per frame) for now. We can potentially use requestAnimationFrame (raf) instead,
182
178
  // note that browsers may throttle raf below 60fps in certain conditions.
179
+ // @ts-ignore
183
180
  const throttledDragOver = throttle( over, 16 );
184
181
 
185
182
  ownerDocument.addEventListener( 'dragover', throttledDragOver );
@@ -119,7 +119,6 @@ export function DropZoneComponent( {
119
119
  const disableMotion = useReducedMotion();
120
120
 
121
121
  let children;
122
-
123
122
  const backdrop = {
124
123
  hidden: { scaleY: 0, opacity: 0 },
125
124
  show: {
@@ -156,6 +155,10 @@ export function DropZoneComponent( {
156
155
  animate="show"
157
156
  exit={ disableMotion ? 'show' : 'exit' }
158
157
  className="components-drop-zone__content"
158
+ // Without this, when this div is shown,
159
+ // Safari calls a onDropZoneLeave causing a loop because of this bug
160
+ // https://bugs.webkit.org/show_bug.cgi?id=66547
161
+ style={ { pointerEvents: 'none' } }
159
162
  >
160
163
  <motion.div variants={ foreground }>
161
164
  <Icon
@@ -0,0 +1,47 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useState } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import FontSizePicker from '../..';
10
+
11
+ export default {
12
+ title: 'Components/FontSizePicker',
13
+ component: FontSizePicker,
14
+ };
15
+
16
+ const FontSizePickerWithState = ( { initialValue, ...props } ) => {
17
+ const [ fontSize, setFontSize ] = useState( initialValue );
18
+ return (
19
+ <FontSizePicker
20
+ { ...props }
21
+ value={ fontSize }
22
+ onChange={ setFontSize }
23
+ />
24
+ );
25
+ };
26
+
27
+ export const Default = FontSizePickerWithState.bind( {} );
28
+ Default.args = {
29
+ fontSizes: [
30
+ {
31
+ name: 'Small',
32
+ slug: 'small',
33
+ size: 12,
34
+ },
35
+ {
36
+ name: 'Normal',
37
+ slug: 'normal',
38
+ size: 16,
39
+ },
40
+ {
41
+ name: 'Big',
42
+ slug: 'big',
43
+ size: 26,
44
+ },
45
+ ],
46
+ initialValue: 16,
47
+ };
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { debounce, without } from 'lodash';
4
+ import { without } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { Component } from '@wordpress/element';
10
10
  import { addAction, applyFilters, removeAction } from '@wordpress/hooks';
11
- import { createHigherOrderComponent } from '@wordpress/compose';
11
+ import { createHigherOrderComponent, debounce } from '@wordpress/compose';
12
12
 
13
13
  const ANIMATION_FRAME_PERIOD = 16;
14
14
 
package/src/index.js CHANGED
@@ -16,7 +16,7 @@ export {
16
16
  default as Animate,
17
17
  getAnimateClassName as __unstableGetAnimateClassName,
18
18
  } from './animate';
19
- export { __unstableMotion } from './animation';
19
+ export { __unstableMotion, __unstableAnimatePresence } from './animation';
20
20
  export { default as AnglePickerControl } from './angle-picker-control';
21
21
  export {
22
22
  default as Autocomplete,
@@ -79,3 +79,10 @@ If shortcut is a string, it is expecting the display text. If shortcut is an obj
79
79
  - Default: `'menuitem'`
80
80
 
81
81
  [Aria Spec](https://www.w3.org/TR/wai-aria-1.1/#aria-checked). If you need to have selectable menu items use menuitemradio for single select, and menuitemcheckbox for multiselect.
82
+
83
+ ### `suffix`
84
+
85
+ - Type: `WPElement`
86
+ - Required: No
87
+
88
+ Allows for markup other than icons or shortcuts to be added to the menu item.
@@ -26,6 +26,7 @@ export function MenuItem( props, ref ) {
26
26
  shortcut,
27
27
  isSelected,
28
28
  role = 'menuitem',
29
+ suffix,
29
30
  ...buttonProps
30
31
  } = props;
31
32
 
@@ -63,11 +64,16 @@ export function MenuItem( props, ref ) {
63
64
  { ...buttonProps }
64
65
  >
65
66
  <span className="components-menu-item__item">{ children }</span>
66
- <Shortcut
67
- className="components-menu-item__shortcut"
68
- shortcut={ shortcut }
69
- />
70
- { icon && iconPosition === 'right' && <Icon icon={ icon } /> }
67
+ { ! suffix && (
68
+ <Shortcut
69
+ className="components-menu-item__shortcut"
70
+ shortcut={ shortcut }
71
+ />
72
+ ) }
73
+ { ! suffix && icon && iconPosition === 'right' && (
74
+ <Icon icon={ icon } />
75
+ ) }
76
+ { suffix }
71
77
  </Button>
72
78
  );
73
79
  }
@@ -8,6 +8,7 @@
8
8
  // Ensure unchecked items have clearance for consistency
9
9
  // with checked items containing an icon or shortcut.
10
10
  padding-right: $grid-unit-60;
11
+ box-sizing: initial;
11
12
  }
12
13
  }
13
14
 
@@ -107,4 +107,40 @@ describe( 'MenuItem', () => {
107
107
  expect( checkboxMenuItem ).toBeChecked();
108
108
  expect( checkboxMenuItem ).toHaveAttribute( 'aria-checked', 'true' );
109
109
  } );
110
+
111
+ it( 'should not render shortcut or right icon if suffix provided', () => {
112
+ render(
113
+ <MenuItem
114
+ icon={ <span>Icon</span> }
115
+ iconPosition="right"
116
+ role="menuitemcheckbox"
117
+ shortcut="Shortcut"
118
+ suffix="Suffix"
119
+ >
120
+ My item
121
+ </MenuItem>
122
+ );
123
+
124
+ expect( screen.getByText( 'Suffix' ) ).toBeInTheDocument();
125
+ expect( screen.queryByText( 'Shortcut' ) ).not.toBeInTheDocument();
126
+ expect( screen.queryByText( 'Icon' ) ).not.toBeInTheDocument();
127
+ } );
128
+
129
+ it( 'should render left icon despite suffix being provided', () => {
130
+ render(
131
+ <MenuItem
132
+ icon={ <span>Icon</span> }
133
+ iconPosition="left"
134
+ role="menuitemcheckbox"
135
+ shortcut="Shortcut"
136
+ suffix="Suffix"
137
+ >
138
+ My item
139
+ </MenuItem>
140
+ );
141
+
142
+ expect( screen.getByText( 'Icon' ) ).toBeInTheDocument();
143
+ expect( screen.getByText( 'Suffix' ) ).toBeInTheDocument();
144
+ expect( screen.queryByText( 'Shortcut' ) ).not.toBeInTheDocument();
145
+ } );
110
146
  } );
@@ -112,6 +112,9 @@ function BottomSheetNavigationContainer( {
112
112
  }
113
113
  }
114
114
  },
115
+ // Disable reason: deferring this refactor to the native team.
116
+ // see https://github.com/WordPress/gutenberg/pull/41166
117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
115
118
  [ currentHeight ]
116
119
  );
117
120
 
@@ -133,6 +136,9 @@ function BottomSheetNavigationContainer( {
133
136
  />
134
137
  );
135
138
  } );
139
+ // Disable reason: deferring this refactor to the native team.
140
+ // see https://github.com/WordPress/gutenberg/pull/41166
141
+ // eslint-disable-next-line react-hooks/exhaustive-deps
136
142
  }, [ children ] );
137
143
 
138
144
  return useMemo( () => {
@@ -158,6 +164,9 @@ function BottomSheetNavigationContainer( {
158
164
  </BottomSheetNavigationProvider>
159
165
  </View>
160
166
  );
167
+ // Disable reason: deferring this refactor to the native team.
168
+ // see https://github.com/WordPress/gutenberg/pull/41166
169
+ // eslint-disable-next-line react-hooks/exhaustive-deps
161
170
  }, [ currentHeight, _theme ] );
162
171
  }
163
172
 
@@ -7,13 +7,12 @@ import {
7
7
  useFocusEffect,
8
8
  } from '@react-navigation/native';
9
9
  import { View, ScrollView, TouchableHighlight } from 'react-native';
10
- import { debounce } from 'lodash';
11
10
 
12
11
  /**
13
12
  * WordPress dependencies
14
13
  */
15
14
  import { BottomSheetContext } from '@wordpress/components';
16
-
15
+ import { debounce } from '@wordpress/compose';
17
16
  import { useRef, useCallback, useContext, useMemo } from '@wordpress/element';
18
17
 
19
18
  /**
@@ -42,6 +41,9 @@ const BottomSheetNavigationScreen = ( {
42
41
 
43
42
  const { setHeight } = useContext( BottomSheetNavigationContext );
44
43
 
44
+ // Disable reason: deferring this refactor to the native team.
45
+ // see https://github.com/WordPress/gutenberg/pull/41166
46
+ // eslint-disable-next-line react-hooks/exhaustive-deps
45
47
  const setHeightDebounce = useCallback( debounce( setHeight, 10 ), [
46
48
  setHeight,
47
49
  ] );
@@ -71,6 +73,8 @@ const BottomSheetNavigationScreen = ( {
71
73
  *
72
74
  * Related: https://github.com/WordPress/gutenberg/pull/36328#discussion_r768897546
73
75
  */
76
+ // see https://github.com/WordPress/gutenberg/pull/41166
77
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
78
  }, [] )
75
79
  );
76
80
 
@@ -84,6 +88,9 @@ const BottomSheetNavigationScreen = ( {
84
88
  setHeight( heightRef.current.maxHeight );
85
89
  }
86
90
  return () => {};
91
+ // Disable reason: deferring this refactor to the native team.
92
+ // see https://github.com/WordPress/gutenberg/pull/41166
93
+ // eslint-disable-next-line react-hooks/exhaustive-deps
87
94
  }, [ setHeight ] )
88
95
  );
89
96
 
@@ -128,6 +135,9 @@ const BottomSheetNavigationScreen = ( {
128
135
  </TouchableHighlight>
129
136
  </ScrollView>
130
137
  );
138
+ // Disable reason: deferring this refactor to the native team.
139
+ // see https://github.com/WordPress/gutenberg/pull/41166
140
+ // eslint-disable-next-line react-hooks/exhaustive-deps
131
141
  }, [
132
142
  children,
133
143
  isFocused,
@@ -23,6 +23,9 @@ const BottomSheetSubSheet = ( {
23
23
  if ( showSheet ) {
24
24
  setIsFullScreen( isFullScreen );
25
25
  }
26
+ // Disable reason: deferring this refactor to the native team.
27
+ // see https://github.com/WordPress/gutenberg/pull/41166
28
+ // eslint-disable-next-line react-hooks/exhaustive-deps
26
29
  }, [ showSheet, isFullScreen ] );
27
30
 
28
31
  return (
@@ -34,6 +34,9 @@ const ColorSettingsMemo = memo(
34
34
  useEffect( () => {
35
35
  shouldEnableBottomSheetMaxHeight( true );
36
36
  onHandleClosingBottomSheet( null );
37
+ // Disable reason: deferring this refactor to the native team.
38
+ // see https://github.com/WordPress/gutenberg/pull/41166
39
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
40
  }, [] );
38
41
  return (
39
42
  <BottomSheet.NavigationContainer>
@@ -43,6 +43,9 @@ const PickerScreen = () => {
43
43
  onHandleHardwareButtonPress={ onHandleHardwareButtonPress }
44
44
  />
45
45
  );
46
+ // Disable reason: deferring this refactor to the native team.
47
+ // see https://github.com/WordPress/gutenberg/pull/41166
48
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
49
  }, [
47
50
  setColor,
48
51
  currentValue,
@@ -82,6 +82,9 @@ const ImageComponent = ( {
82
82
  } );
83
83
  }
84
84
  return () => ( isCurrent = false );
85
+ // Disable reason: deferring this refactor to the native team.
86
+ // see https://github.com/WordPress/gutenberg/pull/41166
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
85
88
  }, [ url ] );
86
89
 
87
90
  const onContainerLayout = ( event ) => {
@@ -69,6 +69,9 @@ export const KeyboardAvoidingView = ( {
69
69
  keyboardShowSubscription.remove();
70
70
  keyboardHideSubscription.remove();
71
71
  };
72
+ // Disable reason: deferring this refactor to the native team.
73
+ // see https://github.com/WordPress/gutenberg/pull/41166
74
+ // eslint-disable-next-line react-hooks/exhaustive-deps
72
75
  }, [] );
73
76
 
74
77
  function onSafeAreaInsetsUpdate( { safeAreaInsets } ) {
@@ -91,6 +91,9 @@ export const LinkPicker = ( {
91
91
  getURLFromClipboard()
92
92
  .then( ( url ) => setValue( { value, clipboardUrl: url } ) )
93
93
  .catch( () => setValue( { value, clipboardUrl: '' } ) );
94
+ // Disable reason: deferring this refactor to the native team.
95
+ // see https://github.com/WordPress/gutenberg/pull/41166
96
+ // eslint-disable-next-line react-hooks/exhaustive-deps
94
97
  }, [] );
95
98
 
96
99
  // TODO: Localize the accessibility label.
@@ -2,12 +2,12 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { ActivityIndicator, FlatList, View } from 'react-native';
5
- import { debounce } from 'lodash';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
9
8
  */
10
9
  import { BottomSheet, BottomSheetConsumer } from '@wordpress/components';
10
+ import { debounce } from '@wordpress/compose';
11
11
  import { useState, useEffect, useRef } from '@wordpress/element';
12
12
  import { useSelect } from '@wordpress/data';
13
13
 
@@ -86,6 +86,9 @@ export default function LinkPickerResults( {
86
86
  setHasAllSuggestions( false );
87
87
  setLinks( [ directEntry ] );
88
88
  fetchMoreSuggestions( { query, links: [ directEntry ] } );
89
+ // Disable reason: deferring this refactor to the native team.
90
+ // see https://github.com/WordPress/gutenberg/pull/41166
91
+ // eslint-disable-next-line react-hooks/exhaustive-deps
89
92
  }, [ query ] );
90
93
 
91
94
  const onEndReached = () => fetchMoreSuggestions( { query, links } );
@@ -53,6 +53,9 @@ const LinkPickerScreen = ( { returnScreenName } ) => {
53
53
  onCancel={ onCancel }
54
54
  />
55
55
  );
56
+ // Disable reason: deferring this refactor to the native team.
57
+ // see https://github.com/WordPress/gutenberg/pull/41166
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
56
59
  }, [ inputValue ] );
57
60
  };
58
61
 
@@ -101,6 +101,9 @@ function LinkSettings( {
101
101
  if ( onHandleClosingBottomSheet ) {
102
102
  onHandleClosingBottomSheet( onCloseSettingsSheet );
103
103
  }
104
+ // Disable reason: deferring this refactor to the native team.
105
+ // see https://github.com/WordPress/gutenberg/pull/41166
106
+ // eslint-disable-next-line react-hooks/exhaustive-deps
104
107
  }, [ urlInputValue, labelInputValue, linkRelInputValue ] );
105
108
 
106
109
  useEffect( () => {
@@ -112,6 +115,9 @@ function LinkSettings( {
112
115
  if ( url !== urlInputValue ) {
113
116
  setUrlInputValue( url || '' );
114
117
  }
118
+ // Disable reason: deferring this refactor to the native team.
119
+ // see https://github.com/WordPress/gutenberg/pull/41166
120
+ // eslint-disable-next-line react-hooks/exhaustive-deps
115
121
  }, [ url ] );
116
122
 
117
123
  useEffect( () => {
@@ -135,6 +141,9 @@ function LinkSettings( {
135
141
  if ( prevEditorSidebarOpened && ! editorSidebarOpened ) {
136
142
  onSetAttributes();
137
143
  }
144
+ // Disable reason: deferring this refactor to the native team.
145
+ // see https://github.com/WordPress/gutenberg/pull/41166
146
+ // eslint-disable-next-line react-hooks/exhaustive-deps
138
147
  }, [ editorSidebarOpened, isVisible ] );
139
148
 
140
149
  useEffect( () => {
@@ -147,6 +156,9 @@ function LinkSettings( {
147
156
  url: prependHTTP( urlValue ),
148
157
  } );
149
158
  }
159
+ // Disable reason: deferring this refactor to the native team.
160
+ // see https://github.com/WordPress/gutenberg/pull/41166
161
+ // eslint-disable-next-line react-hooks/exhaustive-deps
150
162
  }, [ urlValue ] );
151
163
 
152
164
  const onChangeURL = useCallback(
@@ -176,6 +188,9 @@ function LinkSettings( {
176
188
  rel: linkRelInputValue,
177
189
  } );
178
190
  }
191
+ // Disable reason: deferring this refactor to the native team.
192
+ // see https://github.com/WordPress/gutenberg/pull/41166
193
+ // eslint-disable-next-line react-hooks/exhaustive-deps
179
194
  }, [ urlInputValue, labelInputValue, linkRelInputValue, setAttributes ] );
180
195
 
181
196
  const onCloseSettingsSheet = useCallback( () => {
@@ -208,6 +223,9 @@ function LinkSettings( {
208
223
  rel: updatedRel,
209
224
  } );
210
225
  },
226
+ // Disable reason: deferring this refactor to the native team.
227
+ // see https://github.com/WordPress/gutenberg/pull/41166
228
+ // eslint-disable-next-line react-hooks/exhaustive-deps
211
229
  [ linkRelInputValue ]
212
230
  );
213
231