@wordpress/components 19.16.0 → 19.17.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 (434) hide show
  1. package/CHANGELOG.md +40 -4
  2. package/build/base-control/index.js +6 -3
  3. package/build/base-control/index.js.map +1 -1
  4. package/build/base-control/styles/base-control-styles.js +8 -8
  5. package/build/base-control/styles/base-control-styles.js.map +1 -1
  6. package/build/border-control/styles.js +17 -25
  7. package/build/border-control/styles.js.map +1 -1
  8. package/build/box-control/all-input-control.js +2 -27
  9. package/build/box-control/all-input-control.js.map +1 -1
  10. package/build/box-control/index.js +10 -5
  11. package/build/box-control/index.js.map +1 -1
  12. package/build/box-control/styles/box-control-styles.js +17 -9
  13. package/build/box-control/styles/box-control-styles.js.map +1 -1
  14. package/build/box-control/utils.js +35 -0
  15. package/build/box-control/utils.js.map +1 -1
  16. package/build/color-picker/styles.js +10 -8
  17. package/build/color-picker/styles.js.map +1 -1
  18. package/build/combobox-control/index.js +14 -6
  19. package/build/combobox-control/index.js.map +1 -1
  20. package/build/custom-select-control/index.js +3 -1
  21. package/build/custom-select-control/index.js.map +1 -1
  22. package/build/date-time/time/index.js +6 -2
  23. package/build/date-time/time/index.js.map +1 -1
  24. package/build/date-time/time/styles.js +17 -24
  25. package/build/date-time/time/styles.js.map +1 -1
  26. package/build/external-link/index.js +6 -0
  27. package/build/external-link/index.js.map +1 -1
  28. package/build/flex/flex/component.js +9 -9
  29. package/build/flex/flex/component.js.map +1 -1
  30. package/build/flex/flex/hook.js +6 -16
  31. package/build/flex/flex/hook.js.map +1 -1
  32. package/build/flex/flex/index.js.map +1 -1
  33. package/build/flex/flex-block/component.js +9 -9
  34. package/build/flex/flex-block/component.js.map +1 -1
  35. package/build/flex/flex-block/hook.js +0 -4
  36. package/build/flex/flex-block/hook.js.map +1 -1
  37. package/build/flex/flex-block/index.js.map +1 -1
  38. package/build/flex/flex-item/component.js +9 -9
  39. package/build/flex/flex-item/component.js.map +1 -1
  40. package/build/flex/flex-item/hook.js +1 -5
  41. package/build/flex/flex-item/hook.js.map +1 -1
  42. package/build/flex/flex-item/index.js.map +1 -1
  43. package/build/flex/index.js.map +1 -1
  44. package/build/flex/styles.js +5 -5
  45. package/build/flex/styles.js.map +1 -1
  46. package/build/focal-point-picker/styles/focal-point-picker-style.js +22 -22
  47. package/build/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
  48. package/build/focal-point-picker/styles/focal-point-style.js +5 -5
  49. package/build/focal-point-picker/styles/focal-point-style.js.map +1 -1
  50. package/build/font-size-picker/index.js +15 -6
  51. package/build/font-size-picker/index.js.map +1 -1
  52. package/build/form-token-field/index.js +6 -2
  53. package/build/form-token-field/index.js.map +1 -1
  54. package/build/form-token-field/suggestions-list.js +19 -6
  55. package/build/form-token-field/suggestions-list.js.map +1 -1
  56. package/build/index.js +7 -1
  57. package/build/index.js.map +1 -1
  58. package/build/input-control/input-base.js +1 -2
  59. package/build/input-control/input-base.js.map +1 -1
  60. package/build/input-control/reducer/actions.js +3 -1
  61. package/build/input-control/reducer/actions.js.map +1 -1
  62. package/build/input-control/reducer/reducer.js +28 -11
  63. package/build/input-control/reducer/reducer.js.map +1 -1
  64. package/build/input-control/reducer/state.js.map +1 -1
  65. package/build/input-control/styles/input-control-styles.js +26 -26
  66. package/build/input-control/styles/input-control-styles.js.map +1 -1
  67. package/build/mobile/global-styles-context/utils.native.js +23 -3
  68. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  69. package/build/mobile/image/index.native.js +23 -2
  70. package/build/mobile/image/index.native.js.map +1 -1
  71. package/build/mobile/link-picker/link-picker-screen.native.js +10 -4
  72. package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  73. package/build/mobile/picker/index.ios.js +16 -3
  74. package/build/mobile/picker/index.ios.js.map +1 -1
  75. package/build/placeholder/index.js +11 -14
  76. package/build/placeholder/index.js.map +1 -1
  77. package/build/placeholder/types.js +6 -0
  78. package/build/placeholder/types.js.map +1 -0
  79. package/build/popover/index.js +113 -62
  80. package/build/popover/index.js.map +1 -1
  81. package/build/range-control/styles/range-control-styles.js +40 -40
  82. package/build/range-control/styles/range-control-styles.js.map +1 -1
  83. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +4 -4
  84. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  85. package/build/select-control/styles/select-control-styles.js +6 -6
  86. package/build/select-control/styles/select-control-styles.js.map +1 -1
  87. package/build/style-provider/index.js +10 -7
  88. package/build/style-provider/index.js.map +1 -1
  89. package/build/style-provider/types.js +6 -0
  90. package/build/style-provider/types.js.map +1 -0
  91. package/build/swatch/index.js +2 -0
  92. package/build/swatch/index.js.map +1 -1
  93. package/build/swatch/types.js +6 -0
  94. package/build/swatch/types.js.map +1 -0
  95. package/build/text/hook.js +5 -8
  96. package/build/text/hook.js.map +1 -1
  97. package/build/tools-panel/styles.js +13 -10
  98. package/build/tools-panel/styles.js.map +1 -1
  99. package/build/tools-panel/tools-panel/hook.js +1 -1
  100. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  101. package/build/ui/tooltip/styles.js +4 -4
  102. package/build/ui/tooltip/styles.js.map +1 -1
  103. package/build/unit-control/styles/unit-control-styles.js +34 -9
  104. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  105. package/build/utils/base-label.js +24 -0
  106. package/build/utils/base-label.js.map +1 -0
  107. package/build/utils/box-sizing.js +22 -0
  108. package/build/utils/box-sizing.js.map +1 -0
  109. package/build/utils/style-mixins.js +16 -0
  110. package/build/utils/style-mixins.js.map +1 -1
  111. package/build-module/base-control/index.js +7 -5
  112. package/build-module/base-control/index.js.map +1 -1
  113. package/build-module/base-control/styles/base-control-styles.js +9 -9
  114. package/build-module/base-control/styles/base-control-styles.js.map +1 -1
  115. package/build-module/border-control/styles.js +18 -26
  116. package/build-module/border-control/styles.js.map +1 -1
  117. package/build-module/box-control/all-input-control.js +3 -28
  118. package/build-module/box-control/all-input-control.js.map +1 -1
  119. package/build-module/box-control/index.js +4 -4
  120. package/build-module/box-control/index.js.map +1 -1
  121. package/build-module/box-control/styles/box-control-styles.js +18 -10
  122. package/build-module/box-control/styles/box-control-styles.js.map +1 -1
  123. package/build-module/box-control/utils.js +33 -0
  124. package/build-module/box-control/utils.js.map +1 -1
  125. package/build-module/color-picker/styles.js +9 -8
  126. package/build-module/color-picker/styles.js.map +1 -1
  127. package/build-module/combobox-control/index.js +13 -6
  128. package/build-module/combobox-control/index.js.map +1 -1
  129. package/build-module/custom-select-control/index.js +2 -1
  130. package/build-module/custom-select-control/index.js.map +1 -1
  131. package/build-module/date-time/time/index.js +6 -3
  132. package/build-module/date-time/time/index.js.map +1 -1
  133. package/build-module/date-time/time/styles.js +15 -21
  134. package/build-module/date-time/time/styles.js.map +1 -1
  135. package/build-module/external-link/index.js +6 -0
  136. package/build-module/external-link/index.js.map +1 -1
  137. package/build-module/flex/flex/component.js +9 -9
  138. package/build-module/flex/flex/component.js.map +1 -1
  139. package/build-module/flex/flex/hook.js +6 -15
  140. package/build-module/flex/flex/hook.js.map +1 -1
  141. package/build-module/flex/flex/index.js.map +1 -1
  142. package/build-module/flex/flex-block/component.js +9 -9
  143. package/build-module/flex/flex-block/component.js.map +1 -1
  144. package/build-module/flex/flex-block/hook.js +0 -4
  145. package/build-module/flex/flex-block/hook.js.map +1 -1
  146. package/build-module/flex/flex-block/index.js.map +1 -1
  147. package/build-module/flex/flex-item/component.js +9 -9
  148. package/build-module/flex/flex-item/component.js.map +1 -1
  149. package/build-module/flex/flex-item/hook.js +1 -5
  150. package/build-module/flex/flex-item/hook.js.map +1 -1
  151. package/build-module/flex/flex-item/index.js.map +1 -1
  152. package/build-module/flex/index.js.map +1 -1
  153. package/build-module/flex/styles.js +5 -5
  154. package/build-module/flex/styles.js.map +1 -1
  155. package/build-module/focal-point-picker/styles/focal-point-picker-style.js +22 -22
  156. package/build-module/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
  157. package/build-module/focal-point-picker/styles/focal-point-style.js +5 -5
  158. package/build-module/focal-point-picker/styles/focal-point-style.js.map +1 -1
  159. package/build-module/font-size-picker/index.js +14 -6
  160. package/build-module/font-size-picker/index.js.map +1 -1
  161. package/build-module/form-token-field/index.js +5 -2
  162. package/build-module/form-token-field/index.js.map +1 -1
  163. package/build-module/form-token-field/suggestions-list.js +19 -6
  164. package/build-module/form-token-field/suggestions-list.js.map +1 -1
  165. package/build-module/index.js +1 -1
  166. package/build-module/index.js.map +1 -1
  167. package/build-module/input-control/input-base.js +1 -2
  168. package/build-module/input-control/input-base.js.map +1 -1
  169. package/build-module/input-control/reducer/actions.js +1 -0
  170. package/build-module/input-control/reducer/actions.js.map +1 -1
  171. package/build-module/input-control/reducer/reducer.js +28 -11
  172. package/build-module/input-control/reducer/reducer.js.map +1 -1
  173. package/build-module/input-control/reducer/state.js.map +1 -1
  174. package/build-module/input-control/styles/input-control-styles.js +27 -27
  175. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  176. package/build-module/mobile/global-styles-context/utils.native.js +23 -4
  177. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  178. package/build-module/mobile/image/index.native.js +25 -4
  179. package/build-module/mobile/image/index.native.js.map +1 -1
  180. package/build-module/mobile/link-picker/link-picker-screen.native.js +11 -4
  181. package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  182. package/build-module/mobile/picker/index.ios.js +14 -3
  183. package/build-module/mobile/picker/index.ios.js.map +1 -1
  184. package/build-module/placeholder/index.js +10 -15
  185. package/build-module/placeholder/index.js.map +1 -1
  186. package/build-module/placeholder/types.js +2 -0
  187. package/build-module/placeholder/types.js.map +1 -0
  188. package/build-module/popover/index.js +112 -62
  189. package/build-module/popover/index.js.map +1 -1
  190. package/build-module/range-control/styles/range-control-styles.js +40 -40
  191. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  192. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +4 -4
  193. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  194. package/build-module/select-control/styles/select-control-styles.js +6 -6
  195. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  196. package/build-module/style-provider/index.js +10 -5
  197. package/build-module/style-provider/index.js.map +1 -1
  198. package/build-module/style-provider/types.js +2 -0
  199. package/build-module/style-provider/types.js.map +1 -0
  200. package/build-module/swatch/index.js +2 -0
  201. package/build-module/swatch/index.js.map +1 -1
  202. package/build-module/swatch/types.js +2 -0
  203. package/build-module/swatch/types.js.map +1 -0
  204. package/build-module/text/hook.js +5 -7
  205. package/build-module/text/hook.js.map +1 -1
  206. package/build-module/tools-panel/styles.js +12 -11
  207. package/build-module/tools-panel/styles.js.map +1 -1
  208. package/build-module/tools-panel/tools-panel/hook.js +1 -1
  209. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  210. package/build-module/ui/tooltip/styles.js +4 -4
  211. package/build-module/ui/tooltip/styles.js.map +1 -1
  212. package/build-module/unit-control/styles/unit-control-styles.js +35 -9
  213. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  214. package/build-module/utils/base-label.js +18 -0
  215. package/build-module/utils/base-label.js.map +1 -0
  216. package/build-module/utils/box-sizing.js +16 -0
  217. package/build-module/utils/box-sizing.js.map +1 -0
  218. package/build-module/utils/style-mixins.js +2 -0
  219. package/build-module/utils/style-mixins.js.map +1 -1
  220. package/build-style/style-rtl.css +50 -30
  221. package/build-style/style.css +52 -30
  222. package/build-types/base-control/index.d.ts +4 -3
  223. package/build-types/base-control/index.d.ts.map +1 -1
  224. package/build-types/base-control/stories/index.d.ts +1 -1
  225. package/build-types/base-control/stories/index.d.ts.map +1 -1
  226. package/build-types/base-control/styles/base-control-styles.d.ts.map +1 -1
  227. package/build-types/base-control/types.d.ts +0 -1
  228. package/build-types/base-control/types.d.ts.map +1 -1
  229. package/build-types/border-control/styles.d.ts.map +1 -1
  230. package/build-types/color-picker/color-display.d.ts +13 -0
  231. package/build-types/color-picker/color-display.d.ts.map +1 -0
  232. package/build-types/color-picker/styles.d.ts.map +1 -1
  233. package/build-types/date-time/time/index.d.ts.map +1 -1
  234. package/build-types/date-time/time/styles.d.ts +0 -4
  235. package/build-types/date-time/time/styles.d.ts.map +1 -1
  236. package/build-types/external-link/index.d.ts.map +1 -1
  237. package/build-types/flex/flex/component.d.ts +5 -4
  238. package/build-types/flex/flex/component.d.ts.map +1 -1
  239. package/build-types/flex/flex/hook.d.ts +5 -2
  240. package/build-types/flex/flex/hook.d.ts.map +1 -1
  241. package/build-types/flex/flex/index.d.ts +2 -2
  242. package/build-types/flex/flex/index.d.ts.map +1 -1
  243. package/build-types/flex/flex-block/component.d.ts +5 -4
  244. package/build-types/flex/flex-block/component.d.ts.map +1 -1
  245. package/build-types/flex/flex-block/hook.d.ts +6 -3
  246. package/build-types/flex/flex-block/hook.d.ts.map +1 -1
  247. package/build-types/flex/flex-block/index.d.ts +2 -2
  248. package/build-types/flex/flex-block/index.d.ts.map +1 -1
  249. package/build-types/flex/flex-item/component.d.ts +5 -4
  250. package/build-types/flex/flex-item/component.d.ts.map +1 -1
  251. package/build-types/flex/flex-item/hook.d.ts +6 -3
  252. package/build-types/flex/flex-item/hook.d.ts.map +1 -1
  253. package/build-types/flex/flex-item/index.d.ts +2 -2
  254. package/build-types/flex/flex-item/index.d.ts.map +1 -1
  255. package/build-types/flex/index.d.ts +3 -3
  256. package/build-types/flex/index.d.ts.map +1 -1
  257. package/build-types/flex/stories/index.d.ts +13 -0
  258. package/build-types/flex/stories/index.d.ts.map +1 -0
  259. package/build-types/flex/styles.d.ts +5 -5
  260. package/build-types/flex/styles.d.ts.map +1 -1
  261. package/build-types/flex/test/index.d.ts +2 -0
  262. package/build-types/flex/test/index.d.ts.map +1 -0
  263. package/build-types/flex/types.d.ts +15 -11
  264. package/build-types/flex/types.d.ts.map +1 -1
  265. package/build-types/flyout/context.d.ts +6 -0
  266. package/build-types/flyout/context.d.ts.map +1 -0
  267. package/build-types/flyout/flyout/component.d.ts +21 -0
  268. package/build-types/flyout/flyout/component.d.ts.map +1 -0
  269. package/build-types/flyout/flyout/hook.d.ts +270 -0
  270. package/build-types/flyout/flyout/hook.d.ts.map +1 -0
  271. package/build-types/flyout/flyout/index.d.ts +3 -0
  272. package/build-types/flyout/flyout/index.d.ts.map +1 -0
  273. package/build-types/flyout/flyout-content/component.d.ts +3 -0
  274. package/build-types/flyout/flyout-content/component.d.ts.map +1 -0
  275. package/build-types/flyout/flyout-content/index.d.ts +2 -0
  276. package/build-types/flyout/flyout-content/index.d.ts.map +1 -0
  277. package/build-types/flyout/index.d.ts +2 -0
  278. package/build-types/flyout/index.d.ts.map +1 -0
  279. package/build-types/flyout/styles.d.ts +22 -0
  280. package/build-types/flyout/styles.d.ts.map +1 -0
  281. package/build-types/flyout/types.d.ts +80 -0
  282. package/build-types/flyout/types.d.ts.map +1 -0
  283. package/build-types/flyout/utils.d.ts +8 -0
  284. package/build-types/flyout/utils.d.ts.map +1 -0
  285. package/build-types/form-token-field/index.d.ts.map +1 -1
  286. package/build-types/form-token-field/stories/index.d.ts +6 -0
  287. package/build-types/form-token-field/stories/index.d.ts.map +1 -1
  288. package/build-types/form-token-field/suggestions-list.d.ts +1 -1
  289. package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
  290. package/build-types/form-token-field/types.d.ts +15 -3
  291. package/build-types/form-token-field/types.d.ts.map +1 -1
  292. package/build-types/input-control/input-base.d.ts.map +1 -1
  293. package/build-types/input-control/reducer/actions.d.ts +3 -1
  294. package/build-types/input-control/reducer/actions.d.ts.map +1 -1
  295. package/build-types/input-control/reducer/reducer.d.ts +2 -2
  296. package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
  297. package/build-types/input-control/reducer/state.d.ts +2 -2
  298. package/build-types/input-control/reducer/state.d.ts.map +1 -1
  299. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  300. package/build-types/placeholder/index.d.ts +16 -0
  301. package/build-types/placeholder/index.d.ts.map +1 -0
  302. package/build-types/placeholder/stories/index.d.ts +12 -0
  303. package/build-types/placeholder/stories/index.d.ts.map +1 -0
  304. package/build-types/placeholder/types.d.ts +47 -0
  305. package/build-types/placeholder/types.d.ts.map +1 -0
  306. package/build-types/popover/index.d.ts +1 -1
  307. package/build-types/popover/index.d.ts.map +1 -1
  308. package/build-types/popover/utils.d.ts +70 -0
  309. package/build-types/popover/utils.d.ts.map +1 -0
  310. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  311. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  312. package/build-types/style-provider/index.d.ts +7 -4
  313. package/build-types/style-provider/index.d.ts.map +1 -1
  314. package/build-types/style-provider/types.d.ts +15 -0
  315. package/build-types/style-provider/types.d.ts.map +1 -0
  316. package/build-types/swatch/index.d.ts +5 -0
  317. package/build-types/swatch/index.d.ts.map +1 -0
  318. package/build-types/swatch/types.d.ts +11 -0
  319. package/build-types/swatch/types.d.ts.map +1 -0
  320. package/build-types/text/hook.d.ts.map +1 -1
  321. package/build-types/tools-panel/styles.d.ts +1 -1
  322. package/build-types/tools-panel/styles.d.ts.map +1 -1
  323. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  324. package/build-types/ui/tooltip/styles.d.ts.map +1 -1
  325. package/build-types/unit-control/index.d.ts +1 -1
  326. package/build-types/unit-control/stories/index.d.ts.map +1 -1
  327. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  328. package/build-types/unit-control/types.d.ts +1 -7
  329. package/build-types/unit-control/types.d.ts.map +1 -1
  330. package/build-types/utils/base-label.d.ts +2 -0
  331. package/build-types/utils/base-label.d.ts.map +1 -0
  332. package/build-types/utils/box-sizing.d.ts +2 -0
  333. package/build-types/utils/box-sizing.d.ts.map +1 -0
  334. package/build-types/utils/hooks/use-combined-ref.d.ts +8 -0
  335. package/build-types/utils/hooks/use-combined-ref.d.ts.map +1 -0
  336. package/build-types/utils/style-mixins.d.ts +2 -0
  337. package/package.json +17 -17
  338. package/src/base-control/index.tsx +5 -3
  339. package/src/base-control/stories/index.tsx +1 -0
  340. package/src/base-control/styles/base-control-styles.ts +9 -5
  341. package/src/base-control/types.ts +0 -1
  342. package/src/border-control/styles.ts +2 -1
  343. package/src/box-control/all-input-control.js +3 -27
  344. package/src/box-control/index.js +5 -6
  345. package/src/box-control/styles/box-control-styles.js +1 -2
  346. package/src/box-control/utils.js +32 -0
  347. package/src/color-picker/styles.ts +3 -0
  348. package/src/combobox-control/README.md +7 -0
  349. package/src/combobox-control/index.js +14 -4
  350. package/src/combobox-control/stories/index.js +49 -5
  351. package/src/custom-gradient-picker/style.scss +0 -12
  352. package/src/custom-select-control/index.js +3 -2
  353. package/src/custom-select-control/style.scss +1 -5
  354. package/src/date-time/time/index.tsx +7 -5
  355. package/src/date-time/time/styles.ts +3 -6
  356. package/src/external-link/index.tsx +10 -0
  357. package/src/flex/flex/README.md +19 -13
  358. package/src/flex/flex/{component.js → component.tsx} +15 -10
  359. package/src/flex/flex/{hook.js → hook.ts} +14 -13
  360. package/src/flex/flex/{index.js → index.ts} +0 -0
  361. package/src/flex/flex-block/README.md +3 -3
  362. package/src/flex/flex-block/{component.js → component.tsx} +15 -10
  363. package/src/flex/flex-block/{hook.js → hook.ts} +5 -5
  364. package/src/flex/flex-block/{index.js → index.ts} +0 -0
  365. package/src/flex/flex-item/README.md +6 -5
  366. package/src/flex/flex-item/{component.js → component.tsx} +15 -10
  367. package/src/flex/flex-item/{hook.js → hook.ts} +10 -7
  368. package/src/flex/flex-item/{index.js → index.ts} +0 -0
  369. package/src/flex/{index.js → index.ts} +0 -0
  370. package/src/flex/stories/index.tsx +81 -0
  371. package/src/flex/{styles.js → styles.ts} +0 -0
  372. package/src/flex/test/__snapshots__/{index.js.snap → index.tsx.snap} +49 -9
  373. package/src/flex/test/index.tsx +84 -0
  374. package/src/flex/types.ts +15 -11
  375. package/src/focal-point-picker/styles/focal-point-picker-style.js +0 -5
  376. package/src/focal-point-picker/styles/focal-point-style.js +0 -1
  377. package/src/font-size-picker/index.js +18 -7
  378. package/src/font-size-picker/stories/index.js +6 -0
  379. package/src/form-token-field/README.md +2 -1
  380. package/src/form-token-field/index.tsx +5 -2
  381. package/src/form-token-field/stories/index.tsx +14 -0
  382. package/src/form-token-field/style.scss +0 -5
  383. package/src/form-token-field/suggestions-list.tsx +21 -12
  384. package/src/form-token-field/types.ts +16 -2
  385. package/src/index.js +4 -1
  386. package/src/input-control/input-base.tsx +0 -1
  387. package/src/input-control/reducer/actions.ts +3 -1
  388. package/src/input-control/reducer/reducer.ts +27 -10
  389. package/src/input-control/reducer/state.ts +7 -2
  390. package/src/input-control/styles/input-control-styles.tsx +3 -1
  391. package/src/input-control/test/index.js +20 -4
  392. package/src/mobile/global-styles-context/utils.native.js +21 -4
  393. package/src/mobile/image/index.native.js +27 -2
  394. package/src/mobile/link-picker/link-picker-screen.native.js +12 -4
  395. package/src/mobile/picker/index.ios.js +16 -0
  396. package/src/mobile/picker/styles.native.scss +8 -0
  397. package/src/panel/style.scss +4 -1
  398. package/src/placeholder/README.md +49 -9
  399. package/src/placeholder/{index.js → index.tsx} +27 -23
  400. package/src/placeholder/stories/index.tsx +64 -0
  401. package/src/placeholder/style.scss +0 -4
  402. package/src/placeholder/types.ts +48 -0
  403. package/src/popover/README.md +7 -0
  404. package/src/popover/index.js +144 -70
  405. package/src/popover/stories/index.js +199 -98
  406. package/src/popover/style.scss +60 -6
  407. package/src/popover/test/index.js +23 -1
  408. package/src/range-control/styles/range-control-styles.ts +0 -12
  409. package/src/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +1 -1
  410. package/src/select-control/styles/select-control-styles.ts +0 -1
  411. package/src/style-provider/index.tsx +41 -0
  412. package/src/style-provider/types.ts +15 -0
  413. package/src/swatch/{index.js → index.tsx} +4 -1
  414. package/src/swatch/types.ts +11 -0
  415. package/src/text/hook.js +5 -3
  416. package/src/toggle-group-control/test/__snapshots__/index.js.snap +24 -0
  417. package/src/tools-panel/styles.ts +7 -16
  418. package/src/tools-panel/test/__snapshots__/index.js.snap +2 -11
  419. package/src/tools-panel/tools-panel/hook.ts +6 -1
  420. package/src/ui/tooltip/styles.js +1 -0
  421. package/src/ui/tooltip/test/__snapshots__/index.js.snap +1 -0
  422. package/src/unit-control/stories/index.tsx +16 -23
  423. package/src/unit-control/styles/unit-control-styles.ts +93 -41
  424. package/src/unit-control/types.ts +1 -7
  425. package/src/utils/base-label.ts +13 -0
  426. package/src/utils/box-sizing.ts +14 -0
  427. package/src/utils/style-mixins.js +2 -0
  428. package/tsconfig.json +2 -0
  429. package/tsconfig.tsbuildinfo +1 -1
  430. package/src/flex/stories/index.js +0 -29
  431. package/src/flex/test/index.js +0 -77
  432. package/src/placeholder/stories/index.js +0 -44
  433. package/src/popover/stories/_utils.js +0 -64
  434. package/src/style-provider/index.js +0 -31
