@wordpress/components 25.14.0 → 25.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (479) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/CONTRIBUTING.md +57 -115
  3. package/LICENSE.md +1 -1
  4. package/build/base-control/index.js +17 -13
  5. package/build/base-control/index.js.map +1 -1
  6. package/build/border-box-control/border-box-control-linked-button/component.js +1 -1
  7. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  8. package/build/border-control/border-control-style-picker/component.js +1 -1
  9. package/build/border-control/border-control-style-picker/component.js.map +1 -1
  10. package/build/box-control/index.js +1 -1
  11. package/build/box-control/index.js.map +1 -1
  12. package/build/box-control/linked-button.js +1 -1
  13. package/build/box-control/linked-button.js.map +1 -1
  14. package/build/button/index.js +1 -1
  15. package/build/button/index.js.map +1 -1
  16. package/build/color-picker/color-copy-button.js +1 -1
  17. package/build/color-picker/color-copy-button.js.map +1 -1
  18. package/build/context/wordpress-component.js.map +1 -1
  19. package/build/custom-select-control-v2/index.js +11 -10
  20. package/build/custom-select-control-v2/index.js.map +1 -1
  21. package/build/date-time/date/styles.js +8 -8
  22. package/build/date-time/date/styles.js.map +1 -1
  23. package/build/dropdown-menu-v2/index.js +205 -159
  24. package/build/dropdown-menu-v2/index.js.map +1 -1
  25. package/build/dropdown-menu-v2/styles.js +86 -77
  26. package/build/dropdown-menu-v2/styles.js.map +1 -1
  27. package/build/dropdown-menu-v2/types.js.map +1 -1
  28. package/build/duotone-picker/duotone-picker.js +4 -3
  29. package/build/duotone-picker/duotone-picker.js.map +1 -1
  30. package/build/font-size-picker/index.js +4 -2
  31. package/build/font-size-picker/index.js.map +1 -1
  32. package/build/font-size-picker/index.native.js +6 -3
  33. package/build/font-size-picker/index.native.js.map +1 -1
  34. package/build/form-token-field/index.js +10 -5
  35. package/build/form-token-field/index.js.map +1 -1
  36. package/build/form-token-field/token.js +1 -0
  37. package/build/form-token-field/token.js.map +1 -1
  38. package/build/gradient-picker/index.js +3 -2
  39. package/build/gradient-picker/index.js.map +1 -1
  40. package/build/index.native.js +20 -3
  41. package/build/index.native.js.map +1 -1
  42. package/build/input-control/styles/input-control-styles.js +32 -29
  43. package/build/input-control/styles/input-control-styles.js.map +1 -1
  44. package/build/input-control/types.js.map +1 -1
  45. package/build/lock-unlock.js +18 -0
  46. package/build/lock-unlock.js.map +1 -0
  47. package/build/mobile/bottom-sheet/index.native.js +8 -0
  48. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  49. package/build/mobile/global-styles-context/utils.native.js +26 -13
  50. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  51. package/build/mobile/image/constants.js +12 -0
  52. package/build/mobile/image/constants.js.map +1 -0
  53. package/build/mobile/image/index.native.js +26 -18
  54. package/build/mobile/image/index.native.js.map +1 -1
  55. package/build/mobile/keyboard-aware-flat-list/index.android.js +40 -8
  56. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  57. package/build/mobile/keyboard-aware-flat-list/index.ios.js +44 -68
  58. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  59. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +39 -0
  60. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  61. package/build/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -29
  62. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  63. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js +93 -0
  64. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  65. package/build/mobile/utils/get-px-from-css-unit.native.js +302 -0
  66. package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  67. package/build/modal/index.js +18 -13
  68. package/build/modal/index.js.map +1 -1
  69. package/build/navigation/menu/menu-title.js +1 -1
  70. package/build/navigation/menu/menu-title.js.map +1 -1
  71. package/build/navigator/navigator-provider/component.js +13 -15
  72. package/build/navigator/navigator-provider/component.js.map +1 -1
  73. package/build/navigator/navigator-screen/component.js +23 -63
  74. package/build/navigator/navigator-screen/component.js.map +1 -1
  75. package/build/navigator/styles.js +52 -0
  76. package/build/navigator/styles.js.map +1 -0
  77. package/build/number-control/index.js +4 -8
  78. package/build/number-control/index.js.map +1 -1
  79. package/build/number-control/types.js.map +1 -1
  80. package/build/palette-edit/index.js +15 -54
  81. package/build/palette-edit/index.js.map +1 -1
  82. package/build/private-apis.js +11 -26
  83. package/build/private-apis.js.map +1 -1
  84. package/build/private-apis.native.js +21 -0
  85. package/build/private-apis.native.js.map +1 -0
  86. package/build/radio-control/index.js +1 -0
  87. package/build/radio-control/index.js.map +1 -1
  88. package/build/range-control/index.js +1 -1
  89. package/build/range-control/index.js.map +1 -1
  90. package/build/select-control/styles/select-control-styles.js +15 -25
  91. package/build/select-control/styles/select-control-styles.js.map +1 -1
  92. package/build/slot-fill/index.js +3 -2
  93. package/build/slot-fill/index.js.map +1 -1
  94. package/build/slot-fill/types.js.map +1 -1
  95. package/build/snackbar/types.js.map +1 -1
  96. package/build/tabs/styles.js +3 -3
  97. package/build/tabs/styles.js.map +1 -1
  98. package/build/tabs/tabpanel.js +9 -7
  99. package/build/tabs/tabpanel.js.map +1 -1
  100. package/build/toggle-group-control/toggle-group-control/component.js +4 -4
  101. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  102. package/build/toggle-group-control/toggle-group-control/styles.js +29 -15
  103. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  104. package/build/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  105. package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  106. package/build/tools-panel/tools-panel/component.js +3 -1
  107. package/build/tools-panel/tools-panel/component.js.map +1 -1
  108. package/build/tools-panel/tools-panel-header/component.js +9 -8
  109. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  110. package/build/tools-panel/types.js.map +1 -1
  111. package/build/tooltip/index.js +1 -1
  112. package/build/tooltip/index.js.map +1 -1
  113. package/build/truncate/hook.js +10 -4
  114. package/build/truncate/hook.js.map +1 -1
  115. package/build/truncate/types.js.map +1 -1
  116. package/build/unit-control/index.js +1 -1
  117. package/build/unit-control/index.js.map +1 -1
  118. package/build/utils/strings.js +34 -3
  119. package/build/utils/strings.js.map +1 -1
  120. package/build-module/base-control/index.js +16 -12
  121. package/build-module/base-control/index.js.map +1 -1
  122. package/build-module/border-box-control/border-box-control-linked-button/component.js +1 -1
  123. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  124. package/build-module/border-control/border-control-style-picker/component.js +1 -1
  125. package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
  126. package/build-module/box-control/index.js +1 -1
  127. package/build-module/box-control/index.js.map +1 -1
  128. package/build-module/box-control/linked-button.js +1 -1
  129. package/build-module/box-control/linked-button.js.map +1 -1
  130. package/build-module/button/index.js +1 -1
  131. package/build-module/button/index.js.map +1 -1
  132. package/build-module/color-picker/color-copy-button.js +1 -1
  133. package/build-module/color-picker/color-copy-button.js.map +1 -1
  134. package/build-module/context/wordpress-component.js.map +1 -1
  135. package/build-module/custom-select-control-v2/index.js +11 -10
  136. package/build-module/custom-select-control-v2/index.js.map +1 -1
  137. package/build-module/date-time/date/styles.js +8 -8
  138. package/build-module/date-time/date/styles.js.map +1 -1
  139. package/build-module/dropdown-menu-v2/index.js +201 -154
  140. package/build-module/dropdown-menu-v2/index.js.map +1 -1
  141. package/build-module/dropdown-menu-v2/styles.js +68 -61
  142. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  143. package/build-module/dropdown-menu-v2/types.js.map +1 -1
  144. package/build-module/duotone-picker/duotone-picker.js +4 -3
  145. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  146. package/build-module/font-size-picker/index.js +4 -2
  147. package/build-module/font-size-picker/index.js.map +1 -1
  148. package/build-module/font-size-picker/index.native.js +5 -2
  149. package/build-module/font-size-picker/index.native.js.map +1 -1
  150. package/build-module/form-token-field/index.js +10 -5
  151. package/build-module/form-token-field/index.js.map +1 -1
  152. package/build-module/form-token-field/token.js +1 -0
  153. package/build-module/form-token-field/token.js.map +1 -1
  154. package/build-module/gradient-picker/index.js +3 -2
  155. package/build-module/gradient-picker/index.js.map +1 -1
  156. package/build-module/index.native.js +6 -1
  157. package/build-module/index.native.js.map +1 -1
  158. package/build-module/input-control/styles/input-control-styles.js +31 -29
  159. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  160. package/build-module/input-control/types.js.map +1 -1
  161. package/build-module/lock-unlock.js +9 -0
  162. package/build-module/lock-unlock.js.map +1 -0
  163. package/build-module/mobile/bottom-sheet/index.native.js +9 -1
  164. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  165. package/build-module/mobile/global-styles-context/utils.native.js +25 -13
  166. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  167. package/build-module/mobile/image/constants.js +5 -0
  168. package/build-module/mobile/image/constants.js.map +1 -0
  169. package/build-module/mobile/image/index.native.js +25 -16
  170. package/build-module/mobile/image/index.native.js.map +1 -1
  171. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +40 -6
  172. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  173. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +46 -68
  174. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  175. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +33 -0
  176. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  177. package/build-module/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +21 -27
  178. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  179. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js +86 -0
  180. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  181. package/build-module/mobile/utils/get-px-from-css-unit.native.js +294 -0
  182. package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  183. package/build-module/modal/index.js +18 -13
  184. package/build-module/modal/index.js.map +1 -1
  185. package/build-module/navigation/menu/menu-title.js +1 -1
  186. package/build-module/navigation/menu/menu-title.js.map +1 -1
  187. package/build-module/navigator/navigator-provider/component.js +3 -16
  188. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  189. package/build-module/navigator/navigator-screen/component.js +16 -70
  190. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  191. package/build-module/navigator/styles.js +47 -0
  192. package/build-module/navigator/styles.js.map +1 -0
  193. package/build-module/number-control/index.js +4 -8
  194. package/build-module/number-control/index.js.map +1 -1
  195. package/build-module/number-control/types.js.map +1 -1
  196. package/build-module/palette-edit/index.js +15 -51
  197. package/build-module/palette-edit/index.js.map +1 -1
  198. package/build-module/private-apis.js +10 -23
  199. package/build-module/private-apis.js.map +1 -1
  200. package/build-module/private-apis.native.js +14 -0
  201. package/build-module/private-apis.native.js.map +1 -0
  202. package/build-module/radio-control/index.js +1 -0
  203. package/build-module/radio-control/index.js.map +1 -1
  204. package/build-module/range-control/index.js +1 -1
  205. package/build-module/range-control/index.js.map +1 -1
  206. package/build-module/select-control/styles/select-control-styles.js +15 -25
  207. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  208. package/build-module/slot-fill/index.js +3 -2
  209. package/build-module/slot-fill/index.js.map +1 -1
  210. package/build-module/slot-fill/types.js.map +1 -1
  211. package/build-module/snackbar/types.js.map +1 -1
  212. package/build-module/tabs/styles.js +3 -3
  213. package/build-module/tabs/styles.js.map +1 -1
  214. package/build-module/tabs/tabpanel.js +9 -7
  215. package/build-module/tabs/tabpanel.js.map +1 -1
  216. package/build-module/toggle-group-control/toggle-group-control/component.js +4 -4
  217. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  218. package/build-module/toggle-group-control/toggle-group-control/styles.js +29 -15
  219. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  220. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  221. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  222. package/build-module/tools-panel/tools-panel/component.js +3 -1
  223. package/build-module/tools-panel/tools-panel/component.js.map +1 -1
  224. package/build-module/tools-panel/tools-panel-header/component.js +9 -8
  225. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  226. package/build-module/tools-panel/types.js.map +1 -1
  227. package/build-module/tooltip/index.js +1 -1
  228. package/build-module/tooltip/index.js.map +1 -1
  229. package/build-module/truncate/hook.js +10 -4
  230. package/build-module/truncate/hook.js.map +1 -1
  231. package/build-module/truncate/types.js.map +1 -1
  232. package/build-module/unit-control/index.js +1 -1
  233. package/build-module/unit-control/index.js.map +1 -1
  234. package/build-module/utils/strings.js +32 -2
  235. package/build-module/utils/strings.js.map +1 -1
  236. package/build-style/style-rtl.css +29 -5
  237. package/build-style/style.css +29 -5
  238. package/build-types/base-control/index.d.ts +3 -27
  239. package/build-types/base-control/index.d.ts.map +1 -1
  240. package/build-types/base-control/stories/index.story.d.ts +4 -1
  241. package/build-types/base-control/stories/index.story.d.ts.map +1 -1
  242. package/build-types/color-picker/component.d.ts +1 -1
  243. package/build-types/color-picker/stories/index.story.d.ts +1 -1
  244. package/build-types/color-picker/stories/index.story.d.ts.map +1 -1
  245. package/build-types/composite/test/index.d.ts.map +1 -0
  246. package/build-types/context/wordpress-component.d.ts +3 -3
  247. package/build-types/context/wordpress-component.d.ts.map +1 -1
  248. package/build-types/custom-select-control-v2/index.d.ts +3 -2
  249. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  250. package/build-types/custom-select-control-v2/stories/index.story.d.ts +4 -3
  251. package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
  252. package/build-types/dropdown/index.d.ts +1 -1
  253. package/build-types/dropdown/index.d.ts.map +1 -1
  254. package/build-types/dropdown/stories/index.story.d.ts +3 -3
  255. package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
  256. package/build-types/dropdown-menu/index.d.ts +1 -1
  257. package/build-types/dropdown-menu/index.d.ts.map +1 -1
  258. package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
  259. package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
  260. package/build-types/dropdown-menu-v2/index.d.ts +18 -15
  261. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
  262. package/build-types/dropdown-menu-v2/stories/index.story.d.ts +7 -2
  263. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
  264. package/build-types/dropdown-menu-v2/styles.d.ts +77 -23
  265. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
  266. package/build-types/dropdown-menu-v2/types.d.ts +89 -173
  267. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
  268. package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
  269. package/build-types/font-size-picker/index.d.ts.map +1 -1
  270. package/build-types/form-token-field/index.d.ts.map +1 -1
  271. package/build-types/form-token-field/token.d.ts.map +1 -1
  272. package/build-types/input-control/styles/input-control-styles.d.ts +11 -0
  273. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  274. package/build-types/input-control/types.d.ts +1 -1
  275. package/build-types/input-control/types.d.ts.map +1 -1
  276. package/build-types/lock-unlock.d.ts +3 -0
  277. package/build-types/lock-unlock.d.ts.map +1 -0
  278. package/build-types/mobile/image/constants.d.ts +5 -0
  279. package/build-types/mobile/image/constants.d.ts.map +1 -0
  280. package/build-types/modal/index.d.ts.map +1 -1
  281. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  282. package/build-types/navigator/navigator-screen/component.d.ts +1 -7
  283. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  284. package/build-types/navigator/styles.d.ts +9 -0
  285. package/build-types/navigator/styles.d.ts.map +1 -0
  286. package/build-types/number-control/index.d.ts.map +1 -1
  287. package/build-types/number-control/types.d.ts +1 -1
  288. package/build-types/palette-edit/index.d.ts +3 -8
  289. package/build-types/palette-edit/index.d.ts.map +1 -1
  290. package/build-types/popover/index.d.ts +1 -1
  291. package/build-types/popover/index.d.ts.map +1 -1
  292. package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
  293. package/build-types/private-apis.d.ts +0 -1
  294. package/build-types/private-apis.d.ts.map +1 -1
  295. package/build-types/radio-control/index.d.ts.map +1 -1
  296. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  297. package/build-types/slot-fill/index.d.ts +1 -1
  298. package/build-types/slot-fill/index.d.ts.map +1 -1
  299. package/build-types/slot-fill/types.d.ts +4 -0
  300. package/build-types/slot-fill/types.d.ts.map +1 -1
  301. package/build-types/snackbar/index.d.ts +2 -2
  302. package/build-types/snackbar/stories/index.story.d.ts +0 -3
  303. package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
  304. package/build-types/snackbar/types.d.ts +1 -1
  305. package/build-types/snackbar/types.d.ts.map +1 -1
  306. package/build-types/tabs/styles.d.ts.map +1 -1
  307. package/build-types/tabs/tabpanel.d.ts +1 -1
  308. package/build-types/tabs/tabpanel.d.ts.map +1 -1
  309. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  310. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +2 -2
  311. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  312. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +1 -1
  313. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  314. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  315. package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
  316. package/build-types/tools-panel/tools-panel/hook.d.ts +1 -0
  317. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  318. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  319. package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -0
  320. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  321. package/build-types/tools-panel/types.d.ts +9 -0
  322. package/build-types/tools-panel/types.d.ts.map +1 -1
  323. package/build-types/truncate/hook.d.ts +1 -1
  324. package/build-types/truncate/hook.d.ts.map +1 -1
  325. package/build-types/truncate/types.d.ts +4 -0
  326. package/build-types/truncate/types.d.ts.map +1 -1
  327. package/build-types/utils/strings.d.ts +14 -2
  328. package/build-types/utils/strings.d.ts.map +1 -1
  329. package/package.json +20 -21
  330. package/src/alignment-matrix-control/test/index.tsx +10 -16
  331. package/src/base-control/index.tsx +21 -16
  332. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
  333. package/src/border-control/border-control-style-picker/component.tsx +1 -1
  334. package/src/box-control/index.tsx +1 -1
  335. package/src/box-control/linked-button.tsx +1 -1
  336. package/src/button/README.md +32 -6
  337. package/src/button/index.tsx +1 -1
  338. package/src/button-group/README.md +0 -6
  339. package/src/card/card/README.md +1 -1
  340. package/src/checkbox-control/README.md +1 -9
  341. package/src/color-picker/color-copy-button.tsx +1 -1
  342. package/src/combobox-control/README.md +0 -6
  343. package/src/composite/test/index.tsx +576 -0
  344. package/src/context/wordpress-component.ts +11 -6
  345. package/src/custom-select-control/README.md +0 -6
  346. package/src/custom-select-control-v2/index.tsx +13 -12
  347. package/src/date-time/date/styles.ts +3 -3
  348. package/src/dropdown-menu/README.md +0 -5
  349. package/src/dropdown-menu-v2/README.md +75 -136
  350. package/src/dropdown-menu-v2/index.tsx +321 -231
  351. package/src/dropdown-menu-v2/stories/index.story.tsx +522 -126
  352. package/src/dropdown-menu-v2/styles.ts +226 -151
  353. package/src/dropdown-menu-v2/test/index.tsx +480 -188
  354. package/src/dropdown-menu-v2/types.ts +98 -184
  355. package/src/duotone-picker/duotone-picker.tsx +7 -3
  356. package/src/font-size-picker/index.native.js +8 -2
  357. package/src/font-size-picker/index.tsx +4 -2
  358. package/src/form-toggle/README.md +0 -6
  359. package/src/form-token-field/index.tsx +11 -7
  360. package/src/form-token-field/test/index.tsx +97 -0
  361. package/src/form-token-field/token.tsx +1 -0
  362. package/src/gradient-picker/index.tsx +2 -2
  363. package/src/index.native.js +6 -1
  364. package/src/input-control/styles/input-control-styles.tsx +10 -8
  365. package/src/input-control/types.ts +1 -1
  366. package/src/lock-unlock.js +10 -0
  367. package/src/menu-group/README.md +0 -8
  368. package/src/menu-items-choice/README.md +0 -7
  369. package/src/mobile/bottom-sheet/index.native.js +15 -1
  370. package/src/mobile/global-styles-context/test/fixtures/theme.native.js +0 -20
  371. package/src/mobile/global-styles-context/utils.native.js +28 -19
  372. package/src/mobile/image/constants.js +1 -0
  373. package/src/mobile/image/index.native.js +55 -18
  374. package/src/mobile/image/style.native.scss +35 -9
  375. package/src/mobile/keyboard-aware-flat-list/index.android.js +50 -5
  376. package/src/mobile/keyboard-aware-flat-list/index.ios.js +65 -91
  377. package/src/mobile/keyboard-aware-flat-list/test/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +27 -25
  378. package/src/mobile/keyboard-aware-flat-list/test/use-scroll.native.js +71 -0
  379. package/src/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +41 -0
  380. package/src/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -27
  381. package/src/mobile/keyboard-aware-flat-list/use-scroll.native.js +100 -0
  382. package/src/mobile/utils/get-px-from-css-unit.native.js +329 -0
  383. package/src/mobile/utils/test/get-px-from-css-unit.native.js +172 -0
  384. package/src/modal/README.md +0 -6
  385. package/src/modal/index.tsx +18 -16
  386. package/src/modal/test/index.tsx +90 -1
  387. package/src/navigation/menu/menu-title.tsx +1 -1
  388. package/src/navigator/navigator-provider/component.tsx +3 -4
  389. package/src/navigator/navigator-screen/component.tsx +15 -93
  390. package/src/navigator/styles.ts +71 -0
  391. package/src/navigator/test/index.tsx +0 -64
  392. package/src/notice/README.md +0 -6
  393. package/src/number-control/README.md +2 -2
  394. package/src/number-control/index.tsx +4 -8
  395. package/src/number-control/types.ts +1 -1
  396. package/src/palette-edit/index.tsx +15 -58
  397. package/src/palette-edit/test/index.tsx +1 -75
  398. package/src/panel/README.md +0 -6
  399. package/src/private-apis.native.js +13 -0
  400. package/src/private-apis.ts +12 -37
  401. package/src/radio-control/README.md +0 -6
  402. package/src/radio-control/index.tsx +4 -1
  403. package/src/radio-control/style.scss +29 -2
  404. package/src/radio-group/README.md +0 -6
  405. package/src/range-control/README.md +1 -9
  406. package/src/range-control/index.tsx +1 -1
  407. package/src/search-control/README.md +0 -6
  408. package/src/select-control/README.md +0 -6
  409. package/src/select-control/styles/select-control-styles.ts +10 -28
  410. package/src/slot-fill/index.tsx +5 -2
  411. package/src/slot-fill/types.ts +5 -0
  412. package/src/snackbar/README.md +0 -6
  413. package/src/snackbar/stories/index.story.tsx +7 -5
  414. package/src/snackbar/style.scss +4 -3
  415. package/src/snackbar/types.ts +2 -1
  416. package/src/spacer/README.md +0 -2
  417. package/src/tab-panel/README.md +0 -5
  418. package/src/tab-panel/test/index.tsx +39 -56
  419. package/src/tabs/styles.ts +7 -1
  420. package/src/tabs/tabpanel.tsx +7 -6
  421. package/src/tabs/test/index.tsx +56 -0
  422. package/src/text-control/README.md +0 -6
  423. package/src/textarea-control/README.md +0 -6
  424. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +12 -16
  425. package/src/toggle-group-control/test/index.tsx +58 -45
  426. package/src/toggle-group-control/toggle-group-control/component.tsx +5 -4
  427. package/src/toggle-group-control/toggle-group-control/styles.ts +13 -19
  428. package/src/toggle-group-control/toggle-group-control-option/README.md +1 -1
  429. package/src/toggle-group-control/toggle-group-control-option-base/README.md +1 -1
  430. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +3 -2
  431. package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
  432. package/src/toolbar/toolbar/README.md +0 -6
  433. package/src/tools-panel/test/index.tsx +12 -20
  434. package/src/tools-panel/tools-panel/README.md +7 -0
  435. package/src/tools-panel/tools-panel/component.tsx +2 -0
  436. package/src/tools-panel/tools-panel-header/README.md +7 -0
  437. package/src/tools-panel/tools-panel-header/component.tsx +20 -13
  438. package/src/tools-panel/types.ts +9 -0
  439. package/src/tooltip/index.tsx +1 -1
  440. package/src/tooltip/test/index.tsx +360 -256
  441. package/src/tree-grid/README.md +0 -4
  442. package/src/truncate/README.md +8 -0
  443. package/src/truncate/hook.ts +17 -10
  444. package/src/truncate/test/index.tsx +54 -27
  445. package/src/truncate/types.ts +4 -0
  446. package/src/unit-control/index.tsx +1 -1
  447. package/src/utils/strings.ts +30 -2
  448. package/src/utils/test/strings.js +96 -1
  449. package/tsconfig.tsbuildinfo +1 -1
  450. package/build/dropdown-menu-v2-ariakit/index.js +0 -256
  451. package/build/dropdown-menu-v2-ariakit/index.js.map +0 -1
  452. package/build/dropdown-menu-v2-ariakit/styles.js +0 -180
  453. package/build/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  454. package/build/dropdown-menu-v2-ariakit/types.js +0 -6
  455. package/build/dropdown-menu-v2-ariakit/types.js.map +0 -1
  456. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  457. package/build-module/dropdown-menu-v2-ariakit/index.js +0 -237
  458. package/build-module/dropdown-menu-v2-ariakit/index.js.map +0 -1
  459. package/build-module/dropdown-menu-v2-ariakit/styles.js +0 -165
  460. package/build-module/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  461. package/build-module/dropdown-menu-v2-ariakit/types.js +0 -2
  462. package/build-module/dropdown-menu-v2-ariakit/types.js.map +0 -1
  463. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  464. package/build-types/dropdown-menu-v2-ariakit/index.d.ts +0 -20
  465. package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +0 -1
  466. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +0 -16
  467. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +0 -1
  468. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +0 -96
  469. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +0 -1
  470. package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +0 -1
  471. package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -168
  472. package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +0 -1
  473. package/src/dropdown-menu-v2-ariakit/README.md +0 -331
  474. package/src/dropdown-menu-v2-ariakit/index.tsx +0 -383
  475. package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +0 -617
  476. package/src/dropdown-menu-v2-ariakit/styles.ts +0 -345
  477. package/src/dropdown-menu-v2-ariakit/test/index.tsx +0 -1108
  478. package/src/dropdown-menu-v2-ariakit/types.ts +0 -179
  479. /package/build-types/{dropdown-menu-v2-ariakit → composite}/test/index.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IMAGE_DEFAULT_FOCAL_POINT","x","y","exports"],"sources":["@wordpress/components/src/mobile/image/constants.js"],"sourcesContent":["export const IMAGE_DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\n"],"mappings":";;;;;;AAAO,MAAMA,yBAAyB,GAAG;EAAEC,CAAC,EAAE,GAAG;EAAEC,CAAC,EAAE;AAAI,CAAC;AAACC,OAAA,CAAAH,yBAAA,GAAAA,yBAAA"}
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = exports.IMAGE_DEFAULT_FOCAL_POINT = void 0;
7
+ exports.default = void 0;
8
8
  var _react = require("react");
