@wordpress/components 28.10.0 → 28.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 (576) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/build/autocomplete/autocompleter-ui.js +2 -6
  3. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  4. package/build/autocomplete/autocompleter-ui.native.js +2 -4
  5. package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
  6. package/build/autocomplete/index.js +4 -5
  7. package/build/autocomplete/index.js.map +1 -1
  8. package/build/base-control/types.js.map +1 -1
  9. package/build/border-box-control/border-box-control/component.js +1 -0
  10. package/build/border-box-control/border-box-control/component.js.map +1 -1
  11. package/build/border-box-control/border-box-control/hook.js +6 -0
  12. package/build/border-box-control/border-box-control/hook.js.map +1 -1
  13. package/build/border-control/border-control/component.js +1 -0
  14. package/build/border-control/border-control/component.js.map +1 -1
  15. package/build/border-control/border-control/hook.js +6 -0
  16. package/build/border-control/border-control/hook.js.map +1 -1
  17. package/build/border-control/border-control-dropdown/component.js +12 -12
  18. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  19. package/build/color-palette/index.js +1 -1
  20. package/build/color-palette/index.js.map +1 -1
  21. package/build/color-palette/index.native.js +1 -2
  22. package/build/color-palette/index.native.js.map +1 -1
  23. package/build/color-picker/index.native.js +0 -1
  24. package/build/color-picker/index.native.js.map +1 -1
  25. package/build/composite/legacy/index.js +5 -2
  26. package/build/composite/legacy/index.js.map +1 -1
  27. package/build/custom-gradient-picker/gradient-bar/control-points.js +1 -1
  28. package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  29. package/build/date-time/date/index.js +0 -1
  30. package/build/date-time/date/index.js.map +1 -1
  31. package/build/font-size-picker/index.native.js +6 -6
  32. package/build/font-size-picker/index.native.js.map +1 -1
  33. package/build/form-token-field/index.js +0 -3
  34. package/build/form-token-field/index.js.map +1 -1
  35. package/build/form-token-field/suggestions-list.js +7 -3
  36. package/build/form-token-field/suggestions-list.js.map +1 -1
  37. package/build/{dropdown-menu-v2 → menu}/checkbox-item.js +8 -8
  38. package/build/menu/checkbox-item.js.map +1 -0
  39. package/build/{dropdown-menu-v2 → menu}/context.js +2 -2
  40. package/build/menu/context.js.map +1 -0
  41. package/build/{dropdown-menu-v2 → menu}/group-label.js +5 -5
  42. package/build/menu/group-label.js.map +1 -0
  43. package/build/{dropdown-menu-v2 → menu}/group.js +5 -5
  44. package/build/menu/group.js.map +1 -0
  45. package/build/{dropdown-menu-v2 → menu}/index.js +38 -38
  46. package/build/menu/index.js.map +1 -0
  47. package/build/{dropdown-menu-v2 → menu}/item-help-text.js +3 -3
  48. package/build/menu/item-help-text.js.map +1 -0
  49. package/build/{dropdown-menu-v2 → menu}/item-label.js +3 -3
  50. package/build/menu/item-label.js.map +1 -0
  51. package/build/{dropdown-menu-v2 → menu}/item.js +7 -7
  52. package/build/menu/item.js.map +1 -0
  53. package/build/{dropdown-menu-v2 → menu}/radio-item.js +8 -8
  54. package/build/menu/radio-item.js.map +1 -0
  55. package/build/{dropdown-menu-v2 → menu}/separator.js +6 -6
  56. package/build/menu/separator.js.map +1 -0
  57. package/build/menu/styles.js +150 -0
  58. package/build/menu/styles.js.map +1 -0
  59. package/build/menu/types.js.map +1 -0
  60. package/build/menu/use-temporary-focus-visible-fix.js.map +1 -0
  61. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -5
  62. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  63. package/build/mobile/bottom-sheet/range-cell.native.js +1 -1
  64. package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  65. package/build/mobile/bottom-sheet/stepper-cell/index.native.js +1 -1
  66. package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  67. package/build/mobile/bottom-sheet/sub-sheet/index.native.js +1 -3
  68. package/build/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
  69. package/build/mobile/bottom-sheet-select-control/index.native.js +2 -2
  70. package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  71. package/build/mobile/color-settings/index.native.js +1 -3
  72. package/build/mobile/color-settings/index.native.js.map +1 -1
  73. package/build/mobile/color-settings/picker-screen.native.js +1 -3
  74. package/build/mobile/color-settings/picker-screen.native.js.map +1 -1
  75. package/build/mobile/image/index.native.js +1 -3
  76. package/build/mobile/image/index.native.js.map +1 -1
  77. package/build/mobile/keyboard-avoiding-view/index.ios.js +1 -3
  78. package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  79. package/build/mobile/link-picker/link-picker-results.native.js +2 -5
  80. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  81. package/build/mobile/link-picker/link-picker-screen.native.js +1 -3
  82. package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  83. package/build/mobile/link-settings/index.native.js +6 -18
  84. package/build/mobile/link-settings/index.native.js.map +1 -1
  85. package/build/mobile/link-settings/link-settings-screen.native.js +1 -3
  86. package/build/mobile/link-settings/link-settings-screen.native.js.map +1 -1
  87. package/build/mobile/segmented-control/index.native.js +2 -6
  88. package/build/mobile/segmented-control/index.native.js.map +1 -1
  89. package/build/mobile/utils/use-unit-converter-to-mobile.native.js +2 -6
  90. package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  91. package/build/navigation/index.js +1 -2
  92. package/build/navigation/index.js.map +1 -1
  93. package/build/navigation/item/use-navigation-tree-item.js +2 -2
  94. package/build/navigation/item/use-navigation-tree-item.js.map +1 -1
  95. package/build/navigation/menu/menu-title-search.js +2 -2
  96. package/build/navigation/menu/menu-title-search.js.map +1 -1
  97. package/build/navigation/menu/use-navigation-tree-menu.js +2 -2
  98. package/build/navigation/menu/use-navigation-tree-menu.js.map +1 -1
  99. package/build/palette-edit/index.js +4 -2
  100. package/build/palette-edit/index.js.map +1 -1
  101. package/build/palette-edit/styles.js +13 -28
  102. package/build/palette-edit/styles.js.map +1 -1
  103. package/build/private-apis.js +4 -4
  104. package/build/private-apis.js.map +1 -1
  105. package/build/radio-group/index.js +3 -1
  106. package/build/radio-group/index.js.map +1 -1
  107. package/build/sandbox/index.js +3 -6
  108. package/build/sandbox/index.js.map +1 -1
  109. package/build/sandbox/index.native.js +1 -3
  110. package/build/sandbox/index.native.js.map +1 -1
  111. package/build/search-control/index.native.js +1 -3
  112. package/build/search-control/index.native.js.map +1 -1
  113. package/build/slot-fill/bubbles-virtually/slot.js +1 -2
  114. package/build/slot-fill/bubbles-virtually/slot.js.map +1 -1
  115. package/build/slot-fill/fill.js +3 -6
  116. package/build/slot-fill/fill.js.map +1 -1
  117. package/build/spacer/hook.js +5 -3
  118. package/build/spacer/hook.js.map +1 -1
  119. package/build/tab-panel/index.js +4 -1
  120. package/build/tab-panel/index.js.map +1 -1
  121. package/build/tabs/index.js +48 -113
  122. package/build/tabs/index.js.map +1 -1
  123. package/build/tabs/styles.js +12 -12
  124. package/build/tabs/styles.js.map +1 -1
  125. package/build/tabs/tab.js +23 -6
  126. package/build/tabs/tab.js.map +1 -1
  127. package/build/tabs/tablist.js +24 -12
  128. package/build/tabs/tablist.js.map +1 -1
  129. package/build/tabs/types.js.map +1 -1
  130. package/build/toggle-group-control/toggle-group-control/component.js +2 -1
  131. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  132. package/build/toolbar/toolbar/index.js +3 -0
  133. package/build/toolbar/toolbar/index.js.map +1 -1
  134. package/build/tools-panel/tools-panel-header/component.js +1 -1
  135. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  136. package/build/tools-panel/tools-panel-item/hook.js +0 -2
  137. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  138. package/build/tooltip/index.native.js +5 -15
  139. package/build/tooltip/index.native.js.map +1 -1
  140. package/build/unit-control/index.native.js +2 -6
  141. package/build/unit-control/index.native.js.map +1 -1
  142. package/build/utils/deprecated-36px-size.js +27 -0
  143. package/build/utils/deprecated-36px-size.js.map +1 -0
  144. package/build/utils/element-rect.js +13 -2
  145. package/build/utils/element-rect.js.map +1 -1
  146. package/build/utils/hooks/use-animated-offset-rect.js +3 -2
  147. package/build/utils/hooks/use-animated-offset-rect.js.map +1 -1
  148. package/build/utils/hooks/use-update-effect.js +0 -2
  149. package/build/utils/hooks/use-update-effect.js.map +1 -1
  150. package/build-module/autocomplete/autocompleter-ui.js +2 -6
  151. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  152. package/build-module/autocomplete/autocompleter-ui.native.js +2 -4
  153. package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
  154. package/build-module/autocomplete/index.js +4 -5
  155. package/build-module/autocomplete/index.js.map +1 -1
  156. package/build-module/base-control/types.js.map +1 -1
  157. package/build-module/border-box-control/border-box-control/component.js +1 -0
  158. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  159. package/build-module/border-box-control/border-box-control/hook.js +6 -0
  160. package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
  161. package/build-module/border-control/border-control/component.js +1 -0
  162. package/build-module/border-control/border-control/component.js.map +1 -1
  163. package/build-module/border-control/border-control/hook.js +7 -0
  164. package/build-module/border-control/border-control/hook.js.map +1 -1
  165. package/build-module/border-control/border-control-dropdown/component.js +12 -12
  166. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  167. package/build-module/color-palette/index.js +1 -1
  168. package/build-module/color-palette/index.js.map +1 -1
  169. package/build-module/color-palette/index.native.js +1 -2
  170. package/build-module/color-palette/index.native.js.map +1 -1
  171. package/build-module/color-picker/index.native.js +0 -1
  172. package/build-module/color-picker/index.native.js.map +1 -1
  173. package/build-module/composite/legacy/index.js +5 -2
  174. package/build-module/composite/legacy/index.js.map +1 -1
  175. package/build-module/custom-gradient-picker/gradient-bar/control-points.js +1 -1
  176. package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  177. package/build-module/date-time/date/index.js +0 -1
  178. package/build-module/date-time/date/index.js.map +1 -1
  179. package/build-module/font-size-picker/index.native.js +7 -7
  180. package/build-module/font-size-picker/index.native.js.map +1 -1
  181. package/build-module/form-token-field/index.js +0 -3
  182. package/build-module/form-token-field/index.js.map +1 -1
  183. package/build-module/form-token-field/suggestions-list.js +7 -3
  184. package/build-module/form-token-field/suggestions-list.js.map +1 -1
  185. package/build-module/{dropdown-menu-v2 → menu}/checkbox-item.js +8 -8
  186. package/build-module/menu/checkbox-item.js.map +1 -0
  187. package/build-module/{dropdown-menu-v2 → menu}/context.js +1 -1
  188. package/build-module/menu/context.js.map +1 -0
  189. package/build-module/{dropdown-menu-v2 → menu}/group-label.js +5 -5
  190. package/build-module/menu/group-label.js.map +1 -0
  191. package/build-module/menu/group.js +21 -0
  192. package/build-module/menu/group.js.map +1 -0
  193. package/build-module/{dropdown-menu-v2 → menu}/index.js +46 -46
  194. package/build-module/menu/index.js.map +1 -0
  195. package/build-module/{dropdown-menu-v2 → menu}/item-help-text.js +2 -2
  196. package/build-module/menu/item-help-text.js.map +1 -0
  197. package/build-module/{dropdown-menu-v2 → menu}/item-label.js +2 -2
  198. package/build-module/menu/item-label.js.map +1 -0
  199. package/build-module/{dropdown-menu-v2 → menu}/item.js +7 -7
  200. package/build-module/menu/item.js.map +1 -0
  201. package/build-module/{dropdown-menu-v2 → menu}/radio-item.js +8 -8
  202. package/build-module/menu/radio-item.js.map +1 -0
  203. package/build-module/menu/separator.js +22 -0
  204. package/build-module/menu/separator.js.map +1 -0
  205. package/build-module/menu/styles.js +143 -0
  206. package/build-module/menu/styles.js.map +1 -0
  207. package/build-module/menu/types.js.map +1 -0
  208. package/build-module/menu/use-temporary-focus-visible-fix.js.map +1 -0
  209. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -5
  210. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  211. package/build-module/mobile/bottom-sheet/range-cell.native.js +1 -1
  212. package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  213. package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js +1 -1
  214. package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  215. package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js +1 -3
  216. package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
  217. package/build-module/mobile/bottom-sheet-select-control/index.native.js +2 -2
  218. package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  219. package/build-module/mobile/color-settings/index.native.js +1 -3
  220. package/build-module/mobile/color-settings/index.native.js.map +1 -1
  221. package/build-module/mobile/color-settings/picker-screen.native.js +1 -3
  222. package/build-module/mobile/color-settings/picker-screen.native.js.map +1 -1
  223. package/build-module/mobile/image/index.native.js +1 -3
  224. package/build-module/mobile/image/index.native.js.map +1 -1
  225. package/build-module/mobile/keyboard-avoiding-view/index.ios.js +1 -3
  226. package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  227. package/build-module/mobile/link-picker/link-picker-results.native.js +2 -5
  228. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  229. package/build-module/mobile/link-picker/link-picker-screen.native.js +1 -3
  230. package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  231. package/build-module/mobile/link-settings/index.native.js +6 -18
  232. package/build-module/mobile/link-settings/index.native.js.map +1 -1
  233. package/build-module/mobile/link-settings/link-settings-screen.native.js +1 -3
  234. package/build-module/mobile/link-settings/link-settings-screen.native.js.map +1 -1
  235. package/build-module/mobile/segmented-control/index.native.js +2 -6
  236. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  237. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +2 -6
  238. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  239. package/build-module/navigation/index.js +1 -2
  240. package/build-module/navigation/index.js.map +1 -1
  241. package/build-module/navigation/item/use-navigation-tree-item.js +2 -2
  242. package/build-module/navigation/item/use-navigation-tree-item.js.map +1 -1
  243. package/build-module/navigation/menu/menu-title-search.js +2 -2
  244. package/build-module/navigation/menu/menu-title-search.js.map +1 -1
  245. package/build-module/navigation/menu/use-navigation-tree-menu.js +2 -2
  246. package/build-module/navigation/menu/use-navigation-tree-menu.js.map +1 -1
  247. package/build-module/palette-edit/index.js +6 -4
  248. package/build-module/palette-edit/index.js.map +1 -1
  249. package/build-module/palette-edit/styles.js +13 -29
  250. package/build-module/palette-edit/styles.js.map +1 -1
  251. package/build-module/private-apis.js +3 -3
  252. package/build-module/private-apis.js.map +1 -1
  253. package/build-module/radio-group/index.js +3 -1
  254. package/build-module/radio-group/index.js.map +1 -1
  255. package/build-module/sandbox/index.js +3 -6
  256. package/build-module/sandbox/index.js.map +1 -1
  257. package/build-module/sandbox/index.native.js +1 -3
  258. package/build-module/sandbox/index.native.js.map +1 -1
  259. package/build-module/search-control/index.native.js +1 -3
  260. package/build-module/search-control/index.native.js.map +1 -1
  261. package/build-module/slot-fill/bubbles-virtually/slot.js +1 -2
  262. package/build-module/slot-fill/bubbles-virtually/slot.js.map +1 -1
  263. package/build-module/slot-fill/fill.js +3 -6
  264. package/build-module/slot-fill/fill.js.map +1 -1
  265. package/build-module/spacer/hook.js +5 -3
  266. package/build-module/spacer/hook.js.map +1 -1
  267. package/build-module/tab-panel/index.js +4 -1
  268. package/build-module/tab-panel/index.js.map +1 -1
  269. package/build-module/tabs/index.js +47 -112
  270. package/build-module/tabs/index.js.map +1 -1
  271. package/build-module/tabs/styles.js +11 -11
  272. package/build-module/tabs/styles.js.map +1 -1
  273. package/build-module/tabs/tab.js +21 -6
  274. package/build-module/tabs/tab.js.map +1 -1
  275. package/build-module/tabs/tablist.js +24 -12
  276. package/build-module/tabs/tablist.js.map +1 -1
  277. package/build-module/tabs/types.js.map +1 -1
  278. package/build-module/toggle-group-control/toggle-group-control/component.js +2 -1
  279. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  280. package/build-module/toolbar/toolbar/index.js +3 -0
  281. package/build-module/toolbar/toolbar/index.js.map +1 -1
  282. package/build-module/tools-panel/tools-panel-header/component.js +1 -1
  283. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  284. package/build-module/tools-panel/tools-panel-item/hook.js +0 -2
  285. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  286. package/build-module/tooltip/index.native.js +5 -15
  287. package/build-module/tooltip/index.native.js.map +1 -1
  288. package/build-module/unit-control/index.native.js +2 -6
  289. package/build-module/unit-control/index.native.js.map +1 -1
  290. package/build-module/utils/deprecated-36px-size.js +19 -0
  291. package/build-module/utils/deprecated-36px-size.js.map +1 -0
  292. package/build-module/utils/element-rect.js +13 -2
  293. package/build-module/utils/element-rect.js.map +1 -1
  294. package/build-module/utils/hooks/use-animated-offset-rect.js +3 -2
  295. package/build-module/utils/hooks/use-animated-offset-rect.js.map +1 -1
  296. package/build-module/utils/hooks/use-update-effect.js +0 -2
  297. package/build-module/utils/hooks/use-update-effect.js.map +1 -1
  298. package/build-style/style-rtl.css +6 -6
  299. package/build-style/style.css +6 -6
  300. package/build-types/animate/stories/index.story.d.ts.map +1 -1
  301. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  302. package/build-types/autocomplete/index.d.ts.map +1 -1
  303. package/build-types/base-control/stories/index.story.d.ts.map +1 -1
  304. package/build-types/base-control/types.d.ts +3 -0
  305. package/build-types/base-control/types.d.ts.map +1 -1
  306. package/build-types/border-box-control/border-box-control/component.d.ts +1 -0
  307. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  308. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  309. package/build-types/border-control/border-control/component.d.ts +1 -0
  310. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  311. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  312. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  313. package/build-types/border-control/stories/index.story.d.ts.map +1 -1
  314. package/build-types/button/stories/index.story.d.ts.map +1 -1
  315. package/build-types/card/stories/index.story.d.ts.map +1 -1
  316. package/build-types/composite/legacy/index.d.ts.map +1 -1
  317. package/build-types/composite/stories/index.story.d.ts.map +1 -1
  318. package/build-types/date-time/date/index.d.ts.map +1 -1
  319. package/build-types/disabled/stories/index.story.d.ts.map +1 -1
  320. package/build-types/draggable/stories/index.story.d.ts.map +1 -1
  321. package/build-types/form-token-field/index.d.ts.map +1 -1
  322. package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
  323. package/build-types/item-group/stories/index.story.d.ts +1 -1
  324. package/build-types/item-group/stories/index.story.d.ts.map +1 -1
  325. package/build-types/keyboard-shortcuts/stories/index.story.d.ts.map +1 -1
  326. package/build-types/menu/checkbox-item.d.ts +3 -0
  327. package/build-types/menu/checkbox-item.d.ts.map +1 -0
  328. package/build-types/menu/context.d.ts +6 -0
  329. package/build-types/menu/context.d.ts.map +1 -0
  330. package/build-types/menu/group-label.d.ts +3 -0
  331. package/build-types/menu/group-label.d.ts.map +1 -0
  332. package/build-types/menu/group.d.ts +3 -0
  333. package/build-types/menu/group.d.ts.map +1 -0
  334. package/build-types/menu/index.d.ts +40 -0
  335. package/build-types/menu/index.d.ts.map +1 -0
  336. package/build-types/{dropdown-menu-v2 → menu}/item-help-text.d.ts +1 -1
  337. package/build-types/menu/item-help-text.d.ts.map +1 -0
  338. package/build-types/{dropdown-menu-v2 → menu}/item-label.d.ts +1 -1
  339. package/build-types/menu/item-label.d.ts.map +1 -0
  340. package/build-types/menu/item.d.ts +3 -0
  341. package/build-types/menu/item.d.ts.map +1 -0
  342. package/build-types/menu/radio-item.d.ts +3 -0
  343. package/build-types/menu/radio-item.d.ts.map +1 -0
  344. package/build-types/menu/separator.d.ts +3 -0
  345. package/build-types/menu/separator.d.ts.map +1 -0
  346. package/build-types/menu/stories/index.story.d.ts +16 -0
  347. package/build-types/menu/stories/index.story.d.ts.map +1 -0
  348. package/build-types/{dropdown-menu-v2 → menu}/styles.d.ts +13 -13
  349. package/build-types/menu/styles.d.ts.map +1 -0
  350. package/build-types/menu/test/index.d.ts.map +1 -0
  351. package/build-types/{dropdown-menu-v2 → menu}/types.d.ts +22 -21
  352. package/build-types/menu/types.d.ts.map +1 -0
  353. package/build-types/menu/use-temporary-focus-visible-fix.d.ts.map +1 -0
  354. package/build-types/navigable-container/stories/navigable-menu.story.d.ts.map +1 -1
  355. package/build-types/navigable-container/stories/tabbable-container.story.d.ts.map +1 -1
  356. package/build-types/navigation/index.d.ts.map +1 -1
  357. package/build-types/palette-edit/index.d.ts.map +1 -1
  358. package/build-types/palette-edit/styles.d.ts +0 -256
  359. package/build-types/palette-edit/styles.d.ts.map +1 -1
  360. package/build-types/panel/stories/index.story.d.ts.map +1 -1
  361. package/build-types/radio-group/index.d.ts.map +1 -1
  362. package/build-types/resizable-box/stories/index.story.d.ts.map +1 -1
  363. package/build-types/sandbox/index.d.ts.map +1 -1
  364. package/build-types/sandbox/stories/index.story.d.ts.map +1 -1
  365. package/build-types/scroll-lock/stories/index.story.d.ts.map +1 -1
  366. package/build-types/shortcut/stories/index.story.d.ts.map +1 -1
  367. package/build-types/slot-fill/bubbles-virtually/slot.d.ts.map +1 -1
  368. package/build-types/slot-fill/fill.d.ts.map +1 -1
  369. package/build-types/slot-fill/stories/index.story.d.ts.map +1 -1
  370. package/build-types/spacer/hook.d.ts.map +1 -1
  371. package/build-types/tab-panel/index.d.ts.map +1 -1
  372. package/build-types/tab-panel/stories/index.story.d.ts.map +1 -1
  373. package/build-types/tabs/index.d.ts +21 -8
  374. package/build-types/tabs/index.d.ts.map +1 -1
  375. package/build-types/tabs/stories/index.story.d.ts +1 -1
  376. package/build-types/tabs/stories/index.story.d.ts.map +1 -1
  377. package/build-types/tabs/styles.d.ts +6 -3
  378. package/build-types/tabs/styles.d.ts.map +1 -1
  379. package/build-types/tabs/tab.d.ts +0 -3
  380. package/build-types/tabs/tab.d.ts.map +1 -1
  381. package/build-types/tabs/tablist.d.ts.map +1 -1
  382. package/build-types/tabs/types.d.ts +85 -48
  383. package/build-types/tabs/types.d.ts.map +1 -1
  384. package/build-types/theme/stories/index.story.d.ts.map +1 -1
  385. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  386. package/build-types/toolbar/toolbar/index.d.ts.map +1 -1
  387. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  388. package/build-types/utils/deprecated-36px-size.d.ts +6 -0
  389. package/build-types/utils/deprecated-36px-size.d.ts.map +1 -0
  390. package/build-types/utils/element-rect.d.ts +1 -1
  391. package/build-types/utils/element-rect.d.ts.map +1 -1
  392. package/build-types/utils/hooks/use-animated-offset-rect.d.ts +8 -1
  393. package/build-types/utils/hooks/use-animated-offset-rect.d.ts.map +1 -1
  394. package/build-types/utils/hooks/use-update-effect.d.ts.map +1 -1
  395. package/build-types/visually-hidden/stories/index.story.d.ts.map +1 -1
  396. package/package.json +20 -19
  397. package/src/alignment-matrix-control/README.md +1 -2
  398. package/src/angle-picker-control/README.md +1 -2
  399. package/src/animate/stories/index.story.tsx +2 -1
  400. package/src/autocomplete/autocompleter-ui.native.js +2 -4
  401. package/src/autocomplete/autocompleter-ui.tsx +2 -6
  402. package/src/autocomplete/index.tsx +4 -5
  403. package/src/base-control/README.md +58 -47
  404. package/src/base-control/docs-manifest.json +12 -0
  405. package/src/base-control/stories/index.story.tsx +4 -0
  406. package/src/base-control/types.ts +3 -0
  407. package/src/border-box-control/border-box-control/README.md +1 -0
  408. package/src/border-box-control/border-box-control/component.tsx +1 -0
  409. package/src/border-box-control/border-box-control/hook.ts +7 -0
  410. package/src/border-box-control/stories/index.story.tsx +1 -0
  411. package/src/border-box-control/test/index.tsx +1 -0
  412. package/src/border-control/border-control/README.md +1 -0
  413. package/src/border-control/border-control/component.tsx +1 -0
  414. package/src/border-control/border-control/hook.ts +7 -1
  415. package/src/border-control/border-control-dropdown/component.tsx +24 -12
  416. package/src/border-control/stories/index.story.tsx +1 -0
  417. package/src/border-control/test/index.js +1 -0
  418. package/src/button/stories/index.story.tsx +2 -1
  419. package/src/card/stories/index.story.tsx +2 -1
  420. package/src/color-palette/index.native.js +1 -2
  421. package/src/color-palette/index.tsx +1 -1
  422. package/src/color-palette/style.scss +2 -4
  423. package/src/color-picker/index.native.js +0 -1
  424. package/src/composite/legacy/index.tsx +5 -2
  425. package/src/composite/stories/index.story.tsx +2 -1
  426. package/src/custom-gradient-picker/gradient-bar/control-points.tsx +1 -1
  427. package/src/date-time/date/index.tsx +0 -1
  428. package/src/disabled/stories/index.story.tsx +2 -1
  429. package/src/draggable/stories/index.story.tsx +2 -1
  430. package/src/font-size-picker/index.native.js +7 -7
  431. package/src/form-token-field/index.tsx +0 -3
  432. package/src/form-token-field/style.scss +4 -1
  433. package/src/form-token-field/suggestions-list.tsx +6 -0
  434. package/src/item-group/stories/index.story.tsx +8 -4
  435. package/src/keyboard-shortcuts/stories/index.story.tsx +2 -1
  436. package/src/{dropdown-menu-v2 → menu}/README.md +34 -34
  437. package/src/{dropdown-menu-v2 → menu}/checkbox-item.tsx +14 -14
  438. package/src/menu/context.tsx +13 -0
  439. package/src/{dropdown-menu-v2 → menu}/group-label.tsx +8 -8
  440. package/src/menu/group.tsx +26 -0
  441. package/src/{dropdown-menu-v2 → menu}/index.tsx +65 -70
  442. package/src/{dropdown-menu-v2 → menu}/item-help-text.tsx +3 -7
  443. package/src/{dropdown-menu-v2 → menu}/item-label.tsx +3 -7
  444. package/src/{dropdown-menu-v2 → menu}/item.tsx +13 -13
  445. package/src/{dropdown-menu-v2 → menu}/radio-item.tsx +14 -14
  446. package/src/menu/separator.tsx +27 -0
  447. package/src/menu/stories/index.story.tsx +542 -0
  448. package/src/{dropdown-menu-v2 → menu}/styles.ts +17 -17
  449. package/src/{dropdown-menu-v2 → menu}/test/index.tsx +145 -225
  450. package/src/{dropdown-menu-v2 → menu}/types.ts +24 -23
  451. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -5
  452. package/src/mobile/bottom-sheet/range-cell.native.js +1 -1
  453. package/src/mobile/bottom-sheet/stepper-cell/index.native.js +1 -1
  454. package/src/mobile/bottom-sheet/sub-sheet/index.native.js +1 -3
  455. package/src/mobile/bottom-sheet-select-control/index.native.js +2 -2
  456. package/src/mobile/color-settings/index.native.js +1 -3
  457. package/src/mobile/color-settings/picker-screen.native.js +1 -3
  458. package/src/mobile/image/index.native.js +1 -3
  459. package/src/mobile/keyboard-avoiding-view/index.ios.js +1 -3
  460. package/src/mobile/link-picker/link-picker-results.native.js +2 -5
  461. package/src/mobile/link-picker/link-picker-screen.native.js +1 -3
  462. package/src/mobile/link-settings/index.native.js +6 -18
  463. package/src/mobile/link-settings/link-settings-screen.native.js +1 -3
  464. package/src/mobile/segmented-control/index.native.js +2 -6
  465. package/src/mobile/utils/use-unit-converter-to-mobile.native.js +2 -6
  466. package/src/navigable-container/stories/navigable-menu.story.tsx +2 -1
  467. package/src/navigable-container/stories/tabbable-container.story.tsx +2 -1
  468. package/src/navigation/index.tsx +1 -2
  469. package/src/navigation/item/use-navigation-tree-item.tsx +2 -2
  470. package/src/navigation/menu/menu-title-search.tsx +2 -2
  471. package/src/navigation/menu/use-navigation-tree-menu.tsx +2 -2
  472. package/src/palette-edit/index.tsx +4 -5
  473. package/src/palette-edit/styles.ts +1 -67
  474. package/src/panel/stories/index.story.tsx +2 -1
  475. package/src/private-apis.ts +3 -3
  476. package/src/radio-group/index.tsx +2 -0
  477. package/src/resizable-box/stories/index.story.tsx +2 -1
  478. package/src/sandbox/index.native.js +1 -3
  479. package/src/sandbox/index.tsx +3 -6
  480. package/src/sandbox/stories/index.story.tsx +2 -1
  481. package/src/scroll-lock/stories/index.story.tsx +2 -1
  482. package/src/search-control/index.native.js +1 -3
  483. package/src/shortcut/stories/index.story.tsx +2 -1
  484. package/src/slot-fill/bubbles-virtually/slot.tsx +1 -2
  485. package/src/slot-fill/fill.ts +3 -6
  486. package/src/slot-fill/stories/index.story.tsx +2 -1
  487. package/src/spacer/hook.ts +3 -2
  488. package/src/tab-panel/index.tsx +3 -0
  489. package/src/tab-panel/stories/index.story.tsx +2 -1
  490. package/src/tab-panel/style.scss +1 -3
  491. package/src/tabs/README.md +63 -21
  492. package/src/tabs/index.tsx +112 -189
  493. package/src/tabs/stories/index.story.tsx +5 -2
  494. package/src/tabs/styles.ts +13 -5
  495. package/src/tabs/tab.tsx +23 -3
  496. package/src/tabs/tablist.tsx +31 -15
  497. package/src/tabs/test/index.tsx +131 -118
  498. package/src/tabs/types.ts +89 -49
  499. package/src/theme/stories/index.story.tsx +2 -1
  500. package/src/toggle-group-control/toggle-group-control/component.tsx +1 -0
  501. package/src/toolbar/toolbar/index.tsx +3 -0
  502. package/src/tools-panel/tools-panel-header/component.tsx +1 -1
  503. package/src/tools-panel/tools-panel-item/hook.ts +0 -2
  504. package/src/tooltip/index.native.js +5 -15
  505. package/src/unit-control/index.native.js +2 -6
  506. package/src/utils/deprecated-36px-size.ts +24 -0
  507. package/src/utils/element-rect.ts +14 -2
  508. package/src/utils/hooks/use-animated-offset-rect.ts +13 -1
  509. package/src/utils/hooks/use-update-effect.js +0 -2
  510. package/src/visually-hidden/stories/index.story.tsx +2 -1
  511. package/tsconfig.tsbuildinfo +1 -1
  512. package/build/dropdown-menu-v2/checkbox-item.js.map +0 -1
  513. package/build/dropdown-menu-v2/context.js.map +0 -1
  514. package/build/dropdown-menu-v2/group-label.js.map +0 -1
  515. package/build/dropdown-menu-v2/group.js.map +0 -1
  516. package/build/dropdown-menu-v2/index.js.map +0 -1
  517. package/build/dropdown-menu-v2/item-help-text.js.map +0 -1
  518. package/build/dropdown-menu-v2/item-label.js.map +0 -1
  519. package/build/dropdown-menu-v2/item.js.map +0 -1
  520. package/build/dropdown-menu-v2/radio-item.js.map +0 -1
  521. package/build/dropdown-menu-v2/separator.js.map +0 -1
  522. package/build/dropdown-menu-v2/styles.js +0 -150
  523. package/build/dropdown-menu-v2/styles.js.map +0 -1
  524. package/build/dropdown-menu-v2/types.js.map +0 -1
  525. package/build/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +0 -1
  526. package/build-module/dropdown-menu-v2/checkbox-item.js.map +0 -1
  527. package/build-module/dropdown-menu-v2/context.js.map +0 -1
  528. package/build-module/dropdown-menu-v2/group-label.js.map +0 -1
  529. package/build-module/dropdown-menu-v2/group.js +0 -21
  530. package/build-module/dropdown-menu-v2/group.js.map +0 -1
  531. package/build-module/dropdown-menu-v2/index.js.map +0 -1
  532. package/build-module/dropdown-menu-v2/item-help-text.js.map +0 -1
  533. package/build-module/dropdown-menu-v2/item-label.js.map +0 -1
  534. package/build-module/dropdown-menu-v2/item.js.map +0 -1
  535. package/build-module/dropdown-menu-v2/radio-item.js.map +0 -1
  536. package/build-module/dropdown-menu-v2/separator.js +0 -22
  537. package/build-module/dropdown-menu-v2/separator.js.map +0 -1
  538. package/build-module/dropdown-menu-v2/styles.js +0 -143
  539. package/build-module/dropdown-menu-v2/styles.js.map +0 -1
  540. package/build-module/dropdown-menu-v2/types.js.map +0 -1
  541. package/build-module/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +0 -1
  542. package/build-types/dropdown-menu-v2/checkbox-item.d.ts +0 -3
  543. package/build-types/dropdown-menu-v2/checkbox-item.d.ts.map +0 -1
  544. package/build-types/dropdown-menu-v2/context.d.ts +0 -6
  545. package/build-types/dropdown-menu-v2/context.d.ts.map +0 -1
  546. package/build-types/dropdown-menu-v2/group-label.d.ts +0 -3
  547. package/build-types/dropdown-menu-v2/group-label.d.ts.map +0 -1
  548. package/build-types/dropdown-menu-v2/group.d.ts +0 -3
  549. package/build-types/dropdown-menu-v2/group.d.ts.map +0 -1
  550. package/build-types/dropdown-menu-v2/index.d.ts +0 -40
  551. package/build-types/dropdown-menu-v2/index.d.ts.map +0 -1
  552. package/build-types/dropdown-menu-v2/item-help-text.d.ts.map +0 -1
  553. package/build-types/dropdown-menu-v2/item-label.d.ts.map +0 -1
  554. package/build-types/dropdown-menu-v2/item.d.ts +0 -3
  555. package/build-types/dropdown-menu-v2/item.d.ts.map +0 -1
  556. package/build-types/dropdown-menu-v2/radio-item.d.ts +0 -3
  557. package/build-types/dropdown-menu-v2/radio-item.d.ts.map +0 -1
  558. package/build-types/dropdown-menu-v2/separator.d.ts +0 -3
  559. package/build-types/dropdown-menu-v2/separator.d.ts.map +0 -1
  560. package/build-types/dropdown-menu-v2/stories/index.story.d.ts +0 -16
  561. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +0 -1
  562. package/build-types/dropdown-menu-v2/styles.d.ts.map +0 -1
  563. package/build-types/dropdown-menu-v2/test/index.d.ts.map +0 -1
  564. package/build-types/dropdown-menu-v2/types.d.ts.map +0 -1
  565. package/build-types/dropdown-menu-v2/use-temporary-focus-visible-fix.d.ts.map +0 -1
  566. package/src/dropdown-menu-v2/context.tsx +0 -13
  567. package/src/dropdown-menu-v2/group.tsx +0 -26
  568. package/src/dropdown-menu-v2/separator.tsx +0 -27
  569. package/src/dropdown-menu-v2/stories/index.story.tsx +0 -639
  570. /package/build/{dropdown-menu-v2 → menu}/types.js +0 -0
  571. /package/build/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.js +0 -0
  572. /package/build-module/{dropdown-menu-v2 → menu}/types.js +0 -0
  573. /package/build-module/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.js +0 -0
  574. /package/build-types/{dropdown-menu-v2 → menu}/test/index.d.ts +0 -0
  575. /package/build-types/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.d.ts +0 -0
  576. /package/src/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.ts +0 -0
