@wordpress/components 25.14.0 → 25.15.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 (479) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/CONTRIBUTING.md +57 -115
  3. package/LICENSE.md +1 -1
  4. package/build/base-control/index.js +17 -13
  5. package/build/base-control/index.js.map +1 -1
  6. package/build/border-box-control/border-box-control-linked-button/component.js +1 -1
  7. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  8. package/build/border-control/border-control-style-picker/component.js +1 -1
  9. package/build/border-control/border-control-style-picker/component.js.map +1 -1
  10. package/build/box-control/index.js +1 -1
  11. package/build/box-control/index.js.map +1 -1
  12. package/build/box-control/linked-button.js +1 -1
  13. package/build/box-control/linked-button.js.map +1 -1
  14. package/build/button/index.js +1 -1
  15. package/build/button/index.js.map +1 -1
  16. package/build/color-picker/color-copy-button.js +1 -1
  17. package/build/color-picker/color-copy-button.js.map +1 -1
  18. package/build/context/wordpress-component.js.map +1 -1
  19. package/build/custom-select-control-v2/index.js +11 -10
  20. package/build/custom-select-control-v2/index.js.map +1 -1
  21. package/build/date-time/date/styles.js +8 -8
  22. package/build/date-time/date/styles.js.map +1 -1
  23. package/build/dropdown-menu-v2/index.js +205 -159
  24. package/build/dropdown-menu-v2/index.js.map +1 -1
  25. package/build/dropdown-menu-v2/styles.js +86 -77
  26. package/build/dropdown-menu-v2/styles.js.map +1 -1
  27. package/build/dropdown-menu-v2/types.js.map +1 -1
  28. package/build/duotone-picker/duotone-picker.js +4 -3
  29. package/build/duotone-picker/duotone-picker.js.map +1 -1
  30. package/build/font-size-picker/index.js +4 -2
  31. package/build/font-size-picker/index.js.map +1 -1
  32. package/build/font-size-picker/index.native.js +6 -3
  33. package/build/font-size-picker/index.native.js.map +1 -1
  34. package/build/form-token-field/index.js +10 -5
  35. package/build/form-token-field/index.js.map +1 -1
  36. package/build/form-token-field/token.js +1 -0
  37. package/build/form-token-field/token.js.map +1 -1
  38. package/build/gradient-picker/index.js +3 -2
  39. package/build/gradient-picker/index.js.map +1 -1
  40. package/build/index.native.js +20 -3
  41. package/build/index.native.js.map +1 -1
  42. package/build/input-control/styles/input-control-styles.js +32 -29
  43. package/build/input-control/styles/input-control-styles.js.map +1 -1
  44. package/build/input-control/types.js.map +1 -1
  45. package/build/lock-unlock.js +18 -0
  46. package/build/lock-unlock.js.map +1 -0
  47. package/build/mobile/bottom-sheet/index.native.js +8 -0
  48. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  49. package/build/mobile/global-styles-context/utils.native.js +26 -13
  50. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  51. package/build/mobile/image/constants.js +12 -0
  52. package/build/mobile/image/constants.js.map +1 -0
  53. package/build/mobile/image/index.native.js +26 -18
  54. package/build/mobile/image/index.native.js.map +1 -1
  55. package/build/mobile/keyboard-aware-flat-list/index.android.js +40 -8
  56. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  57. package/build/mobile/keyboard-aware-flat-list/index.ios.js +44 -68
  58. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  59. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +39 -0
  60. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  61. package/build/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -29
  62. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  63. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js +93 -0
  64. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  65. package/build/mobile/utils/get-px-from-css-unit.native.js +302 -0
  66. package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  67. package/build/modal/index.js +18 -13
  68. package/build/modal/index.js.map +1 -1
  69. package/build/navigation/menu/menu-title.js +1 -1
  70. package/build/navigation/menu/menu-title.js.map +1 -1
  71. package/build/navigator/navigator-provider/component.js +13 -15
  72. package/build/navigator/navigator-provider/component.js.map +1 -1
  73. package/build/navigator/navigator-screen/component.js +23 -63
  74. package/build/navigator/navigator-screen/component.js.map +1 -1
  75. package/build/navigator/styles.js +52 -0
  76. package/build/navigator/styles.js.map +1 -0
  77. package/build/number-control/index.js +4 -8
  78. package/build/number-control/index.js.map +1 -1
  79. package/build/number-control/types.js.map +1 -1
  80. package/build/palette-edit/index.js +15 -54
  81. package/build/palette-edit/index.js.map +1 -1
  82. package/build/private-apis.js +11 -26
  83. package/build/private-apis.js.map +1 -1
  84. package/build/private-apis.native.js +21 -0
  85. package/build/private-apis.native.js.map +1 -0
  86. package/build/radio-control/index.js +1 -0
  87. package/build/radio-control/index.js.map +1 -1
  88. package/build/range-control/index.js +1 -1
  89. package/build/range-control/index.js.map +1 -1
  90. package/build/select-control/styles/select-control-styles.js +15 -25
  91. package/build/select-control/styles/select-control-styles.js.map +1 -1
  92. package/build/slot-fill/index.js +3 -2
  93. package/build/slot-fill/index.js.map +1 -1
  94. package/build/slot-fill/types.js.map +1 -1
  95. package/build/snackbar/types.js.map +1 -1
  96. package/build/tabs/styles.js +3 -3
  97. package/build/tabs/styles.js.map +1 -1
  98. package/build/tabs/tabpanel.js +9 -7
  99. package/build/tabs/tabpanel.js.map +1 -1
  100. package/build/toggle-group-control/toggle-group-control/component.js +4 -4
  101. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  102. package/build/toggle-group-control/toggle-group-control/styles.js +29 -15
  103. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  104. package/build/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  105. package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  106. package/build/tools-panel/tools-panel/component.js +3 -1
  107. package/build/tools-panel/tools-panel/component.js.map +1 -1
  108. package/build/tools-panel/tools-panel-header/component.js +9 -8
  109. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  110. package/build/tools-panel/types.js.map +1 -1
  111. package/build/tooltip/index.js +1 -1
  112. package/build/tooltip/index.js.map +1 -1
  113. package/build/truncate/hook.js +10 -4
  114. package/build/truncate/hook.js.map +1 -1
  115. package/build/truncate/types.js.map +1 -1
  116. package/build/unit-control/index.js +1 -1
  117. package/build/unit-control/index.js.map +1 -1
  118. package/build/utils/strings.js +34 -3
  119. package/build/utils/strings.js.map +1 -1
  120. package/build-module/base-control/index.js +16 -12
  121. package/build-module/base-control/index.js.map +1 -1
  122. package/build-module/border-box-control/border-box-control-linked-button/component.js +1 -1
  123. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  124. package/build-module/border-control/border-control-style-picker/component.js +1 -1
  125. package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
  126. package/build-module/box-control/index.js +1 -1
  127. package/build-module/box-control/index.js.map +1 -1
  128. package/build-module/box-control/linked-button.js +1 -1
  129. package/build-module/box-control/linked-button.js.map +1 -1
  130. package/build-module/button/index.js +1 -1
  131. package/build-module/button/index.js.map +1 -1
  132. package/build-module/color-picker/color-copy-button.js +1 -1
  133. package/build-module/color-picker/color-copy-button.js.map +1 -1
  134. package/build-module/context/wordpress-component.js.map +1 -1
  135. package/build-module/custom-select-control-v2/index.js +11 -10
  136. package/build-module/custom-select-control-v2/index.js.map +1 -1
  137. package/build-module/date-time/date/styles.js +8 -8
  138. package/build-module/date-time/date/styles.js.map +1 -1
  139. package/build-module/dropdown-menu-v2/index.js +201 -154
  140. package/build-module/dropdown-menu-v2/index.js.map +1 -1
  141. package/build-module/dropdown-menu-v2/styles.js +68 -61
  142. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  143. package/build-module/dropdown-menu-v2/types.js.map +1 -1
  144. package/build-module/duotone-picker/duotone-picker.js +4 -3
  145. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  146. package/build-module/font-size-picker/index.js +4 -2
  147. package/build-module/font-size-picker/index.js.map +1 -1
  148. package/build-module/font-size-picker/index.native.js +5 -2
  149. package/build-module/font-size-picker/index.native.js.map +1 -1
  150. package/build-module/form-token-field/index.js +10 -5
  151. package/build-module/form-token-field/index.js.map +1 -1
  152. package/build-module/form-token-field/token.js +1 -0
  153. package/build-module/form-token-field/token.js.map +1 -1
  154. package/build-module/gradient-picker/index.js +3 -2
  155. package/build-module/gradient-picker/index.js.map +1 -1
  156. package/build-module/index.native.js +6 -1
  157. package/build-module/index.native.js.map +1 -1
  158. package/build-module/input-control/styles/input-control-styles.js +31 -29
  159. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  160. package/build-module/input-control/types.js.map +1 -1
  161. package/build-module/lock-unlock.js +9 -0
  162. package/build-module/lock-unlock.js.map +1 -0
  163. package/build-module/mobile/bottom-sheet/index.native.js +9 -1
  164. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  165. package/build-module/mobile/global-styles-context/utils.native.js +25 -13
  166. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  167. package/build-module/mobile/image/constants.js +5 -0
  168. package/build-module/mobile/image/constants.js.map +1 -0
  169. package/build-module/mobile/image/index.native.js +25 -16
  170. package/build-module/mobile/image/index.native.js.map +1 -1
  171. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +40 -6
  172. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  173. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +46 -68
  174. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  175. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +33 -0
  176. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  177. package/build-module/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +21 -27
  178. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  179. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js +86 -0
  180. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  181. package/build-module/mobile/utils/get-px-from-css-unit.native.js +294 -0
  182. package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  183. package/build-module/modal/index.js +18 -13
  184. package/build-module/modal/index.js.map +1 -1
  185. package/build-module/navigation/menu/menu-title.js +1 -1
  186. package/build-module/navigation/menu/menu-title.js.map +1 -1
  187. package/build-module/navigator/navigator-provider/component.js +3 -16
  188. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  189. package/build-module/navigator/navigator-screen/component.js +16 -70
  190. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  191. package/build-module/navigator/styles.js +47 -0
  192. package/build-module/navigator/styles.js.map +1 -0
  193. package/build-module/number-control/index.js +4 -8
  194. package/build-module/number-control/index.js.map +1 -1
  195. package/build-module/number-control/types.js.map +1 -1
  196. package/build-module/palette-edit/index.js +15 -51
  197. package/build-module/palette-edit/index.js.map +1 -1
  198. package/build-module/private-apis.js +10 -23
  199. package/build-module/private-apis.js.map +1 -1
  200. package/build-module/private-apis.native.js +14 -0
  201. package/build-module/private-apis.native.js.map +1 -0
  202. package/build-module/radio-control/index.js +1 -0
  203. package/build-module/radio-control/index.js.map +1 -1
  204. package/build-module/range-control/index.js +1 -1
  205. package/build-module/range-control/index.js.map +1 -1
  206. package/build-module/select-control/styles/select-control-styles.js +15 -25
  207. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  208. package/build-module/slot-fill/index.js +3 -2
  209. package/build-module/slot-fill/index.js.map +1 -1
  210. package/build-module/slot-fill/types.js.map +1 -1
  211. package/build-module/snackbar/types.js.map +1 -1
  212. package/build-module/tabs/styles.js +3 -3
  213. package/build-module/tabs/styles.js.map +1 -1
  214. package/build-module/tabs/tabpanel.js +9 -7
  215. package/build-module/tabs/tabpanel.js.map +1 -1
  216. package/build-module/toggle-group-control/toggle-group-control/component.js +4 -4
  217. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  218. package/build-module/toggle-group-control/toggle-group-control/styles.js +29 -15
  219. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  220. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  221. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  222. package/build-module/tools-panel/tools-panel/component.js +3 -1
  223. package/build-module/tools-panel/tools-panel/component.js.map +1 -1
  224. package/build-module/tools-panel/tools-panel-header/component.js +9 -8
  225. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  226. package/build-module/tools-panel/types.js.map +1 -1
  227. package/build-module/tooltip/index.js +1 -1
  228. package/build-module/tooltip/index.js.map +1 -1
  229. package/build-module/truncate/hook.js +10 -4
  230. package/build-module/truncate/hook.js.map +1 -1
  231. package/build-module/truncate/types.js.map +1 -1
  232. package/build-module/unit-control/index.js +1 -1
  233. package/build-module/unit-control/index.js.map +1 -1
  234. package/build-module/utils/strings.js +32 -2
  235. package/build-module/utils/strings.js.map +1 -1
  236. package/build-style/style-rtl.css +29 -5
  237. package/build-style/style.css +29 -5
  238. package/build-types/base-control/index.d.ts +3 -27
  239. package/build-types/base-control/index.d.ts.map +1 -1
  240. package/build-types/base-control/stories/index.story.d.ts +4 -1
  241. package/build-types/base-control/stories/index.story.d.ts.map +1 -1
  242. package/build-types/color-picker/component.d.ts +1 -1
  243. package/build-types/color-picker/stories/index.story.d.ts +1 -1
  244. package/build-types/color-picker/stories/index.story.d.ts.map +1 -1
  245. package/build-types/composite/test/index.d.ts.map +1 -0
  246. package/build-types/context/wordpress-component.d.ts +3 -3
  247. package/build-types/context/wordpress-component.d.ts.map +1 -1
  248. package/build-types/custom-select-control-v2/index.d.ts +3 -2
  249. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  250. package/build-types/custom-select-control-v2/stories/index.story.d.ts +4 -3
  251. package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
  252. package/build-types/dropdown/index.d.ts +1 -1
  253. package/build-types/dropdown/index.d.ts.map +1 -1
  254. package/build-types/dropdown/stories/index.story.d.ts +3 -3
  255. package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
  256. package/build-types/dropdown-menu/index.d.ts +1 -1
  257. package/build-types/dropdown-menu/index.d.ts.map +1 -1
  258. package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
  259. package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
  260. package/build-types/dropdown-menu-v2/index.d.ts +18 -15
  261. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
  262. package/build-types/dropdown-menu-v2/stories/index.story.d.ts +7 -2
  263. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
  264. package/build-types/dropdown-menu-v2/styles.d.ts +77 -23
  265. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
  266. package/build-types/dropdown-menu-v2/types.d.ts +89 -173
  267. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
  268. package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
  269. package/build-types/font-size-picker/index.d.ts.map +1 -1
  270. package/build-types/form-token-field/index.d.ts.map +1 -1
  271. package/build-types/form-token-field/token.d.ts.map +1 -1
  272. package/build-types/input-control/styles/input-control-styles.d.ts +11 -0
  273. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  274. package/build-types/input-control/types.d.ts +1 -1
  275. package/build-types/input-control/types.d.ts.map +1 -1
  276. package/build-types/lock-unlock.d.ts +3 -0
  277. package/build-types/lock-unlock.d.ts.map +1 -0
  278. package/build-types/mobile/image/constants.d.ts +5 -0
  279. package/build-types/mobile/image/constants.d.ts.map +1 -0
  280. package/build-types/modal/index.d.ts.map +1 -1
  281. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  282. package/build-types/navigator/navigator-screen/component.d.ts +1 -7
  283. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  284. package/build-types/navigator/styles.d.ts +9 -0
  285. package/build-types/navigator/styles.d.ts.map +1 -0
  286. package/build-types/number-control/index.d.ts.map +1 -1
  287. package/build-types/number-control/types.d.ts +1 -1
  288. package/build-types/palette-edit/index.d.ts +3 -8
  289. package/build-types/palette-edit/index.d.ts.map +1 -1
  290. package/build-types/popover/index.d.ts +1 -1
  291. package/build-types/popover/index.d.ts.map +1 -1
  292. package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
  293. package/build-types/private-apis.d.ts +0 -1
  294. package/build-types/private-apis.d.ts.map +1 -1
  295. package/build-types/radio-control/index.d.ts.map +1 -1
  296. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  297. package/build-types/slot-fill/index.d.ts +1 -1
  298. package/build-types/slot-fill/index.d.ts.map +1 -1
  299. package/build-types/slot-fill/types.d.ts +4 -0
  300. package/build-types/slot-fill/types.d.ts.map +1 -1
  301. package/build-types/snackbar/index.d.ts +2 -2
  302. package/build-types/snackbar/stories/index.story.d.ts +0 -3
  303. package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
  304. package/build-types/snackbar/types.d.ts +1 -1
  305. package/build-types/snackbar/types.d.ts.map +1 -1
  306. package/build-types/tabs/styles.d.ts.map +1 -1
  307. package/build-types/tabs/tabpanel.d.ts +1 -1
  308. package/build-types/tabs/tabpanel.d.ts.map +1 -1
  309. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  310. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +2 -2
  311. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  312. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +1 -1
  313. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  314. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  315. package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
  316. package/build-types/tools-panel/tools-panel/hook.d.ts +1 -0
  317. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  318. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  319. package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -0
  320. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  321. package/build-types/tools-panel/types.d.ts +9 -0
  322. package/build-types/tools-panel/types.d.ts.map +1 -1
  323. package/build-types/truncate/hook.d.ts +1 -1
  324. package/build-types/truncate/hook.d.ts.map +1 -1
  325. package/build-types/truncate/types.d.ts +4 -0
  326. package/build-types/truncate/types.d.ts.map +1 -1
  327. package/build-types/utils/strings.d.ts +14 -2
  328. package/build-types/utils/strings.d.ts.map +1 -1
  329. package/package.json +20 -21
  330. package/src/alignment-matrix-control/test/index.tsx +10 -16
  331. package/src/base-control/index.tsx +21 -16
  332. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
  333. package/src/border-control/border-control-style-picker/component.tsx +1 -1
  334. package/src/box-control/index.tsx +1 -1
  335. package/src/box-control/linked-button.tsx +1 -1
  336. package/src/button/README.md +32 -6
  337. package/src/button/index.tsx +1 -1
  338. package/src/button-group/README.md +0 -6
  339. package/src/card/card/README.md +1 -1
  340. package/src/checkbox-control/README.md +1 -9
  341. package/src/color-picker/color-copy-button.tsx +1 -1
  342. package/src/combobox-control/README.md +0 -6
  343. package/src/composite/test/index.tsx +576 -0
  344. package/src/context/wordpress-component.ts +11 -6
  345. package/src/custom-select-control/README.md +0 -6
  346. package/src/custom-select-control-v2/index.tsx +13 -12
  347. package/src/date-time/date/styles.ts +3 -3
  348. package/src/dropdown-menu/README.md +0 -5
  349. package/src/dropdown-menu-v2/README.md +75 -136
  350. package/src/dropdown-menu-v2/index.tsx +321 -231
  351. package/src/dropdown-menu-v2/stories/index.story.tsx +522 -126
  352. package/src/dropdown-menu-v2/styles.ts +226 -151
  353. package/src/dropdown-menu-v2/test/index.tsx +480 -188
  354. package/src/dropdown-menu-v2/types.ts +98 -184
  355. package/src/duotone-picker/duotone-picker.tsx +7 -3
  356. package/src/font-size-picker/index.native.js +8 -2
  357. package/src/font-size-picker/index.tsx +4 -2
  358. package/src/form-toggle/README.md +0 -6
  359. package/src/form-token-field/index.tsx +11 -7
  360. package/src/form-token-field/test/index.tsx +97 -0
  361. package/src/form-token-field/token.tsx +1 -0
  362. package/src/gradient-picker/index.tsx +2 -2
  363. package/src/index.native.js +6 -1
  364. package/src/input-control/styles/input-control-styles.tsx +10 -8
  365. package/src/input-control/types.ts +1 -1
  366. package/src/lock-unlock.js +10 -0
  367. package/src/menu-group/README.md +0 -8
  368. package/src/menu-items-choice/README.md +0 -7
  369. package/src/mobile/bottom-sheet/index.native.js +15 -1
  370. package/src/mobile/global-styles-context/test/fixtures/theme.native.js +0 -20
  371. package/src/mobile/global-styles-context/utils.native.js +28 -19
  372. package/src/mobile/image/constants.js +1 -0
  373. package/src/mobile/image/index.native.js +55 -18
  374. package/src/mobile/image/style.native.scss +35 -9
  375. package/src/mobile/keyboard-aware-flat-list/index.android.js +50 -5
  376. package/src/mobile/keyboard-aware-flat-list/index.ios.js +65 -91
  377. package/src/mobile/keyboard-aware-flat-list/test/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +27 -25
  378. package/src/mobile/keyboard-aware-flat-list/test/use-scroll.native.js +71 -0
  379. package/src/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +41 -0
  380. package/src/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -27
  381. package/src/mobile/keyboard-aware-flat-list/use-scroll.native.js +100 -0
  382. package/src/mobile/utils/get-px-from-css-unit.native.js +329 -0
  383. package/src/mobile/utils/test/get-px-from-css-unit.native.js +172 -0
  384. package/src/modal/README.md +0 -6
  385. package/src/modal/index.tsx +18 -16
  386. package/src/modal/test/index.tsx +90 -1
  387. package/src/navigation/menu/menu-title.tsx +1 -1
  388. package/src/navigator/navigator-provider/component.tsx +3 -4
  389. package/src/navigator/navigator-screen/component.tsx +15 -93
  390. package/src/navigator/styles.ts +71 -0
  391. package/src/navigator/test/index.tsx +0 -64
  392. package/src/notice/README.md +0 -6
  393. package/src/number-control/README.md +2 -2
  394. package/src/number-control/index.tsx +4 -8
  395. package/src/number-control/types.ts +1 -1
  396. package/src/palette-edit/index.tsx +15 -58
  397. package/src/palette-edit/test/index.tsx +1 -75
  398. package/src/panel/README.md +0 -6
  399. package/src/private-apis.native.js +13 -0
  400. package/src/private-apis.ts +12 -37
  401. package/src/radio-control/README.md +0 -6
  402. package/src/radio-control/index.tsx +4 -1
  403. package/src/radio-control/style.scss +29 -2
  404. package/src/radio-group/README.md +0 -6
  405. package/src/range-control/README.md +1 -9
  406. package/src/range-control/index.tsx +1 -1
  407. package/src/search-control/README.md +0 -6
  408. package/src/select-control/README.md +0 -6
  409. package/src/select-control/styles/select-control-styles.ts +10 -28
  410. package/src/slot-fill/index.tsx +5 -2
  411. package/src/slot-fill/types.ts +5 -0
  412. package/src/snackbar/README.md +0 -6
  413. package/src/snackbar/stories/index.story.tsx +7 -5
  414. package/src/snackbar/style.scss +4 -3
  415. package/src/snackbar/types.ts +2 -1
  416. package/src/spacer/README.md +0 -2
  417. package/src/tab-panel/README.md +0 -5
  418. package/src/tab-panel/test/index.tsx +39 -56
  419. package/src/tabs/styles.ts +7 -1
  420. package/src/tabs/tabpanel.tsx +7 -6
  421. package/src/tabs/test/index.tsx +56 -0
  422. package/src/text-control/README.md +0 -6
  423. package/src/textarea-control/README.md +0 -6
  424. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +12 -16
  425. package/src/toggle-group-control/test/index.tsx +58 -45
  426. package/src/toggle-group-control/toggle-group-control/component.tsx +5 -4
  427. package/src/toggle-group-control/toggle-group-control/styles.ts +13 -19
  428. package/src/toggle-group-control/toggle-group-control-option/README.md +1 -1
  429. package/src/toggle-group-control/toggle-group-control-option-base/README.md +1 -1
  430. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +3 -2
  431. package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
  432. package/src/toolbar/toolbar/README.md +0 -6
  433. package/src/tools-panel/test/index.tsx +12 -20
  434. package/src/tools-panel/tools-panel/README.md +7 -0
  435. package/src/tools-panel/tools-panel/component.tsx +2 -0
  436. package/src/tools-panel/tools-panel-header/README.md +7 -0
  437. package/src/tools-panel/tools-panel-header/component.tsx +20 -13
  438. package/src/tools-panel/types.ts +9 -0
  439. package/src/tooltip/index.tsx +1 -1
  440. package/src/tooltip/test/index.tsx +360 -256
  441. package/src/tree-grid/README.md +0 -4
  442. package/src/truncate/README.md +8 -0
  443. package/src/truncate/hook.ts +17 -10
  444. package/src/truncate/test/index.tsx +54 -27
  445. package/src/truncate/types.ts +4 -0
  446. package/src/unit-control/index.tsx +1 -1
  447. package/src/utils/strings.ts +30 -2
  448. package/src/utils/test/strings.js +96 -1
  449. package/tsconfig.tsbuildinfo +1 -1
  450. package/build/dropdown-menu-v2-ariakit/index.js +0 -256
  451. package/build/dropdown-menu-v2-ariakit/index.js.map +0 -1
  452. package/build/dropdown-menu-v2-ariakit/styles.js +0 -180
  453. package/build/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  454. package/build/dropdown-menu-v2-ariakit/types.js +0 -6
  455. package/build/dropdown-menu-v2-ariakit/types.js.map +0 -1
  456. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  457. package/build-module/dropdown-menu-v2-ariakit/index.js +0 -237
  458. package/build-module/dropdown-menu-v2-ariakit/index.js.map +0 -1
  459. package/build-module/dropdown-menu-v2-ariakit/styles.js +0 -165
  460. package/build-module/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  461. package/build-module/dropdown-menu-v2-ariakit/types.js +0 -2
  462. package/build-module/dropdown-menu-v2-ariakit/types.js.map +0 -1
  463. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  464. package/build-types/dropdown-menu-v2-ariakit/index.d.ts +0 -20
  465. package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +0 -1
  466. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +0 -16
  467. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +0 -1
  468. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +0 -96
  469. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +0 -1
  470. package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +0 -1
  471. package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -168
  472. package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +0 -1
  473. package/src/dropdown-menu-v2-ariakit/README.md +0 -331
  474. package/src/dropdown-menu-v2-ariakit/index.tsx +0 -383
  475. package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +0 -617
  476. package/src/dropdown-menu-v2-ariakit/styles.ts +0 -345
  477. package/src/dropdown-menu-v2-ariakit/test/index.tsx +0 -1108
  478. package/src/dropdown-menu-v2-ariakit/types.ts +0 -179
  479. /package/build-types/{dropdown-menu-v2-ariakit → composite}/test/index.d.ts +0 -0
