@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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,66 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 25.0.0 (2023-05-24)
6
+
7
+ ### Breaking Changes
8
+
9
+ - `DateTime`: Remove previously deprecated props, `__nextRemoveHelpButton` and `__nextRemoveResetButton` ([#50724](https://github.com/WordPress/gutenberg/pull/50724)).
10
+
11
+ ### Internal
12
+
13
+ - `Modal`: Remove children container's unused class name ([#50655](https://github.com/WordPress/gutenberg/pull/50655)).
14
+ - `DropdownMenu`: Convert to TypeScript ([#50187](https://github.com/WordPress/gutenberg/pull/50187)).
15
+ - Added experimental v2 of `DropdownMenu` ([#49473](https://github.com/WordPress/gutenberg/pull/49473)).
16
+ - `ColorPicker`: its private `SelectControl` component no longer hides BackdropUI, thus making its focus state visible for keyboard users ([#50703](https://github.com/WordPress/gutenberg/pull/50703)).
17
+
18
+ ### Bug Fix
19
+
20
+ - `ColorPicker`: Add an outline when the color picker select box is focused([#50609](https://github.com/WordPress/gutenberg/pull/50609)).
21
+ - `InputControl`: Fix focus style to support Windows High Contrast mode ([#50772](https://github.com/WordPress/gutenberg/pull/50772)).
22
+ - `ToggleGroupControl`: Fix focus and selected style to support Windows High Contrast mode ([#50785](https://github.com/WordPress/gutenberg/pull/50785)).
23
+ - `SearchControl`: Adjust icon styles to fix alignment issues in the block inserter ([#50439](https://github.com/WordPress/gutenberg/pull/50439)).
24
+
25
+ ### Enhancements
26
+
27
+ - `Tooltip`: Update background color so tooltip boundaries are more visible in the site editor ([#50792](https://github.com/WordPress/gutenberg/pull/50792)).
28
+
29
+ ## 24.0.0 (2023-05-10)
30
+
31
+ ### Breaking Changes
32
+
33
+ - `onDragStart` in `<Draggable>` is now a synchronous function to allow setting additional data for `event.dataTransfer` ([#49673](https://github.com/WordPress/gutenberg/pull/49673)).
34
+
35
+ ### Bug Fix
36
+
37
+ - `NavigableContainer`: do not trap focus in `TabbableContainer` ([#49846](https://github.com/WordPress/gutenberg/pull/49846)).
38
+ - Update `<Button>` component to have a transparent background for its tertiary disabled state, to match its enabled state. ([#50496](https://github.com/WordPress/gutenberg/pull/50496)).
39
+
40
+ ### Internal
41
+
42
+ - `NavigableContainer`: Convert to TypeScript ([#49377](https://github.com/WordPress/gutenberg/pull/49377)).
43
+ - `ToolbarItem`: Convert to TypeScript ([#49190](https://github.com/WordPress/gutenberg/pull/49190)).
44
+ - Move rich-text related types to the rich-text package ([#49651](https://github.com/WordPress/gutenberg/pull/49651)).
45
+ - `SlotFill`: simplified the implementation and removed unused code ([#50098](https://github.com/WordPress/gutenberg/pull/50098) and [#50133](https://github.com/WordPress/gutenberg/pull/50133)).
46
+
47
+ ### Documentation
48
+
49
+ - `TreeGrid`: Update docs with `data-expanded` attribute usage ([#50026](https://github.com/WordPress/gutenberg/pull/50026)).
50
+ - Consolidate multiple versions of `README` and `CONTRIBUTING` docs, and add them to Storybook ([#50226](https://github.com/WordPress/gutenberg/pull/50226)).
51
+ - `DimensionControl`: Use WordPress package instead of react in code example ([#50435](https://github.com/WordPress/gutenberg/pull/50435)).
52
+
53
+ ### Enhancements
54
+
55
+ - `FormTokenField`, `ComboboxControl`: Add `__next40pxDefaultSize` prop to opt into the new 40px default size, superseding the `__next36pxDefaultSize` prop ([#50261](https://github.com/WordPress/gutenberg/pull/50261)).
56
+ - `Modal`: Add css class to children container ([#50099](https://github.com/WordPress/gutenberg/pull/50099)).
57
+ - `Button`: Add `__next40pxDefaultSize` prop to opt into the new 40px default size ([#50254](https://github.com/WordPress/gutenberg/pull/50254)).
58
+ - `PaletteEdit`: Allow custom popover configuration ([#49975](https://github.com/WordPress/gutenberg/pull/49975)).
59
+ - Change the default color scheme to use the new WP Blueberry color. See PR description for instructions on how to restore the previous color scheme when using in a non-WordPress context ([#50193](https://github.com/WordPress/gutenberg/pull/50193)).
60
+ - `CheckboxControl`, `CustomGradientPicker`, `FormToggle`, : Refactor and correct the focus style for consistency ([#50127](https://github.com/WordPress/gutenberg/pull/50127)).
61
+ - `Button`, update spacing values in `has-text has-icon` buttons. ([#50277](https://github.com/WordPress/gutenberg/pull/50277)).
62
+ - `Button`, remove custom padding applied to `tertiary` variant. ([#50276](https://github.com/WordPress/gutenberg/pull/50276)).
63
+ - `Modal`: Correct padding for title less confirm variant. ([#50283](https://github.com/WordPress/gutenberg/pull/50283)).
64
+
5
65
  ## 23.9.0 (2023-04-26)
6
66
 
7
67
  ### Internal
@@ -30,6 +90,7 @@
30
90
  ### Documentation
31
91
 
32
92
  - `Autocomplete`: Add heading and fix type for `onReplace` in README. ([#49798](https://github.com/WordPress/gutenberg/pull/49798)).
93
+ - `Autocomplete`: Update `Usage` section in README. ([#49965](https://github.com/WordPress/gutenberg/pull/49965)).
33
94
 
34
95
  ## 23.8.0 (2023-04-12)
35
96
 
@@ -43,6 +104,7 @@
43
104
  - `DropZone`: Smooth animation ([#49517](https://github.com/WordPress/gutenberg/pull/49517)).
44
105
  - `Navigator`: Add `skipFocus` property in `NavigateOptions`. ([#49350](https://github.com/WordPress/gutenberg/pull/49350)).
45
106
  - `Spinner`: add explicit opacity and background styles ([#49695](https://github.com/WordPress/gutenberg/pull/49695)).
107
+ - Make TypeScript types available for consumers ([#49229](https://github.com/WordPress/gutenberg/pull/49229)).
46
108
 
47
109
  ### Bug Fix
48
110
 
package/CONTRIBUTING.md CHANGED
@@ -7,7 +7,7 @@ The following is a set of guidelines for contributing to the `@wordpress/compone
7
7
  This set of guidelines should apply especially to newly introduced components. In fact, while these guidelines should also be retroactively applied to existing components, it is sometimes impossible to do so for legacy/compatibility reasons.
8
8
 
9
9
  For an example of a component that follows these requirements, take a look at [`ItemGroup`](/packages/components/src/item-group).
10
-
10
+ - [Introducing new components](#introducing-new-components)
11
11
  - [Compatibility](#compatibility)
12
12
  - [Compound components](#compound-components)
13
13
  - [Components & Hooks](#components--hooks)
@@ -20,6 +20,71 @@ For an example of a component that follows these requirements, take a look at [`
20
20
  - [README example](#README-example)
21
21
  - [Folder structure](#folder-structure)
22
22
  - [TypeScript migration guide](#refactoring-a-component-to-typescript)
23
+ - [Using Radix UI primitives](#using-radix-ui-primitives)
24
+
25
+ ## Introducing new components
26
+
27
+ ### Does it belong in the component library?
28
+
29
+ A component library should include components that are generic and flexible enough to work across a variety of products. It should include what’s shared across many products and omit what’s not.
30
+
31
+ To determine if a component should be added, ask yourself:
32
+
33
+ - Could this component be used by other products/plugins?
34
+ - Does the new component overlap (in functionality or visual design) with any existing components?
35
+ - How much effort will be required to make and maintain?
36
+ - Is there a clear purpose for the component?
37
+
38
+ Here’s a flowchart that can help determine if a new component is necessary:
39
+
40
+ [![New component flowchart](https://wordpress.org/gutenberg/files/2019/07/New_component_flowchart.png)](https://coggle.it/diagram/WtUSrld3uAYZHsn-/t/new-ui-component/992b38cbe685d897b4aec6d0dd93cc4b47c06e0d4484eeb0d7d9a47fb2c48d94)
41
+
42
+ ### First steps
43
+
44
+ If you have a component you'd like added or changed, start by opening a GitHub issue. Include a detailed description in which you:
45
+
46
+ - Explain the rationale
47
+ - Detail the intended behavior
48
+ - Clarify whether it’s a variation of an existing component, or a new asset
49
+ - Include mockups of any fidelity (optional)
50
+ - Include any inspirations from other products (optional)
51
+
52
+ This issue will be used to discuss the proposed changes and track progress. Reviewers start by discussing the proposal to determine if it's appropriate for WordPress Components, or if there's overlap with an existing component.
53
+
54
+ It’s encouraged to surface works-in-progress. If you’re not able to complete all of the parts yourself, someone in the community may be able to pick up where you left off.
55
+
56
+ ### Next steps
57
+
58
+ Once the team has discussed and approved the change, it's time to start implementing it.
59
+
60
+ 1. **Provide a rationale**: Explain how your component will add value to the system and the greater product ecosystem. Be sure to include any user experience and interaction descriptions.
61
+ 2. **Draft documentation**: New components need development, design, and accessibility guidelines. Additionally, if your change adds additional behavior or expands a component’s features, those changes will need to be fully documented as well. Read through existing component documentation for examples. Start with a rough draft, and reviewers will help polish documentation.
62
+ 3. **Provide working code**: The component or enhancement must be built in React. See the [developer contribution guidelines](https://github.com/WordPress/gutenberg/blob/HEAD/docs/contributors/code/README.md).
63
+ 4. **Create a design spec**: Create sizing and styling annotations for all aspects of the component. This spec should provide a developer with everything they need to create the design in code. [Figma automatically does this for you](https://help.figma.com/article/32-developer-handoff).
64
+
65
+ Remember, it’s unlikely that all parts will be done by one person. Contribute where you can, and others will help.
66
+
67
+ ### Component refinement
68
+
69
+ Before a component is published it will need to be fine-tuned:
70
+
71
+ 1. **Expand** the features of the component to a minimum. Agree on what features should be included.
72
+ 2. **Reduce** scope and leave off features lacking consensus.
73
+ 3. **Quality assurance**: each contribution must adhere to system standards.
74
+
75
+ #### Quality assurance
76
+
77
+ To ensure quality, each component should be tested. The testing process should be done during the development of the component and before the component is published.
78
+
79
+ - **Accessibility**: Has the design and implementation accounted for accessibility? Please use the [WordPress accessibility guidelines](https://make.wordpress.org/accessibility/handbook/best-practices/). You must use the "Needs Accessibility Feedback" label and get a review from the accessibility team. It's best to request a review early (at the documentation stage) in order to ensure the component is designed inclusively from the outset.
80
+ - **Visual quality**: Does the component apply visual style — color, typography, icons, space, borders, and more — using appropriate variables, and does it follow [visual guidelines](https://make.wordpress.org/design/handbook/design-guide/)? You must use the "Needs Design Feedback" label and get a review from the design team.
81
+ - **Documentation**: Ensure that the component has proper documentation for development, design, and accessibility.
82
+ - **Sufficient states & variations**: Does it cover all the necessary variations (primary, secondary, dense, etc.) and states (default, hover, active, disabled, loading, etc.), within the intended scope?
83
+ - **Functionality**: Do all behaviors function as expected?
84
+ - **Responsiveness**: Does it incorporate responsive behaviors as needed? Is the component designed from a mobile-first perspective? Do all touch interactions work as expected?
85
+ - **Content resilience**: Is each dynamic word or image element resilient to too much, too little, and no content at all, respectively? How long can labels be, and what happens when you run out of space?
86
+ - **Composability**: Does it fit well when placed next to or layered with other components to form a larger composition?
87
+ - **Browser support**: Has the component visual quality and accuracy been checked across Safari, Chrome, Firefox, IE, etc? Please adhere to our [browser support requirements](https://github.com/WordPress/gutenberg/blob/HEAD/packages/browserslist-config/index.js).
23
88
 
24
89
  ## Compatibility
25
90
 
@@ -575,3 +640,12 @@ Given a component folder (e.g. `packages/components/src/unit-control`):
575
640
  11. Convert unit tests.
576
641
  1. Rename test file extensions from `.js` to `.tsx`.
577
642
  2. Fix all TypeScript errors.
643
+
644
+ ## Using Radix UI primitives
645
+
646
+ Useful links:
647
+
648
+ - [online docs](https://www.radix-ui.com/docs/primitives/overview/introduction)
649
+ - [repo](https://github.com/radix-ui/primitives) — useful for:
650
+ - inspecting source code
651
+ - running storybook examples (`yarn install && yarn dev`)
package/README.md CHANGED
@@ -4,8 +4,6 @@ This package includes a library of generic WordPress components to be used for c
4
4
 
5
5
  ## Installation
6
6
 
7
- Install the module
8
-
9
7
  ```bash
10
8
  npm install @wordpress/components --save
11
9
  ```
@@ -27,7 +25,7 @@ export default function MyButton() {
27
25
  }
28
26
  ```
29
27
 
30
- Many components include CSS to add style, you will need to add in order to appear correctly. Within WordPress, add the `wp-components` stylesheet as a dependency of your plugin's stylesheet. See [wp_enqueue_style documentation](https://developer.wordpress.org/reference/functions/wp_enqueue_style/#parameters) for how to specify dependencies.
28
+ Many components include CSS to add styles, which you will need to load in order for them to appear correctly. Within WordPress, add the `wp-components` stylesheet as a dependency of your plugin's stylesheet. See [wp_enqueue_style documentation](https://developer.wordpress.org/reference/functions/wp_enqueue_style/#parameters) for how to specify dependencies.
31
29
 
32
30
  In non-WordPress projects, link to the `build-style/style.css` file directly, it is located at `node_modules/@wordpress/components/build-style/style.css`.
33
31
 
@@ -32,8 +32,6 @@ var _reactDom = require("react-dom");
32
32
  /**
33
33
  * WordPress dependencies
34
34
  */
35
- // Error expected because `@wordpress/rich-text` is not yet fully typed.
36
- // @ts-expect-error
37
35
 
38
36
  /**
39
37
  * Internal dependencies
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.tsx"],"names":["getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","instanceId","listBoxId","className","selectedIndex","onChangeOptions","onSelect","onReset","reset","contentRef","items","popoverAnchor","editableContentElement","current","needsA11yCompat","setNeedsA11yCompat","popoverRef","popoverRefs","node","ownerDocument","useOnClickOutside","length","ListBox","Component","map","option","index","key","isDisabled","label","VisuallyHidden","body","ref","handler","listener","event","contains","target","document","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAQA;;AALA;;AAaA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;AAOA;AACA;;AAIA;AACA;AAC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,GAAKC,KAAF,IAAsC;AACtD;AACA,UACC,CAAEH,GAAG,CAACnB,OAAN,IACAmB,GAAG,CAACnB,OAAJ,CAAYuB,QAAZ,CAAsBD,KAAK,CAACE,MAA5B,CAFD,EAGE;AACD;AACA;;AACDJ,MAAAA,OAAO,CAAEE,KAAF,CAAP;AACA,KATD;;AAUAG,IAAAA,QAAQ,CAACC,gBAAT,CAA2B,WAA3B,EAAwCL,QAAxC;AACAI,IAAAA,QAAQ,CAACC,gBAAT,CAA2B,YAA3B,EAAyCL,QAAzC;AACA,WAAO,MAAM;AACZI,MAAAA,QAAQ,CAACE,mBAAT,CAA8B,WAA9B,EAA2CN,QAA3C;AACAI,MAAAA,QAAQ,CAACE,mBAAT,CAA8B,YAA9B,EAA4CN,QAA5C;AACA,KAHD,CAbgB,CAiBhB;AACA;AACA;AACA,GApBD,EAoBG,CAAED,OAAF,CApBH;AAqBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseRef,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\n// Error expected because `@wordpress/rich-text` is not yet fully typed.\n// @ts-expect-error\nimport { useAnchor } from '@wordpress/rich-text';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport getDefaultUseItems from './get-default-use-items';\nimport Button from '../button';\nimport Popover from '../popover';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { createPortal } from 'react-dom';\nimport type { AutocompleterUIProps, WPCompleter } from './types';\n\nexport function getAutoCompleterUI( autocompleter: WPCompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tinstanceId,\n\t\tlistBoxId,\n\t\tclassName,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tonReset,\n\t\treset,\n\t\tcontentRef,\n\t}: AutocompleterUIProps ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst popoverAnchor = useAnchor( {\n\t\t\teditableContentElement: contentRef.current,\n\t\t} );\n\n\t\tconst [ needsA11yCompat, setNeedsA11yCompat ] = useState( false );\n\t\tconst popoverRef = useRef< HTMLElement >( null );\n\t\tconst popoverRefs = useMergeRefs( [\n\t\t\tpopoverRef,\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tif ( ! contentRef.current ) return;\n\n\t\t\t\t\t// If the popover is rendered in a different document than\n\t\t\t\t\t// the content, we need to duplicate the options list in the\n\t\t\t\t\t// content document so that it's available to the screen\n\t\t\t\t\t// readers, which check the DOM ID based aira-* attributes.\n\t\t\t\t\tsetNeedsA11yCompat(\n\t\t\t\t\t\tnode.ownerDocument !== contentRef.current.ownerDocument\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t[ contentRef ]\n\t\t\t),\n\t\t] );\n\n\t\tuseOnClickOutside( popoverRef, reset );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\t// Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, [ items ] );\n\n\t\tif ( items.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ListBox = ( {\n\t\t\tComponent = 'div',\n\t\t}: {\n\t\t\tComponent?: React.ElementType;\n\t\t} ) => (\n\t\t\t<Component\n\t\t\t\tid={ listBoxId }\n\t\t\t\trole=\"listbox\"\n\t\t\t\tclassName=\"components-autocomplete__results\"\n\t\t\t>\n\t\t\t\t{ items.map( ( option, index ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ option.key }\n\t\t\t\t\t\tid={ `components-autocomplete-item-${ instanceId }-${ option.key }` }\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\taria-selected={ index === selectedIndex }\n\t\t\t\t\t\tdisabled={ option.isDisabled }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-autocomplete__result',\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-selected': index === selectedIndex,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonClick={ () => onSelect( option ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ option.label }\n\t\t\t\t\t</Button>\n\t\t\t\t) ) }\n\t\t\t</Component>\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Popover\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\tonClose={ onReset }\n\t\t\t\t\tplacement=\"top-start\"\n\t\t\t\t\tclassName=\"components-autocomplete__popover\"\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tref={ popoverRefs }\n\t\t\t\t>\n\t\t\t\t\t<ListBox />\n\t\t\t\t</Popover>\n\t\t\t\t{ contentRef.current &&\n\t\t\t\t\tneedsA11yCompat &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<ListBox Component={ VisuallyHidden } />,\n\t\t\t\t\t\tcontentRef.current.ownerDocument.body\n\t\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n\nfunction useOnClickOutside(\n\tref: React.RefObject< HTMLElement >,\n\thandler: AutocompleterUIProps[ 'reset' ]\n) {\n\tuseEffect( () => {\n\t\tconst listener = ( event: MouseEvent | TouchEvent ) => {\n\t\t\t// Do nothing if clicking ref's element or descendent elements, or if the ref is not referencing an element\n\t\t\tif (\n\t\t\t\t! ref.current ||\n\t\t\t\tref.current.contains( event.target as Node )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thandler( event );\n\t\t};\n\t\tdocument.addEventListener( 'mousedown', listener );\n\t\tdocument.addEventListener( 'touchstart', listener );\n\t\treturn () => {\n\t\t\tdocument.removeEventListener( 'mousedown', listener );\n\t\t\tdocument.removeEventListener( 'touchstart', listener );\n\t\t};\n\t\t// Disable reason: `ref` is a ref object and should not be included in a\n\t\t// hook's dependency list.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ handler ] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.tsx"],"names":["getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","instanceId","listBoxId","className","selectedIndex","onChangeOptions","onSelect","onReset","reset","contentRef","items","popoverAnchor","editableContentElement","current","needsA11yCompat","setNeedsA11yCompat","popoverRef","popoverRefs","node","ownerDocument","useOnClickOutside","length","ListBox","Component","map","option","index","key","isDisabled","label","VisuallyHidden","body","ref","handler","listener","event","contains","target","document","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAQA;;AALA;;AAWA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAQO,SAASA,kBAAT,CAA6BC,aAA7B,EAA0D;AAChE,QAAMC,QAAQ,GAAGD,aAAa,CAACC,QAAd,GACdD,aAAa,CAACC,QADA,GAEd,iCAAoBD,aAApB,CAFH;;AAIA,WAASE,eAAT,OAW0B;AAAA,QAXA;AACzBC,MAAAA,WADyB;AAEzBC,MAAAA,UAFyB;AAGzBC,MAAAA,SAHyB;AAIzBC,MAAAA,SAJyB;AAKzBC,MAAAA,aALyB;AAMzBC,MAAAA,eANyB;AAOzBC,MAAAA,QAPyB;AAQzBC,MAAAA,OARyB;AASzBC,MAAAA,KATyB;AAUzBC,MAAAA;AAVyB,KAWA;AACzB,UAAM,CAAEC,KAAF,IAAYZ,QAAQ,CAAEE,WAAF,CAA1B;AACA,UAAMW,aAAa,GAAG,yBAAW;AAChCC,MAAAA,sBAAsB,EAAEH,UAAU,CAACI;AADH,KAAX,CAAtB;AAIA,UAAM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["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseRef,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\nimport { useAnchor } from '@wordpress/rich-text';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport getDefaultUseItems from './get-default-use-items';\nimport Button from '../button';\nimport Popover from '../popover';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { createPortal } from 'react-dom';\nimport type { AutocompleterUIProps, WPCompleter } from './types';\n\nexport function getAutoCompleterUI( autocompleter: WPCompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tinstanceId,\n\t\tlistBoxId,\n\t\tclassName,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tonReset,\n\t\treset,\n\t\tcontentRef,\n\t}: AutocompleterUIProps ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst popoverAnchor = useAnchor( {\n\t\t\teditableContentElement: contentRef.current,\n\t\t} );\n\n\t\tconst [ needsA11yCompat, setNeedsA11yCompat ] = useState( false );\n\t\tconst popoverRef = useRef< HTMLElement >( null );\n\t\tconst popoverRefs = useMergeRefs( [\n\t\t\tpopoverRef,\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tif ( ! contentRef.current ) return;\n\n\t\t\t\t\t// If the popover is rendered in a different document than\n\t\t\t\t\t// the content, we need to duplicate the options list in the\n\t\t\t\t\t// content document so that it's available to the screen\n\t\t\t\t\t// readers, which check the DOM ID based aira-* attributes.\n\t\t\t\t\tsetNeedsA11yCompat(\n\t\t\t\t\t\tnode.ownerDocument !== contentRef.current.ownerDocument\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t[ contentRef ]\n\t\t\t),\n\t\t] );\n\n\t\tuseOnClickOutside( popoverRef, reset );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\t// Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, [ items ] );\n\n\t\tif ( items.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ListBox = ( {\n\t\t\tComponent = 'div',\n\t\t}: {\n\t\t\tComponent?: React.ElementType;\n\t\t} ) => (\n\t\t\t<Component\n\t\t\t\tid={ listBoxId }\n\t\t\t\trole=\"listbox\"\n\t\t\t\tclassName=\"components-autocomplete__results\"\n\t\t\t>\n\t\t\t\t{ items.map( ( option, index ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ option.key }\n\t\t\t\t\t\tid={ `components-autocomplete-item-${ instanceId }-${ option.key }` }\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\taria-selected={ index === selectedIndex }\n\t\t\t\t\t\tdisabled={ option.isDisabled }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-autocomplete__result',\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-selected': index === selectedIndex,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonClick={ () => onSelect( option ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ option.label }\n\t\t\t\t\t</Button>\n\t\t\t\t) ) }\n\t\t\t</Component>\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Popover\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\tonClose={ onReset }\n\t\t\t\t\tplacement=\"top-start\"\n\t\t\t\t\tclassName=\"components-autocomplete__popover\"\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tref={ popoverRefs }\n\t\t\t\t>\n\t\t\t\t\t<ListBox />\n\t\t\t\t</Popover>\n\t\t\t\t{ contentRef.current &&\n\t\t\t\t\tneedsA11yCompat &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<ListBox Component={ VisuallyHidden } />,\n\t\t\t\t\t\tcontentRef.current.ownerDocument.body\n\t\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n\nfunction useOnClickOutside(\n\tref: React.RefObject< HTMLElement >,\n\thandler: AutocompleterUIProps[ 'reset' ]\n) {\n\tuseEffect( () => {\n\t\tconst listener = ( event: MouseEvent | TouchEvent ) => {\n\t\t\t// Do nothing if clicking ref's element or descendent elements, or if the ref is not referencing an element\n\t\t\tif (\n\t\t\t\t! ref.current ||\n\t\t\t\tref.current.contains( event.target as Node )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thandler( event );\n\t\t};\n\t\tdocument.addEventListener( 'mousedown', listener );\n\t\tdocument.addEventListener( 'touchstart', listener );\n\t\treturn () => {\n\t\t\tdocument.removeEventListener( 'mousedown', listener );\n\t\t\tdocument.removeEventListener( 'touchstart', listener );\n\t\t};\n\t\t// Disable reason: `ref` is a ref object and should not be included in a\n\t\t// hook's dependency list.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ handler ] );\n}\n"]}
@@ -197,6 +197,8 @@ function useAutocomplete(_ref) {
197
197
  if ((0, _richText.isCollapsed)(record)) {
198
198
  return (0, _richText.getTextContent)((0, _richText.slice)(record, 0));
199
199
  }
200
+
201
+ return '';
200
202
  }, [record]);
201
203
  (0, _element.useEffect)(() => {
202
204
  if (!textContent) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/autocomplete/index.tsx"],"names":["EMPTY_FILTERED_OPTIONS","useAutocomplete","record","onChange","onReplace","completers","contentRef","debouncedSpeak","speak","instanceId","selectedIndex","setSelectedIndex","filteredOptions","setFilteredOptions","filterValue","setFilterValue","autocompleter","setAutocompleter","AutocompleterUI","setAutocompleterUI","backspacing","insertCompletion","replacement","end","start","triggerPrefix","length","toInsert","html","select","option","getOptionCompletion","isDisabled","completion","value","isCompletionObject","obj","action","undefined","completionObject","reset","announce","options","onChangeOptions","handleKeyDown","event","current","key","defaultPrevented","isComposing","keyCode","preventDefault","textContent","completer","find","allowContext","index","lastIndexOf","textWithoutTrigger","slice","tooDistantFromTrigger","mismatch","wordsFromTrigger","split","hasOneTriggerWord","matchingWhileBackspacing","textAfterSelection","test","safeTrigger","text","match","RegExp","query","selectedKey","className","isExpanded","listBoxId","activeId","hasSelection","onKeyDown","popover","useLastDifferentValue","history","Set","add","size","delete","Array","from","useAutocompleteProps","ref","onKeyDownRef","previousRecord","mergedRefs","element","_onKeyDown","addEventListener","removeEventListener","didUserInput","children","Autocomplete","isSelected","props"],"mappings":";;;;;;;;;;;AAQA;;AALA;;AAYA;;AACA;;AAMA;;AASA;;AAKA;;AACA;;AArCA;AACA;AACA;;AAGA;AACA;AACA;;AA0BA;AACA;AACA;AAcA,MAAMA,sBAAqC,GAAG,EAA9C;;AAEO,SAASC,eAAT,OAMmB;AAAA,MANO;AAChCC,IAAAA,MADgC;AAEhCC,IAAAA,QAFgC;AAGhCC,IAAAA,SAHgC;AAIhCC,IAAAA,UAJgC;AAKhCC,IAAAA;AALgC,GAMP;AACzB,QAAMC,cAAc,GAAG,0BAAaC,WAAb,EAAoB,GAApB,CAAvB;AACA,QAAMC,UAAU,GAAG,4BAAeR,eAAf,CAAnB;AACA,QAAM,CAAES,aAAF,EAAiBC,gBAAjB,IAAsC,uBAAU,CAAV,CAA5C;AAEA,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAE7Cb,sBAF6C,CAAhD;AAGA,QAAM,CAAEc,WAAF,EAAeC,cAAf,IACL,uBAAmD,EAAnD,CADD;AAEA,QAAM,CAAEC,aAAF,EAAiBC,gBAAjB,IAAsC,uBAC3C,IAD2C,CAA5C;AAGA,QAAM,CAAEC,eAAF,EA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G,MAAH,GAAYtC,SAHpC;AAIN,iBAAasC,SAJP;AAKN,6BAAyBC;AALnB,GAAP;AAOA;;AAEc,SAASuB,YAAT,QAIQ;AAAA,MAJe;AACrCD,IAAAA,QADqC;AAErCE,IAAAA,UAFqC;AAGrC,OAAG3D;AAHkC,GAIf;AACtB,QAAM;AAAEsC,IAAAA,OAAF;AAAW,OAAGsB;AAAd,MAAwBrG,eAAe,CAAEyC,OAAF,CAA7C;AACA,SACC,qDACGyD,QAAQ,CAAEG,KAAF,CADX,EAEGD,UAAU,IAAIrB,OAFjB,CADD;AAMA","sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseEffect,\n\tuseState,\n\tuseRef,\n\tuseMemo,\n} from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseInstanceId,\n\tuseDebounce,\n\tuseMergeRefs,\n\tuseRefEffect,\n} from '@wordpress/compose';\nimport {\n\tcreate,\n\tslice,\n\tinsert,\n\tisCollapsed,\n\tgetTextContent,\n\t// Error expected because `@wordpress/rich-text` is not yet fully typed.\n\t// @ts-expect-error\n} from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { getAutoCompleterUI } from './autocompleter-ui';\nimport { escapeRegExp } from '../utils/strings';\nimport type {\n\tAutocompleteProps,\n\tAutocompleterUIProps,\n\tInsertOption,\n\tKeyedOption,\n\tOptionCompletion,\n\tReplaceOption,\n\tUseAutocompleteProps,\n\tWPCompleter,\n} from './types';\n\nconst EMPTY_FILTERED_OPTIONS: KeyedOption[] = [];\n\nexport function useAutocomplete( {\n\trecord,\n\tonChange,\n\tonReplace,\n\tcompleters,\n\tcontentRef,\n}: UseAutocompleteProps ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst instanceId = useInstanceId( useAutocomplete );\n\tconst [ selectedIndex, setSelectedIndex ] = useState( 0 );\n\n\tconst [ filteredOptions, setFilteredOptions ] = useState<\n\t\tArray< KeyedOption >\n\t>( EMPTY_FILTERED_OPTIONS );\n\tconst [ filterValue, setFilterValue ] =\n\t\tuseState< AutocompleterUIProps[ 'filterValue' ] >( '' );\n\tconst [ autocompleter, setAutocompleter ] = useState< WPCompleter | null >(\n\t\tnull\n\t);\n\tconst [ AutocompleterUI, setAutocompleterUI ] = useState<\n\t\t( ( props: AutocompleterUIProps ) => JSX.Element | null ) | null\n\t>( null );\n\n\tconst backspacing = useRef( false );\n\n\tfunction insertCompletion( replacement: React.ReactNode ) {\n\t\tif ( autocompleter === null ) {\n\t\t\treturn;\n\t\t}\n\t\tconst end = record.start;\n\t\tconst start =\n\t\t\tend - autocompleter.triggerPrefix.length - filterValue.length;\n\t\tconst toInsert = create( { html: renderToString( replacement ) } );\n\n\t\tonChange( insert( record, toInsert, start, end ) );\n\t}\n\n\tfunction select( option: KeyedOption ) {\n\t\tconst { getOptionCompletion } = autocompleter || {};\n\n\t\tif ( option.isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( getOptionCompletion ) {\n\t\t\tconst completion = getOptionCompletion( option.value, filterValue );\n\n\t\t\tconst isCompletionObject = (\n\t\t\t\tobj: OptionCompletion\n\t\t\t): obj is InsertOption | ReplaceOption => {\n\t\t\t\treturn (\n\t\t\t\t\tobj !== null &&\n\t\t\t\t\ttypeof obj === 'object' &&\n\t\t\t\t\t'action' in obj &&\n\t\t\t\t\tobj.action !== undefined &&\n\t\t\t\t\t'value' in obj &&\n\t\t\t\t\tobj.value !== undefined\n\t\t\t\t);\n\t\t\t};\n\n\t\t\tconst completionObject = isCompletionObject( completion )\n\t\t\t\t? completion\n\t\t\t\t: ( {\n\t\t\t\t\t\taction: 'insert-at-caret',\n\t\t\t\t\t\tvalue: completion,\n\t\t\t\t } as InsertOption );\n\n\t\t\tif ( 'replace' === completionObject.action ) {\n\t\t\t\tonReplace( [ completionObject.value ] );\n\t\t\t\t// When replacing, the component will unmount, so don't reset\n\t\t\t\t// state (below) on an unmounted component.\n\t\t\t\treturn;\n\t\t\t} else if ( 'insert-at-caret' === completionObject.action ) {\n\t\t\t\tinsertCompletion( completionObject.value );\n\t\t\t}\n\t\t}\n\n\t\t// Reset autocomplete state after insertion rather than before\n\t\t// so insertion events don't cause the completion menu to redisplay.\n\t\treset();\n\t}\n\n\tfunction reset() {\n\t\tsetSelectedIndex( 0 );\n\t\tsetFilteredOptions( EMPTY_FILTERED_OPTIONS );\n\t\tsetFilterValue( '' );\n\t\tsetAutocompleter( null );\n\t\tsetAutocompleterUI( null );\n\t}\n\n\tfunction announce( options: Array< KeyedOption > ) {\n\t\tif ( ! debouncedSpeak ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( !! options.length ) {\n\t\t\tdebouncedSpeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\toptions.length\n\t\t\t\t\t),\n\t\t\t\t\toptions.length\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else {\n\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t}\n\t}\n\n\t/**\n\t * Load options for an autocompleter.\n\t *\n\t * @param {Array} options\n\t */\n\tfunction onChangeOptions( options: Array< KeyedOption > ) {\n\t\tsetSelectedIndex(\n\t\t\toptions.length === filteredOptions.length ? selectedIndex : 0\n\t\t);\n\t\tsetFilteredOptions( options );\n\t\tannounce( options );\n\t}\n\n\tfunction handleKeyDown( event: KeyboardEvent ) {\n\t\tbackspacing.current = event.key === 'Backspace';\n\n\t\tif ( ! autocompleter ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( filteredOptions.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tevent.defaultPrevented ||\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tswitch ( event.key ) {\n\t\t\tcase 'ArrowUp':\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex === 0\n\t\t\t\t\t\t? filteredOptions.length\n\t\t\t\t\t\t: selectedIndex ) - 1\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'ArrowDown':\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex + 1 ) % filteredOptions.length\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'Escape':\n\t\t\t\tsetAutocompleter( null );\n\t\t\t\tsetAutocompleterUI( null );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tbreak;\n\n\t\t\tcase 'Enter':\n\t\t\t\tselect( filteredOptions[ selectedIndex ] );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\t\treset();\n\t\t\t\treturn;\n\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\t// Any handled key should prevent original behavior. This relies on\n\t\t// the early return in the default case.\n\t\tevent.preventDefault();\n\t}\n\n\t// textContent is a primitive (string), memoizing is not strictly necessary\n\t// but this is a preemptive performance improvement, since the autocompleter\n\t// is a potential bottleneck for the editor type metric.\n\tconst textContent = useMemo( () => {\n\t\tif ( isCollapsed( record ) ) {\n\t\t\treturn getTextContent( slice( record, 0 ) );\n\t\t}\n\t}, [ record ] );\n\n\tuseEffect( () => {\n\t\tif ( ! textContent ) {\n\t\t\tif ( autocompleter ) reset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst completer = completers?.find(\n\t\t\t( { triggerPrefix, allowContext } ) => {\n\t\t\t\tconst index = textContent.lastIndexOf( triggerPrefix );\n\n\t\t\t\tif ( index === -1 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textWithoutTrigger = textContent.slice(\n\t\t\t\t\tindex + triggerPrefix.length\n\t\t\t\t);\n\n\t\t\t\tconst tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.\n\t\t\t\t// This is a final barrier to prevent the effect from completing with\n\t\t\t\t// an extremely long string, which causes the editor to slow-down\n\t\t\t\t// significantly. This could happen, for example, if `matchingWhileBackspacing`\n\t\t\t\t// is true and one of the \"words\" end up being too long. If that's the case,\n\t\t\t\t// it will be caught by this guard.\n\t\t\t\tif ( tooDistantFromTrigger ) return false;\n\n\t\t\t\tconst mismatch = filteredOptions.length === 0;\n\t\t\t\tconst wordsFromTrigger = textWithoutTrigger.split( /\\s/ );\n\t\t\t\t// We need to allow the effect to run when not backspacing and if there\n\t\t\t\t// was a mismatch. i.e when typing a trigger + the match string or when\n\t\t\t\t// clicking in an existing trigger word on the page. We do that if we\n\t\t\t\t// detect that we have one word from trigger in the current textual context.\n\t\t\t\t//\n\t\t\t\t// Ex.: \"Some text @a\" <-- \"@a\" will be detected as the trigger word and\n\t\t\t\t// allow the effect to run. It will run until there's a mismatch.\n\t\t\t\tconst hasOneTriggerWord = wordsFromTrigger.length === 1;\n\t\t\t\t// This is used to allow the effect to run when backspacing and if\n\t\t\t\t// \"touching\" a word that \"belongs\" to a trigger. We consider a \"trigger\n\t\t\t\t// word\" any word up to the limit of 3 from the trigger character.\n\t\t\t\t// Anything beyond that is ignored if there's a mismatch. This allows\n\t\t\t\t// us to \"escape\" a mismatch when backspacing, but still imposing some\n\t\t\t\t// sane limits.\n\t\t\t\t//\n\t\t\t\t// Ex: \"Some text @marcelo sekkkk\" <--- \"kkkk\" caused a mismatch, but\n\t\t\t\t// if the user presses backspace here, it will show the completion popup again.\n\t\t\t\tconst matchingWhileBackspacing =\n\t\t\t\t\tbackspacing.current &&\n\t\t\t\t\ttextWithoutTrigger.split( /\\s/ ).length <= 3;\n\n\t\t\t\tif (\n\t\t\t\t\tmismatch &&\n\t\t\t\t\t! ( matchingWhileBackspacing || hasOneTriggerWord )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textAfterSelection = getTextContent(\n\t\t\t\t\tslice( record, undefined, getTextContent( record ).length )\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\tallowContext &&\n\t\t\t\t\t! allowContext(\n\t\t\t\t\t\ttextContent.slice( 0, index ),\n\t\t\t\t\t\ttextAfterSelection\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t/^\\s/.test( textWithoutTrigger ) ||\n\t\t\t\t\t/\\s\\s+$/.test( textWithoutTrigger )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn /[\\u0000-\\uFFFF]*$/.test( textWithoutTrigger );\n\t\t\t}\n\t\t);\n\n\t\tif ( ! completer ) {\n\t\t\tif ( autocompleter ) reset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst safeTrigger = escapeRegExp( completer.triggerPrefix );\n\t\tconst text = removeAccents( textContent );\n\t\tconst match = text\n\t\t\t.slice( text.lastIndexOf( completer.triggerPrefix ) )\n\t\t\t.match( new RegExp( `${ safeTrigger }([\\u0000-\\uFFFF]*)$` ) );\n\t\tconst query = match && match[ 1 ];\n\n\t\tsetAutocompleter( completer );\n\t\tsetAutocompleterUI( () =>\n\t\t\tcompleter !== autocompleter\n\t\t\t\t? getAutoCompleterUI( completer )\n\t\t\t\t: AutocompleterUI\n\t\t);\n\t\tsetFilterValue( query === null ? '' : query );\n\t\t// Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.\n\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ textContent ] );\n\n\tconst { key: selectedKey = '' } = filteredOptions[ selectedIndex ] || {};\n\tconst { className } = autocompleter || {};\n\tconst isExpanded = !! autocompleter && filteredOptions.length > 0;\n\tconst listBoxId = isExpanded\n\t\t? `components-autocomplete-listbox-${ instanceId }`\n\t\t: undefined;\n\tconst activeId = isExpanded\n\t\t? `components-autocomplete-item-${ instanceId }-${ selectedKey }`\n\t\t: null;\n\tconst hasSelection = record.start !== undefined;\n\n\treturn {\n\t\tlistBoxId,\n\t\tactiveId,\n\t\tonKeyDown: handleKeyDown,\n\t\tpopover: hasSelection && AutocompleterUI && (\n\t\t\t<AutocompleterUI\n\t\t\t\tclassName={ className }\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tinstanceId={ instanceId }\n\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\tonChangeOptions={ onChangeOptions }\n\t\t\t\tonSelect={ select }\n\t\t\t\tvalue={ record }\n\t\t\t\tcontentRef={ contentRef }\n\t\t\t\treset={ reset }\n\t\t\t/>\n\t\t),\n\t};\n}\n\nfunction useLastDifferentValue( value: UseAutocompleteProps[ 'record' ] ) {\n\tconst history = useRef< Set< typeof value > >( new Set() );\n\n\thistory.current.add( value );\n\n\t// Keep the history size to 2.\n\tif ( history.current.size > 2 ) {\n\t\thistory.current.delete( Array.from( history.current )[ 0 ] );\n\t}\n\n\treturn Array.from( history.current )[ 0 ];\n}\n\nexport function useAutocompleteProps( options: UseAutocompleteProps ) {\n\tconst ref = useRef< HTMLElement >( null );\n\tconst onKeyDownRef = useRef< ( event: KeyboardEvent ) => void >();\n\tconst { record } = options;\n\tconst previousRecord = useLastDifferentValue( record );\n\tconst { popover, listBoxId, activeId, onKeyDown } = useAutocomplete( {\n\t\t...options,\n\t\tcontentRef: ref,\n\t} );\n\tonKeyDownRef.current = onKeyDown;\n\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tuseRefEffect( ( element: HTMLElement ) => {\n\t\t\tfunction _onKeyDown( event: KeyboardEvent ) {\n\t\t\t\tonKeyDownRef.current?.( event );\n\t\t\t}\n\t\t\telement.addEventListener( 'keydown', _onKeyDown );\n\t\t\treturn () => {\n\t\t\t\telement.removeEventListener( 'keydown', _onKeyDown );\n\t\t\t};\n\t\t}, [] ),\n\t] );\n\n\t// We only want to show the popover if the user has typed something.\n\tconst didUserInput = record.text !== previousRecord?.text;\n\n\tif ( ! didUserInput ) {\n\t\treturn { ref: mergedRefs };\n\t}\n\n\treturn {\n\t\tref: mergedRefs,\n\t\tchildren: popover,\n\t\t'aria-autocomplete': listBoxId ? 'list' : undefined,\n\t\t'aria-owns': listBoxId,\n\t\t'aria-activedescendant': activeId,\n\t};\n}\n\nexport default function Autocomplete( {\n\tchildren,\n\tisSelected,\n\t...options\n}: AutocompleteProps ) {\n\tconst { popover, ...props } = useAutocomplete( options );\n\treturn (\n\t\t<>\n\t\t\t{ children( props ) }\n\t\t\t{ isSelected && popover }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/autocomplete/index.tsx"],"names":["EMPTY_FILTERED_OPTIONS","useAutocomplete","record","onChange","onReplace","completers","contentRef","debouncedSpeak","speak","instanceId","selectedIndex","setSelectedIndex","filteredOptions","setFilteredOptions","filterValue","setFilterValue","autocompleter","setAutocompleter","AutocompleterUI","setAutocompleterUI","backspacing","insertCompletion","replacement","end","start","triggerPrefix","length","toInsert","html","select","option","getOptionCompletion","isDisabled","completion","value","isCompletionObject","obj","action","undefined","completionObject","reset","announce","options","onChangeOptions","handleKeyDown","event","current","key","defaultPrevented","isComposing","keyCode","preventDefault","textContent","completer","find","allowContext","index","lastIndexOf","textWithoutTrigger","slice","tooDistantFromTrigger","mismatch","wordsFromTrigger","split","hasOneTriggerWord","matchingWhileBackspacing","textAfterSelection","test","safeTrigger","text","match","RegExp","query","selectedKey","className","isExpanded","listBoxId","activeId","hasSelection","onKeyDown","popover","useLastDifferentValue","history","Set","add","size","delete","Array","from","useAutocompleteProps","ref","onKeyDownRef","previousRecord","mergedRefs","element","_onKeyDown","addEventListener","removeEventListener","didUserInput","children","Autocomplete","isSelected","props"],"mappings":";;;;;;;;;;;AAQA;;AALA;;AAYA;;AACA;;AAMA;;AAOA;;AAKA;;AACA;;AAnCA;AACA;AACA;;AAGA;AACA;AACA;;AAwBA;AACA;AACA;AAcA,MAAMA,sBAAqC,GAAG,EAA9C;;AAEO,SAASC,eAAT,OAMmB;AAAA,MANO;AAChCC,IAAAA,MADgC;AAEhCC,IAAAA,QAFgC;AAGhCC,IAAAA,SAHgC;AAIhCC,IAAAA,UAJgC;AAKhCC,IAAAA;AALgC,GAMP;AACzB,QAAMC,cAAc,GAAG,0BAAaC,WAAb,EAAoB,GAApB,CAAvB;AACA,QAAMC,UAAU,GAAG,4BAAeR,eAAf,CAAnB;AACA,QAAM,CAAES,aAAF,EAAiBC,gBAAjB,IAAsC,uBAAU,CAAV,CAA5C;AAEA,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAE7Cb,sBAF6C,CAAhD;AAGA,QAAM,CAAEc,WAAF,EAAeC,cAAf,IACL,uBAAmD,EAAnD,CADD;AAEA,QAAM,CAAEC,aAAF,EAAiBC,gBAAjB,IAAsC,uBAC3C,IAD2C,CAA5C;AAGA,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAE7C,IAF6C,CAAhD;AAIA,QAAMC,WAAW,GAAG,qBAAQ,KAAR,CAApB;;AAEA,WAASC,gBAAT,CAA2BC,WAA3B,EAA0D;AACzD,QAAKN,aAAa,KAAK,IAAvB,EAA8B;AAC7B;AACA;;AACD,UAAMO,GAAG,GAAGrB,MAAM,CAACsB,KAAnB;AACA,UAAMA,KAAK,GACVD,GAAG,GAAGP,aAAa,CAACS,aAAd,CAA4BC,MAAlC,GAA2CZ,WAAW,CAACY,MADxD;AAEA,UAAMC,QAAQ,GAAG,sBAAQ;AAAEC,MAAAA,IAAI,EAAE,6BAAgBN,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*/\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseEffect,\n\tuseState,\n\tuseRef,\n\tuseMemo,\n} from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseInstanceId,\n\tuseDebounce,\n\tuseMergeRefs,\n\tuseRefEffect,\n} from '@wordpress/compose';\nimport {\n\tcreate,\n\tslice,\n\tinsert,\n\tisCollapsed,\n\tgetTextContent,\n} from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { getAutoCompleterUI } from './autocompleter-ui';\nimport { escapeRegExp } from '../utils/strings';\nimport type {\n\tAutocompleteProps,\n\tAutocompleterUIProps,\n\tInsertOption,\n\tKeyedOption,\n\tOptionCompletion,\n\tReplaceOption,\n\tUseAutocompleteProps,\n\tWPCompleter,\n} from './types';\n\nconst EMPTY_FILTERED_OPTIONS: KeyedOption[] = [];\n\nexport function useAutocomplete( {\n\trecord,\n\tonChange,\n\tonReplace,\n\tcompleters,\n\tcontentRef,\n}: UseAutocompleteProps ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst instanceId = useInstanceId( useAutocomplete );\n\tconst [ selectedIndex, setSelectedIndex ] = useState( 0 );\n\n\tconst [ filteredOptions, setFilteredOptions ] = useState<\n\t\tArray< KeyedOption >\n\t>( EMPTY_FILTERED_OPTIONS );\n\tconst [ filterValue, setFilterValue ] =\n\t\tuseState< AutocompleterUIProps[ 'filterValue' ] >( '' );\n\tconst [ autocompleter, setAutocompleter ] = useState< WPCompleter | null >(\n\t\tnull\n\t);\n\tconst [ AutocompleterUI, setAutocompleterUI ] = useState<\n\t\t( ( props: AutocompleterUIProps ) => JSX.Element | null ) | null\n\t>( null );\n\n\tconst backspacing = useRef( false );\n\n\tfunction insertCompletion( replacement: React.ReactNode ) {\n\t\tif ( autocompleter === null ) {\n\t\t\treturn;\n\t\t}\n\t\tconst end = record.start;\n\t\tconst start =\n\t\t\tend - autocompleter.triggerPrefix.length - filterValue.length;\n\t\tconst toInsert = create( { html: renderToString( replacement ) } );\n\n\t\tonChange( insert( record, toInsert, start, end ) );\n\t}\n\n\tfunction select( option: KeyedOption ) {\n\t\tconst { getOptionCompletion } = autocompleter || {};\n\n\t\tif ( option.isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( getOptionCompletion ) {\n\t\t\tconst completion = getOptionCompletion( option.value, filterValue );\n\n\t\t\tconst isCompletionObject = (\n\t\t\t\tobj: OptionCompletion\n\t\t\t): obj is InsertOption | ReplaceOption => {\n\t\t\t\treturn (\n\t\t\t\t\tobj !== null &&\n\t\t\t\t\ttypeof obj === 'object' &&\n\t\t\t\t\t'action' in obj &&\n\t\t\t\t\tobj.action !== undefined &&\n\t\t\t\t\t'value' in obj &&\n\t\t\t\t\tobj.value !== undefined\n\t\t\t\t);\n\t\t\t};\n\n\t\t\tconst completionObject = isCompletionObject( completion )\n\t\t\t\t? completion\n\t\t\t\t: ( {\n\t\t\t\t\t\taction: 'insert-at-caret',\n\t\t\t\t\t\tvalue: completion,\n\t\t\t\t } as InsertOption );\n\n\t\t\tif ( 'replace' === completionObject.action ) {\n\t\t\t\tonReplace( [ completionObject.value ] );\n\t\t\t\t// When replacing, the component will unmount, so don't reset\n\t\t\t\t// state (below) on an unmounted component.\n\t\t\t\treturn;\n\t\t\t} else if ( 'insert-at-caret' === completionObject.action ) {\n\t\t\t\tinsertCompletion( completionObject.value );\n\t\t\t}\n\t\t}\n\n\t\t// Reset autocomplete state after insertion rather than before\n\t\t// so insertion events don't cause the completion menu to redisplay.\n\t\treset();\n\t}\n\n\tfunction reset() {\n\t\tsetSelectedIndex( 0 );\n\t\tsetFilteredOptions( EMPTY_FILTERED_OPTIONS );\n\t\tsetFilterValue( '' );\n\t\tsetAutocompleter( null );\n\t\tsetAutocompleterUI( null );\n\t}\n\n\tfunction announce( options: Array< KeyedOption > ) {\n\t\tif ( ! debouncedSpeak ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( !! options.length ) {\n\t\t\tdebouncedSpeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\toptions.length\n\t\t\t\t\t),\n\t\t\t\t\toptions.length\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else {\n\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t}\n\t}\n\n\t/**\n\t * Load options for an autocompleter.\n\t *\n\t * @param {Array} options\n\t */\n\tfunction onChangeOptions( options: Array< KeyedOption > ) {\n\t\tsetSelectedIndex(\n\t\t\toptions.length === filteredOptions.length ? selectedIndex : 0\n\t\t);\n\t\tsetFilteredOptions( options );\n\t\tannounce( options );\n\t}\n\n\tfunction handleKeyDown( event: KeyboardEvent ) {\n\t\tbackspacing.current = event.key === 'Backspace';\n\n\t\tif ( ! autocompleter ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( filteredOptions.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tevent.defaultPrevented ||\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tswitch ( event.key ) {\n\t\t\tcase 'ArrowUp':\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex === 0\n\t\t\t\t\t\t? filteredOptions.length\n\t\t\t\t\t\t: selectedIndex ) - 1\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'ArrowDown':\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex + 1 ) % filteredOptions.length\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'Escape':\n\t\t\t\tsetAutocompleter( null );\n\t\t\t\tsetAutocompleterUI( null );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tbreak;\n\n\t\t\tcase 'Enter':\n\t\t\t\tselect( filteredOptions[ selectedIndex ] );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\t\treset();\n\t\t\t\treturn;\n\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\t// Any handled key should prevent original behavior. This relies on\n\t\t// the early return in the default case.\n\t\tevent.preventDefault();\n\t}\n\n\t// textContent is a primitive (string), memoizing is not strictly necessary\n\t// but this is a preemptive performance improvement, since the autocompleter\n\t// is a potential bottleneck for the editor type metric.\n\tconst textContent = useMemo( () => {\n\t\tif ( isCollapsed( record ) ) {\n\t\t\treturn getTextContent( slice( record, 0 ) );\n\t\t}\n\t\treturn '';\n\t}, [ record ] );\n\n\tuseEffect( () => {\n\t\tif ( ! textContent ) {\n\t\t\tif ( autocompleter ) reset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst completer = completers?.find(\n\t\t\t( { triggerPrefix, allowContext } ) => {\n\t\t\t\tconst index = textContent.lastIndexOf( triggerPrefix );\n\n\t\t\t\tif ( index === -1 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textWithoutTrigger = textContent.slice(\n\t\t\t\t\tindex + triggerPrefix.length\n\t\t\t\t);\n\n\t\t\t\tconst tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.\n\t\t\t\t// This is a final barrier to prevent the effect from completing with\n\t\t\t\t// an extremely long string, which causes the editor to slow-down\n\t\t\t\t// significantly. This could happen, for example, if `matchingWhileBackspacing`\n\t\t\t\t// is true and one of the \"words\" end up being too long. If that's the case,\n\t\t\t\t// it will be caught by this guard.\n\t\t\t\tif ( tooDistantFromTrigger ) return false;\n\n\t\t\t\tconst mismatch = filteredOptions.length === 0;\n\t\t\t\tconst wordsFromTrigger = textWithoutTrigger.split( /\\s/ );\n\t\t\t\t// We need to allow the effect to run when not backspacing and if there\n\t\t\t\t// was a mismatch. i.e when typing a trigger + the match string or when\n\t\t\t\t// clicking in an existing trigger word on the page. We do that if we\n\t\t\t\t// detect that we have one word from trigger in the current textual context.\n\t\t\t\t//\n\t\t\t\t// Ex.: \"Some text @a\" <-- \"@a\" will be detected as the trigger word and\n\t\t\t\t// allow the effect to run. It will run until there's a mismatch.\n\t\t\t\tconst hasOneTriggerWord = wordsFromTrigger.length === 1;\n\t\t\t\t// This is used to allow the effect to run when backspacing and if\n\t\t\t\t// \"touching\" a word that \"belongs\" to a trigger. We consider a \"trigger\n\t\t\t\t// word\" any word up to the limit of 3 from the trigger character.\n\t\t\t\t// Anything beyond that is ignored if there's a mismatch. This allows\n\t\t\t\t// us to \"escape\" a mismatch when backspacing, but still imposing some\n\t\t\t\t// sane limits.\n\t\t\t\t//\n\t\t\t\t// Ex: \"Some text @marcelo sekkkk\" <--- \"kkkk\" caused a mismatch, but\n\t\t\t\t// if the user presses backspace here, it will show the completion popup again.\n\t\t\t\tconst matchingWhileBackspacing =\n\t\t\t\t\tbackspacing.current &&\n\t\t\t\t\ttextWithoutTrigger.split( /\\s/ ).length <= 3;\n\n\t\t\t\tif (\n\t\t\t\t\tmismatch &&\n\t\t\t\t\t! ( matchingWhileBackspacing || hasOneTriggerWord )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textAfterSelection = getTextContent(\n\t\t\t\t\tslice( record, undefined, getTextContent( record ).length )\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\tallowContext &&\n\t\t\t\t\t! allowContext(\n\t\t\t\t\t\ttextContent.slice( 0, index ),\n\t\t\t\t\t\ttextAfterSelection\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t/^\\s/.test( textWithoutTrigger ) ||\n\t\t\t\t\t/\\s\\s+$/.test( textWithoutTrigger )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn /[\\u0000-\\uFFFF]*$/.test( textWithoutTrigger );\n\t\t\t}\n\t\t);\n\n\t\tif ( ! completer ) {\n\t\t\tif ( autocompleter ) reset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst safeTrigger = escapeRegExp( completer.triggerPrefix );\n\t\tconst text = removeAccents( textContent );\n\t\tconst match = text\n\t\t\t.slice( text.lastIndexOf( completer.triggerPrefix ) )\n\t\t\t.match( new RegExp( `${ safeTrigger }([\\u0000-\\uFFFF]*)$` ) );\n\t\tconst query = match && match[ 1 ];\n\n\t\tsetAutocompleter( completer );\n\t\tsetAutocompleterUI( () =>\n\t\t\tcompleter !== autocompleter\n\t\t\t\t? getAutoCompleterUI( completer )\n\t\t\t\t: AutocompleterUI\n\t\t);\n\t\tsetFilterValue( query === null ? '' : query );\n\t\t// Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.\n\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ textContent ] );\n\n\tconst { key: selectedKey = '' } = filteredOptions[ selectedIndex ] || {};\n\tconst { className } = autocompleter || {};\n\tconst isExpanded = !! autocompleter && filteredOptions.length > 0;\n\tconst listBoxId = isExpanded\n\t\t? `components-autocomplete-listbox-${ instanceId }`\n\t\t: undefined;\n\tconst activeId = isExpanded\n\t\t? `components-autocomplete-item-${ instanceId }-${ selectedKey }`\n\t\t: null;\n\tconst hasSelection = record.start !== undefined;\n\n\treturn {\n\t\tlistBoxId,\n\t\tactiveId,\n\t\tonKeyDown: handleKeyDown,\n\t\tpopover: hasSelection && AutocompleterUI && (\n\t\t\t<AutocompleterUI\n\t\t\t\tclassName={ className }\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tinstanceId={ instanceId }\n\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\tonChangeOptions={ onChangeOptions }\n\t\t\t\tonSelect={ select }\n\t\t\t\tvalue={ record }\n\t\t\t\tcontentRef={ contentRef }\n\t\t\t\treset={ reset }\n\t\t\t/>\n\t\t),\n\t};\n}\n\nfunction useLastDifferentValue( value: UseAutocompleteProps[ 'record' ] ) {\n\tconst history = useRef< Set< typeof value > >( new Set() );\n\n\thistory.current.add( value );\n\n\t// Keep the history size to 2.\n\tif ( history.current.size > 2 ) {\n\t\thistory.current.delete( Array.from( history.current )[ 0 ] );\n\t}\n\n\treturn Array.from( history.current )[ 0 ];\n}\n\nexport function useAutocompleteProps( options: UseAutocompleteProps ) {\n\tconst ref = useRef< HTMLElement >( null );\n\tconst onKeyDownRef = useRef< ( event: KeyboardEvent ) => void >();\n\tconst { record } = options;\n\tconst previousRecord = useLastDifferentValue( record );\n\tconst { popover, listBoxId, activeId, onKeyDown } = useAutocomplete( {\n\t\t...options,\n\t\tcontentRef: ref,\n\t} );\n\tonKeyDownRef.current = onKeyDown;\n\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tuseRefEffect( ( element: HTMLElement ) => {\n\t\t\tfunction _onKeyDown( event: KeyboardEvent ) {\n\t\t\t\tonKeyDownRef.current?.( event );\n\t\t\t}\n\t\t\telement.addEventListener( 'keydown', _onKeyDown );\n\t\t\treturn () => {\n\t\t\t\telement.removeEventListener( 'keydown', _onKeyDown );\n\t\t\t};\n\t\t}, [] ),\n\t] );\n\n\t// We only want to show the popover if the user has typed something.\n\tconst didUserInput = record.text !== previousRecord?.text;\n\n\tif ( ! didUserInput ) {\n\t\treturn { ref: mergedRefs };\n\t}\n\n\treturn {\n\t\tref: mergedRefs,\n\t\tchildren: popover,\n\t\t'aria-autocomplete': listBoxId ? 'list' : undefined,\n\t\t'aria-owns': listBoxId,\n\t\t'aria-activedescendant': activeId,\n\t};\n}\n\nexport default function Autocomplete( {\n\tchildren,\n\tisSelected,\n\t...options\n}: AutocompleteProps ) {\n\tconst { popover, ...props } = useAutocomplete( options );\n\treturn (\n\t\t<>\n\t\t\t{ children( props ) }\n\t\t\t{ isSelected && popover }\n\t\t</>\n\t);\n}\n"]}
@@ -94,6 +94,7 @@ function UnforwardedButton(props, ref) {
94
94
  var _children$, _children$$props;
95
95
 
96
96
  const {
97
+ __next40pxDefaultSize,
97
98
  isSmall,
98
99
  isPressed,
99
100
  isBusy,
@@ -127,6 +128,7 @@ function UnforwardedButton(props, ref) {
127
128
  const hasChildren = 'string' === typeof children && !!children || Array.isArray(children) && (children === null || children === void 0 ? void 0 : children[0]) && children[0] !== null && // Tooltip should not considered as a child
128
129
  (children === null || children === void 0 ? void 0 : (_children$ = children[0]) === null || _children$ === void 0 ? void 0 : (_children$$props = _children$.props) === null || _children$$props === void 0 ? void 0 : _children$$props.className) !== 'components-tooltip';
129
130
  const classes = (0, _classnames.default)('components-button', className, {
131
+ 'is-next-40px-default-size': __next40pxDefaultSize,
130
132
  'is-secondary': variant === 'secondary',
131
133
  'is-primary': variant === 'primary',
132
134
  'is-small': isSmall,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/button/index.tsx"],"names":["disabledEventsOnDisabledButton","useDeprecatedProps","isDefault","isPrimary","isSecondary","isTertiary","isLink","variant","otherProps","computedVariant","since","alternative","version","UnforwardedButton","props","ref","isSmall","isPressed","isBusy","isDestructive","className","disabled","icon","iconPosition","iconSize","showTooltip","tooltipPosition","shortcut","label","children","text","__experimentalIsFocusable","isFocusable","describedBy","buttonOrAnchorProps","href","target","additionalProps","undefined","instanceId","Button","hasChildren","Array","isArray","classes","trulyDisabled","Tag","buttonProps","type","anchorProps","disabledEvent","event","stopPropagation","preventDefault","shouldShowTooltip","length","descriptionId","describedById","commonProps","elementChildren","element"],"mappings":";;;;;;;;;;;AAgBA;;;;AAbA;;AAYA;;AAEA;;A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X,KAA6BvB,WAA7B,CADD,CAdF,CADD;AAqBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMO,MAAM,GAAG,yBAAY3B,iBAAZ,CAAf;;eACQ2B,M","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type {\n\tComponentPropsWithoutRef,\n\tForwardedRef,\n\tHTMLAttributes,\n\tMouseEvent,\n\tReactElement,\n} from 'react';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport Icon from '../icon';\nimport { VisuallyHidden } from '../visually-hidden';\nimport type { ButtonProps, DeprecatedButtonProps } from './types';\n\nconst disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ] as const;\n\nfunction useDeprecatedProps( {\n\tisDefault,\n\tisPrimary,\n\tisSecondary,\n\tisTertiary,\n\tisLink,\n\tvariant,\n\t...otherProps\n}: ButtonProps & DeprecatedButtonProps ): ButtonProps {\n\tlet computedVariant = variant;\n\n\tif ( isPrimary ) {\n\t\tcomputedVariant ??= 'primary';\n\t}\n\n\tif ( isTertiary ) {\n\t\tcomputedVariant ??= 'tertiary';\n\t}\n\n\tif ( isSecondary ) {\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isDefault ) {\n\t\tdeprecated( 'Button isDefault prop', {\n\t\t\tsince: '5.4',\n\t\t\talternative: 'variant=\"secondary\"',\n\t\t\tversion: '6.2',\n\t\t} );\n\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isLink ) {\n\t\tcomputedVariant ??= 'link';\n\t}\n\n\treturn {\n\t\t...otherProps,\n\t\tvariant: computedVariant,\n\t};\n}\n\nexport function UnforwardedButton(\n\tprops: ButtonProps,\n\tref: ForwardedRef< any >\n) {\n\tconst {\n\t\tisSmall,\n\t\tisPressed,\n\t\tisBusy,\n\t\tisDestructive,\n\t\tclassName,\n\t\tdisabled,\n\t\ticon,\n\t\ticonPosition = 'left',\n\t\ticonSize,\n\t\tshowTooltip,\n\t\ttooltipPosition,\n\t\tshortcut,\n\t\tlabel,\n\t\tchildren,\n\t\ttext,\n\t\tvariant,\n\t\t__experimentalIsFocusable: isFocusable,\n\t\tdescribedBy,\n\t\t...buttonOrAnchorProps\n\t} = useDeprecatedProps( props );\n\n\tconst { href, target, ...additionalProps } =\n\t\t'href' in buttonOrAnchorProps\n\t\t\t? buttonOrAnchorProps\n\t\t\t: { href: undefined, target: undefined, ...buttonOrAnchorProps };\n\n\tconst instanceId = useInstanceId(\n\t\tButton,\n\t\t'components-button__description'\n\t);\n\n\tconst hasChildren =\n\t\t( 'string' === typeof children && !! children ) ||\n\t\t( Array.isArray( children ) &&\n\t\t\tchildren?.[ 0 ] &&\n\t\t\tchildren[ 0 ] !== null &&\n\t\t\t// Tooltip should not considered as a child\n\t\t\tchildren?.[ 0 ]?.props?.className !== 'components-tooltip' );\n\n\tconst classes = classnames( 'components-button', className, {\n\t\t'is-secondary': variant === 'secondary',\n\t\t'is-primary': variant === 'primary',\n\t\t'is-small': isSmall,\n\t\t'is-tertiary': variant === 'tertiary',\n\t\t'is-pressed': isPressed,\n\t\t'is-busy': isBusy,\n\t\t'is-link': variant === 'link',\n\t\t'is-destructive': isDestructive,\n\t\t'has-text': !! icon && hasChildren,\n\t\t'has-icon': !! icon,\n\t} );\n\n\tconst trulyDisabled = disabled && ! isFocusable;\n\tconst Tag = href !== undefined && ! trulyDisabled ? 'a' : 'button';\n\tconst buttonProps: ComponentPropsWithoutRef< 'button' > =\n\t\tTag === 'button'\n\t\t\t? {\n\t\t\t\t\ttype: 'button',\n\t\t\t\t\tdisabled: trulyDisabled,\n\t\t\t\t\t'aria-pressed': isPressed,\n\t\t\t }\n\t\t\t: {};\n\tconst anchorProps: ComponentPropsWithoutRef< 'a' > =\n\t\tTag === 'a' ? { href, target } : {};\n\n\tif ( disabled && isFocusable ) {\n\t\t// In this case, the button will be disabled, but still focusable and\n\t\t// perceivable by screen reader users.\n\t\tbuttonProps[ 'aria-disabled' ] = true;\n\t\tanchorProps[ 'aria-disabled' ] = true;\n\n\t\tfor ( const disabledEvent of disabledEventsOnDisabledButton ) {\n\t\t\tadditionalProps[ disabledEvent ] = ( event: MouseEvent ) => {\n\t\t\t\tif ( event ) {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}\n\n\t// Should show the tooltip if...\n\tconst shouldShowTooltip =\n\t\t! trulyDisabled &&\n\t\t// An explicit tooltip is passed or...\n\t\t( ( showTooltip && label ) ||\n\t\t\t// There's a shortcut or...\n\t\t\tshortcut ||\n\t\t\t// There's a label and...\n\t\t\t( !! label &&\n\t\t\t\t// The children are empty and...\n\t\t\t\t! ( children as string | ReactElement[] )?.length &&\n\t\t\t\t// The tooltip is not explicitly disabled.\n\t\t\t\tfalse !== showTooltip ) );\n\n\tconst descriptionId = describedBy ? instanceId : undefined;\n\n\tconst describedById =\n\t\tadditionalProps[ 'aria-describedby' ] || descriptionId;\n\n\tconst commonProps = {\n\t\tclassName: classes,\n\t\t'aria-label': additionalProps[ 'aria-label' ] || label,\n\t\t'aria-describedby': describedById,\n\t\tref,\n\t};\n\n\tconst elementChildren = (\n\t\t<>\n\t\t\t{ icon && iconPosition === 'left' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ text && <>{ text }</> }\n\t\t\t{ icon && iconPosition === 'right' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ children }\n\t\t</>\n\t);\n\n\tconst element =\n\t\tTag === 'a' ? (\n\t\t\t<a\n\t\t\t\t{ ...anchorProps }\n\t\t\t\t{ ...( additionalProps as HTMLAttributes< HTMLAnchorElement > ) }\n\t\t\t\t{ ...commonProps }\n\t\t\t>\n\t\t\t\t{ elementChildren }\n\t\t\t</a>\n\t\t) : (\n\t\t\t<button\n\t\t\t\t{ ...buttonProps }\n\t\t\t\t{ ...( additionalProps as HTMLAttributes< HTMLButtonElement > ) }\n\t\t\t\t{ ...commonProps }\n\t\t\t>\n\t\t\t\t{ elementChildren }\n\t\t\t</button>\n\t\t);\n\n\tif ( ! shouldShowTooltip ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element }\n\t\t\t\t{ describedBy && (\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Tooltip\n\t\t\t\ttext={\n\t\t\t\t\t( children as string | ReactElement[] )?.length &&\n\t\t\t\t\tdescribedBy\n\t\t\t\t\t\t? describedBy\n\t\t\t\t\t\t: label\n\t\t\t\t}\n\t\t\t\tshortcut={ shortcut }\n\t\t\t\tposition={ tooltipPosition }\n\t\t\t>\n\t\t\t\t{ element }\n\t\t\t</Tooltip>\n\t\t\t{ describedBy && (\n\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t</VisuallyHidden>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Lets users take actions and make choices with a single click or tap.\n *\n * ```jsx\n * import { Button } from '@wordpress/components';\n * const Mybutton = () => (\n * <Button\n * variant=\"primary\"\n * onClick={ handleClick }\n * >\n * Click here\n * </Button>\n * );\n * ```\n */\nexport const Button = forwardRef( UnforwardedButton );\nexport default Button;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/button/index.tsx"],"names":["disabledEventsOnDisabledButton","useDeprecatedProps","isDefault","isPrimary","isSecondary","isTertiary","isLink","variant","otherProps","computedVariant","since","alternative","version","UnforwardedButton","props","ref","__next40pxDefaultSize","isSmall","isPressed","isBusy","isDestructive","className","disabled","icon","iconPosition","iconSize","showTooltip","tooltipPosition","shortcut","label","children","text","__experimentalIsFocusable","isFocusable","describedBy","buttonOrAnchorProps","href","target","additionalProps","undefined","instanceId","Button","hasChildren","Array","isArray","classes","trulyDisabled","Tag","buttonProps","type","anchorProps","disabledEvent","event","stopPropagation","preventDefault","shouldShowTooltip","length","descriptionId","describedById","commonProps","elementChildren","element"],"mappings":";;;;;;;;;;;AAgBA;;;;AAbA;;AAYA;;AAEA;;AAKA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AAMA,MAAMA,8BAA8B,GAAG,CAAE,aAAF,EAAiB,SAAjB,CAAvC;;AAEA,SAASC,kBAAT,OAQsD;AAAA,MARzB;AAC5BC,IAAAA,SAD4B;AAE5BC,IAAAA,SAF4B;AAG5BC,IAAAA,WAH4B;AAI5BC,IAAAA,UAJ4B;AAK5BC,IAAAA,MAL4B;AAM5BC,IAAAA,OAN4B;AAO5B,OAAGC;AAPyB,GAQyB;AACrD,MAAIC,eAAe,GAAGF,OAAtB;;AAEA,MAAKJ,SAAL,EAAiB;AAAA;;AAChB,wBAAAM,eAAe,UAAf,qDAAAA,eAAe,GAAK,SAApB;AACA;;AAED,MAAKJ,UAAL,EAAkB;AAAA;;AACjB,yBAAAI,eAAe,UAAf,uDAAAA,eAAe,GAAK,UAApB;AACA;;AAED,MAAKL,WAAL,EAAmB;AAAA;;AAClB,yBAAAK,eAAe,UAAf,uDAAAA,eAAe,GAAK,WAApB;AACA;;AAED,MAAKP,SAAL,EAAiB;AAAA;;AAChB,6BAAY,uBAAZ,EAAqC;AACpCQ,MAAAA,KAAK,EAAE,KAD6B;AAEpCC,MAAAA,WAAW,EAAE,qBAFuB;AAGpCC,MAAAA,OAAO,EAAE;AAH2B,KAArC;AAMA,yBAAAH,eAAe,UAAf,uDAAAA,eAAe,GAAK,WAApB;AACA;;AAED,MAAKH,MAAL,EAAc;AAAA;;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C;AAAM,MAAA,EAAE,EAAGuB;AAAX,OAA6BvB,WAA7B,CADD,CAHF,CADD;AAUA;;AAED,SACC,qDACC,4BAAC,gBAAD;AACC,IAAA,IAAI,EACDJ,QAAF,aAAEA,QAAF,eAAEA,QAAF,CAAyC0B,MAAzC,IACAtB,WADA,GAEGA,WAFH,GAGGL,KALL;AAOC,IAAA,QAAQ,EAAGD,QAPZ;AAQC,IAAA,QAAQ,EAAGD;AARZ,KAUGkC,OAVH,CADD,EAaG3B,WAAW,IACZ,4BAAC,8BAAD,QACC;AAAM,IAAA,EAAE,EAAGuB;AAAX,KAA6BvB,WAA7B,CADD,CAdF,CADD;AAqBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMO,MAAM,GAAG,yBAAY5B,iBAAZ,CAAf;;eACQ4B,M","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type {\n\tComponentPropsWithoutRef,\n\tForwardedRef,\n\tHTMLAttributes,\n\tMouseEvent,\n\tReactElement,\n} from 'react';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport Icon from '../icon';\nimport { VisuallyHidden } from '../visually-hidden';\nimport type { ButtonProps, DeprecatedButtonProps } from './types';\n\nconst disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ] as const;\n\nfunction useDeprecatedProps( {\n\tisDefault,\n\tisPrimary,\n\tisSecondary,\n\tisTertiary,\n\tisLink,\n\tvariant,\n\t...otherProps\n}: ButtonProps & DeprecatedButtonProps ): ButtonProps {\n\tlet computedVariant = variant;\n\n\tif ( isPrimary ) {\n\t\tcomputedVariant ??= 'primary';\n\t}\n\n\tif ( isTertiary ) {\n\t\tcomputedVariant ??= 'tertiary';\n\t}\n\n\tif ( isSecondary ) {\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isDefault ) {\n\t\tdeprecated( 'Button isDefault prop', {\n\t\t\tsince: '5.4',\n\t\t\talternative: 'variant=\"secondary\"',\n\t\t\tversion: '6.2',\n\t\t} );\n\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isLink ) {\n\t\tcomputedVariant ??= 'link';\n\t}\n\n\treturn {\n\t\t...otherProps,\n\t\tvariant: computedVariant,\n\t};\n}\n\nexport function UnforwardedButton(\n\tprops: ButtonProps,\n\tref: ForwardedRef< any >\n) {\n\tconst {\n\t\t__next40pxDefaultSize,\n\t\tisSmall,\n\t\tisPressed,\n\t\tisBusy,\n\t\tisDestructive,\n\t\tclassName,\n\t\tdisabled,\n\t\ticon,\n\t\ticonPosition = 'left',\n\t\ticonSize,\n\t\tshowTooltip,\n\t\ttooltipPosition,\n\t\tshortcut,\n\t\tlabel,\n\t\tchildren,\n\t\ttext,\n\t\tvariant,\n\t\t__experimentalIsFocusable: isFocusable,\n\t\tdescribedBy,\n\t\t...buttonOrAnchorProps\n\t} = useDeprecatedProps( props );\n\n\tconst { href, target, ...additionalProps } =\n\t\t'href' in buttonOrAnchorProps\n\t\t\t? buttonOrAnchorProps\n\t\t\t: { href: undefined, target: undefined, ...buttonOrAnchorProps };\n\n\tconst instanceId = useInstanceId(\n\t\tButton,\n\t\t'components-button__description'\n\t);\n\n\tconst hasChildren =\n\t\t( 'string' === typeof children && !! children ) ||\n\t\t( Array.isArray( children ) &&\n\t\t\tchildren?.[ 0 ] &&\n\t\t\tchildren[ 0 ] !== null &&\n\t\t\t// Tooltip should not considered as a child\n\t\t\tchildren?.[ 0 ]?.props?.className !== 'components-tooltip' );\n\n\tconst classes = classnames( 'components-button', className, {\n\t\t'is-next-40px-default-size': __next40pxDefaultSize,\n\t\t'is-secondary': variant === 'secondary',\n\t\t'is-primary': variant === 'primary',\n\t\t'is-small': isSmall,\n\t\t'is-tertiary': variant === 'tertiary',\n\t\t'is-pressed': isPressed,\n\t\t'is-busy': isBusy,\n\t\t'is-link': variant === 'link',\n\t\t'is-destructive': isDestructive,\n\t\t'has-text': !! icon && hasChildren,\n\t\t'has-icon': !! icon,\n\t} );\n\n\tconst trulyDisabled = disabled && ! isFocusable;\n\tconst Tag = href !== undefined && ! trulyDisabled ? 'a' : 'button';\n\tconst buttonProps: ComponentPropsWithoutRef< 'button' > =\n\t\tTag === 'button'\n\t\t\t? {\n\t\t\t\t\ttype: 'button',\n\t\t\t\t\tdisabled: trulyDisabled,\n\t\t\t\t\t'aria-pressed': isPressed,\n\t\t\t }\n\t\t\t: {};\n\tconst anchorProps: ComponentPropsWithoutRef< 'a' > =\n\t\tTag === 'a' ? { href, target } : {};\n\n\tif ( disabled && isFocusable ) {\n\t\t// In this case, the button will be disabled, but still focusable and\n\t\t// perceivable by screen reader users.\n\t\tbuttonProps[ 'aria-disabled' ] = true;\n\t\tanchorProps[ 'aria-disabled' ] = true;\n\n\t\tfor ( const disabledEvent of disabledEventsOnDisabledButton ) {\n\t\t\tadditionalProps[ disabledEvent ] = ( event: MouseEvent ) => {\n\t\t\t\tif ( event ) {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}\n\n\t// Should show the tooltip if...\n\tconst shouldShowTooltip =\n\t\t! trulyDisabled &&\n\t\t// An explicit tooltip is passed or...\n\t\t( ( showTooltip && label ) ||\n\t\t\t// There's a shortcut or...\n\t\t\tshortcut ||\n\t\t\t// There's a label and...\n\t\t\t( !! label &&\n\t\t\t\t// The children are empty and...\n\t\t\t\t! ( children as string | ReactElement[] )?.length &&\n\t\t\t\t// The tooltip is not explicitly disabled.\n\t\t\t\tfalse !== showTooltip ) );\n\n\tconst descriptionId = describedBy ? instanceId : undefined;\n\n\tconst describedById =\n\t\tadditionalProps[ 'aria-describedby' ] || descriptionId;\n\n\tconst commonProps = {\n\t\tclassName: classes,\n\t\t'aria-label': additionalProps[ 'aria-label' ] || label,\n\t\t'aria-describedby': describedById,\n\t\tref,\n\t};\n\n\tconst elementChildren = (\n\t\t<>\n\t\t\t{ icon && iconPosition === 'left' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ text && <>{ text }</> }\n\t\t\t{ icon && iconPosition === 'right' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ children }\n\t\t</>\n\t);\n\n\tconst element =\n\t\tTag === 'a' ? (\n\t\t\t<a\n\t\t\t\t{ ...anchorProps }\n\t\t\t\t{ ...( additionalProps as HTMLAttributes< HTMLAnchorElement > ) }\n\t\t\t\t{ ...commonProps }\n\t\t\t>\n\t\t\t\t{ elementChildren }\n\t\t\t</a>\n\t\t) : (\n\t\t\t<button\n\t\t\t\t{ ...buttonProps }\n\t\t\t\t{ ...( additionalProps as HTMLAttributes< HTMLButtonElement > ) }\n\t\t\t\t{ ...commonProps }\n\t\t\t>\n\t\t\t\t{ elementChildren }\n\t\t\t</button>\n\t\t);\n\n\tif ( ! shouldShowTooltip ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element }\n\t\t\t\t{ describedBy && (\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Tooltip\n\t\t\t\ttext={\n\t\t\t\t\t( children as string | ReactElement[] )?.length &&\n\t\t\t\t\tdescribedBy\n\t\t\t\t\t\t? describedBy\n\t\t\t\t\t\t: label\n\t\t\t\t}\n\t\t\t\tshortcut={ shortcut }\n\t\t\t\tposition={ tooltipPosition }\n\t\t\t>\n\t\t\t\t{ element }\n\t\t\t</Tooltip>\n\t\t\t{ describedBy && (\n\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t</VisuallyHidden>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Lets users take actions and make choices with a single click or tap.\n *\n * ```jsx\n * import { Button } from '@wordpress/components';\n * const Mybutton = () => (\n * <Button\n * variant=\"primary\"\n * onClick={ handleClick }\n * >\n * Click here\n * </Button>\n * );\n * ```\n */\nexport const Button = forwardRef( UnforwardedButton );\nexport default Button;\n"]}
@@ -31,7 +31,8 @@ function UnconnectedCardMedia(props, forwardedRef) {
31
31
  }));
32
32
  }
33
33
  /**
34
- * `CardMedia` provides a container for media elements within a `Card`.
34
+ * `CardMedia` provides a container for full-bleed content within a `Card`,
35
+ * such as images, video, or even just a background color.
35
36
  *
36
37
  * @example
37
38
  * ```jsx
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/card/card-media/component.tsx"],"names":["UnconnectedCardMedia","props","forwardedRef","cardMediaProps","CardMedia"],"mappings":";;;;;;;;;;;;;AAQA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,oBAAT,CACCC,KADD,EAECC,YAFD,EAGE;AACD,QAAMC,cAAc,GAAG,wBAAcF,KAAd,CAAvB;AAEA,SAAO,4BAAC,UAAD,6BAAWE,cAAX;AAA4B,IAAA,GAAG,EAAGD;AAAlC,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,SAAS,GAAG,6BAAgBJ,oBAAhB,EAAsC,WAAtC,CAAlB;;eAEQI,S","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { View } from '../../view';\nimport { useCardMedia } from './hook';\nimport type { MediaProps } from '../types';\n\nfunction UnconnectedCardMedia(\n\tprops: WordPressComponentProps< MediaProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst cardMediaProps = useCardMedia( props );\n\n\treturn <View { ...cardMediaProps } ref={ forwardedRef } />;\n}\n\n/**\n * `CardMedia` provides a container for media elements within a `Card`.\n *\n * @example\n * ```jsx\n * import { Card, CardBody, CardMedia } from '@wordpress/components';\n *\n * const Example = () => (\n * <Card>\n *\t <CardMedia>\n *\t\t <img src=\"...\" />\n * </CardMedia>\n * <CardBody>...</CardBody>\n * </Card>\n * );\n * ```\n */\nexport const CardMedia = contextConnect( UnconnectedCardMedia, 'CardMedia' );\n\nexport default CardMedia;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/card/card-media/component.tsx"],"names":["UnconnectedCardMedia","props","forwardedRef","cardMediaProps","CardMedia"],"mappings":";;;;;;;;;;;;;AAQA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,oBAAT,CACCC,KADD,EAECC,YAFD,EAGE;AACD,QAAMC,cAAc,GAAG,wBAAcF,KAAd,CAAvB;AAEA,SAAO,4BAAC,UAAD,6BAAWE,cAAX;AAA4B,IAAA,GAAG,EAAGD;AAAlC,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,SAAS,GAAG,6BAAgBJ,oBAAhB,EAAsC,WAAtC,CAAlB;;eAEQI,S","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { View } from '../../view';\nimport { useCardMedia } from './hook';\nimport type { MediaProps } from '../types';\n\nfunction UnconnectedCardMedia(\n\tprops: WordPressComponentProps< MediaProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst cardMediaProps = useCardMedia( props );\n\n\treturn <View { ...cardMediaProps } ref={ forwardedRef } />;\n}\n\n/**\n * `CardMedia` provides a container for full-bleed content within a `Card`,\n * such as images, video, or even just a background color.\n *\n * @example\n * ```jsx\n * import { Card, CardBody, CardMedia } from '@wordpress/components';\n *\n * const Example = () => (\n * <Card>\n *\t <CardMedia>\n *\t\t <img src=\"...\" />\n * </CardMedia>\n * <CardBody>...</CardBody>\n * </Card>\n * );\n * ```\n */\nexport const CardMedia = contextConnect( UnconnectedCardMedia, 'CardMedia' );\n\nexport default CardMedia;\n"]}