@@ -96,11 +96,13 @@ const POLL_RATE = 100;
96
96
  * to measure again after a frame, and if that fails, it will poll every 100
97
97
  * milliseconds until it succeeds.
98
98
  */
99
- function useTrackElementOffsetRect(targetElement) {
99
+ function useTrackElementOffsetRect(targetElement, deps = []) {
100
100
  const [indicatorPosition, setIndicatorPosition] = (0, _element.useState)(NULL_ELEMENT_OFFSET_RECT);
101
101
  const intervalRef = (0, _element.useRef)();
102
102
  const measure = (0, _compose.useEvent)(() => {
103
- if (targetElement) {
103
+ // Check that the targetElement is still attached to the DOM, in case
104
+ // it was removed since the last `measure` call.
105
+ if (targetElement && targetElement.isConnected) {
104
106
  const elementOffsetRect = getElementOffsetRect(targetElement);
105
107
  if (elementOffsetRect) {
106
108
  setIndicatorPosition(elementOffsetRect);
@@ -127,6 +129,15 @@ function useTrackElementOffsetRect(targetElement) {
127
129
  setIndicatorPosition(NULL_ELEMENT_OFFSET_RECT);
128
130
  }
129
131
  }, [setElement, targetElement]);
132
+
133
+ // Escape hatch to force a remeasurement when something else changes rather
134
+ // than the target elements' ref or size (for example, the target element
135
+ // can change its position within the tablist).
136
+ (0, _element.useLayoutEffect)(() => {
137
+ measure();
138
+ // `measure` is a stable function, so it's safe to omit it from the deps array.
139
+ // deps can't be statically analyzed by ESLint
140
+ }, deps);
130
141
  return indicatorPosition;
131
142
  }
132
143
 
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_compose","NULL_ELEMENT_OFFSET_RECT","exports","element","undefined","top","right","bottom","left","width","height","getElementOffsetRect","_offsetParent$getBoun","_offsetParent$scrollL","_offsetParent$scrollT","rect","getBoundingClientRect","offsetParent","offsetParentRect","offsetParentScrollX","scrollLeft","offsetParentScrollY","scrollTop","computedWidth","parseFloat","getComputedStyle","computedHeight","scaleX","scaleY","POLL_RATE","useTrackElementOffsetRect","targetElement","indicatorPosition","setIndicatorPosition","useState","intervalRef","useRef","measure","useEvent","elementOffsetRect","clearInterval","current","setElement","useResizeObserver","requestAnimationFrame","setInterval","useLayoutEffect"],"sources":["@wordpress/components/src/utils/element-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport { useEvent, useResizeObserver } from '@wordpress/compose';\n\n/**\n * The position and dimensions of an element, relative to its offset parent.\n */\nexport type ElementOffsetRect = {\n\t/**\n\t * The element the rect belongs to.\n\t */\n\telement: HTMLElement | undefined;\n\t/**\n\t * The distance from the top edge of the offset parent to the top edge of\n\t * the element.\n\t */\n\ttop: number;\n\t/**\n\t * The distance from the right edge of the offset parent to the right edge\n\t * of the element.\n\t */\n\tright: number;\n\t/**\n\t * The distance from the bottom edge of the offset parent to the bottom edge\n\t * of the element.\n\t */\n\tbottom: number;\n\t/**\n\t * The distance from the left edge of the offset parent to the left edge of\n\t * the element.\n\t */\n\tleft: number;\n\t/**\n\t * The width of the element.\n\t */\n\twidth: number;\n\t/**\n\t * The height of the element.\n\t */\n\theight: number;\n};\n\n/**\n * An `ElementOffsetRect` object with all values set to zero.\n */\nexport const NULL_ELEMENT_OFFSET_RECT = {\n\telement: undefined,\n\ttop: 0,\n\tright: 0,\n\tbottom: 0,\n\tleft: 0,\n\twidth: 0,\n\theight: 0,\n} satisfies ElementOffsetRect;\n\n/**\n * Returns the position and dimensions of an element, relative to its offset\n * parent, with subpixel precision. Values reflect the real measures before any\n * potential scaling distortions along the X and Y axes.\n *\n * Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`\n * entries are not suitable, such as when the element is transformed, and when\n * `element.offset<Top|Left|Width|Height>` methods are not precise enough.\n *\n * **Note:** in some contexts, like when the scale is 0, this method will fail\n * because it's impossible to calculate a scaling ratio. When that happens, it\n * will return `undefined`.\n */\nexport function getElementOffsetRect(\n\telement: HTMLElement\n): ElementOffsetRect | undefined {\n\t// Position and dimension values computed with `getBoundingClientRect` have\n\t// subpixel precision, but are affected by distortions since they represent\n\t// the \"real\" measures, or in other words, the actual final values as rendered\n\t// by the browser.\n\tconst rect = element.getBoundingClientRect();\n\tif ( rect.width === 0 || rect.height === 0 ) {\n\t\treturn;\n\t}\n\tconst offsetParent = element.offsetParent;\n\tconst offsetParentRect =\n\t\toffsetParent?.getBoundingClientRect() ?? NULL_ELEMENT_OFFSET_RECT;\n\tconst offsetParentScrollX = offsetParent?.scrollLeft ?? 0;\n\tconst offsetParentScrollY = offsetParent?.scrollTop ?? 0;\n\n\t// Computed widths and heights have subpixel precision, and are not affected\n\t// by distortions.\n\tconst computedWidth = parseFloat( getComputedStyle( element ).width );\n\tconst computedHeight = parseFloat( getComputedStyle( element ).height );\n\n\t// We can obtain the current scale factor for the element by comparing \"computed\"\n\t// dimensions with the \"real\" ones.\n\tconst scaleX = computedWidth / rect.width;\n\tconst scaleY = computedHeight / rect.height;\n\n\treturn {\n\t\telement,\n\t\t// To obtain the adjusted values for the position:\n\t\t// 1. Compute the element's position relative to the offset parent.\n\t\t// 2. Correct for the scale factor.\n\t\t// 3. Adjust for the scroll position of the offset parent.\n\t\ttop:\n\t\t\t( rect.top - offsetParentRect?.top ) * scaleY + offsetParentScrollY,\n\t\tright:\n\t\t\t( offsetParentRect?.right - rect.right ) * scaleX -\n\t\t\toffsetParentScrollX,\n\t\tbottom:\n\t\t\t( offsetParentRect?.bottom - rect.bottom ) * scaleY -\n\t\t\toffsetParentScrollY,\n\t\tleft:\n\t\t\t( rect.left - offsetParentRect?.left ) * scaleX +\n\t\t\toffsetParentScrollX,\n\t\t// Computed dimensions don't need any adjustments.\n\t\twidth: computedWidth,\n\t\theight: computedHeight,\n\t};\n}\n\nconst POLL_RATE = 100;\n\n/**\n * Tracks the position and dimensions of an element, relative to its offset\n * parent. The element can be changed dynamically.\n *\n * When no element is provided (`null` or `undefined`), the hook will return\n * a \"null\" rect, in which all values are `0` and `element` is `undefined`.\n *\n * **Note:** sometimes, the measurement will fail (see `getElementOffsetRect`'s\n * documentation for more details). When that happens, this hook will attempt\n * to measure again after a frame, and if that fails, it will poll every 100\n * milliseconds until it succeeds.\n */\nexport function useTrackElementOffsetRect(\n\ttargetElement: HTMLElement | undefined | null\n) {\n\tconst [ indicatorPosition, setIndicatorPosition ] =\n\t\tuseState< ElementOffsetRect >( NULL_ELEMENT_OFFSET_RECT );\n\tconst intervalRef = useRef< ReturnType< typeof setInterval > >();\n\n\tconst measure = useEvent( () => {\n\t\tif ( targetElement ) {\n\t\t\tconst elementOffsetRect = getElementOffsetRect( targetElement );\n\t\t\tif ( elementOffsetRect ) {\n\t\t\t\tsetIndicatorPosition( elementOffsetRect );\n\t\t\t\tclearInterval( intervalRef.current );\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tclearInterval( intervalRef.current );\n\t\t}\n\t\treturn false;\n\t} );\n\n\tconst setElement = useResizeObserver( () => {\n\t\tif ( ! measure() ) {\n\t\t\trequestAnimationFrame( () => {\n\t\t\t\tif ( ! measure() ) {\n\t\t\t\t\tintervalRef.current = setInterval( measure, POLL_RATE );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tsetElement( targetElement );\n\t\tif ( ! targetElement ) {\n\t\t\tsetIndicatorPosition( NULL_ELEMENT_OFFSET_RECT );\n\t\t}\n\t}, [ setElement, targetElement ] );\n\n\treturn indicatorPosition;\n}\n\n/* eslint-enable jsdoc/require-param */\n"],"mappings":";;;;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AALA;AACA;AACA;AACA;;AAIA;AACA;AACA;;AAoCA;AACA;AACA;AACO,MAAME,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACvCE,OAAO,EAAEC,SAAS;EAClBC,GAAG,EAAE,CAAC;EACNC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACT,CAA6B;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,oBAAoBA,CACnCR,OAAoB,EACY;EAAA,IAAAS,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;EAChC;EACA;EACA;EACA;EACA,MAAMC,IAAI,GAAGZ,OAAO,CAACa,qBAAqB,CAAC,CAAC;EAC5C,IAAKD,IAAI,CAACN,KAAK,KAAK,CAAC,IAAIM,IAAI,CAACL,MAAM,KAAK,CAAC,EAAG;IAC5C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_RECT","exports","element","undefined","top","right","bottom","left","width","height","getElementOffsetRect","_offsetParent$getBoun","_offsetParent$scrollL","_offsetParent$scrollT","rect","getBoundingClientRect","offsetParent","offsetParentRect","offsetParentScrollX","scrollLeft","offsetParentScrollY","scrollTop","computedWidth","parseFloat","getComputedStyle","computedHeight","scaleX","scaleY","POLL_RATE","useTrackElementOffsetRect","targetElement","deps","indicatorPosition","setIndicatorPosition","useState","intervalRef","useRef","measure","useEvent","isConnected","elementOffsetRect","clearInterval","current","setElement","useResizeObserver","requestAnimationFrame","setInterval","useLayoutEffect"],"sources":["@wordpress/components/src/utils/element-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport { useEvent, useResizeObserver } from '@wordpress/compose';\n\n/**\n * The position and dimensions of an element, relative to its offset parent.\n */\nexport type ElementOffsetRect = {\n\t/**\n\t * The element the rect belongs to.\n\t */\n\telement: HTMLElement | undefined;\n\t/**\n\t * The distance from the top edge of the offset parent to the top edge of\n\t * the element.\n\t */\n\ttop: number;\n\t/**\n\t * The distance from the right edge of the offset parent to the right edge\n\t * of the element.\n\t */\n\tright: number;\n\t/**\n\t * The distance from the bottom edge of the offset parent to the bottom edge\n\t * of the element.\n\t */\n\tbottom: number;\n\t/**\n\t * The distance from the left edge of the offset parent to the left edge of\n\t * the element.\n\t */\n\tleft: number;\n\t/**\n\t * The width of the element.\n\t */\n\twidth: number;\n\t/**\n\t * The height of the element.\n\t */\n\theight: number;\n};\n\n/**\n * An `ElementOffsetRect` object with all values set to zero.\n */\nexport const NULL_ELEMENT_OFFSET_RECT = {\n\telement: undefined,\n\ttop: 0,\n\tright: 0,\n\tbottom: 0,\n\tleft: 0,\n\twidth: 0,\n\theight: 0,\n} satisfies ElementOffsetRect;\n\n/**\n * Returns the position and dimensions of an element, relative to its offset\n * parent, with subpixel precision. Values reflect the real measures before any\n * potential scaling distortions along the X and Y axes.\n *\n * Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`\n * entries are not suitable, such as when the element is transformed, and when\n * `element.offset<Top|Left|Width|Height>` methods are not precise enough.\n *\n * **Note:** in some contexts, like when the scale is 0, this method will fail\n * because it's impossible to calculate a scaling ratio. When that happens, it\n * will return `undefined`.\n */\nexport function getElementOffsetRect(\n\telement: HTMLElement\n): ElementOffsetRect | undefined {\n\t// Position and dimension values computed with `getBoundingClientRect` have\n\t// subpixel precision, but are affected by distortions since they represent\n\t// the \"real\" measures, or in other words, the actual final values as rendered\n\t// by the browser.\n\tconst rect = element.getBoundingClientRect();\n\tif ( rect.width === 0 || rect.height === 0 ) {\n\t\treturn;\n\t}\n\tconst offsetParent = element.offsetParent;\n\tconst offsetParentRect =\n\t\toffsetParent?.getBoundingClientRect() ?? NULL_ELEMENT_OFFSET_RECT;\n\tconst offsetParentScrollX = offsetParent?.scrollLeft ?? 0;\n\tconst offsetParentScrollY = offsetParent?.scrollTop ?? 0;\n\n\t// Computed widths and heights have subpixel precision, and are not affected\n\t// by distortions.\n\tconst computedWidth = parseFloat( getComputedStyle( element ).width );\n\tconst computedHeight = parseFloat( getComputedStyle( element ).height );\n\n\t// We can obtain the current scale factor for the element by comparing \"computed\"\n\t// dimensions with the \"real\" ones.\n\tconst scaleX = computedWidth / rect.width;\n\tconst scaleY = computedHeight / rect.height;\n\n\treturn {\n\t\telement,\n\t\t// To obtain the adjusted values for the position:\n\t\t// 1. Compute the element's position relative to the offset parent.\n\t\t// 2. Correct for the scale factor.\n\t\t// 3. Adjust for the scroll position of the offset parent.\n\t\ttop:\n\t\t\t( rect.top - offsetParentRect?.top ) * scaleY + offsetParentScrollY,\n\t\tright:\n\t\t\t( offsetParentRect?.right - rect.right ) * scaleX -\n\t\t\toffsetParentScrollX,\n\t\tbottom:\n\t\t\t( offsetParentRect?.bottom - rect.bottom ) * scaleY -\n\t\t\toffsetParentScrollY,\n\t\tleft:\n\t\t\t( rect.left - offsetParentRect?.left ) * scaleX +\n\t\t\toffsetParentScrollX,\n\t\t// Computed dimensions don't need any adjustments.\n\t\twidth: computedWidth,\n\t\theight: computedHeight,\n\t};\n}\n\nconst POLL_RATE = 100;\n\n/**\n * Tracks the position and dimensions of an element, relative to its offset\n * parent. The element can be changed dynamically.\n *\n * When no element is provided (`null` or `undefined`), the hook will return\n * a \"null\" rect, in which all values are `0` and `element` is `undefined`.\n *\n * **Note:** sometimes, the measurement will fail (see `getElementOffsetRect`'s\n * documentation for more details). When that happens, this hook will attempt\n * to measure again after a frame, and if that fails, it will poll every 100\n * milliseconds until it succeeds.\n */\nexport function useTrackElementOffsetRect(\n\ttargetElement: HTMLElement | undefined | null,\n\tdeps: unknown[] = []\n) {\n\tconst [ indicatorPosition, setIndicatorPosition ] =\n\t\tuseState< ElementOffsetRect >( NULL_ELEMENT_OFFSET_RECT );\n\tconst intervalRef = useRef< ReturnType< typeof setInterval > >();\n\n\tconst measure = useEvent( () => {\n\t\t// Check that the targetElement is still attached to the DOM, in case\n\t\t// it was removed since the last `measure` call.\n\t\tif ( targetElement && targetElement.isConnected ) {\n\t\t\tconst elementOffsetRect = getElementOffsetRect( targetElement );\n\t\t\tif ( elementOffsetRect ) {\n\t\t\t\tsetIndicatorPosition( elementOffsetRect );\n\t\t\t\tclearInterval( intervalRef.current );\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tclearInterval( intervalRef.current );\n\t\t}\n\t\treturn false;\n\t} );\n\n\tconst setElement = useResizeObserver( () => {\n\t\tif ( ! measure() ) {\n\t\t\trequestAnimationFrame( () => {\n\t\t\t\tif ( ! measure() ) {\n\t\t\t\t\tintervalRef.current = setInterval( measure, POLL_RATE );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tsetElement( targetElement );\n\t\tif ( ! targetElement ) {\n\t\t\tsetIndicatorPosition( NULL_ELEMENT_OFFSET_RECT );\n\t\t}\n\t}, [ setElement, targetElement ] );\n\n\t// Escape hatch to force a remeasurement when something else changes rather\n\t// than the target elements' ref or size (for example, the target element\n\t// can change its position within the tablist).\n\tuseLayoutEffect( () => {\n\t\tmeasure();\n\t\t// `measure` is a stable function, so it's safe to omit it from the deps array.\n\t\t// deps can't be statically analyzed by ESLint\n\t}, deps );\n\n\treturn indicatorPosition;\n}\n\n/* eslint-enable jsdoc/require-param */\n"],"mappings":";;;;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AALA;AACA;AACA;AACA;;AAIA;AACA;AACA;;AAoCA;AACA;AACA;AACO,MAAME,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACvCE,OAAO,EAAEC,SAAS;EAClBC,GAAG,EAAE,CAAC;EACNC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACT,CAA6B;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,oBAAoBA,CACnCR,OAAoB,EACY;EAAA,IAAAS,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;EAChC;EACA;EACA;EACA;EACA,MAAMC,IAAI,GAAGZ,OAAO,CAACa,qBAAqB,CAAC,CAAC;EAC5C,IAAKD,IAAI,CAACN,KAAK,KAAK,CAAC,IAAIM,IAAI,CAACL,MAAM,KAAK,CAAC,EAAG;IAC5C;EACD;EACA,MAAMO,YAAY,GAAGd,OAAO,CAACc,YAAY;EACzC,MAAMC,gBAAgB,IAAAN,qBAAA,GACrBK,YAAY,EAAED,qBAAqB,CAAC,CAAC,cAAAJ,qBAAA,cAAAA,qBAAA,GAAIX,wBAAwB;EAClE,MAAMkB,mBAAmB,IAAAN,qBAAA,GAAGI,YAAY,EAAEG,UAAU,cAAAP,qBAAA,cAAAA,qBAAA,GAAI,CAAC;EACzD,MAAMQ,mBAAmB,IAAAP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hE,MAAMC,OAAO,GAAG,IAAAC,iBAAQ,EAAE,MAAM;IAC/B;IACA;IACA,IAAKR,aAAa,IAAIA,aAAa,CAACS,WAAW,EAAG;MACjD,MAAMC,iBAAiB,GAAG9B,oBAAoB,CAAEoB,aAAc,CAAC;MAC/D,IAAKU,iBAAiB,EAAG;QACxBP,oBAAoB,CAAEO,iBAAkB,CAAC;QACzCC,aAAa,CAAEN,WAAW,CAACO,OAAQ,CAAC;QACpC,OAAO,IAAI;MACZ;IACD,CAAC,MAAM;MACND,aAAa,CAAEN,WAAW,CAACO,OAAQ,CAAC;IACrC;IACA,OAAO,KAAK;EACb,CAAE,CAAC;EAEH,MAAMC,UAAU,GAAG,IAAAC,0BAAiB,EAAE,MAAM;IAC3C,IAAK,CAAEP,OAAO,CAAC,CAAC,EAAG;MAClBQ,qBAAqB,CAAE,MAAM;QAC5B,IAAK,CAAER,OAAO,CAAC,CAAC,EAAG;UAClBF,WAAW,CAACO,OAAO,GAAGI,WAAW,CAAET,OAAO,EAAET,SAAU,CAAC;QACxD;MACD,CAAE,CAAC;IACJ;EACD,CAAE,CAAC;EAEH,IAAAmB,wBAAe,EAAE,MAAM;IACtBJ,UAAU,CAAEb,aAAc,CAAC;IAC3B,IAAK,CAAEA,aAAa,EAAG;MACtBG,oBAAoB,CAAEjC,wBAAyB,CAAC;IACjD;EACD,CAAC,EAAE,CAAE2C,UAAU,EAAEb,aAAa,CAAG,CAAC;;EAElC;EACA;EACA;EACA,IAAAiB,wBAAe,EAAE,MAAM;IACtBV,OAAO,CAAC,CAAC;IACT;IACA;EACD,CAAC,EAAEN,IAAK,CAAC;EAET,OAAOC,iBAAiB;AACzB;;AAEA","ignoreList":[]}
@@ -50,10 +50,11 @@ container,
50
50
  rect, {
51
51
  prefix = 'subelement',
52
52
  dataAttribute = `${prefix}-animated`,
53
- transitionEndFilter = () => true
53
+ transitionEndFilter = () => true,
54
+ roundRect = false
54
55
  } = {}) {
55
56
  const setProperties = (0, _compose.useEvent)(() => {
56
- Object.keys(rect).forEach(property => property !== 'element' && container?.style.setProperty(`--${prefix}-${property}`, String(rect[property])));
57
+ Object.keys(rect).forEach(property => property !== 'element' && container?.style.setProperty(`--${prefix}-${property}`, String(roundRect ? Math.floor(rect[property]) : rect[property])));
57
58
  });
58
59
  (0, _element.useLayoutEffect)(() => {
59
60
  setProperties();
@@ -1 +1 @@
1
- {"version":3,"names":["_compose","require","_element","_useOnValueUpdate","useAnimatedOffsetRect","container","rect","prefix","dataAttribute","transitionEndFilter","setProperties","useEvent","Object","keys","forEach","property","style","setProperty","String","useLayoutEffect","useOnValueUpdate","element","previousValue","setAttribute","onTransitionEnd","event","removeAttribute","addEventListener","removeEventListener"],"sources":["@wordpress/components/src/utils/hooks/use-animated-offset-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n\n/**\n * WordPress dependencies\n */\nimport { useEvent } from '@wordpress/compose';\nimport { useLayoutEffect } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport type { ElementOffsetRect } from '../element-rect';\nimport { useOnValueUpdate } from './use-on-value-update';\n\n/**\n * A utility used to animate something in a container component based on the \"offset\n * rect\" (position relative to the container and size) of a subelement. For example,\n * this is useful to render an indicator for the selected option of a component, and\n * to animate it when the selected option changes.\n *\n * Takes in a container element and the up-to-date \"offset rect\" of the target\n * subelement, obtained with `useTrackElementOffsetRect`. Then it does the following:\n *\n * - Adds CSS variables with rect information to the container, so that the indicator\n * can be rendered and animated with them. These are kept up-to-date, enabling CSS\n * transitions on change.\n * - Sets an attribute (`data-subelement-animated` by default) when the tracked\n * element changes, so that the target (e.g. the indicator) can be animated to its\n * new size and position.\n * - Removes the attribute when the animation is done.\n *\n * The need for the attribute is due to the fact that the rect might update in\n * situations other than when the tracked element changes, e.g. the tracked element\n * might be resized. In such cases, there is no need to animate the indicator, and\n * the change in size or position of the indicator needs to be reflected immediately.\n */\nexport function useAnimatedOffsetRect(\n\t/**\n\t * The container element.\n\t */\n\tcontainer: HTMLElement | undefined,\n\t/**\n\t * The rect of the tracked element.\n\t */\n\trect: ElementOffsetRect,\n\t{\n\t\tprefix = 'subelement',\n\t\tdataAttribute = `${ prefix }-animated`,\n\t\ttransitionEndFilter = () => true,\n\t}: {\n\t\t/**\n\t\t * The prefix used for the CSS variables, e.g. if `prefix` is `selected`, the\n\t\t * CSS variables will be `--selected-top`, `--selected-left`, etc.\n\t\t * @default 'subelement'\n\t\t */\n\t\tprefix?: string;\n\t\t/**\n\t\t * The name of the data attribute used to indicate that the animation is in\n\t\t * progress. The `data-` prefix is added automatically.\n\t\t *\n\t\t * For example, if `dataAttribute` is `indicator-animated`, the attribute will\n\t\t * be `data-indicator-animated`.\n\t\t * @default `${ prefix }-animated`\n\t\t */\n\t\tdataAttribute?: string;\n\t\t/**\n\t\t * A function that is called with the transition event and returns a boolean\n\t\t * indicating whether the animation should be stopped. The default is a function\n\t\t * that always returns `true`.\n\t\t *\n\t\t * For example, if the animated element is the `::before` pseudo-element, the\n\t\t * function can be written as `( event ) => event.pseudoElement === '::before'`.\n\t\t * @default () => true\n\t\t */\n\t\ttransitionEndFilter?: ( event: TransitionEvent ) => boolean;\n\t} = {}\n) {\n\tconst setProperties = useEvent( () => {\n\t\t( Object.keys( rect ) as Array< keyof typeof rect > ).forEach(\n\t\t\t( property ) =>\n\t\t\t\tproperty !== 'element' &&\n\t\t\t\tcontainer?.style.setProperty(\n\t\t\t\t\t`--${ prefix }-${ property }`,\n\t\t\t\t\tString( rect[ property ] )\n\t\t\t\t)\n\t\t);\n\t} );\n\tuseLayoutEffect( () => {\n\t\tsetProperties();\n\t}, [ rect, setProperties ] );\n\tuseOnValueUpdate( rect.element, ( { previousValue } ) => {\n\t\t// Only enable the animation when moving from one element to another.\n\t\tif ( rect.element && previousValue ) {\n\t\t\tcontainer?.setAttribute( `data-${ dataAttribute }`, '' );\n\t\t}\n\t} );\n\tuseLayoutEffect( () => {\n\t\tfunction onTransitionEnd( event: TransitionEvent ) {\n\t\t\tif ( transitionEndFilter( event ) ) {\n\t\t\t\tcontainer?.removeAttribute( `data-${ dataAttribute }` );\n\t\t\t}\n\t\t}\n\t\tcontainer?.addEventListener( 'transitionend', onTransitionEnd );\n\t\treturn () =>\n\t\t\tcontainer?.removeEventListener( 'transitionend', onTransitionEnd );\n\t}, [ dataAttribute, container, transitionEndFilter ] );\n}\n/* eslint-enable jsdoc/require-param */\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAF,OAAA;AAXA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,qBAAqBA;AACpC;AACD;AACA;AACCC,SAAkC;AAClC;AACD;AACA;AACCC,IAAuB,EACvB;EACCC,MAAM,GAAG,YAAY;EACrBC,aAAa,GAAG,GAAID,MAAM,WAAY;EACtCE,mBAAmB,GAAGA,CAAA,KAAM;AA2B7B,CAAC,GAAG,CAAC,CAAC,EACL;EACD,MAAMC,aAAa,GAAG,IAAAC,iBAAQ,EAAE,MAAM;IACnCC,MAAM,CAACC,IAAI,CAAEP,IAAK,CAAC,CAAiCQ,OAAO,CAC1DC,QAAQ,IACTA,QAAQ,KAAK,SAAS,IACtBV,SAAS,EAAEW,KAAK,CAACC,WAAW,CAC3B,KAAMV,MAAM,IAAMQ,QAAQ,EAAG,EAC7BG,MAAM,CAAEZ,IAAI,CAAES,QAAQ,CAAG,CAC1B,CACF,CAAC;EACF,CAAE,CAAC;EACH,IAAAI,wBAAe,EAAE,MAAM;IACtBT,aAAa,CAAC,CAAC;EAChB,CAAC,EAAE,CAAEJ,IAAI,EAAEI,aAAa,CAAG,CAAC;EAC5B,IAAAU,kCAAgB,EAAEd,IAAI,CAACe,OAAO,EAAE,CAAE;IAAEC;EAAc,CAAC,KAAM;IACxD;IACA,IAAKhB,IAAI,CAACe,OAAO,IAAIC,aAAa,EAAG;MACpCjB,SAAS,EAAEkB,YAAY,CAAE,QAASf,aAAa,EAAG,EAAE,EAAG,CAAC;IACzD;EACD,CAAE,CAAC;EACH,IAAAW,wBAAe,EAAE,MAAM;IACtB,SAASK,eAAeA,CAAEC,KAAsB,EAAG;MAClD,IAAKhB,mBAAmB,CAAEgB,KAAM,CAAC,EAAG;QACnCpB,SAAS,EAAEqB,eAAe,CAAE,QAASlB,aAAa,EAAI,CAAC;MACxD;IACD;IACAH,SAAS,EAAEsB,gBAAgB,CAAE,eAAe,EAAEH,eAAgB,CAAC;IAC/D,OAAO,MACNnB,SAAS,EAAEuB,mBAAmB,CAAE,eAAe,EAAEJ,eAAgB,CAAC;EACpE,CAAC,EAAE,CAAEhB,aAAa,EAAEH,SAAS,EAAEI,mBAAmB,CAAG,CAAC;AACvD;AACA","ignoreList":[]}
1
+ {"version":3,"names":["_compose","require","_element","_useOnValueUpdate","useAnimatedOffsetRect","container","rect","prefix","dataAttribute","transitionEndFilter","roundRect","setProperties","useEvent","Object","keys","forEach","property","style","setProperty","String","Math","floor","useLayoutEffect","useOnValueUpdate","element","previousValue","setAttribute","onTransitionEnd","event","removeAttribute","addEventListener","removeEventListener"],"sources":["@wordpress/components/src/utils/hooks/use-animated-offset-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n\n/**\n * WordPress dependencies\n */\nimport { useEvent } from '@wordpress/compose';\nimport { useLayoutEffect } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport type { ElementOffsetRect } from '../element-rect';\nimport { useOnValueUpdate } from './use-on-value-update';\n\n/**\n * A utility used to animate something in a container component based on the \"offset\n * rect\" (position relative to the container and size) of a subelement. For example,\n * this is useful to render an indicator for the selected option of a component, and\n * to animate it when the selected option changes.\n *\n * Takes in a container element and the up-to-date \"offset rect\" of the target\n * subelement, obtained with `useTrackElementOffsetRect`. Then it does the following:\n *\n * - Adds CSS variables with rect information to the container, so that the indicator\n * can be rendered and animated with them. These are kept up-to-date, enabling CSS\n * transitions on change.\n * - Sets an attribute (`data-subelement-animated` by default) when the tracked\n * element changes, so that the target (e.g. the indicator) can be animated to its\n * new size and position.\n * - Removes the attribute when the animation is done.\n *\n * The need for the attribute is due to the fact that the rect might update in\n * situations other than when the tracked element changes, e.g. the tracked element\n * might be resized. In such cases, there is no need to animate the indicator, and\n * the change in size or position of the indicator needs to be reflected immediately.\n */\nexport function useAnimatedOffsetRect(\n\t/**\n\t * The container element.\n\t */\n\tcontainer: HTMLElement | undefined,\n\t/**\n\t * The rect of the tracked element.\n\t */\n\trect: ElementOffsetRect,\n\t{\n\t\tprefix = 'subelement',\n\t\tdataAttribute = `${ prefix }-animated`,\n\t\ttransitionEndFilter = () => true,\n\t\troundRect = false,\n\t}: {\n\t\t/**\n\t\t * The prefix used for the CSS variables, e.g. if `prefix` is `selected`, the\n\t\t * CSS variables will be `--selected-top`, `--selected-left`, etc.\n\t\t * @default 'subelement'\n\t\t */\n\t\tprefix?: string;\n\t\t/**\n\t\t * The name of the data attribute used to indicate that the animation is in\n\t\t * progress. The `data-` prefix is added automatically.\n\t\t *\n\t\t * For example, if `dataAttribute` is `indicator-animated`, the attribute will\n\t\t * be `data-indicator-animated`.\n\t\t * @default `${ prefix }-animated`\n\t\t */\n\t\tdataAttribute?: string;\n\t\t/**\n\t\t * A function that is called with the transition event and returns a boolean\n\t\t * indicating whether the animation should be stopped. The default is a function\n\t\t * that always returns `true`.\n\t\t *\n\t\t * For example, if the animated element is the `::before` pseudo-element, the\n\t\t * function can be written as `( event ) => event.pseudoElement === '::before'`.\n\t\t * @default () => true\n\t\t */\n\t\ttransitionEndFilter?: ( event: TransitionEvent ) => boolean;\n\t\t/**\n\t\t * Whether the `rect` measurements should be rounded down when applied\n\t\t * to the CSS variables. This can be useful to avoid blurry animations or\n\t\t * to avoid subpixel rendering issues.\n\t\t * @default false\n\t\t */\n\t\troundRect?: boolean;\n\t} = {}\n) {\n\tconst setProperties = useEvent( () => {\n\t\t( Object.keys( rect ) as Array< keyof typeof rect > ).forEach(\n\t\t\t( property ) =>\n\t\t\t\tproperty !== 'element' &&\n\t\t\t\tcontainer?.style.setProperty(\n\t\t\t\t\t`--${ prefix }-${ property }`,\n\t\t\t\t\tString(\n\t\t\t\t\t\troundRect\n\t\t\t\t\t\t\t? Math.floor( rect[ property ] )\n\t\t\t\t\t\t\t: rect[ property ]\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t);\n\t} );\n\tuseLayoutEffect( () => {\n\t\tsetProperties();\n\t}, [ rect, setProperties ] );\n\tuseOnValueUpdate( rect.element, ( { previousValue } ) => {\n\t\t// Only enable the animation when moving from one element to another.\n\t\tif ( rect.element && previousValue ) {\n\t\t\tcontainer?.setAttribute( `data-${ dataAttribute }`, '' );\n\t\t}\n\t} );\n\tuseLayoutEffect( () => {\n\t\tfunction onTransitionEnd( event: TransitionEvent ) {\n\t\t\tif ( transitionEndFilter( event ) ) {\n\t\t\t\tcontainer?.removeAttribute( `data-${ dataAttribute }` );\n\t\t\t}\n\t\t}\n\t\tcontainer?.addEventListener( 'transitionend', onTransitionEnd );\n\t\treturn () =>\n\t\t\tcontainer?.removeEventListener( 'transitionend', onTransitionEnd );\n\t}, [ dataAttribute, container, transitionEndFilter ] );\n}\n/* eslint-enable jsdoc/require-param */\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAF,OAAA;AAXA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,qBAAqBA;AACpC;AACD;AACA;AACCC,SAAkC;AAClC;AACD;AACA;AACCC,IAAuB,EACvB;EACCC,MAAM,GAAG,YAAY;EACrBC,aAAa,GAAG,GAAID,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mBAAmB,CAAG,CAAC;AACvD;AACA","ignoreList":[]}
@@ -25,11 +25,9 @@ function useUpdateEffect(effect, deps) {
25
25
  }
26
26
  mountedRef.current = true;
27
27
  return undefined;
28
- // Disable reasons:
29
28
  // 1. This hook needs to pass a dep list that isn't an array literal
30
29
  // 2. `effect` is missing from the array, and will need to be added carefully to avoid additional warnings
31
30
  // see https://github.com/WordPress/gutenberg/pull/41166
32
- // eslint-disable-next-line react-hooks/exhaustive-deps
33
31
  }, deps);
34
32
  (0, _element.useEffect)(() => () => {
35
33
  mountedRef.current = false;
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","useUpdateEffect","effect","deps","mountedRef","useRef","useEffect","current","undefined","_default","exports","default"],"sources":["@wordpress/components/src/utils/hooks/use-update-effect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\n\n/**\n * A `React.useEffect` that will not run on the first render.\n * Source:\n * https://github.com/ariakit/ariakit/blob/main/packages/ariakit-react-core/src/utils/hooks.ts\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mountedRef = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mountedRef.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmountedRef.current = true;\n\t\treturn undefined;\n\t\t// Disable reasons:\n\t\t// 1. This hook needs to pass a dep list that isn't an array literal\n\t\t// 2. `effect` is missing from the array, and will need to be added carefully to avoid additional warnings\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, deps );\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tmountedRef.current = false;\n\t\t},\n\t\t[]\n\t);\n}\n\nexport default useUpdateEffect;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAEC,MAAM,EAAEC,IAAI,EAAG;EACxC,MAAMC,UAAU,GAAG,IAAAC,eAAM,EAAE,KAAM,CAAC;EAClC,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKF,UAAU,CAACG,OAAO,EAAG;MACzB,OAAOL,MAAM,CAAC,CAAC;IAChB;IACAE,UAAU,CAACG,OAAO,GAAG,IAAI;IACzB,OAAOC,SAAS;IAChB;IACA;IACA;IACA;IACA;EACD,CAAC,EAAEL,IAAK,CAAC;EAET,IAAAG,kBAAS,EACR,MAAM,MAAM;IACXF,UAAU,CAACG,OAAO,GAAG,KAAK;EAC3B,CAAC,EACD,EACD,CAAC;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcV,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","useUpdateEffect","effect","deps","mountedRef","useRef","useEffect","current","undefined","_default","exports","default"],"sources":["@wordpress/components/src/utils/hooks/use-update-effect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\n\n/**\n * A `React.useEffect` that will not run on the first render.\n * Source:\n * https://github.com/ariakit/ariakit/blob/main/packages/ariakit-react-core/src/utils/hooks.ts\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mountedRef = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mountedRef.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmountedRef.current = true;\n\t\treturn undefined;\n\t\t// 1. This hook needs to pass a dep list that isn't an array literal\n\t\t// 2. `effect` is missing from the array, and will need to be added carefully to avoid additional warnings\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t}, deps );\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tmountedRef.current = false;\n\t\t},\n\t\t[]\n\t);\n}\n\nexport default useUpdateEffect;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAEC,MAAM,EAAEC,IAAI,EAAG;EACxC,MAAMC,UAAU,GAAG,IAAAC,eAAM,EAAE,KAAM,CAAC;EAClC,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKF,UAAU,CAACG,OAAO,EAAG;MACzB,OAAOL,MAAM,CAAC,CAAC;IAChB;IACAE,UAAU,CAACG,OAAO,GAAG,IAAI;IACzB,OAAOC,SAAS;IAChB;IACA;IACA;EACD,CAAC,EAAEL,IAAK,CAAC;EAET,IAAAG,kBAAS,EACR,MAAM,MAAM;IACXF,UAAU,CAACG,OAAO,GAAG,KAAK;EAC3B,CAAC,EACD,EACD,CAAC;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcV,eAAe","ignoreList":[]}
@@ -103,9 +103,8 @@ export function getAutoCompleterUI(autocompleter) {
103
103
  useLayoutEffect(() => {
104
104
  onChangeOptions(items);
105
105
  announce(items);
106
- // Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.
106
+ // We want to avoid introducing unexpected side effects.
107
107
  // See https://github.com/WordPress/gutenberg/pull/41820
108
- // eslint-disable-next-line react-hooks/exhaustive-deps
109
108
  }, [items]);
110
109
  if (items.length === 0) {
111
110
  return null;
@@ -154,9 +153,6 @@ function useOnClickOutside(ref, handler) {
154
153
  document.removeEventListener('mousedown', listener);
155
154
  document.removeEventListener('touchstart', listener);
156
155
  };
157
- // Disable reason: `ref` is a ref object and should not be included in a
158
- // hook's dependency list.
159
- // eslint-disable-next-line react-hooks/exhaustive-deps
160
- }, [handler]);
156
+ }, [handler, ref]);
161
157
  }
162
158
  //# sourceMappingURL=autocompleter-ui.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","useLayoutEffect","useRef","useEffect","useState","useAnchor","useDebounce","useMergeRefs","useRefEffect","speak","__","_n","sprintf","getDefaultUseItems","Button","Popover","VisuallyHidden","createPortal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ListBox","items","onSelect","selectedIndex","instanceId","listBoxId","className","Component","id","role","children","map","option","index","key","accessibleWhenDisabled","disabled","isDisabled","variant","undefined","onClick","label","getAutoCompleterUI","autocompleter","_autocompleter$useIte","useItems","AutocompleterUI","filterValue","onChangeOptions","onReset","reset","contentRef","popoverAnchor","editableContentElement","current","needsA11yCompat","setNeedsA11yCompat","popoverRef","popoverRefs","node","ownerDocument","useOnClickOutside","debouncedSpeak","announce","options","length","focusOnMount","onClose","placement","anchor","ref","body","handler","listener","event","contains","target","document","addEventListener","removeEventListener"],"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\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 { useDebounce, useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { __, _n, sprintf } from '@wordpress/i18n';\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, KeyedOption, WPCompleter } from './types';\n\ntype ListBoxProps = {\n\titems: KeyedOption[];\n\tonSelect: ( option: KeyedOption ) => void;\n\tselectedIndex: number;\n\tinstanceId: number;\n\tlistBoxId: string | undefined;\n\tclassName?: string;\n\tComponent?: React.ElementType;\n};\n\nfunction ListBox( {\n\titems,\n\tonSelect,\n\tselectedIndex,\n\tinstanceId,\n\tlistBoxId,\n\tclassName,\n\tComponent = 'div',\n}: ListBoxProps ) {\n\treturn (\n\t\t<Component\n\t\t\tid={ listBoxId }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"components-autocomplete__results\"\n\t\t>\n\t\t\t{ items.map( ( option, index ) => (\n\t\t\t\t<Button\n\t\t\t\t\tkey={ option.key }\n\t\t\t\t\tid={ `components-autocomplete-item-${ instanceId }-${ option.key }` }\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\taria-selected={ index === selectedIndex }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ option.isDisabled }\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'components-autocomplete__result',\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Unused, for backwards compatibility.\n\t\t\t\t\t\t\t'is-selected': index === selectedIndex,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tvariant={ index === selectedIndex ? 'primary' : undefined }\n\t\t\t\t\tonClick={ () => onSelect( option ) }\n\t\t\t\t>\n\t\t\t\t\t{ option.label }\n\t\t\t\t</Button>\n\t\t\t) ) }\n\t\t</Component>\n\t);\n}\n\nexport function getAutoCompleterUI( autocompleter: WPCompleter ) {\n\tconst useItems =\n\t\tautocompleter.useItems ?? 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 ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\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 aria-* 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\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\t\tfunction announce( options: Array< KeyedOption > ) {\n\t\t\tif ( ! debouncedSpeak ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( !! options.length ) {\n\t\t\t\tif ( filterValue ) {\n\t\t\t\t\tdebouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tdebouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Initial %d result loaded. Type to filter all available results. Use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'Initial %d results loaded. Type to filter all available results. Use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t\t}\n\t\t}\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tannounce( 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\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\t\titems={ items }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t/>\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\n\t\t\t\t\t\t\titems={ items }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tComponent={ VisuallyHidden }\n\t\t\t\t\t\t/>,\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"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,eAAe,EACfC,MAAM,EACNC,SAAS,EACTC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,WAAW,EAAEC,YAAY,EAAEC,YAAY,QAAQ,oBAAoB;AAC5E,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAEjD;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,OAAO,MAAM,YAAY;AAChC,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,YAAY,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAazC,SAASC,OAAOA,CAAE;EACjBC,KAAK;EACLC,QAAQ;EACRC,aAAa;EACbC,UAAU;EACVC,SAA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,CAAED,KAAK,CAACE,MAAe,CAAC,EAC3C;QACD;MACD;MACAJ,OAAO,CAAEE,KAAM,CAAC;IACjB,CAAC;IACDG,QAAQ,CAACC,gBAAgB,CAAE,WAAW,EAAEL,QAAS,CAAC;IAClDI,QAAQ,CAACC,gBAAgB,CAAE,YAAY,EAAEL,QAAS,CAAC;IACnD,OAAO,MAAM;MACZI,QAAQ,CAACE,mBAAmB,CAAE,WAAW,EAAEN,QAAS,CAAC;MACrDI,QAAQ,CAACE,mBAAmB,CAAE,YAAY,EAAEN,QAAS,CAAC;IACvD,CAAC;IACD;IACA;IACA;EACD,CAAC,EAAE,CAAED,OAAO,CAAG,CAAC;AACjB","ignoreList":[]}
1
+ {"version":3,"names":["clsx","useLayoutEffect","useRef","useEffect","useState","useAnchor","useDebounce","useMergeRefs","useRefEffect","speak","__","_n","sprintf","getDefaultUseItems","Button","Popover","VisuallyHidden","createPortal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ListBox","items","onSelect","selectedIndex","instanceId","listBoxId","className","Component","id","role","children","map","option","index","key","accessibleWhenDisabled","disabled","isDisabled","variant","undefined","onClick","label","getAutoCompleterUI","autocompleter","_autocompleter$useIte","useItems","AutocompleterUI","filterValue","onChangeOptions","onReset","reset","contentRef","popoverAnchor","editableContentElement","current","needsA11yCompat","setNeedsA11yCompat","popoverRef","popoverRefs","node","ownerDocument","useOnClickOutside","debouncedSpeak","announce","options","length","focusOnMount","onClose","placement","anchor","ref","body","handler","listener","event","contains","target","document","addEventListener","removeEventListener"],"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\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 { useDebounce, useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { __, _n, sprintf } from '@wordpress/i18n';\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, KeyedOption, WPCompleter } from './types';\n\ntype ListBoxProps = {\n\titems: KeyedOption[];\n\tonSelect: ( option: KeyedOption ) => void;\n\tselectedIndex: number;\n\tinstanceId: number;\n\tlistBoxId: string | undefined;\n\tclassName?: string;\n\tComponent?: React.ElementType;\n};\n\nfunction ListBox( {\n\titems,\n\tonSelect,\n\tselectedIndex,\n\tinstanceId,\n\tlistBoxId,\n\tclassName,\n\tComponent = 'div',\n}: ListBoxProps ) {\n\treturn (\n\t\t<Component\n\t\t\tid={ listBoxId }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"components-autocomplete__results\"\n\t\t>\n\t\t\t{ items.map( ( option, index ) => (\n\t\t\t\t<Button\n\t\t\t\t\tkey={ option.key }\n\t\t\t\t\tid={ `components-autocomplete-item-${ instanceId }-${ option.key }` }\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\taria-selected={ index === selectedIndex }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ option.isDisabled }\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'components-autocomplete__result',\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Unused, for backwards compatibility.\n\t\t\t\t\t\t\t'is-selected': index === selectedIndex,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tvariant={ index === selectedIndex ? 'primary' : undefined }\n\t\t\t\t\tonClick={ () => onSelect( option ) }\n\t\t\t\t>\n\t\t\t\t\t{ option.label }\n\t\t\t\t</Button>\n\t\t\t) ) }\n\t\t</Component>\n\t);\n}\n\nexport function getAutoCompleterUI( autocompleter: WPCompleter ) {\n\tconst useItems =\n\t\tautocompleter.useItems ?? 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 ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\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 aria-* 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\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\t\tfunction announce( options: Array< KeyedOption > ) {\n\t\t\tif ( ! debouncedSpeak ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( !! options.length ) {\n\t\t\t\tif ( filterValue ) {\n\t\t\t\t\tdebouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tdebouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Initial %d result loaded. Type to filter all available results. Use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'Initial %d results loaded. Type to filter all available results. Use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t\t}\n\t\t}\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tannounce( items );\n\t\t\t// We want to avoid introducing unexpected side effects.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t}, [ items ] );\n\n\t\tif ( items.length === 0 ) {\n\t\t\treturn null;\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\t\titems={ items }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t/>\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\n\t\t\t\t\t\t\titems={ items }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tComponent={ VisuallyHidden }\n\t\t\t\t\t\t/>,\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}, [ handler, ref ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,eAAe,EACfC,MAAM,EACNC,SAAS,EACTC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,WAAW,EAAEC,YAAY,EAAEC,YAAY,QAAQ,oBAAoB;AAC5E,SAASC,KAAK,QAAQ,iBAAiB;AAC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;QACzBC,SAAS,EAAGA,SAAW;QACvBC,SAAS,EAAGA,SAAW;QACvBC,SAAS,EAAGf;MAAgB,CAC5B,CAAC,EACFuC,UAAU,CAACG,OAAO,CAACM,aAAa,CAACW,IAClC,CAAC;IAAA,CACD,CAAC;EAEL;EAEA,OAAOzB,eAAe;AACvB;AAEA,SAASe,iBAAiBA,CACzBS,GAAmC,EACnCE,OAAwC,EACvC;EACDzE,SAAS,CAAE,MAAM;IAChB,MAAM0E,QAAQ,GAAKC,KAA8B,IAAM;MACtD;MACA,IACC,CAAEJ,GAAG,CAAChB,OAAO,IACbgB,GAAG,CAAChB,OAAO,CAACqB,QAAQ,CAAED,KAAK,CAACE,MAAe,CAAC,EAC3C;QACD;MACD;MACAJ,OAAO,CAAEE,KAAM,CAAC;IACjB,CAAC;IACDG,QAAQ,CAACC,gBAAgB,CAAE,WAAW,EAAEL,QAAS,CAAC;IAClDI,QAAQ,CAACC,gBAAgB,CAAE,YAAY,EAAEL,QAAS,CAAC;IACnD,OAAO,MAAM;MACZI,QAAQ,CAACE,mBAAmB,CAAE,WAAW,EAAEN,QAAS,CAAC;MACrDI,QAAQ,CAACE,mBAAmB,CAAE,YAAY,EAAEN,QAAS,CAAC;IACvD,CAAC;EACF,CAAC,EAAE,CAAED,OAAO,EAAEF,GAAG,CAAG,CAAC;AACtB","ignoreList":[]}
@@ -56,9 +56,8 @@ export function getAutoCompleterUI(autocompleter) {
56
56
  } else if (isVisible && text.length === 0) {
57
57
  startAnimation(false);
58
58
  }
59
- // Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.
59
+ // We want to avoid introducing unexpected side effects.
60
60
  // See https://github.com/WordPress/gutenberg/pull/41820
61
- // eslint-disable-next-line react-hooks/exhaustive-deps
62
61
  }, [items, isVisible, text]);
63
62
  const activeItemStyles = usePreferredColorSchemeStyle(styles['components-autocomplete__item-active'], styles['components-autocomplete__item-active-dark']);
64
63
  const iconStyles = usePreferredColorSchemeStyle(styles['components-autocomplete__icon'], styles['components-autocomplete__icon-active-dark']);
@@ -79,9 +78,8 @@ export function getAutoCompleterUI(autocompleter) {
79
78
  }
80
79
  });
81
80
  },
82
- // Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.
81
+ // We want to avoid introducing unexpected side effects.
83
82
  // See https://github.com/WordPress/gutenberg/pull/41820
84
- // eslint-disable-next-line react-hooks/exhaustive-deps
85
83
  [isVisible]);
86
84
  const contentStyles = {
87
85
  transform: [{
@@ -1 +1 @@
1
- {"version":3,"names":["View","Animated","StyleSheet","Text","TouchableOpacity","ScrollView","useLayoutEffect","useEffect","useRef","useState","useCallback","__","sprintf","usePreferredColorSchemeStyle","BackgroundView","getDefaultUseItems","styles","Icon","__unstableAutocompletionItemsFill","AutocompletionItemsFill","jsx","_jsx","jsxs","_jsxs","compose","stylesCompose","getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","selectedIndex","onChangeOptions","onSelect","value","reset","items","filteredItems","filter","item","isDisabled","scrollViewRef","animationValue","Value","current","isVisible","setIsVisible","text","length","scrollTo","x","animated","startAnimation","activeItemStyles","iconStyles","activeIconStyles","textStyles","activeTextStyles","show","timing","toValue","duration","useNativeDriver","start","finished","contentStyles","transform","translateY","interpolate","inputRange","outputRange","height","children","style","testID","ref","horizontal","contentContainerStyle","showsHorizontalScrollIndicator","keyboardShouldPersistTaps","accessibilityLabel","map","option","index","isActive","itemStyle","textStyle","iconStyle","iconSource","icon","src","activeOpacity","onPress","title","size"],"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tAnimated,\n\tStyleSheet,\n\tText,\n\tTouchableOpacity,\n\tScrollView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackgroundView from './background-view';\nimport getDefaultUseItems from './get-default-use-items';\nimport styles from './style.scss';\nimport Icon from '../icon';\nimport { __unstableAutocompletionItemsFill as AutocompletionItemsFill } from '../mobile/autocompletion-items';\n\nconst { compose: stylesCompose } = StyleSheet;\n\nexport function getAutoCompleterUI( autocompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tvalue,\n\t\treset,\n\t} ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst filteredItems = items.filter( ( item ) => ! item.isDisabled );\n\t\tconst scrollViewRef = useRef();\n\t\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\t\tconst [ isVisible, setIsVisible ] = useState( false );\n\t\tconst { text } = value;\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! isVisible && text.length > 0 ) {\n\t\t\t\tsetIsVisible( true );\n\t\t\t}\n\t\t}, [ isVisible, text ] );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tscrollViewRef.current?.scrollTo( { x: 0, animated: false } );\n\n\t\t\tif ( isVisible && text.length > 0 ) {\n\t\t\t\tstartAnimation( true );\n\t\t\t} else if ( isVisible && text.length === 0 ) {\n\t\t\t\tstartAnimation( false );\n\t\t\t}\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, isVisible, text ] );\n\n\t\tconst activeItemStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__item-active' ],\n\t\t\tstyles[ 'components-autocomplete__item-active-dark' ]\n\t\t);\n\n\t\tconst iconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst activeIconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon-active ' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst textStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text' ],\n\t\t\tstyles[ 'components-autocomplete__text-dark' ]\n\t\t);\n\n\t\tconst activeTextStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text-active' ],\n\t\t\tstyles[ 'components-autocomplete__text-active-dark' ]\n\t\t);\n\n\t\tconst startAnimation = useCallback(\n\t\t\t( show ) => {\n\t\t\t\tAnimated.timing( animationValue, {\n\t\t\t\t\ttoValue: show ? 1 : 0,\n\t\t\t\t\tduration: show ? 200 : 100,\n\t\t\t\t\tuseNativeDriver: true,\n\t\t\t\t} ).start( ( { finished } ) => {\n\t\t\t\t\tif ( finished && ! show && isVisible ) {\n\t\t\t\t\t\tsetIsVisible( false );\n\t\t\t\t\t\treset();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\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\t[ isVisible ]\n\t\t);\n\n\t\tconst contentStyles = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [\n\t\t\t\t\t\t\tstyles[ 'components-autocomplete' ].height,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tif ( ! filteredItems.length > 0 || ! isVisible ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<AutocompletionItemsFill>\n\t\t\t\t<View style={ styles[ 'components-autocomplete' ] }>\n\t\t\t\t\t<Animated.View style={ contentStyles }>\n\t\t\t\t\t\t<BackgroundView>\n\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\ttestID=\"autocompleter\"\n\t\t\t\t\t\t\t\tref={ scrollViewRef }\n\t\t\t\t\t\t\t\thorizontal\n\t\t\t\t\t\t\t\tcontentContainerStyle={\n\t\t\t\t\t\t\t\t\tstyles[ 'components-autocomplete__content' ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\t\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\t\t\t\t\taccessibilityLabel={\n\t\t\t\t\t\t\t\t\t// translators: Slash inserter autocomplete results\n\t\t\t\t\t\t\t\t\t__( 'Slash inserter results' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ filteredItems.map( ( option, index ) => {\n\t\t\t\t\t\t\t\t\tconst isActive = index === selectedIndex;\n\t\t\t\t\t\t\t\t\tconst itemStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__item'\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tisActive && activeItemStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst textStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ttextStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeTextStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ticonStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeIconStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconSource =\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon?.src ||\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon;\n\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\t\t\t\t\tstyle={ itemStyle }\n\t\t\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\t\t\tonPress={ () => onSelect( option ) }\n\t\t\t\t\t\t\t\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Block name e.g. \"Image block\"\n\t\t\t\t\t\t\t\t\t\t\t\t__( '%s block' ),\n\t\t\t\t\t\t\t\t\t\t\t\toption?.value?.title\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__icon'\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ iconSource }\n\t\t\t\t\t\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={ iconStyle }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t\t\t<Text style={ textStyle }>\n\t\t\t\t\t\t\t\t\t\t\t\t{ option?.value?.title }\n\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t</TouchableOpacity>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t</ScrollView>\n\t\t\t\t\t\t</BackgroundView>\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</AutocompletionItemsFill>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n\nexport default getAutoCompleterUI;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,QACJ,cAAc;;AAErB;AACA;AACA;AACA,SACCC,eAAe,EACfC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,WAAW,QACL,oBAAoB;AAC3B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,4BAA4B,QAAQ,oBAAoB;;AAEjE;AACA;AACA;AACA,OAAOC,cAAc,MAAM,mBAAmB;AAC9C,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,MAAM,MAAM,cAAc;AACjC,OAAOC,IAAI,MAAM,SAAS;AAC1B,SAASC,iCAAiC,IAAIC,uBAAuB,QAAQ,gCAAgC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9G,MAAM;EAAEC,OAAO,EAAEC;AAAc,CAAC,GAAGvB,UAAU;AAE7C,OAAO,SAASwB,kBAAkBA,CAAEC,aAAa,EAAG;EACnD,MAAMC,QAAQ,GAAGD,aAAa,CAACC,QAAQ,GACpCD,aAAa,CAACC,QAAQ,GACtBb,kBAAkB,CAAEY,aAAc,CAAC;EAEtC,SAASE,eAAeA,CAAE;IACzBC,WAAW;IACXC,aAAa;IACbC,eAAe;IACfC,QAAQ;IACRC,KAAK;IACLC;EACD,CAAC,EAAG;IACH,MAAM,CAAEC,KAAK,CAAE,GAAGR,QAAQ,CAAEE,WAAY,CAAC;IACzC,MAAMO,aAAa,GAAGD,KAAK,CAACE,MAAM,CAAI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AG;kBAAArB,QAAA,gBAEHnD,IAAA,CAACrB,IAAI;oBACJyE,KAAK,EACJzD,MAAM,CACL,+BAA+B,CAEhC;oBAAAwD,QAAA,eAEDnD,IAAA,CAACJ,IAAI;sBACJwE,IAAI,EAAGD,UAAY;sBACnBM,IAAI,EAAG,EAAI;sBACXrB,KAAK,EAAGc;oBAAW,CACnB;kBAAC,CACG,CAAC,eACPlE,IAAA,CAAClB,IAAI;oBAACsE,KAAK,EAAGa,SAAW;oBAAAd,QAAA,EACtBU,MAAM,EAAEhD,KAAK,EAAE2D;kBAAK,CACjB,CAAC;gBAAA,GAvBDV,KAwBW,CAAC;cAErB,CAAE;YAAC,CACQ;UAAC,CACE;QAAC,CACH;MAAC,CACX;IAAC,CACiB,CAAC;EAE5B;EAEA,OAAOtD,eAAe;AACvB;AAEA,eAAeH,kBAAkB","ignoreList":[]}
1
+ {"version":3,"names":["View","Animated","StyleSheet","Text","TouchableOpacity","ScrollView","useLayoutEffect","useEffect","useRef","useState","useCallback","__","sprintf","usePreferredColorSchemeStyle","BackgroundView","getDefaultUseItems","styles","Icon","__unstableAutocompletionItemsFill","AutocompletionItemsFill","jsx","_jsx","jsxs","_jsxs","compose","stylesCompose","getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","selectedIndex","onChangeOptions","onSelect","value","reset","items","filteredItems","filter","item","isDisabled","scrollViewRef","animationValue","Value","current","isVisible","setIsVisible","text","length","scrollTo","x","animated","startAnimation","activeItemStyles","iconStyles","activeIconStyles","textStyles","activeTextStyles","show","timing","toValue","duration","useNativeDriver","start","finished","contentStyles","transform","translateY","interpolate","inputRange","outputRange","height","children","style","testID","ref","horizontal","contentContainerStyle","showsHorizontalScrollIndicator","keyboardShouldPersistTaps","accessibilityLabel","map","option","index","isActive","itemStyle","textStyle","iconStyle","iconSource","icon","src","activeOpacity","onPress","title","size"],"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tAnimated,\n\tStyleSheet,\n\tText,\n\tTouchableOpacity,\n\tScrollView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackgroundView from './background-view';\nimport getDefaultUseItems from './get-default-use-items';\nimport styles from './style.scss';\nimport Icon from '../icon';\nimport { __unstableAutocompletionItemsFill as AutocompletionItemsFill } from '../mobile/autocompletion-items';\n\nconst { compose: stylesCompose } = StyleSheet;\n\nexport function getAutoCompleterUI( autocompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tvalue,\n\t\treset,\n\t} ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst filteredItems = items.filter( ( item ) => ! item.isDisabled );\n\t\tconst scrollViewRef = useRef();\n\t\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\t\tconst [ isVisible, setIsVisible ] = useState( false );\n\t\tconst { text } = value;\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! isVisible && text.length > 0 ) {\n\t\t\t\tsetIsVisible( true );\n\t\t\t}\n\t\t}, [ isVisible, text ] );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tscrollViewRef.current?.scrollTo( { x: 0, animated: false } );\n\n\t\t\tif ( isVisible && text.length > 0 ) {\n\t\t\t\tstartAnimation( true );\n\t\t\t} else if ( isVisible && text.length === 0 ) {\n\t\t\t\tstartAnimation( false );\n\t\t\t}\n\t\t\t// We want to avoid introducing unexpected side effects.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t}, [ items, isVisible, text ] );\n\n\t\tconst activeItemStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__item-active' ],\n\t\t\tstyles[ 'components-autocomplete__item-active-dark' ]\n\t\t);\n\n\t\tconst iconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst activeIconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon-active ' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst textStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text' ],\n\t\t\tstyles[ 'components-autocomplete__text-dark' ]\n\t\t);\n\n\t\tconst activeTextStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text-active' ],\n\t\t\tstyles[ 'components-autocomplete__text-active-dark' ]\n\t\t);\n\n\t\tconst startAnimation = useCallback(\n\t\t\t( show ) => {\n\t\t\t\tAnimated.timing( animationValue, {\n\t\t\t\t\ttoValue: show ? 1 : 0,\n\t\t\t\t\tduration: show ? 200 : 100,\n\t\t\t\t\tuseNativeDriver: true,\n\t\t\t\t} ).start( ( { finished } ) => {\n\t\t\t\t\tif ( finished && ! show && isVisible ) {\n\t\t\t\t\t\tsetIsVisible( false );\n\t\t\t\t\t\treset();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t// We want to avoid introducing unexpected side effects.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t\t[ isVisible ]\n\t\t);\n\n\t\tconst contentStyles = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [\n\t\t\t\t\t\t\tstyles[ 'components-autocomplete' ].height,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tif ( ! filteredItems.length > 0 || ! isVisible ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<AutocompletionItemsFill>\n\t\t\t\t<View style={ styles[ 'components-autocomplete' ] }>\n\t\t\t\t\t<Animated.View style={ contentStyles }>\n\t\t\t\t\t\t<BackgroundView>\n\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\ttestID=\"autocompleter\"\n\t\t\t\t\t\t\t\tref={ scrollViewRef }\n\t\t\t\t\t\t\t\thorizontal\n\t\t\t\t\t\t\t\tcontentContainerStyle={\n\t\t\t\t\t\t\t\t\tstyles[ 'components-autocomplete__content' ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\t\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\t\t\t\t\taccessibilityLabel={\n\t\t\t\t\t\t\t\t\t// translators: Slash inserter autocomplete results\n\t\t\t\t\t\t\t\t\t__( 'Slash inserter results' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ filteredItems.map( ( option, index ) => {\n\t\t\t\t\t\t\t\t\tconst isActive = index === selectedIndex;\n\t\t\t\t\t\t\t\t\tconst itemStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__item'\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tisActive && activeItemStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst textStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ttextStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeTextStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ticonStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeIconStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconSource =\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon?.src ||\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon;\n\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\t\t\t\t\tstyle={ itemStyle }\n\t\t\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\t\t\tonPress={ () => onSelect( option ) }\n\t\t\t\t\t\t\t\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Block name e.g. \"Image block\"\n\t\t\t\t\t\t\t\t\t\t\t\t__( '%s block' ),\n\t\t\t\t\t\t\t\t\t\t\t\toption?.value?.title\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__icon'\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ iconSource }\n\t\t\t\t\t\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={ iconStyle }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t\t\t<Text style={ textStyle }>\n\t\t\t\t\t\t\t\t\t\t\t\t{ option?.value?.title }\n\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t</TouchableOpacity>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t</ScrollView>\n\t\t\t\t\t\t</BackgroundView>\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</AutocompletionItemsFill>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n\nexport default getAutoCompleterUI;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,QACJ,cAAc;;AAErB;AACA;AACA;AACA,SACCC,eAAe,EACfC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,WAAW,QACL,oBAAoB;AAC3B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,4BAA4B,QAAQ,oBAAoB;;AAEjE;AACA;AACA;AACA,OAAOC,cAAc,MAAM,mBAAmB;AAC9C,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,MAAM,MAAM,cAAc;AACjC,OAAOC,IAAI,MAAM,SAAS;AAC1B,SAASC,iCAAiC,IAAIC,uBAAuB,QAAQ,gCAAgC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9G,MAAM;EAAEC,OAAO,EAAEC;AAAc,CAAC,GAAGvB,UAAU;AAE7C,OAAO,SAASwB,kBAAkBA,CAAEC,aAAa,EAAG;EACnD,MAAMC,QAAQ,GAAGD,aAAa,CAACC,QAAQ,GACpCD,aAAa,CAACC,QAAQ,GACtBb,kBAAkB,CAAEY,aAAc,CAAC;EAEtC,SAASE,eAAeA,CAAE;IACzBC,WAAW;IACXC,aAAa;IACbC,eAAe;IACfC,QAAQ;IACRC,KAAK;IACLC;EAC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;kBACpCF,kBAAkB,EAAGpE,OAAO;kBAC3B;kBACAD,EAAE,CAAE,UAAW,CAAC,EAChBuE,MAAM,EAAEhD,KAAK,EAAE2D,KAChB,CAAG;kBAAArB,QAAA,gBAEHnD,IAAA,CAACrB,IAAI;oBACJyE,KAAK,EACJzD,MAAM,CACL,+BAA+B,CAEhC;oBAAAwD,QAAA,eAEDnD,IAAA,CAACJ,IAAI;sBACJwE,IAAI,EAAGD,UAAY;sBACnBM,IAAI,EAAG,EAAI;sBACXrB,KAAK,EAAGc;oBAAW,CACnB;kBAAC,CACG,CAAC,eACPlE,IAAA,CAAClB,IAAI;oBAACsE,KAAK,EAAGa,SAAW;oBAAAd,QAAA,EACtBU,MAAM,EAAEhD,KAAK,EAAE2D;kBAAK,CACjB,CAAC;gBAAA,GAvBDV,KAwBW,CAAC;cAErB,CAAE;YAAC,CACQ;UAAC,CACE;QAAC,CACH;MAAC,CACX;IAAC,CACiB,CAAC;EAE5B;EAEA,OAAOtD,eAAe;AACvB;AAEA,eAAeH,kBAAkB","ignoreList":[]}
@@ -64,7 +64,7 @@ export function useAutocomplete({
64
64
  const [filterValue, setFilterValue] = useState('');
65
65
  const [autocompleter, setAutocompleter] = useState(null);
66
66
  const [AutocompleterUI, setAutocompleterUI] = useState(null);
67
- const backspacing = useRef(false);
67
+ const backspacingRef = useRef(false);
68
68
  function insertCompletion(replacement) {
69
69
  if (autocompleter === null) {
70
70
  return;
@@ -124,7 +124,7 @@ export function useAutocomplete({
124
124
  setFilteredOptions(options);
125
125
  }
126
126
  function handleKeyDown(event) {
127
- backspacing.current = event.key === 'Backspace';
127
+ backspacingRef.current = event.key === 'Backspace';
128
128
  if (!autocompleter) {
129
129
  return;
130
130
  }
@@ -239,7 +239,7 @@ export function useAutocomplete({
239
239
  //
240
240
  // Ex: "Some text @marcelo sekkkk" <--- "kkkk" caused a mismatch, but
241
241
  // if the user presses backspace here, it will show the completion popup again.
242
- const matchingWhileBackspacing = backspacing.current && wordsFromTrigger.length <= 3;
242
+ const matchingWhileBackspacing = backspacingRef.current && wordsFromTrigger.length <= 3;
243
243
  if (mismatch && !(matchingWhileBackspacing || hasOneTriggerWord)) {
244
244
  if (autocompleter) {
245
245
  reset();
@@ -272,9 +272,8 @@ export function useAutocomplete({
272
272
  setAutocompleter(completer);
273
273
  setAutocompleterUI(() => completer !== autocompleter ? getAutoCompleterUI(completer) : AutocompleterUI);
274
274
  setFilterValue(query === null ? '' : query);
275
- // Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.
275
+ // We want to avoid introducing unexpected side effects.
276
276
  // See https://github.com/WordPress/gutenberg/pull/41820
277
- // eslint-disable-next-line react-hooks/exhaustive-deps
278
277
  }, [textContent]);
279
278
  const {
280
279
  key: selectedKey = ''
@@ -1 +1 @@
1
- {"version":3,"names":["removeAccents","renderToString","useEffect","useState","useRef","useMemo","useInstanceId","useMergeRefs","useRefEffect","create","slice","insert","isCollapsed","getTextContent","speak","isAppleOS","getAutoCompleterUI","escapeRegExp","withIgnoreIMEEvents","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","getNodeText","node","toString","Array","map","join","props","children","EMPTY_FILTERED_OPTIONS","AUTOCOMPLETE_HOOK_REFERENCE","useAutocomplete","record","onChange","onReplace","completers","contentRef","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","onChangeOptions","options","handleKeyDown","event","current","key","defaultPrevented","newIndex","label","preventDefault","textContent","completer","reduce","lastTrigger","currentCompleter","triggerIndex","lastIndexOf","lastTriggerIndex","allowContext","textWithoutTrigger","tooDistantFromTrigger","mismatch","wordsFromTrigger","split","hasOneTriggerWord","matchingWhileBackspacing","textAfterSelection","test","safeTrigger","text","match","RegExp","query","selectedKey","className","isExpanded","listBoxId","activeId","hasSelection","onKeyDown","popover","onSelect","useLastDifferentValue","history","Set","add","size","delete","from","useAutocompleteProps","ref","onKeyDownRef","previousRecord","mergedRefs","element","_onKeyDown","addEventListener","removeEventListener","didUserInput","Autocomplete","isSelected"],"sources":["@wordpress/components/src/autocomplete/index.tsx"],"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 { useInstanceId, useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport {\n\tcreate,\n\tslice,\n\tinsert,\n\tisCollapsed,\n\tgetTextContent,\n} from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { getAutoCompleterUI } from './autocompleter-ui';\nimport { escapeRegExp } from '../utils/strings';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport type {\n\tAutocompleteProps,\n\tAutocompleterUIProps,\n\tInsertOption,\n\tKeyedOption,\n\tOptionCompletion,\n\tReplaceOption,\n\tUseAutocompleteProps,\n\tWPCompleter,\n} from './types';\n\nconst getNodeText = ( node: React.ReactNode ): string => {\n\tif ( node === null ) {\n\t\treturn '';\n\t}\n\n\tswitch ( typeof node ) {\n\t\tcase 'string':\n\t\tcase 'number':\n\t\t\treturn node.toString();\n\t\t\tbreak;\n\t\tcase 'boolean':\n\t\t\treturn '';\n\t\t\tbreak;\n\t\tcase 'object': {\n\t\t\tif ( node instanceof Array ) {\n\t\t\t\treturn node.map( getNodeText ).join( '' );\n\t\t\t}\n\t\t\tif ( 'props' in node ) {\n\t\t\t\treturn getNodeText( node.props.children );\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\treturn '';\n\t}\n\n\treturn '';\n};\n\nconst EMPTY_FILTERED_OPTIONS: KeyedOption[] = [];\n\n// Used for generating the instance ID\nconst AUTOCOMPLETE_HOOK_REFERENCE = {};\n\nexport function useAutocomplete( {\n\trecord,\n\tonChange,\n\tonReplace,\n\tcompleters,\n\tcontentRef,\n}: UseAutocompleteProps ) {\n\tconst instanceId = useInstanceId( AUTOCOMPLETE_HOOK_REFERENCE );\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\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}\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 ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( event.key ) {\n\t\t\tcase 'ArrowUp': {\n\t\t\t\tconst newIndex =\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\tsetSelectedIndex( newIndex );\n\t\t\t\t// See the related PR as to why this is necessary: https://github.com/WordPress/gutenberg/pull/54902.\n\t\t\t\tif ( isAppleOS() ) {\n\t\t\t\t\tspeak(\n\t\t\t\t\t\tgetNodeText( filteredOptions[ newIndex ].label ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tconst newIndex = ( selectedIndex + 1 ) % filteredOptions.length;\n\t\t\t\tsetSelectedIndex( newIndex );\n\t\t\t\tif ( isAppleOS() ) {\n\t\t\t\t\tspeak(\n\t\t\t\t\t\tgetNodeText( filteredOptions[ newIndex ].label ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\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 ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Find the completer with the highest triggerPrefix index in the\n\t\t// textContent.\n\t\tconst completer = completers.reduce< WPCompleter | null >(\n\t\t\t( lastTrigger, currentCompleter ) => {\n\t\t\t\tconst triggerIndex = textContent.lastIndexOf(\n\t\t\t\t\tcurrentCompleter.triggerPrefix\n\t\t\t\t);\n\t\t\t\tconst lastTriggerIndex =\n\t\t\t\t\tlastTrigger !== null\n\t\t\t\t\t\t? textContent.lastIndexOf( lastTrigger.triggerPrefix )\n\t\t\t\t\t\t: -1;\n\n\t\t\t\treturn triggerIndex > lastTriggerIndex\n\t\t\t\t\t? currentCompleter\n\t\t\t\t\t: lastTrigger;\n\t\t\t},\n\t\t\tnull\n\t\t);\n\n\t\tif ( ! completer ) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst { allowContext, triggerPrefix } = completer;\n\t\tconst triggerIndex = textContent.lastIndexOf( triggerPrefix );\n\t\tconst textWithoutTrigger = textContent.slice(\n\t\t\ttriggerIndex + triggerPrefix.length\n\t\t);\n\n\t\tconst tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.\n\t\t// This is a final barrier to prevent the effect from completing with\n\t\t// an extremely long string, which causes the editor to slow-down\n\t\t// significantly. This could happen, for example, if `matchingWhileBackspacing`\n\t\t// is true and one of the \"words\" end up being too long. If that's the case,\n\t\t// it will be caught by this guard.\n\t\tif ( tooDistantFromTrigger ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst mismatch = filteredOptions.length === 0;\n\t\tconst wordsFromTrigger = textWithoutTrigger.split( /\\s/ );\n\t\t// We need to allow the effect to run when not backspacing and if there\n\t\t// was a mismatch. i.e when typing a trigger + the match string or when\n\t\t// clicking in an existing trigger word on the page. We do that if we\n\t\t// detect that we have one word from trigger in the current textual context.\n\t\t//\n\t\t// Ex.: \"Some text @a\" <-- \"@a\" will be detected as the trigger word and\n\t\t// allow the effect to run. It will run until there's a mismatch.\n\t\tconst hasOneTriggerWord = wordsFromTrigger.length === 1;\n\t\t// This is used to allow the effect to run when backspacing and if\n\t\t// \"touching\" a word that \"belongs\" to a trigger. We consider a \"trigger\n\t\t// word\" any word up to the limit of 3 from the trigger character.\n\t\t// Anything beyond that is ignored if there's a mismatch. This allows\n\t\t// us to \"escape\" a mismatch when backspacing, but still imposing some\n\t\t// sane limits.\n\t\t//\n\t\t// Ex: \"Some text @marcelo sekkkk\" <--- \"kkkk\" caused a mismatch, but\n\t\t// if the user presses backspace here, it will show the completion popup again.\n\t\tconst matchingWhileBackspacing =\n\t\t\tbackspacing.current && wordsFromTrigger.length <= 3;\n\n\t\tif ( mismatch && ! ( matchingWhileBackspacing || hasOneTriggerWord ) ) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst textAfterSelection = getTextContent(\n\t\t\tslice( record, undefined, getTextContent( record ).length )\n\t\t);\n\n\t\tif (\n\t\t\tallowContext &&\n\t\t\t! allowContext(\n\t\t\t\ttextContent.slice( 0, triggerIndex ),\n\t\t\t\ttextAfterSelection\n\t\t\t)\n\t\t) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\t/^\\s/.test( textWithoutTrigger ) ||\n\t\t\t/\\s\\s+$/.test( textWithoutTrigger )\n\t\t) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! /[\\u0000-\\uFFFF]*$/.test( textWithoutTrigger ) ) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\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: withIgnoreIMEEvents( 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"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA,SACCC,cAAc,EACdC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACNC,OAAO,QACD,oBAAoB;AAC3B,SAASC,aAAa,EAAEC,YAAY,EAAEC,YAAY,QAAQ,oBAAoB;AAC9E,SACCC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,WAAW,EACXC,cAAc,QACR,sB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rD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC,CACN,CAAC;;EAEH;EACA,MAAMG,YAAY,GAAG/F,MAAM,CAACkE,IAAI,KAAKuB,cAAc,EAAEvB,IAAI;EAEzD,IAAK,CAAE6B,YAAY,EAAG;IACrB,OAAO;MAAER,GAAG,EAAEG;IAAW,CAAC;EAC3B;EAEA,OAAO;IACNH,GAAG,EAAEG,UAAU;IACf9F,QAAQ,EAAEiF,OAAO;IACjB,mBAAmB,EAAEJ,SAAS,GAAG,MAAM,GAAGvC,SAAS;IACnD,WAAW,EAAEuC,SAAS;IACtB,uBAAuB,EAAEC;EAC1B,CAAC;AACF;AAEA,eAAe,SAASsB,YAAYA,CAAE;EACrCpG,QAAQ;EACRqG,UAAU;EACV,GAAG3D;AACe,CAAC,EAAG;EACtB,MAAM;IAAEuC,OAAO;IAAE,GAAGlF;EAAM,CAAC,GAAGI,eAAe,CAAEuC,OAAQ,CAAC;EACxD,oBACClD,KAAA,CAAAF,SAAA;IAAAU,QAAA,GACGA,QAAQ,CAAED,KAAM,CAAC,EACjBsG,UAAU,IAAIpB,OAAO;EAAA,CACtB,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["removeAccents","renderToString","useEffect","useState","useRef","useMemo","useInstanceId","useMergeRefs","useRefEffect","create","slice","insert","isCollapsed","getTextContent","speak","isAppleOS","getAutoCompleterUI","escapeRegExp","withIgnoreIMEEvents","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","getNodeText","node","toString","Array","map","join","props","children","EMPTY_FILTERED_OPTIONS","AUTOCOMPLETE_HOOK_REFERENCE","useAutocomplete","record","onChange","onReplace","completers","contentRef","instanceId","selectedIndex","setSelectedIndex","filteredOptions","setFilteredOptions","filterValue","setFilterValue","autocompleter","setAutocompleter","AutocompleterUI","setAutocompleterUI","backspacingRef","insertCompletion","replacement","end","start","triggerPrefix","length","toInsert","html","select","option","getOptionCompletion","isDisabled","completion","value","isCompletionObject","obj","action","undefined","completionObject","reset","onChangeOptions","options","handleKeyDown","event","current","key","defaultPrevented","newIndex","label","preventDefault","textContent","completer","reduce","lastTrigger","currentCompleter","triggerIndex","lastIndexOf","lastTriggerIndex","allowContext","textWithoutTrigger","tooDistantFromTrigger","mismatch","wordsFromTrigger","split","hasOneTriggerWord","matchingWhileBackspacing","textAfterSelection","test","safeTrigger","text","match","RegExp","query","selectedKey","className","isExpanded","listBoxId","activeId","hasSelection","onKeyDown","popover","onSelect","useLastDifferentValue","history","Set","add","size","delete","from","useAutocompleteProps","ref","onKeyDownRef","previousRecord","mergedRefs","element","_onKeyDown","addEventListener","removeEventListener","didUserInput","Autocomplete","isSelected"],"sources":["@wordpress/components/src/autocomplete/index.tsx"],"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 { useInstanceId, useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport {\n\tcreate,\n\tslice,\n\tinsert,\n\tisCollapsed,\n\tgetTextContent,\n} from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { getAutoCompleterUI } from './autocompleter-ui';\nimport { escapeRegExp } from '../utils/strings';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport type {\n\tAutocompleteProps,\n\tAutocompleterUIProps,\n\tInsertOption,\n\tKeyedOption,\n\tOptionCompletion,\n\tReplaceOption,\n\tUseAutocompleteProps,\n\tWPCompleter,\n} from './types';\n\nconst getNodeText = ( node: React.ReactNode ): string => {\n\tif ( node === null ) {\n\t\treturn '';\n\t}\n\n\tswitch ( typeof node ) {\n\t\tcase 'string':\n\t\tcase 'number':\n\t\t\treturn node.toString();\n\t\t\tbreak;\n\t\tcase 'boolean':\n\t\t\treturn '';\n\t\t\tbreak;\n\t\tcase 'object': {\n\t\t\tif ( node instanceof Array ) {\n\t\t\t\treturn node.map( getNodeText ).join( '' );\n\t\t\t}\n\t\t\tif ( 'props' in node ) {\n\t\t\t\treturn getNodeText( node.props.children );\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\treturn '';\n\t}\n\n\treturn '';\n};\n\nconst EMPTY_FILTERED_OPTIONS: KeyedOption[] = [];\n\n// Used for generating the instance ID\nconst AUTOCOMPLETE_HOOK_REFERENCE = {};\n\nexport function useAutocomplete( {\n\trecord,\n\tonChange,\n\tonReplace,\n\tcompleters,\n\tcontentRef,\n}: UseAutocompleteProps ) {\n\tconst instanceId = useInstanceId( AUTOCOMPLETE_HOOK_REFERENCE );\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 backspacingRef = 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\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}\n\n\tfunction handleKeyDown( event: KeyboardEvent ) {\n\t\tbackspacingRef.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 ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( event.key ) {\n\t\t\tcase 'ArrowUp': {\n\t\t\t\tconst newIndex =\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\tsetSelectedIndex( newIndex );\n\t\t\t\t// See the related PR as to why this is necessary: https://github.com/WordPress/gutenberg/pull/54902.\n\t\t\t\tif ( isAppleOS() ) {\n\t\t\t\t\tspeak(\n\t\t\t\t\t\tgetNodeText( filteredOptions[ newIndex ].label ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tconst newIndex = ( selectedIndex + 1 ) % filteredOptions.length;\n\t\t\t\tsetSelectedIndex( newIndex );\n\t\t\t\tif ( isAppleOS() ) {\n\t\t\t\t\tspeak(\n\t\t\t\t\t\tgetNodeText( filteredOptions[ newIndex ].label ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\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 ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Find the completer with the highest triggerPrefix index in the\n\t\t// textContent.\n\t\tconst completer = completers.reduce< WPCompleter | null >(\n\t\t\t( lastTrigger, currentCompleter ) => {\n\t\t\t\tconst triggerIndex = textContent.lastIndexOf(\n\t\t\t\t\tcurrentCompleter.triggerPrefix\n\t\t\t\t);\n\t\t\t\tconst lastTriggerIndex =\n\t\t\t\t\tlastTrigger !== null\n\t\t\t\t\t\t? textContent.lastIndexOf( lastTrigger.triggerPrefix )\n\t\t\t\t\t\t: -1;\n\n\t\t\t\treturn triggerIndex > lastTriggerIndex\n\t\t\t\t\t? currentCompleter\n\t\t\t\t\t: lastTrigger;\n\t\t\t},\n\t\t\tnull\n\t\t);\n\n\t\tif ( ! completer ) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst { allowContext, triggerPrefix } = completer;\n\t\tconst triggerIndex = textContent.lastIndexOf( triggerPrefix );\n\t\tconst textWithoutTrigger = textContent.slice(\n\t\t\ttriggerIndex + triggerPrefix.length\n\t\t);\n\n\t\tconst tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.\n\t\t// This is a final barrier to prevent the effect from completing with\n\t\t// an extremely long string, which causes the editor to slow-down\n\t\t// significantly. This could happen, for example, if `matchingWhileBackspacing`\n\t\t// is true and one of the \"words\" end up being too long. If that's the case,\n\t\t// it will be caught by this guard.\n\t\tif ( tooDistantFromTrigger ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst mismatch = filteredOptions.length === 0;\n\t\tconst wordsFromTrigger = textWithoutTrigger.split( /\\s/ );\n\t\t// We need to allow the effect to run when not backspacing and if there\n\t\t// was a mismatch. i.e when typing a trigger + the match string or when\n\t\t// clicking in an existing trigger word on the page. We do that if we\n\t\t// detect that we have one word from trigger in the current textual context.\n\t\t//\n\t\t// Ex.: \"Some text @a\" <-- \"@a\" will be detected as the trigger word and\n\t\t// allow the effect to run. It will run until there's a mismatch.\n\t\tconst hasOneTriggerWord = wordsFromTrigger.length === 1;\n\t\t// This is used to allow the effect to run when backspacing and if\n\t\t// \"touching\" a word that \"belongs\" to a trigger. We consider a \"trigger\n\t\t// word\" any word up to the limit of 3 from the trigger character.\n\t\t// Anything beyond that is ignored if there's a mismatch. This allows\n\t\t// us to \"escape\" a mismatch when backspacing, but still imposing some\n\t\t// sane limits.\n\t\t//\n\t\t// Ex: \"Some text @marcelo sekkkk\" <--- \"kkkk\" caused a mismatch, but\n\t\t// if the user presses backspace here, it will show the completion popup again.\n\t\tconst matchingWhileBackspacing =\n\t\t\tbackspacingRef.current && wordsFromTrigger.length <= 3;\n\n\t\tif ( mismatch && ! ( matchingWhileBackspacing || hasOneTriggerWord ) ) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst textAfterSelection = getTextContent(\n\t\t\tslice( record, undefined, getTextContent( record ).length )\n\t\t);\n\n\t\tif (\n\t\t\tallowContext &&\n\t\t\t! allowContext(\n\t\t\t\ttextContent.slice( 0, triggerIndex ),\n\t\t\t\ttextAfterSelection\n\t\t\t)\n\t\t) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\t/^\\s/.test( textWithoutTrigger ) ||\n\t\t\t/\\s\\s+$/.test( textWithoutTrigger )\n\t\t) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! /[\\u0000-\\uFFFF]*$/.test( textWithoutTrigger ) ) {\n\t\t\tif ( autocompleter ) {\n\t\t\t\treset();\n\t\t\t}\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// We want to avoid introducing unexpected side effects.\n\t\t// See https://github.com/WordPress/gutenberg/pull/41820\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: withIgnoreIMEEvents( 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"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA,SACCC,cAAc,EACd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AC3CgD,YAAY,CAAC/C,OAAO,GAAID,KAAM,CAAC;IAChC;IACAmD,OAAO,CAACE,gBAAgB,CAAE,SAAS,EAAED,UAAW,CAAC;IACjD,OAAO,MAAM;MACZD,OAAO,CAACG,mBAAmB,CAAE,SAAS,EAAEF,UAAW,CAAC;IACrD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC,CACN,CAAC;;EAEH;EACA,MAAMG,YAAY,GAAG/F,MAAM,CAACkE,IAAI,KAAKuB,cAAc,EAAEvB,IAAI;EAEzD,IAAK,CAAE6B,YAAY,EAAG;IACrB,OAAO;MAAER,GAAG,EAAEG;IAAW,CAAC;EAC3B;EAEA,OAAO;IACNH,GAAG,EAAEG,UAAU;IACf9F,QAAQ,EAAEiF,OAAO;IACjB,mBAAmB,EAAEJ,SAAS,GAAG,MAAM,GAAGvC,SAAS;IACnD,WAAW,EAAEuC,SAAS;IACtB,uBAAuB,EAAEC;EAC1B,CAAC;AACF;AAEA,eAAe,SAASsB,YAAYA,CAAE;EACrCpG,QAAQ;EACRqG,UAAU;EACV,GAAG3D;AACe,CAAC,EAAG;EACtB,MAAM;IAAEuC,OAAO;IAAE,GAAGlF;EAAM,CAAC,GAAGI,eAAe,CAAEuC,OAAQ,CAAC;EACxD,oBACClD,KAAA,CAAAF,SAAA;IAAAU,QAAA,GACGA,QAAQ,CAAED,KAAM,CAAC,EACjBsG,UAAU,IAAIpB,OAAO;EAAA,CACtB,CAAC;AAEL","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/base-control/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\nexport type BaseControlProps = {\n\t/**\n\t * Start opting into the new margin-free styles that will become the default in a future version.\n\t *\n\t * @default false\n\t */\n\t__nextHasNoMarginBottom?: boolean;\n\t/**\n\t * Temporary private prop for showing better deprecation messages,\n\t * e.g. `Some feature from wp.components.${ __associatedWPControl } is deprecated`.\n\t *\n\t * @ignore\n\t */\n\t__associatedWPComponentName?: string;\n\t/**\n\t * The HTML `id` of the control element (passed in as a child to `BaseControl`) to which labels and help text are being generated.\n\t * This is necessary to accessibly associate the label with that element.\n\t *\n\t * The recommended way is to use the `useBaseControlProps` hook, which takes care of generating a unique `id` for you.\n\t * Otherwise, if you choose to pass an explicit `id` to this prop, you are responsible for ensuring the uniqueness of the `id`.\n\t */\n\tid?: string;\n\t/**\n\t * Additional description for the control.\n\t *\n\t * Only use for meaningful description or instructions for the control. An element containing the description will be programmatically associated to the BaseControl by the means of an `aria-describedby` attribute.\n\t */\n\thelp?: ReactNode;\n\t/**\n\t * If this property is added, a label will be generated using label property as the content.\n\t */\n\tlabel?: ReactNode;\n\t/**\n\t * If true, the label will only be visible to screen readers.\n\t *\n\t * @default false\n\t */\n\thideLabelFromVision?: boolean;\n\tclassName?: string;\n\t/**\n\t * The content to be displayed within the `BaseControl`.\n\t */\n\tchildren: ReactNode;\n};\n\nexport type BaseControlVisualLabelProps = {\n\tchildren: ReactNode;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/base-control/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\nexport type BaseControlProps = {\n\t/**\n\t * Start opting into the new margin-free styles that will become the default in a future version.\n\t *\n\t * @default false\n\t */\n\t__nextHasNoMarginBottom?: boolean;\n\t/**\n\t * Temporary private prop for showing better deprecation messages,\n\t * e.g. `Some feature from wp.components.${ __associatedWPControl } is deprecated`.\n\t *\n\t * @ignore\n\t */\n\t__associatedWPComponentName?: string;\n\t/**\n\t * The HTML `id` of the control element (passed in as a child to `BaseControl`) to which labels and help text are being generated.\n\t * This is necessary to accessibly associate the label with that element.\n\t *\n\t * The recommended way is to use the `useBaseControlProps` hook, which takes care of generating a unique `id` for you.\n\t * Otherwise, if you choose to pass an explicit `id` to this prop, you are responsible for ensuring the uniqueness of the `id`.\n\t */\n\tid?: string;\n\t/**\n\t * Additional description for the control.\n\t *\n\t * Only use for meaningful description or instructions for the control. An element containing the description will be programmatically associated to the BaseControl by the means of an `aria-describedby` attribute.\n\t */\n\thelp?: ReactNode;\n\t/**\n\t * If this property is added, a label will be generated using label property as the content.\n\t */\n\tlabel?: ReactNode;\n\t/**\n\t * If true, the label will only be visible to screen readers.\n\t *\n\t * @default false\n\t */\n\thideLabelFromVision?: boolean;\n\tclassName?: string;\n\t/**\n\t * The content to be displayed within the `BaseControl`.\n\t */\n\tchildren: ReactNode;\n};\n\nexport type BaseControlVisualLabelProps = {\n\t/**\n\t * The content to be displayed within the `BaseControl.VisualLabel`.\n\t */\n\tchildren: ReactNode;\n};\n"],"mappings":"","ignoreList":[]}
@@ -145,6 +145,7 @@ const UnconnectedBorderBoxControl = (props, forwardedRef) => {
145
145
  *
146
146
  * return (
147
147
  * <BorderBoxControl
148
+ * __next40pxDefaultSize
148
149
  * colors={ colors }
149
150
  * label={ __( 'Borders' ) }
150
151
  * onChange={ onChange }
@@ -1 +1 @@
1
- {"version":3,"names":["__","useMemo","useState","useMergeRefs","BorderBoxControlLinkedButton","BorderBoxControlSplitControls","BorderControl","StyledLabel","View","VisuallyHidden","contextConnect","useBorderBoxControl","jsx","_jsx","jsxs","_jsxs","BorderLabel","props","label","hideLabelFromVision","as","children","UnconnectedBorderBoxControl","forwardedRef","className","colors","disableCustomColors","disableUnits","enableAlpha","enableStyle","hasMixedBorders","isLinked","linkedControlClassName","linkedValue","onLinkedChange","onSplitChange","popoverPlacement","popoverOffset","size","splitValue","toggleLinked","wrapperClassName","__experimentalIsRenderedInSidebar","otherProps","popoverAnchor","setPopoverAnchor","popoverProps","placement","offset","anchor","shift","undefined","mergedRef","ref","onChange","placeholder","__unstablePopoverProps","shouldSanitizeBorder","value","withSlider","width","onClick","BorderBoxControl"],"sources":["@wordpress/components/src/border-box-control/border-box-control/component.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BorderBoxControlLinkedButton from '../border-box-control-linked-button';\nimport BorderBoxControlSplitControls from '../border-box-control-split-controls';\nimport { BorderControl } from '../../border-control';\nimport { StyledLabel } from '../../base-control/styles/base-control-styles';\nimport { View } from '../../view';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { useBorderBoxControl } from './hook';\n\nimport type { BorderBoxControlProps } from '../types';\nimport type {\n\tLabelProps,\n\tBorderControlProps,\n} from '../../border-control/types';\n\nconst BorderLabel = ( props: LabelProps ) => {\n\tconst { label, hideLabelFromVision } = props;\n\n\tif ( ! label ) {\n\t\treturn null;\n\t}\n\n\treturn hideLabelFromVision ? (\n\t\t<VisuallyHidden as=\"label\">{ label }</VisuallyHidden>\n\t) : (\n\t\t<StyledLabel>{ label }</StyledLabel>\n\t);\n};\n\nconst UnconnectedBorderBoxControl = (\n\tprops: WordPressComponentProps< BorderBoxControlProps, 'div', false >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\tclassName,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tdisableUnits,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\thasMixedBorders,\n\t\thideLabelFromVision,\n\t\tisLinked,\n\t\tlabel,\n\t\tlinkedControlClassName,\n\t\tlinkedValue,\n\t\tonLinkedChange,\n\t\tonSplitChange,\n\t\tpopoverPlacement,\n\t\tpopoverOffset,\n\t\tsize,\n\t\tsplitValue,\n\t\ttoggleLinked,\n\t\twrapperClassName,\n\t\t__experimentalIsRenderedInSidebar,\n\t\t...otherProps\n\t} = useBorderBoxControl( props );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< Element | null >(\n\t\tnull\n\t);\n\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps: BorderControlProps[ '__unstablePopoverProps' ] =\n\t\tuseMemo(\n\t\t\t() =>\n\t\t\t\tpopoverPlacement\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tplacement: popoverPlacement,\n\t\t\t\t\t\t\toffset: popoverOffset,\n\t\t\t\t\t\t\tanchor: popoverAnchor,\n\t\t\t\t\t\t\tshift: true,\n\t\t\t\t\t }\n\t\t\t\t\t: undefined,\n\t\t\t[ popoverPlacement, popoverOffset, popoverAnchor ]\n\t\t);\n\n\tconst mergedRef = useMergeRefs( [ setPopoverAnchor, forwardedRef ] );\n\treturn (\n\t\t<View className={ className } { ...otherProps } ref={ mergedRef }>\n\t\t\t<BorderLabel\n\t\t\t\tlabel={ label }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t/>\n\t\t\t<View className={ wrapperClassName }>\n\t\t\t\t{ isLinked ? (\n\t\t\t\t\t<BorderControl\n\t\t\t\t\t\tclassName={ linkedControlClassName }\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tdisableUnits={ disableUnits }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t\tenableStyle={ enableStyle }\n\t\t\t\t\t\tonChange={ onLinkedChange }\n\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\thasMixedBorders ? __( 'Mixed' ) : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\t\t\tshouldSanitizeBorder={ false } // This component will handle that.\n\t\t\t\t\t\tvalue={ linkedValue }\n\t\t\t\t\t\twithSlider\n\t\t\t\t\t\twidth={\n\t\t\t\t\t\t\tsize === '__unstable-large' ? '116px' : '110px'\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<BorderBoxControlSplitControls\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t\tenableStyle={ enableStyle }\n\t\t\t\t\t\tonChange={ onSplitChange }\n\t\t\t\t\t\tpopoverPlacement={ popoverPlacement }\n\t\t\t\t\t\tpopoverOffset={ popoverOffset }\n\t\t\t\t\t\tvalue={ splitValue }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BorderBoxControlLinkedButton\n\t\t\t\t\tonClick={ toggleLinked }\n\t\t\t\t\tisLinked={ isLinked }\n\t\t\t\t\tsize={ size }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</View>\n\t);\n};\n\n/**\n * An input control for the color, style, and width of the border of a box. The\n * border can be customized as a whole, or individually for each side of the box.\n *\n * ```jsx\n * import { BorderBoxControl } from '@wordpress/components';\n * import { __ } from '@wordpress/i18n';\n *\n * const colors = [\n * \t{ name: 'Blue 20', color: '#72aee6' },\n * \t// ...\n * ];\n *\n * const MyBorderBoxControl = () => {\n * \tconst defaultBorder = {\n * \t\tcolor: '#72aee6',\n * \t\tstyle: 'dashed',\n * \t\twidth: '1px',\n * \t};\n * \tconst [ borders, setBorders ] = useState( {\n * \t\ttop: defaultBorder,\n * \t\tright: defaultBorder,\n * \t\tbottom: defaultBorder,\n * \t\tleft: defaultBorder,\n * \t} );\n * \tconst onChange = ( newBorders ) => setBorders( newBorders );\n *\n * \treturn (\n * \t\t<BorderBoxControl\n * \t\t\tcolors={ colors }\n * \t\t\tlabel={ __( 'Borders' ) }\n * \t\t\tonChange={ onChange }\n * \t\t\tvalue={ borders }\n * \t\t/>\n * \t);\n * };\n * ```\n */\nexport const BorderBoxControl = contextConnect(\n\tUnconnectedBorderBoxControl,\n\t'BorderBoxControl'\n);\n\nexport default BorderBoxControl;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,OAAOC,4BAA4B,MAAM,qCAAqC;AAC9E,OAAOC,6BAA6B,MAAM,sCAAsC;AAChF,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,WAAW,QAAQ,+CAA+C;AAC3E,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,cAAc,QAAQ,uBAAuB;AAEtD,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,mBAAmB,QAAQ,QAAQ;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAQ7C,MAAMC,WAAW,GAAKC,KAAiB,IAAM;EAC5C,MAAM;IAAEC,KAAK;IAAEC;EAAoB,CAAC,GAAGF,KAAK;EAE5C,IAAK,CAAEC,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,OAAOC,mBAAmB,gBACzBN,IAAA,CAACJ,cAAc;IAACW,EAAE,EAAC,OAAO;IAAAC,QAAA,EAAGH;EAAK,CAAkB,CAAC,gBAErDL,IAAA,CAACN,WAAW;IAAAc,QAAA,EAAGH;EAAK,CAAe,CACnC;AACF,CAAC;AAED,MAAMI,2BAA2B,GAAGA,CACnCL,KAAqE,EACrEM,YAAuC,KACnC;EACJ,MAAM;IACLC,SAAS;IACTC,MAAM;IACNC,mBAAmB;IACnBC,YAAY;IACZC,WAAW;IACXC,WAAW;IACXC,eAAe;IACfX,mBAAmB;IACnBY,QAAQ;IACRb,KAAK;IACLc,sBAAsB;IACtBC,WAAW;IACXC,cAAc;IACdC,aAAa;IACbC,gBAAgB;IAChBC,aAAa;IACbC,IAAI;IACJC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Aa;QACrB0B,UAAU;QACVC,KAAK,EACJtB,IAAI,KAAK,kBAAkB,GAAG,OAAO,GAAG,OACxC;QACDI,iCAAiC,EAChCA,iCACA;QACDJ,IAAI,EAAGA;MAAM,CACb,CAAC,gBAEFzB,IAAA,CAACR,6BAA6B;QAC7BoB,MAAM,EAAGA,MAAQ;QACjBC,mBAAmB,EAAGA,mBAAqB;QAC3CE,WAAW,EAAGA,WAAa;QAC3BC,WAAW,EAAGA,WAAa;QAC3ByB,QAAQ,EAAGnB,aAAe;QAC1BC,gBAAgB,EAAGA,gBAAkB;QACrCC,aAAa,EAAGA,aAAe;QAC/BqB,KAAK,EAAGnB,UAAY;QACpBG,iCAAiC,EAChCA,iCACA;QACDJ,IAAI,EAAGA;MAAM,CACb,CACD,eACDzB,IAAA,CAACT,4BAA4B;QAC5ByD,OAAO,EAAGrB,YAAc;QACxBT,QAAQ,EAAGA,QAAU;QACrBO,IAAI,EAAGA;MAAM,CACb,CAAC;IAAA,CACG,CAAC;EAAA,CACF,CAAC;AAET,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMwB,gBAAgB,GAAGpD,cAAc,CAC7CY,2BAA2B,EAC3B,kBACD,CAAC;AAED,eAAewC,gBAAgB","ignoreList":[]}
1
+ {"version":3,"names":["__","useMemo","useState","useMergeRefs","BorderBoxControlLinkedButton","BorderBoxControlSplitControls","BorderControl","StyledLabel","View","VisuallyHidden","contextConnect","useBorderBoxControl","jsx","_jsx","jsxs","_jsxs","BorderLabel","props","label","hideLabelFromVision","as","children","UnconnectedBorderBoxControl","forwardedRef","className","colors","disableCustomColors","disableUnits","enableAlpha","enableStyle","hasMixedBorders","isLinked","linkedControlClassName","linkedValue","onLinkedChange","onSplitChange","popoverPlacement","popoverOffset","size","splitValue","toggleLinked","wrapperClassName","__experimentalIsRenderedInSidebar","otherProps","popoverAnchor","setPopoverAnchor","popoverProps","placement","offset","anchor","shift","undefined","mergedRef","ref","onChange","placeholder","__unstablePopoverProps","shouldSanitizeBorder","value","withSlider","width","onClick","BorderBoxControl"],"sources":["@wordpress/components/src/border-box-control/border-box-control/component.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BorderBoxControlLinkedButton from '../border-box-control-linked-button';\nimport BorderBoxControlSplitControls from '../border-box-control-split-controls';\nimport { BorderControl } from '../../border-control';\nimport { StyledLabel } from '../../base-control/styles/base-control-styles';\nimport { View } from '../../view';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { useBorderBoxControl } from './hook';\n\nimport type { BorderBoxControlProps } from '../types';\nimport type {\n\tLabelProps,\n\tBorderControlProps,\n} from '../../border-control/types';\n\nconst BorderLabel = ( props: LabelProps ) => {\n\tconst { label, hideLabelFromVision } = props;\n\n\tif ( ! label ) {\n\t\treturn null;\n\t}\n\n\treturn hideLabelFromVision ? (\n\t\t<VisuallyHidden as=\"label\">{ label }</VisuallyHidden>\n\t) : (\n\t\t<StyledLabel>{ label }</StyledLabel>\n\t);\n};\n\nconst UnconnectedBorderBoxControl = (\n\tprops: WordPressComponentProps< BorderBoxControlProps, 'div', false >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\tclassName,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tdisableUnits,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\thasMixedBorders,\n\t\thideLabelFromVision,\n\t\tisLinked,\n\t\tlabel,\n\t\tlinkedControlClassName,\n\t\tlinkedValue,\n\t\tonLinkedChange,\n\t\tonSplitChange,\n\t\tpopoverPlacement,\n\t\tpopoverOffset,\n\t\tsize,\n\t\tsplitValue,\n\t\ttoggleLinked,\n\t\twrapperClassName,\n\t\t__experimentalIsRenderedInSidebar,\n\t\t...otherProps\n\t} = useBorderBoxControl( props );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< Element | null >(\n\t\tnull\n\t);\n\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps: BorderControlProps[ '__unstablePopoverProps' ] =\n\t\tuseMemo(\n\t\t\t() =>\n\t\t\t\tpopoverPlacement\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tplacement: popoverPlacement,\n\t\t\t\t\t\t\toffset: popoverOffset,\n\t\t\t\t\t\t\tanchor: popoverAnchor,\n\t\t\t\t\t\t\tshift: true,\n\t\t\t\t\t }\n\t\t\t\t\t: undefined,\n\t\t\t[ popoverPlacement, popoverOffset, popoverAnchor ]\n\t\t);\n\n\tconst mergedRef = useMergeRefs( [ setPopoverAnchor, forwardedRef ] );\n\treturn (\n\t\t<View className={ className } { ...otherProps } ref={ mergedRef }>\n\t\t\t<BorderLabel\n\t\t\t\tlabel={ label }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t/>\n\t\t\t<View className={ wrapperClassName }>\n\t\t\t\t{ isLinked ? (\n\t\t\t\t\t<BorderControl\n\t\t\t\t\t\tclassName={ linkedControlClassName }\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tdisableUnits={ disableUnits }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t\tenableStyle={ enableStyle }\n\t\t\t\t\t\tonChange={ onLinkedChange }\n\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\thasMixedBorders ? __( 'Mixed' ) : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\t\t\tshouldSanitizeBorder={ false } // This component will handle that.\n\t\t\t\t\t\tvalue={ linkedValue }\n\t\t\t\t\t\twithSlider\n\t\t\t\t\t\twidth={\n\t\t\t\t\t\t\tsize === '__unstable-large' ? '116px' : '110px'\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<BorderBoxControlSplitControls\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t\tenableStyle={ enableStyle }\n\t\t\t\t\t\tonChange={ onSplitChange }\n\t\t\t\t\t\tpopoverPlacement={ popoverPlacement }\n\t\t\t\t\t\tpopoverOffset={ popoverOffset }\n\t\t\t\t\t\tvalue={ splitValue }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BorderBoxControlLinkedButton\n\t\t\t\t\tonClick={ toggleLinked }\n\t\t\t\t\tisLinked={ isLinked }\n\t\t\t\t\tsize={ size }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</View>\n\t);\n};\n\n/**\n * An input control for the color, style, and width of the border of a box. The\n * border can be customized as a whole, or individually for each side of the box.\n *\n * ```jsx\n * import { BorderBoxControl } from '@wordpress/components';\n * import { __ } from '@wordpress/i18n';\n *\n * const colors = [\n * \t{ name: 'Blue 20', color: '#72aee6' },\n * \t// ...\n * ];\n *\n * const MyBorderBoxControl = () => {\n * \tconst defaultBorder = {\n * \t\tcolor: '#72aee6',\n * \t\tstyle: 'dashed',\n * \t\twidth: '1px',\n * \t};\n * \tconst [ borders, setBorders ] = useState( {\n * \t\ttop: defaultBorder,\n * \t\tright: defaultBorder,\n * \t\tbottom: defaultBorder,\n * \t\tleft: defaultBorder,\n * \t} );\n * \tconst onChange = ( newBorders ) => setBorders( newBorders );\n *\n * \treturn (\n * \t\t<BorderBoxControl\n * \t\t\t__next40pxDefaultSize\n * \t\t\tcolors={ colors }\n * \t\t\tlabel={ __( 'Borders' ) }\n * \t\t\tonChange={ onChange }\n * \t\t\tvalue={ borders }\n * \t\t/>\n * \t);\n * };\n * ```\n */\nexport const BorderBoxControl = contextConnect(\n\tUnconnectedBorderBoxControl,\n\t'BorderBoxControl'\n);\n\nexport default BorderBoxControl;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,OAAOC,4BAA4B,MAAM,qCAAqC;AAC9E,OAAOC,6BAA6B,MAAM,sCAAsC;AAChF,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,WAAW,QAAQ,+CAA+C;AAC3E,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,cAAc,QAAQ,uBAAuB;AAEtD,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,mBAAmB,QAAQ,QAAQ;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAQ7C,MAAMC,WAAW,GAAKC,KAAiB,IAAM;EAC5C,MAAM;IAAEC,KAAK;IAAEC;EAAoB,CAAC,GAAGF,KAAK;EAE5C,IAAK,CAAEC,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,OAAOC,mBAAmB,gBACzBN,IAAA,CAACJ,cAAc;IAACW,EAAE,EAAC,OAAO;IAAAC,QAAA,EAAGH;EAAK,CAAkB,CAAC,gBAErDL,IAAA,CAACN,WAAW;IA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