@@ -10,7 +10,7 @@ import FastImage from 'react-native-fast-image';
10
10
  */
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { Icon } from '@wordpress/components';
13
- import { image as icon } from '@wordpress/icons';
13
+ import { image, offline } from '@wordpress/icons';
14
14
  import { usePreferredColorSchemeStyle } from '@wordpress/compose';
15
15
  import { useEffect, useState, Platform } from '@wordpress/element';
16
16
 
@@ -22,14 +22,11 @@ import styles from './style.scss';
22
22
  import SvgIconRetry from './icon-retry';
23
23
  import ImageEditingButton from './image-editing-button';
24
24
  const ICON_TYPE = {
25
+ OFFLINE: 'offline',
25
26
  PLACEHOLDER: 'placeholder',
26
27
  RETRY: 'retry',
27
28
  UPLOAD: 'upload'
28
29
  };
29
- export const IMAGE_DEFAULT_FOCAL_POINT = {
30
- x: 0.5,
31
- y: 0.5
32
- };
33
30
  const ImageComponent = ({
34
31
  align,
35
32
  alt,
@@ -40,6 +37,7 @@ const ImageComponent = ({
40
37
  isSelected,
41
38
  shouldUseFastImage,
42
39
  isUploadFailed,
40
+ isUploadPaused,
43
41
  isUploadInProgress,
44
42
  mediaPickerOptions,
45
43
  onImageDataLoad,
@@ -95,17 +93,23 @@ const ImageComponent = ({
95
93
  }
96
94
  };
97
95
  const getIcon = iconType => {
96
+ let icon;
98
97
  let iconStyle;
99
98
  switch (iconType) {
100
99
  case ICON_TYPE.RETRY:
101
- return createElement(Icon, {
102
- icon: retryIcon || SvgIconRetry,
103
- ...styles.iconRetry
104
- });
100
+ icon = retryIcon || SvgIconRetry;
101
+ iconStyle = iconRetryStyles;
102
+ break;
103
+ case ICON_TYPE.OFFLINE:
104
+ icon = offline;
105
+ iconStyle = iconOfflineStyles;
106
+ break;
105
107
  case ICON_TYPE.PLACEHOLDER:
108
+ icon = image;
106
109
  iconStyle = iconPlaceholderStyles;
107
110
  break;
108
111
  case ICON_TYPE.UPLOAD:
112
+ icon = image;
109
113
  iconStyle = iconUploadStyles;
110
114
  break;
111
115
  }
@@ -116,6 +120,11 @@ const ImageComponent = ({
116
120
  };
117
121
  const iconPlaceholderStyles = usePreferredColorSchemeStyle(styles.iconPlaceholder, styles.iconPlaceholderDark);
118
122
  const iconUploadStyles = usePreferredColorSchemeStyle(styles.iconUpload, styles.iconUploadDark);
123
+ const iconOfflineStyles = usePreferredColorSchemeStyle(styles.iconOffline, styles.iconOfflineDark);
124
+ const retryIconStyles = usePreferredColorSchemeStyle(styles.retryIcon, styles.retryIconDark);
125
+ const iconRetryStyles = usePreferredColorSchemeStyle(styles.iconRetry, styles.iconRetryDark);
126
+ const retryContainerStyles = usePreferredColorSchemeStyle(styles.retryContainer, styles.retryContainerDark);
127
+ const uploadFailedTextStyles = usePreferredColorSchemeStyle(styles.uploadFailedText, styles.uploadFailedTextDark);
119
128
  const placeholderStyles = [usePreferredColorSchemeStyle(styles.imageContainerUpload, styles.imageContainerUploadDark), focalPoint && styles.imageContainerUploadWithFocalpoint, imageHeight && {
120
129
  height: imageHeight
121
130
  }];
@@ -155,7 +164,7 @@ const ImageComponent = ({
155
164
  accessibilityRole: 'imagebutton',
156
165
  key: url,
157
166
  style: imageContainerStyles
158
- }, isSelected && highlightSelected && !(isUploadInProgress || isUploadFailed) && createElement(View, {
167
+ }, isSelected && highlightSelected && !(isUploadInProgress || isUploadFailed || isUploadPaused) && createElement(View, {
159
168
  style: imageSelectedStyles
160
169
  }), !imageData ? createElement(View, {
161
170
  style: placeholderStyles
@@ -172,16 +181,16 @@ const ImageComponent = ({
172
181
  resizeMethod: 'scale'
173
182
  }),
174
183
  resizeMode: imageResizeMode
175
- })), isUploadFailed && retryMessage && createElement(View, {
176
- style: [styles.imageContainer, styles.retryContainer]
184
+ })), (isUploadFailed || isUploadPaused) && retryMessage && createElement(View, {
185
+ style: [styles.imageContainer, retryContainerStyles]
177
186
  }, createElement(View, {
178
- style: [styles.retryIcon, retryIcon && styles.customRetryIcon]
179
- }, getIcon(ICON_TYPE.RETRY)), createElement(Text, {
180
- style: styles.uploadFailedText
187
+ style: [retryIconStyles, retryIcon && styles.customRetryIcon]
188
+ }, isUploadPaused ? getIcon(ICON_TYPE.OFFLINE) : getIcon(ICON_TYPE.RETRY)), createElement(Text, {
189
+ style: uploadFailedTextStyles
181
190
  }, retryMessage))), editButton && isSelected && !isUploadInProgress && createElement(ImageEditingButton, {
182
191
  onSelectMediaUploadOption: onSelectMediaUploadOption,
183
192
  openMediaOptions: openMediaOptions,
184
- url: !isUploadFailed && imageData && url,
193
+ url: !(isUploadFailed || isUploadPaused) && imageData && url,
185
194
  pickerOptions: mediaPickerOptions
186
195
  }));
187
196
  };
@@ -1 +1 @@
1
- {"version":3,"names":["Image","RNImage","Text","View","FastImage","__","Icon","image","icon","usePreferredColorSchemeStyle","useEffect","useState","Platform","getImageWithFocalPointStyles","styles","SvgIconRetry","ImageEditingButton","ICON_TYPE","PLACEHOLDER","RETRY","UPLOAD","IMAGE_DEFAULT_FOCAL_POINT","x","y","ImageComponent","align","alt","editButton","focalPoint","height","imageHeight","highlightSelected","isSelected","shouldUseFastImage","isUploadFailed","isUploadInProgress","mediaPickerOptions","onImageDataLoad","onSelectMediaUploadOption","openMediaOptions","resizeMode","retryMessage","retryIcon","url","shapeStyle","style","width","imageWidth","imageData","setImageData","containerSize","setContainerSize","isAndroid","imageResizeMode","isCurrent","getSize","imgWidth","imgHeight","metaData","aspectRatio","onContainerLayout","event","nativeEvent","layout","getIcon","iconType","iconStyle","createElement","iconRetry","iconPlaceholderStyles","iconUploadStyles","iconPlaceholder","iconPlaceholderDark","iconUpload","iconUploadDark","placeholderStyles","imageContainerUpload","imageContainerUploadDark","imageContainerUploadWithFocalpoint","customWidth","wide","imageContainerStyles","imageContent","focalPointContainer","imageStyles","opacity","undefined","imageSelectedStyles","imageBorder","imageBorderDark","container","alignItems","onLayout","accessible","disabled","accessibilityLabel","accessibilityHint","accessibilityRole","key","imageUploadingIconContainer","focalPointContent","source","uri","resizeMethod","imageContainer","retryContainer","customRetryIcon","uploadFailedText","pickerOptions"],"sources":["@wordpress/components/src/mobile/image/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Image as RNImage, Text, View } from 'react-native';\nimport FastImage from 'react-native-fast-image';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon } from '@wordpress/components';\nimport { image as icon } from '@wordpress/icons';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { useEffect, useState, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getImageWithFocalPointStyles } from './utils';\nimport styles from './style.scss';\nimport SvgIconRetry from './icon-retry';\nimport ImageEditingButton from './image-editing-button';\n\nconst ICON_TYPE = {\n\tPLACEHOLDER: 'placeholder',\n\tRETRY: 'retry',\n\tUPLOAD: 'upload',\n};\n\nexport const IMAGE_DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\n\nconst ImageComponent = ( {\n\talign,\n\talt,\n\teditButton = true,\n\tfocalPoint,\n\theight: imageHeight,\n\thighlightSelected = true,\n\tisSelected,\n\tshouldUseFastImage,\n\tisUploadFailed,\n\tisUploadInProgress,\n\tmediaPickerOptions,\n\tonImageDataLoad,\n\tonSelectMediaUploadOption,\n\topenMediaOptions,\n\tresizeMode,\n\tretryMessage,\n\tretryIcon,\n\turl,\n\tshapeStyle,\n\tstyle,\n\twidth: imageWidth,\n} ) => {\n\tconst [ imageData, setImageData ] = useState( null );\n\tconst [ containerSize, setContainerSize ] = useState( null );\n\n\t// Disabled for Android due to https://github.com/WordPress/gutenberg/issues/43149\n\tconst Image =\n\t\t! shouldUseFastImage || Platform.isAndroid ? RNImage : FastImage;\n\tconst imageResizeMode =\n\t\t! shouldUseFastImage || Platform.isAndroid\n\t\t\t? resizeMode\n\t\t\t: FastImage.resizeMode[ resizeMode ];\n\n\tuseEffect( () => {\n\t\tlet isCurrent = true;\n\t\tif ( url ) {\n\t\t\tRNImage.getSize( url, ( imgWidth, imgHeight ) => {\n\t\t\t\tif ( ! isCurrent ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst metaData = {\n\t\t\t\t\taspectRatio: imgWidth / imgHeight,\n\t\t\t\t\twidth: imgWidth,\n\t\t\t\t\theight: imgHeight,\n\t\t\t\t};\n\t\t\t\tsetImageData( metaData );\n\t\t\t\tif ( onImageDataLoad ) {\n\t\t\t\t\tonImageDataLoad( metaData );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\treturn () => ( isCurrent = false );\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ url ] );\n\n\tconst onContainerLayout = ( event ) => {\n\t\tconst { height, width } = event.nativeEvent.layout;\n\n\t\tif (\n\t\t\twidth !== 0 &&\n\t\t\theight !== 0 &&\n\t\t\t( containerSize?.width !== width ||\n\t\t\t\tcontainerSize?.height !== height )\n\t\t) {\n\t\t\tsetContainerSize( { width, height } );\n\t\t}\n\t};\n\n\tconst getIcon = ( iconType ) => {\n\t\tlet iconStyle;\n\t\tswitch ( iconType ) {\n\t\t\tcase ICON_TYPE.RETRY:\n\t\t\t\treturn (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ retryIcon || SvgIconRetry }\n\t\t\t\t\t\t{ ...styles.iconRetry }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\tcase ICON_TYPE.PLACEHOLDER:\n\t\t\t\ticonStyle = iconPlaceholderStyles;\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.UPLOAD:\n\t\t\t\ticonStyle = iconUploadStyles;\n\t\t\t\tbreak;\n\t\t}\n\t\treturn <Icon icon={ icon } { ...iconStyle } />;\n\t};\n\n\tconst iconPlaceholderStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconPlaceholder,\n\t\tstyles.iconPlaceholderDark\n\t);\n\n\tconst iconUploadStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconUpload,\n\t\tstyles.iconUploadDark\n\t);\n\n\tconst placeholderStyles = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.imageContainerUpload,\n\t\t\tstyles.imageContainerUploadDark\n\t\t),\n\t\tfocalPoint && styles.imageContainerUploadWithFocalpoint,\n\t\timageHeight && { height: imageHeight },\n\t];\n\n\tconst customWidth =\n\t\timageData?.width < containerSize?.width\n\t\t\t? imageData?.width\n\t\t\t: styles.wide?.width;\n\n\tconst imageContainerStyles = [\n\t\tstyles.imageContent,\n\t\t{\n\t\t\twidth:\n\t\t\t\timageWidth === styles.wide?.width ||\n\t\t\t\t( imageData &&\n\t\t\t\t\timageWidth > 0 &&\n\t\t\t\t\timageWidth < containerSize?.width )\n\t\t\t\t\t? imageWidth\n\t\t\t\t\t: customWidth,\n\t\t},\n\t\tresizeMode && { width: styles.wide?.width },\n\t\tfocalPoint && styles.focalPointContainer,\n\t];\n\n\tconst imageStyles = [\n\t\t{\n\t\t\topacity: isUploadInProgress ? 0.3 : 1,\n\t\t\theight: containerSize?.height,\n\t\t},\n\t\t! resizeMode && {\n\t\t\taspectRatio: imageData?.aspectRatio,\n\t\t},\n\t\tfocalPoint && styles.focalPoint,\n\t\tfocalPoint &&\n\t\t\tgetImageWithFocalPointStyles(\n\t\t\t\tfocalPoint,\n\t\t\t\tcontainerSize,\n\t\t\t\timageData\n\t\t\t),\n\t\t! focalPoint &&\n\t\t\timageData &&\n\t\t\tcontainerSize && {\n\t\t\t\theight:\n\t\t\t\t\timageData?.width > containerSize?.width && ! imageWidth\n\t\t\t\t\t\t? containerSize?.width / imageData?.aspectRatio\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\timageHeight && { height: imageHeight },\n\t\tshapeStyle,\n\t];\n\tconst imageSelectedStyles = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.imageBorder,\n\t\t\tstyles.imageBorderDark\n\t\t),\n\t\t{ height: containerSize?.height },\n\t];\n\n\treturn (\n\t\t<View\n\t\t\tstyle={ [\n\t\t\t\tstyles.container,\n\t\t\t\t// Only set alignItems if an image exists because alignItems causes the placeholder\n\t\t\t\t// to disappear when an aligned image can't be downloaded\n\t\t\t\t// https://github.com/wordpress-mobile/gutenberg-mobile/issues/1592\n\t\t\t\timageData && align && { alignItems: align },\n\t\t\t\tstyle,\n\t\t\t] }\n\t\t\tonLayout={ onContainerLayout }\n\t\t>\n\t\t\t<View\n\t\t\t\taccessible\n\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\taccessibilityLabel={ alt }\n\t\t\t\taccessibilityHint={ __( 'Double tap and hold to edit' ) }\n\t\t\t\taccessibilityRole={ 'imagebutton' }\n\t\t\t\tkey={ url }\n\t\t\t\tstyle={ imageContainerStyles }\n\t\t\t>\n\t\t\t\t{ isSelected &&\n\t\t\t\t\thighlightSelected &&\n\t\t\t\t\t! ( isUploadInProgress || isUploadFailed ) && (\n\t\t\t\t\t\t<View style={ imageSelectedStyles } />\n\t\t\t\t\t) }\n\n\t\t\t\t{ ! imageData ? (\n\t\t\t\t\t<View style={ placeholderStyles }>\n\t\t\t\t\t\t<View style={ styles.imageUploadingIconContainer }>\n\t\t\t\t\t\t\t{ getIcon( ICON_TYPE.UPLOAD ) }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</View>\n\t\t\t\t) : (\n\t\t\t\t\t<View style={ focalPoint && styles.focalPointContent }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\tstyle={ imageStyles }\n\t\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t\t\t{ ...( ! focalPoint && {\n\t\t\t\t\t\t\t\tresizeMethod: 'scale',\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tresizeMode={ imageResizeMode }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\n\t\t\t\t{ isUploadFailed && retryMessage && (\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\tstyles.imageContainer,\n\t\t\t\t\t\t\tstyles.retryContainer,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<View\n\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\tstyles.retryIcon,\n\t\t\t\t\t\t\t\tretryIcon && styles.customRetryIcon,\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ getIcon( ICON_TYPE.RETRY ) }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<Text style={ styles.uploadFailedText }>\n\t\t\t\t\t\t\t{ retryMessage }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\t\t\t</View>\n\n\t\t\t{ editButton && isSelected && ! isUploadInProgress && (\n\t\t\t\t<ImageEditingButton\n\t\t\t\t\tonSelectMediaUploadOption={ onSelectMediaUploadOption }\n\t\t\t\t\topenMediaOptions={ openMediaOptions }\n\t\t\t\t\turl={ ! isUploadFailed && imageData && url }\n\t\t\t\t\tpickerOptions={ mediaPickerOptions }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</View>\n\t);\n};\n\nexport default ImageComponent;\n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vDC,gBAAgB,EAAGA,gBAAkB;IACrCI,GAAG,EAAG,CAAET,cAAc,IAAIc,SAAS,IAAIL,GAAK;IAC5CiE,aAAa,EAAGxE;EAAoB,CACpC,CAEG,CAAC;AAET,CAAC;AAED,eAAeZ,cAAc"}
1
+ {"version":3,"names":["Image","RNImage","Text","View","FastImage","__","Icon","image","offline","usePreferredColorSchemeStyle","useEffect","useState","Platform","getImageWithFocalPointStyles","styles","SvgIconRetry","ImageEditingButton","ICON_TYPE","OFFLINE","PLACEHOLDER","RETRY","UPLOAD","ImageComponent","align","alt","editButton","focalPoint","height","imageHeight","highlightSelected","isSelected","shouldUseFastImage","isUploadFailed","isUploadPaused","isUploadInProgress","mediaPickerOptions","onImageDataLoad","onSelectMediaUploadOption","openMediaOptions","resizeMode","retryMessage","retryIcon","url","shapeStyle","style","width","imageWidth","imageData","setImageData","containerSize","setContainerSize","isAndroid","imageResizeMode","isCurrent","getSize","imgWidth","imgHeight","metaData","aspectRatio","onContainerLayout","event","nativeEvent","layout","getIcon","iconType","icon","iconStyle","iconRetryStyles","iconOfflineStyles","iconPlaceholderStyles","iconUploadStyles","createElement","iconPlaceholder","iconPlaceholderDark","iconUpload","iconUploadDark","iconOffline","iconOfflineDark","retryIconStyles","retryIconDark","iconRetry","iconRetryDark","retryContainerStyles","retryContainer","retryContainerDark","uploadFailedTextStyles","uploadFailedText","uploadFailedTextDark","placeholderStyles","imageContainerUpload","imageContainerUploadDark","imageContainerUploadWithFocalpoint","customWidth","wide","imageContainerStyles","imageContent","focalPointContainer","imageStyles","opacity","undefined","imageSelectedStyles","imageBorder","imageBorderDark","container","alignItems","onLayout","accessible","disabled","accessibilityLabel","accessibilityHint","accessibilityRole","key","imageUploadingIconContainer","focalPointContent","source","uri","resizeMethod","imageContainer","customRetryIcon","pickerOptions"],"sources":["@wordpress/components/src/mobile/image/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Image as RNImage, Text, View } from 'react-native';\nimport FastImage from 'react-native-fast-image';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon } from '@wordpress/components';\nimport { image, offline } from '@wordpress/icons';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { useEffect, useState, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getImageWithFocalPointStyles } from './utils';\nimport styles from './style.scss';\nimport SvgIconRetry from './icon-retry';\nimport ImageEditingButton from './image-editing-button';\n\nconst ICON_TYPE = {\n\tOFFLINE: 'offline',\n\tPLACEHOLDER: 'placeholder',\n\tRETRY: 'retry',\n\tUPLOAD: 'upload',\n};\n\nconst ImageComponent = ( {\n\talign,\n\talt,\n\teditButton = true,\n\tfocalPoint,\n\theight: imageHeight,\n\thighlightSelected = true,\n\tisSelected,\n\tshouldUseFastImage,\n\tisUploadFailed,\n\tisUploadPaused,\n\tisUploadInProgress,\n\tmediaPickerOptions,\n\tonImageDataLoad,\n\tonSelectMediaUploadOption,\n\topenMediaOptions,\n\tresizeMode,\n\tretryMessage,\n\tretryIcon,\n\turl,\n\tshapeStyle,\n\tstyle,\n\twidth: imageWidth,\n} ) => {\n\tconst [ imageData, setImageData ] = useState( null );\n\tconst [ containerSize, setContainerSize ] = useState( null );\n\n\t// Disabled for Android due to https://github.com/WordPress/gutenberg/issues/43149\n\tconst Image =\n\t\t! shouldUseFastImage || Platform.isAndroid ? RNImage : FastImage;\n\tconst imageResizeMode =\n\t\t! shouldUseFastImage || Platform.isAndroid\n\t\t\t? resizeMode\n\t\t\t: FastImage.resizeMode[ resizeMode ];\n\n\tuseEffect( () => {\n\t\tlet isCurrent = true;\n\t\tif ( url ) {\n\t\t\tRNImage.getSize( url, ( imgWidth, imgHeight ) => {\n\t\t\t\tif ( ! isCurrent ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst metaData = {\n\t\t\t\t\taspectRatio: imgWidth / imgHeight,\n\t\t\t\t\twidth: imgWidth,\n\t\t\t\t\theight: imgHeight,\n\t\t\t\t};\n\t\t\t\tsetImageData( metaData );\n\t\t\t\tif ( onImageDataLoad ) {\n\t\t\t\t\tonImageDataLoad( metaData );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\treturn () => ( isCurrent = false );\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ url ] );\n\n\tconst onContainerLayout = ( event ) => {\n\t\tconst { height, width } = event.nativeEvent.layout;\n\n\t\tif (\n\t\t\twidth !== 0 &&\n\t\t\theight !== 0 &&\n\t\t\t( containerSize?.width !== width ||\n\t\t\t\tcontainerSize?.height !== height )\n\t\t) {\n\t\t\tsetContainerSize( { width, height } );\n\t\t}\n\t};\n\n\tconst getIcon = ( iconType ) => {\n\t\tlet icon;\n\t\tlet iconStyle;\n\t\tswitch ( iconType ) {\n\t\t\tcase ICON_TYPE.RETRY:\n\t\t\t\ticon = retryIcon || SvgIconRetry;\n\t\t\t\ticonStyle = iconRetryStyles;\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.OFFLINE:\n\t\t\t\ticon = offline;\n\t\t\t\ticonStyle = iconOfflineStyles;\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.PLACEHOLDER:\n\t\t\t\ticon = image;\n\t\t\t\ticonStyle = iconPlaceholderStyles;\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.UPLOAD:\n\t\t\t\ticon = image;\n\t\t\t\ticonStyle = iconUploadStyles;\n\t\t\t\tbreak;\n\t\t}\n\t\treturn <Icon icon={ icon } { ...iconStyle } />;\n\t};\n\n\tconst iconPlaceholderStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconPlaceholder,\n\t\tstyles.iconPlaceholderDark\n\t);\n\n\tconst iconUploadStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconUpload,\n\t\tstyles.iconUploadDark\n\t);\n\n\tconst iconOfflineStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconOffline,\n\t\tstyles.iconOfflineDark\n\t);\n\n\tconst retryIconStyles = usePreferredColorSchemeStyle(\n\t\tstyles.retryIcon,\n\t\tstyles.retryIconDark\n\t);\n\n\tconst iconRetryStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconRetry,\n\t\tstyles.iconRetryDark\n\t);\n\n\tconst retryContainerStyles = usePreferredColorSchemeStyle(\n\t\tstyles.retryContainer,\n\t\tstyles.retryContainerDark\n\t);\n\n\tconst uploadFailedTextStyles = usePreferredColorSchemeStyle(\n\t\tstyles.uploadFailedText,\n\t\tstyles.uploadFailedTextDark\n\t);\n\n\tconst placeholderStyles = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.imageContainerUpload,\n\t\t\tstyles.imageContainerUploadDark\n\t\t),\n\t\tfocalPoint && styles.imageContainerUploadWithFocalpoint,\n\t\timageHeight && { height: imageHeight },\n\t];\n\n\tconst customWidth =\n\t\timageData?.width < containerSize?.width\n\t\t\t? imageData?.width\n\t\t\t: styles.wide?.width;\n\n\tconst imageContainerStyles = [\n\t\tstyles.imageContent,\n\t\t{\n\t\t\twidth:\n\t\t\t\timageWidth === styles.wide?.width ||\n\t\t\t\t( imageData &&\n\t\t\t\t\timageWidth > 0 &&\n\t\t\t\t\timageWidth < containerSize?.width )\n\t\t\t\t\t? imageWidth\n\t\t\t\t\t: customWidth,\n\t\t},\n\t\tresizeMode && { width: styles.wide?.width },\n\t\tfocalPoint && styles.focalPointContainer,\n\t];\n\n\tconst imageStyles = [\n\t\t{\n\t\t\topacity: isUploadInProgress ? 0.3 : 1,\n\t\t\theight: containerSize?.height,\n\t\t},\n\t\t! resizeMode && {\n\t\t\taspectRatio: imageData?.aspectRatio,\n\t\t},\n\t\tfocalPoint && styles.focalPoint,\n\t\tfocalPoint &&\n\t\t\tgetImageWithFocalPointStyles(\n\t\t\t\tfocalPoint,\n\t\t\t\tcontainerSize,\n\t\t\t\timageData\n\t\t\t),\n\t\t! focalPoint &&\n\t\t\timageData &&\n\t\t\tcontainerSize && {\n\t\t\t\theight:\n\t\t\t\t\timageData?.width > containerSize?.width && ! imageWidth\n\t\t\t\t\t\t? containerSize?.width / imageData?.aspectRatio\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\timageHeight && { height: imageHeight },\n\t\tshapeStyle,\n\t];\n\tconst imageSelectedStyles = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.imageBorder,\n\t\t\tstyles.imageBorderDark\n\t\t),\n\t\t{ height: containerSize?.height },\n\t];\n\n\treturn (\n\t\t<View\n\t\t\tstyle={ [\n\t\t\t\tstyles.container,\n\t\t\t\t// Only set alignItems if an image exists because alignItems causes the placeholder\n\t\t\t\t// to disappear when an aligned image can't be downloaded\n\t\t\t\t// https://github.com/wordpress-mobile/gutenberg-mobile/issues/1592\n\t\t\t\timageData && align && { alignItems: align },\n\t\t\t\tstyle,\n\t\t\t] }\n\t\t\tonLayout={ onContainerLayout }\n\t\t>\n\t\t\t<View\n\t\t\t\taccessible\n\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\taccessibilityLabel={ alt }\n\t\t\t\taccessibilityHint={ __( 'Double tap and hold to edit' ) }\n\t\t\t\taccessibilityRole={ 'imagebutton' }\n\t\t\t\tkey={ url }\n\t\t\t\tstyle={ imageContainerStyles }\n\t\t\t>\n\t\t\t\t{ isSelected &&\n\t\t\t\t\thighlightSelected &&\n\t\t\t\t\t! (\n\t\t\t\t\t\tisUploadInProgress ||\n\t\t\t\t\t\tisUploadFailed ||\n\t\t\t\t\t\tisUploadPaused\n\t\t\t\t\t) && <View style={ imageSelectedStyles } /> }\n\n\t\t\t\t{ ! imageData ? (\n\t\t\t\t\t<View style={ placeholderStyles }>\n\t\t\t\t\t\t<View style={ styles.imageUploadingIconContainer }>\n\t\t\t\t\t\t\t{ getIcon( ICON_TYPE.UPLOAD ) }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</View>\n\t\t\t\t) : (\n\t\t\t\t\t<View style={ focalPoint && styles.focalPointContent }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\tstyle={ imageStyles }\n\t\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t\t\t{ ...( ! focalPoint && {\n\t\t\t\t\t\t\t\tresizeMethod: 'scale',\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tresizeMode={ imageResizeMode }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\n\t\t\t\t{ ( isUploadFailed || isUploadPaused ) && retryMessage && (\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\tstyles.imageContainer,\n\t\t\t\t\t\t\tretryContainerStyles,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<View\n\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\tretryIconStyles,\n\t\t\t\t\t\t\t\tretryIcon && styles.customRetryIcon,\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ isUploadPaused\n\t\t\t\t\t\t\t\t? getIcon( ICON_TYPE.OFFLINE )\n\t\t\t\t\t\t\t\t: getIcon( ICON_TYPE.RETRY ) }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<Text style={ uploadFailedTextStyles }>\n\t\t\t\t\t\t\t{ retryMessage }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\t\t\t</View>\n\n\t\t\t{ editButton && isSelected && ! isUploadInProgress && (\n\t\t\t\t<ImageEditingButton\n\t\t\t\t\tonSelectMediaUploadOption={ onSelectMediaUploadOption }\n\t\t\t\t\topenMediaOptions={ openMediaOptions }\n\t\t\t\t\turl={\n\t\t\t\t\t\t! ( isUploadFailed || isUploadPaused ) &&\n\t\t\t\t\t\timageData &&\n\t\t\t\t\t\turl\n\t\t\t\t\t}\n\t\t\t\t\tpickerOptions={ mediaPickerOptions }\n\t\t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I,CAAG;IAAA,IAChB,CAAEhB,UAAU,IAAI;MACtB0F,YAAY,EAAE;IACf,CAAC;IACD7E,UAAU,EAAGa;EAAiB,CAC9B,CACI,CACN,EAEC,CAAEpB,cAAc,IAAIC,cAAc,KAAMO,YAAY,IACrD+B,aAAA,CAACpE,IAAI;IACJyC,KAAK,EAAG,CACP9B,MAAM,CAACuG,cAAc,EACrBnC,oBAAoB;EAClB,GAEHX,aAAA,CAACpE,IAAI;IACJyC,KAAK,EAAG,CACPkC,eAAe,EACfrC,SAAS,IAAI3B,MAAM,CAACwG,eAAe;EACjC,GAEDrF,cAAc,GACb8B,OAAO,CAAE9C,SAAS,CAACC,OAAQ,CAAC,GAC5B6C,OAAO,CAAE9C,SAAS,CAACG,KAAM,CACvB,CAAC,EACPmD,aAAA,CAACrE,IAAI;IAAC0C,KAAK,EAAGyC;EAAwB,GACnC7C,YACG,CACD,CAEF,CAAC,EAELf,UAAU,IAAIK,UAAU,IAAI,CAAEI,kBAAkB,IACjDqC,aAAA,CAACvD,kBAAkB;IAClBqB,yBAAyB,EAAGA,yBAA2B;IACvDC,gBAAgB,EAAGA,gBAAkB;IACrCI,GAAG,EACF,EAAIV,cAAc,IAAIC,cAAc,CAAE,IACtCc,SAAS,IACTL,GACA;IACD6E,aAAa,EAAGpF;EAAoB,CACpC,CAEG,CAAC;AAET,CAAC;AAED,eAAeb,cAAc"}
@@ -3,30 +3,64 @@ import { createElement } from "react";
3
3
  * External dependencies
4
4
  */
5
5
  import { FlatList } from 'react-native';
6
- import Animated, { useAnimatedScrollHandler } from 'react-native-reanimated';
6
+ import Animated from 'react-native-reanimated';
7
+
8
+ /**
9
+ * WordPress dependencies
10
+ */
11
+ import { forwardRef, useCallback, useImperativeHandle } from '@wordpress/element';
7
12
 
8
13
  /**
9
14
  * Internal dependencies
10
15
  */
16
+ import useScroll from './use-scroll';
11
17
  import KeyboardAvoidingView from '../keyboard-avoiding-view';
12
18
  const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
13
19
  export const KeyboardAwareFlatList = ({
14
- innerRef,
15
20
  onScroll,
16
21
  ...props
17
- }) => {
18
- const scrollHandler = useAnimatedScrollHandler({
22
+ }, ref) => {
23
+ const {
24
+ extraScrollHeight,
25
+ scrollEnabled,
26
+ shouldPreventAutomaticScroll
27
+ } = props;
28
+ const {
29
+ scrollViewRef,
30
+ scrollHandler,
31
+ scrollToSection,
32
+ scrollToElement,
33
+ onContentSizeChange,
34
+ lastScrollTo
35
+ } = useScroll({
36
+ scrollEnabled,
37
+ shouldPreventAutomaticScroll,
38
+ extraScrollHeight,
19
39
  onScroll
20
40
  });
41
+ const getFlatListRef = useCallback(flatListRef => {
42
+ // On Android, we get the ref of the associated scroll
43
+ // view to the FlatList.
44
+ scrollViewRef.current = flatListRef?.getNativeScrollRef();
45
+ }, [scrollViewRef]);
46
+ useImperativeHandle(ref, () => {
47
+ return {
48
+ scrollViewRef: scrollViewRef.current,
49
+ scrollToSection,
50
+ scrollToElement,
51
+ lastScrollTo
52
+ };
53
+ });
21
54
  return createElement(KeyboardAvoidingView, {
22
55
  style: {
23
56
  flex: 1
24
57
  }
25
58
  }, createElement(AnimatedFlatList, {
26
- ref: innerRef,
59
+ ref: getFlatListRef,
27
60
  onScroll: scrollHandler,
61
+ onContentSizeChange: onContentSizeChange,
28
62
  ...props
29
63
  }));
30
64
  };
31
- export default KeyboardAwareFlatList;
65
+ export default forwardRef(KeyboardAwareFlatList);
32
66
  //# sourceMappingURL=index.android.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["FlatList","Animated","useAnimatedScrollHandler","KeyboardAvoidingView","AnimatedFlatList","createAnimatedComponent","KeyboardAwareFlatList","innerRef","onScroll","props","scrollHandler","createElement","style","flex","ref"],"sources":["@wordpress/components/src/mobile/keyboard-aware-flat-list/index.android.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { FlatList } from 'react-native';\nimport Animated, { useAnimatedScrollHandler } from 'react-native-reanimated';\n\n/**\n * Internal dependencies\n */\nimport KeyboardAvoidingView from '../keyboard-avoiding-view';\n\nconst AnimatedFlatList = Animated.createAnimatedComponent( FlatList );\n\nexport const KeyboardAwareFlatList = ( { innerRef, onScroll, ...props } ) => {\n\tconst scrollHandler = useAnimatedScrollHandler( { onScroll } );\n\treturn (\n\t\t<KeyboardAvoidingView style={ { flex: 1 } }>\n\t\t\t<AnimatedFlatList\n\t\t\t\tref={ innerRef }\n\t\t\t\tonScroll={ scrollHandler }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</KeyboardAvoidingView>\n\t);\n};\n\nexport default KeyboardAwareFlatList;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,QAAQ,IAAIC,wBAAwB,QAAQ,yBAAyB;;AAE5E;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,2BAA2B;AAE5D,MAAMC,gBAAgB,GAAGH,QAAQ,CAACI,uBAAuB,CAAEL,QAAS,CAAC;AAErE,OAAO,MAAMM,qBAAqB,GAAGA,CAAE;EAAEC,QAAQ;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,KAAM;EAC5E,MAAMC,aAAa,GAAGR,wBAAwB,CAAE;IAAEM;EAAS,CAAE,CAAC;EAC9D,OACCG,aAAA,CAACR,oBAAoB;IAACS,KAAK,EAAG;MAAEC,IAAI,EAAE;IAAE;EAAG,GAC1CF,aAAA,CAACP,gBAAgB;IAChBU,GAAG,EAAGP,QAAU;IAChBC,QAAQ,EAAGE,aAAe;IAAA,GACrBD;EAAK,CACV,CACoB,CAAC;AAEzB,CAAC;AAED,eAAeH,qBAAqB"}
1
+ {"version":3,"names":["FlatList","Animated","forwardRef","useCallback","useImperativeHandle","useScroll","KeyboardAvoidingView","AnimatedFlatList","createAnimatedComponent","KeyboardAwareFlatList","onScroll","props","ref","extraScrollHeight","scrollEnabled","shouldPreventAutomaticScroll","scrollViewRef","scrollHandler","scrollToSection","scrollToElement","onContentSizeChange","lastScrollTo","getFlatListRef","flatListRef","current","getNativeScrollRef","createElement","style","flex"],"sources":["@wordpress/components/src/mobile/keyboard-aware-flat-list/index.android.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { FlatList } from 'react-native';\nimport Animated from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tforwardRef,\n\tuseCallback,\n\tuseImperativeHandle,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useScroll from './use-scroll';\nimport KeyboardAvoidingView from '../keyboard-avoiding-view';\n\nconst AnimatedFlatList = Animated.createAnimatedComponent( FlatList );\n\nexport const KeyboardAwareFlatList = ( { onScroll, ...props }, ref ) => {\n\tconst { extraScrollHeight, scrollEnabled, shouldPreventAutomaticScroll } =\n\t\tprops;\n\n\tconst {\n\t\tscrollViewRef,\n\t\tscrollHandler,\n\t\tscrollToSection,\n\t\tscrollToElement,\n\t\tonContentSizeChange,\n\t\tlastScrollTo,\n\t} = useScroll( {\n\t\tscrollEnabled,\n\t\tshouldPreventAutomaticScroll,\n\t\textraScrollHeight,\n\t\tonScroll,\n\t} );\n\n\tconst getFlatListRef = useCallback(\n\t\t( flatListRef ) => {\n\t\t\t// On Android, we get the ref of the associated scroll\n\t\t\t// view to the FlatList.\n\t\t\tscrollViewRef.current = flatListRef?.getNativeScrollRef();\n\t\t},\n\t\t[ scrollViewRef ]\n\t);\n\n\tuseImperativeHandle( ref, () => {\n\t\treturn {\n\t\t\tscrollViewRef: scrollViewRef.current,\n\t\t\tscrollToSection,\n\t\t\tscrollToElement,\n\t\t\tlastScrollTo,\n\t\t};\n\t} );\n\n\treturn (\n\t\t<KeyboardAvoidingView style={ { flex: 1 } }>\n\t\t\t<AnimatedFlatList\n\t\t\t\tref={ getFlatListRef }\n\t\t\t\tonScroll={ scrollHandler }\n\t\t\t\tonContentSizeChange={ onContentSizeChange }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</KeyboardAvoidingView>\n\t);\n};\n\nexport default forwardRef( KeyboardAwareFl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,CACV,CACoB,CAAC;AAEzB,CAAC;AAED,eAAeT,UAAU,CAAEO,qBAAsB,CAAC"}
@@ -3,111 +3,81 @@ import { createElement } from "react";
3
3
  * External dependencies
4
4
  */
5
5
 
6
- import { ScrollView, FlatList, useWindowDimensions } from 'react-native';
7
- import Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated';
6
+ import { ScrollView, FlatList } from 'react-native';
7
+ import Animated from 'react-native-reanimated';
8
8
 
9
9
  /**
10
10
  * WordPress dependencies
11
11
  */
12
- import { useCallback, useEffect, useRef } from '@wordpress/element';
12
+ import { useCallback, useEffect, forwardRef, useImperativeHandle } from '@wordpress/element';
13
13
  import { useThrottle } from '@wordpress/compose';
14
14
 
15
15
  /**
16
16
  * Internal dependencies
17
17
  */
18
+ import useScroll from './use-scroll';
18
19
  import useTextInputOffset from './use-text-input-offset';
19
- import useKeyboardOffset from './use-keyboard-offset';
20
- import useScrollToTextInput from './use-scroll-to-text-input';
21
20
  import useTextInputCaretPosition from './use-text-input-caret-position';
21
+ const DEFAULT_FONT_SIZE = 16;
22
22
  const AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);
23
23
 
24
+ /** @typedef {import('@wordpress/element').RefObject} RefObject */
24
25
  /**
25
26
  * React component that provides a FlatList that is aware of the keyboard state and can scroll
26
27
  * to the currently focused TextInput.
27
28
  *
28
- * @param {Object} props Component props.
29
- * @param {number} props.extraScrollHeight Extra scroll height for the content.
30
- * @param {Function} props.innerRef Function to pass the ScrollView ref to the parent component.
31
- * @param {Function} props.onScroll Function to be called when the list is scrolled.
32
- * @param {boolean} props.scrollEnabled Whether the list can be scrolled.
33
- * @param {Object} props.scrollViewStyle Additional style for the ScrollView component.
34
- * @param {boolean} props.shouldPreventAutomaticScroll Whether to prevent scrolling when there's a Keyboard offset set.
35
- * @param {Object} props... Other props to pass to the FlatList component.
29
+ * @param {Object} props Component props.
30
+ * @param {number} props.extraScrollHeight Extra scroll height for the content.
31
+ * @param {Function} props.onScroll Function to be called when the list is scrolled.
32
+ * @param {boolean} props.scrollEnabled Whether the list can be scrolled.
33
+ * @param {Object} props.scrollViewStyle Additional style for the ScrollView component.
34
+ * @param {boolean} props.shouldPreventAutomaticScroll Whether to prevent scrolling when there's a Keyboard offset set.
35
+ * @param {Object} props... Other props to pass to the FlatList component.
36
+ * @param {RefObject} ref
36
37
  * @return {Component} KeyboardAwareFlatList component.
37
38
  */
38
39
  export const KeyboardAwareFlatList = ({
39
40
  extraScrollHeight,
40
- innerRef,
41
41
  onScroll,
42
42
  scrollEnabled,
43
43
  scrollViewStyle,
44
44
  shouldPreventAutomaticScroll,
45
45
  ...props
46
- }) => {
47
- const scrollViewRef = useRef();
48
- const scrollViewMeasurements = useRef();
49
- const scrollViewYOffset = useSharedValue(-1);
46
+ }, ref) => {
50
47
  const {
51
- height: windowHeight,
52
- width: windowWidth
53
- } = useWindowDimensions();
54
- const isLandscape = windowWidth >= windowHeight;
55
- const [keyboardOffset] = useKeyboardOffset(scrollEnabled, shouldPreventAutomaticScroll);
56
- const [currentCaretData] = useTextInputCaretPosition(scrollEnabled);
48
+ scrollViewRef,
49
+ scrollHandler,
50
+ keyboardOffset,
51
+ scrollToSection,
52
+ scrollToElement,
53
+ onContentSizeChange,
54
+ lastScrollTo
55
+ } = useScroll({
56
+ scrollEnabled,
57
+ shouldPreventAutomaticScroll,
58
+ extraScrollHeight,
59
+ onScroll,
60
+ onSizeChange
61
+ });
57
62
  const [getTextInputOffset] = useTextInputOffset(scrollEnabled, scrollViewRef);
58
- const [scrollToTextInputOffset] = useScrollToTextInput(extraScrollHeight, keyboardOffset, scrollEnabled, scrollViewMeasurements, scrollViewRef, scrollViewYOffset);
59
63
  const onScrollToTextInput = useThrottle(useCallback(async caret => {
64
+ const {
65
+ caretHeight = DEFAULT_FONT_SIZE
66
+ } = caret !== null && caret !== void 0 ? caret : {};
60
67
  const textInputOffset = await getTextInputOffset(caret);
61
68
  const hasTextInputOffset = textInputOffset !== null;
62
69
  if (hasTextInputOffset) {
63
- scrollToTextInputOffset(caret, textInputOffset);
70
+ scrollToSection(textInputOffset, caretHeight);
64
71
  }
65
- }, [getTextInputOffset, scrollToTextInputOffset]), 200, {
72
+ }, [getTextInputOffset, scrollToSection]), 200, {
66
73
  leading: false
67
74
  });
75
+ const [currentCaretData] = useTextInputCaretPosition(scrollEnabled);
76
+ const onSizeChange = useCallback(() => onScrollToTextInput(currentCaretData), [currentCaretData, onScrollToTextInput]);
68
77
  useEffect(() => {
69
78
  onScrollToTextInput(currentCaretData);
70
79
  }, [currentCaretData, onScrollToTextInput]);
71
80
 
72
- // When the orientation changes, the ScrollView measurements
73
- // need to be re-calculated.
74
- useEffect(() => {
75
- scrollViewMeasurements.current = null;
76
- }, [isLandscape]);
77
- const scrollHandler = useAnimatedScrollHandler({
78
- onScroll: event => {
79
- const {
80
- contentOffset
81
- } = event;
82
- scrollViewYOffset.value = contentOffset.y;
83
- onScroll(event);
84
- }
85
- });
86
- const measureScrollView = useCallback(() => {
87
- if (scrollViewRef.current) {
88
- const scrollRef = scrollViewRef.current.getNativeScrollRef();
89
- scrollRef.measureInWindow((_x, y, width, height) => {
90
- scrollViewMeasurements.current = {
91
- y,
92
- width,
93
- height
94
- };
95
- });
96
- }
97
- }, []);
98
- const onContentSizeChange = useCallback(() => {
99
- onScrollToTextInput(currentCaretData);
100
-
101
- // Sets the first values when the content size changes.
102
- if (!scrollViewMeasurements.current) {
103
- measureScrollView();
104
- }
105
- }, [measureScrollView, onScrollToTextInput, currentCaretData]);
106
- const getRef = useCallback(ref => {
107
- scrollViewRef.current = ref;
108
- innerRef(ref);
109
- }, [innerRef]);
110
-
111
81
  // Adds content insets when the keyboard is opened to have
112
82
  // extra padding at the bottom.
113
83
  const contentInset = {
@@ -116,13 +86,21 @@ export const KeyboardAwareFlatList = ({
116
86
  const style = [{
117
87
  flex: 1
118
88
  }, scrollViewStyle];
89
+ useImperativeHandle(ref, () => {
90
+ return {
91
+ scrollViewRef: scrollViewRef.current,
92
+ scrollToSection,
93
+ scrollToElement,
94
+ lastScrollTo
95
+ };
96
+ });
119
97
  return createElement(AnimatedScrollView, {
120
98
  automaticallyAdjustContentInsets: false,
121
99
  contentInset: contentInset,
122
100
  keyboardShouldPersistTaps: "handled",
123
101
  onContentSizeChange: onContentSizeChange,
124
102
  onScroll: scrollHandler,
125
- ref: getRef,
103
+ ref: scrollViewRef,
126
104
  scrollEnabled: scrollEnabled,
127
105
  scrollEventThrottle: 16,
128
106
  style: style
@@ -131,5 +109,5 @@ export const KeyboardAwareFlatList = ({
131
109
  scrollEnabled: false
132
110
  }));
133
111
  };
134
- export default KeyboardAwareFlatList;
112
+ export default forwardRef(KeyboardAwareFlatList);
135
113
  //# sourceMappingURL=index.ios.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ScrollView","FlatList","useWindowDimensions","Animated","useAnimatedScrollHandler","useSharedValue","useCallback","useEffect","useRef","useThrottle","useTextInputOffset","useKeyboardOffset","useScrollToTextInput","useTextInputCaretPosition","AnimatedScrollView","createAnimatedComponent","KeyboardAwareFlatList","extraScrollHeight","innerRef","onScroll","scrollEnabled","scrollViewStyle","shouldPreventAutomaticScroll","props","scrollViewRef","scrollViewMeasurements","scrollViewYOffset","height","windowHeight","width","windowWidth","isLandscape","keyboardOffset","currentCaretData","getTextInputOffset","scrollToTextInputOffset","onScrollToTextInput","caret","textInputOffset","hasTextInputOffset","leading","current","scrollHandler","event","contentOffset","value","y","measureScrollView","scrollRef","getNativeScrollRef","measureInWindow","_x","onContentSizeChange","getRef","ref","contentInset","bottom","style","flex","createElement","automaticallyAdjustContentInsets","keyboardShouldPersistTaps","scrollEventThrottle"],"sources":["@wordpress/components/src/mobile/keyboard-aware-flat-list/index.ios.js"],"sourcesContent":["/**\n * External dependencies\n */\n\nimport { ScrollView, FlatList, useWindowDimensions } from 'react-native';\nimport Animated, {\n\tuseAnimatedScrollHandler,\n\tuseSharedValue,\n} from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useThrottle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useTextInputOffset from './use-text-input-offset';\nimport useKeyboardOffset from './use-keyboard-offset';\nimport useScrollToTextInput from './use-scroll-to-text-input';\nimport useTextInputCaretPosition from './use-text-input-caret-position';\n\nconst AnimatedScrollView = Animated.createAnimatedComponent( ScrollView );\n\n/**\n * React component that provides a FlatList that is aware of the keyboard state and can scroll\n * to the currently focused TextInput.\n *\n * @param {Object} props Component props.\n * @param {number} props.extraScrollHeight Extra scroll height for the content.\n * @param {Function} props.innerRef Function to pass the ScrollView ref to the parent component.\n * @param {Function} props.onScroll Function to be called when the list is scrolled.\n * @param {boolean} props.scrollEnabled Whether the list can be scrolled.\n * @param {Object} props.scrollViewStyle Additional style for the ScrollView component.\n * @param {boolean} props.shouldPreventAutomaticScroll Whether to prevent scrolling when there's a Keyboard offset set.\n * @param {Object} props... Other props to pass to the FlatList component.\n * @return {Component} KeyboardAwareFlatList component.\n */\nexport const KeyboardAwareFlatList = ( {\n\textraScrollHeight,\n\tinnerRef,\n\tonScroll,\n\tscrollEnabled,\n\tscrollViewStyle,\n\tshouldPreventAutomaticScroll,\n\t...props\n} ) => {\n\tconst scrollViewRef = useRef();\n\tconst scrollViewMeasurements = useRef();\n\tconst scrollViewYOffset = useSharedValue( -1 );\n\n\tconst { height: windowHeight, width: windowWidth } = useWindowDimensions();\n\tconst isLandscape = windowWidth >= windowHeight;\n\n\tconst [ keyboardOffset ] = useKeyboardOffset(\n\t\tscrollEnabled,\n\t\tshouldPreventAutomaticScroll\n\t);\n\n\tconst [ currentCaretData ] = useTextInputCaretPosition( scrollEnabled );\n\n\tconst [ getTextInputOffset ] = useTextInputOffset(\n\t\tscrollEnabled,\n\t\tscrollViewRef\n\t);\n\n\tconst [ scrollToTextInputOffset ] = useScrollToTextInput(\n\t\textraScrollHeight,\n\t\tkeyboardOffset,\n\t\tscrollEnabled,\n\t\tscrollViewMeasurements,\n\t\tscrollViewRef,\n\t\tscrollViewYOffset\n\t);\n\n\tconst onScrollToTextInput = useThrottle(\n\t\tuseCallback(\n\t\t\tasync ( caret ) => {\n\t\t\t\tconst textInputOffset = await getTextInputOffset( caret );\n\t\t\t\tconst hasTextInputOffset = textInputOffset !== null;\n\n\t\t\t\tif ( hasTextInputOffset ) {\n\t\t\t\t\tscrollToTextInputOffset( caret, textInputOffset );\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ getTextInputOffset, scrollToTextInputOffset ]\n\t\t),\n\t\t200,\n\t\t{ leading: false }\n\t);\n\n\tuseEffect( () => {\n\t\tonScrollToTextInput( currentCaretData );\n\t}, [ currentCaretData, onScrollToTextInput ] );\n\n\t// When the orientation changes, the ScrollView measurements\n\t// need to be re-calculated.\n\tuseEffect( () => {\n\t\tscrollViewMeasurements.current = null;\n\t}, [ isLandscape ] );\n\n\tconst scrollHandler = useAnimatedScrollHandler( {\n\t\tonScroll: ( event ) => {\n\t\t\tconst { contentOffset } = event;\n\t\t\tscrollViewYOffset.value = contentOffset.y;\n\t\t\tonScroll( event );\n\t\t},\n\t} );\n\n\tconst measureScrollView = useCallback( () => {\n\t\tif ( scrollViewRef.current ) {\n\t\t\tconst scrollRef = scrollViewRef.current.getNativeScrollRef();\n\n\t\t\tscrollRef.measureInWindow( ( _x, y, width, height ) => {\n\t\t\t\tscrollViewMeasurements.current = { y, width, height };\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\tconst onContentSizeChange = useCallback( () => {\n\t\tonScrollToTextInput( currentCaretData );\n\n\t\t// Sets the first values when the content size changes.\n\t\tif ( ! scrollViewMeasurements.current ) {\n\t\t\tmeasureScrollView();\n\t\t}\n\t}, [ measureScrollView, onScrollToTextInput, currentCaretData ] );\n\n\tconst getRef = useCallback(\n\t\t( ref ) => {\n\t\t\tscrollViewRef.current = ref;\n\t\t\tinnerRef( ref );\n\t\t},\n\t\t[ innerRef ]\n\t);\n\n\t// Adds content insets when the keyboard is opened to have\n\t// extra padding at the bottom.\n\tconst contentInset = { bottom: keyboardOffset };\n\n\tconst style = [ { flex: 1 }, scrollViewStyle ];\n\n\treturn (\n\t\t<AnimatedScrollView\n\t\t\tautomaticallyAdjustContentInsets={ false }\n\t\t\tcontentInset={ contentInset }\n\t\t\tkeyboardShouldPersistTaps=\"handled\"\n\t\t\tonContentSizeChange={ onContentSizeChange }\n\t\t\tonScroll={ scrollHandler }\n\t\t\tref={ getRef }\n\t\t\tscrollEnabled={ scrollEnabled }\n\t\t\tscrollEventThrottle={ 16 }\n\t\t\tstyle={ style }\n\t\t>\n\t\t\t<FlatList { ...props } scrollEnabled={ false } />\n\t\t</AnimatedScrollView>\n\t);\n};\n\nexport default KeyboardAwareFlatList;\n"],"mappings":";AAAA;AACA;AACA;;AAEA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,mBAAmB,QAAQ,cAAc;AACxE,OAAOC,QAAQ,IACdC,wBAAwB,EACxBC,cAAc,QACR,yBAAyB;;AAEhC;AACA;AACA;AACA,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACnE,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,iBAAiB,MAAM,uBAAuB;AACrD,OAAOC,oBAAoB,MAAM,4BAA4B;AAC7D,OAAOC,yBAAyB,MAAM,iCAAiC;AAEvE,MAAMC,kBAAkB,GAAGX,QAAQ,CAACY,uBAAuB,CAAEf,UAAW,CAAC;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMgB,qBAAqB,GAAGA,CAAE;EACtCC,iBAAiB;EACjBC,QAAQ;EACRC,QAAQ;EACRC,aAAa;EACbC,eAAe;EACfC,4BAA4B;EAC5B,GAAGC;AACJ,CAAC,KAAM;EACN,MAAMC,aAAa,GAAGhB,MAAM,CAAC,CAAC;EAC9B,MAAMiB,s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9C,OACCsC,aAAA,CAAC7C,kBAAkB;IAClB8C,gCAAgC,EAAG,KAAO;IAC1CL,YAAY,EAAGA,YAAc;IAC7BM,yBAAyB,EAAC,SAAS;IACnCT,mBAAmB,EAAGA,mBAAqB;IAC3CjC,QAAQ,EAAGuB,aAAe;IAC1BY,GAAG,EAAGD,MAAQ;IACdjC,aAAa,EAAGA,aAAe;IAC/B0C,mBAAmB,EAAG,EAAI;IAC1BL,KAAK,EAAGA;EAAO,GAEfE,aAAA,CAAC1D,QAAQ;IAAA,GAAMsB,KAAK;IAAGH,aAAa,EAAG;EAAO,CAAE,CAC7B,CAAC;AAEvB,CAAC;AAED,eAAeJ,qBAAqB"}
1
+ {"version":3,"names":["ScrollView","FlatList","Animated","useCallback","useEffect","forwardRef","useImperativeHandle","useThrottle","useScroll","useTextInputOffset","useTextInputCaretPosition","DEFAULT_FONT_SIZE","AnimatedScrollView","createAnimatedComponent","KeyboardAwareFlatList","extraScrollHeight","onScroll","scrollEnabled","scrollViewStyle","shouldPreventAutomaticScroll","props","ref","scrollViewRef","scrollHandler","keyboardOffset","scrollToSection","scrollToElement","onContentSizeChange","lastScrollTo","onSizeChange","getTextInputOffset","onScrollToTextInput","caret","caretHeight","textInputOffset","hasTextInputOffset","leading","currentCaretData","contentInset","bottom","style","flex","current","createElement","automaticallyAdjustContentInsets","keyboardShouldPersistTaps","scrollEventThrottle"],"sources":["@wordpress/components/src/mobile/keyboard-aware-flat-list/index.ios.js"],"sourcesContent":["/**\n * External dependencies\n */\n\nimport { ScrollView, FlatList } from 'react-native';\nimport Animated from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tforwardRef,\n\tuseImperativeHandle,\n} from '@wordpress/element';\nimport { useThrottle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useScroll from './use-scroll';\nimport useTextInputOffset from './use-text-input-offset';\nimport useTextInputCaretPosition from './use-text-input-caret-position';\n\nconst DEFAULT_FONT_SIZE = 16;\nconst AnimatedScrollView = Animated.createAnimatedComponent( ScrollView );\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n/**\n * React component that provides a FlatList that is aware of the keyboard state and can scroll\n * to the currently focused TextInput.\n *\n * @param {Object} props Component props.\n * @param {number} props.extraScrollHeight Extra scroll height for the content.\n * @param {Function} props.onScroll Function to be called when the list is scrolled.\n * @param {boolean} props.scrollEnabled Whether the list can be scrolled.\n * @param {Object} props.scrollViewStyle Additional style for the ScrollView component.\n * @param {boolean} props.shouldPreventAutomaticScroll Whether to prevent scrolling when there's a Keyboard offset set.\n * @param {Object} props... Other props to pass to the FlatList component.\n * @param {RefObject} ref\n * @return {Component} KeyboardAwareFlatList component.\n */\nexport const KeyboardAwareFlatList = (\n\t{\n\t\textraScrollHeight,\n\t\tonScroll,\n\t\tscrollEnabled,\n\t\tscrollViewStyle,\n\t\tshouldPreventAutomaticScroll,\n\t\t...props\n\t},\n\tref\n) => {\n\tconst {\n\t\tscrollViewRef,\n\t\tscrollHandler,\n\t\tkeyboardOffset,\n\t\tscrollToSection,\n\t\tscrollToElement,\n\t\tonContentSizeChange,\n\t\tlastScrollTo,\n\t} = useScroll( {\n\t\tscrollEnabled,\n\t\tshouldPreventAutomaticScroll,\n\t\textraScrollHeight,\n\t\tonScroll,\n\t\tonSizeChange,\n\t} );\n\n\tconst [ getTextInputOffset ] = useTextInputOffset(\n\t\tscrollEnabled,\n\t\tscrollViewRef\n\t);\n\n\tconst onScrollToTextInput = useThrottle(\n\t\tuseCallback(\n\t\t\tasync ( caret ) => {\n\t\t\t\tconst { caretHeight = DEFAULT_FONT_SIZE } = caret ?? {};\n\t\t\t\tconst textInputOffset = await getTextInputOffset( caret );\n\t\t\t\tconst hasTextInputOffset = textInputOffset !== null;\n\n\t\t\t\tif ( hasTextInputOffset ) {\n\t\t\t\t\tscrollToSection( textInputOffset, caretHeight );\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ getTextInputOffset, scrollToSection ]\n\t\t),\n\t\t200,\n\t\t{ leading: false }\n\t);\n\n\tconst [ currentCaretData ] = useTextInputCaretPosition( scrollEnabled );\n\n\tconst onSizeChange = useCallback(\n\t\t() => onScrollToTextInput( currentCaretData ),\n\t\t[ currentCaretData, onScrollToTextInput ]\n\t);\n\n\tuseEffect( () => {\n\t\tonScrollToTextInput( currentCaretData );\n\t}, [ currentCaretData, onScrollToTextInput ] );\n\n\t// Adds content insets when the keyboard is opened to have\n\t// extra padding at the bottom.\n\tconst contentInset = { bottom: keyboardOffset };\n\n\tconst style = [ { flex: 1 }, scrollViewStyle ];\n\n\tuseImperativeHandle( ref, () => {\n\t\treturn {\n\t\t\tscrollViewRef: scrollViewRef.current,\n\t\t\tscrollToSection,\n\t\t\tscrollToElement,\n\t\t\tlastScrollTo,\n\t\t};\n\t} );\n\n\treturn (\n\t\t<AnimatedScrollView\n\t\t\tautomaticallyAdjustContentInsets={ false }\n\t\t\tcontentInset={ contentInset }\n\t\t\tkeyboardShouldPersistTaps=\"handled\"\n\t\t\tonContentSizeChange={ onContentSizeChange }\n\t\t\tonScroll={ scrollHandler }\n\t\t\tref={ scrollViewRef }\n\t\t\tscrollEnabled={ scrollEnabled }\n\t\t\tscrollEventThrottle={ 16 }\n\t\t\tstyle={ style }\n\t\t>\n\t\t\t<FlatList { ...props } scrollEnabled={ false } />\n\t\t</AnimatedScrollView>\n\t);\n};\n\nexport default forwardRef( KeyboardAwareFlatList );\n"],"mappings":";AAAA;AACA;AACA;;AAEA,SAASA,UAAU,EAAEC,QAAQ,QAAQ,cAAc;AACnD,OAAOC,QAAQ,MAAM,yBAAyB;;AAE9C;AACA;AACA;AACA,SACCC,WAAW,EACXC,SAAS,EACTC,UAAU,EACVC,mBAAmB,QACb,oBAAoB;AAC3B,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,yBAAyB,MA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B,CAAEM,gBAAiB,CAAC,EAC7C,CAAEA,gBAAgB,EAAEN,mBAAmB,CACxC,CAAC;EAED3B,SAAS,CAAE,MAAM;IAChB2B,mBAAmB,CAAEM,gBAAiB,CAAC;EACxC,CAAC,EAAE,CAAEA,gBAAgB,EAAEN,mBAAmB,CAAG,CAAC;;EAE9C;EACA;EACA,MAAMO,YAAY,GAAG;IAAEC,MAAM,EAAEf;EAAe,CAAC;EAE/C,MAAMgB,KAAK,GAAG,CAAE;IAAEC,IAAI,EAAE;EAAE,CAAC,EAAEvB,eAAe,CAAE;EAE9CZ,mBAAmB,CAAEe,GAAG,EAAE,MAAM;IAC/B,OAAO;MACNC,aAAa,EAAEA,aAAa,CAACoB,OAAO;MACpCjB,eAAe;MACfC,eAAe;MACfE;IACD,CAAC;EACF,CAAE,CAAC;EAEH,OACCe,aAAA,CAAC/B,kBAAkB;IAClBgC,gCAAgC,EAAG,KAAO;IAC1CN,YAAY,EAAGA,YAAc;IAC7BO,yBAAyB,EAAC,SAAS;IACnClB,mBAAmB,EAAGA,mBAAqB;IAC3CX,QAAQ,EAAGO,aAAe;IAC1BF,GAAG,EAAGC,aAAe;IACrBL,aAAa,EAAGA,aAAe;IAC/B6B,mBAAmB,EAAG,EAAI;IAC1BN,KAAK,EAAGA;EAAO,GAEfG,aAAA,CAAC1C,QAAQ;IAAA,GAAMmB,KAAK;IAAGH,aAAa,EAAG;EAAO,CAAE,CAC7B,CAAC;AAEvB,CAAC;AAED,eAAeZ,UAAU,CAAES,qBAAsB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useCallback } from '@wordpress/element';
5
+
6
+ /** @typedef {import('@wordpress/element').RefObject} RefObject */
7
+ /**
8
+ * Hook to scroll to a specified element by taking into account the Keyboard
9
+ * and the Header.
10
+ *
11
+ * @param {RefObject} scrollViewRef Scroll view reference.
12
+ * @param {Function} scrollToSection Function to scroll.
13
+ * @return {Function[]} Function to scroll to an element.
14
+ */
15
+ export default function useScrollToElement(scrollViewRef, scrollToSection) {
16
+ /**
17
+ * Function to scroll to an element.
18
+ *
19
+ * @param {RefObject} elementRef Ref of the element.
20
+ */
21
+ const scrollToElement = useCallback(elementRef => {
22
+ if (!scrollViewRef.current || !elementRef) {
23
+ return;
24
+ }
25
+ elementRef.current.measureLayout(scrollViewRef.current, (_x, y, _width, height) => {
26
+ if (height || y) {
27
+ scrollToSection(Math.round(y), height);
28
+ }
29
+ }, () => {});
30
+ }, [scrollViewRef, scrollToSection]);
31
+ return [scrollToElement];
32
+ }
33
+ //# sourceMappingURL=use-scroll-to-element.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useScrollToElement","scrollViewRef","scrollToSection","scrollToElement","elementRef","current","measureLayout","_x","y","_width","height","Math","round"],"sources":["@wordpress/components/src/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n/**\n * Hook to scroll to a specified element by taking into account the Keyboard\n * and the Header.\n *\n * @param {RefObject} scrollViewRef Scroll view reference.\n * @param {Function} scrollToSection Function to scroll.\n * @return {Function[]} Function to scroll to an element.\n */\nexport default function useScrollToElement( scrollViewRef, scrollToSection ) {\n\t/**\n\t * Function to scroll to an element.\n\t *\n\t * @param {RefObject} elementRef Ref of the element.\n\t */\n\tconst scrollToElement = useCallback(\n\t\t( elementRef ) => {\n\t\t\tif ( ! scrollViewRef.current || ! elementRef ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\telementRef.current.measureLayout(\n\t\t\t\tscrollViewRef.current,\n\t\t\t\t( _x, y, _width, height ) => {\n\t\t\t\t\tif ( height || y ) {\n\t\t\t\t\t\tscrollToSection( Math.round( y ), height );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {}\n\t\t\t);\n\t\t},\n\t\t[ scrollViewRef, scrollToSection ]\n\t);\n\n\treturn [ scrollToElement ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,kBAAkBA,CAAEC,aAAa,EAAEC,eAAe,EAAG;EAC5E;AACD;AACA;AACA;AACA;EACC,MAAMC,eAAe,GAAGJ,WAAW,CAChCK,UAAU,IAAM;IACjB,IAAK,CAAEH,aAAa,CAACI,OAAO,IAAI,CAAED,UAAU,EAAG;MAC9C;IACD;IAEAA,UAAU,CAACC,OAAO,CAACC,aAAa,CAC/BL,aAAa,CAACI,OAAO,EACrB,CAAEE,EAAE,EAAEC,CAAC,EAAEC,MAAM,EAAEC,MAAM,KAAM;MAC5B,IAAKA,MAAM,IAAIF,CAAC,EAAG;QAClBN,eAAe,CAAES,IAAI,CAACC,KAAK,CAAEJ,CAAE,CAAC,EAAEE,MAAO,CAAC;MAC3C;IACD,CAAC,EACD,MAAM,CAAC,CACR,CAAC;EACF,CAAC,EACD,CAAET,aAAa,EAAEC,eAAe,CACjC,CAAC;EAED,OAAO,CAAEC,eAAe,CAAE;AAC3B"}