@wordpress/components 23.0.0 → 23.2.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 (457) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/CONTRIBUTING.md +0 -21
  3. package/LICENSE.md +1 -1
  4. package/build/autocomplete/index.js +1 -3
  5. package/build/autocomplete/index.js.map +1 -1
  6. package/build/border-box-control/border-box-control/component.js +0 -3
  7. package/build/border-box-control/border-box-control/component.js.map +1 -1
  8. package/build/border-box-control/border-box-control/hook.js +0 -2
  9. package/build/border-box-control/border-box-control/hook.js.map +1 -1
  10. package/build/border-box-control/border-box-control-split-controls/component.js +0 -2
  11. package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  12. package/build/border-box-control/border-box-control-split-controls/hook.js +0 -2
  13. package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
  14. package/build/border-control/border-control/component.js +0 -2
  15. package/build/border-control/border-control/component.js.map +1 -1
  16. package/build/border-control/border-control/hook.js +0 -2
  17. package/build/border-control/border-control/hook.js.map +1 -1
  18. package/build/border-control/border-control-dropdown/component.js +6 -11
  19. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  20. package/build/border-control/border-control-dropdown/hook.js +0 -2
  21. package/build/border-control/border-control-dropdown/hook.js.map +1 -1
  22. package/build/color-palette/index.js +5 -8
  23. package/build/color-palette/index.js.map +1 -1
  24. package/build/color-picker/component.js +1 -0
  25. package/build/color-picker/component.js.map +1 -1
  26. package/build/color-picker/styles.js +8 -10
  27. package/build/color-picker/styles.js.map +1 -1
  28. package/build/combobox-control/index.js +5 -1
  29. package/build/combobox-control/index.js.map +1 -1
  30. package/build/dimension-control/index.js.map +1 -1
  31. package/build/dropdown/index.js +45 -10
  32. package/build/dropdown/index.js.map +1 -1
  33. package/build/focal-point-picker/utils.js +1 -1
  34. package/build/focal-point-picker/utils.js.map +1 -1
  35. package/build/gradient-picker/index.js +1 -2
  36. package/build/gradient-picker/index.js.map +1 -1
  37. package/build/higher-order/navigate-regions/index.js +4 -3
  38. package/build/higher-order/navigate-regions/index.js.map +1 -1
  39. package/build/index.js +7 -25
  40. package/build/index.js.map +1 -1
  41. package/build/index.native.js +8 -18
  42. package/build/index.native.js.map +1 -1
  43. package/build/item-group/item/component.js +27 -3
  44. package/build/item-group/item/component.js.map +1 -1
  45. package/build/item-group/item-group/component.js +26 -3
  46. package/build/item-group/item-group/component.js.map +1 -1
  47. package/build/item-group/styles.js +14 -14
  48. package/build/item-group/styles.js.map +1 -1
  49. package/build/mobile/bottom-sheet/picker-cell.native.js +1 -9
  50. package/build/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
  51. package/build/mobile/global-styles-context/utils.native.js +30 -12
  52. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  53. package/build/panel/row.js +5 -3
  54. package/build/panel/row.js.map +1 -1
  55. package/build/query-controls/index.js +1 -0
  56. package/build/query-controls/index.js.map +1 -1
  57. package/build/resizable-box/index.js +5 -4
  58. package/build/resizable-box/index.js.map +1 -1
  59. package/build/responsive-wrapper/index.js +18 -1
  60. package/build/responsive-wrapper/index.js.map +1 -1
  61. package/build/responsive-wrapper/types.js +6 -0
  62. package/build/responsive-wrapper/types.js.map +1 -0
  63. package/build/sandbox/index.js +35 -24
  64. package/build/sandbox/index.js.map +1 -1
  65. package/build/sandbox/types.js +6 -0
  66. package/build/sandbox/types.js.map +1 -0
  67. package/build/tab-panel/index.js +15 -9
  68. package/build/tab-panel/index.js.map +1 -1
  69. package/build/toolbar/index.js +42 -60
  70. package/build/toolbar/index.js.map +1 -1
  71. package/build/toolbar/toolbar/index.js +74 -0
  72. package/build/toolbar/toolbar/index.js.map +1 -0
  73. package/build/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  74. package/build/toolbar/toolbar/toolbar-container.js.map +1 -0
  75. package/build/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  76. package/build/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  77. package/build/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  78. package/build/toolbar/toolbar-button/index.js.map +1 -0
  79. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  80. package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  81. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  82. package/build/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  83. package/build/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  84. package/build/toolbar/toolbar-context/index.js.map +1 -0
  85. package/build/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  86. package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  87. package/build/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  88. package/build/toolbar/toolbar-group/index.js.map +1 -0
  89. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  90. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  91. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  92. package/build/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  93. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  94. package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  95. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  96. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  97. package/build/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  98. package/build/toolbar/toolbar-item/index.js.map +1 -0
  99. package/build/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  100. package/build/toolbar/toolbar-item/index.native.js.map +1 -0
  101. package/build/tree-grid/index.js +3 -3
  102. package/build/tree-grid/index.js.map +1 -1
  103. package/build-module/autocomplete/index.js +1 -2
  104. package/build-module/autocomplete/index.js.map +1 -1
  105. package/build-module/border-box-control/border-box-control/component.js +0 -3
  106. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  107. package/build-module/border-box-control/border-box-control/hook.js +0 -2
  108. package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
  109. package/build-module/border-box-control/border-box-control-split-controls/component.js +0 -2
  110. package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  111. package/build-module/border-box-control/border-box-control-split-controls/hook.js +0 -2
  112. package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
  113. package/build-module/border-control/border-control/component.js +0 -2
  114. package/build-module/border-control/border-control/component.js.map +1 -1
  115. package/build-module/border-control/border-control/hook.js +0 -2
  116. package/build-module/border-control/border-control/hook.js.map +1 -1
  117. package/build-module/border-control/border-control-dropdown/component.js +6 -11
  118. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  119. package/build-module/border-control/border-control-dropdown/hook.js +0 -2
  120. package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
  121. package/build-module/color-palette/index.js +5 -8
  122. package/build-module/color-palette/index.js.map +1 -1
  123. package/build-module/color-picker/component.js +1 -0
  124. package/build-module/color-picker/component.js.map +1 -1
  125. package/build-module/color-picker/styles.js +8 -9
  126. package/build-module/color-picker/styles.js.map +1 -1
  127. package/build-module/combobox-control/index.js +5 -1
  128. package/build-module/combobox-control/index.js.map +1 -1
  129. package/build-module/dimension-control/index.js +1 -2
  130. package/build-module/dimension-control/index.js.map +1 -1
  131. package/build-module/dropdown/index.js +44 -10
  132. package/build-module/dropdown/index.js.map +1 -1
  133. package/build-module/focal-point-picker/utils.js +1 -1
  134. package/build-module/focal-point-picker/utils.js.map +1 -1
  135. package/build-module/gradient-picker/index.js +1 -2
  136. package/build-module/gradient-picker/index.js.map +1 -1
  137. package/build-module/higher-order/navigate-regions/index.js +4 -3
  138. package/build-module/higher-order/navigate-regions/index.js.map +1 -1
  139. package/build-module/index.js +1 -7
  140. package/build-module/index.js.map +1 -1
  141. package/build-module/index.native.js +1 -6
  142. package/build-module/index.native.js.map +1 -1
  143. package/build-module/item-group/item/component.js +26 -2
  144. package/build-module/item-group/item/component.js.map +1 -1
  145. package/build-module/item-group/item-group/component.js +25 -2
  146. package/build-module/item-group/item-group/component.js.map +1 -1
  147. package/build-module/item-group/styles.js +14 -14
  148. package/build-module/item-group/styles.js.map +1 -1
  149. package/build-module/mobile/bottom-sheet/picker-cell.native.js +1 -8
  150. package/build-module/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
  151. package/build-module/mobile/global-styles-context/utils.native.js +31 -13
  152. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  153. package/build-module/panel/row.js +5 -3
  154. package/build-module/panel/row.js.map +1 -1
  155. package/build-module/query-controls/index.js +1 -0
  156. package/build-module/query-controls/index.js.map +1 -1
  157. package/build-module/resizable-box/index.js +3 -2
  158. package/build-module/resizable-box/index.js.map +1 -1
  159. package/build-module/responsive-wrapper/index.js +20 -1
  160. package/build-module/responsive-wrapper/index.js.map +1 -1
  161. package/build-module/responsive-wrapper/types.js +2 -0
  162. package/build-module/responsive-wrapper/types.js.map +1 -0
  163. package/build-module/sandbox/index.js +37 -23
  164. package/build-module/sandbox/index.js.map +1 -1
  165. package/build-module/sandbox/types.js +2 -0
  166. package/build-module/sandbox/types.js.map +1 -0
  167. package/build-module/tab-panel/index.js +15 -8
  168. package/build-module/tab-panel/index.js.map +1 -1
  169. package/build-module/toolbar/index.js +6 -58
  170. package/build-module/toolbar/index.js.map +1 -1
  171. package/build-module/toolbar/toolbar/index.js +59 -0
  172. package/build-module/toolbar/toolbar/index.js.map +1 -0
  173. package/build-module/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  174. package/{build → build-module/toolbar}/toolbar/toolbar-container.js.map +1 -1
  175. package/build-module/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  176. package/build-module/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  177. package/build-module/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  178. package/build-module/toolbar/toolbar-button/index.js.map +1 -0
  179. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  180. package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  181. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  182. package/build-module/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  183. package/build-module/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  184. package/build-module/toolbar/toolbar-context/index.js.map +1 -0
  185. package/build-module/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  186. package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  187. package/build-module/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  188. package/build-module/toolbar/toolbar-group/index.js.map +1 -0
  189. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  190. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  191. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  192. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  193. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  194. package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  195. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  196. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  197. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  198. package/build-module/toolbar/toolbar-item/index.js.map +1 -0
  199. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  200. package/build-module/toolbar/toolbar-item/index.native.js.map +1 -0
  201. package/build-module/tree-grid/index.js +3 -3
  202. package/build-module/tree-grid/index.js.map +1 -1
  203. package/build-style/style-rtl.css +19 -32
  204. package/build-style/style.css +19 -32
  205. package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
  206. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  207. package/build-types/border-box-control/border-box-control/hook.d.ts +0 -1
  208. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  209. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
  210. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
  211. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +0 -1
  212. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
  213. package/build-types/border-box-control/stories/index.d.ts +1 -1
  214. package/build-types/border-control/border-control/component.d.ts +1 -1
  215. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  216. package/build-types/border-control/border-control/hook.d.ts +0 -1
  217. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  218. package/build-types/border-control/border-control-dropdown/component.d.ts +1 -1
  219. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  220. package/build-types/border-control/border-control-dropdown/hook.d.ts +0 -1
  221. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  222. package/build-types/border-control/stories/index.d.ts +6 -6
  223. package/build-types/border-control/stories/index.d.ts.map +1 -1
  224. package/build-types/border-control/types.d.ts +1 -1
  225. package/build-types/border-control/types.d.ts.map +1 -1
  226. package/build-types/color-palette/index.d.ts +2 -3
  227. package/build-types/color-palette/index.d.ts.map +1 -1
  228. package/build-types/color-palette/stories/index.d.ts +2 -9
  229. package/build-types/color-palette/stories/index.d.ts.map +1 -1
  230. package/build-types/color-palette/types.d.ts +3 -16
  231. package/build-types/color-palette/types.d.ts.map +1 -1
  232. package/build-types/color-picker/component.d.ts.map +1 -1
  233. package/build-types/color-picker/styles.d.ts.map +1 -1
  234. package/build-types/dashicon/types.d.ts +0 -4
  235. package/build-types/dashicon/types.d.ts.map +1 -1
  236. package/build-types/disabled/stories/index.d.ts.map +1 -1
  237. package/build-types/dropdown/index.d.ts +29 -1
  238. package/build-types/dropdown/index.d.ts.map +1 -1
  239. package/build-types/dropdown/stories/index.d.ts +23 -0
  240. package/build-types/dropdown/stories/index.d.ts.map +1 -0
  241. package/build-types/dropdown/test/index.d.ts +2 -0
  242. package/build-types/dropdown/test/index.d.ts.map +1 -0
  243. package/build-types/dropdown/types.d.ts +101 -0
  244. package/build-types/dropdown/types.d.ts.map +1 -1
  245. package/build-types/focal-point-picker/utils.d.ts.map +1 -1
  246. package/build-types/icon/stories/index.d.ts +22 -0
  247. package/build-types/icon/stories/index.d.ts.map +1 -0
  248. package/build-types/item-group/item/component.d.ts +24 -2
  249. package/build-types/item-group/item/component.d.ts.map +1 -1
  250. package/build-types/item-group/item-group/component.d.ts +23 -2
  251. package/build-types/item-group/item-group/component.d.ts.map +1 -1
  252. package/build-types/item-group/stories/index.d.ts +15 -0
  253. package/build-types/item-group/stories/index.d.ts.map +1 -0
  254. package/build-types/item-group/styles.d.ts.map +1 -1
  255. package/build-types/radio-context/index.d.ts +6 -0
  256. package/build-types/radio-context/index.d.ts.map +1 -0
  257. package/build-types/resizable-box/index.d.ts +6 -7
  258. package/build-types/resizable-box/index.d.ts.map +1 -1
  259. package/build-types/resizable-box/stories/index.d.ts +61 -0
  260. package/build-types/resizable-box/stories/index.d.ts.map +1 -0
  261. package/build-types/responsive-wrapper/index.d.ts +24 -0
  262. package/build-types/responsive-wrapper/index.d.ts.map +1 -0
  263. package/build-types/responsive-wrapper/stories/index.d.ts +12 -0
  264. package/build-types/responsive-wrapper/stories/index.d.ts.map +1 -0
  265. package/build-types/responsive-wrapper/types.d.ts +22 -0
  266. package/build-types/responsive-wrapper/types.d.ts.map +1 -0
  267. package/build-types/sandbox/index.d.ts +19 -0
  268. package/build-types/sandbox/index.d.ts.map +1 -0
  269. package/build-types/sandbox/stories/index.d.ts +12 -0
  270. package/build-types/sandbox/stories/index.d.ts.map +1 -0
  271. package/build-types/sandbox/test/index.d.ts +2 -0
  272. package/build-types/sandbox/test/index.d.ts.map +1 -0
  273. package/build-types/sandbox/types.d.ts +36 -0
  274. package/build-types/sandbox/types.d.ts.map +1 -0
  275. package/build-types/tab-panel/index.d.ts.map +1 -1
  276. package/build-types/tab-panel/stories/index.d.ts +1 -0
  277. package/build-types/tab-panel/stories/index.d.ts.map +1 -1
  278. package/build-types/tab-panel/types.d.ts +10 -4
  279. package/build-types/tab-panel/types.d.ts.map +1 -1
  280. package/package.json +17 -17
  281. package/src/autocomplete/index.js +1 -3
  282. package/src/autocomplete/test/index.js +2 -0
  283. package/src/base-control/test/index.tsx +1 -0
  284. package/src/border-box-control/border-box-control/component.tsx +0 -7
  285. package/src/border-box-control/border-box-control/hook.ts +0 -2
  286. package/src/border-box-control/border-box-control-split-controls/component.tsx +0 -2
  287. package/src/border-box-control/border-box-control-split-controls/hook.ts +0 -2
  288. package/src/border-box-control/test/index.js +2 -0
  289. package/src/border-control/border-control/component.tsx +0 -4
  290. package/src/border-control/border-control/hook.ts +0 -2
  291. package/src/border-control/border-control-dropdown/component.tsx +11 -17
  292. package/src/border-control/border-control-dropdown/hook.ts +0 -2
  293. package/src/border-control/stories/index.tsx +0 -1
  294. package/src/border-control/test/index.js +70 -67
  295. package/src/border-control/types.ts +1 -4
  296. package/src/box-control/test/index.js +2 -0
  297. package/src/checkbox-control/test/index.tsx +2 -0
  298. package/src/color-palette/index.tsx +12 -12
  299. package/src/color-palette/stories/index.tsx +0 -13
  300. package/src/color-palette/test/index.tsx +2 -0
  301. package/src/color-palette/types.ts +3 -17
  302. package/src/color-picker/component.tsx +1 -0
  303. package/src/color-picker/stories/index.js +20 -60
  304. package/src/color-picker/styles.ts +0 -5
  305. package/src/color-picker/test/index.js +2 -0
  306. package/src/combobox-control/index.js +9 -1
  307. package/src/combobox-control/test/index.js +2 -0
  308. package/src/confirm-dialog/test/index.js +2 -0
  309. package/src/dashicon/types.ts +0 -6
  310. package/src/date-time/date/test/index.tsx +2 -0
  311. package/src/date-time/time/test/index.tsx +2 -0
  312. package/src/dimension-control/index.js +2 -3
  313. package/src/dimension-control/test/index.test.js +2 -0
  314. package/src/disabled/stories/index.tsx +6 -2
  315. package/src/disabled/test/index.tsx +2 -0
  316. package/src/dropdown/README.md +41 -46
  317. package/src/dropdown/{index.js → index.tsx} +57 -13
  318. package/src/dropdown/stories/{index.js → index.tsx} +21 -8
  319. package/src/dropdown/test/{index.js → index.tsx} +9 -9
  320. package/src/dropdown/types.ts +107 -0
  321. package/src/dropdown-menu/README.md +2 -3
  322. package/src/dropdown-menu/test/index.js +2 -0
  323. package/src/external-link/test/index.tsx +2 -0
  324. package/src/focal-point-picker/stories/index.tsx +1 -1
  325. package/src/focal-point-picker/test/index.js +2 -0
  326. package/src/focal-point-picker/utils.ts +4 -1
  327. package/src/font-size-picker/test/index.tsx +2 -0
  328. package/src/form-file-upload/test/index.tsx +2 -0
  329. package/src/form-toggle/test/index.tsx +2 -0
  330. package/src/form-token-field/test/index.tsx +3 -0
  331. package/src/gradient-picker/index.js +1 -2
  332. package/src/gradient-picker/stories/index.js +0 -1
  333. package/src/guide/stories/index.js +14 -41
  334. package/src/guide/test/index.js +2 -0
  335. package/src/higher-order/navigate-regions/index.js +5 -2
  336. package/src/higher-order/navigate-regions/style.scss +13 -39
  337. package/src/higher-order/with-filters/test/index.js +70 -74
  338. package/src/higher-order/with-focus-outside/test/index.js +2 -0
  339. package/src/higher-order/with-focus-return/test/index.js +2 -0
  340. package/src/higher-order/with-notices/test/index.js +1 -0
  341. package/src/icon/stories/index.tsx +103 -0
  342. package/src/index.js +8 -7
  343. package/src/index.native.js +8 -6
  344. package/src/input-control/test/index.js +3 -0
  345. package/src/isolated-event-container/test/index.js +2 -0
  346. package/src/item-group/item/component.tsx +26 -2
  347. package/src/item-group/item-group/component.tsx +25 -2
  348. package/src/item-group/stories/index.tsx +103 -0
  349. package/src/item-group/styles.ts +1 -0
  350. package/src/item-group/test/__snapshots__/index.js.snap +11 -10
  351. package/src/mobile/bottom-sheet/picker-cell.native.js +1 -6
  352. package/src/mobile/global-styles-context/utils.native.js +17 -16
  353. package/src/modal/test/index.tsx +1 -3
  354. package/src/navigable-container/test/navigable-menu.js +2 -0
  355. package/src/navigable-container/test/tababble-container.js +2 -0
  356. package/src/navigation/test/index.js +2 -0
  357. package/src/navigator/test/index.tsx +2 -0
  358. package/src/notice/stories/index.js +30 -58
  359. package/src/notice/test/index.js +8 -3
  360. package/src/number-control/test/index.tsx +2 -0
  361. package/src/panel/row.js +3 -3
  362. package/src/panel/stories/index.js +62 -80
  363. package/src/panel/test/__snapshots__/body.js.snap +9 -0
  364. package/src/panel/test/body.js +71 -62
  365. package/src/placeholder/style.scss +1 -1
  366. package/src/placeholder/test/index.tsx +3 -0
  367. package/src/query-controls/index.js +1 -0
  368. package/src/resizable-box/README.md +2 -2
  369. package/src/resizable-box/index.tsx +7 -6
  370. package/src/resizable-box/stories/index.tsx +92 -0
  371. package/src/responsive-wrapper/README.md +29 -0
  372. package/src/responsive-wrapper/{index.js → index.tsx} +23 -2
  373. package/src/responsive-wrapper/stories/index.tsx +38 -0
  374. package/src/responsive-wrapper/types.ts +20 -0
  375. package/src/sandbox/README.md +45 -2
  376. package/src/sandbox/{index.js → index.tsx} +47 -24
  377. package/src/sandbox/stories/index.tsx +32 -0
  378. package/src/sandbox/test/{index.js → index.tsx} +9 -4
  379. package/src/sandbox/types.ts +34 -0
  380. package/src/select-control/test/select-control.tsx +2 -0
  381. package/src/slot-fill/stories/index.js +12 -17
  382. package/src/style.scss +3 -3
  383. package/src/tab-panel/README.md +1 -0
  384. package/src/tab-panel/index.tsx +20 -7
  385. package/src/tab-panel/stories/index.tsx +20 -0
  386. package/src/tab-panel/test/index.tsx +91 -0
  387. package/src/tab-panel/types.ts +10 -4
  388. package/src/text-highlight/test/index.tsx +1 -0
  389. package/src/toggle-group-control/test/index.tsx +2 -0
  390. package/src/toolbar/index.js +6 -52
  391. package/src/toolbar/stories/index.js +2 -9
  392. package/src/{toolbar-button/stories/index.js → toolbar/stories/toolbar-button.js} +1 -2
  393. package/src/{toolbar-group/stories/index.js → toolbar/stories/toolbar-group.js} +1 -1
  394. package/src/toolbar/test/index.js +1 -2
  395. package/src/{toolbar-group/test/index.js → toolbar/test/toolbar-group.js} +3 -1
  396. package/src/toolbar/{README.md → toolbar/README.md} +0 -0
  397. package/src/toolbar/toolbar/index.js +52 -0
  398. package/src/toolbar/{style.native.scss → toolbar/style.native.scss} +0 -0
  399. package/src/toolbar/{style.scss → toolbar/style.scss} +1 -1
  400. package/src/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  401. package/src/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  402. package/src/{toolbar-button → toolbar/toolbar-button}/README.md +0 -0
  403. package/src/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  404. package/src/{toolbar-button → toolbar/toolbar-button}/style.scss +0 -0
  405. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  406. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  407. package/src/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  408. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/README.md +0 -0
  409. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  410. package/src/{toolbar-group → toolbar/toolbar-group}/README.md +0 -0
  411. package/src/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  412. package/src/{toolbar-group → toolbar/toolbar-group}/style.native.scss +0 -0
  413. package/src/{toolbar-group → toolbar/toolbar-group}/style.scss +0 -0
  414. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  415. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  416. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  417. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  418. package/src/{toolbar-item → toolbar/toolbar-item}/README.md +0 -0
  419. package/src/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  420. package/src/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  421. package/src/tooltip/stories/index.js +68 -78
  422. package/src/tooltip/test/index.js +2 -0
  423. package/src/tree-grid/index.js +2 -4
  424. package/src/unit-control/test/index.tsx +3 -0
  425. package/src/utils/hooks/test/use-latest-ref.js +2 -0
  426. package/tsconfig.json +0 -7
  427. package/tsconfig.tsbuildinfo +1 -1
  428. package/build/toolbar/toolbar-container.native.js.map +0 -1
  429. package/build/toolbar-button/index.js.map +0 -1
  430. package/build/toolbar-button/toolbar-button-container.js.map +0 -1
  431. package/build/toolbar-button/toolbar-button-container.native.js.map +0 -1
  432. package/build/toolbar-context/index.js.map +0 -1
  433. package/build/toolbar-dropdown-menu/index.js.map +0 -1
  434. package/build/toolbar-group/index.js.map +0 -1
  435. package/build/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  436. package/build/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  437. package/build/toolbar-group/toolbar-group-container.js.map +0 -1
  438. package/build/toolbar-group/toolbar-group-container.native.js.map +0 -1
  439. package/build/toolbar-item/index.js.map +0 -1
  440. package/build/toolbar-item/index.native.js.map +0 -1
  441. package/build-module/toolbar/toolbar-container.js.map +0 -1
  442. package/build-module/toolbar/toolbar-container.native.js.map +0 -1
  443. package/build-module/toolbar-button/index.js.map +0 -1
  444. package/build-module/toolbar-button/toolbar-button-container.js.map +0 -1
  445. package/build-module/toolbar-button/toolbar-button-container.native.js.map +0 -1
  446. package/build-module/toolbar-context/index.js.map +0 -1
  447. package/build-module/toolbar-dropdown-menu/index.js.map +0 -1
  448. package/build-module/toolbar-group/index.js.map +0 -1
  449. package/build-module/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  450. package/build-module/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  451. package/build-module/toolbar-group/toolbar-group-container.js.map +0 -1
  452. package/build-module/toolbar-group/toolbar-group-container.native.js.map +0 -1
  453. package/build-module/toolbar-item/index.js.map +0 -1
  454. package/build-module/toolbar-item/index.native.js.map +0 -1
  455. package/src/icon/stories/index.js +0 -128
  456. package/src/item-group/stories/index.js +0 -270
  457. package/src/resizable-box/stories/index.js +0 -97
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { boolean, select } from '@storybook/addon-knobs';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -12,70 +7,35 @@ import { useState } from '@wordpress/element';
12
7
  * Internal dependencies