@@ -34,6 +34,7 @@ import { TokensAndInputWrapperFlex } from './styles';
34
34
  import SuggestionsList from './suggestions-list';
35
35
  import type { FormTokenFieldProps, TokenItem } from './types';
36
36
  import { FlexItem } from '../flex';
37
+ import { StyledLabel } from '../base-control/styles/base-control-styles';
37
38
 
38
39
  const identity = ( value: string ) => value;
39
40
 
@@ -72,6 +73,7 @@ export function FormTokenField( props: FormTokenFieldProps ) {
72
73
  remove: __( 'Remove item' ),
73
74
  __experimentalInvalid: __( 'Invalid item' ),
74
75
  },
76
+ __experimentalRenderItem,
75
77
  __experimentalExpandOnFocus = false,
76
78
  __experimentalValidateInput = () => true,
77
79
  __experimentalShowHowTo = true,
@@ -659,12 +661,12 @@ export function FormTokenField( props: FormTokenFieldProps ) {
659
661
  /* eslint-disable jsx-a11y/no-static-element-interactions */
660
662
  return (
661
663
  <div { ...tokenFieldProps }>
662
- <label
664
+ <StyledLabel
663
665
  htmlFor={ `components-form-token-input-${ instanceId }` }
664
666
  className="components-form-token-field__label"
665
667
  >
666
668
  { label }
667
- </label>
669
+ </StyledLabel>
668
670
  <div
669
671
  ref={ tokensAndInput }
670
672
  className={ classes }
@@ -692,6 +694,7 @@ export function FormTokenField( props: FormTokenFieldProps ) {
692
694
  scrollIntoView={ selectedSuggestionScroll }
693
695
  onHover={ onSuggestionHovered }
694
696
  onSelect={ onSuggestionSelected }
697
+ __experimentalRenderItem={ __experimentalRenderItem }
695
698
  />
696
699
  ) }
697
700
  </div>
@@ -101,3 +101,17 @@ Async.args = {
101
101
  label: 'Type a continent',
102
102
  suggestions: continents,
103
103
  };
104
+
105
+ /**
106
+ * The rendered output of each suggestion can be customized by passing a
107
+ * render function to the `__experimentalRenderItem` prop. (This is still an experimental feature
108
+ * and is subject to change.)
109
+ */
110
+ export const WithCustomRenderItem: ComponentStory< typeof FormTokenField > =
111
+ DefaultTemplate.bind( {} );
112
+ WithCustomRenderItem.args = {
113
+ ...Default.args,
114
+ __experimentalRenderItem: ( { item } ) => (
115
+ <div>{ `${ item } — a nice place to visit` }</div>
116
+ ),
117
+ };
@@ -48,11 +48,6 @@
48
48
  }