9
9
  var _reactNative = require("react-native");
10
10
  var _reactNativeFastImage = _interopRequireDefault(require("react-native-fast-image"));
@@ -30,15 +30,11 @@ var _imageEditingButton = _interopRequireDefault(require("./image-editing-button
30
30
  */
31
31
 
32
32
  const ICON_TYPE = {
33
+ OFFLINE: 'offline',
33
34
  PLACEHOLDER: 'placeholder',
34
35
  RETRY: 'retry',
35
36
  UPLOAD: 'upload'
36
37
  };
37
- const IMAGE_DEFAULT_FOCAL_POINT = {
38
- x: 0.5,
39
- y: 0.5
40
- };
41
- exports.IMAGE_DEFAULT_FOCAL_POINT = IMAGE_DEFAULT_FOCAL_POINT;
42
38
  const ImageComponent = ({
43
39
  align,
44
40
  alt,
@@ -49,6 +45,7 @@ const ImageComponent = ({
49
45
  isSelected,
50
46
  shouldUseFastImage,
51
47
  isUploadFailed,
48
+ isUploadPaused,
52
49
  isUploadInProgress,
53
50
  mediaPickerOptions,
54
51
  onImageDataLoad,
@@ -104,27 +101,38 @@ const ImageComponent = ({
104
101
  }
105
102
  };
106
103
  const getIcon = iconType => {
104
+ let icon;
107
105
  let iconStyle;
108
106
  switch (iconType) {
109
107
  case ICON_TYPE.RETRY:
110
- return (0, _react.createElement)(_components.Icon, {
111
- icon: retryIcon || _iconRetry.default,
112
- ..._style.default.iconRetry
113
- });
108
+ icon = retryIcon || _iconRetry.default;
109
+ iconStyle = iconRetryStyles;
110
+ break;
111
+ case ICON_TYPE.OFFLINE:
112
+ icon = _icons.offline;
113
+ iconStyle = iconOfflineStyles;
114
+ break;
114
115
  case ICON_TYPE.PLACEHOLDER:
116
+ icon = _icons.image;
115
117
  iconStyle = iconPlaceholderStyles;
116
118
  break;
117
119
  case ICON_TYPE.UPLOAD:
120
+ icon = _icons.image;
118
121
  iconStyle = iconUploadStyles;
119
122
  break;
120
123
  }
121
124
  return (0, _react.createElement)(_components.Icon, {
122
- icon: _icons.image,
125
+ icon: icon,
123
126
  ...iconStyle
124
127
  });
125
128
  };
126
129
  const iconPlaceholderStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default.iconPlaceholder, _style.default.iconPlaceholderDark);
127
130
  const iconUploadStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default.iconUpload, _style.default.iconUploadDark);
131
+ const iconOfflineStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default.iconOffline, _style.default.iconOfflineDark);
132
+ const retryIconStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default.retryIcon, _style.default.retryIconDark);
133
+ const iconRetryStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default.iconRetry, _style.default.iconRetryDark);
134
+ const retryContainerStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default.retryContainer, _style.default.retryContainerDark);
135
+ const uploadFailedTextStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default.uploadFailedText, _style.default.uploadFailedTextDark);
128
136
  const placeholderStyles = [(0, _compose.usePreferredColorSchemeStyle)(_style.default.imageContainerUpload, _style.default.imageContainerUploadDark), focalPoint && _style.default.imageContainerUploadWithFocalpoint, imageHeight && {
129
137
  height: imageHeight
130
138
  }];
