@wordpress/components 23.9.0 → 25.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/CONTRIBUTING.md +75 -1
  3. package/README.md +1 -3
  4. package/build/autocomplete/autocompleter-ui.js +0 -2
  5. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  6. package/build/autocomplete/index.js +2 -0
  7. package/build/autocomplete/index.js.map +1 -1
  8. package/build/button/index.js +2 -0
  9. package/build/button/index.js.map +1 -1
  10. package/build/card/card-media/component.js +2 -1
  11. package/build/card/card-media/component.js.map +1 -1
  12. package/build/color-picker/styles.js +8 -8
  13. package/build/color-picker/styles.js.map +1 -1
  14. package/build/combobox-control/index.js +7 -5
  15. package/build/combobox-control/index.js.map +1 -1
  16. package/build/combobox-control/styles.js +3 -3
  17. package/build/combobox-control/styles.js.map +1 -1
  18. package/build/date-time/date-time/index.js +3 -84
  19. package/build/date-time/date-time/index.js.map +1 -1
  20. package/build/date-time/date-time/styles.js +4 -19
  21. package/build/date-time/date-time/styles.js.map +1 -1
  22. package/build/dimension-control/index.js +1 -1
  23. package/build/dimension-control/index.js.map +1 -1
  24. package/build/draggable/index.js +2 -7
  25. package/build/draggable/index.js.map +1 -1
  26. package/build/dropdown-menu/index.js +87 -11
  27. package/build/dropdown-menu/index.js.map +1 -1
  28. package/build/dropdown-menu/types.js +6 -0
  29. package/build/dropdown-menu/types.js.map +1 -0
  30. package/build/dropdown-menu-v2/index.js +195 -0
  31. package/build/dropdown-menu-v2/index.js.map +1 -0
  32. package/build/dropdown-menu-v2/styles.js +176 -0
  33. package/build/dropdown-menu-v2/styles.js.map +1 -0
  34. package/build/dropdown-menu-v2/types.js +6 -0
  35. package/build/dropdown-menu-v2/types.js.map +1 -0
  36. package/build/form-token-field/index.js +5 -3
  37. package/build/form-token-field/index.js.map +1 -1
  38. package/build/form-token-field/styles.js +3 -3
  39. package/build/form-token-field/styles.js.map +1 -1
  40. package/build/index.native.js +0 -9
  41. package/build/index.native.js.map +1 -1
  42. package/build/input-control/styles/input-control-styles.js +30 -23
  43. package/build/input-control/styles/input-control-styles.js.map +1 -1
  44. package/build/mobile/bottom-sheet/cell.native.js +16 -8
  45. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  46. package/build/mobile/bottom-sheet/range-cell.native.js +3 -2
  47. package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  48. package/build/mobile/bottom-sheet/stepper-cell/index.native.js +4 -2
  49. package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  50. package/build/mobile/bottom-sheet/switch-cell.native.js +8 -2
  51. package/build/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
  52. package/build/mobile/bottom-sheet-select-control/index.native.js +4 -2
  53. package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  54. package/build/mobile/bottom-sheet-text-control/index.native.js +4 -2
  55. package/build/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
  56. package/build/mobile/global-styles-context/index.native.js +13 -1
  57. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  58. package/build/mobile/link-picker/link-picker-results.native.js +3 -1
  59. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  60. package/build/navigable-container/container.js +39 -19
  61. package/build/navigable-container/container.js.map +1 -1
  62. package/build/navigable-container/index.js.map +1 -1
  63. package/build/navigable-container/menu.js +37 -5
  64. package/build/navigable-container/menu.js.map +1 -1
  65. package/build/navigable-container/tabbable.js +45 -4
  66. package/build/navigable-container/tabbable.js.map +1 -1
  67. package/build/navigable-container/types.js +6 -0
  68. package/build/navigable-container/types.js.map +1 -0
  69. package/build/palette-edit/index.js +34 -12
  70. package/build/palette-edit/index.js.map +1 -1
  71. package/build/private-apis.js +13 -1
  72. package/build/private-apis.js.map +1 -1
  73. package/build/range-control/index.native.js +5 -2
  74. package/build/range-control/index.native.js.map +1 -1
  75. package/build/sandbox/index.native.js +6 -2
  76. package/build/sandbox/index.native.js.map +1 -1
  77. package/build/slot-fill/bubbles-virtually/fill.js +2 -1
  78. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  79. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +45 -35
  80. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  81. package/build/slot-fill/bubbles-virtually/use-slot.js +11 -26
  82. package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  83. package/build/slot-fill/fill.js +7 -31
  84. package/build/slot-fill/fill.js.map +1 -1
  85. package/build/slot-fill/index.js.map +1 -1
  86. package/build/slot-fill/provider.js +0 -6
  87. package/build/slot-fill/provider.js.map +1 -1
  88. package/build/slot-fill/slot.js +0 -5
  89. package/build/slot-fill/slot.js.map +1 -1
  90. package/build/snackbar/list.js +0 -2
  91. package/build/snackbar/list.js.map +1 -1
  92. package/build/tab-panel/index.js.map +1 -1
  93. package/build/theme/color-algorithms.js +1 -1
  94. package/build/theme/color-algorithms.js.map +1 -1
  95. package/build/toggle-group-control/toggle-group-control/styles.js +7 -7
  96. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  97. package/build/toolbar/toolbar-button/index.js +1 -2
  98. package/build/toolbar/toolbar-button/index.js.map +1 -1
  99. package/build/toolbar/toolbar-item/index.js +4 -2
  100. package/build/toolbar/toolbar-item/index.js.map +1 -1
  101. package/build/utils/colors-values.js +3 -3
  102. package/build/utils/colors-values.js.map +1 -1
  103. package/build/utils/use-deprecated-props.js +35 -0
  104. package/build/utils/use-deprecated-props.js.map +1 -0
  105. package/build-module/autocomplete/autocompleter-ui.js +1 -3
  106. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  107. package/build-module/autocomplete/index.js +3 -3
  108. package/build-module/autocomplete/index.js.map +1 -1
  109. package/build-module/button/index.js +2 -0
  110. package/build-module/button/index.js.map +1 -1
  111. package/build-module/card/card-media/component.js +2 -1
  112. package/build-module/card/card-media/component.js.map +1 -1
  113. package/build-module/color-picker/styles.js +8 -8
  114. package/build-module/color-picker/styles.js.map +1 -1
  115. package/build-module/combobox-control/index.js +6 -5
  116. package/build-module/combobox-control/index.js.map +1 -1
  117. package/build-module/combobox-control/styles.js +3 -3
  118. package/build-module/combobox-control/styles.js.map +1 -1
  119. package/build-module/date-time/date-time/index.js +6 -81
  120. package/build-module/date-time/date-time/index.js.map +1 -1
  121. package/build-module/date-time/date-time/styles.js +3 -17
  122. package/build-module/date-time/date-time/styles.js.map +1 -1
  123. package/build-module/dimension-control/index.js +1 -1
  124. package/build-module/dimension-control/index.js.map +1 -1
  125. package/build-module/draggable/index.js +2 -7
  126. package/build-module/draggable/index.js.map +1 -1
  127. package/build-module/dropdown-menu/index.js +87 -10
  128. package/build-module/dropdown-menu/index.js.map +1 -1
  129. package/build-module/dropdown-menu/types.js +2 -0
  130. package/build-module/dropdown-menu/types.js.map +1 -0
  131. package/build-module/dropdown-menu-v2/index.js +149 -0
  132. package/build-module/dropdown-menu-v2/index.js.map +1 -0
  133. package/build-module/dropdown-menu-v2/styles.js +153 -0
  134. package/build-module/dropdown-menu-v2/styles.js.map +1 -0
  135. package/build-module/dropdown-menu-v2/types.js +2 -0
  136. package/build-module/dropdown-menu-v2/types.js.map +1 -0
  137. package/build-module/form-token-field/index.js +4 -3
  138. package/build-module/form-token-field/index.js.map +1 -1
  139. package/build-module/form-token-field/styles.js +3 -3
  140. package/build-module/form-token-field/styles.js.map +1 -1
  141. package/build-module/index.native.js +0 -1
  142. package/build-module/index.native.js.map +1 -1
  143. package/build-module/input-control/styles/input-control-styles.js +30 -23
  144. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  145. package/build-module/mobile/bottom-sheet/cell.native.js +16 -8
  146. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  147. package/build-module/mobile/bottom-sheet/range-cell.native.js +3 -2
  148. package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  149. package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js +4 -2
  150. package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  151. package/build-module/mobile/bottom-sheet/switch-cell.native.js +7 -2
  152. package/build-module/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
  153. package/build-module/mobile/bottom-sheet-select-control/index.native.js +4 -2
  154. package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  155. package/build-module/mobile/bottom-sheet-text-control/index.native.js +4 -2
  156. package/build-module/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
  157. package/build-module/mobile/global-styles-context/index.native.js +13 -1
  158. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  159. package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
  160. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  161. package/build-module/navigable-container/container.js +43 -19
  162. package/build-module/navigable-container/container.js.map +1 -1
  163. package/build-module/navigable-container/index.js +0 -2
  164. package/build-module/navigable-container/index.js.map +1 -1
  165. package/build-module/navigable-container/menu.js +36 -4
  166. package/build-module/navigable-container/menu.js.map +1 -1
  167. package/build-module/navigable-container/tabbable.js +44 -3
  168. package/build-module/navigable-container/tabbable.js.map +1 -1
  169. package/build-module/navigable-container/types.js +2 -0
  170. package/build-module/navigable-container/types.js.map +1 -0
  171. package/build-module/palette-edit/index.js +34 -13
  172. package/build-module/palette-edit/index.js.map +1 -1
  173. package/build-module/private-apis.js +12 -1
  174. package/build-module/private-apis.js.map +1 -1
  175. package/build-module/range-control/index.native.js +5 -2
  176. package/build-module/range-control/index.native.js.map +1 -1
  177. package/build-module/sandbox/index.native.js +6 -2
  178. package/build-module/sandbox/index.native.js.map +1 -1
  179. package/build-module/slot-fill/bubbles-virtually/fill.js +2 -1
  180. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  181. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -36
  182. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  183. package/build-module/slot-fill/bubbles-virtually/use-slot.js +12 -27
  184. package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  185. package/build-module/slot-fill/fill.js +7 -31
  186. package/build-module/slot-fill/fill.js.map +1 -1
  187. package/build-module/slot-fill/index.js +1 -2
  188. package/build-module/slot-fill/index.js.map +1 -1
  189. package/build-module/slot-fill/provider.js +0 -6
  190. package/build-module/slot-fill/provider.js.map +1 -1
  191. package/build-module/slot-fill/slot.js +0 -5
  192. package/build-module/slot-fill/slot.js.map +1 -1
  193. package/build-module/snackbar/list.js +0 -2
  194. package/build-module/snackbar/list.js.map +1 -1
  195. package/build-module/tab-panel/index.js.map +1 -1
  196. package/build-module/theme/color-algorithms.js +1 -1
  197. package/build-module/theme/color-algorithms.js.map +1 -1
  198. package/build-module/toggle-group-control/toggle-group-control/styles.js +7 -7
  199. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  200. package/build-module/toolbar/toolbar-button/index.js +1 -2
  201. package/build-module/toolbar/toolbar-button/index.js.map +1 -1
  202. package/build-module/toolbar/toolbar-item/index.js +5 -2
  203. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  204. package/build-module/utils/colors-values.js +3 -3
  205. package/build-module/utils/colors-values.js.map +1 -1
  206. package/build-module/utils/use-deprecated-props.js +25 -0
  207. package/build-module/utils/use-deprecated-props.js.map +1 -0
  208. package/build-style/style-rtl.css +67 -67
  209. package/build-style/style.css +67 -67
  210. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  211. package/build-types/autocomplete/index.d.ts.map +1 -1
  212. package/build-types/autocomplete/types.d.ts +2 -18
  213. package/build-types/autocomplete/types.d.ts.map +1 -1
  214. package/build-types/button/deprecated.d.ts +6 -0
  215. package/build-types/button/deprecated.d.ts.map +1 -1
  216. package/build-types/button/index.d.ts.map +1 -1
  217. package/build-types/button/types.d.ts +7 -0
  218. package/build-types/button/types.d.ts.map +1 -1
  219. package/build-types/card/card-media/component.d.ts +2 -1
  220. package/build-types/card/card-media/component.d.ts.map +1 -1
  221. package/build-types/card/stories/index.d.ts +21 -1
  222. package/build-types/card/stories/index.d.ts.map +1 -1
  223. package/build-types/color-picker/styles.d.ts.map +1 -1
  224. package/build-types/combobox-control/index.d.ts +1 -1
  225. package/build-types/combobox-control/index.d.ts.map +1 -1
  226. package/build-types/combobox-control/stories/index.d.ts.map +1 -1
  227. package/build-types/combobox-control/styles.d.ts +1 -1
  228. package/build-types/combobox-control/types.d.ts +8 -1
  229. package/build-types/combobox-control/types.d.ts.map +1 -1
  230. package/build-types/date-time/date-time/index.d.ts +3 -4
  231. package/build-types/date-time/date-time/index.d.ts.map +1 -1
  232. package/build-types/date-time/date-time/styles.d.ts +0 -4
  233. package/build-types/date-time/date-time/styles.d.ts.map +1 -1
  234. package/build-types/date-time/stories/date-time.d.ts.map +1 -1
  235. package/build-types/date-time/types.d.ts +0 -14
  236. package/build-types/date-time/types.d.ts.map +1 -1
  237. package/build-types/dimension-control/index.d.ts +1 -1
  238. package/build-types/draggable/index.d.ts.map +1 -1
  239. package/build-types/dropdown-menu/index.d.ts +83 -1
  240. package/build-types/dropdown-menu/index.d.ts.map +1 -1
  241. package/build-types/dropdown-menu/stories/index.d.ts +13 -0
  242. package/build-types/dropdown-menu/stories/index.d.ts.map +1 -0
  243. package/build-types/dropdown-menu/test/index.d.ts +2 -0
  244. package/build-types/dropdown-menu/test/index.d.ts.map +1 -0
  245. package/build-types/dropdown-menu/types.d.ts +134 -0
  246. package/build-types/dropdown-menu/types.d.ts.map +1 -0
  247. package/build-types/dropdown-menu-v2/index.d.ts +17 -0
  248. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -0
  249. package/build-types/dropdown-menu-v2/stories/index.d.ts +13 -0
  250. package/build-types/dropdown-menu-v2/stories/index.d.ts.map +1 -0
  251. package/build-types/dropdown-menu-v2/styles.d.ts +41 -0
  252. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -0
  253. package/build-types/dropdown-menu-v2/test/index.d.ts +2 -0
  254. package/build-types/dropdown-menu-v2/test/index.d.ts.map +1 -0
  255. package/build-types/dropdown-menu-v2/types.d.ts +242 -0
  256. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -0
  257. package/build-types/form-token-field/index.d.ts.map +1 -1
  258. package/build-types/form-token-field/styles.d.ts +1 -1
  259. package/build-types/form-token-field/types.d.ts +8 -1
  260. package/build-types/form-token-field/types.d.ts.map +1 -1
  261. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  262. package/build-types/navigable-container/container.d.ts +20 -1
  263. package/build-types/navigable-container/container.d.ts.map +1 -1
  264. package/build-types/navigable-container/index.d.ts +5 -2
  265. package/build-types/navigable-container/index.d.ts.map +1 -1
  266. package/build-types/navigable-container/menu.d.ts +45 -11
  267. package/build-types/navigable-container/menu.d.ts.map +1 -1
  268. package/build-types/navigable-container/stories/navigable-menu.d.ts +12 -0
  269. package/build-types/navigable-container/stories/navigable-menu.d.ts.map +1 -0
  270. package/build-types/navigable-container/stories/tabbable-container.d.ts +12 -0
  271. package/build-types/navigable-container/stories/tabbable-container.d.ts.map +1 -0
  272. package/build-types/navigable-container/tabbable.d.ts +52 -9
  273. package/build-types/navigable-container/tabbable.d.ts.map +1 -1
  274. package/build-types/navigable-container/test/navigable-menu.d.ts +2 -0
  275. package/build-types/navigable-container/test/navigable-menu.d.ts.map +1 -0
  276. package/build-types/navigable-container/test/tababble-container.d.ts +2 -0
  277. package/build-types/navigable-container/test/tababble-container.d.ts.map +1 -0
  278. package/build-types/navigable-container/types.d.ts +61 -0
  279. package/build-types/navigable-container/types.d.ts.map +1 -0
  280. package/build-types/navigator/navigator-back-button/component.d.ts +1 -0
  281. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  282. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
  283. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  284. package/build-types/navigator/navigator-button/component.d.ts +1 -0
  285. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  286. package/build-types/navigator/navigator-button/hook.d.ts +1 -0
  287. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  288. package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -0
  289. package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
  290. package/build-types/palette-edit/index.d.ts +1 -1
  291. package/build-types/palette-edit/index.d.ts.map +1 -1
  292. package/build-types/palette-edit/stories/index.d.ts.map +1 -1
  293. package/build-types/palette-edit/types.d.ts +8 -0
  294. package/build-types/palette-edit/types.d.ts.map +1 -1
  295. package/build-types/private-apis.d.ts.map +1 -1
  296. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  297. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
  298. package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
  299. package/build-types/slot-fill/fill.d.ts +4 -2
  300. package/build-types/slot-fill/fill.d.ts.map +1 -1
  301. package/build-types/slot-fill/index.d.ts +1 -2
  302. package/build-types/slot-fill/index.d.ts.map +1 -1
  303. package/build-types/slot-fill/provider.d.ts +0 -2
  304. package/build-types/slot-fill/provider.d.ts.map +1 -1
  305. package/build-types/slot-fill/slot.d.ts.map +1 -1
  306. package/build-types/snackbar/list.d.ts.map +1 -1
  307. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  308. package/build-types/toolbar/stories/index.d.ts.map +1 -1
  309. package/build-types/toolbar/toolbar-button/index.d.ts +6 -0
  310. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
  311. package/build-types/toolbar/toolbar-item/index.d.ts +6 -4
  312. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
  313. package/build-types/tree-grid/types.d.ts +7 -0
  314. package/build-types/tree-grid/types.d.ts.map +1 -1
  315. package/build-types/ui/context/get-styled-class-name-from-key.d.ts +1 -10
  316. package/build-types/ui/context/get-styled-class-name-from-key.d.ts.map +1 -1
  317. package/build-types/utils/use-deprecated-props.d.ts +9 -0
  318. package/build-types/utils/use-deprecated-props.d.ts.map +1 -0
  319. package/package.json +21 -20
  320. package/src/autocomplete/README.md +78 -52
  321. package/src/autocomplete/autocompleter-ui.tsx +0 -2
  322. package/src/autocomplete/index.tsx +1 -2
  323. package/src/autocomplete/types.ts +3 -19
  324. package/src/button/index.tsx +2 -0
  325. package/src/button/style.scss +18 -18
  326. package/src/button/types.ts +7 -0
  327. package/src/card/card-media/README.md +1 -1
  328. package/src/card/card-media/component.tsx +2 -1
  329. package/src/card/stories/index.tsx +47 -26
  330. package/src/checkbox-control/style.scss +1 -4
  331. package/src/color-picker/styles.ts +7 -2
  332. package/src/combobox-control/index.tsx +24 -18
  333. package/src/combobox-control/stories/index.tsx +0 -1
  334. package/src/combobox-control/styles.ts +4 -4
  335. package/src/combobox-control/types.ts +8 -1
  336. package/src/custom-gradient-picker/style.scss +2 -2
  337. package/src/date-time/README.md +0 -16
  338. package/src/date-time/date-time/index.tsx +17 -155
  339. package/src/date-time/date-time/styles.ts +0 -4
  340. package/src/date-time/stories/date-time.tsx +0 -4
  341. package/src/date-time/types.ts +0 -16
  342. package/src/dimension-control/index.tsx +1 -1
  343. package/src/draggable/index.tsx +1 -9
  344. package/src/dropdown-menu/README.md +12 -22
  345. package/src/dropdown-menu/{index.js → index.tsx} +111 -25
  346. package/src/dropdown-menu/stories/{index.js → index.tsx} +14 -22
  347. package/src/dropdown-menu/test/{index.js → index.tsx} +6 -5
  348. package/src/dropdown-menu/types.ts +143 -0
  349. package/src/dropdown-menu-v2/README.md +392 -0
  350. package/src/dropdown-menu-v2/index.tsx +241 -0
  351. package/src/dropdown-menu-v2/stories/index.tsx +193 -0
  352. package/src/dropdown-menu-v2/styles.ts +263 -0
  353. package/src/dropdown-menu-v2/test/index.tsx +816 -0
  354. package/src/dropdown-menu-v2/types.ts +250 -0
  355. package/src/form-toggle/style.scss +1 -5
  356. package/src/form-token-field/index.tsx +7 -3
  357. package/src/form-token-field/styles.ts +4 -4
  358. package/src/form-token-field/types.ts +8 -1
  359. package/src/index.native.js +0 -1
  360. package/src/input-control/styles/input-control-styles.tsx +7 -0
  361. package/src/mobile/bottom-sheet/cell.native.js +26 -5
  362. package/src/mobile/bottom-sheet/range-cell.native.js +2 -1
  363. package/src/mobile/bottom-sheet/stepper-cell/index.native.js +2 -0
  364. package/src/mobile/bottom-sheet/styles.native.scss +13 -1
  365. package/src/mobile/bottom-sheet/switch-cell.native.js +10 -2
  366. package/src/mobile/bottom-sheet-select-control/index.native.js +2 -0
  367. package/src/mobile/bottom-sheet-text-control/index.native.js +2 -0
  368. package/src/mobile/global-styles-context/index.native.js +12 -1
  369. package/src/mobile/link-picker/link-picker-results.native.js +3 -0
  370. package/src/modal/style.scss +1 -1
  371. package/src/navigable-container/README.md +24 -13
  372. package/src/navigable-container/{container.js → container.tsx} +57 -27
  373. package/src/navigable-container/{index.js → index.tsx} +0 -1
  374. package/src/navigable-container/menu.tsx +100 -0
  375. package/src/navigable-container/stories/{navigable-menu.js → navigable-menu.tsx} +15 -10
  376. package/src/navigable-container/stories/{tabbable-container.js → tabbable-container.tsx} +15 -6
  377. package/src/navigable-container/tabbable.tsx +92 -0
  378. package/src/navigable-container/test/{navigable-menu.js → navigable-menu.tsx} +3 -1
  379. package/src/navigable-container/test/{tababble-container.js → tababble-container.tsx} +53 -24
  380. package/src/navigable-container/types.ts +76 -0
  381. package/src/palette-edit/index.tsx +45 -7
  382. package/src/palette-edit/stories/index.tsx +4 -0
  383. package/src/palette-edit/types.ts +11 -0
  384. package/src/private-apis.ts +22 -0
  385. package/src/range-control/index.native.js +3 -0
  386. package/src/sandbox/index.native.js +4 -0
  387. package/src/search-control/style.scss +2 -0
  388. package/src/slot-fill/bubbles-virtually/fill.js +2 -1
  389. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -60
  390. package/src/slot-fill/bubbles-virtually/use-slot.js +14 -41
  391. package/src/slot-fill/fill.js +4 -26
  392. package/src/slot-fill/index.js +1 -3
  393. package/src/slot-fill/provider.js +0 -6
  394. package/src/slot-fill/slot.js +0 -5
  395. package/src/snackbar/list.tsx +0 -1
  396. package/src/style.scss +6 -0
  397. package/src/tab-panel/index.tsx +1 -1
  398. package/src/theme/color-algorithms.ts +1 -1
  399. package/src/theme/stories/index.tsx +1 -1
  400. package/src/theme/test/color-algorithms.ts +2 -2
  401. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +10 -6
  402. package/src/toggle-group-control/toggle-group-control/styles.ts +6 -1
  403. package/src/toolbar/stories/index.tsx +25 -26
  404. package/src/toolbar/toolbar-button/index.tsx +10 -13
  405. package/src/toolbar/toolbar-item/{index.js → index.tsx} +12 -3
  406. package/src/tooltip/style.scss +2 -2
  407. package/src/tree-grid/README.md +18 -0
  408. package/src/tree-grid/types.ts +7 -0
  409. package/src/utils/colors-values.js +3 -3
  410. package/src/utils/theme-variables.scss +4 -4
  411. package/src/utils/use-deprecated-props.ts +29 -0
  412. package/tsconfig.json +1 -0
  413. package/tsconfig.tsbuildinfo +1 -1
  414. package/build/mobile/readable-content-view/index.native.js +0 -97
  415. package/build/mobile/readable-content-view/index.native.js.map +0 -1
  416. package/build-module/mobile/readable-content-view/index.native.js +0 -81
  417. package/build-module/mobile/readable-content-view/index.native.js.map +0 -1
  418. package/src/CONTRIBUTING.md +0 -78
  419. package/src/README.md +0 -20
  420. package/src/mobile/readable-content-view/index.native.js +0 -85
  421. package/src/mobile/readable-content-view/style.native.scss +0 -30
  422. package/src/navigable-container/menu.js +0 -62
  423. package/src/navigable-container/tabbable.js +0 -46
