@wordpress/components 25.14.0 → 25.15.1-next.79a6196f.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 (568) hide show
  1. package/CHANGELOG.md +51 -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-palette/index.native.js +11 -7
  17. package/build/color-palette/index.native.js.map +1 -1
  18. package/build/color-picker/color-copy-button.js +1 -1
  19. package/build/color-picker/color-copy-button.js.map +1 -1
  20. package/build/context/wordpress-component.js.map +1 -1
  21. package/build/custom-select-control-v2/index.js +11 -10
  22. package/build/custom-select-control-v2/index.js.map +1 -1
  23. package/build/date-time/date/styles.js +8 -8
  24. package/build/date-time/date/styles.js.map +1 -1
  25. package/build/dropdown-menu-v2/index.js +205 -159
  26. package/build/dropdown-menu-v2/index.js.map +1 -1
  27. package/build/dropdown-menu-v2/styles.js +86 -77
  28. package/build/dropdown-menu-v2/styles.js.map +1 -1
  29. package/build/dropdown-menu-v2/types.js.map +1 -1
  30. package/build/duotone-picker/duotone-picker.js +4 -3
  31. package/build/duotone-picker/duotone-picker.js.map +1 -1
  32. package/build/font-size-picker/index.js +4 -2
  33. package/build/font-size-picker/index.js.map +1 -1
  34. package/build/font-size-picker/index.native.js +6 -3
  35. package/build/font-size-picker/index.native.js.map +1 -1
  36. package/build/form-token-field/index.js +10 -5
  37. package/build/form-token-field/index.js.map +1 -1
  38. package/build/form-token-field/token.js +1 -0
  39. package/build/form-token-field/token.js.map +1 -1
  40. package/build/gradient-picker/index.js +3 -2
  41. package/build/gradient-picker/index.js.map +1 -1
  42. package/build/index.native.js +20 -3
  43. package/build/index.native.js.map +1 -1
  44. package/build/input-control/styles/input-control-styles.js +32 -29
  45. package/build/input-control/styles/input-control-styles.js.map +1 -1
  46. package/build/input-control/types.js.map +1 -1
  47. package/build/lock-unlock.js +18 -0
  48. package/build/lock-unlock.js.map +1 -0
  49. package/build/mobile/bottom-sheet/index.native.js +8 -0
  50. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  51. package/build/mobile/color-settings/palette.screen.native.js +8 -4
  52. package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
  53. package/build/mobile/global-styles-context/utils.native.js +26 -13
  54. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  55. package/build/mobile/image/constants.js +12 -0
  56. package/build/mobile/image/constants.js.map +1 -0
  57. package/build/mobile/image/index.native.js +26 -18
  58. package/build/mobile/image/index.native.js.map +1 -1
  59. package/build/mobile/keyboard-aware-flat-list/index.android.js +40 -8
  60. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  61. package/build/mobile/keyboard-aware-flat-list/index.ios.js +44 -68
  62. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  63. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +39 -0
  64. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  65. package/build/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -29
  66. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  67. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js +93 -0
  68. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  69. package/build/mobile/utils/get-px-from-css-unit.native.js +302 -0
  70. package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  71. package/build/modal/index.js +18 -13
  72. package/build/modal/index.js.map +1 -1
  73. package/build/navigation/menu/menu-title.js +1 -1
  74. package/build/navigation/menu/menu-title.js.map +1 -1
  75. package/build/navigator/navigator-provider/component.js +13 -15
  76. package/build/navigator/navigator-provider/component.js.map +1 -1
  77. package/build/navigator/navigator-screen/component.js +23 -63
  78. package/build/navigator/navigator-screen/component.js.map +1 -1
  79. package/build/navigator/styles.js +52 -0
  80. package/build/navigator/styles.js.map +1 -0
  81. package/build/number-control/index.js +4 -8
  82. package/build/number-control/index.js.map +1 -1
  83. package/build/number-control/types.js.map +1 -1
  84. package/build/palette-edit/index.js +15 -54
  85. package/build/palette-edit/index.js.map +1 -1
  86. package/build/private-apis.js +11 -26
  87. package/build/private-apis.js.map +1 -1
  88. package/build/private-apis.native.js +21 -0
  89. package/build/private-apis.native.js.map +1 -0
  90. package/build/radio-control/index.js +1 -0
  91. package/build/radio-control/index.js.map +1 -1
  92. package/build/range-control/index.js +1 -1
  93. package/build/range-control/index.js.map +1 -1
  94. package/build/select-control/styles/select-control-styles.js +15 -25
  95. package/build/select-control/styles/select-control-styles.js.map +1 -1
  96. package/build/slot-fill/index.js +3 -2
  97. package/build/slot-fill/index.js.map +1 -1
  98. package/build/slot-fill/types.js.map +1 -1
  99. package/build/snackbar/types.js.map +1 -1
  100. package/build/tabs/styles.js +3 -3
  101. package/build/tabs/styles.js.map +1 -1
  102. package/build/tabs/tabpanel.js +9 -7
  103. package/build/tabs/tabpanel.js.map +1 -1
  104. package/build/toggle-group-control/toggle-group-control/component.js +4 -4
  105. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  106. package/build/toggle-group-control/toggle-group-control/styles.js +29 -15
  107. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  108. package/build/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  109. package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  110. package/build/tools-panel/tools-panel/component.js +3 -1
  111. package/build/tools-panel/tools-panel/component.js.map +1 -1
  112. package/build/tools-panel/tools-panel-header/component.js +9 -8
  113. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  114. package/build/tools-panel/types.js.map +1 -1
  115. package/build/tooltip/index.js +34 -10
  116. package/build/tooltip/index.js.map +1 -1
  117. package/build/tooltip/types.js.map +1 -1
  118. package/build/truncate/hook.js +10 -4
  119. package/build/truncate/hook.js.map +1 -1
  120. package/build/truncate/types.js.map +1 -1
  121. package/build/unit-control/index.js +1 -1
  122. package/build/unit-control/index.js.map +1 -1
  123. package/build/utils/strings.js +34 -3
  124. package/build/utils/strings.js.map +1 -1
  125. package/build-module/base-control/index.js +16 -12
  126. package/build-module/base-control/index.js.map +1 -1
  127. package/build-module/border-box-control/border-box-control-linked-button/component.js +1 -1
  128. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  129. package/build-module/border-control/border-control-style-picker/component.js +1 -1
  130. package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
  131. package/build-module/box-control/index.js +1 -1
  132. package/build-module/box-control/index.js.map +1 -1
  133. package/build-module/box-control/linked-button.js +1 -1
  134. package/build-module/box-control/linked-button.js.map +1 -1
  135. package/build-module/button/index.js +1 -1
  136. package/build-module/button/index.js.map +1 -1
  137. package/build-module/color-palette/index.native.js +11 -7
  138. package/build-module/color-palette/index.native.js.map +1 -1
  139. package/build-module/color-picker/color-copy-button.js +1 -1
  140. package/build-module/color-picker/color-copy-button.js.map +1 -1
  141. package/build-module/context/wordpress-component.js.map +1 -1
  142. package/build-module/custom-select-control-v2/index.js +11 -10
  143. package/build-module/custom-select-control-v2/index.js.map +1 -1
  144. package/build-module/date-time/date/styles.js +8 -8
  145. package/build-module/date-time/date/styles.js.map +1 -1
  146. package/build-module/dropdown-menu-v2/index.js +201 -154
  147. package/build-module/dropdown-menu-v2/index.js.map +1 -1
  148. package/build-module/dropdown-menu-v2/styles.js +68 -61
  149. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  150. package/build-module/dropdown-menu-v2/types.js.map +1 -1
  151. package/build-module/duotone-picker/duotone-picker.js +4 -3
  152. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  153. package/build-module/font-size-picker/index.js +4 -2
  154. package/build-module/font-size-picker/index.js.map +1 -1
  155. package/build-module/font-size-picker/index.native.js +5 -2
  156. package/build-module/font-size-picker/index.native.js.map +1 -1
  157. package/build-module/form-token-field/index.js +10 -5
  158. package/build-module/form-token-field/index.js.map +1 -1
  159. package/build-module/form-token-field/token.js +1 -0
  160. package/build-module/form-token-field/token.js.map +1 -1
  161. package/build-module/gradient-picker/index.js +3 -2
  162. package/build-module/gradient-picker/index.js.map +1 -1
  163. package/build-module/index.native.js +6 -1
  164. package/build-module/index.native.js.map +1 -1
  165. package/build-module/input-control/styles/input-control-styles.js +31 -29
  166. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  167. package/build-module/input-control/types.js.map +1 -1
  168. package/build-module/lock-unlock.js +9 -0
  169. package/build-module/lock-unlock.js.map +1 -0
  170. package/build-module/mobile/bottom-sheet/index.native.js +9 -1
  171. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  172. package/build-module/mobile/color-settings/palette.screen.native.js +8 -4
  173. package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
  174. package/build-module/mobile/global-styles-context/utils.native.js +25 -13
  175. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  176. package/build-module/mobile/image/constants.js +5 -0
  177. package/build-module/mobile/image/constants.js.map +1 -0
  178. package/build-module/mobile/image/index.native.js +25 -16
  179. package/build-module/mobile/image/index.native.js.map +1 -1
  180. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +40 -6
  181. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  182. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +46 -68
  183. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  184. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +33 -0
  185. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  186. package/build-module/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +21 -27
  187. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  188. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js +86 -0
  189. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  190. package/build-module/mobile/utils/get-px-from-css-unit.native.js +294 -0
  191. package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  192. package/build-module/modal/index.js +18 -13
  193. package/build-module/modal/index.js.map +1 -1
  194. package/build-module/navigation/menu/menu-title.js +1 -1
  195. package/build-module/navigation/menu/menu-title.js.map +1 -1
  196. package/build-module/navigator/navigator-provider/component.js +3 -16
  197. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  198. package/build-module/navigator/navigator-screen/component.js +16 -70
  199. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  200. package/build-module/navigator/styles.js +47 -0
  201. package/build-module/navigator/styles.js.map +1 -0
  202. package/build-module/number-control/index.js +4 -8
  203. package/build-module/number-control/index.js.map +1 -1
  204. package/build-module/number-control/types.js.map +1 -1
  205. package/build-module/palette-edit/index.js +15 -51
  206. package/build-module/palette-edit/index.js.map +1 -1
  207. package/build-module/private-apis.js +10 -23
  208. package/build-module/private-apis.js.map +1 -1
  209. package/build-module/private-apis.native.js +14 -0
  210. package/build-module/private-apis.native.js.map +1 -0
  211. package/build-module/radio-control/index.js +1 -0
  212. package/build-module/radio-control/index.js.map +1 -1
  213. package/build-module/range-control/index.js +1 -1
  214. package/build-module/range-control/index.js.map +1 -1
  215. package/build-module/select-control/styles/select-control-styles.js +15 -25
  216. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  217. package/build-module/slot-fill/index.js +3 -2
  218. package/build-module/slot-fill/index.js.map +1 -1
  219. package/build-module/slot-fill/types.js.map +1 -1
  220. package/build-module/snackbar/types.js.map +1 -1
  221. package/build-module/tabs/styles.js +3 -3
  222. package/build-module/tabs/styles.js.map +1 -1
  223. package/build-module/tabs/tabpanel.js +9 -7
  224. package/build-module/tabs/tabpanel.js.map +1 -1
  225. package/build-module/toggle-group-control/toggle-group-control/component.js +4 -4
  226. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  227. package/build-module/toggle-group-control/toggle-group-control/styles.js +29 -15
  228. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  229. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  230. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  231. package/build-module/tools-panel/tools-panel/component.js +3 -1
  232. package/build-module/tools-panel/tools-panel/component.js.map +1 -1
  233. package/build-module/tools-panel/tools-panel-header/component.js +9 -8
  234. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  235. package/build-module/tools-panel/types.js.map +1 -1
  236. package/build-module/tooltip/index.js +34 -12
  237. package/build-module/tooltip/index.js.map +1 -1
  238. package/build-module/tooltip/types.js.map +1 -1
  239. package/build-module/truncate/hook.js +10 -4
  240. package/build-module/truncate/hook.js.map +1 -1
  241. package/build-module/truncate/types.js.map +1 -1
  242. package/build-module/unit-control/index.js +1 -1
  243. package/build-module/unit-control/index.js.map +1 -1
  244. package/build-module/utils/strings.js +32 -2
  245. package/build-module/utils/strings.js.map +1 -1
  246. package/build-style/style-rtl.css +29 -5
  247. package/build-style/style.css +29 -5
  248. package/build-types/base-control/index.d.ts +3 -27
  249. package/build-types/base-control/index.d.ts.map +1 -1
  250. package/build-types/base-control/stories/index.story.d.ts +4 -1
  251. package/build-types/base-control/stories/index.story.d.ts.map +1 -1
  252. package/build-types/border-box-control/border-box-control/hook.d.ts +4 -4
  253. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +6 -6
  254. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +4 -4
  255. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +4 -4
  256. package/build-types/border-box-control/stories/index.story.d.ts +1 -1
  257. package/build-types/border-control/border-control/hook.d.ts +4 -4
  258. package/build-types/border-control/border-control-dropdown/hook.d.ts +4 -4
  259. package/build-types/border-control/border-control-style-picker/hook.d.ts +4 -4
  260. package/build-types/border-control/stories/index.story.d.ts +6 -6
  261. package/build-types/box-control/stories/index.story.d.ts +42 -42
  262. package/build-types/box-control/styles/box-control-styles.d.ts +1 -1
  263. package/build-types/button/deprecated.d.ts +3 -3
  264. package/build-types/card/card/hook.d.ts +4 -4
  265. package/build-types/card/card-body/hook.d.ts +4 -4
  266. package/build-types/card/card-divider/hook.d.ts +4 -4
  267. package/build-types/card/card-footer/hook.d.ts +4 -4
  268. package/build-types/card/card-header/hook.d.ts +4 -4
  269. package/build-types/card/card-media/hook.d.ts +4 -4
  270. package/build-types/color-palette/styles.d.ts +2 -2
  271. package/build-types/color-picker/component.d.ts +2 -2
  272. package/build-types/color-picker/stories/index.story.d.ts +1 -1
  273. package/build-types/color-picker/stories/index.story.d.ts.map +1 -1
  274. package/build-types/color-picker/styles.d.ts +3 -3
  275. package/build-types/composite/test/index.d.ts.map +1 -0
  276. package/build-types/context/wordpress-component.d.ts +3 -3
  277. package/build-types/context/wordpress-component.d.ts.map +1 -1
  278. package/build-types/custom-select-control-v2/index.d.ts +3 -2
  279. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  280. package/build-types/custom-select-control-v2/stories/index.story.d.ts +4 -3
  281. package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
  282. package/build-types/date-time/date/styles.d.ts +3 -3
  283. package/build-types/date-time/date-time/styles.d.ts +1 -1
  284. package/build-types/date-time/time/styles.d.ts +4 -4
  285. package/build-types/dropdown/index.d.ts +1 -1
  286. package/build-types/dropdown/index.d.ts.map +1 -1
  287. package/build-types/dropdown/stories/index.story.d.ts +3 -3
  288. package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
  289. package/build-types/dropdown-menu/index.d.ts +1 -1
  290. package/build-types/dropdown-menu/index.d.ts.map +1 -1
  291. package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
  292. package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
  293. package/build-types/dropdown-menu-v2/index.d.ts +18 -15
  294. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
  295. package/build-types/dropdown-menu-v2/stories/index.story.d.ts +7 -2
  296. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
  297. package/build-types/dropdown-menu-v2/styles.d.ts +77 -23
  298. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
  299. package/build-types/dropdown-menu-v2/types.d.ts +89 -173
  300. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
  301. package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
  302. package/build-types/elevation/hook.d.ts +4 -4
  303. package/build-types/flex/flex/hook.d.ts +4 -4
  304. package/build-types/flex/flex-block/hook.d.ts +4 -4
  305. package/build-types/flex/flex-item/hook.d.ts +4 -4
  306. package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
  307. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  308. package/build-types/font-size-picker/index.d.ts.map +1 -1
  309. package/build-types/font-size-picker/styles.d.ts +1 -1
  310. package/build-types/form-token-field/index.d.ts.map +1 -1
  311. package/build-types/form-token-field/token.d.ts.map +1 -1
  312. package/build-types/grid/hook.d.ts +4 -4
  313. package/build-types/h-stack/hook.d.ts +4 -4
  314. package/build-types/heading/component.d.ts +1 -1
  315. package/build-types/heading/hook.d.ts +4 -4
  316. package/build-types/input-control/styles/input-control-styles.d.ts +11 -0
  317. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  318. package/build-types/input-control/types.d.ts +1 -1
  319. package/build-types/input-control/types.d.ts.map +1 -1
  320. package/build-types/item-group/item/hook.d.ts +4 -4
  321. package/build-types/item-group/item-group/hook.d.ts +4 -4
  322. package/build-types/lock-unlock.d.ts +3 -0
  323. package/build-types/lock-unlock.d.ts.map +1 -0
  324. package/build-types/menu-item/index.d.ts +1 -1
  325. package/build-types/menu-item/stories/index.story.d.ts +4 -4
  326. package/build-types/mobile/image/constants.d.ts +5 -0
  327. package/build-types/mobile/image/constants.d.ts.map +1 -0
  328. package/build-types/modal/index.d.ts.map +1 -1
  329. package/build-types/navigation/styles/navigation-styles.d.ts +3 -3
  330. package/build-types/navigator/navigator-back-button/hook.d.ts +6 -6
  331. package/build-types/navigator/navigator-button/hook.d.ts +6 -6
  332. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  333. package/build-types/navigator/navigator-screen/component.d.ts +1 -7
  334. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  335. package/build-types/navigator/styles.d.ts +9 -0
  336. package/build-types/navigator/styles.d.ts.map +1 -0
  337. package/build-types/number-control/index.d.ts +1 -1
  338. package/build-types/number-control/index.d.ts.map +1 -1
  339. package/build-types/number-control/stories/index.story.d.ts +1 -1
  340. package/build-types/number-control/types.d.ts +1 -1
  341. package/build-types/palette-edit/index.d.ts +3 -8
  342. package/build-types/palette-edit/index.d.ts.map +1 -1
  343. package/build-types/palette-edit/styles.d.ts +3 -3
  344. package/build-types/popover/index.d.ts +1 -1
  345. package/build-types/popover/index.d.ts.map +1 -1
  346. package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
  347. package/build-types/private-apis.d.ts +0 -1
  348. package/build-types/private-apis.d.ts.map +1 -1
  349. package/build-types/radio-control/index.d.ts.map +1 -1
  350. package/build-types/range-control/index.d.ts +1 -1
  351. package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
  352. package/build-types/resizable-box/index.d.ts +1 -1
  353. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  354. package/build-types/resizable-box/stories/index.story.d.ts +2 -2
  355. package/build-types/scrollable/hook.d.ts +4 -4
  356. package/build-types/search-control/index.d.ts +1 -1
  357. package/build-types/search-control/stories/index.story.d.ts +2 -2
  358. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  359. package/build-types/slot-fill/index.d.ts +1 -1
  360. package/build-types/slot-fill/index.d.ts.map +1 -1
  361. package/build-types/slot-fill/types.d.ts +4 -0
  362. package/build-types/slot-fill/types.d.ts.map +1 -1
  363. package/build-types/snackbar/index.d.ts +2 -2
  364. package/build-types/snackbar/stories/index.story.d.ts +0 -3
  365. package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
  366. package/build-types/snackbar/types.d.ts +1 -1
  367. package/build-types/snackbar/types.d.ts.map +1 -1
  368. package/build-types/spacer/hook.d.ts +4 -4
  369. package/build-types/surface/hook.d.ts +4 -4
  370. package/build-types/tabs/styles.d.ts.map +1 -1
  371. package/build-types/tabs/tabpanel.d.ts +1 -1
  372. package/build-types/tabs/tabpanel.d.ts.map +1 -1
  373. package/build-types/text/hook.d.ts +4 -4
  374. package/build-types/text-control/index.d.ts +1 -1
  375. package/build-types/textarea-control/index.d.ts +1 -1
  376. package/build-types/toggle-control/stories/index.story.d.ts +2 -2
  377. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +1 -1
  378. package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +1 -1
  379. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  380. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +2 -2
  381. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  382. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
  383. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +1 -1
  384. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  385. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  386. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
  387. package/build-types/toolbar/toolbar-button/index.d.ts +3 -3
  388. package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
  389. package/build-types/tools-panel/tools-panel/hook.d.ts +5 -4
  390. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  391. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  392. package/build-types/tools-panel/tools-panel-header/hook.d.ts +5 -4
  393. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  394. package/build-types/tools-panel/tools-panel-item/hook.d.ts +4 -4
  395. package/build-types/tools-panel/types.d.ts +9 -0
  396. package/build-types/tools-panel/types.d.ts.map +1 -1
  397. package/build-types/tooltip/index.d.ts +1 -1
  398. package/build-types/tooltip/index.d.ts.map +1 -1
  399. package/build-types/tooltip/stories/index.story.d.ts +10 -1
  400. package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
  401. package/build-types/tooltip/types.d.ts +3 -0
  402. package/build-types/tooltip/types.d.ts.map +1 -1
  403. package/build-types/truncate/hook.d.ts +5 -5
  404. package/build-types/truncate/hook.d.ts.map +1 -1
  405. package/build-types/truncate/types.d.ts +4 -0
  406. package/build-types/truncate/types.d.ts.map +1 -1
  407. package/build-types/unit-control/index.d.ts +1 -1
  408. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
  409. package/build-types/utils/strings.d.ts +14 -2
  410. package/build-types/utils/strings.d.ts.map +1 -1
  411. package/build-types/v-stack/hook.d.ts +4 -4
  412. package/build-types/v-stack/stories/index.story.d.ts +1 -1
  413. package/package.json +20 -21
  414. package/src/alignment-matrix-control/test/index.tsx +10 -16
  415. package/src/base-control/index.tsx +21 -16
  416. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
  417. package/src/border-control/border-control-style-picker/component.tsx +1 -1
  418. package/src/box-control/index.tsx +1 -1
  419. package/src/box-control/linked-button.tsx +1 -1
  420. package/src/button/README.md +32 -6
  421. package/src/button/index.tsx +1 -1
  422. package/src/button-group/README.md +0 -6
  423. package/src/card/card/README.md +1 -1
  424. package/src/checkbox-control/README.md +1 -9
  425. package/src/color-palette/index.native.js +18 -7
  426. package/src/color-picker/color-copy-button.tsx +1 -1
  427. package/src/combobox-control/README.md +0 -6
  428. package/src/composite/test/index.tsx +576 -0
  429. package/src/context/wordpress-component.ts +11 -6
  430. package/src/custom-select-control/README.md +0 -6
  431. package/src/custom-select-control-v2/index.tsx +13 -12
  432. package/src/date-time/date/styles.ts +3 -3
  433. package/src/dropdown-menu/README.md +0 -5
  434. package/src/dropdown-menu-v2/README.md +75 -136
  435. package/src/dropdown-menu-v2/index.tsx +321 -231
  436. package/src/dropdown-menu-v2/stories/index.story.tsx +522 -126
  437. package/src/dropdown-menu-v2/styles.ts +226 -151
  438. package/src/dropdown-menu-v2/test/index.tsx +480 -188
  439. package/src/dropdown-menu-v2/types.ts +98 -184
  440. package/src/duotone-picker/duotone-picker.tsx +7 -3
  441. package/src/font-size-picker/index.native.js +8 -2
  442. package/src/font-size-picker/index.tsx +4 -2
  443. package/src/form-toggle/README.md +0 -6
  444. package/src/form-token-field/index.tsx +11 -7
  445. package/src/form-token-field/test/index.tsx +97 -0
  446. package/src/form-token-field/token.tsx +1 -0
  447. package/src/gradient-picker/index.tsx +2 -2
  448. package/src/index.native.js +6 -1
  449. package/src/input-control/styles/input-control-styles.tsx +10 -8
  450. package/src/input-control/types.ts +1 -1
  451. package/src/lock-unlock.js +10 -0
  452. package/src/menu-group/README.md +0 -8
  453. package/src/menu-items-choice/README.md +0 -7
  454. package/src/mobile/bottom-sheet/index.native.js +15 -1
  455. package/src/mobile/color-settings/palette.screen.native.js +7 -5
  456. package/src/mobile/global-styles-context/test/fixtures/theme.native.js +0 -20
  457. package/src/mobile/global-styles-context/utils.native.js +28 -19
  458. package/src/mobile/image/constants.js +1 -0
  459. package/src/mobile/image/index.native.js +55 -18
  460. package/src/mobile/image/style.native.scss +35 -9
  461. package/src/mobile/keyboard-aware-flat-list/index.android.js +50 -5
  462. package/src/mobile/keyboard-aware-flat-list/index.ios.js +65 -91
  463. package/src/mobile/keyboard-aware-flat-list/test/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +27 -25
  464. package/src/mobile/keyboard-aware-flat-list/test/use-scroll.native.js +71 -0
  465. package/src/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +41 -0
  466. package/src/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -27
  467. package/src/mobile/keyboard-aware-flat-list/use-scroll.native.js +100 -0
  468. package/src/mobile/utils/get-px-from-css-unit.native.js +329 -0
  469. package/src/mobile/utils/test/get-px-from-css-unit.native.js +172 -0
  470. package/src/modal/README.md +0 -6
  471. package/src/modal/index.tsx +18 -16
  472. package/src/modal/test/index.tsx +90 -1
  473. package/src/navigation/menu/menu-title.tsx +1 -1
  474. package/src/navigator/navigator-provider/component.tsx +3 -4
  475. package/src/navigator/navigator-screen/component.tsx +15 -93
  476. package/src/navigator/styles.ts +71 -0
  477. package/src/navigator/test/index.tsx +0 -64
  478. package/src/notice/README.md +0 -6
  479. package/src/number-control/README.md +2 -2
  480. package/src/number-control/index.tsx +4 -8
  481. package/src/number-control/types.ts +1 -1
  482. package/src/palette-edit/index.tsx +15 -58
  483. package/src/palette-edit/test/index.tsx +1 -75
  484. package/src/panel/README.md +0 -6
  485. package/src/private-apis.native.js +13 -0
  486. package/src/private-apis.ts +12 -37
  487. package/src/radio-control/README.md +0 -6
  488. package/src/radio-control/index.tsx +4 -1
  489. package/src/radio-control/style.scss +29 -2
  490. package/src/radio-group/README.md +0 -6
  491. package/src/range-control/README.md +1 -9
  492. package/src/range-control/index.tsx +1 -1
  493. package/src/search-control/README.md +0 -6
  494. package/src/select-control/README.md +0 -6
  495. package/src/select-control/styles/select-control-styles.ts +10 -28
  496. package/src/slot-fill/index.tsx +5 -2
  497. package/src/slot-fill/types.ts +5 -0
  498. package/src/snackbar/README.md +0 -6
  499. package/src/snackbar/stories/index.story.tsx +7 -5
  500. package/src/snackbar/style.scss +4 -3
  501. package/src/snackbar/types.ts +2 -1
  502. package/src/spacer/README.md +0 -2
  503. package/src/tab-panel/README.md +0 -5
  504. package/src/tab-panel/test/index.tsx +39 -56
  505. package/src/tabs/styles.ts +7 -1
  506. package/src/tabs/tabpanel.tsx +7 -6
  507. package/src/tabs/test/index.tsx +56 -0
  508. package/src/text-control/README.md +0 -6
  509. package/src/textarea-control/README.md +0 -6
  510. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +12 -16
  511. package/src/toggle-group-control/test/index.tsx +58 -45
  512. package/src/toggle-group-control/toggle-group-control/component.tsx +5 -4
  513. package/src/toggle-group-control/toggle-group-control/styles.ts +13 -19
  514. package/src/toggle-group-control/toggle-group-control-option/README.md +1 -1
  515. package/src/toggle-group-control/toggle-group-control-option-base/README.md +1 -1
  516. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +3 -2
  517. package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
  518. package/src/toolbar/toolbar/README.md +0 -6
  519. package/src/tools-panel/test/index.tsx +12 -20
  520. package/src/tools-panel/tools-panel/README.md +7 -0
  521. package/src/tools-panel/tools-panel/component.tsx +2 -0
  522. package/src/tools-panel/tools-panel-header/README.md +7 -0
  523. package/src/tools-panel/tools-panel-header/component.tsx +20 -13
  524. package/src/tools-panel/types.ts +9 -0
  525. package/src/tooltip/README.md +4 -0
  526. package/src/tooltip/index.tsx +48 -10
  527. package/src/tooltip/stories/index.story.tsx +18 -1
  528. package/src/tooltip/test/index.tsx +404 -254
  529. package/src/tooltip/types.ts +4 -0
  530. package/src/tree-grid/README.md +0 -4
  531. package/src/truncate/README.md +8 -0
  532. package/src/truncate/hook.ts +17 -10
  533. package/src/truncate/test/index.tsx +54 -27
  534. package/src/truncate/types.ts +4 -0
  535. package/src/unit-control/index.tsx +1 -1
  536. package/src/utils/strings.ts +30 -2
  537. package/src/utils/test/strings.js +96 -1
  538. package/tsconfig.tsbuildinfo +1 -1
  539. package/build/dropdown-menu-v2-ariakit/index.js +0 -256
  540. package/build/dropdown-menu-v2-ariakit/index.js.map +0 -1
  541. package/build/dropdown-menu-v2-ariakit/styles.js +0 -180
  542. package/build/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  543. package/build/dropdown-menu-v2-ariakit/types.js +0 -6
  544. package/build/dropdown-menu-v2-ariakit/types.js.map +0 -1
  545. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  546. package/build-module/dropdown-menu-v2-ariakit/index.js +0 -237
  547. package/build-module/dropdown-menu-v2-ariakit/index.js.map +0 -1
  548. package/build-module/dropdown-menu-v2-ariakit/styles.js +0 -165
  549. package/build-module/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  550. package/build-module/dropdown-menu-v2-ariakit/types.js +0 -2
  551. package/build-module/dropdown-menu-v2-ariakit/types.js.map +0 -1
  552. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  553. package/build-types/dropdown-menu-v2-ariakit/index.d.ts +0 -20
  554. package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +0 -1
  555. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +0 -16
  556. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +0 -1
  557. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +0 -96
  558. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +0 -1
  559. package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +0 -1
  560. package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -168
  561. package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +0 -1
  562. package/src/dropdown-menu-v2-ariakit/README.md +0 -331
  563. package/src/dropdown-menu-v2-ariakit/index.tsx +0 -383
  564. package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +0 -617
  565. package/src/dropdown-menu-v2-ariakit/styles.ts +0 -345
  566. package/src/dropdown-menu-v2-ariakit/test/index.tsx +0 -1108
  567. package/src/dropdown-menu-v2-ariakit/types.ts +0 -179
  568. /package/build-types/{dropdown-menu-v2-ariakit → composite}/test/index.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["camelCase","Dimensions","colord","getPxFromCssUnit","useSettings","useMultipleOriginColorsAndGradients","SETTINGS_DEFAULTS","usePreferredColorSchemeStyle","useGlobalStyles","BLOCK_STYLE_ATTRIBUTES","BLOCK_STYLE_ATTRIBUTES_MAPPING","textColor","text","background","link","placeholder","PADDING","UNKNOWN_VALUE","DEFAULT_FONT_SIZE","getBlockPaddings","mergedStyle","wrapperPropsStyle","blockStyleAttributes","blockColors","blockPaddings","padding","backgroundColor","undefined","getBlockColors","defaultColors","blockName","baseGlobalStyles","blockStyles","customBlockStyles","style","color","blockGlobalStyles","blocks","Object","entries","forEach","key","value","styleKey","_customBlockStyles$ke","styles","elements","linkColor","isCustomColor","startsWith","mappedColor","values","find","slug","getBlockTypography","fontSizes","typographyStyles","typography","parsedFontSizes","fontSize","lineHeight","parseInt","mappedFontSize","size","getValueFromObjectPath","object","path","fieldName","parseStylesVariables","mappedValues","customValues","stylesBase","variables","variable","regex","RegExp","varRegex","fontSizeRegex","replace","_$1","$2","split","mappedPresetValue","_mappedPresetValue$va","matchedValue","customValuesData","JSON","parse","colorKey","length","reduce","prev","curr","slice","width","height","get","parsedFontSize","getMappedValues","features","palette","colors","theme","custom","default","normalizeFontSizes","normalizedFontSizes","dimensions","map","fontSizeObject","sizePx","useMobileGlobalStylesColors","type","colorGradientSettings","availableThemeColors","origin","concat","defaultPaletteSetting","defaultPaletteValue","defaultPalette","getColorsAndGradients","defaultEditorColors","defaultEditorGradients","rawFeatures","__experimentalGlobalStylesBaseStyles","__experimentalFeatures","gradients","defaultGradients","getGlobalStyles","rawStyles","_features$color$text","_features$color$backg","_features$color$defau","_features$color$defau2","stringify","globalStyles","customLineHeight","spacing","useEditorColorScheme","baseStyle","darkStyle","deviceColorScheme","editorColors","baseColors","editorBackgroundColor","isBackgroundColorDefined","isEditorBackgroundDark","isDark"],"sources":["@wordpress/components/src/mobile/global-styles-context/utils.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\nimport { Dimensions } from 'react-native';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetPxFromCssUnit,\n\tuseSettings,\n\tuseMultipleOriginColorsAndGradients,\n\tSETTINGS_DEFAULTS,\n} from '@wordpress/block-editor';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useGlobalStyles } from './index.native';\n\nexport const BLOCK_STYLE_ATTRIBUTES = [\n\t'textColor',\n\t'backgroundColor',\n\t'style',\n\t'color',\n\t'fontSize',\n];\n\n// Mapping style properties name to native.\nconst BLOCK_STYLE_ATTRIBUTES_MAPPING = {\n\ttextColor: 'color',\n\ttext: 'color',\n\tbackground: 'backgroundColor',\n\tlink: 'linkColor',\n\tplaceholder: 'placeholderColor',\n};\n\nconst PADDING = 12; // $solid-border-space\nconst UNKNOWN_VALUE = 'undefined';\nconst DEFAULT_FONT_SIZE = 16;\n\nexport function getBlockPaddings(\n\tmergedStyle,\n\twrapperPropsStyle,\n\tblockStyleAttributes,\n\tblockColors\n) {\n\tconst blockPaddings = {};\n\n\tif (\n\t\t! mergedStyle.padding &&\n\t\t( wrapperPropsStyle?.backgroundColor ||\n\t\t\tblockStyleAttributes?.backgroundColor ||\n\t\t\tblockColors?.backgroundColor )\n\t) {\n\t\tblockPaddings.padding = PADDING;\n\t\treturn blockPaddings;\n\t}\n\n\t// Prevent adding extra paddings to inner blocks without background colors.\n\tif (\n\t\tmergedStyle?.padding &&\n\t\t! wrapperPropsStyle?.backgroundColor &&\n\t\t! blockStyleAttributes?.backgroundColor &&\n\t\t! blockColors?.backgroundColor\n\t) {\n\t\tblockPaddings.padding = undefined;\n\t}\n\n\treturn blockPaddings;\n}\n\nexport function getBlockColors(\n\tblockStyleAttributes,\n\tdefaultColors,\n\tblockName,\n\tbaseGlobalStyles\n) {\n\tconst blockStyles = {};\n\tconst customBlockStyles = blockStyleAttributes?.style?.color || {};\n\tconst blockGlobalStyles = baseGlobalStyles?.blocks?.[ blockName ];\n\n\t// Global styles colors.\n\tif ( blockGlobalStyles?.color ) {\n\t\tObject.entries( blockGlobalStyles.color ).forEach(\n\t\t\t( [ key, value ] ) => {\n\t\t\t\tconst styleKey = BLOCK_STYLE_ATTRIBUTES_MAPPING[ key ];\n\n\t\t\t\tif ( styleKey && value !== UNKNOWN_VALUE ) {\n\t\t\t\t\tconst color = customBlockStyles[ key ] ?? value;\n\t\t\t\t\tblockStyles[ styleKey ] = color;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t} else if ( baseGlobalStyles?.styles?.color?.text ) {\n\t\tblockStyles[ BLOCK_STYLE_ATTRIBUTES_MAPPING.text ] =\n\t\t\tbaseGlobalStyles?.styles?.color?.text;\n\t}\n\n\t// Global styles elements.\n\tif ( blockGlobalStyles?.elements ) {\n\t\tconst linkColor = blockGlobalStyles.elements?.link?.color?.text;\n\t\tconst styleKey = BLOCK_STYLE_ATTRIBUTES_MAPPING.link;\n\n\t\tif ( styleKey && linkColor && linkColor !== UNKNOWN_VALUE ) {\n\t\t\tblockStyles[ styleKey ] = linkColor;\n\t\t}\n\t}\n\n\t// Custom colors.\n\tObject.entries( blockStyleAttributes ).forEach( ( [ key, value ] ) => {\n\t\tconst isCustomColor = value?.startsWith?.( '#' );\n\t\tlet styleKey = key;\n\n\t\tif ( BLOCK_STYLE_ATTRIBUTES_MAPPING[ styleKey ] ) {\n\t\t\tstyleKey = BLOCK_STYLE_ATTRIBUTES_MAPPING[ styleKey ];\n\t\t}\n\n\t\tif ( ! isCustomColor ) {\n\t\t\tconst mappedColor = Object.values( defaultColors ?? {} ).find(\n\t\t\t\t( { slug } ) => slug === value\n\t\t\t);\n\n\t\t\tif ( mappedColor ) {\n\t\t\t\tblockStyles[ styleKey ] = mappedColor.color;\n\t\t\t}\n\t\t} else {\n\t\t\tblockStyles[ styleKey ] = value;\n\t\t}\n\t} );\n\n\t// Color placeholder.\n\tif ( blockStyles?.color ) {\n\t\tblockStyles[ BLOCK_STYLE_ATTRIBUTES_MAPPING.placeholder ] =\n\t\t\tblockStyles.color;\n\t}\n\n\treturn blockStyles;\n}\n\nexport function getBlockTypography(\n\tblockStyleAttributes,\n\tfontSizes,\n\tblockName,\n\tbaseGlobalStyles\n) {\n\tconst typographyStyles = {};\n\tconst customBlockStyles = blockStyleAttributes?.style?.typography || {};\n\tconst blockGlobalStyles = baseGlobalStyles?.blocks?.[ blockName ];\n\tconst parsedFontSizes = Object.values( fontSizes ?? {} );\n\n\t// Global styles.\n\tif ( blockGlobalStyles?.typography ) {\n\t\tconst fontSize = blockGlobalStyles?.typography?.fontSize;\n\t\tconst lineHeight = blockGlobalStyles?.typography?.lineHeight;\n\n\t\tif ( fontSize ) {\n\t\t\tif ( parseInt( fontSize, 10 ) ) {\n\t\t\t\ttypographyStyles.fontSize = fontSize;\n\t\t\t} else {\n\t\t\t\tconst mappedFontSize = parsedFontSizes.find(\n\t\t\t\t\t( { slug } ) => slug === fontSize\n\t\t\t\t);\n\n\t\t\t\tif ( mappedFontSize ) {\n\t\t\t\t\ttypographyStyles.fontSize = mappedFontSize?.size;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( lineHeight ) {\n\t\t\ttypographyStyles.lineHeight = lineHeight;\n\t\t}\n\t}\n\n\tif ( blockStyleAttributes?.fontSize && baseGlobalStyles ) {\n\t\tconst mappedFontSize = parsedFontSizes.find(\n\t\t\t( { slug } ) => slug === blockStyleAttributes?.fontSize\n\t\t);\n\n\t\tif ( mappedFontSize ) {\n\t\t\ttypographyStyles.fontSize = mappedFontSize?.size;\n\t\t}\n\t}\n\n\t// Custom styles.\n\tif ( customBlockStyles?.fontSize ) {\n\t\ttypographyStyles.fontSize = customBlockStyles?.fontSize;\n\t}\n\n\tif ( customBlockStyles?.lineHeight ) {\n\t\ttypographyStyles.lineHeight = customBlockStyles?.lineHeight;\n\t}\n\n\treturn typographyStyles;\n}\n\n/**\n * Return a value from a certain path of the object.\n * Path is specified as an array of properties, like: [ 'parent', 'child' ].\n *\n * @param {Object} object Input object.\n * @param {Array} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\nexport function parseStylesVariables( styles, mappedValues, customValues ) {\n\tlet stylesBase = styles;\n\tconst variables = [ 'preset', 'custom', 'var', 'fontSize' ];\n\n\tif ( ! stylesBase ) {\n\t\treturn styles;\n\t}\n\n\tvariables.forEach( ( variable ) => {\n\t\t// Examples\n\t\t// var(--wp--preset--color--gray)\n\t\t// var(--wp--custom--body--typography--font-family)\n\t\t// var:preset|color|custom-color-2\n\t\tconst regex = new RegExp( `var\\\\(--wp--${ variable }--(.*?)\\\\)`, 'g' );\n\t\tconst varRegex = /\\\"var:preset\\|color\\|(.*?)\\\"/gm;\n\t\tconst fontSizeRegex = /\"fontSize\":\"(.*?)\"/gm;\n\n\t\tif ( variable === 'preset' ) {\n\t\t\tstylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {\n\t\t\t\tconst path = $2.split( '--' );\n\t\t\t\tconst mappedPresetValue = mappedValues[ path[ 0 ] ];\n\t\t\t\tif ( mappedPresetValue && mappedPresetValue.slug ) {\n\t\t\t\t\tconst matchedValue = Object.values(\n\t\t\t\t\t\tmappedPresetValue.values ?? {}\n\t\t\t\t\t).find( ( { slug } ) => slug === path[ 1 ] );\n\t\t\t\t\treturn matchedValue?.[ mappedPresetValue.slug ];\n\t\t\t\t}\n\t\t\t\treturn UNKNOWN_VALUE;\n\t\t\t} );\n\t\t}\n\t\tif ( variable === 'custom' ) {\n\t\t\tconst customValuesData = customValues ?? JSON.parse( stylesBase );\n\t\t\tstylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {\n\t\t\t\tconst path = $2.split( '--' );\n\n\t\t\t\t// Supports cases for variables like var(--wp--custom--color--background)\n\t\t\t\tif ( path[ 0 ] === 'color' ) {\n\t\t\t\t\tconst colorKey = path[ path.length - 1 ];\n\t\t\t\t\tif ( mappedValues?.color ) {\n\t\t\t\t\t\tconst matchedValue = mappedValues.color?.values?.find(\n\t\t\t\t\t\t\t( { slug } ) => slug === colorKey\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( matchedValue ) {\n\t\t\t\t\t\t\treturn `${ matchedValue?.color }`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tpath.reduce(\n\t\t\t\t\t\t( prev, curr ) => prev && prev[ curr ],\n\t\t\t\t\t\tcustomValuesData\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn getValueFromObjectPath( customValuesData, path );\n\t\t\t\t}\n\n\t\t\t\t// Check for camelcase properties.\n\t\t\t\treturn getValueFromObjectPath( customValuesData, [\n\t\t\t\t\t...path.slice( 0, path.length - 1 ),\n\t\t\t\t\tcamelCase( path[ path.length - 1 ] ),\n\t\t\t\t] );\n\t\t\t} );\n\t\t}\n\n\t\tif ( variable === 'var' ) {\n\t\t\tstylesBase = stylesBase.replace( varRegex, ( _$1, $2 ) => {\n\t\t\t\tif ( mappedValues?.color ) {\n\t\t\t\t\tconst matchedValue = mappedValues.color?.values?.find(\n\t\t\t\t\t\t( { slug } ) => slug === $2\n\t\t\t\t\t);\n\t\t\t\t\treturn `\"${ matchedValue?.color }\"`;\n\t\t\t\t}\n\t\t\t\treturn UNKNOWN_VALUE;\n\t\t\t} );\n\t\t}\n\n\t\tif ( variable === 'fontSize' ) {\n\t\t\tconst { width, height } = Dimensions.get( 'window' );\n\n\t\t\tstylesBase = stylesBase.replace( fontSizeRegex, ( _$1, $2 ) => {\n\t\t\t\tconst parsedFontSize =\n\t\t\t\t\tgetPxFromCssUnit( $2, {\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\theight,\n\t\t\t\t\t\tfontSize: DEFAULT_FONT_SIZE,\n\t\t\t\t\t} ) || `${ DEFAULT_FONT_SIZE }px`;\n\n\t\t\t\treturn `\"fontSize\":\"${ parsedFontSize }\"`;\n\t\t\t} );\n\t\t}\n\t} );\n\n\treturn JSON.parse( stylesBase );\n}\n\nexport function getMappedValues( features, palette ) {\n\tconst typography = features?.typography;\n\tconst colors = [\n\t\t...( palette?.theme || [] ),\n\t\t...( palette?.custom || [] ),\n\t\t...( palette?.default || [] ),\n\t];\n\n\tconst fontSizes = {\n\t\t...typography?.fontSizes?.theme,\n\t\t...typography?.fontSizes?.custom,\n\t};\n\tconst mappedValues = {\n\t\tcolor: {\n\t\t\tvalues: colors,\n\t\t\tslug: 'color',\n\t\t},\n\t\t'font-size': {\n\t\t\tvalues: fontSizes,\n\t\t\tslug: 'size',\n\t\t},\n\t};\n\treturn mappedValues;\n}\n\n/**\n * Returns the normalized fontSizes to include the sizePx value for each of the different sizes.\n *\n * @param {Object} fontSizes found in global styles.\n * @return {Object} normalized sizes.\n */\nfunction normalizeFontSizes( fontSizes ) {\n\t// Adds normalized PX values for each of the different keys.\n\tif ( ! fontSizes ) {\n\t\treturn fontSizes;\n\t}\n\tconst normalizedFontSizes = {};\n\tconst dimensions = Dimensions.get( 'window' );\n\n\t[ 'default', 'theme', 'custom' ].forEach( ( key ) => {\n\t\tif ( fontSizes[ key ] ) {\n\t\t\tnormalizedFontSizes[ key ] = fontSizes[ key ]?.map(\n\t\t\t\t( fontSizeObject ) => {\n\t\t\t\t\tfontSizeObject.sizePx = getPxFromCssUnit(\n\t\t\t\t\t\tfontSizeObject.size,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twidth: dimensions.width,\n\t\t\t\t\t\t\theight: dimensions.height,\n\t\t\t\t\t\t\tfontSize: DEFAULT_FONT_SIZE,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\treturn fontSizeObject;\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn normalizedFontSizes;\n}\n\nexport function useMobileGlobalStylesColors( type = 'colors' ) {\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst availableThemeColors = colorGradientSettings?.[ type ]?.reduce(\n\t\t( colors, origin ) => colors.concat( origin?.[ type ] ),\n\t\t[]\n\t);\n\t// Default editor colors/gradients if it's not a block-based theme.\n\tconst defaultPaletteSetting =\n\t\ttype === 'colors' ? 'color.palette' : 'color.gradients';\n\tconst [ defaultPaletteValue ] = useSettings( defaultPaletteSetting );\n\t// In edge cases, the default palette might be undefined. To avoid\n\t// exceptions across the editor in that case, we explicitly return\n\t// the default editor colors.\n\tconst defaultPalette = defaultPaletteValue ?? SETTINGS_DEFAULTS.colors;\n\n\treturn availableThemeColors.length >= 1\n\t\t? availableThemeColors\n\t\t: defaultPalette;\n}\n\nexport function getColorsAndGradients(\n\tdefaultEditorColors = [],\n\tdefaultEditorGradients = [],\n\trawFeatures\n) {\n\tconst features = rawFeatures ? JSON.parse( rawFeatures ) : {};\n\n\treturn {\n\t\t__experimentalGlobalStylesBaseStyles: null,\n\t\t__experimentalFeatures: {\n\t\t\tcolor: {\n\t\t\t\t...( ! features?.color\n\t\t\t\t\t? {\n\t\t\t\t\t\t\ttext: true,\n\t\t\t\t\t\t\tbackground: true,\n\t\t\t\t\t\t\tpalette: {\n\t\t\t\t\t\t\t\tdefault: defaultEditorColors,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgradients: {\n\t\t\t\t\t\t\t\tdefault: defaultEditorGradients,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }\n\t\t\t\t\t: features?.color ),\n\t\t\t\tdefaultPalette: defaultEditorColors?.length > 0,\n\t\t\t\tdefaultGradients: defaultEditorGradients?.length > 0,\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport function getGlobalStyles( rawStyles, rawFeatures ) {\n\tconst features = rawFeatures ? JSON.parse( rawFeatures ) : {};\n\tconst mappedValues = getMappedValues( features, features?.color?.palette );\n\tconst colors = parseStylesVariables(\n\t\tJSON.stringify( features?.color ),\n\t\tmappedValues\n\t);\n\tconst gradients = parseStylesVariables(\n\t\tJSON.stringify( features?.color?.gradients ),\n\t\tmappedValues\n\t);\n\tconst customValues = parseStylesVariables(\n\t\tJSON.stringify( features?.custom ),\n\t\tmappedValues\n\t);\n\tconst globalStyles = parseStylesVariables(\n\t\trawStyles,\n\t\tmappedValues,\n\t\tcustomValues\n\t);\n\n\tconst fontSizes = normalizeFontSizes( features?.typography?.fontSizes );\n\n\treturn {\n\t\t__experimentalFeatures: {\n\t\t\tcolor: {\n\t\t\t\tpalette: colors?.palette,\n\t\t\t\tgradients,\n\t\t\t\ttext: features?.color?.text ?? true,\n\t\t\t\tbackground: features?.color?.background ?? true,\n\t\t\t\tdefaultPalette: features?.color?.defaultPalette ?? true,\n\t\t\t\tdefaultGradients: features?.color?.defaultGradients ?? true,\n\t\t\t},\n\t\t\ttypography: {\n\t\t\t\tfontSizes,\n\t\t\t\tcustomLineHeight: features?.custom?.[ 'line-height' ],\n\t\t\t},\n\t\t\tspacing: features?.spacing,\n\t\t},\n\t\t__experimentalGlobalStylesBaseStyles: globalStyles,\n\t};\n}\n\n/**\n * Determine and apply appropriate color scheme based on global styles or device's light/dark mode.\n *\n * The function first attempts to retrieve the editor's background color from global styles.\n * If the detected background color is light, light styles are applied, and dark styles otherwise.\n * If no custom background color is defined, styles are applied using the device's dark/light setting.\n *\n * @param {Object} baseStyle - An object representing the base (light theme) styles for the editor.\n * @param {Object} darkStyle - An object representing the additional styles to apply when the editor is in dark mode.\n *\n * @return {Object} - The combined style object that should be applied to the editor.\n */\nexport const useEditorColorScheme = ( baseStyle, darkStyle ) => {\n\tconst globalStyles = useGlobalStyles();\n\n\tconst deviceColorScheme = usePreferredColorSchemeStyle(\n\t\tbaseStyle,\n\t\tdarkStyle\n\t);\n\n\tconst editorColors = globalStyles?.baseColors?.color;\n\tconst editorBackgroundColor = editorColors?.background;\n\n\tconst isBackgroundColorDefined =\n\t\ttypeof editorBackgroundColor !== 'undefined' &&\n\t\teditorBackgroundColor !== 'undefined';\n\n\tif ( isBackgroundColorDefined ) {\n\t\tconst isEditorBackgroundDark = colord( editorBackgroundColor ).isDark();\n\t\treturn isEditorBackgroundDark\n\t\t\t? { ...baseStyle, ...darkStyle }\n\t\t\t: baseStyle;\n\t}\n\n\treturn deviceColorScheme;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA,SACCC,gBAAgB,EAChBC,WAAW,EACXC,mCAAmC,EACnCC,iBAAiB,QACX,yBAAyB;AAChC,SAASC,4BAA4B,QAAQ,oBAAoB;;AAEjE;AACA;AACA;AACA,SAASC,eAAe,QAAQ,gBAAgB;AAEhD,OAAO,MAAMC,sBAAsB,GAAG,CACrC,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,UAAU,CACV;;AAED;AACA,MAAMC,8BAA8B,GAAG;EACtCC,SAAS,EAAE,OAAO;EAClBC,IAAI,EAAE,OAAO;EACbC,UAAU,EAAE,iBAAiB;EAC7BC,IAAI,EAAE,WAAW;EACjBC,WAAW,EAAE;AACd,CAAC;AAED,MAAMC,OAAO,GAAG,EAAE,CAAC,CAAC;AACpB,MAAMC,aAAa,GAAG,WAAW;AACjC,MAAMC,iBAAiB,GAAG,EAAE;AAE5B,OAAO,SAASC,gBAAgBA,CAC/BC,WAAW,EACXC,iBAAiB,EACjBC,oBAAoB,EACpBC,WAAW,EACV;EACD,MAAMC,aAAa,GAAG,CAAC,CAAC;EAExB,IACC,CAAEJ,WAAW,CAACK,OAAO,KACnBJ,iBAAiB,EAAEK,eAAe,IACnCJ,oBAAoB,EAAEI,eAAe,IACrCH,WAAW,EAAEG,eAAe,CAAE,EAC9B;IACDF,aAAa,CAACC,OAAO,GAAGT,OAAO;IAC/B,OAAO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ACG,MAAM,CAAC,CAAC;IACvE,OAAOD,sBAAsB,GAC1B;MAAE,GAAGP,SAAS;MAAE,GAAGC;IAAU,CAAC,GAC9BD,SAAS;EACb;EAEA,OAAOE,iBAAiB;AACzB,CAAC"}