@@ -164,7 +172,7 @@ const ImageComponent = ({
164
172
  accessibilityRole: 'imagebutton',
165
173
  key: url,
166
174
  style: imageContainerStyles
167
- }, isSelected && highlightSelected && !(isUploadInProgress || isUploadFailed) && (0, _react.createElement)(_reactNative.View, {
175
+ }, isSelected && highlightSelected && !(isUploadInProgress || isUploadFailed || isUploadPaused) && (0, _react.createElement)(_reactNative.View, {
168
176
  style: imageSelectedStyles
169
177
  }), !imageData ? (0, _react.createElement)(_reactNative.View, {
170
178
  style: placeholderStyles
@@ -181,16 +189,16 @@ const ImageComponent = ({
181
189
  resizeMethod: 'scale'
182
190
  }),
183
191
  resizeMode: imageResizeMode
184
- })), isUploadFailed && retryMessage && (0, _react.createElement)(_reactNative.View, {
185
- style: [_style.default.imageContainer, _style.default.retryContainer]
192
+ })), (isUploadFailed || isUploadPaused) && retryMessage && (0, _react.createElement)(_reactNative.View, {
193
+ style: [_style.default.imageContainer, retryContainerStyles]
186
194
  }, (0, _react.createElement)(_reactNative.View, {
187
- style: [_style.default.retryIcon, retryIcon && _style.default.customRetryIcon]
188
- }, getIcon(ICON_TYPE.RETRY)), (0, _react.createElement)(_reactNative.Text, {
189
- style: _style.default.uploadFailedText
195
+ style: [retryIconStyles, retryIcon && _style.default.customRetryIcon]
196
+ }, isUploadPaused ? getIcon(ICON_TYPE.OFFLINE) : getIcon(ICON_TYPE.RETRY)), (0, _react.createElement)(_reactNative.Text, {
197
+ style: uploadFailedTextStyles
190
198
  }, retryMessage))), editButton && isSelected && !isUploadInProgress && (0, _react.createElement)(_imageEditingButton.default, {
191
199
  onSelectMediaUploadOption: onSelectMediaUploadOption,
192
200
  openMediaOptions: openMediaOptions,
193
- url: !isUploadFailed && imageData && url,
201
+ url: !(isUploadFailed || isUploadPaused) && imageData && url,
194
202
  pickerOptions: mediaPickerOptions
195
203
  }));