49
49
  }
50
50
 
51
- .components-form-token-field__label {
52
- display: inline-block;
53
- margin-bottom: $grid-unit-10;
54
- }
55
-
56
51
  .components-form-token-field__help {
57
52
  font-size: $helptext-font-size;
58
53
  font-style: normal;
@@ -4,7 +4,7 @@
4
4
  import { map } from 'lodash';
5
5
  import scrollView from 'dom-scroll-into-view';
6
6
  import classnames from 'classnames';
7
- import type { MouseEventHandler } from 'react';
7
+ import type { MouseEventHandler, ReactNode } from 'react';
8
8
 
9
9
  /**
10
10
  * WordPress dependencies
@@ -31,6 +31,7 @@ export function SuggestionsList< T extends string | { value: string } >( {
31
31
  suggestions = [],
32
32
  displayTransform,
33
33
  instanceId,
34
+ __experimentalRenderItem,
34
35
  }: SuggestionsListProps< T > ) {
35
36
  const [ scrollingIntoView, setScrollingIntoView ] = useState( false );
36
37
 
@@ -122,6 +123,24 @@ export function SuggestionsList< T extends string | { value: string } >( {
122
123
  }
123
124
  );
124
125
 
126
+ let output: ReactNode;
127
+
128
+ if ( typeof __experimentalRenderItem === 'function' ) {
129
+ output = __experimentalRenderItem( { item: suggestion } );
130
+ } else if ( matchText ) {
131
+ output = (
132
+ <span aria-label={ displayTransform( suggestion ) }>
133
+ { matchText.suggestionBeforeMatch }
134
+ <strong className="components-form-token-field__suggestion-match">
135
+ { matchText.suggestionMatch }
136
+ </strong>
137
+ { matchText.suggestionAfterMatch }
138
+ </span>
139
+ );
140
+ } else {
141
+ output = displayTransform( suggestion );
142
+ }
143
+
125
144
  /* eslint-disable jsx-a11y/click-events-have-key-events */
126
145
  return (
127
146
  <li
@@ -139,17 +158,7 @@ export function SuggestionsList< T extends string | { value: string } >( {
139
158
  onMouseEnter={ handleHover( suggestion ) }
140
159
  aria-selected={ index === selectedIndex }
141
160
  >
142
- { matchText ? (
143
- <span aria-label={ displayTransform( suggestion ) }>
144
- { matchText.suggestionBeforeMatch }
145
- <strong className="components-form-token-field__suggestion-match">
146
- { matchText.suggestionMatch }
147
- </strong>
148
- { matchText.suggestionAfterMatch }
149
- </span>
150
- ) : (
151
- displayTransform( suggestion )
152
- ) }
161
+ { output }
153
162
  </li>
154
163
  );
155
164
  /* eslint-enable jsx-a11y/click-events-have-key-events */
@@ -1,7 +1,11 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import type { ComponentPropsWithRef, MouseEventHandler } from 'react';
4
+ import type {
5
+ ComponentPropsWithRef,
6
+ MouseEventHandler,
7
+ ReactNode,
8
+ } from 'react';
5
9
 
6
10
  type Messages = {
7
11
  /**
@@ -154,9 +158,18 @@ export interface FormTokenFieldProps
154
158
  * @default false
155
159
  */
156
160
  __next36pxDefaultSize?: boolean;
161
+ /**
162
+ * Custom renderer for suggestions.
163
+ */
164
+ __experimentalRenderItem?: ( args: { item: string } ) => ReactNode;
157
165
  }
158
166
 
159
- export interface SuggestionsListProps< T = string | { value: string } > {
167
+ /**
168
+ * `T` can be either a `string` or an object which must have a `value` prop as a string.
169
+ */
170
+ export interface SuggestionsListProps<
171
+ T = string | ( Record< string, unknown > & { value: string } )
172
+ > {
160
173
  selectedIndex: number;
161
174
  scrollIntoView: boolean;
162
175
  match: T;
@@ -165,6 +178,7 @@ export interface SuggestionsListProps< T = string | { value: string } > {
165
178
  suggestions: T[];
166
179
  displayTransform: ( value: T ) => string;
167
180
  instanceId: string | number;
181
+ __experimentalRenderItem?: ( args: { item: T } ) => ReactNode;
168
182
  }
169
183
 
170
184
  export interface TokenProps extends TokenItem {
package/src/index.js CHANGED
@@ -30,7 +30,10 @@ export {
30
30
  isEmptyBorder as __experimentalIsEmptyBorder,
31
31
  } from './border-box-control';
32
32
  export { BorderControl as __experimentalBorderControl } from './border-control';
33
- export { default as __experimentalBoxControl } from './box-control';
33
+ export {
34
+ default as __experimentalBoxControl,
35
+ applyValueToSides as __experimentalApplyValueToSides,
36
+ } from './box-control';
34
37
  export { default as Button } from './button';
35
38
  export { default as ButtonGroup } from './button-group';
36
39
  export {
@@ -101,7 +101,6 @@ export function InputBase(
101
101
  hideLabelFromVision={ hideLabelFromVision }
102
102
  labelPosition={ labelPosition }
103
103
  htmlFor={ id }
104
- size={ size }
105
104
  >
106
105
  { label }
107
106
  </Label>
@@ -10,6 +10,7 @@ import type { DragProps } from '../types';
10
10
 
11
11
  export const CHANGE = 'CHANGE';
12
12
  export const COMMIT = 'COMMIT';
13
+ export const CONTROL = 'CONTROL';
13
14
  export const DRAG_END = 'DRAG_END';
14
15
  export const DRAG_START = 'DRAG_START';
15
16
  export const DRAG = 'DRAG';
@@ -23,7 +24,7 @@ interface EventPayload {
23
24
  event?: SyntheticEvent;
24
25
  }
25
26
 
26
- interface Action< Type, ExtraPayload = {} > {
27
+ export interface Action< Type = string, ExtraPayload = {} > {
27
28
  type: Type;
28
29
  payload: EventPayload & ExtraPayload;
29
30
  }
@@ -34,6 +35,7 @@ interface ValuePayload {
34
35
 
35
36
  export type ChangeAction = Action< typeof CHANGE, ValuePayload >;
36
37
  export type CommitAction = Action< typeof COMMIT, ValuePayload >;
38
+ export type ControlAction = Action< typeof CONTROL, ValuePayload >;
37
39
  export type PressUpAction = Action< typeof PRESS_UP >;
38
40
  export type PressDownAction = Action< typeof PRESS_DOWN >;
39
41
  export type PressEnterAction = Action< typeof PRESS_ENTER >;
@@ -39,22 +39,32 @@ function mergeInitialState(
39
39
  }
40
40
 
41
41
  /**
42
- * Creates a reducer that opens the channel for external state subscription
43
- * and modification.
42
+ * Creates the base reducer which may be coupled to a specializing reducer.
43
+ * As its final step, for all actions other than CONTROL, the base reducer
44
+ * passes the state and action on through the specializing reducer. The
45
+ * exception for CONTROL actions is because they represent controlled updates
46
+ * from props and no case has yet presented for their specialization.
44
47
  *
45
- * This technique uses the "stateReducer" design pattern:
46
- * https://kentcdodds.com/blog/the-state-reducer-pattern/
47
- *
48
- * @param composedStateReducers A custom reducer that can subscribe and modify state.
48
+ * @param composedStateReducers A reducer to specialize state changes.
49
49
  * @return The reducer.
50
50
  */
51
51
  function inputControlStateReducer(
52
52
  composedStateReducers: StateReducer
53
- ): StateReducer {
53
+ ): StateReducer< actions.ControlAction > {
54
54
  return ( state, action ) => {
55
55
  const nextState = { ...state };
56
56
 
57
57
  switch ( action.type ) {
58
+ /*
59
+ * Controlled updates
60
+ */
61
+ case actions.CONTROL:
62
+ nextState.value = action.payload.value;
63
+ nextState.isDirty = false;
64
+ nextState._event = undefined;
65
+ // Returns immediately to avoid invoking additional reducers.
66
+ return nextState;
67
+
58
68
  /**
59
69
  * Keyboard events
60
70
  */
@@ -140,7 +150,7 @@ export function useInputControlStateReducer(
140
150
  initialState: Partial< InputState > = initialInputControlState,
141
151
  onChangeHandler: InputChangeCallback
142
152
  ) {
143
- const [ state, dispatch ] = useReducer< StateReducer >(
153
+ const [ state, dispatch ] = useReducer(
144
154
  inputControlStateReducer( stateReducer ),
145
155
  mergeInitialState( initialState )
146
156
  );
@@ -188,10 +198,15 @@ export function useInputControlStateReducer(
188
198
 
189
199
  const currentState = useRef( state );
190
200
  const refProps = useRef( { value: initialState.value, onChangeHandler } );
201
+
202
+ // Freshens refs to props and state so that subsequent effects have access
203
+ // to their latest values without their changes causing effect runs.
191
204
  useLayoutEffect( () => {
192
205
  currentState.current = state;
193
206
  refProps.current = { value: initialState.value, onChangeHandler };
194
207
  } );
208
+
209
+ // Propagates the latest state through onChange.
195
210
  useLayoutEffect( () => {
196
211
  if (
197
212
  currentState.current._event !== undefined &&
@@ -205,14 +220,16 @@ export function useInputControlStateReducer(
205
220
  } );
206
221
  }
207
222
  }, [ state.value, state.isDirty ] );
223
+
224
+ // Updates the state from props.
208
225
  useLayoutEffect( () => {
209
226
  if (
210
227
  initialState.value !== currentState.current.value &&
211
228
  ! currentState.current.isDirty
212
229
  ) {
213
230
  dispatch( {
214
- type: actions.RESET,
215
- payload: { value: initialState.value },
231
+ type: actions.CONTROL,
232
+ payload: { value: initialState.value ?? '' },
216
233
  } );
217
234
  }
218
235
  }, [ initialState.value ] );
@@ -6,7 +6,7 @@ import type { Reducer, SyntheticEvent } from 'react';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
- import type { InputAction } from './actions';
9
+ import type { Action, InputAction } from './actions';
10
10
 
11
11
  export interface InputState {
12
12
  _event?: SyntheticEvent;
@@ -19,7 +19,12 @@ export interface InputState {
19
19
  value?: string;
20
20
  }
21
21
 
22
- export type StateReducer = Reducer< InputState, InputAction >;
22
+ export type StateReducer< SpecializedAction = {} > = Reducer<
23
+ InputState,
24
+ SpecializedAction extends Action
25
+ ? InputAction | SpecializedAction
26
+ : InputAction
27
+ >;
23
28
 
24
29
  export const initialStateReducer: StateReducer = ( state: InputState ) => state;
25
30
 
@@ -11,7 +11,7 @@ import type { CSSProperties, ReactNode } from 'react';
11
11
  import type { WordPressComponentProps } from '../../ui/context';
12
12
  import { Flex, FlexItem } from '../../flex';
13
13
  import { Text } from '../../text';
14
- import { COLORS, rtl } from '../../utils';
14
+ import { baseLabelTypography, COLORS, rtl } from '../../utils';
15
15
  import type { LabelPosition, Size } from '../types';
16
16
  import { space } from '../../ui/utils/space';
17
17
 
@@ -272,6 +272,8 @@ const labelMargin = ( {
272
272
 
273
273
  const BaseLabel = styled( Text )< { labelPosition?: LabelPosition } >`
274
274
  &&& {
275
+ ${ baseLabelTypography };
276
+
275
277
  box-sizing: border-box;
276
278
  display: block;
277
279
  padding-top: 0;
@@ -85,9 +85,10 @@ describe( 'InputControl', () => {
85
85
  expect( spy ).toHaveBeenLastCalledWith( 'Hello there' );
86
86
  } );
87
87
 
88
- it( 'should work as a controlled component', async () => {
88
+ it( 'should work as a controlled component given normal, falsy or nullish values', async () => {
89
89
  const user = setupUser();
90
90
  const spy = jest.fn();
91
+ const heldKeySet = new Set();
91
92
  const Example = () => {
92
93
  const [ state, setState ] = useState( 'one' );
93
94
  const onChange = ( value ) => {
@@ -95,13 +96,21 @@ describe( 'InputControl', () => {
95
96
  spy( value );
96
97
  };
97
98
  const onKeyDown = ( { key } ) => {
98
- if ( key === 'Escape' ) setState( 'three' );
99
+ heldKeySet.add( key );
100
+ if ( key === 'Escape' ) {
101
+ if ( heldKeySet.has( 'Meta' ) ) setState( 'qux' );
102
+ else if ( heldKeySet.has( 'Alt' ) )
103
+ setState( undefined );
104
+ else setState( '' );
105
+ }
99
106
  };
107
+ const onKeyUp = ( { key } ) => heldKeySet.delete( key );
100
108
  return (
101
109
  <InputControl
102
110
  value={ state }
103
111
  onChange={ onChange }
104
112
  onKeyDown={ onKeyDown }
113
+ onKeyUp={ onKeyUp }
105
114
  />
106
115
  );
107
116
  };
@@ -109,10 +118,17 @@ describe( 'InputControl', () => {
109
118
  const input = getInput();
110
119
 
111
120
  await user.type( input, '2' );
112
- // Make a controlled update.
121
+ // Make a controlled update with a falsy value.
113
122
  await user.keyboard( '{Escape}' );
123
+ expect( input ).toHaveValue( '' );
114
124
 
115
- expect( input ).toHaveValue( 'three' );
125
+ // Make a controlled update with a normal value.
126
+ await user.keyboard( '{Meta>}{Escape}{/Meta}' );
127
+ expect( input ).toHaveValue( 'qux' );
128
+
129
+ // Make a controlled update with a nullish value.
130
+ await user.keyboard( '{Alt>}{Escape}{/Alt}' );
131
+ expect( input ).toHaveValue( '' );
116
132
  /*
117
133
  * onChange called only once. onChange is not called when a
118
134
  * parent component explicitly passed a (new value) change down to
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { find, startsWith, get, camelCase, has } from 'lodash';
4
+ import { find, get, camelCase, has } from 'lodash';
5
5
  import { Dimensions } from 'react-native';
6
6
 
7
7
  /**
@@ -32,6 +32,7 @@ const BLOCK_STYLE_ATTRIBUTES_MAPPING = {
32
32
 
33
33
  const PADDING = 12; // $solid-border-space
34
34
  const UNKNOWN_VALUE = 'undefined';
35
+ const DEFAULT_FONT_SIZE = 16;
35
36
 
36
37
  export function getBlockPaddings(
37
38
  mergedStyle,
@@ -103,7 +104,7 @@ export function getBlockColors(
103
104
 
104
105
  // Custom colors.
105
106
  Object.entries( blockStyleAttributes ).forEach( ( [ key, value ] ) => {
106
- const isCustomColor = startsWith( value, '#' );
107
+ const isCustomColor = value?.startsWith?.( '#' );
107
108
  let styleKey = key;
108
109
 
109
110
  if ( BLOCK_STYLE_ATTRIBUTES_MAPPING[ styleKey ] ) {
@@ -190,7 +191,7 @@ export function getBlockTypography(
190
191
 
191
192
  export function parseStylesVariables( styles, mappedValues, customValues ) {
192
193
  let stylesBase = styles;
193
- const variables = [ 'preset', 'custom', 'var' ];
194
+ const variables = [ 'preset', 'custom', 'var', 'fontSize' ];
194
195
 
195
196
  if ( ! stylesBase ) {
196
197
  return styles;
@@ -203,6 +204,7 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
203
204
  // var:preset|color|custom-color-2
204
205
  const regex = new RegExp( `var\\(--wp--${ variable }--(.*?)\\)`, 'g' );
205
206
  const varRegex = /\"var:preset\|color\|(.*?)\"/gm;
207
+ const fontSizeRegex = /"fontSize":"(.*?)"/gm;
206
208
 
207
209
  if ( variable === 'preset' ) {
208
210
  stylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {
@@ -244,6 +246,21 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
244
246
  return UNKNOWN_VALUE;
245
247
  } );
246
248
  }
249
+
250
+ if ( variable === 'fontSize' ) {
251
+ const { width, height } = Dimensions.get( 'window' );
252
+
253
+ stylesBase = stylesBase.replace( fontSizeRegex, ( _$1, $2 ) => {
254
+ const parsedFontSize =
255
+ getPxFromCssUnit( $2, {
256
+ width,
257
+ height,
258
+ fontSize: DEFAULT_FONT_SIZE,
259
+ } ) || `${ DEFAULT_FONT_SIZE }px`;
260
+
261
+ return `"fontSize":"${ parsedFontSize }"`;
262
+ } );
263
+ }
247
264
  } );
248
265
 
249
266
  return JSON.parse( stylesBase );
@@ -297,7 +314,7 @@ function normalizeFontSizes( fontSizes ) {
297
314
  {
298
315
  width: dimensions.width,
299
316
  height: dimensions.height,
300
- fontSize: 16,
317
+ fontSize: DEFAULT_FONT_SIZE,
301
318
  }
302
319
  );
303
320
  return fontSizeObject;
@@ -1,7 +1,12 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { Image as RNImage, Text, View } from 'react-native';
4
+ import {
5
+ Image as RNImage,
6
+ Text,
7
+ View,
8
+ useWindowDimensions,
9
+ } from 'react-native';
5
10
  import FastImage from 'react-native-fast-image';
6
11
 
7
12
  /**
@@ -11,7 +16,7 @@ import { __ } from '@wordpress/i18n';
11
16
  import { Icon } from '@wordpress/components';
12
17
  import { image as icon } from '@wordpress/icons';
13
18
  import { usePreferredColorSchemeStyle } from '@wordpress/compose';
14
- import { useEffect, useState } from '@wordpress/element';
19
+ import { useEffect, useState, useRef, Platform } from '@wordpress/element';
15
20
 
16
21
  /**
17
22
  * Internal dependencies
@@ -54,6 +59,10 @@ const ImageComponent = ( {
54
59
  } ) => {
55
60
  const [ imageData, setImageData ] = useState( null );
56
61
  const [ containerSize, setContainerSize ] = useState( null );
62
+ const [ shouldUseFallback, setShouldUseFallback ] = useState( false );
63
+ const { height: windowHeight, width: windowWidth } = useWindowDimensions();
64
+ const isLandscape = useRef( windowWidth > windowHeight );
65
+
57
66
  const Image = ! shouldUseFastImage ? RNImage : FastImage;
58
67
  const imageResizeMode = ! shouldUseFastImage
59
68
  ? resizeMode
@@ -80,6 +89,21 @@ const ImageComponent = ( {
80
89
  return () => ( isCurrent = false );
81
90
  }, [ url ] );
82
91
 
92
+ // Workaround for Android where changing the orientation breaks FastImage
93
+ // for now if there's any orientation changes, it will use the fallback
94
+ // prop to use the default Image component.
95
+ // https://github.com/WordPress/gutenberg/issues/42869
96
+ useEffect( () => {
97
+ if ( Platform.isAndroid && shouldUseFastImage ) {
98
+ const isCurrentOrientationLandscape = windowWidth > windowHeight;
99
+
100
+ if ( isLandscape.current !== isCurrentOrientationLandscape ) {
101
+ setShouldUseFallback( true );
102
+ isLandscape.current = isCurrentOrientationLandscape;
103
+ }
104
+ }
105
+ }, [ windowHeight, windowWidth ] );
106
+
83
107
  const onContainerLayout = ( event ) => {
84
108
  const { height, width } = event.nativeEvent.layout;
85
109
 
@@ -226,6 +250,7 @@ const ImageComponent = ( {
226
250
  resizeMethod: 'scale',
227
251
  } ) }
228
252
  resizeMode={ imageResizeMode }
253
+ fallback={ shouldUseFallback }
229
254
  />
230
255
  </View>
231
256
  ) }
@@ -3,12 +3,11 @@
3
3
  */
4
4
  import { Keyboard } from 'react-native';
5
5
  import { useNavigation, useRoute } from '@react-navigation/native';
6
- import { delay } from 'lodash';
7
6
 
8
7
  /**
9
8
  * WordPress dependencies
10
9
  */
11
- import { useMemo } from '@wordpress/element';
10
+ import { useEffect, useMemo, useRef } from '@wordpress/element';
12
11
 
13
12
  /**
14
13
  * Internal dependencies
@@ -18,10 +17,12 @@ import { LinkPicker } from './';
18
17
  const LinkPickerScreen = ( { returnScreenName } ) => {
19
18
  const navigation = useNavigation();
20
19
  const route = useRoute();
20
+ const navigateToLinkTimeoutRef = useRef( null );
21
+ const navigateBackTimeoutRef = useRef( null );
21
22
 
22
23
  const onLinkPicked = ( { url, title } ) => {
23
24
  Keyboard.dismiss();
24
- delay( () => {
25
+ navigateToLinkTimeoutRef.current = setTimeout( () => {
25
26
  navigation.navigate( returnScreenName, {
26
27
  inputValue: url,
27
28
  text: title,
@@ -31,11 +32,18 @@ const LinkPickerScreen = ( { returnScreenName } ) => {
31
32
 
32
33
  const onCancel = () => {
33
34
  Keyboard.dismiss();
34
- delay( () => {
35
+ navigateBackTimeoutRef.current = setTimeout( () => {
35
36
  navigation.goBack();
36
37
  }, 100 );
37
38
  };
38
39
 
40
+ useEffect( () => {
41
+ return () => {
42
+ clearTimeout( navigateToLinkTimeoutRef.current );
43
+ clearTimeout( navigateBackTimeoutRef.current );
44
+ };
45
+ }, [] );
46
+
39
47
  const { inputValue } = route.params;
40
48
  return useMemo( () => {
41
49
  return (
@@ -10,6 +10,12 @@ import { __ } from '@wordpress/i18n';
10
10
  import { Component, forwardRef, useContext } from '@wordpress/element';
11
11
  import { useDispatch, useSelect } from '@wordpress/data';
12
12
  import { BottomSheetContext } from '@wordpress/components';
13
+ import { usePreferredColorScheme } from '@wordpress/compose';
14
+
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ import styles from './styles.scss';
13
19
 
14
20
  class Picker extends Component {
15
21
  presentPicker() {
@@ -23,10 +29,16 @@ class Picker extends Component {
23
29
  isBottomSheetOpened,
24
30
  closeBottomSheet,
25
31
  onHandleClosingBottomSheet,
32
+ colorScheme,
26
33
  } = this.props;
27
34
  const labels = options.map( ( { label } ) => label );
28
35
  const fullOptions = [ __( 'Cancel' ) ].concat( labels );
29
36
 
37
+ const buttonTitleColor =
38
+ colorScheme === 'light'
39
+ ? styles[ 'components-picker__button-title' ].color
40
+ : styles[ 'components-picker__button-title--dark' ].color;
41
+
30
42
  ActionSheetIOS.showActionSheetWithOptions(
31
43
  {
32
44
  title,
@@ -35,6 +47,7 @@ class Picker extends Component {
35
47
  destructiveButtonIndex,
36
48
  disabledButtonIndices,
37
49
  anchor: getAnchor && getAnchor(),
50
+ tintColor: buttonTitleColor,
38
51
  },
39
52
  ( buttonIndex ) => {
40
53
  if ( buttonIndex === 0 ) {
@@ -66,6 +79,8 @@ const PickerComponent = forwardRef( ( props, ref ) => {
66
79
  const { closeGeneralSidebar } = useDispatch( 'core/edit-post' );
67
80
  const { onHandleClosingBottomSheet } = useContext( BottomSheetContext );
68
81
 
82
+ const colorScheme = usePreferredColorScheme();
83
+
69
84
  return (
70
85
  <Picker
71
86
  ref={ ref }
@@ -73,6 +88,7 @@ const PickerComponent = forwardRef( ( props, ref ) => {
73
88
  isBottomSheetOpened={ isBottomSheetOpened }
74
89
  closeBottomSheet={ closeGeneralSidebar }
75
90
  onHandleClosingBottomSheet={ onHandleClosingBottomSheet }
91
+ colorScheme={ colorScheme }
76
92
  />
77
93
  );
78
94
  } );
@@ -19,3 +19,11 @@
19
19
  padding-left: 0;
20
20
  padding-right: 0;
21
21
  }
22
+
23
+ .components-picker__button-title {
24
+ color: $blue-50;
25
+ }
26
+
27
+ .components-picker__button-title--dark {
28
+ color: $blue-30;
29
+ }
@@ -35,9 +35,12 @@
35
35
  justify-content: space-between;
36
36
  align-items: center;
37
37
  padding: 0 $grid-unit-20;
38
- height: $grid-unit-60;
39
38
  border-bottom: $border-width solid $gray-300;
40
39
 
40
+ // This helps ensure the correct panel height, including the border, avoiding subpixel rounding issues.
41
+ box-sizing: content-box;
42
+ height: $grid-unit-60 - $border-width;
43
+
41
44
  h2 {
42
45
  margin: 0;
43
46
  font-size: inherit;