1
+ {"version":3,"names":["camelCase","Dimensions","colord","useSettings","useMultipleOriginColorsAndGradients","SETTINGS_DEFAULTS","usePreferredColorSchemeStyle","default","getPxFromCssUnit","useGlobalStyles","BLOCK_STYLE_ATTRIBUTES","BLOCK_STYLE_ATTRIBUTES_MAPPING","textColor","text","background","link","placeholder","PADDING","UNKNOWN_VALUE","DEFAULT_FONT_SIZE","getBlockPaddings","mergedStyle","wrapperPropsStyle","blockStyleAttributes","blockColors","blockPaddings","padding","backgroundColor","undefined","getBlockColors","defaultColors","blockName","baseGlobalStyles","blockStyles","customBlockStyles","style","color","blockGlobalStyles","blocks","Object","entries","forEach","key","value","styleKey","_customBlockStyles$ke","styles","elements","linkColor","isCustomColor","startsWith","mappedColor","values","find","slug","getBlockTypography","fontSizes","typographyStyles","typography","parsedFontSizes","fontSize","lineHeight","parseInt","mappedFontSize","size","getValueFromObjectPath","object","path","fieldName","parseStylesVariables","mappedValues","customValues","stylesBase","variables","variable","regex","RegExp","varRegex","fontSizeRegex","replace","_$1","$2","split","mappedPresetValue","_mappedPresetValue$va","matchedValue","customValuesData","JSON","parse","colorKey","length","reduce","prev","curr","slice","width","height","get","parsedFontSize","getMappedValues","features","palette","colors","theme","custom","normalizeFontSizes","dimensions","normalizedFontSizes","keysToProcess","push","map","fontSizeObject","sizePx","useMobileGlobalStylesColors","type","colorGradientSettings","availableThemeColors","origin","concat","defaultPaletteSetting","defaultPaletteValue","defaultPalette","getColorsAndGradients","defaultEditorColors","defaultEditorGradients","rawFeatures","__experimentalGlobalStylesBaseStyles","__experimentalFeatures","gradients","defaultGradients","getGlobalStyles","rawStyles","_features$color$text","_features$color$backg","_features$color$defau","_features$color$defau2","stringify","globalStyles","customLineHeight","spacing","useEditorColorScheme","baseStyle","darkStyle","deviceColorScheme","editorColors","baseColors","editorBackgroundColor","isBackgroundColorDefined","isEditorBackgroundDark","isDark"],"sources":["@wordpress/components/src/mobile/global-styles-context/utils.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\nimport { Dimensions } from 'react-native';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseSettings,\n\tuseMultipleOriginColorsAndGradients,\n\tSETTINGS_DEFAULTS,\n} from '@wordpress/block-editor';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { default as getPxFromCssUnit } from '../utils/get-px-from-css-unit';\nimport { useGlobalStyles } from './index.native';\n\nexport const BLOCK_STYLE_ATTRIBUTES = [\n\t'textColor',\n\t'backgroundColor',\n\t'style',\n\t'color',\n\t'fontSize',\n];\n\n// Mapping style properties name to native.\nconst BLOCK_STYLE_ATTRIBUTES_MAPPING = {\n\ttextColor: 'color',\n\ttext: 'color',\n\tbackground: 'backgroundColor',\n\tlink: 'linkColor',\n\tplaceholder: 'placeholderColor',\n};\n\nconst PADDING = 12; // $solid-border-space\nconst UNKNOWN_VALUE = 'undefined';\nconst DEFAULT_FONT_SIZE = 16;\n\nexport function getBlockPaddings(\n\tmergedStyle,\n\twrapperPropsStyle,\n\tblockStyleAttributes,\n\tblockColors\n) {\n\tconst blockPaddings = {};\n\n\tif (\n\t\t! mergedStyle.padding &&\n\t\t( wrapperPropsStyle?.backgroundColor ||\n\t\t\tblockStyleAttributes?.backgroundColor ||\n\t\t\tblockColors?.backgroundColor )\n\t) {\n\t\tblockPaddings.padding = PADDING;\n\t\treturn blockPaddings;\n\t}\n\n\t// Prevent adding extra paddings to inner blocks without background colors.\n\tif (\n\t\tmergedStyle?.padding &&\n\t\t! wrapperPropsStyle?.backgroundColor &&\n\t\t! blockStyleAttributes?.backgroundColor &&\n\t\t! blockColors?.backgroundColor\n\t) {\n\t\tblockPaddings.padding = undefined;\n\t}\n\n\treturn blockPaddings;\n}\n\nexport function getBlockColors(\n\tblockStyleAttributes,\n\tdefaultColors,\n\tblockName,\n\tbaseGlobalStyles\n) {\n\tconst blockStyles = {};\n\tconst customBlockStyles = blockStyleAttributes?.style?.color || {};\n\tconst blockGlobalStyles = baseGlobalStyles?.blocks?.[ blockName ];\n\n\t// Global styles colors.\n\tif ( blockGlobalStyles?.color ) {\n\t\tObject.entries( blockGlobalStyles.color ).forEach(\n\t\t\t( [ key, value ] ) => {\n\t\t\t\tconst styleKey = BLOCK_STYLE_ATTRIBUTES_MAPPING[ key ];\n\n\t\t\t\tif ( styleKey && value !== UNKNOWN_VALUE ) {\n\t\t\t\t\tconst color = customBlockStyles[ key ] ?? value;\n\t\t\t\t\tblockStyles[ styleKey ] = color;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t} else if ( baseGlobalStyles?.styles?.color?.text ) {\n\t\tblockStyles[ BLOCK_STYLE_ATTRIBUTES_MAPPING.text ] =\n\t\t\tbaseGlobalStyles?.styles?.color?.text;\n\t}\n\n\t// Global styles elements.\n\tif ( blockGlobalStyles?.elements ) {\n\t\tconst linkColor = blockGlobalStyles.elements?.link?.color?.text;\n\t\tconst styleKey = BLOCK_STYLE_ATTRIBUTES_MAPPING.link;\n\n\t\tif ( styleKey && linkColor && linkColor !== UNKNOWN_VALUE ) {\n\t\t\tblockStyles[ styleKey ] = linkColor;\n\t\t}\n\t}\n\n\t// Custom colors.\n\tObject.entries( blockStyleAttributes ).forEach( ( [ key, value ] ) => {\n\t\tconst isCustomColor = value?.startsWith?.( '#' );\n\t\tlet styleKey = key;\n\n\t\tif ( BLOCK_STYLE_ATTRIBUTES_MAPPING[ styleKey ] ) {\n\t\t\tstyleKey = BLOCK_STYLE_ATTRIBUTES_MAPPING[ styleKey ];\n\t\t}\n\n\t\tif ( ! isCustomColor ) {\n\t\t\tconst mappedColor = Object.values( defaultColors ?? {} ).find(\n\t\t\t\t( { slug } ) => slug === value\n\t\t\t);\n\n\t\t\tif ( mappedColor ) {\n\t\t\t\tblockStyles[ styleKey ] = mappedColor.color;\n\t\t\t}\n\t\t} else {\n\t\t\tblockStyles[ styleKey ] = value;\n\t\t}\n\t} );\n\n\t// Color placeholder.\n\tif ( blockStyles?.color ) {\n\t\tblockStyles[ BLOCK_STYLE_ATTRIBUTES_MAPPING.placeholder ] =\n\t\t\tblockStyles.color;\n\t}\n\n\treturn blockStyles;\n}\n\nexport function getBlockTypography(\n\tblockStyleAttributes,\n\tfontSizes,\n\tblockName,\n\tbaseGlobalStyles\n) {\n\tconst typographyStyles = {};\n\tconst customBlockStyles = blockStyleAttributes?.style?.typography || {};\n\tconst blockGlobalStyles = baseGlobalStyles?.blocks?.[ blockName ];\n\tconst parsedFontSizes = Object.values( fontSizes ?? {} );\n\n\t// Global styles.\n\tif ( blockGlobalStyles?.typography ) {\n\t\tconst fontSize = blockGlobalStyles?.typography?.fontSize;\n\t\tconst lineHeight = blockGlobalStyles?.typography?.lineHeight;\n\n\t\tif ( fontSize ) {\n\t\t\tif ( parseInt( fontSize, 10 ) ) {\n\t\t\t\ttypographyStyles.fontSize = fontSize;\n\t\t\t} else {\n\t\t\t\tconst mappedFontSize = parsedFontSizes.find(\n\t\t\t\t\t( { slug } ) => slug === fontSize\n\t\t\t\t);\n\n\t\t\t\tif ( mappedFontSize ) {\n\t\t\t\t\ttypographyStyles.fontSize = mappedFontSize?.size;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( lineHeight ) {\n\t\t\ttypographyStyles.lineHeight = lineHeight;\n\t\t}\n\t}\n\n\tif ( blockStyleAttributes?.fontSize && baseGlobalStyles ) {\n\t\tconst mappedFontSize = parsedFontSizes.find(\n\t\t\t( { slug } ) => slug === blockStyleAttributes?.fontSize\n\t\t);\n\n\t\tif ( mappedFontSize ) {\n\t\t\ttypographyStyles.fontSize = mappedFontSize?.size;\n\t\t}\n\t}\n\n\t// Custom styles.\n\tif ( customBlockStyles?.fontSize ) {\n\t\ttypographyStyles.fontSize = customBlockStyles?.fontSize;\n\t}\n\n\tif ( customBlockStyles?.lineHeight ) {\n\t\ttypographyStyles.lineHeight = customBlockStyles?.lineHeight;\n\t}\n\n\treturn typographyStyles;\n}\n\n/**\n * Return a value from a certain path of the object.\n * Path is specified as an array of properties, like: [ 'parent', 'child' ].\n *\n * @param {Object} object Input object.\n * @param {Array} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\nexport function parseStylesVariables( styles, mappedValues, customValues ) {\n\tlet stylesBase = styles;\n\tconst variables = [ 'preset', 'custom', 'var', 'fontSize' ];\n\n\tif ( ! stylesBase ) {\n\t\treturn styles;\n\t}\n\n\tvariables.forEach( ( variable ) => {\n\t\t// Examples\n\t\t// var(--wp--preset--color--gray)\n\t\t// var(--wp--custom--body--typography--font-family)\n\t\t// var:preset|color|custom-color-2\n\t\tconst regex = new RegExp( `var\\\\(--wp--${ variable }--(.*?)\\\\)`, 'g' );\n\t\tconst varRegex = /\\\"var:preset\\|color\\|(.*?)\\\"/gm;\n\t\tconst fontSizeRegex = /\"fontSize\":\"(.*?)\"/gm;\n\n\t\tif ( variable === 'preset' ) {\n\t\t\tstylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {\n\t\t\t\tconst path = $2.split( '--' );\n\t\t\t\tconst mappedPresetValue = mappedValues[ path[ 0 ] ];\n\t\t\t\tif ( mappedPresetValue && mappedPresetValue.slug ) {\n\t\t\t\t\tconst matchedValue = Object.values(\n\t\t\t\t\t\tmappedPresetValue.values ?? {}\n\t\t\t\t\t).find( ( { slug } ) => slug === path[ 1 ] );\n\t\t\t\t\treturn matchedValue?.[ mappedPresetValue.slug ];\n\t\t\t\t}\n\t\t\t\treturn UNKNOWN_VALUE;\n\t\t\t} );\n\t\t}\n\t\tif ( variable === 'custom' ) {\n\t\t\tconst customValuesData = customValues ?? JSON.parse( stylesBase );\n\t\t\tstylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {\n\t\t\t\tconst path = $2.split( '--' );\n\n\t\t\t\t// Supports cases for variables like var(--wp--custom--color--background)\n\t\t\t\tif ( path[ 0 ] === 'color' ) {\n\t\t\t\t\tconst colorKey = path[ path.length - 1 ];\n\t\t\t\t\tif ( mappedValues?.color ) {\n\t\t\t\t\t\tconst matchedValue = mappedValues.color?.values?.find(\n\t\t\t\t\t\t\t( { slug } ) => slug === colorKey\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( matchedValue ) {\n\t\t\t\t\t\t\treturn `${ matchedValue?.color }`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tpath.reduce(\n\t\t\t\t\t\t( prev, curr ) => prev && prev[ curr ],\n\t\t\t\t\t\tcustomValuesData\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn getValueFromObjectPath( customValuesData, path );\n\t\t\t\t}\n\n\t\t\t\t// Check for camelcase properties.\n\t\t\t\treturn getValueFromObjectPath( customValuesData, [\n\t\t\t\t\t...path.slice( 0, path.length - 1 ),\n\t\t\t\t\tcamelCase( path[ path.length - 1 ] ),\n\t\t\t\t] );\n\t\t\t} );\n\t\t}\n\n\t\tif ( variable === 'var' ) {\n\t\t\tstylesBase = stylesBase.replace( varRegex, ( _$1, $2 ) => {\n\t\t\t\tif ( mappedValues?.color ) {\n\t\t\t\t\tconst matchedValue = mappedValues.color?.values?.find(\n\t\t\t\t\t\t( { slug } ) => slug === $2\n\t\t\t\t\t);\n\t\t\t\t\treturn `\"${ matchedValue?.color }\"`;\n\t\t\t\t}\n\t\t\t\treturn UNKNOWN_VALUE;\n\t\t\t} );\n\t\t}\n\n\t\tif ( variable === 'fontSize' ) {\n\t\t\tconst { width, height } = Dimensions.get( 'window' );\n\n\t\t\tstylesBase = stylesBase.replace( fontSizeRegex, ( _$1, $2 ) => {\n\t\t\t\tconst parsedFontSize =\n\t\t\t\t\tgetPxFromCssUnit( $2, {\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\theight,\n\t\t\t\t\t\tfontSize: DEFAULT_FONT_SIZE,\n\t\t\t\t\t} ) || `${ DEFAULT_FONT_SIZE }px`;\n\n\t\t\t\treturn `\"fontSize\":\"${ parsedFontSize }\"`;\n\t\t\t} );\n\t\t}\n\t} );\n\n\treturn JSON.parse( stylesBase );\n}\n\nexport function getMappedValues( features, palette ) {\n\tconst typography = features?.typography;\n\tconst colors = [\n\t\t...( palette?.theme || [] ),\n\t\t...( palette?.custom || [] ),\n\t\t...( palette?.default || [] ),\n\t];\n\n\tconst fontSizes = {\n\t\t...typography?.fontSizes?.theme,\n\t\t...typography?.fontSizes?.custom,\n\t};\n\tconst mappedValues = {\n\t\tcolor: {\n\t\t\tvalues: colors,\n\t\t\tslug: 'color',\n\t\t},\n\t\t'font-size': {\n\t\t\tvalues: fontSizes,\n\t\t\tslug: 'size',\n\t\t},\n\t};\n\treturn mappedValues;\n}\n\n/**\n * Returns the normalized fontSizes to include the sizePx value for each of the different sizes.\n *\n * @param {Object} fontSizes found in global styles.\n * @return {Object} normalized sizes.\n */\nfunction normalizeFontSizes( fontSizes ) {\n\tif ( ! fontSizes ) {\n\t\treturn fontSizes;\n\t}\n\n\tconst dimensions = Dimensions.get( 'window' );\n\tconst normalizedFontSizes = {};\n\tconst keysToProcess = [];\n\n\t// Check if 'theme' or 'custom' keys exist and add them to keysToProcess array\n\tif ( fontSizes?.theme ) {\n\t\tkeysToProcess.push( 'theme' );\n\t}\n\tif ( fontSizes?.custom ) {\n\t\tkeysToProcess.push( 'custom' );\n\t}\n\n\t// If neither 'theme' nor 'custom' exist, add 'default' if it exists\n\tif ( keysToProcess.length === 0 && fontSizes?.default ) {\n\t\tkeysToProcess.push( 'default' );\n\t}\n\n\tkeysToProcess.forEach( ( key ) => {\n\t\tnormalizedFontSizes[ key ] = fontSizes[ key ].map(\n\t\t\t( fontSizeObject ) => {\n\t\t\t\tfontSizeObject.sizePx = getPxFromCssUnit( fontSizeObject.size, {\n\t\t\t\t\twidth: dimensions.width,\n\t\t\t\t\theight: dimensions.height,\n\t\t\t\t\tfontSize: DEFAULT_FONT_SIZE,\n\t\t\t\t} );\n\t\t\t\treturn fontSizeObject;\n\t\t\t}\n\t\t);\n\t} );\n\n\treturn normalizedFontSizes;\n}\n\nexport function useMobileGlobalStylesColors( type = 'colors' ) {\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst availableThemeColors = colorGradientSettings?.[ type ]?.reduce(\n\t\t( colors, origin ) => colors.concat( origin?.[ type ] ),\n\t\t[]\n\t);\n\t// Default editor colors/gradients if it's not a block-based theme.\n\tconst defaultPaletteSetting =\n\t\ttype === 'colors' ? 'color.palette' : 'color.gradients';\n\tconst [ defaultPaletteValue ] = useSettings( defaultPaletteSetting );\n\t// In edge cases, the default palette might be undefined. To avoid\n\t// exceptions across the editor in that case, we explicitly return\n\t// the default editor colors.\n\tconst defaultPalette = defaultPaletteValue ?? SETTINGS_DEFAULTS.colors;\n\n\treturn availableThemeColors.length >= 1\n\t\t? availableThemeColors\n\t\t: defaultPalette;\n}\n\nexport function getColorsAndGradients(\n\tdefaultEditorColors = [],\n\tdefaultEditorGradients = [],\n\trawFeatures\n) {\n\tconst features = rawFeatures ? JSON.parse( rawFeatures ) : {};\n\n\treturn {\n\t\t__experimentalGlobalStylesBaseStyles: null,\n\t\t__experimentalFeatures: {\n\t\t\tcolor: {\n\t\t\t\t...( ! features?.color\n\t\t\t\t\t? {\n\t\t\t\t\t\t\ttext: true,\n\t\t\t\t\t\t\tbackground: true,\n\t\t\t\t\t\t\tpalette: {\n\t\t\t\t\t\t\t\tdefault: defaultEditorColors,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgradients: {\n\t\t\t\t\t\t\t\tdefault: defaultEditorGradients,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }\n\t\t\t\t\t: features?.color ),\n\t\t\t\tdefaultPalette: defaultEditorColors?.length > 0,\n\t\t\t\tdefaultGradients: defaultEditorGradients?.length > 0,\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport function getGlobalStyles( rawStyles, rawFeatures ) {\n\tconst features = rawFeatures ? JSON.parse( rawFeatures ) : {};\n\tconst mappedValues = getMappedValues( features, features?.color?.palette );\n\tconst colors = parseStylesVariables(\n\t\tJSON.stringify( features?.color ),\n\t\tmappedValues\n\t);\n\tconst gradients = parseStylesVariables(\n\t\tJSON.stringify( features?.color?.gradients ),\n\t\tmappedValues\n\t);\n\tconst customValues = parseStylesVariables(\n\t\tJSON.stringify( features?.custom ),\n\t\tmappedValues\n\t);\n\tconst globalStyles = parseStylesVariables(\n\t\trawStyles,\n\t\tmappedValues,\n\t\tcustomValues\n\t);\n\n\tconst fontSizes = normalizeFontSizes( features?.typography?.fontSizes );\n\n\treturn {\n\t\t__experimentalFeatures: {\n\t\t\tcolor: {\n\t\t\t\tpalette: colors?.palette,\n\t\t\t\tgradients,\n\t\t\t\ttext: features?.color?.text ?? true,\n\t\t\t\tbackground: features?.color?.background ?? true,\n\t\t\t\tdefaultPalette: features?.color?.defaultPalette ?? true,\n\t\t\t\tdefaultGradients: features?.color?.defaultGradients ?? true,\n\t\t\t},\n\t\t\ttypography: {\n\t\t\t\tfontSizes,\n\t\t\t\tcustomLineHeight: features?.custom?.[ 'line-height' ],\n\t\t\t},\n\t\t\tspacing: features?.spacing,\n\t\t},\n\t\t__experimentalGlobalStylesBaseStyles: globalStyles,\n\t};\n}\n\n/**\n * Determine and apply appropriate color scheme based on global styles or device's light/dark mode.\n *\n * The function first attempts to retrieve the editor's background color from global styles.\n * If the detected background color is light, light styles are applied, and dark styles otherwise.\n * If no custom background color is defined, styles are applied using the device's dark/light setting.\n *\n * @param {Object} baseStyle - An object representing the base (light theme) styles for the editor.\n * @param {Object} darkStyle - An object representing the additional styles to apply when the editor is in dark mode.\n *\n * @return {Object} - The combined style object that should be applied to the editor.\n */\nexport const useEditorColorScheme = ( baseStyle, darkStyle ) => {\n\tconst globalStyles = useGlobalStyles();\n\n\tconst deviceColorScheme = usePreferredColorSchemeStyle(\n\t\tbaseStyle,\n\t\tdarkStyle\n\t);\n\n\tconst editorColors = globalStyles?.baseColors?.color;\n\tconst editorBackgroundColor = editorColors?.background;\n\n\tconst isBackgroundColorDefined =\n\t\ttypeof editorBackgroundColor !== 'undefined' &&\n\t\teditorBackgroundColor !== 'undefined';\n\n\tif ( isBackgroundColorDefined ) {\n\t\tconst isEditorBackgroundDark = colord( editorBackgroundColor ).isDark();\n\t\treturn isEditorBackgroundDark\n\t\t\t? { ...baseStyle, ...darkStyle }\n\t\t\t: baseStyle;\n\t}\n\n\treturn deviceColorScheme;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA,SACCC,WAAW,EACXC,mCAAmC,EACnCC,iBAAiB,QACX,yBAAyB;AAChC,SAASC,4BAA4B,QAAQ,oBAAoB;;AAEjE;AACA;AACA;AACA,SAASC,OAAO,IAAIC,gBAAgB,QAAQ,+BAA+B;AAC3E,SAASC,eAAe,QAAQ,gBAAgB;AAEhD,OAAO,MAAMC,sBAAsB,GAAG,CACrC,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,UAAU,CACV;;AAED;AACA,MAAMC,8BAA8B,GAAG;EACtCC,SAAS,EAAE,OAAO;EAClBC,IAAI,EAAE,OAAO;EACbC,UAAU,EAAE,iBAAiB;EAC7BC,IAAI,EAAE,WAAW;EACjBC,WAAW,EAAE;AACd,CAAC;AAED,MAAMC,OAAO,GAAG,EAAE,CAAC,CAAC;AACpB,MAAMC,aAAa,GAAG,WAAW;AACjC,MAAMC,iBAAiB,GAAG,EAAE;AAE5B,OAAO,SAASC,gBAAgBA,CAC/BC,WAAW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AC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,oBAAoB,GAAGA,CAAEC,SAAS,EAAEC,SAAS,KAAM;EAC/D,MAAML,YAAY,GAAGhI,eAAe,CAAC,CAAC;EAEtC,MAAMsI,iBAAiB,GAAGzI,4BAA4B,CACrDuI,SAAS,EACTC,SACD,CAAC;EAED,MAAME,YAAY,GAAGP,YAAY,EAAEQ,UAAU,EAAE7G,KAAK;EACpD,MAAM8G,qBAAqB,GAAGF,YAAY,EAAElI,UAAU;EAEtD,MAAMqI,wBAAwB,GAC7B,OAAOD,qBAAqB,KAAK,WAAW,IAC5CA,qBAAqB,KAAK,WAAW;EAEtC,IAAKC,wBAAwB,EAAG;IAC/B,MAAMC,sBAAsB,GAAGlJ,MAAM,CAAEgJ,qBAAsB,CAAC,CAACG,MAAM,CAAC,CAAC;IACvE,OAAOD,sBAAsB,GAC1B;MAAE,GAAGP,SAAS;MAAE,GAAGC;IAAU,CAAC,GAC9BD,SAAS;EACb;EAEA,OAAOE,iBAAiB;AACzB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export const IMAGE_DEFAULT_FOCAL_POINT = {
2
+ x: 0.5,
3
+ y: 0.5
4
+ };
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IMAGE_DEFAULT_FOCAL_POINT","x","y"],"sources":["@wordpress/components/src/mobile/image/constants.js"],"sourcesContent":["export const IMAGE_DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\n"],"mappings":"AAAA,OAAO,MAAMA,yBAAyB,GAAG;EAAEC,CAAC,EAAE,GAAG;EAAEC,CAAC,EAAE;AAAI,CAAC"}
@@ -10,7 +10,7 @@ import FastImage from 'react-native-fast-image';
10
10
  */
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { Icon } from '@wordpress/components';
13
- import { image as icon } from '@wordpress/icons';
13
+ import { image, offline } from '@wordpress/icons';
14
14
  import { usePreferredColorSchemeStyle } from '@wordpress/compose';
15
15
  import { useEffect, useState, Platform } from '@wordpress/element';
16
16
 
@@ -22,14 +22,11 @@ import styles from './style.scss';
22
22
  import SvgIconRetry from './icon-retry';
23
23
  import ImageEditingButton from './image-editing-button';
24
24
  const ICON_TYPE = {
25
+ OFFLINE: 'offline',
25
26
  PLACEHOLDER: 'placeholder',
26
27
  RETRY: 'retry',
27
28
  UPLOAD: 'upload'
28
29
  };
29
- export const IMAGE_DEFAULT_FOCAL_POINT = {
30
- x: 0.5,
31
- y: 0.5
32
- };
33
30
  const ImageComponent = ({
34
31
  align,
35
32
  alt,
@@ -40,6 +37,7 @@ const ImageComponent = ({
40
37
  isSelected,
41
38
  shouldUseFastImage,
42
39
  isUploadFailed,
40
+ isUploadPaused,
43
41
  isUploadInProgress,
44
42
  mediaPickerOptions,
45
43
  onImageDataLoad,
@@ -95,17 +93,23 @@ const ImageComponent = ({
95
93
  }
96
94
  };
97
95
  const getIcon = iconType => {
96
+ let icon;
98
97
  let iconStyle;
99
98
  switch (iconType) {
100
99
  case ICON_TYPE.RETRY:
101
- return createElement(Icon, {
102
- icon: retryIcon || SvgIconRetry,
103
- ...styles.iconRetry
104
- });
100
+ icon = retryIcon || SvgIconRetry;
101
+ iconStyle = iconRetryStyles;
102
+ break;
103
+ case ICON_TYPE.OFFLINE:
104
+ icon = offline;
105
+ iconStyle = iconOfflineStyles;
106
+ break;
105
107
  case ICON_TYPE.PLACEHOLDER:
108
+ icon = image;
106
109
  iconStyle = iconPlaceholderStyles;
107
110
  break;
108
111
  case ICON_TYPE.UPLOAD:
112
+ icon = image;
109
113
  iconStyle = iconUploadStyles;
110
114
  break;
111
115
  }
@@ -116,6 +120,11 @@ const ImageComponent = ({
116
120
  };
117
121
  const iconPlaceholderStyles = usePreferredColorSchemeStyle(styles.iconPlaceholder, styles.iconPlaceholderDark);
118
122
  const iconUploadStyles = usePreferredColorSchemeStyle(styles.iconUpload, styles.iconUploadDark);
123
+ const iconOfflineStyles = usePreferredColorSchemeStyle(styles.iconOffline, styles.iconOfflineDark);
124
+ const retryIconStyles = usePreferredColorSchemeStyle(styles.retryIcon, styles.retryIconDark);
125
+ const iconRetryStyles = usePreferredColorSchemeStyle(styles.iconRetry, styles.iconRetryDark);
126
+ const retryContainerStyles = usePreferredColorSchemeStyle(styles.retryContainer, styles.retryContainerDark);
127
+ const uploadFailedTextStyles = usePreferredColorSchemeStyle(styles.uploadFailedText, styles.uploadFailedTextDark);
119
128
  const placeholderStyles = [usePreferredColorSchemeStyle(styles.imageContainerUpload, styles.imageContainerUploadDark), focalPoint && styles.imageContainerUploadWithFocalpoint, imageHeight && {
120
129
  height: imageHeight
121
130
  }];
@@ -155,7 +164,7 @@ const ImageComponent = ({
155
164
  accessibilityRole: 'imagebutton',
156
165
  key: url,
157
166
  style: imageContainerStyles
158
- }, isSelected && highlightSelected && !(isUploadInProgress || isUploadFailed) && createElement(View, {
167
+ }, isSelected && highlightSelected && !(isUploadInProgress || isUploadFailed || isUploadPaused) && createElement(View, {
159
168
  style: imageSelectedStyles
160
169
  }), !imageData ? createElement(View, {
161
170
  style: placeholderStyles
@@ -172,16 +181,16 @@ const ImageComponent = ({
172
181
  resizeMethod: 'scale'
173
182
  }),
174
183
  resizeMode: imageResizeMode
175
- })), isUploadFailed && retryMessage && createElement(View, {
176
- style: [styles.imageContainer, styles.retryContainer]
184
+ })), (isUploadFailed || isUploadPaused) && retryMessage && createElement(View, {
185
+ style: [styles.imageContainer, retryContainerStyles]
177
186
  }, createElement(View, {
178
- style: [styles.retryIcon, retryIcon && styles.customRetryIcon]
179
- }, getIcon(ICON_TYPE.RETRY)), createElement(Text, {
180
- style: styles.uploadFailedText
187
+ style: [retryIconStyles, retryIcon && styles.customRetryIcon]
188
+ }, isUploadPaused ? getIcon(ICON_TYPE.OFFLINE) : getIcon(ICON_TYPE.RETRY)), createElement(Text, {
189
+ style: uploadFailedTextStyles
181
190
  }, retryMessage))), editButton && isSelected && !isUploadInProgress && createElement(ImageEditingButton, {
182
191
  onSelectMediaUploadOption: onSelectMediaUploadOption,
183
192
  openMediaOptions: openMediaOptions,
184
- url: !isUploadFailed && imageData && url,
193
+ url: !(isUploadFailed || isUploadPaused) && imageData && url,
185
194
  pickerOptions: mediaPickerOptions
186
195
  }));
187
196
  };
@@ -1 +1 @@
1
- {"version":3,"names":["Image","RNImage","Text","View","FastImage","__","Icon","image","icon","usePreferredColorSchemeStyle","useEffect","useState","Platform","getImageWithFocalPointStyles","styles","SvgIconRetry","ImageEditingButton","ICON_TYPE","PLACEHOLDER","RETRY","UPLOAD","IMAGE_DEFAULT_FOCAL_POINT","x","y","ImageComponent","align","alt","editButton","focalPoint","height","imageHeight","highlightSelected","isSelected","shouldUseFastImage","isUploadFailed","isUploadInProgress","mediaPickerOptions","onImageDataLoad","onSelectMediaUploadOption","openMediaOptions","resizeMode","retryMessage","retryIcon","url","shapeStyle","style","width","imageWidth","imageData","setImageData","containerSize","setContainerSize","isAndroid","imageResizeMode","isCurrent","getSize","imgWidth","imgHeight","metaData","aspectRatio","onContainerLayout","event","nativeEvent","layout","getIcon","iconType","iconStyle","createElement","iconRetry","iconPlaceholderStyles","iconUploadStyles","iconPlaceholder","iconPlaceholderDark","iconUpload","iconUploadDark","placeholderStyles","imageContainerUpload","imageContainerUploadDark","imageContainerUploadWithFocalpoint","customWidth","wide","imageContainerStyles","imageContent","focalPointContainer","imageStyles","opacity","undefined","imageSelectedStyles","imageBorder","imageBorderDark","container","alignItems","onLayout","accessible","disabled","accessibilityLabel","accessibilityHint","accessibilityRole","key","imageUploadingIconContainer","focalPointContent","source","uri","resizeMethod","imageContainer","retryContainer","customRetryIcon","uploadFailedText","pickerOptions"],"sources":["@wordpress/components/src/mobile/image/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Image as RNImage, Text, View } from 'react-native';\nimport FastImage from 'react-native-fast-image';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon } from '@wordpress/components';\nimport { image as icon } from '@wordpress/icons';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { useEffect, useState, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getImageWithFocalPointStyles } from './utils';\nimport styles from './style.scss';\nimport SvgIconRetry from './icon-retry';\nimport ImageEditingButton from './image-editing-button';\n\nconst ICON_TYPE = {\n\tPLACEHOLDER: 'placeholder',\n\tRETRY: 'retry',\n\tUPLOAD: 'upload',\n};\n\nexport const IMAGE_DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\n\nconst ImageComponent = ( {\n\talign,\n\talt,\n\teditButton = true,\n\tfocalPoint,\n\theight: imageHeight,\n\thighlightSelected = true,\n\tisSelected,\n\tshouldUseFastImage,\n\tisUploadFailed,\n\tisUploadInProgress,\n\tmediaPickerOptions,\n\tonImageDataLoad,\n\tonSelectMediaUploadOption,\n\topenMediaOptions,\n\tresizeMode,\n\tretryMessage,\n\tretryIcon,\n\turl,\n\tshapeStyle,\n\tstyle,\n\twidth: imageWidth,\n} ) => {\n\tconst [ imageData, setImageData ] = useState( null );\n\tconst [ containerSize, setContainerSize ] = useState( null );\n\n\t// Disabled for Android due to https://github.com/WordPress/gutenberg/issues/43149\n\tconst Image =\n\t\t! shouldUseFastImage || Platform.isAndroid ? RNImage : FastImage;\n\tconst imageResizeMode =\n\t\t! shouldUseFastImage || Platform.isAndroid\n\t\t\t? resizeMode\n\t\t\t: FastImage.resizeMode[ resizeMode ];\n\n\tuseEffect( () => {\n\t\tlet isCurrent = true;\n\t\tif ( url ) {\n\t\t\tRNImage.getSize( url, ( imgWidth, imgHeight ) => {\n\t\t\t\tif ( ! isCurrent ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst metaData = {\n\t\t\t\t\taspectRatio: imgWidth / imgHeight,\n\t\t\t\t\twidth: imgWidth,\n\t\t\t\t\theight: imgHeight,\n\t\t\t\t};\n\t\t\t\tsetImageData( metaData );\n\t\t\t\tif ( onImageDataLoad ) {\n\t\t\t\t\tonImageDataLoad( metaData );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\treturn () => ( isCurrent = false );\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ url ] );\n\n\tconst onContainerLayout = ( event ) => {\n\t\tconst { height, width } = event.nativeEvent.layout;\n\n\t\tif (\n\t\t\twidth !== 0 &&\n\t\t\theight !== 0 &&\n\t\t\t( containerSize?.width !== width ||\n\t\t\t\tcontainerSize?.height !== height )\n\t\t) {\n\t\t\tsetContainerSize( { width, height } );\n\t\t}\n\t};\n\n\tconst getIcon = ( iconType ) => {\n\t\tlet iconStyle;\n\t\tswitch ( iconType ) {\n\t\t\tcase ICON_TYPE.RETRY:\n\t\t\t\treturn (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ retryIcon || SvgIconRetry }\n\t\t\t\t\t\t{ ...styles.iconRetry }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\tcase ICON_TYPE.PLACEHOLDER:\n\t\t\t\ticonStyle = iconPlaceholderStyles;\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.UPLOAD:\n\t\t\t\ticonStyle = iconUploadStyles;\n\t\t\t\tbreak;\n\t\t}\n\t\treturn <Icon icon={ icon } { ...iconStyle } />;\n\t};\n\n\tconst iconPlaceholderStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconPlaceholder,\n\t\tstyles.iconPlaceholderDark\n\t);\n\n\tconst iconUploadStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconUpload,\n\t\tstyles.iconUploadDark\n\t);\n\n\tconst placeholderStyles = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.imageContainerUpload,\n\t\t\tstyles.imageContainerUploadDark\n\t\t),\n\t\tfocalPoint && styles.imageContainerUploadWithFocalpoint,\n\t\timageHeight && { height: imageHeight },\n\t];\n\n\tconst customWidth =\n\t\timageData?.width < containerSize?.width\n\t\t\t? imageData?.width\n\t\t\t: styles.wide?.width;\n\n\tconst imageContainerStyles = [\n\t\tstyles.imageContent,\n\t\t{\n\t\t\twidth:\n\t\t\t\timageWidth === styles.wide?.width ||\n\t\t\t\t( imageData &&\n\t\t\t\t\timageWidth > 0 &&\n\t\t\t\t\timageWidth < containerSize?.width )\n\t\t\t\t\t? imageWidth\n\t\t\t\t\t: customWidth,\n\t\t},\n\t\tresizeMode && { width: styles.wide?.width },\n\t\tfocalPoint && styles.focalPointContainer,\n\t];\n\n\tconst imageStyles = [\n\t\t{\n\t\t\topacity: isUploadInProgress ? 0.3 : 1,\n\t\t\theight: containerSize?.height,\n\t\t},\n\t\t! resizeMode && {\n\t\t\taspectRatio: imageData?.aspectRatio,\n\t\t},\n\t\tfocalPoint && styles.focalPoint,\n\t\tfocalPoint &&\n\t\t\tgetImageWithFocalPointStyles(\n\t\t\t\tfocalPoint,\n\t\t\t\tcontainerSize,\n\t\t\t\timageData\n\t\t\t),\n\t\t! focalPoint &&\n\t\t\timageData &&\n\t\t\tcontainerSize && {\n\t\t\t\theight:\n\t\t\t\t\timageData?.width > containerSize?.width && ! imageWidth\n\t\t\t\t\t\t? containerSize?.width / imageData?.aspectRatio\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\timageHeight && { height: imageHeight },\n\t\tshapeStyle,\n\t];\n\tconst imageSelectedStyles = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.imageBorder,\n\t\t\tstyles.imageBorderDark\n\t\t),\n\t\t{ height: containerSize?.height },\n\t];\n\n\treturn (\n\t\t<View\n\t\t\tstyle={ [\n\t\t\t\tstyles.container,\n\t\t\t\t// Only set alignItems if an image exists because alignItems causes the placeholder\n\t\t\t\t// to disappear when an aligned image can't be downloaded\n\t\t\t\t// https://github.com/wordpress-mobile/gutenberg-mobile/issues/1592\n\t\t\t\timageData && align && { alignItems: align },\n\t\t\t\tstyle,\n\t\t\t] }\n\t\t\tonLayout={ onContainerLayout }\n\t\t>\n\t\t\t<View\n\t\t\t\taccessible\n\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\taccessibilityLabel={ alt }\n\t\t\t\taccessibilityHint={ __( 'Double tap and hold to edit' ) }\n\t\t\t\taccessibilityRole={ 'imagebutton' }\n\t\t\t\tkey={ url }\n\t\t\t\tstyle={ imageContainerStyles }\n\t\t\t>\n\t\t\t\t{ isSelected &&\n\t\t\t\t\thighlightSelected &&\n\t\t\t\t\t! ( isUploadInProgress || isUploadFailed ) && (\n\t\t\t\t\t\t<View style={ imageSelectedStyles } />\n\t\t\t\t\t) }\n\n\t\t\t\t{ ! imageData ? (\n\t\t\t\t\t<View style={ placeholderStyles }>\n\t\t\t\t\t\t<View style={ styles.imageUploadingIconContainer }>\n\t\t\t\t\t\t\t{ getIcon( ICON_TYPE.UPLOAD ) }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</View>\n\t\t\t\t) : (\n\t\t\t\t\t<View style={ focalPoint && styles.focalPointContent }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\tstyle={ imageStyles }\n\t\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t\t\t{ ...( ! focalPoint && {\n\t\t\t\t\t\t\t\tresizeMethod: 'scale',\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tresizeMode={ imageResizeMode }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\n\t\t\t\t{ isUploadFailed && retryMessage && (\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\tstyles.imageContainer,\n\t\t\t\t\t\t\tstyles.retryContainer,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<View\n\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\tstyles.retryIcon,\n\t\t\t\t\t\t\t\tretryIcon && styles.customRetryIcon,\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ getIcon( ICON_TYPE.RETRY ) }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<Text style={ styles.uploadFailedText }>\n\t\t\t\t\t\t\t{ retryMessage }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\t\t\t</View>\n\n\t\t\t{ editButton && isSelected && ! isUploadInProgress && (\n\t\t\t\t<ImageEditingButton\n\t\t\t\t\tonSelectMediaUploadOption={ onSelectMediaUploadOption }\n\t\t\t\t\topenMediaOptions={ openMediaOptions }\n\t\t\t\t\turl={ ! isUploadFailed && imageData && url }\n\t\t\t\t\tpickerOptions={ mediaPickerOptions }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</View>\n\t);\n};\n\nexport default ImageComponent;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,OAAO,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAC3D,OAAOC,SAAS,MAAM,yBAAyB;;AAE/C;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,KAAK,IAAIC,IAAI,QAAQ,kBAAkB;AAChD,SAASC,4BAA4B,QAAQ,oBAAoB;AACjE,SAASC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA,SAASC,4BAA4B,QAAQ,SAAS;AACtD,OAAOC,MAAM,MAAM,cAAc;AACjC,OAAOC,YAAY,MAAM,cAAc;AACvC,OAAOC,kBAAkB,MAAM,wBAAwB;AAEvD,MAAMC,SAAS,GAAG;EACjBC,WAAW,EAAE,aAAa;EAC1BC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AAED,OAAO,MAAMC,yBAAyB,GAAG;EAAEC,CAAC,EAAE,GAAG;EAAEC,CAAC,EAAE;AAAI,CAAC;AAE3D,MAA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Ac,IAAIO,YAAY,IAC/B0B,aAAA,CAAChE,IAAI;IACJ0C,KAAK,EAAG,CACP/B,MAAM,CAAC0F,cAAc,EACrB1F,MAAM,CAAC2F,cAAc;EACnB,GAEHtC,aAAA,CAAChE,IAAI;IACJ0C,KAAK,EAAG,CACP/B,MAAM,CAAC4B,SAAS,EAChBA,SAAS,IAAI5B,MAAM,CAAC4F,eAAe;EACjC,GAED1C,OAAO,CAAE/C,SAAS,CAACE,KAAM,CACtB,CAAC,EACPgD,aAAA,CAACjE,IAAI;IAAC2C,KAAK,EAAG/B,MAAM,CAAC6F;EAAkB,GACpClE,YACG,CACD,CAEF,CAAC,EAELd,UAAU,IAAIK,UAAU,IAAI,CAAEG,kBAAkB,IACjDgC,aAAA,CAACnD,kBAAkB;IAClBsB,yBAAyB,EAAGA,yBAA2B;IACvDC,gBAAgB,EAAGA,gBAAkB;IACrCI,GAAG,EAAG,CAAET,cAAc,IAAIc,SAAS,IAAIL,GAAK;IAC5CiE,aAAa,EAAGxE;EAAoB,CACpC,CAEG,CAAC;AAET,CAAC;AAED,eAAeZ,cAAc"}
1
+ {"version":3,"names":["Image","RNImage","Text","View","FastImage","__","Icon","image","offline","usePreferredColorSchemeStyle","useEffect","useState","Platform","getImageWithFocalPointStyles","styles","SvgIconRetry","ImageEditingButton","ICON_TYPE","OFFLINE","PLACEHOLDER","RETRY","UPLOAD","ImageComponent","align","alt","editButton","focalPoint","height","imageHeight","highlightSelected","isSelected","shouldUseFastImage","isUploadFailed","isUploadPaused","isUploadInProgress","mediaPickerOptions","onImageDataLoad","onSelectMediaUploadOption","openMediaOptions","resizeMode","retryMessage","retryIcon","url","shapeStyle","style","width","imageWidth","imageData","setImageData","containerSize","setContainerSize","isAndroid","imageResizeMode","isCurrent","getSize","imgWidth","imgHeight","metaData","aspectRatio","onContainerLayout","event","nativeEvent","layout","getIcon","iconType","icon","iconStyle","iconRetryStyles","iconOfflineStyles","iconPlaceholderStyles","iconUploadStyles","createElement","iconPlaceholder","iconPlaceholderDark","iconUpload","iconUploadDark","iconOffline","iconOfflineDark","retryIconStyles","retryIconDark","iconRetry","iconRetryDark","retryContainerStyles","retryContainer","retryContainerDark","uploadFailedTextStyles","uploadFailedText","uploadFailedTextDark","placeholderStyles","imageContainerUpload","imageContainerUploadDark","imageContainerUploadWithFocalpoint","customWidth","wide","imageContainerStyles","imageContent","focalPointContainer","imageStyles","opacity","undefined","imageSelectedStyles","imageBorder","imageBorderDark","container","alignItems","onLayout","accessible","disabled","accessibilityLabel","accessibilityHint","accessibilityRole","key","imageUploadingIconContainer","focalPointContent","source","uri","resizeMethod","imageContainer","customRetryIcon","pickerOptions"],"sources":["@wordpress/components/src/mobile/image/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Image as RNImage, Text, View } from 'react-native';\nimport FastImage from 'react-native-fast-image';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon } from '@wordpress/components';\nimport { image, offline } from '@wordpress/icons';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { useEffect, useState, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getImageWithFocalPointStyles } from './utils';\nimport styles from './style.scss';\nimport SvgIconRetry from './icon-retry';\nimport ImageEditingButton from './image-editing-button';\n\nconst ICON_TYPE = {\n\tOFFLINE: 'offline',\n\tPLACEHOLDER: 'placeholder',\n\tRETRY: 'retry',\n\tUPLOAD: 'upload',\n};\n\nconst ImageComponent = ( {\n\talign,\n\talt,\n\teditButton = true,\n\tfocalPoint,\n\theight: imageHeight,\n\thighlightSelected = true,\n\tisSelected,\n\tshouldUseFastImage,\n\tisUploadFailed,\n\tisUploadPaused,\n\tisUploadInProgress,\n\tmediaPickerOptions,\n\tonImageDataLoad,\n\tonSelectMediaUploadOption,\n\topenMediaOptions,\n\tresizeMode,\n\tretryMessage,\n\tretryIcon,\n\turl,\n\tshapeStyle,\n\tstyle,\n\twidth: imageWidth,\n} ) => {\n\tconst [ imageData, setImageData ] = useState( null );\n\tconst [ containerSize, setContainerSize ] = useState( null );\n\n\t// Disabled for Android due to https://github.com/WordPress/gutenberg/issues/43149\n\tconst Image =\n\t\t! shouldUseFastImage || Platform.isAndroid ? RNImage : FastImage;\n\tconst imageResizeMode =\n\t\t! shouldUseFastImage || Platform.isAndroid\n\t\t\t? resizeMode\n\t\t\t: FastImage.resizeMode[ resizeMode ];\n\n\tuseEffect( () => {\n\t\tlet isCurrent = true;\n\t\tif ( url ) {\n\t\t\tRNImage.getSize( url, ( imgWidth, imgHeight ) => {\n\t\t\t\tif ( ! isCurrent ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst metaData = {\n\t\t\t\t\taspectRatio: imgWidth / imgHeight,\n\t\t\t\t\twidth: imgWidth,\n\t\t\t\t\theight: imgHeight,\n\t\t\t\t};\n\t\t\t\tsetImageData( metaData );\n\t\t\t\tif ( onImageDataLoad ) {\n\t\t\t\t\tonImageDataLoad( metaData );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\treturn () => ( isCurrent = false );\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ url ] );\n\n\tconst onContainerLayout = ( event ) => {\n\t\tconst { height, width } = event.nativeEvent.layout;\n\n\t\tif (\n\t\t\twidth !== 0 &&\n\t\t\theight !== 0 &&\n\t\t\t( containerSize?.width !== width ||\n\t\t\t\tcontainerSize?.height !== height )\n\t\t) {\n\t\t\tsetContainerSize( { width, height } );\n\t\t}\n\t};\n\n\tconst getIcon = ( iconType ) => {\n\t\tlet icon;\n\t\tlet iconStyle;\n\t\tswitch ( iconType ) {\n\t\t\tcase ICON_TYPE.RETRY:\n\t\t\t\ticon = retryIcon || SvgIconRetry;\n\t\t\t\ticonStyle = iconRetryStyles;\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.OFFLINE:\n\t\t\t\ticon = offline;\n\t\t\t\ticonStyle = iconOfflineStyles;\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.PLACEHOLDER:\n\t\t\t\ticon = image;\n\t\t\t\ticonStyle = iconPlaceholderStyles;\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.UPLOAD:\n\t\t\t\ticon = image;\n\t\t\t\ticonStyle = iconUploadStyles;\n\t\t\t\tbreak;\n\t\t}\n\t\treturn <Icon icon={ icon } { ...iconStyle } />;\n\t};\n\n\tconst iconPlaceholderStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconPlaceholder,\n\t\tstyles.iconPlaceholderDark\n\t);\n\n\tconst iconUploadStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconUpload,\n\t\tstyles.iconUploadDark\n\t);\n\n\tconst iconOfflineStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconOffline,\n\t\tstyles.iconOfflineDark\n\t);\n\n\tconst retryIconStyles = usePreferredColorSchemeStyle(\n\t\tstyles.retryIcon,\n\t\tstyles.retryIconDark\n\t);\n\n\tconst iconRetryStyles = usePreferredColorSchemeStyle(\n\t\tstyles.iconRetry,\n\t\tstyles.iconRetryDark\n\t);\n\n\tconst retryContainerStyles = usePreferredColorSchemeStyle(\n\t\tstyles.retryContainer,\n\t\tstyles.retryContainerDark\n\t);\n\n\tconst uploadFailedTextStyles = usePreferredColorSchemeStyle(\n\t\tstyles.uploadFailedText,\n\t\tstyles.uploadFailedTextDark\n\t);\n\n\tconst placeholderStyles = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.imageContainerUpload,\n\t\t\tstyles.imageContainerUploadDark\n\t\t),\n\t\tfocalPoint && styles.imageContainerUploadWithFocalpoint,\n\t\timageHeight && { height: imageHeight },\n\t];\n\n\tconst customWidth =\n\t\timageData?.width < containerSize?.width\n\t\t\t? imageData?.width\n\t\t\t: styles.wide?.width;\n\n\tconst imageContainerStyles = [\n\t\tstyles.imageContent,\n\t\t{\n\t\t\twidth:\n\t\t\t\timageWidth === styles.wide?.width ||\n\t\t\t\t( imageData &&\n\t\t\t\t\timageWidth > 0 &&\n\t\t\t\t\timageWidth < containerSize?.width )\n\t\t\t\t\t? imageWidth\n\t\t\t\t\t: customWidth,\n\t\t},\n\t\tresizeMode && { width: styles.wide?.width },\n\t\tfocalPoint && styles.focalPointContainer,\n\t];\n\n\tconst imageStyles = [\n\t\t{\n\t\t\topacity: isUploadInProgress ? 0.3 : 1,\n\t\t\theight: containerSize?.height,\n\t\t},\n\t\t! resizeMode && {\n\t\t\taspectRatio: imageData?.aspectRatio,\n\t\t},\n\t\tfocalPoint && styles.focalPoint,\n\t\tfocalPoint &&\n\t\t\tgetImageWithFocalPointStyles(\n\t\t\t\tfocalPoint,\n\t\t\t\tcontainerSize,\n\t\t\t\timageData\n\t\t\t),\n\t\t! focalPoint &&\n\t\t\timageData &&\n\t\t\tcontainerSize && {\n\t\t\t\theight:\n\t\t\t\t\timageData?.width > containerSize?.width && ! imageWidth\n\t\t\t\t\t\t? containerSize?.width / imageData?.aspectRatio\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\timageHeight && { height: imageHeight },\n\t\tshapeStyle,\n\t];\n\tconst imageSelectedStyles = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.imageBorder,\n\t\t\tstyles.imageBorderDark\n\t\t),\n\t\t{ height: containerSize?.height },\n\t];\n\n\treturn (\n\t\t<View\n\t\t\tstyle={ [\n\t\t\t\tstyles.container,\n\t\t\t\t// Only set alignItems if an image exists because alignItems causes the placeholder\n\t\t\t\t// to disappear when an aligned image can't be downloaded\n\t\t\t\t// https://github.com/wordpress-mobile/gutenberg-mobile/issues/1592\n\t\t\t\timageData && align && { alignItems: align },\n\t\t\t\tstyle,\n\t\t\t] }\n\t\t\tonLayout={ onContainerLayout }\n\t\t>\n\t\t\t<View\n\t\t\t\taccessible\n\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\taccessibilityLabel={ alt }\n\t\t\t\taccessibilityHint={ __( 'Double tap and hold to edit' ) }\n\t\t\t\taccessibilityRole={ 'imagebutton' }\n\t\t\t\tkey={ url }\n\t\t\t\tstyle={ imageContainerStyles }\n\t\t\t>\n\t\t\t\t{ isSelected &&\n\t\t\t\t\thighlightSelected &&\n\t\t\t\t\t! (\n\t\t\t\t\t\tisUploadInProgress ||\n\t\t\t\t\t\tisUploadFailed ||\n\t\t\t\t\t\tisUploadPaused\n\t\t\t\t\t) && <View style={ imageSelectedStyles } /> }\n\n\t\t\t\t{ ! imageData ? (\n\t\t\t\t\t<View style={ placeholderStyles }>\n\t\t\t\t\t\t<View style={ styles.imageUploadingIconContainer }>\n\t\t\t\t\t\t\t{ getIcon( ICON_TYPE.UPLOAD ) }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</View>\n\t\t\t\t) : (\n\t\t\t\t\t<View style={ focalPoint && styles.focalPointContent }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\tstyle={ imageStyles }\n\t\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t\t\t{ ...( ! focalPoint && {\n\t\t\t\t\t\t\t\tresizeMethod: 'scale',\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tresizeMode={ imageResizeMode }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\n\t\t\t\t{ ( isUploadFailed || isUploadPaused ) && retryMessage && (\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\tstyles.imageContainer,\n\t\t\t\t\t\t\tretryContainerStyles,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<View\n\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\tretryIconStyles,\n\t\t\t\t\t\t\t\tretryIcon && styles.customRetryIcon,\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ isUploadPaused\n\t\t\t\t\t\t\t\t? getIcon( ICON_TYPE.OFFLINE )\n\t\t\t\t\t\t\t\t: getIcon( ICON_TYPE.RETRY ) }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<Text style={ uploadFailedTextStyles }>\n\t\t\t\t\t\t\t{ retryMessage }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\t\t\t</View>\n\n\t\t\t{ editButton && isSelected && ! isUploadInProgress && (\n\t\t\t\t<ImageEditingButton\n\t\t\t\t\tonSelectMediaUploadOption={ onSelectMediaUploadOption }\n\t\t\t\t\topenMediaOptions={ openMediaOptions }\n\t\t\t\t\turl={\n\t\t\t\t\t\t! ( isUploadFailed || isUploadPaused ) &&\n\t\t\t\t\t\timageData &&\n\t\t\t\t\t\turl\n\t\t\t\t\t}\n\t\t\t\t\tpickerOptions={ mediaPickerOptions }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</View>\n\t);\n};\n\nexport default ImageComponent;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,OAAO,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAC3D,OAAOC,SAAS,MAAM,yBAAyB;;AAE/C;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,KAAK,EAAEC,OAAO,QAAQ,kBAAkB;AACjD,SAASC,4BAA4B,QAAQ,oBAAoB;AACjE,SAASC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA,SAASC,4BAA4B,QAAQ,SAAS;AACtD,OAAOC,MAAM,MAAM,cAAc;AACjC,OAAOC,YAAY,MAAM,cAAc;AACvC,OAAOC,kBAAkB,MAAM,wBAAwB;AAEvD,MAAMC,SAAS,GAAG;EACjBC,OAAO,EAAE,SAAS;EAClBC,WAAW,EAAE,aAAa;EAC1BC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AAED,MAAMC,cAA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GAAG,EACF,EAAIV,cAAc,IAAIC,cAAc,CAAE,IACtCc,SAAS,IACTL,GACA;IACD6E,aAAa,EAAGpF;EAAoB,CACpC,CAEG,CAAC;AAET,CAAC;AAED,eAAeb,cAAc"}
@@ -3,30 +3,64 @@ import { createElement } from "react";
3
3
  * External dependencies
4
4
  */
5
5
  import { FlatList } from 'react-native';
6
- import Animated, { useAnimatedScrollHandler } from 'react-native-reanimated';
6
+ import Animated from 'react-native-reanimated';
7
+
8
+ /**
9
+ * WordPress dependencies
10
+ */
11
+ import { forwardRef, useCallback, useImperativeHandle } from '@wordpress/element';
7
12
 
8
13
  /**
9
14
  * Internal dependencies
10
15
  */
16
+ import useScroll from './use-scroll';
11
17
  import KeyboardAvoidingView from '../keyboard-avoiding-view';
12
18
  const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
13
19
  export const KeyboardAwareFlatList = ({
14
- innerRef,
15
20
  onScroll,
16
21
  ...props
17
- }) => {
18
- const scrollHandler = useAnimatedScrollHandler({
22
+ }, ref) => {
23
+ const {
24
+ extraScrollHeight,
25
+ scrollEnabled,
26
+ shouldPreventAutomaticScroll
27
+ } = props;
28
+ const {
29
+ scrollViewRef,
30
+ scrollHandler,
31
+ scrollToSection,
32
+ scrollToElement,
33
+ onContentSizeChange,
34
+ lastScrollTo
35
+ } = useScroll({
36
+ scrollEnabled,
37
+ shouldPreventAutomaticScroll,
38
+ extraScrollHeight,
19
39
  onScroll
20
40
  });
41
+ const getFlatListRef = useCallback(flatListRef => {
42
+ // On Android, we get the ref of the associated scroll
43
+ // view to the FlatList.
44
+ scrollViewRef.current = flatListRef?.getNativeScrollRef();
45
+ }, [scrollViewRef]);
46
+ useImperativeHandle(ref, () => {
47
+ return {
48
+ scrollViewRef: scrollViewRef.current,
49
+ scrollToSection,
50
+ scrollToElement,
51
+ lastScrollTo
52
+ };
53
+ });
21
54
  return createElement(KeyboardAvoidingView, {
22
55
  style: {
23
56
  flex: 1
24
57
  }
25
58
  }, createElement(AnimatedFlatList, {
26
- ref: innerRef,
59
+ ref: getFlatListRef,
27
60
  onScroll: scrollHandler,
61
+ onContentSizeChange: onContentSizeChange,
28
62
  ...props
29
63
  }));
30
64
  };
31
- export default KeyboardAwareFlatList;
65
+ export default forwardRef(KeyboardAwareFlatList);
32
66
  //# sourceMappingURL=index.android.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["FlatList","Animated","useAnimatedScrollHandler","KeyboardAvoidingView","AnimatedFlatList","createAnimatedComponent","KeyboardAwareFlatList","innerRef","onScroll","props","scrollHandler","createElement","style","flex","ref"],"sources":["@wordpress/components/src/mobile/keyboard-aware-flat-list/index.android.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { FlatList } from 'react-native';\nimport Animated, { useAnimatedScrollHandler } from 'react-native-reanimated';\n\n/**\n * Internal dependencies\n */\nimport KeyboardAvoidingView from '../keyboard-avoiding-view';\n\nconst AnimatedFlatList = Animated.createAnimatedComponent( FlatList );\n\nexport const KeyboardAwareFlatList = ( { innerRef, onScroll, ...props } ) => {\n\tconst scrollHandler = useAnimatedScrollHandler( { onScroll } );\n\treturn (\n\t\t<KeyboardAvoidingView style={ { flex: 1 } }>\n\t\t\t<AnimatedFlatList\n\t\t\t\tref={ innerRef }\n\t\t\t\tonScroll={ scrollHandler }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</KeyboardAvoidingView>\n\t);\n};\n\nexport default KeyboardAwareFlatList;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,QAAQ,IAAIC,wBAAwB,QAAQ,yBAAyB;;AAE5E;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,2BAA2B;AAE5D,MAAMC,gBAAgB,GAAGH,QAAQ,CAACI,uBAAuB,CAAEL,QAAS,CAAC;AAErE,OAAO,MAAMM,qBAAqB,GAAGA,CAAE;EAAEC,QAAQ;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,KAAM;EAC5E,MAAMC,aAAa,GAAGR,wBAAwB,CAAE;IAAEM;EAAS,CAAE,CAAC;EAC9D,OACCG,aAAA,CAACR,oBAAoB;IAACS,KAAK,EAAG;MAAEC,IAAI,EAAE;IAAE;EAAG,GAC1CF,aAAA,CAACP,gBAAgB;IAChBU,GAAG,EAAGP,QAAU;IAChBC,QAAQ,EAAGE,aAAe;IAAA,GACrBD;EAAK,CACV,CACoB,CAAC;AAEzB,CAAC;AAED,eAAeH,qBAAqB"}
1
+ {"version":3,"names":["FlatList","Animated","forwardRef","useCallback","useImperativeHandle","useScroll","KeyboardAvoidingView","AnimatedFlatList","createAnimatedComponent","KeyboardAwareFlatList","onScroll","props","ref","extraScrollHeight","scrollEnabled","shouldPreventAutomaticScroll","scrollViewRef","scrollHandler","scrollToSection","scrollToElement","onContentSizeChange","lastScrollTo","getFlatListRef","flatListRef","current","getNativeScrollRef","createElement","style","flex"],"sources":["@wordpress/components/src/mobile/keyboard-aware-flat-list/index.android.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { FlatList } from 'react-native';\nimport Animated from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tforwardRef,\n\tuseCallback,\n\tuseImperativeHandle,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useScroll from './use-scroll';\nimport KeyboardAvoidingView from '../keyboard-avoiding-view';\n\nconst AnimatedFlatList = Animated.createAnimatedComponent( FlatList );\n\nexport const KeyboardAwareFlatList = ( { onScroll, ...props }, ref ) => {\n\tconst { extraScrollHeight, scrollEnabled, shouldPreventAutomaticScroll } =\n\t\tprops;\n\n\tconst {\n\t\tscrollViewRef,\n\t\tscrollHandler,\n\t\tscrollToSection,\n\t\tscrollToElement,\n\t\tonContentSizeChange,\n\t\tlastScrollTo,\n\t} = useScroll( {\n\t\tscrollEnabled,\n\t\tshouldPreventAutomaticScroll,\n\t\textraScrollHeight,\n\t\tonScroll,\n\t} );\n\n\tconst getFlatListRef = useCallback(\n\t\t( flatListRef ) => {\n\t\t\t// On Android, we get the ref of the associated scroll\n\t\t\t// view to the FlatList.\n\t\t\tscrollViewRef.current = flatListRef?.getNativeScrollRef();\n\t\t},\n\t\t[ scrollViewRef ]\n\t);\n\n\tuseImperativeHandle( ref, () => {\n\t\treturn {\n\t\t\tscrollViewRef: scrollViewRef.current,\n\t\t\tscrollToSection,\n\t\t\tscrollToElement,\n\t\t\tlastScrollTo,\n\t\t};\n\t} );\n\n\treturn (\n\t\t<KeyboardAvoidingView style={ { flex: 1 } }>\n\t\t\t<AnimatedFlatList\n\t\t\t\tref={ getFlatListRef }\n\t\t\t\tonScroll={ scrollHandler }\n\t\t\t\tonContentSizeChange={ onContentSizeChange }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</KeyboardAvoidingView>\n\t);\n};\n\nexport default forwardRef( KeyboardAwareFlatList );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,QAAQ,MAAM,yBAAyB;;AAE9C;AACA;AACA;AACA,SACCC,UAAU,EACVC,WAAW,EACXC,mBAAmB,QACb,oBAAoB;;AAE3B;AACA;AACA;AACA,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,oBAAoB,MAAM,2BAA2B;AAE5D,MAAMC,gBAAgB,GAAGN,QAAQ,CAACO,uBAAuB,CAAER,QAAS,CAAC;AAErE,OAAO,MAAMS,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,GAAGhB,SAAS,CAAE;IACdS,aAAa;IACbC,4BAA4B;IAC5BF,iBAAiB;IACjBH;EACD,CAAE,CAAC;EAEH,MAAMY,cAAc,GAAGnB,WAAW,CAC/BoB,WAAW,IAAM;IAClB;IACA;IACAP,aAAa,CAACQ,OAAO,GAAGD,WAAW,EAAEE,kBAAkB,CAAC,CAAC;EAC1D,CAAC,EACD,CAAET,aAAa,CAChB,CAAC;EAEDZ,mBAAmB,CAAEQ,GAAG,EAAE,MAAM;IAC/B,OAAO;MACNI,aAAa,EAAEA,aAAa,CAACQ,OAAO;MACpCN,eAAe;MACfC,eAAe;MACfE;IACD,CAAC;EACF,CAAE,CAAC;EAEH,OACCK,aAAA,CAACpB,oBAAoB;IAACqB,KAAK,EAAG;MAAEC,IAAI,EAAE;IAAE;EAAG,GAC1CF,aAAA,CAACnB,gBAAgB;IAChBK,GAAG,EAAGU,cAAgB;IACtBZ,QAAQ,EAAGO,aAAe;IAC1BG,mBAAmB,EAAGA,mBAAqB;IAAA,GACtCT;EAAK,CACV,CACoB,CAAC;AAEzB,CAAC;AAED,eAAeT,UAAU,CAAEO,qBAAsB,CAAC"}
@@ -3,111 +3,81 @@ import { createElement } from "react";
3
3
  * External dependencies
4
4
  */
5
5
 
6
- import { ScrollView, FlatList, useWindowDimensions } from 'react-native';
7
- import Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated';
6
+ import { ScrollView, FlatList } from 'react-native';
7
+ import Animated from 'react-native-reanimated';
8
8
 
9
9
  /**
10
10
  * WordPress dependencies
11
11
  */
12
- import { useCallback, useEffect, useRef } from '@wordpress/element';
12
+ import { useCallback, useEffect, forwardRef, useImperativeHandle } from '@wordpress/element';
13
13
  import { useThrottle } from '@wordpress/compose';
14
14
 
15
15
  /**
16
16
  * Internal dependencies
17
17
  */
18
+ import useScroll from './use-scroll';
18
19
  import useTextInputOffset from './use-text-input-offset';
19
- import useKeyboardOffset from './use-keyboard-offset';
20
- import useScrollToTextInput from './use-scroll-to-text-input';
21
20
  import useTextInputCaretPosition from './use-text-input-caret-position';
21
+ const DEFAULT_FONT_SIZE = 16;
22
22
  const AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);
23
23
 
24
+ /** @typedef {import('@wordpress/element').RefObject} RefObject */
24
25
  /**
25
26
  * React component that provides a FlatList that is aware of the keyboard state and can scroll
26
27
  * to the currently focused TextInput.
27
28
  *
28
- * @param {Object} props Component props.
29
- * @param {number} props.extraScrollHeight Extra scroll height for the content.
30
- * @param {Function} props.innerRef Function to pass the ScrollView ref to the parent component.
31
- * @param {Function} props.onScroll Function to be called when the list is scrolled.
32
- * @param {boolean} props.scrollEnabled Whether the list can be scrolled.
33
- * @param {Object} props.scrollViewStyle Additional style for the ScrollView component.
34
- * @param {boolean} props.shouldPreventAutomaticScroll Whether to prevent scrolling when there's a Keyboard offset set.
35
- * @param {Object} props... Other props to pass to the FlatList component.
29
+ * @param {Object} props Component props.
30
+ * @param {number} props.extraScrollHeight Extra scroll height for the content.
31
+ * @param {Function} props.onScroll Function to be called when the list is scrolled.
32
+ * @param {boolean} props.scrollEnabled Whether the list can be scrolled.
33
+ * @param {Object} props.scrollViewStyle Additional style for the ScrollView component.
34
+ * @param {boolean} props.shouldPreventAutomaticScroll Whether to prevent scrolling when there's a Keyboard offset set.
35
+ * @param {Object} props... Other props to pass to the FlatList component.
36
+ * @param {RefObject} ref
36
37
  * @return {Component} KeyboardAwareFlatList component.
37
38
  */
38
39
  export const KeyboardAwareFlatList = ({
39
40
  extraScrollHeight,
40
- innerRef,
41
41
  onScroll,
42
42
  scrollEnabled,
43
43
  scrollViewStyle,
44
44
  shouldPreventAutomaticScroll,
45
45
  ...props
46
- }) => {
47
- const scrollViewRef = useRef();
48
- const scrollViewMeasurements = useRef();
49
- const scrollViewYOffset = useSharedValue(-1);
46
+ }, ref) => {
50
47
  const {
51
- height: windowHeight,
52
- width: windowWidth
53
- } = useWindowDimensions();
54
- const isLandscape = windowWidth >= windowHeight;
55
- const [keyboardOffset] = useKeyboardOffset(scrollEnabled, shouldPreventAutomaticScroll);
56
- const [currentCaretData] = useTextInputCaretPosition(scrollEnabled);
48
+ scrollViewRef,
49
+ scrollHandler,
50
+ keyboardOffset,
51
+ scrollToSection,
52
+ scrollToElement,
53
+ onContentSizeChange,
54
+ lastScrollTo
55
+ } = useScroll({
56
+ scrollEnabled,
57
+ shouldPreventAutomaticScroll,
58
+ extraScrollHeight,
59
+ onScroll,
60
+ onSizeChange
61
+ });
57
62
  const [getTextInputOffset] = useTextInputOffset(scrollEnabled, scrollViewRef);
58
- const [scrollToTextInputOffset] = useScrollToTextInput(extraScrollHeight, keyboardOffset, scrollEnabled, scrollViewMeasurements, scrollViewRef, scrollViewYOffset);
59
63
  const onScrollToTextInput = useThrottle(useCallback(async caret => {
64
+ const {
65
+ caretHeight = DEFAULT_FONT_SIZE
66
+ } = caret !== null && caret !== void 0 ? caret : {};
60
67
  const textInputOffset = await getTextInputOffset(caret);
61
68
  const hasTextInputOffset = textInputOffset !== null;
62
69
  if (hasTextInputOffset) {
63
- scrollToTextInputOffset(caret, textInputOffset);
70
+ scrollToSection(textInputOffset, caretHeight);
64
71
  }
65
- }, [getTextInputOffset, scrollToTextInputOffset]), 200, {
72
+ }, [getTextInputOffset, scrollToSection]), 200, {
66
73
  leading: false
67
74
  });
75
+ const [currentCaretData] = useTextInputCaretPosition(scrollEnabled);
76
+ const onSizeChange = useCallback(() => onScrollToTextInput(currentCaretData), [currentCaretData, onScrollToTextInput]);
68
77
  useEffect(() => {
69
78
  onScrollToTextInput(currentCaretData);
70
79
  }, [currentCaretData, onScrollToTextInput]);
71
80
 
72
- // When the orientation changes, the ScrollView measurements
73
- // need to be re-calculated.
74
- useEffect(() => {
75
- scrollViewMeasurements.current = null;
76
- }, [isLandscape]);
77
- const scrollHandler = useAnimatedScrollHandler({
78
- onScroll: event => {
79
- const {
80
- contentOffset
81
- } = event;
82
- scrollViewYOffset.value = contentOffset.y;
83
- onScroll(event);
84
- }
85
- });
86
- const measureScrollView = useCallback(() => {
87
- if (scrollViewRef.current) {
88
- const scrollRef = scrollViewRef.current.getNativeScrollRef();
89
- scrollRef.measureInWindow((_x, y, width, height) => {
90
- scrollViewMeasurements.current = {
91
- y,
92
- width,
93
- height
94
- };
95
- });
96
- }
97
- }, []);
98
- const onContentSizeChange = useCallback(() => {
99
- onScrollToTextInput(currentCaretData);
100
-
101
- // Sets the first values when the content size changes.
102
- if (!scrollViewMeasurements.current) {
103
- measureScrollView();
104
- }
105
- }, [measureScrollView, onScrollToTextInput, currentCaretData]);
106
- const getRef = useCallback(ref => {
107
- scrollViewRef.current = ref;
108
- innerRef(ref);
109
- }, [innerRef]);
110
-
111
81
  // Adds content insets when the keyboard is opened to have
112
82
  // extra padding at the bottom.
113
83
  const contentInset = {
@@ -116,13 +86,21 @@ export const KeyboardAwareFlatList = ({
116
86
  const style = [{
117
87
  flex: 1
118
88
  }, scrollViewStyle];
89
+ useImperativeHandle(ref, () => {
90
+ return {
91
+ scrollViewRef: scrollViewRef.current,
92
+ scrollToSection,
93
+ scrollToElement,
94
+ lastScrollTo
95
+ };
96
+ });
119
97
  return createElement(AnimatedScrollView, {
120
98
  automaticallyAdjustContentInsets: false,
121
99
  contentInset: contentInset,
122
100
  keyboardShouldPersistTaps: "handled",
123
101
  onContentSizeChange: onContentSizeChange,
124
102
  onScroll: scrollHandler,
125
- ref: getRef,
103
+ ref: scrollViewRef,
126
104
  scrollEnabled: scrollEnabled,
127
105
  scrollEventThrottle: 16,
128
106
  style: style
@@ -131,5 +109,5 @@ export const KeyboardAwareFlatList = ({
131
109
  scrollEnabled: false
132
110
  }));
133
111
  };
134
- export default KeyboardAwareFlatList;
112
+ export default forwardRef(KeyboardAwareFlatList);
135
113
  //# sourceMappingURL=index.ios.js.map