196
204
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_reactNativeFastImage","_interopRequireDefault","_i18n","_components","_icons","_compose","_element","_utils","_style","_iconRetry","_imageEditingButton","ICON_TYPE","PLACEHOLDER","RETRY","UPLOAD","IMAGE_DEFAULT_FOCAL_POINT","x","y","exports","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","useState","containerSize","setContainerSize","Image","Platform","isAndroid","RNImage","FastImage","imageResizeMode","useEffect","isCurrent","getSize","imgWidth","imgHeight","metaData","aspectRatio","onContainerLayout","event","nativeEvent","layout","getIcon","iconType","iconStyle","_react","createElement","Icon","icon","SvgIconRetry","styles","iconRetry","iconPlaceholderStyles","iconUploadStyles","usePreferredColorSchemeStyle","iconPlaceholder","iconPlaceholderDark","iconUpload","iconUploadDark","placeholderStyles","imageContainerUpload","imageContainerUploadDark","imageContainerUploadWithFocalpoint","customWidth","wide","imageContainerStyles","imageContent","focalPointContainer","imageStyles","opacity","getImageWithFocalPointStyles","undefined","imageSelectedStyles","imageBorder","imageBorderDark","View","container","alignItems","onLayout","accessible","disabled","accessibilityLabel","accessibilityHint","__","accessibilityRole","key","imageUploadingIconContainer","focalPointContent","source","uri","resizeMethod","imageContainer","retryContainer","customRetryIcon","Text","uploadFailedText","default","pickerOptions","_default"],"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":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,UAAA,GAAAR,sBAAA,CAAAF,OAAA;AACA,IAAAW,mBAAA,GAAAT,sBAAA,CAAAF,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BAAA,CAAA6G,OAAkB;IAClBtF,yBAAyB,EAAGA,yBAA2B;IACvDC,gBAAgB,EAAGA,gBAAkB;IACrCI,GAAG,EAAG,CAAET,cAAc,IAAIc,SAAS,IAAIL,GAAK;IAC5CkF,aAAa,EAAGzF;EAAoB,CACpC,CAEG,CAAC;AAET,CAAC;AAAC,IAAA0F,QAAA,GAEatG,cAAc;AAAAD,OAAA,CAAAqG,OAAA,GAAAE,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_reactNativeFastImage","_interopRequireDefault","_i18n","_components","_icons","_compose","_element","_utils","_style","_iconRetry","_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","useState","containerSize","setContainerSize","Image","Platform","isAndroid","RNImage","FastImage","imageResizeMode","useEffect","isCurrent","getSize","imgWidth","imgHeight","metaData","aspectRatio","onContainerLayout","event","nativeEvent","layout","getIcon","iconType","icon","iconStyle","SvgIconRetry","iconRetryStyles","offline","iconOfflineStyles","image","iconPlaceholderStyles","iconUploadStyles","_react","createElement","Icon","usePreferredColorSchemeStyle","styles","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","getImageWithFocalPointStyles","undefined","imageSelectedStyles","imageBorder","imageBorderDark","View","container","alignItems","onLayout","accessible","disabled","accessibilityLabel","accessibilityHint","__","accessibilityRole","key","imageUploadingIconContainer","focalPointContent","source","uri","resizeMethod","imageContainer","customRetryIcon","Text","default","pickerOptions","_default","exports"],"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":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,UAAA,GAAAR,sBAAA,CAAAF,OAAA;AACA,IAAAW,mBAAA,GAAAT,sBAAA,CAAAF,OAAA;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;;AAMA,MAAMY,SAAS,GAAG;EACjBC,OAAO,EAAE,SAAS;EAClBC,WAAW,EAAE,aAAa;EAC1BC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AAED,MAAMC,cAAc,GAAGA,CAAE;EACxBC,KAAK;EACLC,GAAG;EACHC,UAAU,GAAG,IAAI;EACjBC,UAAU;EACVC,MAAM,EAAEC,WAAW;EACnBC,iBAAiB,GAAG,IAAI;EACxBC,UAAU;EACVC,kBAAkB;EAClBC,cAAc;EACdC,cAAc;EACdC,kBAAkB;EAClBC,kBAAkB;EAClBC,eAAe;EACfC,yBAAyB;EACzBC,gBAAgB;EAChBC,UAAU;EACVC,YAAY;EACZC,SAAS;EACTC,GAAG;EACHC,UAAU;EACVC,KAAK;EACLC,KAAK,EAAE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BAAA,CAAAwH,OAAkB;IAClBnG,yBAAyB,EAAGA,yBAA2B;IACvDC,gBAAgB,EAAGA,gBAAkB;IACrCI,GAAG,EACF,EAAIV,cAAc,IAAIC,cAAc,CAAE,IACtCc,SAAS,IACTL,GACA;IACD+F,aAAa,EAAGtG;EAAoB,CACpC,CAEG,CAAC;AAET,CAAC;AAAC,IAAAuG,QAAA,GAEapH,cAAc;AAAAqH,OAAA,CAAAH,OAAA,GAAAE,QAAA"}
@@ -7,38 +7,70 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = exports.KeyboardAwareFlatList = void 0;
8
8
  var _react = require("react");
