@wordpress/components 25.13.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 (656) hide show
  1. package/CHANGELOG.md +88 -1
  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-dropdown/component.js +4 -2
  9. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  10. package/build/border-control/border-control-dropdown/hook.js +3 -2
  11. package/build/border-control/border-control-dropdown/hook.js.map +1 -1
  12. package/build/border-control/border-control-style-picker/component.js +1 -1
  13. package/build/border-control/border-control-style-picker/component.js.map +1 -1
  14. package/build/border-control/styles.js +17 -17
  15. package/build/border-control/styles.js.map +1 -1
  16. package/build/box-control/index.js +1 -1
  17. package/build/box-control/index.js.map +1 -1
  18. package/build/box-control/linked-button.js +1 -1
  19. package/build/box-control/linked-button.js.map +1 -1
  20. package/build/button/index.js +1 -1
  21. package/build/button/index.js.map +1 -1
  22. package/build/checkbox-control/index.js +1 -1
  23. package/build/checkbox-control/index.js.map +1 -1
  24. package/build/checkbox-control/types.js.map +1 -1
  25. package/build/color-picker/color-copy-button.js +1 -1
  26. package/build/color-picker/color-copy-button.js.map +1 -1
  27. package/build/context/wordpress-component.js.map +1 -1
  28. package/build/custom-select-control-v2/index.js +11 -10
  29. package/build/custom-select-control-v2/index.js.map +1 -1
  30. package/build/date-time/date/styles.js +8 -8
  31. package/build/date-time/date/styles.js.map +1 -1
  32. package/build/date-time/time/timezone.js +11 -2
  33. package/build/date-time/time/timezone.js.map +1 -1
  34. package/build/dimension-control/index.js +2 -0
  35. package/build/dimension-control/index.js.map +1 -1
  36. package/build/dimension-control/types.js.map +1 -1
  37. package/build/dropdown-menu-v2/index.js +205 -159
  38. package/build/dropdown-menu-v2/index.js.map +1 -1
  39. package/build/dropdown-menu-v2/styles.js +86 -77
  40. package/build/dropdown-menu-v2/styles.js.map +1 -1
  41. package/build/dropdown-menu-v2/types.js.map +1 -1
  42. package/build/duotone-picker/duotone-picker.js +4 -3
  43. package/build/duotone-picker/duotone-picker.js.map +1 -1
  44. package/build/focal-point-picker/controls.js +5 -1
  45. package/build/focal-point-picker/controls.js.map +1 -1
  46. package/build/focal-point-picker/index.js +2 -0
  47. package/build/focal-point-picker/index.js.map +1 -1
  48. package/build/focal-point-picker/styles/focal-point-picker-style.js +15 -15
  49. package/build/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
  50. package/build/focal-point-picker/types.js.map +1 -1
  51. package/build/font-size-picker/font-size-picker-select.js +2 -0
  52. package/build/font-size-picker/font-size-picker-select.js.map +1 -1
  53. package/build/font-size-picker/font-size-picker-toggle-group.js +2 -0
  54. package/build/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
  55. package/build/font-size-picker/index.js +10 -3
  56. package/build/font-size-picker/index.js.map +1 -1
  57. package/build/font-size-picker/index.native.js +6 -3
  58. package/build/font-size-picker/index.native.js.map +1 -1
  59. package/build/font-size-picker/types.js.map +1 -1
  60. package/build/form-token-field/index.js +10 -5
  61. package/build/form-token-field/index.js.map +1 -1
  62. package/build/form-token-field/token.js +1 -0
  63. package/build/form-token-field/token.js.map +1 -1
  64. package/build/gradient-picker/index.js +3 -2
  65. package/build/gradient-picker/index.js.map +1 -1
  66. package/build/index.native.js +20 -19
  67. package/build/index.native.js.map +1 -1
  68. package/build/input-control/styles/input-control-styles.js +32 -29
  69. package/build/input-control/styles/input-control-styles.js.map +1 -1
  70. package/build/input-control/types.js.map +1 -1
  71. package/build/lock-unlock.js +18 -0
  72. package/build/lock-unlock.js.map +1 -0
  73. package/build/mobile/bottom-sheet/index.native.js +8 -0
  74. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  75. package/build/mobile/global-styles-context/utils.native.js +39 -13
  76. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  77. package/build/mobile/image/constants.js +12 -0
  78. package/build/mobile/image/constants.js.map +1 -0
  79. package/build/mobile/image/index.native.js +26 -18
  80. package/build/mobile/image/index.native.js.map +1 -1
  81. package/build/mobile/keyboard-aware-flat-list/index.android.js +40 -8
  82. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  83. package/build/mobile/keyboard-aware-flat-list/index.ios.js +44 -68
  84. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  85. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +39 -0
  86. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  87. package/build/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -29
  88. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  89. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js +93 -0
  90. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  91. package/build/mobile/utils/get-px-from-css-unit.native.js +302 -0
  92. package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  93. package/build/modal/index.js +18 -13
  94. package/build/modal/index.js.map +1 -1
  95. package/build/navigation/menu/menu-title.js +1 -1
  96. package/build/navigation/menu/menu-title.js.map +1 -1
  97. package/build/navigator/navigator-provider/component.js +13 -15
  98. package/build/navigator/navigator-provider/component.js.map +1 -1
  99. package/build/navigator/navigator-screen/component.js +23 -63
  100. package/build/navigator/navigator-screen/component.js.map +1 -1
  101. package/build/navigator/styles.js +52 -0
  102. package/build/navigator/styles.js.map +1 -0
  103. package/build/number-control/index.js +4 -8
  104. package/build/number-control/index.js.map +1 -1
  105. package/build/number-control/types.js.map +1 -1
  106. package/build/palette-edit/index.js +15 -34
  107. package/build/palette-edit/index.js.map +1 -1
  108. package/build/private-apis.js +11 -26
  109. package/build/private-apis.js.map +1 -1
  110. package/build/private-apis.native.js +21 -0
  111. package/build/private-apis.native.js.map +1 -0
  112. package/build/query-controls/author-select.js +3 -1
  113. package/build/query-controls/author-select.js.map +1 -1
  114. package/build/query-controls/category-select.js +3 -1
  115. package/build/query-controls/category-select.js.map +1 -1
  116. package/build/query-controls/index.js +6 -1
  117. package/build/query-controls/index.js.map +1 -1
  118. package/build/query-controls/types.js.map +1 -1
  119. package/build/radio-control/index.js +1 -0
  120. package/build/radio-control/index.js.map +1 -1
  121. package/build/range-control/index.js +1 -1
  122. package/build/range-control/index.js.map +1 -1
  123. package/build/select-control/styles/select-control-styles.js +15 -25
  124. package/build/select-control/styles/select-control-styles.js.map +1 -1
  125. package/build/slot-fill/index.js +3 -2
  126. package/build/slot-fill/index.js.map +1 -1
  127. package/build/slot-fill/types.js.map +1 -1
  128. package/build/snackbar/types.js.map +1 -1
  129. package/build/tabs/index.js +18 -1
  130. package/build/tabs/index.js.map +1 -1
  131. package/build/tabs/styles.js +3 -3
  132. package/build/tabs/styles.js.map +1 -1
  133. package/build/tabs/tab.js +2 -2
  134. package/build/tabs/tab.js.map +1 -1
  135. package/build/tabs/tabpanel.js +11 -8
  136. package/build/tabs/tabpanel.js.map +1 -1
  137. package/build/tabs/types.js.map +1 -1
  138. package/build/toggle-group-control/toggle-group-control/component.js +4 -4
  139. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  140. package/build/toggle-group-control/toggle-group-control/styles.js +29 -15
  141. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  142. package/build/toggle-group-control/toggle-group-control/utils.js +17 -17
  143. package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  144. package/build/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  145. package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  146. package/build/tools-panel/tools-panel/component.js +3 -1
  147. package/build/tools-panel/tools-panel/component.js.map +1 -1
  148. package/build/tools-panel/tools-panel-header/component.js +9 -8
  149. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  150. package/build/tools-panel/tools-panel-item/hook.js +11 -11
  151. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  152. package/build/tools-panel/types.js.map +1 -1
  153. package/build/tooltip/index.js +1 -1
  154. package/build/tooltip/index.js.map +1 -1
  155. package/build/truncate/hook.js +10 -4
  156. package/build/truncate/hook.js.map +1 -1
  157. package/build/truncate/types.js.map +1 -1
  158. package/build/unit-control/index.js +1 -1
  159. package/build/unit-control/index.js.map +1 -1
  160. package/build/utils/strings.js +34 -3
  161. package/build/utils/strings.js.map +1 -1
  162. package/build-module/base-control/index.js +16 -12
  163. package/build-module/base-control/index.js.map +1 -1
  164. package/build-module/border-box-control/border-box-control-linked-button/component.js +1 -1
  165. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  166. package/build-module/border-control/border-control-dropdown/component.js +4 -2
  167. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  168. package/build-module/border-control/border-control-dropdown/hook.js +3 -2
  169. package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
  170. package/build-module/border-control/border-control-style-picker/component.js +1 -1
  171. package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
  172. package/build-module/border-control/styles.js +17 -17
  173. package/build-module/border-control/styles.js.map +1 -1
  174. package/build-module/box-control/index.js +1 -1
  175. package/build-module/box-control/index.js.map +1 -1
  176. package/build-module/box-control/linked-button.js +1 -1
  177. package/build-module/box-control/linked-button.js.map +1 -1
  178. package/build-module/button/index.js +1 -1
  179. package/build-module/button/index.js.map +1 -1
  180. package/build-module/checkbox-control/index.js +1 -1
  181. package/build-module/checkbox-control/index.js.map +1 -1
  182. package/build-module/checkbox-control/types.js.map +1 -1
  183. package/build-module/color-picker/color-copy-button.js +1 -1
  184. package/build-module/color-picker/color-copy-button.js.map +1 -1
  185. package/build-module/context/wordpress-component.js.map +1 -1
  186. package/build-module/custom-select-control-v2/index.js +11 -10
  187. package/build-module/custom-select-control-v2/index.js.map +1 -1
  188. package/build-module/date-time/date/styles.js +8 -8
  189. package/build-module/date-time/date/styles.js.map +1 -1
  190. package/build-module/date-time/time/timezone.js +11 -2
  191. package/build-module/date-time/time/timezone.js.map +1 -1
  192. package/build-module/dimension-control/index.js +2 -0
  193. package/build-module/dimension-control/index.js.map +1 -1
  194. package/build-module/dimension-control/types.js.map +1 -1
  195. package/build-module/dropdown-menu-v2/index.js +201 -154
  196. package/build-module/dropdown-menu-v2/index.js.map +1 -1
  197. package/build-module/dropdown-menu-v2/styles.js +68 -61
  198. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  199. package/build-module/dropdown-menu-v2/types.js.map +1 -1
  200. package/build-module/duotone-picker/duotone-picker.js +4 -3
  201. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  202. package/build-module/focal-point-picker/controls.js +5 -1
  203. package/build-module/focal-point-picker/controls.js.map +1 -1
  204. package/build-module/focal-point-picker/index.js +2 -0
  205. package/build-module/focal-point-picker/index.js.map +1 -1
  206. package/build-module/focal-point-picker/styles/focal-point-picker-style.js +15 -15
  207. package/build-module/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
  208. package/build-module/focal-point-picker/types.js.map +1 -1
  209. package/build-module/font-size-picker/font-size-picker-select.js +2 -0
  210. package/build-module/font-size-picker/font-size-picker-select.js.map +1 -1
  211. package/build-module/font-size-picker/font-size-picker-toggle-group.js +2 -0
  212. package/build-module/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
  213. package/build-module/font-size-picker/index.js +10 -3
  214. package/build-module/font-size-picker/index.js.map +1 -1
  215. package/build-module/font-size-picker/index.native.js +5 -2
  216. package/build-module/font-size-picker/index.native.js.map +1 -1
  217. package/build-module/font-size-picker/types.js.map +1 -1
  218. package/build-module/form-token-field/index.js +10 -5
  219. package/build-module/form-token-field/index.js.map +1 -1
  220. package/build-module/form-token-field/token.js +1 -0
  221. package/build-module/form-token-field/token.js.map +1 -1
  222. package/build-module/gradient-picker/index.js +3 -2
  223. package/build-module/gradient-picker/index.js.map +1 -1
  224. package/build-module/index.native.js +6 -3
  225. package/build-module/index.native.js.map +1 -1
  226. package/build-module/input-control/styles/input-control-styles.js +31 -29
  227. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  228. package/build-module/input-control/types.js.map +1 -1
  229. package/build-module/lock-unlock.js +9 -0
  230. package/build-module/lock-unlock.js.map +1 -0
  231. package/build-module/mobile/bottom-sheet/index.native.js +9 -1
  232. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  233. package/build-module/mobile/global-styles-context/utils.native.js +38 -13
  234. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  235. package/build-module/mobile/image/constants.js +5 -0
  236. package/build-module/mobile/image/constants.js.map +1 -0
  237. package/build-module/mobile/image/index.native.js +25 -16
  238. package/build-module/mobile/image/index.native.js.map +1 -1
  239. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +40 -6
  240. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  241. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +46 -68
  242. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  243. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +33 -0
  244. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  245. package/build-module/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +21 -27
  246. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  247. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js +86 -0
  248. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  249. package/build-module/mobile/utils/get-px-from-css-unit.native.js +294 -0
  250. package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  251. package/build-module/modal/index.js +18 -13
  252. package/build-module/modal/index.js.map +1 -1
  253. package/build-module/navigation/menu/menu-title.js +1 -1
  254. package/build-module/navigation/menu/menu-title.js.map +1 -1
  255. package/build-module/navigator/navigator-provider/component.js +3 -16
  256. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  257. package/build-module/navigator/navigator-screen/component.js +16 -70
  258. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  259. package/build-module/navigator/styles.js +47 -0
  260. package/build-module/navigator/styles.js.map +1 -0
  261. package/build-module/number-control/index.js +4 -8
  262. package/build-module/number-control/index.js.map +1 -1
  263. package/build-module/number-control/types.js.map +1 -1
  264. package/build-module/palette-edit/index.js +14 -33
  265. package/build-module/palette-edit/index.js.map +1 -1
  266. package/build-module/private-apis.js +10 -23
  267. package/build-module/private-apis.js.map +1 -1
  268. package/build-module/private-apis.native.js +14 -0
  269. package/build-module/private-apis.native.js.map +1 -0
  270. package/build-module/query-controls/author-select.js +3 -1
  271. package/build-module/query-controls/author-select.js.map +1 -1
  272. package/build-module/query-controls/category-select.js +3 -1
  273. package/build-module/query-controls/category-select.js.map +1 -1
  274. package/build-module/query-controls/index.js +6 -1
  275. package/build-module/query-controls/index.js.map +1 -1
  276. package/build-module/query-controls/types.js.map +1 -1
  277. package/build-module/radio-control/index.js +1 -0
  278. package/build-module/radio-control/index.js.map +1 -1
  279. package/build-module/range-control/index.js +1 -1
  280. package/build-module/range-control/index.js.map +1 -1
  281. package/build-module/select-control/styles/select-control-styles.js +15 -25
  282. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  283. package/build-module/slot-fill/index.js +3 -2
  284. package/build-module/slot-fill/index.js.map +1 -1
  285. package/build-module/slot-fill/types.js.map +1 -1
  286. package/build-module/snackbar/types.js.map +1 -1
  287. package/build-module/tabs/index.js +18 -1
  288. package/build-module/tabs/index.js.map +1 -1
  289. package/build-module/tabs/styles.js +3 -3
  290. package/build-module/tabs/styles.js.map +1 -1
  291. package/build-module/tabs/tab.js +2 -2
  292. package/build-module/tabs/tab.js.map +1 -1
  293. package/build-module/tabs/tabpanel.js +11 -8
  294. package/build-module/tabs/tabpanel.js.map +1 -1
  295. package/build-module/tabs/types.js.map +1 -1
  296. package/build-module/toggle-group-control/toggle-group-control/component.js +4 -4
  297. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  298. package/build-module/toggle-group-control/toggle-group-control/styles.js +29 -15
  299. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  300. package/build-module/toggle-group-control/toggle-group-control/utils.js +17 -17
  301. package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  302. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  303. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  304. package/build-module/tools-panel/tools-panel/component.js +3 -1
  305. package/build-module/tools-panel/tools-panel/component.js.map +1 -1
  306. package/build-module/tools-panel/tools-panel-header/component.js +9 -8
  307. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  308. package/build-module/tools-panel/tools-panel-item/hook.js +11 -11
  309. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  310. package/build-module/tools-panel/types.js.map +1 -1
  311. package/build-module/tooltip/index.js +1 -1
  312. package/build-module/tooltip/index.js.map +1 -1
  313. package/build-module/truncate/hook.js +10 -4
  314. package/build-module/truncate/hook.js.map +1 -1
  315. package/build-module/truncate/types.js.map +1 -1
  316. package/build-module/unit-control/index.js +1 -1
  317. package/build-module/unit-control/index.js.map +1 -1
  318. package/build-module/utils/strings.js +32 -2
  319. package/build-module/utils/strings.js.map +1 -1
  320. package/build-style/style-rtl.css +30 -6
  321. package/build-style/style.css +30 -6
  322. package/build-types/base-control/index.d.ts +3 -27
  323. package/build-types/base-control/index.d.ts.map +1 -1
  324. package/build-types/base-control/stories/index.story.d.ts +4 -1
  325. package/build-types/base-control/stories/index.story.d.ts.map +1 -1
  326. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  327. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
  328. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  329. package/build-types/border-control/styles.d.ts +1 -1
  330. package/build-types/border-control/styles.d.ts.map +1 -1
  331. package/build-types/checkbox-control/index.d.ts.map +1 -1
  332. package/build-types/checkbox-control/types.d.ts +3 -2
  333. package/build-types/checkbox-control/types.d.ts.map +1 -1
  334. package/build-types/color-picker/component.d.ts +1 -1
  335. package/build-types/color-picker/stories/index.story.d.ts +1 -1
  336. package/build-types/color-picker/stories/index.story.d.ts.map +1 -1
  337. package/build-types/composite/test/index.d.ts.map +1 -0
  338. package/build-types/context/wordpress-component.d.ts +3 -3
  339. package/build-types/context/wordpress-component.d.ts.map +1 -1
  340. package/build-types/custom-select-control-v2/index.d.ts +3 -2
  341. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  342. package/build-types/custom-select-control-v2/stories/index.story.d.ts +4 -3
  343. package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
  344. package/build-types/date-time/time/timezone.d.ts.map +1 -1
  345. package/build-types/dimension-control/index.d.ts.map +1 -1
  346. package/build-types/dimension-control/types.d.ts +6 -0
  347. package/build-types/dimension-control/types.d.ts.map +1 -1
  348. package/build-types/dropdown/index.d.ts +1 -1
  349. package/build-types/dropdown/index.d.ts.map +1 -1
  350. package/build-types/dropdown/stories/index.story.d.ts +3 -3
  351. package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
  352. package/build-types/dropdown-menu/index.d.ts +1 -1
  353. package/build-types/dropdown-menu/index.d.ts.map +1 -1
  354. package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
  355. package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
  356. package/build-types/dropdown-menu-v2/index.d.ts +18 -15
  357. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
  358. package/build-types/dropdown-menu-v2/stories/index.story.d.ts +7 -2
  359. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
  360. package/build-types/dropdown-menu-v2/styles.d.ts +77 -23
  361. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
  362. package/build-types/dropdown-menu-v2/types.d.ts +89 -173
  363. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
  364. package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
  365. package/build-types/focal-point-picker/controls.d.ts +1 -1
  366. package/build-types/focal-point-picker/controls.d.ts.map +1 -1
  367. package/build-types/focal-point-picker/index.d.ts +1 -1
  368. package/build-types/focal-point-picker/index.d.ts.map +1 -1
  369. package/build-types/focal-point-picker/stories/index.story.d.ts +8 -4
  370. package/build-types/focal-point-picker/stories/index.story.d.ts.map +1 -1
  371. package/build-types/focal-point-picker/types.d.ts +7 -0
  372. package/build-types/focal-point-picker/types.d.ts.map +1 -1
  373. package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
  374. package/build-types/font-size-picker/font-size-picker-toggle-group.d.ts.map +1 -1
  375. package/build-types/font-size-picker/index.d.ts.map +1 -1
  376. package/build-types/font-size-picker/types.d.ts +8 -1
  377. package/build-types/font-size-picker/types.d.ts.map +1 -1
  378. package/build-types/form-token-field/index.d.ts.map +1 -1
  379. package/build-types/form-token-field/token.d.ts.map +1 -1
  380. package/build-types/input-control/styles/input-control-styles.d.ts +11 -0
  381. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  382. package/build-types/input-control/types.d.ts +1 -1
  383. package/build-types/input-control/types.d.ts.map +1 -1
  384. package/build-types/lock-unlock.d.ts +3 -0
  385. package/build-types/lock-unlock.d.ts.map +1 -0
  386. package/build-types/mobile/image/constants.d.ts +5 -0
  387. package/build-types/mobile/image/constants.d.ts.map +1 -0
  388. package/build-types/modal/index.d.ts.map +1 -1
  389. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  390. package/build-types/navigator/navigator-screen/component.d.ts +1 -7
  391. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  392. package/build-types/navigator/styles.d.ts +9 -0
  393. package/build-types/navigator/styles.d.ts.map +1 -0
  394. package/build-types/number-control/index.d.ts.map +1 -1
  395. package/build-types/number-control/types.d.ts +1 -1
  396. package/build-types/palette-edit/index.d.ts +2 -2
  397. package/build-types/palette-edit/index.d.ts.map +1 -1
  398. package/build-types/popover/index.d.ts +1 -1
  399. package/build-types/popover/index.d.ts.map +1 -1
  400. package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
  401. package/build-types/private-apis.d.ts +0 -1
  402. package/build-types/private-apis.d.ts.map +1 -1
  403. package/build-types/query-controls/author-select.d.ts +1 -1
  404. package/build-types/query-controls/author-select.d.ts.map +1 -1
  405. package/build-types/query-controls/category-select.d.ts +1 -1
  406. package/build-types/query-controls/category-select.d.ts.map +1 -1
  407. package/build-types/query-controls/index.d.ts +1 -1
  408. package/build-types/query-controls/index.d.ts.map +1 -1
  409. package/build-types/query-controls/types.d.ts +9 -0
  410. package/build-types/query-controls/types.d.ts.map +1 -1
  411. package/build-types/radio-control/index.d.ts.map +1 -1
  412. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  413. package/build-types/slot-fill/index.d.ts +1 -1
  414. package/build-types/slot-fill/index.d.ts.map +1 -1
  415. package/build-types/slot-fill/types.d.ts +4 -0
  416. package/build-types/slot-fill/types.d.ts.map +1 -1
  417. package/build-types/snackbar/index.d.ts +2 -2
  418. package/build-types/snackbar/stories/index.story.d.ts +0 -3
  419. package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
  420. package/build-types/snackbar/types.d.ts +1 -1
  421. package/build-types/snackbar/types.d.ts.map +1 -1
  422. package/build-types/tabs/index.d.ts +2 -2
  423. package/build-types/tabs/index.d.ts.map +1 -1
  424. package/build-types/tabs/styles.d.ts.map +1 -1
  425. package/build-types/tabs/tab.d.ts +2 -1
  426. package/build-types/tabs/tab.d.ts.map +1 -1
  427. package/build-types/tabs/tabpanel.d.ts +3 -2
  428. package/build-types/tabs/tabpanel.d.ts.map +1 -1
  429. package/build-types/tabs/types.d.ts +8 -3
  430. package/build-types/tabs/types.d.ts.map +1 -1
  431. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  432. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +2 -2
  433. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  434. package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -1
  435. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +1 -1
  436. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  437. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  438. package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
  439. package/build-types/tools-panel/tools-panel/hook.d.ts +1 -0
  440. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  441. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  442. package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -0
  443. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  444. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  445. package/build-types/tools-panel/types.d.ts +9 -0
  446. package/build-types/tools-panel/types.d.ts.map +1 -1
  447. package/build-types/truncate/hook.d.ts +1 -1
  448. package/build-types/truncate/hook.d.ts.map +1 -1
  449. package/build-types/truncate/types.d.ts +4 -0
  450. package/build-types/truncate/types.d.ts.map +1 -1
  451. package/build-types/utils/strings.d.ts +14 -2
  452. package/build-types/utils/strings.d.ts.map +1 -1
  453. package/package.json +20 -21
  454. package/src/alignment-matrix-control/test/index.tsx +10 -16
  455. package/src/base-control/index.tsx +21 -16
  456. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
  457. package/src/border-control/border-control-dropdown/component.tsx +3 -1
  458. package/src/border-control/border-control-dropdown/hook.ts +3 -2
  459. package/src/border-control/border-control-style-picker/component.tsx +1 -1
  460. package/src/border-control/styles.ts +2 -9
  461. package/src/box-control/index.tsx +1 -1
  462. package/src/box-control/linked-button.tsx +1 -1
  463. package/src/button/README.md +32 -6
  464. package/src/button/index.tsx +1 -1
  465. package/src/button-group/README.md +0 -6
  466. package/src/card/card/README.md +1 -1
  467. package/src/checkbox-control/README.md +3 -10
  468. package/src/checkbox-control/index.tsx +8 -6
  469. package/src/checkbox-control/test/__snapshots__/index.tsx.snap +3 -8
  470. package/src/checkbox-control/test/index.tsx +7 -0
  471. package/src/checkbox-control/types.ts +3 -2
  472. package/src/color-picker/color-copy-button.tsx +1 -1
  473. package/src/combobox-control/README.md +0 -6
  474. package/src/composite/test/index.tsx +576 -0
  475. package/src/context/wordpress-component.ts +11 -6
  476. package/src/custom-select-control/README.md +0 -6
  477. package/src/custom-select-control/test/index.js +367 -35
  478. package/src/custom-select-control-v2/index.tsx +13 -12
  479. package/src/date-time/date/styles.ts +3 -3
  480. package/src/date-time/time/timezone.tsx +15 -3
  481. package/src/dimension-control/index.tsx +2 -0
  482. package/src/dimension-control/test/__snapshots__/index.test.js.snap +2 -2
  483. package/src/dimension-control/types.ts +6 -0
  484. package/src/dropdown-menu/README.md +0 -5
  485. package/src/dropdown-menu-v2/README.md +75 -136
  486. package/src/dropdown-menu-v2/index.tsx +321 -231
  487. package/src/dropdown-menu-v2/stories/index.story.tsx +522 -126
  488. package/src/dropdown-menu-v2/styles.ts +226 -151
  489. package/src/dropdown-menu-v2/test/index.tsx +480 -188
  490. package/src/dropdown-menu-v2/types.ts +98 -184
  491. package/src/duotone-picker/duotone-picker.tsx +7 -3
  492. package/src/focal-point-picker/controls.tsx +4 -0
  493. package/src/focal-point-picker/index.tsx +2 -0
  494. package/src/focal-point-picker/styles/focal-point-picker-style.ts +1 -1
  495. package/src/focal-point-picker/types.ts +7 -0
  496. package/src/font-size-picker/font-size-picker-select.tsx +2 -0
  497. package/src/font-size-picker/font-size-picker-toggle-group.tsx +9 -1
  498. package/src/font-size-picker/index.native.js +8 -2
  499. package/src/font-size-picker/index.tsx +15 -5
  500. package/src/font-size-picker/types.ts +8 -1
  501. package/src/form-toggle/README.md +0 -6
  502. package/src/form-toggle/style.scss +4 -2
  503. package/src/form-token-field/index.tsx +11 -7
  504. package/src/form-token-field/test/index.tsx +97 -0
  505. package/src/form-token-field/token.tsx +1 -0
  506. package/src/gradient-picker/index.tsx +2 -2
  507. package/src/index.native.js +6 -3
  508. package/src/input-control/styles/input-control-styles.tsx +10 -8
  509. package/src/input-control/types.ts +1 -1
  510. package/src/lock-unlock.js +10 -0
  511. package/src/menu-group/README.md +0 -8
  512. package/src/menu-items-choice/README.md +0 -7
  513. package/src/mobile/bottom-sheet/index.native.js +15 -1
  514. package/src/mobile/global-styles-context/test/fixtures/theme.native.js +0 -20
  515. package/src/mobile/global-styles-context/test/utils.native.js +22 -0
  516. package/src/mobile/global-styles-context/utils.native.js +42 -19
  517. package/src/mobile/image/constants.js +1 -0
  518. package/src/mobile/image/index.native.js +55 -18
  519. package/src/mobile/image/style.native.scss +35 -9
  520. package/src/mobile/keyboard-aware-flat-list/index.android.js +50 -5
  521. package/src/mobile/keyboard-aware-flat-list/index.ios.js +65 -91
  522. package/src/mobile/keyboard-aware-flat-list/test/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +27 -25
  523. package/src/mobile/keyboard-aware-flat-list/test/use-scroll.native.js +71 -0
  524. package/src/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +41 -0
  525. package/src/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -27
  526. package/src/mobile/keyboard-aware-flat-list/use-scroll.native.js +100 -0
  527. package/src/mobile/link-settings/style.native.scss +0 -17
  528. package/src/mobile/utils/get-px-from-css-unit.native.js +329 -0
  529. package/src/mobile/utils/test/get-px-from-css-unit.native.js +172 -0
  530. package/src/modal/README.md +0 -6
  531. package/src/modal/index.tsx +18 -16
  532. package/src/modal/test/index.tsx +90 -1
  533. package/src/navigation/menu/menu-title.tsx +1 -1
  534. package/src/navigator/navigator-provider/component.tsx +3 -4
  535. package/src/navigator/navigator-screen/component.tsx +15 -93
  536. package/src/navigator/styles.ts +71 -0
  537. package/src/navigator/test/index.tsx +0 -64
  538. package/src/notice/README.md +0 -6
  539. package/src/number-control/README.md +2 -2
  540. package/src/number-control/index.tsx +4 -8
  541. package/src/number-control/types.ts +1 -1
  542. package/src/palette-edit/index.tsx +14 -43
  543. package/src/palette-edit/style.scss +2 -2
  544. package/src/panel/README.md +0 -6
  545. package/src/private-apis.native.js +13 -0
  546. package/src/private-apis.ts +12 -37
  547. package/src/query-controls/author-select.tsx +2 -0
  548. package/src/query-controls/category-select.tsx +2 -0
  549. package/src/query-controls/index.tsx +6 -1
  550. package/src/query-controls/types.ts +9 -0
  551. package/src/radio-control/README.md +0 -6
  552. package/src/radio-control/index.tsx +4 -1
  553. package/src/radio-control/style.scss +29 -2
  554. package/src/radio-group/README.md +0 -6
  555. package/src/range-control/README.md +1 -9
  556. package/src/range-control/index.tsx +1 -1
  557. package/src/search-control/README.md +1 -5
  558. package/src/select-control/README.md +0 -6
  559. package/src/select-control/styles/select-control-styles.ts +10 -28
  560. package/src/slot-fill/index.tsx +5 -2
  561. package/src/slot-fill/types.ts +5 -0
  562. package/src/snackbar/README.md +0 -6
  563. package/src/snackbar/stories/index.story.tsx +7 -5
  564. package/src/snackbar/style.scss +4 -3
  565. package/src/snackbar/types.ts +2 -1
  566. package/src/spacer/README.md +0 -2
  567. package/src/spinner/README.md +2 -0
  568. package/src/tab-panel/README.md +0 -5
  569. package/src/tab-panel/test/index.tsx +39 -56
  570. package/src/tabs/README.md +4 -4
  571. package/src/tabs/index.tsx +22 -1
  572. package/src/tabs/stories/index.story.tsx +48 -48
  573. package/src/tabs/styles.ts +7 -1
  574. package/src/tabs/tab.tsx +3 -3
  575. package/src/tabs/tabpanel.tsx +13 -8
  576. package/src/tabs/test/index.tsx +236 -106
  577. package/src/tabs/types.ts +8 -3
  578. package/src/text-control/README.md +0 -6
  579. package/src/textarea-control/README.md +0 -6
  580. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +12 -16
  581. package/src/toggle-group-control/test/index.tsx +107 -41
  582. package/src/toggle-group-control/toggle-group-control/component.tsx +5 -4
  583. package/src/toggle-group-control/toggle-group-control/styles.ts +13 -19
  584. package/src/toggle-group-control/toggle-group-control/utils.ts +15 -20
  585. package/src/toggle-group-control/toggle-group-control-option/README.md +1 -1
  586. package/src/toggle-group-control/toggle-group-control-option-base/README.md +1 -1
  587. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +3 -2
  588. package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
  589. package/src/toolbar/toolbar/README.md +0 -6
  590. package/src/tools-panel/test/index.tsx +12 -20
  591. package/src/tools-panel/tools-panel/README.md +7 -0
  592. package/src/tools-panel/tools-panel/component.tsx +2 -0
  593. package/src/tools-panel/tools-panel-header/README.md +7 -0
  594. package/src/tools-panel/tools-panel-header/component.tsx +20 -13
  595. package/src/tools-panel/tools-panel-item/hook.ts +10 -21
  596. package/src/tools-panel/types.ts +9 -0
  597. package/src/tooltip/index.tsx +1 -1
  598. package/src/tooltip/test/index.tsx +360 -256
  599. package/src/tree-grid/README.md +0 -4
  600. package/src/truncate/README.md +8 -0
  601. package/src/truncate/hook.ts +17 -10
  602. package/src/truncate/test/index.tsx +54 -27
  603. package/src/truncate/types.ts +4 -0
  604. package/src/unit-control/index.tsx +1 -1
  605. package/src/utils/strings.ts +30 -2
  606. package/src/utils/test/strings.js +96 -1
  607. package/tsconfig.tsbuildinfo +1 -1
  608. package/build/dropdown-menu-v2-ariakit/index.js +0 -256
  609. package/build/dropdown-menu-v2-ariakit/index.js.map +0 -1
  610. package/build/dropdown-menu-v2-ariakit/styles.js +0 -180
  611. package/build/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  612. package/build/dropdown-menu-v2-ariakit/types.js +0 -6
  613. package/build/dropdown-menu-v2-ariakit/types.js.map +0 -1
  614. package/build/mobile/inserter-button/index.native.js +0 -98
  615. package/build/mobile/inserter-button/index.native.js.map +0 -1
  616. package/build/mobile/inserter-button/sparkles.js +0 -23
  617. package/build/mobile/inserter-button/sparkles.js.map +0 -1
  618. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  619. package/build/mobile/link-settings/image-link-destinations-screen.native.js +0 -119
  620. package/build/mobile/link-settings/image-link-destinations-screen.native.js.map +0 -1
  621. package/build-module/dropdown-menu-v2-ariakit/index.js +0 -237
  622. package/build-module/dropdown-menu-v2-ariakit/index.js.map +0 -1
  623. package/build-module/dropdown-menu-v2-ariakit/styles.js +0 -165
  624. package/build-module/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  625. package/build-module/dropdown-menu-v2-ariakit/types.js +0 -2
  626. package/build-module/dropdown-menu-v2-ariakit/types.js.map +0 -1
  627. package/build-module/mobile/inserter-button/index.native.js +0 -89
  628. package/build-module/mobile/inserter-button/index.native.js.map +0 -1
  629. package/build-module/mobile/inserter-button/sparkles.js +0 -15
  630. package/build-module/mobile/inserter-button/sparkles.js.map +0 -1
  631. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  632. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js +0 -110
  633. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js.map +0 -1
  634. package/build-types/dropdown-menu-v2-ariakit/index.d.ts +0 -20
  635. package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +0 -1
  636. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +0 -16
  637. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +0 -1
  638. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +0 -96
  639. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +0 -1
  640. package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +0 -1
  641. package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -168
  642. package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +0 -1
  643. package/build-types/mobile/inserter-button/sparkles.d.ts +0 -3
  644. package/build-types/mobile/inserter-button/sparkles.d.ts.map +0 -1
  645. package/src/dropdown-menu-v2-ariakit/README.md +0 -331
  646. package/src/dropdown-menu-v2-ariakit/index.tsx +0 -383
  647. package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +0 -617
  648. package/src/dropdown-menu-v2-ariakit/styles.ts +0 -333
  649. package/src/dropdown-menu-v2-ariakit/test/index.tsx +0 -1108
  650. package/src/dropdown-menu-v2-ariakit/types.ts +0 -179
  651. package/src/mobile/inserter-button/README.md +0 -62
  652. package/src/mobile/inserter-button/index.native.js +0 -116
  653. package/src/mobile/inserter-button/sparkles.js +0 -15
  654. package/src/mobile/inserter-button/style.native.scss +0 -72
  655. package/src/mobile/link-settings/image-link-destinations-screen.native.js +0 -152
  656. /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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,OAAO,EAAEC,IAAI,EA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S,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\t\t/>\n\t\t\t) }\n\t\t</View>\n\t);\n};\n\nexport default ImageComponent;\n"],"mappings":";AA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;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( KeyboardAwareFlatList );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OA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}
@@ -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,sBAAsB,GAAGjB,MAAM,CAAC,CAAC;EACvC,MAAMkB,iBAAiB,GAAGrB,cAAc,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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,MAAM,iCAAiC;AAEvE,MAAMC,iBAAiB,GAAG,EAAE;AAC5B,MAAMC,kBAAkB,G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AC;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"}