@@ -6,21 +6,16 @@ import type { ForwardedRef } from 'react';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useState, forwardRef } from '@wordpress/element';
9
+ import { forwardRef } from '@wordpress/element';
10
10
  import { __, _x } from '@wordpress/i18n';
11
- import deprecated from '@wordpress/deprecated';
12
11
 
13
12
  /**
14
13
  * Internal dependencies
15
14
  */
16
- import Button from '../../button';
17
15
  import { default as DatePicker } from '../date';
18
16
  import { default as TimePicker } from '../time';
19
17
  import type { DateTimePickerProps } from '../types';
20
- import { Wrapper, CalendarHelp } from './styles';
21
- import { HStack } from '../../h-stack';
22
- import { Heading } from '../../heading';
23
- import { Spacer } from '../../spacer';
18
+ import { Wrapper } from './styles';
24
19
 
25
20
  export { DatePicker, TimePicker };
26
21
 
@@ -35,157 +30,26 @@ function UnforwardedDateTimePicker(
35
30
  onChange,
36
31
  events,
37
32
  startOfWeek,
38
- __nextRemoveHelpButton = false,
39
- __nextRemoveResetButton = false,
40
33
  }: DateTimePickerProps,
41
34
  ref: ForwardedRef< any >
42
35
  ) {
43
- if ( ! __nextRemoveHelpButton ) {
44
- deprecated( 'Help button in wp.components.DateTimePicker', {
45
- since: '13.4',
46
- version: '15.8', // One year of plugin releases.
47
- hint: 'Set the `__nextRemoveHelpButton` prop to `true` to remove this warning and opt in to the new behaviour, which will become the default in a future version.',
48
- } );
49
- }
50
- if ( ! __nextRemoveResetButton ) {
51
- deprecated( 'Reset button in wp.components.DateTimePicker', {
52
- since: '13.4',
53
- version: '15.8', // One year of plugin releases.
54
- hint: 'Set the `__nextRemoveResetButton` prop to `true` to remove this warning and opt in to the new behaviour, which will become the default in a future version.',
55
- } );
56
- }
57
-
58
- const [ calendarHelpIsVisible, setCalendarHelpIsVisible ] =
59
- useState( false );
60
-
61
- function onClickDescriptionToggle() {
62
- setCalendarHelpIsVisible( ! calendarHelpIsVisible );
63
- }
64
-
65
36
  return (
66
37
  <Wrapper ref={ ref } className="components-datetime" spacing={ 4 }>
67
- { ! calendarHelpIsVisible && (
68
- <>
69
- <TimePicker
70
- currentTime={ currentDate }
71
- onChange={ onChange }
72
- is12Hour={ is12Hour }
73
- />
74
- <DatePicker
75
- currentDate={ currentDate }
76
- onChange={ onChange }
77
- isInvalidDate={ isInvalidDate }
78
- events={ events }
79
- onMonthPreviewed={ onMonthPreviewed }
80
- startOfWeek={ startOfWeek }
81
- />
82
- </>
83
- ) }
84
- { calendarHelpIsVisible && (
85
- <CalendarHelp
86
- className="components-datetime__calendar-help" // Unused, for backwards compatibility.
87
- >
88
- <Heading level={ 4 }>{ __( 'Click to Select' ) }</Heading>
89
- <ul>
90
- <li>
91
- { __(
92
- 'Click the right or left arrows to select other months in the past or the future.'
93
- ) }
94
- </li>
95
- <li>{ __( 'Click the desired day to select it.' ) }</li>
96
- </ul>
97
- <Heading level={ 4 }>
98
- { __( 'Navigating with a keyboard' ) }
99
- </Heading>
100
- <ul>
101
- <li>
102
- <abbr
103
- aria-label={ _x( 'Enter', 'keyboard button' ) }
104
- >
105
-
106
- </abbr>
107
- {
108
- ' ' /* JSX removes whitespace, but a space is required for screen readers. */
109
- }
110
- <span>{ __( 'Select the date in focus.' ) }</span>
111
- </li>
112
- <li>
113
- <abbr aria-label={ __( 'Left and Right Arrows' ) }>
114
- ←/→
115
- </abbr>
116
- {
117
- ' ' /* JSX removes whitespace, but a space is required for screen readers. */
118
- }
119
- { __(
120
- 'Move backward (left) or forward (right) by one day.'
121
- ) }
122
- </li>
123
- <li>
124
- <abbr aria-label={ __( 'Up and Down Arrows' ) }>
125
- ↑/↓
126
- </abbr>
127
- {
128
- ' ' /* JSX removes whitespace, but a space is required for screen readers. */
129
- }
130
- { __(
131
- 'Move backward (up) or forward (down) by one week.'
132
- ) }
133
- </li>
134
- <li>
135
- <abbr aria-label={ __( 'Page Up and Page Down' ) }>
136
- { __( 'PgUp/PgDn' ) }
137
- </abbr>
138
- {
139
- ' ' /* JSX removes whitespace, but a space is required for screen readers. */
140
- }
141
- { __(
142
- 'Move backward (PgUp) or forward (PgDn) by one month.'
143
- ) }
144
- </li>
145
- <li>
146
- <abbr aria-label={ __( 'Home and End' ) }>
147
- { /* Translators: Home/End reffer to the 'Home' and 'End' buttons on the keyboard.*/ }
148
- { __( 'Home/End' ) }
149
- </abbr>
150
- {
151
- ' ' /* JSX removes whitespace, but a space is required for screen readers. */
152
- }
153
- { __(
154
- 'Go to the first (Home) or last (End) day of a week.'
155
- ) }
156
- </li>
157
- </ul>
158
- </CalendarHelp>
159
- ) }
160
- { ( ! __nextRemoveResetButton || ! __nextRemoveHelpButton ) && (
161
- <HStack
162
- className="components-datetime__buttons" // Unused, for backwards compatibility.
163
- >
164
- { ! __nextRemoveResetButton &&
165
- ! calendarHelpIsVisible &&
166
- currentDate && (
167
- <Button
168
- className="components-datetime__date-reset-button" // Unused, for backwards compatibility.
169
- variant="link"
170
- onClick={ () => onChange?.( null ) }
171
- >
172
- { __( 'Reset' ) }
173
- </Button>
174
- ) }
175
- <Spacer />
176
- { ! __nextRemoveHelpButton && (
177
- <Button
178
- className="components-datetime__date-help-toggle" // Unused, for backwards compatibility.
179
- variant="link"
180
- onClick={ onClickDescriptionToggle }
181
- >
182
- { calendarHelpIsVisible
183
- ? __( 'Close' )
184
- : __( 'Calendar Help' ) }
185
- </Button>
186
- ) }
187
- </HStack>
188
- ) }
38
+ <>
39
+ <TimePicker
40
+ currentTime={ currentDate }
41
+ onChange={ onChange }
42
+ is12Hour={ is12Hour }
43
+ />
44
+ <DatePicker
45
+ currentDate={ currentDate }
46
+ onChange={ onChange }
47
+ isInvalidDate={ isInvalidDate }
48
+ events={ events }
49
+ onMonthPreviewed={ onMonthPreviewed }
50
+ startOfWeek={ startOfWeek }
51
+ />
52
+ </>
189
53
  </Wrapper>
190
54
  );
191
55
  }