9
9
  var _reactNative = require("react-native");
10
- var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
11
+ var _element = require("@wordpress/element");
12
+ var _useScroll = _interopRequireDefault(require("./use-scroll"));
11
13
  var _keyboardAvoidingView = _interopRequireDefault(require("../keyboard-avoiding-view"));
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
14
  /**
15
15
  * External dependencies
16
16
  */
17
17
 
18
+ /**
19
+ * WordPress dependencies
20
+ */
21
+
18
22
  /**
19
23
  * Internal dependencies
20
24
  */
21
25
 
22
26
  const AnimatedFlatList = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.FlatList);
23
27
  const KeyboardAwareFlatList = ({
24
- innerRef,
25
28
  onScroll,
26
29
  ...props
27
- }) => {
28
- const scrollHandler = (0, _reactNativeReanimated.useAnimatedScrollHandler)({
30
+ }, ref) => {
31
+ const {
32
+ extraScrollHeight,
33
+ scrollEnabled,
34
+ shouldPreventAutomaticScroll
35
+ } = props;
36
+ const {
37
+ scrollViewRef,
38
+ scrollHandler,
39
+ scrollToSection,
40
+ scrollToElement,
41
+ onContentSizeChange,
42
+ lastScrollTo
43
+ } = (0, _useScroll.default)({
44
+ scrollEnabled,
45
+ shouldPreventAutomaticScroll,
46
+ extraScrollHeight,
29
47
  onScroll
30
48
  });
49
+ const getFlatListRef = (0, _element.useCallback)(flatListRef => {
50
+ // On Android, we get the ref of the associated scroll
51
+ // view to the FlatList.
52
+ scrollViewRef.current = flatListRef?.getNativeScrollRef();
53
+ }, [scrollViewRef]);
54
+ (0, _element.useImperativeHandle)(ref, () => {
55
+ return {
56
+ scrollViewRef: scrollViewRef.current,
57
+ scrollToSection,
58
+ scrollToElement,
59
+ lastScrollTo
60
+ };
61
+ });
31
62
  return (0, _react.createElement)(_keyboardAvoidingView.default, {
32
63
  style: {
33
64
  flex: 1
34
65
  }
35
66
  }, (0, _react.createElement)(AnimatedFlatList, {
36
- ref: innerRef,
67
+ ref: getFlatListRef,
37
68
  onScroll: scrollHandler,
69
+ onContentSizeChange: onContentSizeChange,
38
70
  ...props
39
71
  }));
40
72
  };
41
73
  exports.KeyboardAwareFlatList = KeyboardAwareFlatList;
42
- var _default = KeyboardAwareFlatList;
74
+ var _default = (0, _element.forwardRef)(KeyboardAwareFlatList);
43
75
  exports.default = _default;
44
76
  //# sourceMappingURL=index.android.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_reactNativeReanimated","_interopRequireWildcard","_keyboardAvoidingView","_interopRequireDefault","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AnimatedFlatList","Animated","createAnimatedComponent","FlatList","KeyboardAwareFlatList","innerRef","onScroll","props","scrollHandler","useAnimatedScrollHandler","_react","createElement","style","flex","ref","exports","_default"],"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":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAKA,IAAAG,qBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAA6D,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAA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,OAAoB;IAAC2B,KAAK,EAAG;MAAEC,IAAI,EAAE;IAAE;EAAG,GAC1C,IAAAH,MAAA,CAAAC,aAAA,EAACX,gBAAgB;IAChBc,GAAG,EAAGT,QAAU;IAChBC,QAAQ,EAAGE,aAAe;IAAA,GACrBD;EAAK,CACV,CACoB,CAAC;AAEzB,CAAC;AAACQ,OAAA,CAAAX,qBAAA,GAAAA,qBAAA;AAAA,IAAAY,QAAA,GAEaZ,qBAAqB;AAAAW,OAAA,CAAA9B,OAAA,GAAA+B,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_reactNativeReanimated","_interopRequireDefault","_element","_useScroll","_keyboardAvoidingView","AnimatedFlatList","Animated","createAnimatedComponent","FlatList","KeyboardAwareFlatList","onScroll","props","ref","extraScrollHeight","scrollEnabled","shouldPreventAutomaticScroll","scrollViewRef","scrollHandler","scrollToSection","scrollToElement","onContentSizeChange","lastScrollTo","useScroll","getFlatListRef","useCallback","flatListRef","current","getNativeScrollRef","useImperativeHandle","_react","createElement","default","style","flex","exports","_default","forwardRef"],"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":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AASA,IAAAI,UAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,qBAAA,GAAAH,sBAAA,CAAAF,OAAA;AAnBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAMM,gBAAgB,GAAGC,8BAAQ,CAACC,uBAAuB,CAAEC,qBAAS,CAAC;AAE9D,MAAMC,qBAAqB,GAAGA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAM;EACvE,MAAM;IAAEC,iBAAiB;IAAEC,aAAa;IAAEC;EAA6B,CAAC,GACvEJ,KAAK;EAEN,MAAM;IACLK,aAAa;IACbC,aAAa;IACbC,eAAe;IACfC,eAAe;IACfC,mBAAmB;IACnBC;EACD,CAAC,GAAG,IAAAC,kBAAS,EAAE;IACdR,aAAa;IACbC,4BAA4B;IAC5BF,iBAAiB;IACjBH;EACD,CAAE,CAAC;EAEH,MAAMa,cAAc,GAAG,IAAAC,oBAAW,EAC/BC,WAAW,IAAM;IAClB;IACA;IACAT,aAAa,CAACU,OAAO,GAAGD,WAAW,EAAEE,kBAAkB,CAAC,CAAC;EAC1D,CAAC,EACD,CAAEX,aAAa,CAChB,CAAC;EAED,IAAAY,4BAAmB,EAAEhB,GAAG,EAAE,MAAM;IAC/B,OAAO;MACNI,aAAa,EAAEA,aAAa,CAACU,OAAO;MACpCR,eAAe;MACfC,eAAe;MACfE;IACD,CAAC;EACF,CAAE,CAAC;EAEH,OACC,IAAAQ,MAAA,CAAAC,aAAA,EAAC1B,qBAAA,CAAA2B,OAAoB;IAACC,KAAK,EAAG;MAAEC,IAAI,EAAE;IAAE;EAAG,GAC1C,IAAAJ,MAAA,CAAAC,aAAA,EAACzB,gBAAgB;IAChBO,GAAG,EAAGW,cAAgB;IACtBb,QAAQ,EAAGO,aAAe;IAC1BG,mBAAmB,EAAGA,mBAAqB;IAAA,GACtCT;EAAK,CACV,CACoB,CAAC;AAEzB,CAAC;AAACuB,OAAA,CAAAzB,qBAAA,GAAAA,qBAAA;AAAA,IAAA0B,QAAA,GAEa,IAAAC,mBAAU,EAAE3B,qBAAsB,CAAC;AAAAyB,OAAA,CAAAH,OAAA,GAAAI,QAAA"}
@@ -7,15 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = exports.KeyboardAwareFlatList = void 0;
8
8
  var _react = require("react");
9
9
  var _reactNative = require("react-native");
10
- var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
11
11
  var _element = require("@wordpress/element");
12
12
  var _compose = require("@wordpress/compose");
13
+ var _useScroll = _interopRequireDefault(require("./use-scroll"));
13
14
  var _useTextInputOffset = _interopRequireDefault(require("./use-text-input-offset"));
14
- var _useKeyboardOffset = _interopRequireDefault(require("./use-keyboard-offset"));
15
- var _useScrollToTextInput = _interopRequireDefault(require("./use-scroll-to-text-input"));
16
15
  var _useTextInputCaretPosition = _interopRequireDefault(require("./use-text-input-caret-position"));
17
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
16
  /**
20
17
  * External dependencies
21
18
  */
@@ -28,95 +25,66 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
28
25
  * Internal dependencies
29
26
  */
30
27
 
28
+ const DEFAULT_FONT_SIZE = 16;
31
29
  const AnimatedScrollView = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.ScrollView);