13
8
  */
14
9
  import { ColorPicker } from '..';
15
- import { Flex } from '../../flex';
16
- import { Spacer } from '../../spacer';
17
- import { space } from '../../ui/utils/space';
18
10
 
19
11
  export default {
20
12
  component: ColorPicker,
21
13
  title: 'Components/ColorPicker',
22
- parameters: {
23
- knobs: { disable: false },
14
+ argTypes: {
15
+ color: { control: { type: null } },
16
+ copyFormat: {
17
+ control: { type: 'select' },
18
+ options: [ 'rgb', 'hsl', 'hex', undefined ],
19
+ },
20
+ // We can't use a `on*` regex because this component will switch to
21
+ // legacy mode when an onChangeComplete prop is passed.
22
+ onChange: { action: 'onChange' },
24
23
  },
25
24
  };
26
25
 
27
- const PROP_UNSET = 'unset';
28
-
29
- const Example = () => {
30
- const [ color, setColor ] = useState( undefined );
31
- const props = {
32
- enableAlpha: boolean( 'enableAlpha', false ),
33
- copyFormat: select(
34
- 'copyFormat',
35
- [ PROP_UNSET, 'rgb', 'hsl', 'hex' ],
36
- PROP_UNSET
37
- ),
38
- };
39
-
40
- if ( props.copyFormat === PROP_UNSET ) {
41
- delete props.copyFormat;
42
- }
43
-
44
- return (
45
- <Flex
46
- as={ Spacer }
47
- gap={ space( 2 ) }
48
- justify="space-around"
49
- align="flex-start"
50
- marginTop={ space( 10 ) }
51
- >
52
- <ColorPicker { ...props } color={ color } onChange={ setColor } />
53
- <div style={ { width: 200, textAlign: 'center' } }>{ color }</div>
54
- <ColorPicker { ...props } color={ color } onChange={ setColor } />
55
- </Flex>
56
- );
57
- };
58
-
59
- export const _default = () => {
60
- return <Example />;
61
- };
62
-
63
- const LegacyExample = () => {
64
- const [ legacyColor, setLegacyColor ] = useState( '#fff' );
65
- const legacyProps = {
66
- color: legacyColor,
67
- onChangeComplete: setLegacyColor,
68
- disableAlpha: boolean( 'disableAlpha', true ),
69
- };
26
+ const Template = ( { onChange, ...props } ) => {
27
+ const [ color, setColor ] = useState();
70
28
 
71
29
  return (
72
- <Flex align="flex-start" justify="flex-start">
73
- <ColorPicker { ...legacyProps } />
74
- <pre style={ { width: '20em' } }>
75
- { JSON.stringify( legacyColor, undefined, 4 ) }
76
- </pre>
77
- </Flex>
30
+ <ColorPicker
31
+ { ...props }
32
+ color={ color }
33
+ onChange={ ( ...changeArgs ) => {
34
+ onChange( ...changeArgs );
35
+ setColor( ...changeArgs );
36
+ } }
37
+ />
78
38
  );
79
39
  };
80
40
 
81
- export const legacy = () => <LegacyExample />;
41
+ export const Default = Template.bind( {} );
@@ -9,7 +9,6 @@ import styled from '@emotion/styled';
9
9
  import NumberControl from '../number-control';
10
10
  import InnerSelectControl from '../select-control';
11
11
  import InnerRangeControl from '../range-control';
12
- import { StyledField } from '../base-control/styles/base-control-styles';
13
12
  import { space } from '../ui/utils/space';
14
13
  import { boxSizingReset } from '../utils';
15
14
  import Button from '../button';
@@ -111,10 +110,6 @@ export const ColorfulWrapper = styled.div`
111
110
  }
112
111
 
113
112
  ${ interactiveHueStyles }
114
-
115
- ${ StyledField } {
116
- margin-bottom: 0;
117
- }
118
113
  `;
119
114
 
120
115
  export const CopyButton = styled( Button )`
@@ -8,6 +8,8 @@ import { render, fireEvent } from '@testing-library/react';
8
8
  */
9
9
  import { ColorPicker } from '..';
10
10
 
11
+ jest.useFakeTimers();
12
+
11
13
  /**
12
14
  * Ordinarily we'd try to select the compnoent by role but the silder role appears
13
15
  * on several elements and we'd end up encoding assumptions about order when
@@ -121,7 +121,15 @@ function ComboboxControl( {
121
121
  const onKeyDown = ( event ) => {
122
122
  let preventDefault = false;
123
123
 
124
- if ( event.defaultPrevented ) {
124
+ if (
125
+ event.defaultPrevented ||
126
+ // Ignore keydowns from IMEs
127
+ event.nativeEvent.isComposing ||
128
+ // Workaround for Mac Safari where the final Enter/Backspace of an IME composition
129
+ // is `isComposing=false`, even though it's technically still part of the composition.
130
+ // These can only be detected by keyCode.
131
+ event.keyCode === 229
132
+ ) {
125
133
  return;
126
134
  }
127
135
 
@@ -14,6 +14,8 @@ import { useState } from '@wordpress/element';
14
14
  */
15
15
  import ComboboxControl from '../';
16
16
 
17
+ jest.useFakeTimers();
18
+
17
19
  const timezones = [
18
20
  { label: 'Greenwich Mean Time', value: 'GMT' },
19
21
  { label: 'Universal Coordinated Time', value: 'UTC' },
@@ -15,6 +15,8 @@ import userEvent from '@testing-library/user-event';
15
15
  */
16
16
  import { ConfirmDialog } from '..';
17
17
 
18
+ jest.useFakeTimers();
19
+
18
20
  const noop = () => {};
19
21
 
20
22
  describe( 'Confirm', () => {
@@ -3,12 +3,6 @@ export type DashiconProps = {
3
3
  * The icon name
4
4
  */
5
5
  icon: IconKey;
6
-
7
- /**
8
- * Class name
9
- */
10
- className?: string;
11
-
12
6
  /**
13
7
  * Size of the icon
14
8
  */
@@ -10,6 +10,8 @@ import userEvent from '@testing-library/user-event';
10
10
  */
11
11
  import DatePicker from '..';
12
12
 
13
+ jest.useFakeTimers();
14
+
13
15
  describe( 'DatePicker', () => {
14
16
  it( 'should highlight the current date', () => {
15
17
  render( <DatePicker currentDate="2022-05-02T11:00:00" /> );
@@ -9,6 +9,8 @@ import userEvent from '@testing-library/user-event';
9
9
  */
10
10
  import TimePicker from '..';
11
11
 
12
+ jest.useFakeTimers();
13
+
12
14
  describe( 'TimePicker', () => {
13
15
  it( 'should call onChange with updated date values', async () => {
14
16
  const user = userEvent.setup( {
@@ -7,7 +7,6 @@ import classnames from 'classnames';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { __ } from '@wordpress/i18n';
10
- import { Fragment } from '@wordpress/element';
11
10
 
12
11
  /**
13
12
  * Internal dependencies
@@ -50,10 +49,10 @@ export function DimensionControl( props ) {
50
49
  };
51
50
 
52
51
  const selectLabel = (
53
- <Fragment>
52
+ <>
54
53
  { icon && <Icon icon={ icon } /> }
55
54
  { label }
56
- </Fragment>
55
+ </>
57
56
  );
58
57
 
59
58
  return (
@@ -14,6 +14,8 @@ import { plus } from '@wordpress/icons';
14
14
  */
15
15
  import { DimensionControl } from '../';
16
16
 
17
+ jest.useFakeTimers();
18
+
17
19
  describe( 'DimensionControl', () => {
18
20
  const onChangeHandler = jest.fn();
19
21
  const instanceId = 1;
@@ -15,6 +15,7 @@ import Disabled from '../';
15
15
  import SelectControl from '../../select-control/';
16
16
  import TextControl from '../../text-control/';
17
17
  import TextareaControl from '../../textarea-control/';
18
+ import { VStack } from '../../v-stack/';
18
19
 
19
20
  const meta: ComponentMeta< typeof Disabled > = {
20
21
  title: 'Components/Disabled',
@@ -37,18 +38,21 @@ const Form = () => {
37
38
  const [ textControlValue, setTextControlValue ] = useState( '' );
38
39
  const [ textAreaValue, setTextAreaValue ] = useState( '' );
39
40
  return (
40
- <div>
41
+ <VStack>
41
42
  <TextControl
43
+ __nextHasNoMarginBottom
42
44
  label="Text Control"
43
45
  value={ textControlValue }
44
46
  onChange={ setTextControlValue }
45
47
  />
46
48
  <TextareaControl
49
+ __nextHasNoMarginBottom
47
50
  label="TextArea Control"
48
51
  value={ textAreaValue }
49
52
  onChange={ setTextAreaValue }
50
53
  />
51
54
  <SelectControl
55
+ __nextHasNoMarginBottom
52
56
  label="Select Control"
53
57
  onChange={ () => {} }
54
58
  options={ [
@@ -58,7 +62,7 @@ const Form = () => {
58
62
  { value: 'c', label: 'Option C' },
59
63
  ] }
60
64
  />
61
- </div>
65
+ </VStack>
62
66
  );
63
67
  };
64
68
 
@@ -9,6 +9,8 @@ import { render, screen } from '@testing-library/react';
9
9
  import Disabled from '../';
10
10
  import userEvent from '@testing-library/user-event';
11
11
 
12
+ jest.useFakeTimers();
13
+
12
14
  describe( 'Disabled', () => {
13
15
  const Form = () => (
14
16
  <form title="form">
@@ -32,96 +32,91 @@ const MyDropdown = () => (
32
32
 
33
33
  The component accepts the following props. Props not included in this set will be applied to the element wrapping Popover content.
34
34
 
35
- ### className
35
+ ### `className`: `string`
36
36
 
37
37
  className of the global container
38
38
 
39
- - Type: `String`
40
39
  - Required: No
41
40
 
42
- ### contentClassName
41
+ ### `contentClassName`: `string`
43
42
 
44
43
  If you want to target the dropdown menu for styling purposes, you need to provide a contentClassName because it's not being rendered as a child of the container node.
45
44
 
46
- - Type: `String`
47
45
  - Required: No
48
46
 
49
- ### position
47
+ ### `expandOnMobile`: `boolean`
50
48
 
51
- The direction in which the popover should open relative to its parent node. Specify a y- and an x-axis as a space-separated string. Supports `"top"`, `"bottom"` y-axis, and `"left"`, `"center"`, `"right"` x-axis.
49
+ Opt-in prop to show popovers fullscreen on mobile.
52
50
 
53
- - Type: `String`
54
51
  - Required: No
55
- - Default: `"top center"`
56
-
57
- ### renderToggle
58
-
59
- A callback invoked to render the Dropdown Toggle Button.
60
-
61
- - Type: `Function`
62
- - Required: Yes
52
+ - Default: `false`
63
53
 
64
- The first argument of the callback is an object containing the following properties:
54
+ ### `focusOnMount`: `'firstElement' | boolean`
65
55
 
66
- - `isOpen`: whether the dropdown menu is opened or not
67
- - `onToggle`: A function switching the dropdown menu's state from open to closed and vice versa
68
- - `onClose`: A function that closes the menu if invoked
56
+ By default, the _first tabbable element_ in the popover will receive focus when it mounts. This is the same as setting this prop to `"firstElement"`.
69
57
 
70
- ### renderContent
58
+ Specifying a `true` value will focus the container instead.
71
59
 
72
- A callback invoked to render the content of the dropdown menu. Its first argument is the same as the `renderToggle` prop.
60
+ Specifying a `false` value disables the focus handling entirely (this should only be done when an appropriately accessible substitute behavior exists).
73
61
 
74
- - Type: `Function`
75
- - Required: Yes
62
+ - Required: No
63
+ - Default: `"firstElement"`
76
64
 
77
- ### expandOnMobile
65
+ ### `headerTitle`: `string`
78
66
 
79
- Opt-in prop to show popovers fullscreen on mobile.
67
+ Set this to customize the text that is shown in the dropdown's header when it is fullscreen on mobile.
80
68
 
81
- - Type: `Boolean`
82
69
  - Required: No
83
- - Default: `false`
84
70
 
85
- ### headerTitle
71
+ ### `onClose`: `() => void`
86
72
 
87
- Set this to customize the text that is shown in the dropdown's header when it is fullscreen on mobile.
73
+ A callback invoked when the popover should be closed.
88
74
 
89
- - Type: `String`
90
75
  - Required: No
91
76
 
92
- ### focusOnMount
93
-
94
- By default, the _first tabbable element_ in the popover will receive focus when it mounts. This is the same as setting this prop to `"firstElement"`.
77
+ ### `onToggle`: `( willOpen: boolean ) => void`
95
78
 
96
- Specifying a `true` value will focus the container instead.
79
+ A callback invoked when the state of the popover changes from open to closed and vice versa.
97
80
 
98
- Specifying a `false` value disables the focus handling entirely (this should only be done when an appropriately accessible substitute behavior exists).
81
+ The callback receives a boolean as a parameter. If `true`, the popover will open. If `false`, the popover will close.
99
82
 
100
- - Type: `'firstElement' | boolean`
101
83
  - Required: No
102
- - Default: `"firstElement"`
103
84
 
104
- ### popoverProps
85
+ ### `popoverProps`: `WordPressComponentProps< Omit< PopoverProps, 'children' > 'div', false >`
105
86
 
106
87
  Properties of popoverProps object will be passed as props to the `Popover` component.
107
88
 
108
89
  Use this object to access properties/features of the `Popover` component that are not already exposed in the `Dropdown` component, e.g.: the ability to have the popover without an arrow.
109
90
 
110
- - Type: `Object`
111
91
  - Required: No
112
92
 
113
- ### onClose
93
+ ### `position`: `PopoverProps[ 'position' ]`
114
94
 
115
- A callback invoked when the popover should be closed.
95
+ The direction in which the popover should open relative to its parent node. Specify a y- and an x-axis as a space-separated string. Supports `"top"`, `"bottom"` y-axis, and `"left"`, `"center"`, `"right"` x-axis.
116
96
 
117
- - Type: `Function`
118
97
  - Required: No
98
+ - Default: `"top center"`
119
99
 
120
- ### onToggle
100
+ ### `renderContent`: `( props: CallbackProps ) => ReactNode`
121
101
 
122
- A callback invoked when the state of the popover changes from open to closed and vice versa.
102
+ A callback invoked to render the content of the dropdown menu.
123
103
 
124
- The callback receives a boolean as a parameter. If `true`, the popover will open. If `false`, the popover will close.
104
+ - `isOpen`: whether the dropdown menu is opened or not
105
+ - `onToggle`: A function switching the dropdown menu's state from open to closed and vice versa
106
+ - `onClose`: A function that closes the menu if invoked
107
+
108
+ - Required: Yes
109
+
110
+ ### `renderToggle`: `( props: CallbackProps ) => ReactNode`
111
+
112
+ A callback invoked to render the Dropdown Toggle Button.
113
+
114
+ Its props are the same as the `renderContent` props.
115
+
116
+ - Required: Yes
117
+
118
+ ### `style`: `React.CSSProperties`
119
+
120
+ The style of the global container
125
121
 
126
- - Type: `Function`
127
122
  - Required: No
@@ -1,35 +1,39 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * External dependencies
4
3
  */
5
4
  import classnames from 'classnames';
5
+ import type { ForwardedRef } from 'react';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { useRef, useEffect, useState } from '@wordpress/element';
10
+ import { forwardRef, useEffect, useRef, useState } from '@wordpress/element';
11
11
  import { useMergeRefs } from '@wordpress/compose';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
15
15
  */
16
16
  import Popover from '../popover';
17
+ import type { DropdownProps } from './types';
17
18
 
18
- function useObservableState( initialState, onStateChange ) {
19
+ function useObservableState(
20
+ initialState: boolean,
21
+ onStateChange?: ( newState: boolean ) => void
22
+ ) {
19
23
  const [ state, setState ] = useState( initialState );
20
24
  return [
21
25
  state,
22
- ( value ) => {
26
+ ( value: boolean ) => {
23
27
  setState( value );
24
28
  if ( onStateChange ) {
25
29
  onStateChange( value );
26
30
  }
27
31
  },
28
- ];
32
+ ] as const;
29
33
  }
30
34
 
31
- export default function Dropdown( props ) {
32
- const {
35
+ function UnforwardedDropdown(
36
+ {
33
37
  renderContent,
34
38
  renderToggle,
35
39
  className,
@@ -42,12 +46,14 @@ export default function Dropdown( props ) {
42
46
  onClose,
43
47
  onToggle,
44
48
  style,
45
- } = props;
49
+ }: DropdownProps,
50
+ forwardedRef: ForwardedRef< any >
51
+ ) {
46
52
  // Use internal state instead of a ref to make sure that the component
47
53
  // re-renders when the popover's anchor updates.
48
54
  const [ fallbackPopoverAnchor, setFallbackPopoverAnchor ] =
49
- useState( null );
50
- const containerRef = useRef();
55
+ useState< HTMLDivElement | null >( null );
56
+ const containerRef = useRef< HTMLDivElement >();
51
57
  const [ isOpen, setIsOpen ] = useObservableState( false, onToggle );
52
58
 
53
59
  useEffect(
@@ -70,8 +76,13 @@ export default function Dropdown( props ) {
70
76
  * case a dialog has opened, allowing focus to return when it's dismissed.
71
77
  */
72
78
  function closeIfFocusOutside() {
79
+ if ( ! containerRef.current ) {
80
+ return;
81
+ }
82
+
73
83
  const { ownerDocument } = containerRef.current;
74
- const dialog = ownerDocument.activeElement.closest( '[role="dialog"]' );
84
+ const dialog =
85
+ ownerDocument?.activeElement?.closest( '[role="dialog"]' );
75
86
  if (
76
87
  ! containerRef.current.contains( ownerDocument.activeElement ) &&
77
88
  ( ! dialog || dialog.contains( containerRef.current ) )
@@ -99,11 +110,15 @@ export default function Dropdown( props ) {
99
110
  return (
100
111
  <div
101
112
  className={ classnames( 'components-dropdown', className ) }
102
- ref={ useMergeRefs( [ setFallbackPopoverAnchor, containerRef ] ) }
113
+ ref={ useMergeRefs( [
114
+ containerRef,
115
+ forwardedRef,
116
+ setFallbackPopoverAnchor,
117
+ ] ) }
103
118
  // Some UAs focus the closest focusable parent when the toggle is
104
119
  // clicked. Making this div focusable ensures such UAs will focus
105
120
  // it and `closeIfFocusOutside` can tell if the toggle was clicked.
106
- tabIndex="-1"
121
+ tabIndex={ -1 }
107
122
  style={ style }
108
123
  >
109
124
  { renderToggle( args ) }
@@ -136,3 +151,32 @@ export default function Dropdown( props ) {
136
151
  </div>
137
152
  );
138
153
  }
154
+
155
+ /**
156
+ * Renders a button that opens a floating content modal when clicked.
157
+ *
158
+ * ```jsx
159
+ * import { Button, Dropdown } from '@wordpress/components';
160
+ *
161
+ * const MyDropdown = () => (
162
+ * <Dropdown
163
+ * className="my-container-class-name"
164
+ * contentClassName="my-popover-content-classname"
165
+ * position="bottom right"
166
+ * renderToggle={ ( { isOpen, onToggle } ) => (
167
+ * <Button
168
+ * variant="primary"
169
+ * onClick={ onToggle }
170
+ * aria-expanded={ isOpen }
171
+ * >
172
+ * Toggle Popover!
173
+ * </Button>
174
+ * ) }
175
+ * renderContent={ () => <div>This is the content of the popover.</div> }
176
+ * />
177
+ * );
178
+ * ```
179
+ */
180
+ export const Dropdown = forwardRef( UnforwardedDropdown );
181
+
182
+ export default Dropdown;
@@ -1,29 +1,38 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ComponentMeta, ComponentStory } from '@storybook/react';
5
+
1
6
  /**
2
7
  * Internal dependencies
3
8
  */
4
- import Dropdown from '../';
9
+ import Dropdown from '..';
5
10
  import Button from '../../button';
6
11
  import { DropdownContentWrapper } from '../dropdown-content-wrapper';
7
12
 
8
- export default {
13
+ const meta: ComponentMeta< typeof Dropdown > = {
9
14
  title: 'Components/Dropdown',
10
15
  component: Dropdown,
11
16
  subcomponents: { DropdownContentWrapper },
12
17
  argTypes: {
13
- expandOnMobile: { control: { type: 'boolean' } },
14
18
  focusOnMount: {
15
19
  control: {
16
20
  type: 'radio',
17
21
  options: [ 'firstElement', true, false ],
18
22
  },
19
23
  },
20
- headerTitle: { control: { type: 'text' } },
21
24
  renderContent: { control: { type: null } },
22
25
  renderToggle: { control: { type: null } },
23
26
  },
27
+ parameters: {
28
+ controls: {
29
+ expanded: true,
30
+ },
31
+ },
24
32
  };
33
+ export default meta;
25
34
 
26
- const Template = ( args ) => {
35
+ const Template: ComponentStory< typeof Dropdown > = ( args ) => {
27
36
  return (
28
37
  <div style={ { height: 150 } }>
29
38
  <Dropdown { ...args } />
@@ -31,7 +40,7 @@ const Template = ( args ) => {
31
40
  );
32
41
  };
33
42
 
34
- export const Default = Template.bind( {} );
43
+ export const Default: ComponentStory< typeof Dropdown > = Template.bind( {} );
35
44
  Default.args = {
36
45
  position: 'bottom right',
37
46
  renderToggle: ( { isOpen, onToggle } ) => (
@@ -46,7 +55,9 @@ Default.args = {
46
55
  * To apply more padding to the dropdown content, use the provided `<DropdownContentWrapper>`
47
56
  * convenience wrapper. A `paddingSize` of `"medium"` is suitable for relatively larger dropdowns (default is `"small"`).
48
57
  */
49
- export const WithMorePadding = Template.bind( {} );
58
+ export const WithMorePadding: ComponentStory< typeof Dropdown > = Template.bind(
59
+ {}
60
+ );
50
61
  WithMorePadding.args = {
51
62
  ...Default.args,
52
63
  renderContent: () => (
@@ -61,7 +72,9 @@ WithMorePadding.args = {
61
72
  * with a `paddingSize` of `"none"`. This can also serve as a clean foundation to add arbitrary
62
73
  * paddings, for example when child components already have padding on their own.
63
74
  */
64
- export const WithNoPadding = Template.bind( {} );
75
+ export const WithNoPadding: ComponentStory< typeof Dropdown > = Template.bind(
76
+ {}
77
+ );
65
78
  WithNoPadding.args = {
66
79
  ...Default.args,
67
80
  renderContent: () => (