@wordpress/components 25.9.1 → 25.11.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 (369) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/build/alignment-matrix-control/cell.js +8 -5
  3. package/build/alignment-matrix-control/cell.js.map +1 -1
  4. package/build/alignment-matrix-control/index.js +27 -43
  5. package/build/alignment-matrix-control/index.js.map +1 -1
  6. package/build/alignment-matrix-control/utils.js +29 -9
  7. package/build/alignment-matrix-control/utils.js.map +1 -1
  8. package/build/autocomplete/index.js +104 -52
  9. package/build/autocomplete/index.js.map +1 -1
  10. package/build/circular-option-picker/circular-option-picker-option.js +20 -39
  11. package/build/circular-option-picker/circular-option-picker-option.js.map +1 -1
  12. package/build/circular-option-picker/circular-option-picker.js +11 -32
  13. package/build/circular-option-picker/circular-option-picker.js.map +1 -1
  14. package/build/circular-option-picker/types.js.map +1 -1
  15. package/build/color-palette/index.js +7 -2
  16. package/build/color-palette/index.js.map +1 -1
  17. package/build/color-picker/component.js +12 -2
  18. package/build/color-picker/component.js.map +1 -1
  19. package/build/color-picker/picker.js +77 -1
  20. package/build/color-picker/picker.js.map +1 -1
  21. package/build/color-picker/styles.js +8 -8
  22. package/build/color-picker/styles.js.map +1 -1
  23. package/build/color-picker/types.js.map +1 -1
  24. package/build/composite/v2.js +43 -0
  25. package/build/composite/v2.js.map +1 -0
  26. package/build/confirm-dialog/component.js +74 -8
  27. package/build/confirm-dialog/component.js.map +1 -1
  28. package/build/confirm-dialog/types.js.map +1 -1
  29. package/build/custom-gradient-picker/gradient-bar/control-points.js +13 -4
  30. package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  31. package/build/dropdown-menu-v2-ariakit/index.js +217 -0
  32. package/build/dropdown-menu-v2-ariakit/index.js.map +1 -0
  33. package/build/dropdown-menu-v2-ariakit/styles.js +157 -0
  34. package/build/dropdown-menu-v2-ariakit/styles.js.map +1 -0
  35. package/build/dropdown-menu-v2-ariakit/types.js +6 -0
  36. package/build/dropdown-menu-v2-ariakit/types.js.map +1 -0
  37. package/build/font-size-picker/utils.js +1 -1
  38. package/build/font-size-picker/utils.js.map +1 -1
  39. package/build/input-control/styles/input-control-styles.js +23 -23
  40. package/build/input-control/styles/input-control-styles.js.map +1 -1
  41. package/build/mobile/global-styles-context/utils.native.js +1 -1
  42. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  43. package/build/modal/index.js +45 -16
  44. package/build/modal/index.js.map +1 -1
  45. package/build/palette-edit/index.js +4 -0
  46. package/build/palette-edit/index.js.map +1 -1
  47. package/build/popover/index.js +34 -6
  48. package/build/popover/index.js.map +1 -1
  49. package/build/private-apis.js +18 -2
  50. package/build/private-apis.js.map +1 -1
  51. package/build/progress-bar/styles.js +5 -5
  52. package/build/progress-bar/styles.js.map +1 -1
  53. package/build/sandbox/index.js +1 -1
  54. package/build/sandbox/index.js.map +1 -1
  55. package/build/sandbox/index.native.js +1 -1
  56. package/build/sandbox/index.native.js.map +1 -1
  57. package/build/select-control/styles/select-control-styles.js +8 -8
  58. package/build/select-control/styles/select-control-styles.js.map +1 -1
  59. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  60. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  61. package/build/tabs/context.js +16 -0
  62. package/build/tabs/context.js.map +1 -0
  63. package/build/tabs/index.js +147 -0
  64. package/build/tabs/index.js.map +1 -0
  65. package/build/tabs/styles.js +38 -0
  66. package/build/tabs/styles.js.map +1 -0
  67. package/build/tabs/tab.js +46 -0
  68. package/build/tabs/tab.js.map +1 -0
  69. package/build/tabs/tablist.js +47 -0
  70. package/build/tabs/tablist.js.map +1 -0
  71. package/build/tabs/tabpanel.js +48 -0
  72. package/build/tabs/tabpanel.js.map +1 -0
  73. package/build/tabs/types.js +6 -0
  74. package/build/tabs/types.js.map +1 -0
  75. package/build/text/component.js +7 -6
  76. package/build/text/component.js.map +1 -1
  77. package/build/text/hook.js +6 -15
  78. package/build/text/hook.js.map +1 -1
  79. package/build/text/index.js.map +1 -1
  80. package/build/text/styles.js +7 -7
  81. package/build/text/styles.js.map +1 -1
  82. package/build/text/types.js.map +1 -1
  83. package/build/text/utils.js +17 -33
  84. package/build/text/utils.js.map +1 -1
  85. package/build/toggle-group-control/toggle-group-control-option-base/component.js +1 -0
  86. package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  87. package/build/toolbar/toolbar/index.js +17 -10
  88. package/build/toolbar/toolbar/index.js.map +1 -1
  89. package/build/toolbar/toolbar/types.js.map +1 -1
  90. package/build/tools-panel/tools-panel-item/hook.js +2 -2
  91. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  92. package/build/tools-panel/types.js.map +1 -1
  93. package/build/tooltip/index.js +2 -2
  94. package/build/tooltip/index.js.map +1 -1
  95. package/build/unit-control/utils.js +108 -0
  96. package/build/unit-control/utils.js.map +1 -1
  97. package/build/utils/unit-values.js +1 -1
  98. package/build/utils/unit-values.js.map +1 -1
  99. package/build-module/alignment-matrix-control/cell.js +7 -4
  100. package/build-module/alignment-matrix-control/cell.js.map +1 -1
  101. package/build-module/alignment-matrix-control/index.js +27 -43
  102. package/build-module/alignment-matrix-control/index.js.map +1 -1
  103. package/build-module/alignment-matrix-control/utils.js +29 -8
  104. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  105. package/build-module/autocomplete/index.js +104 -52
  106. package/build-module/autocomplete/index.js.map +1 -1
  107. package/build-module/circular-option-picker/circular-option-picker-option.js +20 -39
  108. package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -1
  109. package/build-module/circular-option-picker/circular-option-picker.js +10 -31
  110. package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
  111. package/build-module/circular-option-picker/types.js.map +1 -1
  112. package/build-module/color-palette/index.js +7 -2
  113. package/build-module/color-palette/index.js.map +1 -1
  114. package/build-module/color-picker/component.js +13 -3
  115. package/build-module/color-picker/component.js.map +1 -1
  116. package/build-module/color-picker/picker.js +78 -2
  117. package/build-module/color-picker/picker.js.map +1 -1
  118. package/build-module/color-picker/styles.js +8 -8
  119. package/build-module/color-picker/styles.js.map +1 -1
  120. package/build-module/color-picker/types.js.map +1 -1
  121. package/build-module/composite/v2.js +15 -0
  122. package/build-module/composite/v2.js.map +1 -0
  123. package/build-module/confirm-dialog/component.js +72 -7
  124. package/build-module/confirm-dialog/component.js.map +1 -1
  125. package/build-module/confirm-dialog/types.js.map +1 -1
  126. package/build-module/custom-gradient-picker/gradient-bar/control-points.js +13 -4
  127. package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  128. package/build-module/dropdown-menu-v2-ariakit/index.js +199 -0
  129. package/build-module/dropdown-menu-v2-ariakit/index.js.map +1 -0
  130. package/build-module/dropdown-menu-v2-ariakit/styles.js +136 -0
  131. package/build-module/dropdown-menu-v2-ariakit/styles.js.map +1 -0
  132. package/build-module/dropdown-menu-v2-ariakit/types.js +2 -0
  133. package/build-module/dropdown-menu-v2-ariakit/types.js.map +1 -0
  134. package/build-module/font-size-picker/utils.js +1 -1
  135. package/build-module/font-size-picker/utils.js.map +1 -1
  136. package/build-module/input-control/styles/input-control-styles.js +23 -23
  137. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  138. package/build-module/mobile/global-styles-context/utils.native.js +2 -2
  139. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  140. package/build-module/modal/index.js +47 -18
  141. package/build-module/modal/index.js.map +1 -1
  142. package/build-module/palette-edit/index.js +4 -0
  143. package/build-module/palette-edit/index.js.map +1 -1
  144. package/build-module/popover/index.js +34 -6
  145. package/build-module/popover/index.js.map +1 -1
  146. package/build-module/private-apis.js +18 -2
  147. package/build-module/private-apis.js.map +1 -1
  148. package/build-module/progress-bar/styles.js +5 -5
  149. package/build-module/progress-bar/styles.js.map +1 -1
  150. package/build-module/sandbox/index.js +1 -1
  151. package/build-module/sandbox/index.js.map +1 -1
  152. package/build-module/sandbox/index.native.js +1 -1
  153. package/build-module/sandbox/index.native.js.map +1 -1
  154. package/build-module/select-control/styles/select-control-styles.js +8 -8
  155. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  156. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  157. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  158. package/build-module/tabs/context.js +12 -0
  159. package/build-module/tabs/context.js.map +1 -0
  160. package/build-module/tabs/index.js +142 -0
  161. package/build-module/tabs/index.js.map +1 -0
  162. package/build-module/tabs/styles.js +36 -0
  163. package/build-module/tabs/styles.js.map +1 -0
  164. package/build-module/tabs/tab.js +43 -0
  165. package/build-module/tabs/tab.js.map +1 -0
  166. package/build-module/tabs/tablist.js +41 -0
  167. package/build-module/tabs/tablist.js.map +1 -0
  168. package/build-module/tabs/tabpanel.js +43 -0
  169. package/build-module/tabs/tabpanel.js.map +1 -0
  170. package/build-module/tabs/types.js +2 -0
  171. package/build-module/tabs/types.js.map +1 -0
  172. package/build-module/text/component.js +6 -6
  173. package/build-module/text/component.js.map +1 -1
  174. package/build-module/text/hook.js +11 -19
  175. package/build-module/text/hook.js.map +1 -1
  176. package/build-module/text/index.js.map +1 -1
  177. package/build-module/text/styles.js +7 -7
  178. package/build-module/text/styles.js.map +1 -1
  179. package/build-module/text/types.js.map +1 -1
  180. package/build-module/text/utils.js +17 -10
  181. package/build-module/text/utils.js.map +1 -1
  182. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +1 -0
  183. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  184. package/build-module/toolbar/toolbar/index.js +18 -11
  185. package/build-module/toolbar/toolbar/index.js.map +1 -1
  186. package/build-module/toolbar/toolbar/types.js.map +1 -1
  187. package/build-module/tools-panel/tools-panel-item/hook.js +2 -2
  188. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  189. package/build-module/tools-panel/types.js.map +1 -1
  190. package/build-module/tooltip/index.js +2 -2
  191. package/build-module/tooltip/index.js.map +1 -1
  192. package/build-module/unit-control/utils.js +108 -0
  193. package/build-module/unit-control/utils.js.map +1 -1
  194. package/build-module/utils/unit-values.js +1 -1
  195. package/build-module/utils/unit-values.js.map +1 -1
  196. package/build-style/style-rtl.css +17 -5
  197. package/build-style/style.css +17 -5
  198. package/build-types/alignment-matrix-control/cell.d.ts +1 -1
  199. package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
  200. package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
  201. package/build-types/alignment-matrix-control/stories/index.story.d.ts.map +1 -1
  202. package/build-types/alignment-matrix-control/utils.d.ts +9 -9
  203. package/build-types/alignment-matrix-control/utils.d.ts.map +1 -1
  204. package/build-types/autocomplete/index.d.ts.map +1 -1
  205. package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -1
  206. package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
  207. package/build-types/circular-option-picker/types.d.ts +4 -6
  208. package/build-types/circular-option-picker/types.d.ts.map +1 -1
  209. package/build-types/color-palette/index.d.ts.map +1 -1
  210. package/build-types/color-picker/component.d.ts.map +1 -1
  211. package/build-types/color-picker/picker.d.ts +1 -1
  212. package/build-types/color-picker/picker.d.ts.map +1 -1
  213. package/build-types/color-picker/styles.d.ts.map +1 -1
  214. package/build-types/color-picker/types.d.ts +3 -0
  215. package/build-types/color-picker/types.d.ts.map +1 -1
  216. package/build-types/composite/v2.d.ts +12 -0
  217. package/build-types/composite/v2.d.ts.map +1 -0
  218. package/build-types/confirm-dialog/component.d.ts +70 -29
  219. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  220. package/build-types/confirm-dialog/stories/index.story.d.ts +11 -0
  221. package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -0
  222. package/build-types/confirm-dialog/test/index.d.ts +2 -0
  223. package/build-types/confirm-dialog/test/index.d.ts.map +1 -0
  224. package/build-types/confirm-dialog/types.d.ts +32 -10
  225. package/build-types/confirm-dialog/types.d.ts.map +1 -1
  226. package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
  227. package/build-types/dropdown-menu-v2-ariakit/index.d.ts +11 -0
  228. package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +1 -0
  229. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +16 -0
  230. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +1 -0
  231. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +88 -0
  232. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +1 -0
  233. package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts +2 -0
  234. package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +1 -0
  235. package/build-types/dropdown-menu-v2-ariakit/types.d.ts +174 -0
  236. package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +1 -0
  237. package/build-types/font-size-picker/utils.d.ts.map +1 -1
  238. package/build-types/heading/stories/index.story.d.ts.map +1 -1
  239. package/build-types/modal/index.d.ts.map +1 -1
  240. package/build-types/palette-edit/index.d.ts.map +1 -1
  241. package/build-types/popover/index.d.ts +1 -1
  242. package/build-types/popover/index.d.ts.map +1 -1
  243. package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
  244. package/build-types/private-apis.d.ts.map +1 -1
  245. package/build-types/progress-bar/styles.d.ts.map +1 -1
  246. package/build-types/sandbox/index.d.ts.map +1 -1
  247. package/build-types/tabs/context.d.ts +8 -0
  248. package/build-types/tabs/context.d.ts.map +1 -0
  249. package/build-types/tabs/index.d.ts +13 -0
  250. package/build-types/tabs/index.d.ts.map +1 -0
  251. package/build-types/tabs/stories/index.story.d.ts +20 -0
  252. package/build-types/tabs/stories/index.story.d.ts.map +1 -0
  253. package/build-types/tabs/styles.d.ts +17 -0
  254. package/build-types/tabs/styles.d.ts.map +1 -0
  255. package/build-types/tabs/tab.d.ts +10 -0
  256. package/build-types/tabs/tab.d.ts.map +1 -0
  257. package/build-types/tabs/tablist.d.ts +7 -0
  258. package/build-types/tabs/tablist.d.ts.map +1 -0
  259. package/build-types/tabs/tabpanel.d.ts +7 -0
  260. package/build-types/tabs/tabpanel.d.ts.map +1 -0
  261. package/build-types/tabs/test/index.d.ts +2 -0
  262. package/build-types/tabs/test/index.d.ts.map +1 -0
  263. package/build-types/tabs/types.d.ts +134 -0
  264. package/build-types/tabs/types.d.ts.map +1 -0
  265. package/build-types/text/component.d.ts +4 -2
  266. package/build-types/text/component.d.ts.map +1 -1
  267. package/build-types/text/hook.d.ts +171 -165
  268. package/build-types/text/hook.d.ts.map +1 -1
  269. package/build-types/text/index.d.ts +2 -2
  270. package/build-types/text/index.d.ts.map +1 -1
  271. package/build-types/text/stories/index.story.d.ts +21 -0
  272. package/build-types/text/stories/index.story.d.ts.map +1 -0
  273. package/build-types/text/styles.d.ts +7 -7
  274. package/build-types/text/styles.d.ts.map +1 -1
  275. package/build-types/text/types.d.ts +1 -1
  276. package/build-types/text/types.d.ts.map +1 -1
  277. package/build-types/text/utils.d.ts +56 -61
  278. package/build-types/text/utils.d.ts.map +1 -1
  279. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  280. package/build-types/toolbar/stories/index.story.d.ts +5 -0
  281. package/build-types/toolbar/stories/index.story.d.ts.map +1 -1
  282. package/build-types/toolbar/toolbar/index.d.ts.map +1 -1
  283. package/build-types/toolbar/toolbar/types.d.ts +10 -0
  284. package/build-types/toolbar/toolbar/types.d.ts.map +1 -1
  285. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  286. package/build-types/tools-panel/types.d.ts +2 -0
  287. package/build-types/tools-panel/types.d.ts.map +1 -1
  288. package/build-types/tooltip/index.d.ts.map +1 -1
  289. package/build-types/unit-control/utils.d.ts.map +1 -1
  290. package/package.json +21 -20
  291. package/src/alignment-matrix-control/cell.tsx +6 -2
  292. package/src/alignment-matrix-control/index.tsx +31 -54
  293. package/src/alignment-matrix-control/stories/index.story.tsx +3 -7
  294. package/src/alignment-matrix-control/test/index.tsx +117 -18
  295. package/src/alignment-matrix-control/utils.tsx +33 -9
  296. package/src/autocomplete/index.tsx +136 -77
  297. package/src/button/style.scss +1 -2
  298. package/src/circular-option-picker/circular-option-picker-option.tsx +24 -38
  299. package/src/circular-option-picker/circular-option-picker.tsx +11 -28
  300. package/src/circular-option-picker/types.ts +6 -5
  301. package/src/color-palette/index.tsx +6 -1
  302. package/src/color-picker/component.tsx +25 -3
  303. package/src/color-picker/picker.tsx +96 -2
  304. package/src/color-picker/styles.ts +0 -1
  305. package/src/color-picker/types.ts +3 -0
  306. package/src/composite/v2.ts +22 -0
  307. package/src/confirm-dialog/README.md +1 -1
  308. package/src/confirm-dialog/component.tsx +79 -13
  309. package/src/confirm-dialog/stories/{index.story.js → index.story.tsx} +26 -24
  310. package/src/confirm-dialog/test/{index.js → index.tsx} +3 -3
  311. package/src/confirm-dialog/types.ts +32 -12
  312. package/src/custom-gradient-picker/gradient-bar/control-points.tsx +32 -25
  313. package/src/dimension-control/test/__snapshots__/index.test.js.snap +8 -8
  314. package/src/dropdown-menu-v2-ariakit/README.md +324 -0
  315. package/src/dropdown-menu-v2-ariakit/index.tsx +318 -0
  316. package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +506 -0
  317. package/src/dropdown-menu-v2-ariakit/styles.ts +297 -0
  318. package/src/dropdown-menu-v2-ariakit/test/index.tsx +1139 -0
  319. package/src/dropdown-menu-v2-ariakit/types.ts +186 -0
  320. package/src/font-size-picker/utils.ts +2 -1
  321. package/src/heading/stories/index.story.tsx +2 -4
  322. package/src/input-control/styles/input-control-styles.tsx +2 -2
  323. package/src/mobile/global-styles-context/utils.native.js +2 -2
  324. package/src/modal/index.tsx +58 -22
  325. package/src/modal/test/index.tsx +29 -0
  326. package/src/notice/style.scss +0 -1
  327. package/src/palette-edit/index.tsx +4 -0
  328. package/src/popover/index.tsx +99 -57
  329. package/src/popover/style.scss +9 -0
  330. package/src/private-apis.ts +31 -1
  331. package/src/progress-bar/styles.ts +19 -4
  332. package/src/sandbox/index.native.js +1 -1
  333. package/src/sandbox/index.tsx +3 -1
  334. package/src/select-control/styles/select-control-styles.ts +2 -2
  335. package/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx +1 -1
  336. package/src/tabs/README.md +242 -0
  337. package/src/tabs/context.ts +13 -0
  338. package/src/tabs/index.tsx +167 -0
  339. package/src/tabs/stories/index.story.tsx +352 -0
  340. package/src/tabs/styles.ts +103 -0
  341. package/src/tabs/tab.tsx +39 -0
  342. package/src/tabs/tablist.tsx +40 -0
  343. package/src/tabs/tabpanel.tsx +42 -0
  344. package/src/tabs/test/index.tsx +1133 -0
  345. package/src/tabs/types.ts +142 -0
  346. package/src/text/README.md +2 -2
  347. package/src/text/{component.js → component.tsx} +10 -6
  348. package/src/text/{hook.js → hook.ts} +12 -15
  349. package/src/text/stories/index.story.tsx +80 -0
  350. package/src/text/types.ts +1 -6
  351. package/src/text/{utils.js → utils.ts} +40 -14
  352. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +16 -0
  353. package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +1 -0
  354. package/src/toolbar/stories/index.story.tsx +15 -0
  355. package/src/toolbar/test/index.tsx +8 -0
  356. package/src/toolbar/toolbar/README.md +9 -0
  357. package/src/toolbar/toolbar/index.tsx +21 -12
  358. package/src/toolbar/toolbar/style.scss +9 -0
  359. package/src/toolbar/toolbar/types.ts +10 -0
  360. package/src/tools-panel/tools-panel/README.md +3 -0
  361. package/src/tools-panel/tools-panel-item/hook.ts +4 -6
  362. package/src/tools-panel/types.ts +2 -0
  363. package/src/tooltip/index.tsx +2 -3
  364. package/src/unit-control/utils.ts +124 -0
  365. package/src/utils/unit-values.ts +1 -1
  366. package/tsconfig.tsbuildinfo +1 -1
  367. package/src/text/stories/index.story.js +0 -53
  368. /package/src/text/{index.js → index.ts} +0 -0
  369. /package/src/text/{styles.js → styles.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,47 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 25.11.0 (2023-11-02)
6
+
7
+ ### Enhancements
8
+
9
+ - `InputControl`/`SelectControl`: update `height`/`min-height` to `32px` instead of `30px` to align with modern sizing scale ([#55490](https://github.com/WordPress/gutenberg/pull/55490)).
10
+
11
+ ### Bug Fix
12
+
13
+ - `Autocomplete`: Add `aria-live` announcements for Mac and IOS Voiceover to fix lack of support for `aria-owns` ([#54902](https://github.com/WordPress/gutenberg/pull/54902)).
14
+
15
+ ### Internal
16
+
17
+ - Introduce experimental new version of `DropdownMenu` based on `ariakit` ([#54939](https://github.com/WordPress/gutenberg/pull/54939))
18
+
19
+ ## 25.10.0 (2023-10-18)
20
+
21
+ ### Enhancements
22
+
23
+ - `ProgressBar`: use text color to ensure enough contrast against background ([#55285](https://github.com/WordPress/gutenberg/pull/55285)).
24
+ - `Notice`: Remove margins from `Notice` component ([#54800](https://github.com/WordPress/gutenberg/pull/54800)).
25
+ - Allow using CSS level 4 viewport-relative units ([54415](https://github.com/WordPress/gutenberg/pull/54415))
26
+ - `ToolsPanel`: do not apply the `className` to prop to `ToolsPanelItem` components when rendered as placeholders ([#55207](https://github.com/WordPress/gutenberg/pull/55207)).
27
+ - `GradientPicker`: remove overflow styles and padding from `ColorPicker` popovers ([#55265](https://github.com/WordPress/gutenberg/pull/55265)).
28
+ - `Tabs`: Expose via private APIs ([#55327](https://github.com/WordPress/gutenberg/pull/55327)).
29
+ - `ColorPalette`/`ToggleGroupControl/ToggleGroupControlOptionBase`: add `type="button"` attribute to native `<button>`s ([#55125](https://github.com/WordPress/gutenberg/pull/55125)).
30
+
31
+ ### Bug Fix
32
+
33
+ - Render a "mouse event trap" when using a `ColorPicker` inside a `Popover` to prevent issues when rendering on top of `iframes` ([#55149](https://github.com/WordPress/gutenberg/pull/55149)).
34
+ - `Modal`: fix closing when contained iframe is focused ([#51602](https://github.com/WordPress/gutenberg/pull/51602)).
35
+ - `Autocomplete`: Fix disappearing results issue when using multiple triggers inline ([#55301](https://github.com/WordPress/gutenberg/pull/55301))
36
+
37
+ ### Internal
38
+
39
+ - Update `@ariakit/react` to version `0.3.5` ([#55365](https://github.com/WordPress/gutenberg/pull/55365))
40
+ - `ConfirmDialog`: Migrate to TypeScript. ([#54954](https://github.com/WordPress/gutenberg/pull/54954)).
41
+
42
+ ### New Features
43
+
44
+ - `Toolbar`: add new `variant` prop for 'unstyled' option ([#55139](https://github.com/WordPress/gutenberg/pull/55139)).
45
+
5
46
  ## 25.9.0 (2023-10-05)
6
47
 
7
48
  ### Enhancements
@@ -13,6 +54,7 @@
13
54
  - `InputControl`, `NumberControl`, `UnitControl`, `SelectControl`, `CustomSelectControl`, `TreeSelect`: Add opt-in prop for next 40px default size, superseding the `__next36pxDefaultSize` prop ([#53819](https://github.com/WordPress/gutenberg/pull/53819)).
14
55
  - `Modal`: add a new `size` prop to support preset widths, including a `fill` option to eventually replace the `isFullScreen` prop ([#54471](https://github.com/WordPress/gutenberg/pull/54471)).
15
56
  - Wrapped `TextareaControl` in a `forwardRef` call ([#54975](https://github.com/WordPress/gutenberg/pull/54975)).
57
+ - `Composite`/`AlignmentMatrixControl`/`CircularOptionPicker`: Starts the `Composite` migration from `reakit` to `ariakit` ([#54225](https://github.com/WordPress/gutenberg/pull/54225)).
16
58
 
17
59
  ### Bug Fix
18
60
 
@@ -23,6 +65,7 @@
23
65
  - `Button`: Remove `aria-selected` CSS selector from styling 'active' buttons ([#54931](https://github.com/WordPress/gutenberg/pull/54931)).
24
66
  - `Popover`: Apply the CSS in JS styles properly for components used within popovers. ([#54912](https://github.com/WordPress/gutenberg/pull/54912))
25
67
  - `Button`: Remove hover styles when `aria-disabled` is set to `true` for the secondary variant. ([#54978](https://github.com/WordPress/gutenberg/pull/54978))
68
+ - `Button`: Revert toggled style selector to use a class instead of attributes ([#55065](https://github.com/WordPress/gutenberg/pull/55065)).
26
69
 
27
70
  ### Internal
28
71
 
@@ -34,6 +77,11 @@
34
77
  - `SlotFill`: Migrate to TypeScript and Convert to Functional Component `<Slot bubblesVirtually />`. ([#51350](https://github.com/WordPress/gutenberg/pull/51350)).
35
78
  - `Components`: move `ui/utils` to `utils` and remove `ui/` folder ([#54922](https://github.com/WordPress/gutenberg/pull/54922)).
36
79
  - Ensure `@types/` dependencies used by final type files are included in the main dependency field ([#50231](https://github.com/WordPress/gutenberg/pull/50231)).
80
+ - `Text`: Migrate to TypeScript. ([#54953](https://github.com/WordPress/gutenberg/pull/54953)).
81
+
82
+ ### Experimental
83
+
84
+ - Introduce `Tabs`, an experimental v2 of `TabPanel`: ([#53960](https://github.com/WordPress/gutenberg/pull/53960)).
37
85
 
38
86
  ## 25.8.0 (2023-09-20)
39
87
 
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = Cell;
8
8
  var _react = require("react");
9
- var _composite = require("../composite");
9
+ var _v = require("../composite/v2");
10
10
  var _tooltip = _interopRequireDefault(require("../tooltip"));
11
11
  var _visuallyHidden = require("../visually-hidden");
12
12
  var _utils = require("./utils");
@@ -20,6 +20,7 @@ var _alignmentMatrixControlStyles = require("./styles/alignment-matrix-control-s
20
20
  */
21
21
 
22
22
  function Cell({
23
+ id,
23
24
  isActive = false,
24
25
  value,
25
26
  ...props
@@ -27,10 +28,12 @@ function Cell({
27
28
  const tooltipText = _utils.ALIGNMENT_LABEL[value];
28
29
  return (0, _react.createElement)(_tooltip.default, {
29
30
  text: tooltipText
30
- }, (0, _react.createElement)(_composite.CompositeItem, {
31
- as: _alignmentMatrixControlStyles.Cell,
32
- role: "gridcell",
33
- ...props
31
+ }, (0, _react.createElement)(_v.CompositeItem, {
32
+ id: id,
33
+ render: (0, _react.createElement)(_alignmentMatrixControlStyles.Cell, {
34
+ ...props,
35
+ role: "gridcell"
36
+ })
34
37
  }, (0, _react.createElement)(_visuallyHidden.VisuallyHidden, null, value), (0, _react.createElement)(_alignmentMatrixControlStyles.Point, {
35
38
  isActive: isActive,
36
39
  role: "presentation"
@@ -1 +1 @@
1
- {"version":3,"names":["_composite","require","_tooltip","_interopRequireDefault","_visuallyHidden","_utils","_alignmentMatrixControlStyles","Cell","isActive","value","props","tooltipText","ALIGNMENT_LABEL","_react","createElement","default","text","CompositeItem","as","CellView","role","VisuallyHidden","Point"],"sources":["@wordpress/components/src/alignment-matrix-control/cell.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { CompositeItem } from '../composite';\nimport Tooltip from '../tooltip';\nimport { VisuallyHidden } from '../visually-hidden';\n\n/**\n * Internal dependencies\n */\nimport { ALIGNMENT_LABEL } from './utils';\nimport {\n\tCell as CellView,\n\tPoint,\n} from './styles/alignment-matrix-control-styles';\nimport type { AlignmentMatrixControlCellProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nexport default function Cell( {\n\tisActive = false,\n\tvalue,\n\t...props\n}: WordPressComponentProps< AlignmentMatrixControlCellProps, 'span', false > ) {\n\tconst tooltipText = ALIGNMENT_LABEL[ value ];\n\n\treturn (\n\t\t<Tooltip text={ tooltipText }>\n\t\t\t<CompositeItem as={ CellView } role=\"gridcell\" { ...props }>\n\t\t\t\t{ /* VoiceOver needs a text content to be rendered within grid cell,\n\t\t\totherwise it'll announce the content as \"blank\". So we use a visually\n\t\t\thidden element instead of aria-label. */ }\n\t\t\t\t<VisuallyHidden>{ value }</VisuallyHidden>\n\t\t\t\t<Point isActive={ isActive } role=\"presentation\" />\n\t\t\t</CompositeItem>\n\t\t</Tooltip>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,6BAAA,GAAAL,OAAA;AAXA;AACA;AACA;;AAKA;AACA;AACA;;AASe,SAASM,IAAIA,CAAE;EAC7BC,QAAQ,GAAG,KAAK;EAChBC,KAAK;EACL,GAAGC;AACuE,CAAC,EAAG;EAC9E,MAAMC,WAAW,GAAGC,sBAAe,CAAEH,KAAK,CAAE;EAE5C,OACC,IAAAI,MAAA,CAAAC,aAAA,EAACZ,QAAA,CAAAa,OAAO;IAACC,IAAI,EAAGL;EAAa,GAC5B,IAAAE,MAAA,CAAAC,aAAA,EAACd,UAAA,CAAAiB,aAAa;IAACC,EAAE,EAAGC,kCAAU;IAACC,IAAI,EAAC,UAAU;IAAA,GAAMV;EAAK,GAIxD,IAAAG,MAAA,CAAAC,aAAA,EAACV,eAAA,CAAAiB,cAAc,QAAGZ,KAAuB,CAAC,EAC1C,IAAAI,MAAA,CAAAC,aAAA,EAACR,6BAAA,CAAAgB,KAAK;IAACd,QAAQ,EAAGA,QAAU;IAACY,IAAI,EAAC;EAAc,CAAE,CACpC,CACP,CAAC;AAEZ"}
1
+ {"version":3,"names":["_v","require","_tooltip","_interopRequireDefault","_visuallyHidden","_utils","_alignmentMatrixControlStyles","Cell","id","isActive","value","props","tooltipText","ALIGNMENT_LABEL","_react","createElement","default","text","CompositeItem","render","role","VisuallyHidden","Point"],"sources":["@wordpress/components/src/alignment-matrix-control/cell.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { CompositeItem } from '../composite/v2';\nimport Tooltip from '../tooltip';\nimport { VisuallyHidden } from '../visually-hidden';\n\n/**\n * Internal dependencies\n */\nimport { ALIGNMENT_LABEL } from './utils';\nimport {\n\tCell as CellView,\n\tPoint,\n} from './styles/alignment-matrix-control-styles';\nimport type { AlignmentMatrixControlCellProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nexport default function Cell( {\n\tid,\n\tisActive = false,\n\tvalue,\n\t...props\n}: WordPressComponentProps< AlignmentMatrixControlCellProps, 'span', false > ) {\n\tconst tooltipText = ALIGNMENT_LABEL[ value ];\n\n\treturn (\n\t\t<Tooltip text={ tooltipText }>\n\t\t\t<CompositeItem\n\t\t\t\tid={ id }\n\t\t\t\trender={ <CellView { ...props } role=\"gridcell\" /> }\n\t\t\t>\n\t\t\t\t{ /* VoiceOver needs a text content to be rendered within grid cell,\n\t\t\totherwise it'll announce the content as \"blank\". So we use a visually\n\t\t\thidden element instead of aria-label. */ }\n\t\t\t\t<VisuallyHidden>{ value }</VisuallyHidden>\n\t\t\t\t<Point isActive={ isActive } role=\"presentation\" />\n\t\t\t</CompositeItem>\n\t\t</Tooltip>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,EAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,6BAAA,GAAAL,OAAA;AAXA;AACA;AACA;;AAKA;AACA;AACA;;AASe,SAASM,IAAIA,CAAE;EAC7BC,EAAE;EACFC,QAAQ,GAAG,KAAK;EAChBC,KAAK;EACL,GAAGC;AACuE,CAAC,EAAG;EAC9E,MAAMC,WAAW,GAAGC,sBAAe,CAAEH,KAAK,CAAE;EAE5C,OACC,IAAAI,MAAA,CAAAC,aAAA,EAACb,QAAA,CAAAc,OAAO;IAACC,IAAI,EAAGL;EAAa,GAC5B,IAAAE,MAAA,CAAAC,aAAA,EAACf,EAAA,CAAAkB,aAAa;IACbV,EAAE,EAAGA,EAAI;IACTW,MAAM,EAAG,IAAAL,MAAA,CAAAC,aAAA,EAACT,6BAAA,CAAAC,IAAQ;MAAA,GAAMI,KAAK;MAAGS,IAAI,EAAC;IAAU,CAAE;EAAG,GAKpD,IAAAN,MAAA,CAAAC,aAAA,EAACX,eAAA,CAAAiB,cAAc,QAAGX,KAAuB,CAAC,EAC1C,IAAAI,MAAA,CAAAC,aAAA,EAACT,6BAAA,CAAAgB,KAAK;IAACb,QAAQ,EAAGA,QAAU;IAACW,IAAI,EAAC;EAAc,CAAE,CACpC,CACP,CAAC;AAEZ"}
@@ -10,9 +10,8 @@ var _react = require("react");
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _i18n = require("@wordpress/i18n");
12
12
  var _compose = require("@wordpress/compose");
13
- var _element = require("@wordpress/element");
14
13
  var _cell = _interopRequireDefault(require("./cell"));
15
- var _composite = require("../composite");
14
+ var _v = require("../composite/v2");
16
15
  var _alignmentMatrixControlStyles = require("./styles/alignment-matrix-control-styles");
17
16
  var _icon = _interopRequireDefault(require("./icon"));
18
17
  var _utils = require("./utils");
@@ -28,12 +27,6 @@ var _utils = require("./utils");
28
27
  * Internal dependencies
29
28
  */
30
29
 
31
- const noop = () => {};
32
- function useBaseId(id) {
33
- const instanceId = (0, _compose.useInstanceId)(AlignmentMatrixControl, 'alignment-matrix-control');
34
- return id || instanceId;
35
- }
36
-
37
30
  /**
38
31
  *
39
32
  * AlignmentMatrixControl components enable adjustments to horizontal and vertical alignments for UI.
@@ -60,54 +53,45 @@ function AlignmentMatrixControl({
60
53
  label = (0, _i18n.__)('Alignment Matrix Control'),
61
54
  defaultValue = 'center center',
62
55
  value,
63
- onChange = noop,
56
+ onChange,
64
57
  width = 92,
65
58
  ...props
66
59
  }) {
67
- const [immutableDefaultValue] = (0, _element.useState)(value !== null && value !== void 0 ? value : defaultValue);
68
- const baseId = useBaseId(id);
69
- const initialCurrentId = (0, _utils.getItemId)(baseId, immutableDefaultValue);
70
- const composite = (0, _composite.useCompositeState)({
71
- baseId,
72
- currentId: initialCurrentId,
60
+ const baseId = (0, _compose.useInstanceId)(AlignmentMatrixControl, 'alignment-matrix-control', id);
61
+ const compositeStore = (0, _v.useCompositeStore)({
62
+ defaultActiveId: (0, _utils.getItemId)(baseId, defaultValue),
63
+ activeId: (0, _utils.getItemId)(baseId, value),
64
+ setActiveId: nextActiveId => {
65
+ const nextValue = (0, _utils.getItemValue)(baseId, nextActiveId);
66
+ if (nextValue) onChange?.(nextValue);
67
+ },
73
68
  rtl: (0, _i18n.isRTL)()
74
69
  });
75
- const handleOnChange = nextValue => {
76
- onChange(nextValue);
77
- };
78
- const {
79
- setCurrentId
80
- } = composite;
81
- (0, _element.useEffect)(() => {
82
- if (typeof value !== 'undefined') {
83
- setCurrentId((0, _utils.getItemId)(baseId, value));
84
- }
85
- }, [value, setCurrentId, baseId]);
70
+ const activeId = compositeStore.useState('activeId');
86
71
  const classes = (0, _classnames.default)('component-alignment-matrix-control', className);
87
- return (0, _react.createElement)(_composite.Composite, {
88
- ...props,
89
- ...composite,
90
- "aria-label": label,
91
- as: _alignmentMatrixControlStyles.Root,
92
- className: classes,
93
- role: "grid",
94
- size: width
95
- }, _utils.GRID.map((cells, index) => (0, _react.createElement)(_composite.CompositeGroup, {
96
- ...composite,
97
- as: _alignmentMatrixControlStyles.Row,
98
- role: "row",
72
+ return (0, _react.createElement)(_v.Composite, {
73
+ store: compositeStore,
74
+ render: (0, _react.createElement)(_alignmentMatrixControlStyles.Root, {
75
+ ...props,
76
+ "aria-label": label,
77
+ className: classes,
78
+ id: baseId,
79
+ role: "grid",
80
+ size: width
81
+ })
82
+ }, _utils.GRID.map((cells, index) => (0, _react.createElement)(_v.CompositeRow, {
83
+ render: (0, _react.createElement)(_alignmentMatrixControlStyles.Row, {
84
+ role: "row"
85
+ }),
99
86
  key: index
100
87
  }, cells.map(cell => {
101
88
  const cellId = (0, _utils.getItemId)(baseId, cell);
102
- const isActive = composite.currentId === cellId;
89
+ const isActive = cellId === activeId;
103
90
  return (0, _react.createElement)(_cell.default, {
104
- ...composite,
105
91
  id: cellId,
106
92
  isActive: isActive,
107
93
  key: cell,
108
- value: cell,
109
- onFocus: () => handleOnChange(cell),
110
- tabIndex: isActive ? 0 : -1
94
+ value: cell
111
95
  });
112
96
  }))));
113
97
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_compose","_element","_cell","_composite","_alignmentMatrixControlStyles","_icon","_utils","noop","useBaseId","id","instanceId","useInstanceId","AlignmentMatrixControl","className","label","__","defaultValue","value","onChange","width","props","immutableDefaultValue","useState","baseId","initialCurrentId","getItemId","composite","useCompositeState","currentId","rtl","isRTL","handleOnChange","nextValue","setCurrentId","useEffect","classes","classnames","_react","createElement","Composite","as","Root","role","size","GRID","map","cells","index","CompositeGroup","Row","key","cell","cellId","isActive","default","onFocus","tabIndex","Icon","AlignmentMatrixControlIcon","_default","exports"],"sources":["@wordpress/components/src/alignment-matrix-control/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Cell from './cell';\nimport { Composite, CompositeGroup, useCompositeState } from '../composite';\nimport { Root, Row } from './styles/alignment-matrix-control-styles';\nimport AlignmentMatrixControlIcon from './icon';\nimport { GRID, getItemId } from './utils';\nimport type { WordPressComponentProps } from '../context';\nimport type {\n\tAlignmentMatrixControlProps,\n\tAlignmentMatrixControlValue,\n} from './types';\n\nconst noop = () => {};\n\nfunction useBaseId( id?: string ) {\n\tconst instanceId = useInstanceId(\n\t\tAlignmentMatrixControl,\n\t\t'alignment-matrix-control'\n\t);\n\n\treturn id || instanceId;\n}\n\n/**\n *\n * AlignmentMatrixControl components enable adjustments to horizontal and vertical alignments for UI.\n *\n * ```jsx\n * import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * \tconst [ alignment, setAlignment ] = useState( 'center center' );\n *\n * \treturn (\n * \t\t<AlignmentMatrixControl\n * \t\t\tvalue={ alignment }\n * \t\t\tonChange={ setAlignment }\n * \t\t/>\n * \t);\n * };\n * ```\n */\nexport function AlignmentMatrixControl( {\n\tclassName,\n\tid,\n\tlabel = __( 'Alignment Matrix Control' ),\n\tdefaultValue = 'center center',\n\tvalue,\n\tonChange = noop,\n\twidth = 92,\n\t...props\n}: WordPressComponentProps< AlignmentMatrixControlProps, 'div', false > ) {\n\tconst [ immutableDefaultValue ] = useState( value ?? defaultValue );\n\tconst baseId = useBaseId( id );\n\tconst initialCurrentId = getItemId( baseId, immutableDefaultValue );\n\n\tconst composite = useCompositeState( {\n\t\tbaseId,\n\t\tcurrentId: initialCurrentId,\n\t\trtl: isRTL(),\n\t} );\n\n\tconst handleOnChange = ( nextValue: AlignmentMatrixControlValue ) => {\n\t\tonChange( nextValue );\n\t};\n\n\tconst { setCurrentId } = composite;\n\n\tuseEffect( () => {\n\t\tif ( typeof value !== 'undefined' ) {\n\t\t\tsetCurrentId( getItemId( baseId, value ) );\n\t\t}\n\t}, [ value, setCurrentId, baseId ] );\n\n\tconst classes = classnames(\n\t\t'component-alignment-matrix-control',\n\t\tclassName\n\t);\n\n\treturn (\n\t\t<Composite\n\t\t\t{ ...props }\n\t\t\t{ ...composite }\n\t\t\taria-label={ label }\n\t\t\tas={ Root }\n\t\t\tclassName={ classes }\n\t\t\trole=\"grid\"\n\t\t\tsize={ width }\n\t\t>\n\t\t\t{ GRID.map( ( cells, index ) => (\n\t\t\t\t<CompositeGroup\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\tas={ Row }\n\t\t\t\t\trole=\"row\"\n\t\t\t\t\tkey={ index }\n\t\t\t\t>\n\t\t\t\t\t{ cells.map( ( cell ) => {\n\t\t\t\t\t\tconst cellId = getItemId( baseId, cell );\n\t\t\t\t\t\tconst isActive = composite.currentId === cellId;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Cell\n\t\t\t\t\t\t\t\t{ ...composite }\n\t\t\t\t\t\t\t\tid={ cellId }\n\t\t\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\t\t\tkey={ cell }\n\t\t\t\t\t\t\t\tvalue={ cell }\n\t\t\t\t\t\t\t\tonFocus={ () => handleOnChange( cell ) }\n\t\t\t\t\t\t\t\ttabIndex={ isActive ? 0 : -1 }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</CompositeGroup>\n\t\t\t) ) }\n\t\t</Composite>\n\t);\n}\n\nAlignmentMatrixControl.Icon = AlignmentMatrixControlIcon;\n\nexport default AlignmentMatrixControl;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,6BAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAYA,MAAMS,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,SAASC,SAASA,CAAEC,EAAW,EAAG;EACjC,MAAMC,UAAU,GAAG,IAAAC,sBAAa,EAC/BC,sBAAsB,EACtB,0BACD,CAAC;EAED,OAAOH,EAAE,IAAIC,UAAU;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,sBAAsBA,CAAE;EACvCC,SAAS;EACTJ,EAAE;EACFK,KAAK,GAAG,IAAAC,QAAE,EAAE,0BAA2B,CAAC;EACxCC,YAAY,GAAG,eAAe;EAC9BC,KAAK;EACLC,QAAQ,GAAGX,IAAI;EACfY,KAAK,GAAG,EAAE;EACV,GAAGC;AACkE,CAAC,EAAG;EACzE,MAAM,CAAEC,qBAAqB,CAAE,GAAG,IAAAC,iBAAQ,EAAEL,KAAK,aAALA,KAAK,cAALA,KAAK,GAAID,YAAa,CAAC;EACnE,MAAMO,MAAM,GAAGf,SAAS,CAAEC,EAAG,CAAC;EAC9B,MAAMe,gBAAgB,GAAG,IAAAC,gBAAS,EAAEF,MAAM,EAAEF,qBAAsB,CAAC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CAAAC,aAAA,EAACpC,KAAA,CAAAoD,OAAI;MAAA,GACC5B,SAAS;MACdjB,EAAE,EAAG2C,MAAQ;MACbC,QAAQ,EAAGA,QAAU;MACrBH,GAAG,EAAGC,IAAM;MACZlC,KAAK,EAAGkC,IAAM;MACdI,OAAO,EAAGA,CAAA,KAAMxB,cAAc,CAAEoB,IAAK,CAAG;MACxCK,QAAQ,EAAGH,QAAQ,GAAG,CAAC,GAAG,CAAC;IAAG,CAC9B,CAAC;EAEJ,CAAE,CACa,CACf,CACQ,CAAC;AAEd;AAEAzC,sBAAsB,CAAC6C,IAAI,GAAGC,aAA0B;AAAC,IAAAC,QAAA,GAE1C/C,sBAAsB;AAAAgD,OAAA,CAAAN,OAAA,GAAAK,QAAA"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_compose","_cell","_v","_alignmentMatrixControlStyles","_icon","_utils","AlignmentMatrixControl","className","id","label","__","defaultValue","value","onChange","width","props","baseId","useInstanceId","compositeStore","useCompositeStore","defaultActiveId","getItemId","activeId","setActiveId","nextActiveId","nextValue","getItemValue","rtl","isRTL","useState","classes","classnames","_react","createElement","Composite","store","render","Root","role","size","GRID","map","cells","index","CompositeRow","Row","key","cell","cellId","isActive","default","Icon","AlignmentMatrixControlIcon","_default","exports"],"sources":["@wordpress/components/src/alignment-matrix-control/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Cell from './cell';\nimport { Composite, CompositeRow, useCompositeStore } from '../composite/v2';\nimport { Root, Row } from './styles/alignment-matrix-control-styles';\nimport AlignmentMatrixControlIcon from './icon';\nimport { GRID, getItemId, getItemValue } from './utils';\nimport type { WordPressComponentProps } from '../context';\nimport type { AlignmentMatrixControlProps } from './types';\n\n/**\n *\n * AlignmentMatrixControl components enable adjustments to horizontal and vertical alignments for UI.\n *\n * ```jsx\n * import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * \tconst [ alignment, setAlignment ] = useState( 'center center' );\n *\n * \treturn (\n * \t\t<AlignmentMatrixControl\n * \t\t\tvalue={ alignment }\n * \t\t\tonChange={ setAlignment }\n * \t\t/>\n * \t);\n * };\n * ```\n */\nexport function AlignmentMatrixControl( {\n\tclassName,\n\tid,\n\tlabel = __( 'Alignment Matrix Control' ),\n\tdefaultValue = 'center center',\n\tvalue,\n\tonChange,\n\twidth = 92,\n\t...props\n}: WordPressComponentProps< AlignmentMatrixControlProps, 'div', false > ) {\n\tconst baseId = useInstanceId(\n\t\tAlignmentMatrixControl,\n\t\t'alignment-matrix-control',\n\t\tid\n\t);\n\n\tconst compositeStore = useCompositeStore( {\n\t\tdefaultActiveId: getItemId( baseId, defaultValue ),\n\t\tactiveId: getItemId( baseId, value ),\n\t\tsetActiveId: ( nextActiveId ) => {\n\t\t\tconst nextValue = getItemValue( baseId, nextActiveId );\n\t\t\tif ( nextValue ) onChange?.( nextValue );\n\t\t},\n\t\trtl: isRTL(),\n\t} );\n\n\tconst activeId = compositeStore.useState( 'activeId' );\n\n\tconst classes = classnames(\n\t\t'component-alignment-matrix-control',\n\t\tclassName\n\t);\n\n\treturn (\n\t\t<Composite\n\t\t\tstore={ compositeStore }\n\t\t\trender={\n\t\t\t\t<Root\n\t\t\t\t\t{ ...props }\n\t\t\t\t\taria-label={ label }\n\t\t\t\t\tclassName={ classes }\n\t\t\t\t\tid={ baseId }\n\t\t\t\t\trole=\"grid\"\n\t\t\t\t\tsize={ width }\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t{ GRID.map( ( cells, index ) => (\n\t\t\t\t<CompositeRow render={ <Row role=\"row\" /> } key={ index }>\n\t\t\t\t\t{ cells.map( ( cell ) => {\n\t\t\t\t\t\tconst cellId = getItemId( baseId, cell );\n\t\t\t\t\t\tconst isActive = cellId === activeId;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Cell\n\t\t\t\t\t\t\t\tid={ cellId }\n\t\t\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\t\t\tkey={ cell }\n\t\t\t\t\t\t\t\tvalue={ cell }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</CompositeRow>\n\t\t\t) ) }\n\t\t</Composite>\n\t);\n}\n\nAlignmentMatrixControl.Icon = AlignmentMatrixControlIcon;\n\nexport default AlignmentMatrixControl;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,EAAA,GAAAJ,OAAA;AACA,IAAAK,6BAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,sBAAsBA,CAAE;EACvCC,SAAS;EACTC,EAAE;EACFC,KAAK,GAAG,IAAAC,QAAE,EAAE,0BAA2B,CAAC;EACxCC,YAAY,GAAG,eAAe;EAC9BC,KAAK;EACLC,QAAQ;EACRC,KAAK,GAAG,EAAE;EACV,GAAGC;AACkE,CAAC,EAAG;EACzE,MAAMC,MAAM,GAAG,IAAAC,sBAAa,EAC3BX,sBAAsB,EACtB,0BAA0B,EAC1BE,EACD,CAAC;EAED,MAAMU,cAAc,GAAG,IAAAC,oBAAiB,EAAE;IACzCC,eAAe,EAAE,IAAAC,gBAAS,E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,IAAAU,MAAA,CAAAC,aAAA,EAAChC,KAAA,CAAAiD,OAAI;MACJ1C,EAAE,EAAGwC,MAAQ;MACbC,QAAQ,EAAGA,QAAU;MACrBH,GAAG,EAAGC,IAAM;MACZnC,KAAK,EAAGmC;IAAM,CACd,CAAC;EAEJ,CAAE,CACW,CACb,CACQ,CAAC;AAEd;AAEAzC,sBAAsB,CAAC6C,IAAI,GAAGC,aAA0B;AAAC,IAAAC,QAAA,GAE1C/C,sBAAsB;AAAAgD,OAAA,CAAAJ,OAAA,GAAAG,QAAA"}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.GRID = exports.ALIGNMENT_LABEL = exports.ALIGNMENTS = void 0;
7
7
  exports.getAlignmentIndex = getAlignmentIndex;
8
8
  exports.getItemId = getItemId;
9
- exports.transformValue = transformValue;
9
+ exports.getItemValue = getItemValue;
10
10
  var _i18n = require("@wordpress/i18n");
11
11
  /**
12
12
  * WordPress dependencies
@@ -34,16 +34,21 @@ exports.ALIGNMENT_LABEL = ALIGNMENT_LABEL;
34
34
  const ALIGNMENTS = GRID.flat();
35
35
 
36
36
  /**
37
- * Parses and transforms an incoming value to better match the alignment values
37
+ * Normalizes and transforms an incoming value to better match the alignment values
38
38
  *
39
39
  * @param value An alignment value to parse.
40
40
  *
41
41
  * @return The parsed value.
42
42
  */
43
43
  exports.ALIGNMENTS = ALIGNMENTS;
44
- function transformValue(value) {
45
- const nextValue = value === 'center' ? 'center center' : value;
46
- return nextValue.replace('-', ' ');
44
+ function normalize(value) {
45
+ const normalized = value === 'center' ? 'center center' : value;
46
+
47
+ // Strictly speaking, this could be `string | null | undefined`,
48
+ // but will be validated shortly, so we're typecasting to an
49
+ // `AlignmentMatrixControlValue` to keep TypeScript happy.
50
+ const transformed = normalized?.replace('-', ' ');
51
+ return ALIGNMENTS.includes(transformed) ? transformed : undefined;
47
52
  }
48
53
 
49
54
  /**
@@ -55,8 +60,22 @@ function transformValue(value) {
55
60
  * @return The item id.
56
61
  */
57
62
  function getItemId(prefixId, value) {
58
- const valueId = transformValue(value).replace(' ', '-');
59
- return `${prefixId}-${valueId}`;
63
+ const normalized = normalize(value);
64
+ if (!normalized) return;
65
+ const id = normalized.replace(' ', '-');
66
+ return `${prefixId}-${id}`;
67
+ }
68
+
69
+ /**
70
+ * Extracts an item value from its ID
71
+ *
72
+ * @param prefixId An ID prefix to remove
73
+ * @param id An item ID
74
+ * @return The item value
75
+ */
76
+ function getItemValue(prefixId, id) {
77
+ const value = id?.replace(prefixId + '-', '');
78
+ return normalize(value);
60
79
  }
61
80
 
62
81
  /**
@@ -67,8 +86,9 @@ function getItemId(prefixId, value) {
67
86
  * @return The index of a matching alignment.
68
87
  */
69
88
  function getAlignmentIndex(alignment = 'center') {
70
- const item = transformValue(alignment);
71
- const index = ALIGNMENTS.indexOf(item);
89
+ const normalized = normalize(alignment);
90
+ if (!normalized) return undefined;
91
+ const index = ALIGNMENTS.indexOf(normalized);
72
92
  return index > -1 ? index : undefined;
73
93
  }
74
94
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","GRID","exports","ALIGNMENT_LABEL","__","center","ALIGNMENTS","flat","transformValue","value","nextValue","replace","getItemId","prefixId","valueId","getAlignmentIndex","alignment","item","index","indexOf","undefined"],"sources":["@wordpress/components/src/alignment-matrix-control/utils.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n/**\n * Internal dependencies\n */\nimport type { AlignmentMatrixControlValue } from './types';\n\nexport const GRID: AlignmentMatrixControlValue[][] = [\n\t[ 'top left', 'top center', 'top right' ],\n\t[ 'center left', 'center center', 'center right' ],\n\t[ 'bottom left', 'bottom center', 'bottom right' ],\n];\n\n// Stored as map as i18n __() only accepts strings (not variables)\nexport const ALIGNMENT_LABEL: Record< AlignmentMatrixControlValue, string > = {\n\t'top left': __( 'Top Left' ),\n\t'top center': __( 'Top Center' ),\n\t'top right': __( 'Top Right' ),\n\t'center left': __( 'Center Left' ),\n\t'center center': __( 'Center' ),\n\tcenter: __( 'Center' ),\n\t'center right': __( 'Center Right' ),\n\t'bottom left': __( 'Bottom Left' ),\n\t'bottom center': __( 'Bottom Center' ),\n\t'bottom right': __( 'Bottom Right' ),\n};\n\n// Transforms GRID into a flat Array of values.\nexport const ALIGNMENTS = GRID.flat();\n\n/**\n * Parses and transforms an incoming value to better match the alignment values\n *\n * @param value An alignment value to parse.\n *\n * @return The parsed value.\n */\nexport function transformValue( value: AlignmentMatrixControlValue ) {\n\tconst nextValue = value === 'center' ? 'center center' : value;\n\n\treturn nextValue.replace( '-', ' ' ) as AlignmentMatrixControlValue;\n}\n\n/**\n * Creates an item ID based on a prefix ID and an alignment value.\n *\n * @param prefixId An ID to prefix.\n * @param value An alignment value.\n *\n * @return The item id.\n */\nexport function getItemId(\n\tprefixId: string,\n\tvalue: AlignmentMatrixControlValue\n) {\n\tconst valueId = transformValue( value ).replace( ' ', '-' );\n\n\treturn `${ prefixId }-${ valueId }`;\n}\n\n/**\n * Retrieves the alignment index from a value.\n *\n * @param alignment Value to check.\n *\n * @return The index of a matching alignment.\n */\nexport function getAlignmentIndex(\n\talignment: AlignmentMatrixControlValue = 'center'\n) {\n\tconst item = transformValue( alignment );\n\tconst index = ALIGNMENTS.indexOf( item );\n\n\treturn index > -1 ? index : undefined;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAOO,MAAMC,IAAqC,GAAG,CACpD,CAAE,UAAU,EAAE,YAAY,EAAE,WAAW,CAAE,EACzC,CAAE,aAAa,EAAE,eAAe,EAAE,cAAc,CAAE,EAClD,CAAE,aAAa,EAAE,eAAe,EAAE,cAAc,CAAE,CAClD;;AAED;AAAAC,OAAA,CAAAD,IAAA,GAAAA,IAAA;AACO,MAAME,eAA8D,GAAG;EAC7E,UAAU,EAAE,IAAAC,QAAE,EAAE,UAAW,CAAC;EAC5B,YAAY,EAAE,IA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C;EAExC,OAAOC,KAAK,GAAG,CAAC,CAAC,GAAGA,KAAK,GAAGE,SAAS;AACtC"}
1
+ {"version":3,"names":["_i18n","require","GRID","exports","ALIGNMENT_LABEL","__","center","ALIGNMENTS","flat","normalize","value","normalized","transformed","replace","includes","undefined","getItemId","prefixId","id","getItemValue","getAlignmentIndex","alignment","index","indexOf"],"sources":["@wordpress/components/src/alignment-matrix-control/utils.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { AlignmentMatrixControlValue } from './types';\n\nexport const GRID: AlignmentMatrixControlValue[][] = [\n\t[ 'top left', 'top center', 'top right' ],\n\t[ 'center left', 'center center', 'center right' ],\n\t[ 'bottom left', 'bottom center', 'bottom right' ],\n];\n\n// Stored as map as i18n __() only accepts strings (not variables)\nexport const ALIGNMENT_LABEL: Record< AlignmentMatrixControlValue, string > = {\n\t'top left': __( 'Top Left' ),\n\t'top center': __( 'Top Center' ),\n\t'top right': __( 'Top Right' ),\n\t'center left': __( 'Center Left' ),\n\t'center center': __( 'Center' ),\n\tcenter: __( 'Center' ),\n\t'center right': __( 'Center Right' ),\n\t'bottom left': __( 'Bottom Left' ),\n\t'bottom center': __( 'Bottom Center' ),\n\t'bottom right': __( 'Bottom Right' ),\n};\n\n// Transforms GRID into a flat Array of values.\nexport const ALIGNMENTS = GRID.flat();\n\n/**\n * Normalizes and transforms an incoming value to better match the alignment values\n *\n * @param value An alignment value to parse.\n *\n * @return The parsed value.\n */\nfunction normalize( value?: string | null ) {\n\tconst normalized = value === 'center' ? 'center center' : value;\n\n\t// Strictly speaking, this could be `string | null | undefined`,\n\t// but will be validated shortly, so we're typecasting to an\n\t// `AlignmentMatrixControlValue` to keep TypeScript happy.\n\tconst transformed = normalized?.replace(\n\t\t'-',\n\t\t' '\n\t) as AlignmentMatrixControlValue;\n\n\treturn ALIGNMENTS.includes( transformed ) ? transformed : undefined;\n}\n\n/**\n * Creates an item ID based on a prefix ID and an alignment value.\n *\n * @param prefixId An ID to prefix.\n * @param value An alignment value.\n *\n * @return The item id.\n */\nexport function getItemId(\n\tprefixId: string,\n\tvalue?: AlignmentMatrixControlValue\n) {\n\tconst normalized = normalize( value );\n\tif ( ! normalized ) return;\n\n\tconst id = normalized.replace( ' ', '-' );\n\treturn `${ prefixId }-${ id }`;\n}\n\n/**\n * Extracts an item value from its ID\n *\n * @param prefixId An ID prefix to remove\n * @param id An item ID\n * @return The item value\n */\nexport function getItemValue( prefixId: string, id?: string | null ) {\n\tconst value = id?.replace( prefixId + '-', '' );\n\treturn normalize( value );\n}\n\n/**\n * Retrieves the alignment index from a value.\n *\n * @param alignment Value to check.\n *\n * @return The index of a matching alignment.\n */\nexport function getAlignmentIndex(\n\talignment: AlignmentMatrixControlValue = 'center'\n) {\n\tconst normalized = normalize( alignment );\n\tif ( ! normalized ) return undefined;\n\n\tconst index = ALIGNMENTS.indexOf( normalized );\n\treturn index > -1 ? index : undefined;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAQO,MAAMC,IAAqC,GAAG,CACpD,CAAE,UAAU,EAAE,YAAY,EAAE,WAAW,CAAE,EACzC,CAAE,aAAa,EAAE,eAAe,EAAE,cAAc,CAAE,EAClD,CAAE,aAAa,EAAE,eAAe,EAAE,cAAc,CAAE,CAClD;;AAED;AAAAC,OAAA,CAAAD,IAAA,GAAAA,IAAA;AACO,MAAME,eAA8D,GAAG;EAC7E,UAAU,EAAE,IAAAC,QAAE,EAAE,UAAW,CAAC;EAC5B,YAAY,EAAE,IAAAA,QAAE,EAAE,YAAa,CAAC;EAChC,WAAW,EAAE,IAAAA,QAAE,EAAE,WAAY,CAAC;EAC9B,aAAa,EAAE,IAAAA,QAAE,EAAE,aAAc,CAAC;EAClC,eAAe,EAAE,IAAAA,QAAE,EAAE,QAAS,CAAC;EAC/BC,MAAM,EAAE,IAAAD,QAAE,EAAE,QAAS,C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AACA;AACO,SAASU,iBAAiBA,CAChCC,SAAsC,GAAG,QAAQ,EAChD;EACD,MAAMV,UAAU,GAAGF,SAAS,CAAEY,SAAU,CAAC;EACzC,IAAK,CAAEV,UAAU,EAAG,OAAOI,SAAS;EAEpC,MAAMO,KAAK,GAAGf,UAAU,CAACgB,OAAO,CAAEZ,UAAW,CAAC;EAC9C,OAAOW,KAAK,GAAG,CAAC,CAAC,GAAGA,KAAK,GAAGP,SAAS;AACtC"}
@@ -12,6 +12,8 @@ var _removeAccents = _interopRequireDefault(require("remove-accents"));
12
12
  var _element = require("@wordpress/element");
13
13
  var _compose = require("@wordpress/compose");
14
14
  var _richText = require("@wordpress/rich-text");
15
+ var _a11y = require("@wordpress/a11y");
16
+ var _keycodes = require("@wordpress/keycodes");
15
17
  var _autocompleterUi = require("./autocompleter-ui");
16
18
  var _strings = require("../utils/strings");
17
19
  /**
@@ -26,6 +28,33 @@ var _strings = require("../utils/strings");
26
28
  * Internal dependencies
27
29
  */
28
30
 
31
+ const getNodeText = node => {
32
+ if (node === null) {
33
+ return '';
34
+ }
35
+ switch (typeof node) {
36
+ case 'string':
37
+ case 'number':
38
+ return node.toString();
39
+ break;
40
+ case 'boolean':
41
+ return '';
42
+ break;
43
+ case 'object':
44
+ {
45
+ if (node instanceof Array) {
46
+ return node.map(getNodeText).join('');
47
+ }
48
+ if ('props' in node) {
49
+ return getNodeText(node.props.children);
50
+ }
51
+ break;
52
+ }
53
+ default:
54
+ return '';
55
+ }
56
+ return '';
57
+ };
29
58
  const EMPTY_FILTERED_OPTIONS = [];
30
59
  function useAutocomplete({
31
60
  record,
@@ -118,11 +147,24 @@ function useAutocomplete({
118
147
  }
119
148
  switch (event.key) {
120
149
  case 'ArrowUp':
121
- setSelectedIndex((selectedIndex === 0 ? filteredOptions.length : selectedIndex) - 1);
122
- break;
150
+ {
151
+ const newIndex = (selectedIndex === 0 ? filteredOptions.length : selectedIndex) - 1;
152
+ setSelectedIndex(newIndex);
153
+ // See the related PR as to why this is necessary: https://github.com/WordPress/gutenberg/pull/54902.
154
+ if ((0, _keycodes.isAppleOS)()) {
155
+ (0, _a11y.speak)(getNodeText(filteredOptions[newIndex].label), 'assertive');
156
+ }
157
+ break;
158
+ }
123
159
  case 'ArrowDown':
124
- setSelectedIndex((selectedIndex + 1) % filteredOptions.length);
125
- break;
160
+ {
161
+ const newIndex = (selectedIndex + 1) % filteredOptions.length;
162
+ setSelectedIndex(newIndex);
163
+ if ((0, _keycodes.isAppleOS)()) {
164
+ (0, _a11y.speak)(getNodeText(filteredOptions[newIndex].label), 'assertive');
165
+ }
166
+ break;
167
+ }
126
168
  case 'Escape':
127
169
  setAutocompleter(null);
128
170
  setAutocompleterUI(null);
@@ -158,58 +200,68 @@ function useAutocomplete({
158
200
  if (autocompleter) reset();
159
201
  return;
160
202
  }
161
- const completer = completers?.find(({
162
- triggerPrefix,
163
- allowContext
164
- }) => {
165
- const index = textContent.lastIndexOf(triggerPrefix);
166
- if (index === -1) {
167
- return false;
168
- }
169
- const textWithoutTrigger = textContent.slice(index + triggerPrefix.length);
170
- const tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.
171
- // This is a final barrier to prevent the effect from completing with
172
- // an extremely long string, which causes the editor to slow-down
173
- // significantly. This could happen, for example, if `matchingWhileBackspacing`
174
- // is true and one of the "words" end up being too long. If that's the case,
175
- // it will be caught by this guard.
176
- if (tooDistantFromTrigger) return false;
177
- const mismatch = filteredOptions.length === 0;
178
- const wordsFromTrigger = textWithoutTrigger.split(/\s/);
179
- // We need to allow the effect to run when not backspacing and if there
180
- // was a mismatch. i.e when typing a trigger + the match string or when
181
- // clicking in an existing trigger word on the page. We do that if we
182
- // detect that we have one word from trigger in the current textual context.
183
- //
184
- // Ex.: "Some text @a" <-- "@a" will be detected as the trigger word and
185
- // allow the effect to run. It will run until there's a mismatch.
186
- const hasOneTriggerWord = wordsFromTrigger.length === 1;
187
- // This is used to allow the effect to run when backspacing and if
188
- // "touching" a word that "belongs" to a trigger. We consider a "trigger
189
- // word" any word up to the limit of 3 from the trigger character.
190
- // Anything beyond that is ignored if there's a mismatch. This allows
191
- // us to "escape" a mismatch when backspacing, but still imposing some
192
- // sane limits.
193
- //
194
- // Ex: "Some text @marcelo sekkkk" <--- "kkkk" caused a mismatch, but
195
- // if the user presses backspace here, it will show the completion popup again.
196
- const matchingWhileBackspacing = backspacing.current && textWithoutTrigger.split(/\s/).length <= 3;
197
- if (mismatch && !(matchingWhileBackspacing || hasOneTriggerWord)) {
198
- return false;
199
- }
200
- const textAfterSelection = (0, _richText.getTextContent)((0, _richText.slice)(record, undefined, (0, _richText.getTextContent)(record).length));
201
- if (allowContext && !allowContext(textContent.slice(0, index), textAfterSelection)) {
202
- return false;
203
- }
204
- if (/^\s/.test(textWithoutTrigger) || /\s\s+$/.test(textWithoutTrigger)) {
205
- return false;
206
- }
207
- return /[\u0000-\uFFFF]*$/.test(textWithoutTrigger);
208
- });
203
+
204
+ // Find the completer with the highest triggerPrefix index in the
205
+ // textContent.
206
+ const completer = completers.reduce((lastTrigger, currentCompleter) => {
207
+ const triggerIndex = textContent.lastIndexOf(currentCompleter.triggerPrefix);
208
+ const lastTriggerIndex = lastTrigger !== null ? textContent.lastIndexOf(lastTrigger.triggerPrefix) : -1;
209
+ return triggerIndex > lastTriggerIndex ? currentCompleter : lastTrigger;
210
+ }, null);
209
211
  if (!completer) {
210
212
  if (autocompleter) reset();
211
213
  return;
212
214
  }
215
+ const {
216
+ allowContext,
217
+ triggerPrefix
218
+ } = completer;
219
+ const triggerIndex = textContent.lastIndexOf(triggerPrefix);
220
+ const textWithoutTrigger = textContent.slice(triggerIndex + triggerPrefix.length);
221
+ const tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.
222
+ // This is a final barrier to prevent the effect from completing with
223
+ // an extremely long string, which causes the editor to slow-down
224
+ // significantly. This could happen, for example, if `matchingWhileBackspacing`
225
+ // is true and one of the "words" end up being too long. If that's the case,
226
+ // it will be caught by this guard.
227
+ if (tooDistantFromTrigger) return;
228
+ const mismatch = filteredOptions.length === 0;
229
+ const wordsFromTrigger = textWithoutTrigger.split(/\s/);
230
+ // We need to allow the effect to run when not backspacing and if there
231
+ // was a mismatch. i.e when typing a trigger + the match string or when
232
+ // clicking in an existing trigger word on the page. We do that if we
233
+ // detect that we have one word from trigger in the current textual context.
234
+ //
235
+ // Ex.: "Some text @a" <-- "@a" will be detected as the trigger word and
236
+ // allow the effect to run. It will run until there's a mismatch.
237
+ const hasOneTriggerWord = wordsFromTrigger.length === 1;
238
+ // This is used to allow the effect to run when backspacing and if
239
+ // "touching" a word that "belongs" to a trigger. We consider a "trigger
240
+ // word" any word up to the limit of 3 from the trigger character.
241
+ // Anything beyond that is ignored if there's a mismatch. This allows
242
+ // us to "escape" a mismatch when backspacing, but still imposing some
243
+ // sane limits.
244
+ //
245
+ // Ex: "Some text @marcelo sekkkk" <--- "kkkk" caused a mismatch, but
246
+ // if the user presses backspace here, it will show the completion popup again.
247
+ const matchingWhileBackspacing = backspacing.current && wordsFromTrigger.length <= 3;
248
+ if (mismatch && !(matchingWhileBackspacing || hasOneTriggerWord)) {
249
+ if (autocompleter) reset();
250
+ return;
251
+ }
252
+ const textAfterSelection = (0, _richText.getTextContent)((0, _richText.slice)(record, undefined, (0, _richText.getTextContent)(record).length));
253
+ if (allowContext && !allowContext(textContent.slice(0, triggerIndex), textAfterSelection)) {
254
+ if (autocompleter) reset();
255
+ return;
256
+ }
257
+ if (/^\s/.test(textWithoutTrigger) || /\s\s+$/.test(textWithoutTrigger)) {
258
+ if (autocompleter) reset();
259
+ return;
260
+ }
261
+ if (!/[\u0000-\uFFFF]*$/.test(textWithoutTrigger)) {
262
+ if (autocompleter) reset();
263
+ return;
264
+ }
213
265
  const safeTrigger = (0, _strings.escapeRegExp)(completer.triggerPrefix);
214
266
  const text = (0, _removeAccents.default)(textContent);
215
267
  const match = text.slice(text.lastIndexOf(completer.triggerPrefix)).match(new RegExp(`${safeTrigger}([\u0000-\uFFFF]*)$`));