32
30
 
31
+ /** @typedef {import('@wordpress/element').RefObject} RefObject */
33
32
  /**
34
33
  * React component that provides a FlatList that is aware of the keyboard state and can scroll
35
34
  * to the currently focused TextInput.
36
35
  *
37
- * @param {Object} props Component props.
38
- * @param {number} props.extraScrollHeight Extra scroll height for the content.
39
- * @param {Function} props.innerRef Function to pass the ScrollView ref to the parent component.
40
- * @param {Function} props.onScroll Function to be called when the list is scrolled.
41
- * @param {boolean} props.scrollEnabled Whether the list can be scrolled.
42
- * @param {Object} props.scrollViewStyle Additional style for the ScrollView component.
43
- * @param {boolean} props.shouldPreventAutomaticScroll Whether to prevent scrolling when there's a Keyboard offset set.
44
- * @param {Object} props... Other props to pass to the FlatList component.
36
+ * @param {Object} props Component props.
37
+ * @param {number} props.extraScrollHeight Extra scroll height for the content.
38
+ * @param {Function} props.onScroll Function to be called when the list is scrolled.
39
+ * @param {boolean} props.scrollEnabled Whether the list can be scrolled.
40
+ * @param {Object} props.scrollViewStyle Additional style for the ScrollView component.
41
+ * @param {boolean} props.shouldPreventAutomaticScroll Whether to prevent scrolling when there's a Keyboard offset set.
42
+ * @param {Object} props... Other props to pass to the FlatList component.
43
+ * @param {RefObject} ref
45
44
  * @return {Component} KeyboardAwareFlatList component.
46
45
  */