@@ -207,8 +71,6 @@ function UnforwardedDateTimePicker(
207
71
  * currentDate={ date }
208
72
  * onChange={ ( newDate ) => setDate( newDate ) }
209
73
  * is12Hour
210
- * __nextRemoveHelpButton
211
- * __nextRemoveResetButton
212
74
  * />
213
75
  * );
214
76
  * };
@@ -11,7 +11,3 @@ import { VStack } from '../../v-stack';
11
11
  export const Wrapper = styled( VStack )`
12
12
  box-sizing: border-box;
13
13
  `;
14
-
15
- export const CalendarHelp = styled.div`
16
- min-width: 260px;
17
- `;
@@ -52,10 +52,6 @@ const Template: ComponentStory< typeof DateTimePicker > = ( {
52
52
  export const Default: ComponentStory< typeof DateTimePicker > = Template.bind(
53
53
  {}
54
54
  );
55
- Default.args = {
56
- __nextRemoveHelpButton: true,
57
- __nextRemoveResetButton: true,
58
- };
59
55
 
60
56
  export const WithEvents: ComponentStory< typeof DateTimePicker > =
61
57
  Template.bind( {} );
@@ -73,20 +73,4 @@ export type DateTimePickerProps = Omit< DatePickerProps, 'onChange' > &
73
73
  * passed the date and time as an argument.
74
74
  */
75
75
  onChange?: ( date: string | null ) => void;
76
-
77
- /**
78
- * Start opting in to not displaying a Help button which will become the
79
- * default in a future version.
80
- *
81
- * @default false
82
- */
83
- __nextRemoveHelpButton?: boolean;
84
-
85
- /**
86
- * Start opting in to not displaying a Reset button which will become
87
- * the default in a future version.
88
- *
89
- * @default false
90
- */
91
- __nextRemoveResetButton?: boolean;
92
76
  };
@@ -23,8 +23,8 @@ import type { SelectControlSingleSelectionProps } from '../select-control/types'
23
23
  * This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
24
24
  *
25
25
  * ```jsx
26
- * import { useState } from 'react';
27
26
  * import { __experimentalDimensionControl as DimensionControl } from '@wordpress/components';
27
+ * import { useState } from '@wordpress/element';
28
28
  *
29
29
  * export default function MyCustomDimensionControl() {
30
30
  * const [ paddingSize, setPaddingSize ] = useState( '' );
@@ -212,14 +212,8 @@ export function Draggable( {
212
212
  // Update cursor to 'grabbing', document wide.
213
213
  ownerDocument.body.classList.add( bodyClass );
214
214
 
215
- // Allow the Synthetic Event to be accessed from asynchronous code.
216
- // https://reactjs.org/docs/events.html#event-pooling
217
- event.persist();
218
-
219
- let timerId: number | undefined;
220
-
221
215
  if ( onDragStart ) {
222
- timerId = setTimeout( () => onDragStart( event ) );
216
+ onDragStart( event );
223
217
  }
224
218
 
225
219
  cleanup.current = () => {
@@ -236,8 +230,6 @@ export function Draggable( {
236
230
  ownerDocument.body.classList.remove( bodyClass );
237
231
 
238
232
  ownerDocument.removeEventListener( 'dragover', throttledDragOver );
239
-
240
- clearTimeout( timerId );
241
233
  };
242
234
  }
243
235
 
@@ -131,80 +131,70 @@ const MyDropdownMenu = () => (
131
131
 
132
132
  The component accepts the following props:
133
133
 
134
- #### icon
134
+ #### `icon`: `string | null`
135
135
 
136
136
  The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug to be shown in the collapsed menu button.
137
137
 
138
- - Type: `String|null`
139
138
  - Required: No
140
139
  - Default: `"menu"`
141
140
 
142
141
  See also: [https://developer.wordpress.org/resource/dashicons/](https://developer.wordpress.org/resource/dashicons/)
143
142
 
144
- #### label
143
+ #### `label`: `string`
145
144
 
146
145
  A human-readable label to present as accessibility text on the focused collapsed menu button.
147
146
 
148
- - Type: `String`
149
147
  - Required: Yes
150
148
 
151
- #### controls
149
+ #### `controls:` `DropdownOption[] | DropdownOption[][]`
152
150
 
153
- An array of objects describing the options to be shown in the expanded menu.
151
+ An array or nested array of objects describing the options to be shown in the expanded menu.
154
152
 
155
153
  Each object should include an `icon` [Dashicon](https://developer.wordpress.org/resource/dashicons/) slug string, a human-readable `title` string, `isDisabled` boolean flag and an `onClick` function callback to invoke when the option is selected.
156
154
 
157
- A valid DropdownMenu must specify one or the other of a `controls` or `children` prop.
158
-
159
- - Type: `Array`
155
+ A valid DropdownMenu must specify a `controls` or `children` prop, or both.
160
156
  - Required: No
161
157
 
162
- #### children
158
+ #### `children`: `( callbackProps: DropdownCallbackProps ) => ReactNode`
163
159
 
164
160
  A [function render prop](https://reactjs.org/docs/render-props.html#using-props-other-than-render) which should return an element or elements valid for use in a DropdownMenu: `MenuItem`, `MenuItemsChoice`, or `MenuGroup`. Its first argument is a props object including the same values as given to a [`Dropdown`'s `renderContent`](/packages/components/src/dropdown#rendercontent) (`isOpen`, `onToggle`, `onClose`).
165
161
 
166
- A valid DropdownMenu must specify one or the other of a `controls` or `children` prop.
162
+ A valid DropdownMenu must specify a `controls` or `children` prop, or both.
167
163
 
168
- - Type: `Function`
169
164
  - Required: No
170
165
 
171
166
  See also: [https://developer.wordpress.org/resource/dashicons/](https://developer.wordpress.org/resource/dashicons/)
172
167
 
173
- #### className
168
+ #### `className`: `string`
174
169
 
175
170
  A class name to apply to the dropdown menu's toggle element wrapper.
176
171
 
177
- - Type: `String`
178
172
  - Required: No
179
173
 
180
- #### popoverProps
174
+ #### `popoverProps`: `DropdownProps[ 'popoverProps' ]`
181
175
 
182
176
  Properties of `popoverProps` object will be passed as props to the nested `Popover` component.
183
177
  Use this object to modify props available for the `Popover` component that are not already exposed in the `DropdownMenu` component, e.g.: the direction in which the popover should open relative to its parent node set with `position` prop.
184
178
 
185
- - Type: `Object`
186
179
  - Required: No
187
180
 
188
- #### toggleProps
181
+ #### `toggleProps`: `ToggleProps`
189
182
 
190
183
  Properties of `toggleProps` object will be passed as props to the nested `Button` component in the `renderToggle` implementation of the `Dropdown` component used internally.
191
184
  Use this object to modify props available for the `Button` component that are not already exposed in the `DropdownMenu` component, e.g.: the tooltip text displayed on hover set with `tooltip` prop.
192
185
 
193
- - Type: `Object`
194
186
  - Required: No
195
187
 
196
- #### menuProps
188
+ #### `menuProps`: `NavigableContainerProps`
197
189
 
198
190
  Properties of `menuProps` object will be passed as props to the nested `NavigableMenu` component in the `renderContent` implementation of the `Dropdown` component used internally.
199
191
  Use this object to modify props available for the `NavigableMenu` component that are not already exposed in the `DropdownMenu` component, e.g.: the orientation of the menu set with `orientation` prop.
200
192
 
201
- - Type: `Object`
202
193
  - Required: No
203
194
 
204
- #### disableOpenOnArrowDown
195
+ #### `disableOpenOnArrowDown`: `boolean`
205
196
 
206
197
  In some contexts, the arrow down key used to open the dropdown menu might need to be disabled—for example when that key is used to perform another action.
207
198
 
208
- - Type: `boolean`
209
199
  - Required: No
210
200
  - Default: `false`
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * External dependencies
4
3
  */
@@ -15,9 +14,12 @@ import { menu } from '@wordpress/icons';
15
14
  import Button from '../button';
16
15
  import Dropdown from '../dropdown';
17
16
  import { NavigableMenu } from '../navigable-container';
17
+ import type { DropdownMenuProps, DropdownOption } from './types';
18
18
 
19
- function mergeProps( defaultProps = {}, props = {} ) {
20
- const mergedProps = {
19
+ function mergeProps<
20
+ T extends { className?: string; [ key: string ]: unknown }
21
+ >( defaultProps: Partial< T > = {}, props: T = {} as T ) {
22
+ const mergedProps: T = {
21
23
  ...defaultProps,
22
24
  ...props,
23
25
  };
@@ -32,17 +34,92 @@ function mergeProps( defaultProps = {}, props = {} ) {
32
34
  return mergedProps;
33
35
  }
34
36
 
37
+ function isFunction( maybeFunc: unknown ): maybeFunc is () => void {
38
+ return typeof maybeFunc === 'function';
39
+ }
40
+
35
41
  /**
36
- * Whether the argument is a function.
37
42
  *
38
- * @param {*} maybeFunc The argument to check.
39
- * @return {boolean} True if the argument is a function, false otherwise.
43
+ * The DropdownMenu displays a list of actions (each contained in a MenuItem,
44
+ * MenuItemsChoice, or MenuGroup) in a compact way. It appears in a Popover
45
+ * after the user has interacted with an element (a button or icon) or when
46
+ * they perform a specific action.
47
+ *
48
+ * Render a Dropdown Menu with a set of controls:
49
+ *
50
+ * ```jsx
51
+ * import { DropdownMenu } from '@wordpress/components';
52
+ * import {
53
+ * more,
54
+ * arrowLeft,
55
+ * arrowRight,
56
+ * arrowUp,
57
+ * arrowDown,
58
+ * } from '@wordpress/icons';
59
+ *
60
+ * const MyDropdownMenu = () => (
61
+ * <DropdownMenu
62
+ * icon={ more }
63
+ * label="Select a direction"
64
+ * controls={ [
65
+ * {
66
+ * title: 'Up',
67
+ * icon: arrowUp,
68
+ * onClick: () => console.log( 'up' ),
69
+ * },
70
+ * {
71
+ * title: 'Right',
72
+ * icon: arrowRight,
73
+ * onClick: () => console.log( 'right' ),
74
+ * },
75
+ * {
76
+ * title: 'Down',
77
+ * icon: arrowDown,
78
+ * onClick: () => console.log( 'down' ),
79
+ * },
80
+ * {
81
+ * title: 'Left',
82
+ * icon: arrowLeft,
83
+ * onClick: () => console.log( 'left' ),
84
+ * },
85
+ * ] }
86
+ * />
87
+ * );
88
+ * ```
89
+ *
90
+ * Alternatively, specify a `children` function which returns elements valid for
91
+ * use in a DropdownMenu: `MenuItem`, `MenuItemsChoice`, or `MenuGroup`.
92
+ *
93
+ * ```jsx
94
+ * import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
95
+ * import { more, arrowUp, arrowDown, trash } from '@wordpress/icons';
96
+ *
97
+ * const MyDropdownMenu = () => (
98
+ * <DropdownMenu icon={ more } label="Select a direction">
99
+ * { ( { onClose } ) => (
100
+ * <>
101
+ * <MenuGroup>
102
+ * <MenuItem icon={ arrowUp } onClick={ onClose }>
103
+ * Move Up
104
+ * </MenuItem>
105
+ * <MenuItem icon={ arrowDown } onClick={ onClose }>
106
+ * Move Down
107
+ * </MenuItem>
108
+ * </MenuGroup>
109
+ * <MenuGroup>
110
+ * <MenuItem icon={ trash } onClick={ onClose }>
111
+ * Remove
112
+ * </MenuItem>
113
+ * </MenuGroup>
114
+ * </>
115
+ * ) }
116
+ * </DropdownMenu>
117
+ * );
118
+ * ```
119
+ *
40
120
  */
41
- function isFunction( maybeFunc ) {
42
- return typeof maybeFunc === 'function';
43
- }
44
121
 
45
- function DropdownMenu( dropdownMenuProps ) {
122
+ function DropdownMenu( dropdownMenuProps: DropdownMenuProps ) {
46
123
  const {
47
124
  children,
48
125
  className,
@@ -62,13 +139,18 @@ function DropdownMenu( dropdownMenuProps ) {
62
139
  }
63
140
 
64
141
  // Normalize controls to nested array of objects (sets of controls)
65
- let controlSets;
142
+ let controlSets: DropdownOption[][];
66
143
  if ( controls?.length ) {
144
+ // @ts-expect-error The check below is needed because `DropdownMenus`
145
+ // rendered by `ToolBarGroup` receive controls as a nested array.
67
146
  controlSets = controls;
68
147
  if ( ! Array.isArray( controlSets[ 0 ] ) ) {
69
- controlSets = [ controlSets ];
148
+ // This is not ideal, but at this point we know that `controls` is
149
+ // not a nested array, even if TypeScript doesn't.
150
+ controlSets = [ controls as DropdownOption[] ];
70
151
  }
71
152
  }
153
+
72
154
  const mergedPopoverProps = mergeProps(
73
155
  {
74
156
  className: 'components-dropdown-menu__popover',
@@ -81,7 +163,7 @@ function DropdownMenu( dropdownMenuProps ) {
81
163
  className={ classnames( 'components-dropdown-menu', className ) }
82
164
  popoverProps={ mergedPopoverProps }
83
165
  renderToggle={ ( { isOpen, onToggle } ) => {
84
- const openOnArrowDown = ( event ) => {
166
+ const openOnArrowDown = ( event: React.KeyboardEvent ) => {
85
167
  if ( disableOpenOnArrowDown ) {
86
168
  return;
87
169
  }
@@ -110,18 +192,22 @@ function DropdownMenu( dropdownMenuProps ) {
110
192
  <Toggle
111
193
  { ...mergedToggleProps }
112
194
  icon={ icon }
113
- onClick={ ( event ) => {
114
- onToggle( event );
115
- if ( mergedToggleProps.onClick ) {
116
- mergedToggleProps.onClick( event );
117
- }
118
- } }
119
- onKeyDown={ ( event ) => {
120
- openOnArrowDown( event );
121
- if ( mergedToggleProps.onKeyDown ) {
122
- mergedToggleProps.onKeyDown( event );
123
- }
124
- } }
195
+ onClick={
196
+ ( ( event ) => {
197
+ onToggle();
198
+ if ( mergedToggleProps.onClick ) {
199
+ mergedToggleProps.onClick( event );
200
+ }
201
+ } ) as React.MouseEventHandler< HTMLButtonElement >
202
+ }
203
+ onKeyDown={
204
+ ( ( event ) => {
205
+ openOnArrowDown( event );
206
+ if ( mergedToggleProps.onKeyDown ) {
207
+ mergedToggleProps.onKeyDown( event );
208
+ }
209
+ } ) as React.KeyboardEventHandler< HTMLButtonElement >
210
+ }
125
211
  aria-haspopup="true"
126
212
  aria-expanded={ isOpen }
127
213
  label={ label }
@@ -1,8 +1,13 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ComponentMeta, ComponentStory } from '@storybook/react';
1
5
  /**
2
6
  * Internal dependencies
3
7
  */
4
- import DropdownMenu from '../';
5
- import { MenuGroup, MenuItem } from '../../';
8
+ import DropdownMenu from '..';
9
+ import MenuItem from '../../menu-item';
10
+ import MenuGroup from '../../menu-group';
6
11
 
7
12
  /**
8
13
  * WordPress dependencies
@@ -16,37 +21,24 @@ import {
16
21
  trash,
17
22
  } from '@wordpress/icons';
18
23
 
19
- export default {
24
+ const meta: ComponentMeta< typeof DropdownMenu > = {
20
25
  title: 'Components/DropdownMenu',
21
26
  component: DropdownMenu,
27
+ parameters: {
28
+ controls: { expanded: true },
29
+ docs: { source: { state: 'open' } },
30
+ },
22
31
  argTypes: {
23
- className: { control: { type: 'text' } },
24
- children: { control: { type: null } },
25
- disableOpenOnArrowDown: { control: { type: 'boolean' } },
26
32
  icon: {
27
33
  options: [ 'menu', 'chevronDown', 'more' ],
28
34
  mapping: { menu, chevronDown, more },
29
35
  control: { type: 'select' },
30
36
  },
31
- menuProps: {
32
- control: { type: 'object' },
33
- },
34
- noIcons: { control: { type: 'boolean' } },
35
- popoverProps: {
36
- control: { type: 'object' },
37
- },
38
- text: { control: { type: 'text' } },
39
- toggleProps: {
40
- control: { type: 'object' },
41
- },
42
- },
43
- parameters: {
44
- controls: { expanded: true },
45
- docs: { source: { state: 'open' } },
46
37
  },
47
38
  };
39
+ export default meta;
48
40
 
49
- const Template = ( props ) => (
41
+ const Template: ComponentStory< typeof DropdownMenu > = ( props ) => (
50
42
  <div style={ { height: 150 } }>
51
43
  <DropdownMenu { ...props } />
52
44
  </div>
@@ -12,19 +12,19 @@ import { arrowLeft, arrowRight, arrowUp, arrowDown } from '@wordpress/icons';
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
- import DropdownMenu from '../';
16
- import { MenuItem } from '../../';
15
+ import DropdownMenu from '..';
16
+ import MenuItem from '../../menu-item';
17
17
 
18
18
  describe( 'DropdownMenu', () => {
19
19
  it( 'should not render when neither controls nor children are assigned', () => {
20
- render( <DropdownMenu /> );
20
+ render( <DropdownMenu label="Open dropdown" /> );
21
21
 
22
22
  // The button toggle should not even be rendered
23
23
  expect( screen.queryByRole( 'button' ) ).not.toBeInTheDocument();
24
24
  } );
25
25
 
26
26
  it( 'should not render when controls are empty and children is not specified', () => {
27
- render( <DropdownMenu controls={ [] } /> );
27
+ render( <DropdownMenu label="Open dropdown" controls={ [] } /> );
28
28
 
29
29
  // The button toggle should not even be rendered
30
30
  expect( screen.queryByRole( 'button' ) ).not.toBeInTheDocument();
@@ -56,7 +56,7 @@ describe( 'DropdownMenu', () => {
56
56
  },
57
57
  ];
58
58
 
59
- render( <DropdownMenu controls={ controls } /> );
59
+ render( <DropdownMenu label="Open dropdown" controls={ controls } /> );
60
60
 
61
61
  // Move focus on the toggle button
62
62
  await user.tab();
@@ -78,6 +78,7 @@ describe( 'DropdownMenu', () => {
78
78
 
79
79
  render(
80
80
  <DropdownMenu
81
+ label="Open dropdown"
81
82
  children={ ( { onClose } ) => <MenuItem onClick={ onClose } /> }
82
83
  />
83
84
  );