47
46
  const KeyboardAwareFlatList = ({
48
47
  extraScrollHeight,
49
- innerRef,
50
48
  onScroll,
51
49
  scrollEnabled,
52
50
  scrollViewStyle,
53
51
  shouldPreventAutomaticScroll,
54
52
  ...props
55
- }) => {
56
- const scrollViewRef = (0, _element.useRef)();
57
- const scrollViewMeasurements = (0, _element.useRef)();
58
- const scrollViewYOffset = (0, _reactNativeReanimated.useSharedValue)(-1);
53
+ }, ref) => {
59
54
  const {
60
- height: windowHeight,
61
- width: windowWidth
62
- } = (0, _reactNative.useWindowDimensions)();
63
- const isLandscape = windowWidth >= windowHeight;
64
- const [keyboardOffset] = (0, _useKeyboardOffset.default)(scrollEnabled, shouldPreventAutomaticScroll);
65
- const [currentCaretData] = (0, _useTextInputCaretPosition.default)(scrollEnabled);
55
+ scrollViewRef,
56
+ scrollHandler,
57
+ keyboardOffset,
58
+ scrollToSection,
59
+ scrollToElement,
60
+ onContentSizeChange,
61
+ lastScrollTo
62
+ } = (0, _useScroll.default)({
63
+ scrollEnabled,
64
+ shouldPreventAutomaticScroll,
65
+ extraScrollHeight,
66
+ onScroll,
67
+ onSizeChange
68
+ });
66
69
  const [getTextInputOffset] = (0, _useTextInputOffset.default)(scrollEnabled, scrollViewRef);
67
- const [scrollToTextInputOffset] = (0, _useScrollToTextInput.default)(extraScrollHeight, keyboardOffset, scrollEnabled, scrollViewMeasurements, scrollViewRef, scrollViewYOffset);
68
70
  const onScrollToTextInput = (0, _compose.useThrottle)((0, _element.useCallback)(async caret => {
71
+ const {
72
+ caretHeight = DEFAULT_FONT_SIZE
73
+ } = caret !== null && caret !== void 0 ? caret : {};
69
74
  const textInputOffset = await getTextInputOffset(caret);
70
75
  const hasTextInputOffset = textInputOffset !== null;
71
76
  if (hasTextInputOffset) {
72
- scrollToTextInputOffset(caret, textInputOffset);
77
+ scrollToSection(textInputOffset, caretHeight);
73
78
  }
74
- }, [getTextInputOffset, scrollToTextInputOffset]), 200, {
79
+ }, [getTextInputOffset, scrollToSection]), 200, {
75
80
  leading: false
76
81
  });
82
+ const [currentCaretData] = (0, _useTextInputCaretPosition.default)(scrollEnabled);
83
+ const onSizeChange = (0, _element.useCallback)(() => onScrollToTextInput(currentCaretData), [currentCaretData, onScrollToTextInput]);
77
84
  (0, _element.useEffect)(() => {
78
85
  onScrollToTextInput(currentCaretData);
79
86
  }, [currentCaretData, onScrollToTextInput]);
80
87
 
81
- // When the orientation changes, the ScrollView measurements
82
- // need to be re-calculated.
83
- (0, _element.useEffect)(() => {
84
- scrollViewMeasurements.current = null;
85
- }, [isLandscape]);
86
- const scrollHandler = (0, _reactNativeReanimated.useAnimatedScrollHandler)({
87
- onScroll: event => {
88
- const {
89
- contentOffset
90
- } = event;
91
- scrollViewYOffset.value = contentOffset.y;
92
- onScroll(event);
93
- }
94
- });
95
- const measureScrollView = (0, _element.useCallback)(() => {
96
- if (scrollViewRef.current) {
97
- const scrollRef = scrollViewRef.current.getNativeScrollRef();
98
- scrollRef.measureInWindow((_x, y, width, height) => {
99
- scrollViewMeasurements.current = {
100
- y,
101
- width,
102
- height
103
- };
104
- });
105
- }
106
- }, []);
107
- const onContentSizeChange = (0, _element.useCallback)(() => {
108
- onScrollToTextInput(currentCaretData);
109
-
110
- // Sets the first values when the content size changes.
111
- if (!scrollViewMeasurements.current) {
112
- measureScrollView();
113
- }
114
- }, [measureScrollView, onScrollToTextInput, currentCaretData]);
115
- const getRef = (0, _element.useCallback)(ref => {
116
- scrollViewRef.current = ref;
117
- innerRef(ref);
118
- }, [innerRef]);
119
-
120
88
  // Adds content insets when the keyboard is opened to have
121
89
  // extra padding at the bottom.
122
90
  const contentInset = {
@@ -125,13 +93,21 @@ const KeyboardAwareFlatList = ({
125
93
  const style = [{
126
94
  flex: 1
127
95
  }, scrollViewStyle];
96
+ (0, _element.useImperativeHandle)(ref, () => {
97
+ return {
98
+ scrollViewRef: scrollViewRef.current,
99
+ scrollToSection,
100
+ scrollToElement,
101
+ lastScrollTo
102
+ };
103
+ });
128
104
  return (0, _react.createElement)(AnimatedScrollView, {
129
105
  automaticallyAdjustContentInsets: false,
130
106
  contentInset: contentInset,
131
107
  keyboardShouldPersistTaps: "handled",
132
108
  onContentSizeChange: onContentSizeChange,
133
109
  onScroll: scrollHandler,
134
- ref: getRef,
110
+ ref: scrollViewRef,
135
111
  scrollEnabled: scrollEnabled,
136
112
  scrollEventThrottle: 16,
137
113
  style: style
@@ -141,6 +117,6 @@ const KeyboardAwareFlatList = ({
141
117
  }));
142
118
  };
143
119
  exports.KeyboardAwareFlatList = KeyboardAwareFlatList;
144
- var _default = KeyboardAwareFlatList;
120
+ var _default = (0, _element.forwardRef)(KeyboardAwareFlatList);
145
121
  exports.default = _default;
146
122
  //# sourceMappingURL=index.ios.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_reactNativeReanimated","_interopRequireWildcard","_element","_compose","_useTextInputOffset","_interopRequireDefault","_useKeyboardOffset","_useScrollToTextInput","_useTextInputCaretPosition","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AnimatedScrollView","Animated","createAnimatedComponent","ScrollView","KeyboardAwareFlatList","extraScrollHeight","innerRef","onScroll","scrollEnabled","scrollViewStyle","shouldPreventAutomaticScroll","props","scrollViewRef","useRef","scrollViewMeasurements","scrollViewYOffset","useSharedValue","height","windowHeight","width","windowWidth","useWindowDimensions","isLandscape","keyboardOffset","useKeyboardOffset","currentCaretData","useTextInputCaretPosition","getTextInputOffset","useTextInputOffset","scrollToTextInputOffset","useScrollToTextInput","onScrollToTextInput","useThrottle","useCallback","caret","textInputOffset","hasTextInputOffset","leading","useEffect","current","scrollHandler","useAnimatedScrollHandler","event","contentOffset","value","y","measureScrollView","scrollRef","getNativeScrollRef","measureInWindow","_x","onContentSizeChange","getRef","ref","contentInset","bottom","style","flex","_react","createElement","automaticallyAdjustContentInsets","keyboardShouldPersistTaps","scrollEventThrottle","FlatList","exports","_default"],"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 Key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AA6D,QAAA,GAEa7D,qBAAqB;AAAA4D,OAAA,CAAA/E,OAAA,GAAAgF,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_reactNativeReanimated","_interopRequireDefault","_element","_compose","_useScroll","_useTextInputOffset","_useTextInputCaretPosition","DEFAULT_FONT_SIZE","AnimatedScrollView","Animated","createAnimatedComponent","ScrollView","KeyboardAwareFlatList","extraScrollHeight","onScroll","scrollEnabled","scrollViewStyle","shouldPreventAutomaticScroll","props","ref","scrollViewRef","scrollHandler","keyboardOffset","scrollToSection","scrollToElement","onContentSizeChange","lastScrollTo","useScroll","onSizeChange","getTextInputOffset","useTextInputOffset","onScrollToTextInput","useThrottle","useCallback","caret","caretHeight","textInputOffset","hasTextInputOffset","leading","currentCaretData","useTextInputCaretPosition","useEffect","contentInset","bottom","style","flex","useImperativeHandle","current","_react","createElement","automaticallyAdjustContentInsets","keyboardShouldPersistTaps","scrollEventThrottle","FlatList","exports","_default","forwardRef","default"],"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":";;;;;;;;AAIA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,UAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,mBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,0BAAA,GAAAL,sBAAA,CAAAF,OAAA;AAvBA;AACA;AACA;;AAKA;AACA;AACA;;AASA;AACA;AACA;;AAKA,MAAMQ,iBAAiB,GAAG,EAAE;AAC5B,MAAMC,kBAAkB,GAAGC,8BAAQ,CAACC,uBAAuB,CAAEC,uBAAW,CAAC;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAGA,CACpC;EACCC,iBAAiB;EACjBC,Q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AMW,YAAY,GAAG;IAAEC,MAAM,EAAErB;EAAe,CAAC;EAE/C,MAAMsB,KAAK,GAAG,CAAE;IAAEC,IAAI,EAAE;EAAE,CAAC,EAAE7B,eAAe,CAAE;EAE9C,IAAA8B,4BAAmB,EAAE3B,GAAG,EAAE,MAAM;IAC/B,OAAO;MACNC,aAAa,EAAEA,aAAa,CAAC2B,OAAO;MACpCxB,eAAe;MACfC,eAAe;MACfE;IACD,CAAC;EACF,CAAE,CAAC;EAEH,OACC,IAAAsB,MAAA,CAAAC,aAAA,EAACzC,kBAAkB;IAClB0C,gCAAgC,EAAG,KAAO;IAC1CR,YAAY,EAAGA,YAAc;IAC7BS,yBAAyB,EAAC,SAAS;IACnC1B,mBAAmB,EAAGA,mBAAqB;IAC3CX,QAAQ,EAAGO,aAAe;IAC1BF,GAAG,EAAGC,aAAe;IACrBL,aAAa,EAAGA,aAAe;IAC/BqC,mBAAmB,EAAG,EAAI;IAC1BR,KAAK,EAAGA;EAAO,GAEf,IAAAI,MAAA,CAAAC,aAAA,EAACnD,YAAA,CAAAuD,QAAQ;IAAA,GAAMnC,KAAK;IAAGH,aAAa,EAAG;EAAO,CAAE,CAC7B,CAAC;AAEvB,CAAC;AAACuC,OAAA,CAAA1C,qBAAA,GAAAA,qBAAA;AAAA,IAAA2C,QAAA,GAEa,IAAAC,mBAAU,EAAE5C,qBAAsB,CAAC;AAAA0C,OAAA,CAAAG,OAAA,GAAAF,QAAA"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useScrollToElement;
7
+ var _element = require("@wordpress/element");
8
+ /**
9
+ * WordPress dependencies
10
+ */
11
+
12
+ /** @typedef {import('@wordpress/element').RefObject} RefObject */
13
+ /**
14
+ * Hook to scroll to a specified element by taking into account the Keyboard
15
+ * and the Header.
16
+ *
17
+ * @param {RefObject} scrollViewRef Scroll view reference.
18
+ * @param {Function} scrollToSection Function to scroll.
19
+ * @return {Function[]} Function to scroll to an element.
20
+ */
21
+ function useScrollToElement(scrollViewRef, scrollToSection) {
22
+ /**
23
+ * Function to scroll to an element.
24
+ *
25
+ * @param {RefObject} elementRef Ref of the element.
26
+ */
27
+ const scrollToElement = (0, _element.useCallback)(elementRef => {
28
+ if (!scrollViewRef.current || !elementRef) {
29
+ return;
30
+ }
31
+ elementRef.current.measureLayout(scrollViewRef.current, (_x, y, _width, height) => {
32
+ if (height || y) {
33
+ scrollToSection(Math.round(y), height);
34
+ }
35
+ }, () => {});
36
+ }, [scrollViewRef, scrollToSection]);
37
+ return [scrollToElement];
38
+ }
39
+ //# sourceMappingURL=use-scroll-to-element.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_element","require","useScrollToElement","scrollViewRef","scrollToSection","scrollToElement","useCallback","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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,kBAAkBA,CAAEC,aAAa,EAAEC,eAAe,EAAG;EAC5E;AACD;AACA;AACA;AACA;EACC,MAAMC,eAAe,GAAG,IAAAC,oBAAW,EAChCC,UAAU,IAAM;IACjB,IAAK,CAAEJ,aAAa,CAACK,OAAO,IAAI,CAAED,UAAU,EAAG;MAC9C;IACD;IAEAA,UAAU,CAACC,OAAO,CAACC,aAAa,CAC/BN,aAAa,CAACK,OAAO,EACrB,CAAEE,EAAE,EAAEC,CAAC,EAAEC,MAAM,EAAEC,MAAM,KAAM;MAC5B,IAAKA,MAAM,IAAIF,CAAC,EAAG;QAClBP,eAAe,CAAEU,IAAI,CAACC,KAAK,CAAEJ,CAAE,CAAC,EAAEE,MAAO,CAAC;MAC3C;IACD,CAAC,EACD,MAAM,CAAC,CACR,CAAC;EACF,CAAC,EACD,CAAEV,aAAa,EAAEC,eAAe,CACjC,CAAC;EAED,OAAO,CAAEC,eAAe,CAAE;AAC3B"}