@wordpress/block-editor 8.0.16 → 8.1.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 (436) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +12 -1
  4. package/build/components/block-caption/index.native.js +14 -3
  5. package/build/components/block-caption/index.native.js.map +1 -1
  6. package/build/components/block-edit/index.js +9 -0
  7. package/build/components/block-edit/index.js.map +1 -1
  8. package/build/components/block-inspector/index.js +8 -20
  9. package/build/components/block-inspector/index.js.map +1 -1
  10. package/build/components/block-list-appender/index.js +3 -11
  11. package/build/components/block-list-appender/index.js.map +1 -1
  12. package/build/components/block-media-update-progress/index.native.js +2 -1
  13. package/build/components/block-media-update-progress/index.native.js.map +1 -1
  14. package/build/components/block-preview/auto.js +10 -2
  15. package/build/components/block-preview/auto.js.map +1 -1
  16. package/build/components/block-settings/container.native.js +2 -1
  17. package/build/components/block-settings/container.native.js.map +1 -1
  18. package/build/components/block-styles/index.js +110 -134
  19. package/build/components/block-styles/index.js.map +1 -1
  20. package/build/components/block-styles/menu-items.js +63 -0
  21. package/build/components/block-styles/menu-items.js.map +1 -0
  22. package/build/components/block-styles/preview-panel.js +45 -0
  23. package/build/components/block-styles/preview-panel.js.map +1 -0
  24. package/build/components/block-styles/preview.native.js +2 -2
  25. package/build/components/block-styles/preview.native.js.map +1 -1
  26. package/build/components/block-styles/use-styles-for-block.js +119 -0
  27. package/build/components/block-styles/use-styles-for-block.js.map +1 -0
  28. package/build/components/block-styles/utils.js +39 -0
  29. package/build/components/block-styles/utils.js.map +1 -1
  30. package/build/components/block-switcher/block-styles-menu.js +3 -23
  31. package/build/components/block-switcher/block-styles-menu.js.map +1 -1
  32. package/build/components/block-tools/back-compat.js +2 -1
  33. package/build/components/block-tools/back-compat.js.map +1 -1
  34. package/build/components/block-tools/block-selection-button.js +5 -1
  35. package/build/components/block-tools/block-selection-button.js.map +1 -1
  36. package/build/components/block-tools/insertion-point.js +11 -1
  37. package/build/components/block-tools/insertion-point.js.map +1 -1
  38. package/build/components/block-types-list/index.native.js +2 -2
  39. package/build/components/block-types-list/index.native.js.map +1 -1
  40. package/build/components/button-block-appender/index.js +2 -1
  41. package/build/components/button-block-appender/index.js.map +1 -1
  42. package/build/components/colors-gradients/dropdown.js +88 -0
  43. package/build/components/colors-gradients/dropdown.js.map +1 -0
  44. package/build/components/colors-gradients/panel-color-gradient-settings.js +6 -5
  45. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  46. package/build/components/colors-gradients/panel-color-gradient-settings.native.js +6 -3
  47. package/build/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
  48. package/build/components/contrast-checker/index.js +34 -9
  49. package/build/components/contrast-checker/index.js.map +1 -1
  50. package/build/components/contrast-checker/index.native.js +108 -0
  51. package/build/components/contrast-checker/index.native.js.map +1 -0
  52. package/build/components/default-block-appender/index.js +16 -19
  53. package/build/components/default-block-appender/index.js.map +1 -1
  54. package/build/components/default-style-picker/index.js +18 -3
  55. package/build/components/default-style-picker/index.js.map +1 -1
  56. package/build/components/iframe/index.js +4 -5
  57. package/build/components/iframe/index.js.map +1 -1
  58. package/build/components/index.js +18 -9
  59. package/build/components/index.js.map +1 -1
  60. package/build/components/index.native.js +9 -0
  61. package/build/components/index.native.js.map +1 -1
  62. package/build/components/inner-blocks/default-block-appender.js +2 -4
  63. package/build/components/inner-blocks/default-block-appender.js.map +1 -1
  64. package/build/components/inner-blocks/use-nested-settings-update.js +16 -14
  65. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  66. package/build/components/inserter/index.js +61 -3
  67. package/build/components/inserter/index.js.map +1 -1
  68. package/build/components/inserter/index.native.js +1 -1
  69. package/build/components/inserter/index.native.js.map +1 -1
  70. package/build/components/inserter/library.js +5 -3
  71. package/build/components/inserter/library.js.map +1 -1
  72. package/build/components/inserter/menu.js +11 -3
  73. package/build/components/inserter/menu.js.map +1 -1
  74. package/build/components/inserter/tabs.native.js +7 -4
  75. package/build/components/inserter/tabs.native.js.map +1 -1
  76. package/build/components/inspector-controls/block-support-slot-container.js +2 -1
  77. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
  78. package/build/components/inspector-controls/block-support-tools-panel.js +11 -43
  79. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  80. package/build/components/inspector-controls/fill.native.js +3 -5
  81. package/build/components/inspector-controls/fill.native.js.map +1 -1
  82. package/build/components/inspector-controls/groups.js +2 -0
  83. package/build/components/inspector-controls/groups.js.map +1 -1
  84. package/build/components/inspector-controls/slot.js +1 -3
  85. package/build/components/inspector-controls/slot.js.map +1 -1
  86. package/build/components/letter-spacing-control/index.js +6 -6
  87. package/build/components/letter-spacing-control/index.js.map +1 -1
  88. package/build/components/link-control/link-preview.js +1 -1
  89. package/build/components/link-control/link-preview.js.map +1 -1
  90. package/build/components/link-control/search-item.js +11 -1
  91. package/build/components/link-control/search-item.js.map +1 -1
  92. package/build/components/link-control/search-results.js +2 -1
  93. package/build/components/link-control/search-results.js.map +1 -1
  94. package/build/components/link-control/use-search-handler.js +18 -5
  95. package/build/components/link-control/use-search-handler.js.map +1 -1
  96. package/build/components/list-view/block-select-button.js +23 -3
  97. package/build/components/list-view/block-select-button.js.map +1 -1
  98. package/build/components/list-view/block.js +8 -0
  99. package/build/components/list-view/block.js.map +1 -1
  100. package/build/components/media-placeholder/index.js +2 -0
  101. package/build/components/media-placeholder/index.js.map +1 -1
  102. package/build/components/media-replace-flow/index.js +32 -6
  103. package/build/components/media-replace-flow/index.js.map +1 -1
  104. package/build/components/media-upload-progress/index.native.js +2 -1
  105. package/build/components/media-upload-progress/index.native.js.map +1 -1
  106. package/build/components/panel-color-settings/index.js +7 -3
  107. package/build/components/panel-color-settings/index.js.map +1 -1
  108. package/build/components/provider/block-refs-provider.js +4 -1
  109. package/build/components/provider/block-refs-provider.js.map +1 -1
  110. package/build/components/rich-text/file-paste-handler.js +1 -1
  111. package/build/components/rich-text/file-paste-handler.js.map +1 -1
  112. package/build/components/rich-text/prevent-event-discovery.js +33 -0
  113. package/build/components/rich-text/prevent-event-discovery.js.map +1 -0
  114. package/build/components/rich-text/use-input-rules.js +3 -1
  115. package/build/components/rich-text/use-input-rules.js.map +1 -1
  116. package/build/components/selection-scroll-into-view/index.js +2 -1
  117. package/build/components/selection-scroll-into-view/index.js.map +1 -1
  118. package/build/components/use-display-block-controls/index.native.js +45 -0
  119. package/build/components/use-display-block-controls/index.native.js.map +1 -0
  120. package/build/components/use-on-block-drop/index.js +7 -3
  121. package/build/components/use-on-block-drop/index.js.map +1 -1
  122. package/build/components/writing-flow/use-multi-selection.js +3 -1
  123. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  124. package/build/hooks/border-color.js +74 -10
  125. package/build/hooks/border-color.js.map +1 -1
  126. package/build/hooks/border-radius.js +47 -0
  127. package/build/hooks/border-radius.js.map +1 -1
  128. package/build/hooks/border-style.js +41 -0
  129. package/build/hooks/border-style.js.map +1 -1
  130. package/build/hooks/border-width.js +70 -31
  131. package/build/hooks/border-width.js.map +1 -1
  132. package/build/hooks/border.js +81 -11
  133. package/build/hooks/border.js.map +1 -1
  134. package/build/hooks/color-panel.js +4 -1
  135. package/build/hooks/color-panel.js.map +1 -1
  136. package/build/hooks/color-panel.native.js +77 -0
  137. package/build/hooks/color-panel.native.js.map +1 -0
  138. package/build/hooks/color.js +6 -5
  139. package/build/hooks/color.js.map +1 -1
  140. package/build/hooks/index.native.js +2 -0
  141. package/build/hooks/index.native.js.map +1 -1
  142. package/build/hooks/layout.native.js +20 -0
  143. package/build/hooks/layout.native.js.map +1 -0
  144. package/build/hooks/letter-spacing.js +1 -1
  145. package/build/hooks/letter-spacing.js.map +1 -1
  146. package/build/hooks/typography.js +1 -1
  147. package/build/hooks/typography.js.map +1 -1
  148. package/build/store/actions.js +1 -2
  149. package/build/store/actions.js.map +1 -1
  150. package/build/store/defaults.js +5 -1
  151. package/build/store/defaults.js.map +1 -1
  152. package/build/store/defaults.native.js +2 -6
  153. package/build/store/defaults.native.js.map +1 -1
  154. package/build/store/selectors.js +10 -5
  155. package/build/store/selectors.js.map +1 -1
  156. package/build/utils/get-paste-event-data.js +1 -1
  157. package/build/utils/get-paste-event-data.js.map +1 -1
  158. package/build/utils/parse-css-unit-to-px.js +1 -1
  159. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  160. package/build-module/components/block-caption/index.native.js +13 -3
  161. package/build-module/components/block-caption/index.native.js.map +1 -1
  162. package/build-module/components/block-edit/index.js +9 -0
  163. package/build-module/components/block-edit/index.js.map +1 -1
  164. package/build-module/components/block-inspector/index.js +8 -20
  165. package/build-module/components/block-inspector/index.js.map +1 -1
  166. package/build-module/components/block-list-appender/index.js +3 -10
  167. package/build-module/components/block-list-appender/index.js.map +1 -1
  168. package/build-module/components/block-media-update-progress/index.native.js +2 -1
  169. package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
  170. package/build-module/components/block-preview/auto.js +10 -2
  171. package/build-module/components/block-preview/auto.js.map +1 -1
  172. package/build-module/components/block-settings/container.native.js +2 -1
  173. package/build-module/components/block-settings/container.native.js.map +1 -1
  174. package/build-module/components/block-styles/index.js +112 -133
  175. package/build-module/components/block-styles/index.js.map +1 -1
  176. package/build-module/components/block-styles/menu-items.js +50 -0
  177. package/build-module/components/block-styles/menu-items.js.map +1 -0
  178. package/build-module/components/block-styles/preview-panel.js +35 -0
  179. package/build-module/components/block-styles/preview-panel.js.map +1 -0
  180. package/build-module/components/block-styles/preview.native.js +2 -2
  181. package/build-module/components/block-styles/preview.native.js.map +1 -1
  182. package/build-module/components/block-styles/use-styles-for-block.js +107 -0
  183. package/build-module/components/block-styles/use-styles-for-block.js.map +1 -0
  184. package/build-module/components/block-styles/utils.js +34 -0
  185. package/build-module/components/block-styles/utils.js.map +1 -1
  186. package/build-module/components/block-switcher/block-styles-menu.js +3 -21
  187. package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
  188. package/build-module/components/block-tools/back-compat.js +2 -1
  189. package/build-module/components/block-tools/back-compat.js.map +1 -1
  190. package/build-module/components/block-tools/block-selection-button.js +5 -1
  191. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  192. package/build-module/components/block-tools/insertion-point.js +11 -1
  193. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  194. package/build-module/components/block-types-list/index.native.js +2 -2
  195. package/build-module/components/block-types-list/index.native.js.map +1 -1
  196. package/build-module/components/button-block-appender/index.js +2 -1
  197. package/build-module/components/button-block-appender/index.js.map +1 -1
  198. package/build-module/components/colors-gradients/dropdown.js +75 -0
  199. package/build-module/components/colors-gradients/dropdown.js.map +1 -0
  200. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +8 -7
  201. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  202. package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js +7 -4
  203. package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
  204. package/build-module/components/contrast-checker/index.js +34 -9
  205. package/build-module/components/contrast-checker/index.js.map +1 -1
  206. package/build-module/components/contrast-checker/index.native.js +90 -0
  207. package/build-module/components/contrast-checker/index.native.js.map +1 -0
  208. package/build-module/components/default-block-appender/index.js +15 -18
  209. package/build-module/components/default-block-appender/index.js.map +1 -1
  210. package/build-module/components/default-style-picker/index.js +17 -3
  211. package/build-module/components/default-style-picker/index.js.map +1 -1
  212. package/build-module/components/iframe/index.js +4 -5
  213. package/build-module/components/iframe/index.js.map +1 -1
  214. package/build-module/components/index.js +2 -1
  215. package/build-module/components/index.js.map +1 -1
  216. package/build-module/components/index.native.js +1 -0
  217. package/build-module/components/index.native.js.map +1 -1
  218. package/build-module/components/inner-blocks/default-block-appender.js +2 -4
  219. package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
  220. package/build-module/components/inner-blocks/use-nested-settings-update.js +16 -14
  221. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  222. package/build-module/components/inserter/index.js +61 -3
  223. package/build-module/components/inserter/index.js.map +1 -1
  224. package/build-module/components/inserter/index.native.js +2 -2
  225. package/build-module/components/inserter/index.native.js.map +1 -1
  226. package/build-module/components/inserter/library.js +5 -3
  227. package/build-module/components/inserter/library.js.map +1 -1
  228. package/build-module/components/inserter/menu.js +11 -4
  229. package/build-module/components/inserter/menu.js.map +1 -1
  230. package/build-module/components/inserter/tabs.native.js +7 -4
  231. package/build-module/components/inserter/tabs.native.js.map +1 -1
  232. package/build-module/components/inspector-controls/block-support-slot-container.js +2 -1
  233. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
  234. package/build-module/components/inspector-controls/block-support-tools-panel.js +12 -43
  235. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  236. package/build-module/components/inspector-controls/fill.native.js +3 -5
  237. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  238. package/build-module/components/inspector-controls/groups.js +2 -0
  239. package/build-module/components/inspector-controls/groups.js.map +1 -1
  240. package/build-module/components/inspector-controls/slot.js +1 -3
  241. package/build-module/components/inspector-controls/slot.js.map +1 -1
  242. package/build-module/components/letter-spacing-control/index.js +6 -6
  243. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  244. package/build-module/components/link-control/link-preview.js +1 -1
  245. package/build-module/components/link-control/link-preview.js.map +1 -1
  246. package/build-module/components/link-control/search-item.js +11 -1
  247. package/build-module/components/link-control/search-item.js.map +1 -1
  248. package/build-module/components/link-control/search-results.js +2 -1
  249. package/build-module/components/link-control/search-results.js.map +1 -1
  250. package/build-module/components/link-control/use-search-handler.js +18 -5
  251. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  252. package/build-module/components/list-view/block-select-button.js +22 -3
  253. package/build-module/components/list-view/block-select-button.js.map +1 -1
  254. package/build-module/components/list-view/block.js +6 -0
  255. package/build-module/components/list-view/block.js.map +1 -1
  256. package/build-module/components/media-placeholder/index.js +2 -0
  257. package/build-module/components/media-placeholder/index.js.map +1 -1
  258. package/build-module/components/media-replace-flow/index.js +32 -6
  259. package/build-module/components/media-replace-flow/index.js.map +1 -1
  260. package/build-module/components/media-upload-progress/index.native.js +2 -1
  261. package/build-module/components/media-upload-progress/index.native.js.map +1 -1
  262. package/build-module/components/panel-color-settings/index.js +7 -3
  263. package/build-module/components/panel-color-settings/index.js.map +1 -1
  264. package/build-module/components/provider/block-refs-provider.js +4 -1
  265. package/build-module/components/provider/block-refs-provider.js.map +1 -1
  266. package/build-module/components/rich-text/file-paste-handler.js +1 -1
  267. package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
  268. package/build-module/components/rich-text/prevent-event-discovery.js +25 -0
  269. package/build-module/components/rich-text/prevent-event-discovery.js.map +1 -0
  270. package/build-module/components/rich-text/use-input-rules.js +2 -1
  271. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  272. package/build-module/components/selection-scroll-into-view/index.js +2 -1
  273. package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
  274. package/build-module/components/use-display-block-controls/index.native.js +34 -0
  275. package/build-module/components/use-display-block-controls/index.native.js.map +1 -0
  276. package/build-module/components/use-on-block-drop/index.js +7 -3
  277. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  278. package/build-module/components/writing-flow/use-multi-selection.js +3 -4
  279. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  280. package/build-module/hooks/border-color.js +72 -12
  281. package/build-module/hooks/border-color.js.map +1 -1
  282. package/build-module/hooks/border-radius.js +42 -0
  283. package/build-module/hooks/border-radius.js.map +1 -1
  284. package/build-module/hooks/border-style.js +36 -0
  285. package/build-module/hooks/border-style.js.map +1 -1
  286. package/build-module/hooks/border-width.js +66 -32
  287. package/build-module/hooks/border-width.js.map +1 -1
  288. package/build-module/hooks/border.js +80 -12
  289. package/build-module/hooks/border.js.map +1 -1
  290. package/build-module/hooks/color-panel.js +4 -1
  291. package/build-module/hooks/color-panel.js.map +1 -1
  292. package/build-module/hooks/color-panel.native.js +62 -0
  293. package/build-module/hooks/color-panel.native.js.map +1 -0
  294. package/build-module/hooks/color.js +6 -5
  295. package/build-module/hooks/color.js.map +1 -1
  296. package/build-module/hooks/index.native.js +1 -0
  297. package/build-module/hooks/index.native.js.map +1 -1
  298. package/build-module/hooks/layout.native.js +16 -0
  299. package/build-module/hooks/layout.native.js.map +1 -0
  300. package/build-module/hooks/letter-spacing.js +1 -1
  301. package/build-module/hooks/letter-spacing.js.map +1 -1
  302. package/build-module/hooks/typography.js +1 -1
  303. package/build-module/hooks/typography.js.map +1 -1
  304. package/build-module/store/actions.js +1 -2
  305. package/build-module/store/actions.js.map +1 -1
  306. package/build-module/store/defaults.js +5 -1
  307. package/build-module/store/defaults.js.map +1 -1
  308. package/build-module/store/defaults.native.js +2 -5
  309. package/build-module/store/defaults.native.js.map +1 -1
  310. package/build-module/store/selectors.js +10 -5
  311. package/build-module/store/selectors.js.map +1 -1
  312. package/build-module/utils/get-paste-event-data.js +1 -1
  313. package/build-module/utils/get-paste-event-data.js.map +1 -1
  314. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  315. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  316. package/build-style/style-rtl.css +226 -181
  317. package/build-style/style.css +226 -181
  318. package/package.json +31 -27
  319. package/src/components/block-caption/index.native.js +22 -4
  320. package/src/components/block-card/README.md +1 -1
  321. package/src/components/block-edit/index.js +8 -0
  322. package/src/components/block-edit/test/edit.native.js +10 -9
  323. package/src/components/block-inspector/index.js +9 -16
  324. package/src/components/block-list-appender/index.js +5 -21
  325. package/src/components/block-media-update-progress/index.native.js +1 -1
  326. package/src/components/block-media-update-progress/test/index.native.js +136 -93
  327. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +108 -47
  328. package/src/components/block-mover/test/index.native.js +5 -5
  329. package/src/components/block-preview/README.md +14 -26
  330. package/src/components/block-preview/auto.js +7 -2
  331. package/src/components/block-preview/test/index.js +2 -0
  332. package/src/components/block-settings/container.native.js +1 -0
  333. package/src/components/block-styles/index.js +125 -145
  334. package/src/components/block-styles/menu-items.js +49 -0
  335. package/src/components/block-styles/preview-panel.js +36 -0
  336. package/src/components/block-styles/preview.native.js +5 -2
  337. package/src/components/block-styles/style.scss +59 -51
  338. package/src/components/block-styles/test/{index.js → utils.js} +60 -1
  339. package/src/components/block-styles/use-styles-for-block.js +99 -0
  340. package/src/components/block-styles/utils.js +39 -0
  341. package/src/components/block-switcher/block-styles-menu.js +3 -38
  342. package/src/components/block-tools/back-compat.js +1 -0
  343. package/src/components/block-tools/block-selection-button.js +7 -1
  344. package/src/components/block-tools/insertion-point.js +10 -1
  345. package/src/components/block-types-list/index.native.js +5 -2
  346. package/src/components/border-radius-control/style.scss +1 -1
  347. package/src/components/border-style-control/style.scss +0 -1
  348. package/src/components/button-block-appender/index.js +1 -0
  349. package/src/components/color-palette/test/__snapshots__/control.js.snap +9 -4
  350. package/src/components/colors-gradients/dropdown.js +96 -0
  351. package/src/components/colors-gradients/panel-color-gradient-settings.js +23 -19
  352. package/src/components/colors-gradients/panel-color-gradient-settings.native.js +13 -2
  353. package/src/components/colors-gradients/style.scss +59 -5
  354. package/src/components/contrast-checker/README.md +3 -1
  355. package/src/components/contrast-checker/index.js +48 -20
  356. package/src/components/contrast-checker/index.native.js +113 -0
  357. package/src/components/contrast-checker/style.native.scss +26 -0
  358. package/src/components/contrast-checker/test/index.js +65 -0
  359. package/src/components/default-block-appender/index.js +17 -24
  360. package/src/components/default-block-appender/style.scss +4 -0
  361. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +12 -24
  362. package/src/components/default-block-appender/test/index.js +4 -14
  363. package/src/components/default-style-picker/index.js +18 -6
  364. package/src/components/iframe/index.js +7 -3
  365. package/src/components/index.js +2 -1
  366. package/src/components/index.native.js +1 -0
  367. package/src/components/inner-blocks/README.md +2 -0
  368. package/src/components/inner-blocks/default-block-appender.js +2 -7
  369. package/src/components/inner-blocks/use-nested-settings-update.js +16 -14
  370. package/src/components/inserter/index.js +77 -5
  371. package/src/components/inserter/index.native.js +2 -2
  372. package/src/components/inserter/library.js +17 -12
  373. package/src/components/inserter/menu.js +31 -13
  374. package/src/components/inserter/tabs.native.js +5 -4
  375. package/src/components/inserter/test/block-types-tab.native.js +9 -10
  376. package/src/components/inserter/test/index.native.js +3 -7
  377. package/src/components/inserter/test/reusable-blocks-tab.native.js +8 -10
  378. package/src/components/inspector-controls/block-support-slot-container.js +3 -1
  379. package/src/components/inspector-controls/block-support-tools-panel.js +39 -58
  380. package/src/components/inspector-controls/fill.native.js +4 -3
  381. package/src/components/inspector-controls/groups.js +2 -0
  382. package/src/components/inspector-controls/slot.js +2 -7
  383. package/src/components/letter-spacing-control/index.js +6 -6
  384. package/src/components/link-control/README.md +1 -1
  385. package/src/components/link-control/link-preview.js +1 -1
  386. package/src/components/link-control/search-item.js +11 -2
  387. package/src/components/link-control/search-results.js +1 -0
  388. package/src/components/link-control/style.scss +2 -1
  389. package/src/components/link-control/test/index.js +4 -0
  390. package/src/components/link-control/use-search-handler.js +25 -4
  391. package/src/components/list-view/block-select-button.js +20 -1
  392. package/src/components/list-view/block.js +10 -0
  393. package/src/components/media-placeholder/index.js +2 -0
  394. package/src/components/media-replace-flow/index.js +35 -5
  395. package/src/components/media-upload/test/index.native.js +28 -47
  396. package/src/components/media-upload-progress/index.native.js +1 -0
  397. package/src/components/media-upload-progress/test/index.native.js +60 -47
  398. package/src/components/panel-color-settings/index.js +8 -4
  399. package/src/components/provider/block-refs-provider.js +4 -1
  400. package/src/components/rich-text/file-paste-handler.js +3 -1
  401. package/src/components/rich-text/prevent-event-discovery.js +23 -0
  402. package/src/components/rich-text/use-input-rules.js +2 -1
  403. package/src/components/selection-scroll-into-view/index.js +1 -0
  404. package/src/components/url-input/README.md +5 -0
  405. package/src/components/use-display-block-controls/index.native.js +38 -0
  406. package/src/components/use-on-block-drop/index.js +7 -3
  407. package/src/components/writing-flow/test/use-multi-selection.js +36 -0
  408. package/src/components/writing-flow/use-multi-selection.js +12 -9
  409. package/src/hooks/border-color.js +69 -9
  410. package/src/hooks/border-radius.js +32 -0
  411. package/src/hooks/border-style.js +26 -0
  412. package/src/hooks/border-width.js +56 -32
  413. package/src/hooks/border.js +115 -20
  414. package/src/hooks/border.scss +3 -17
  415. package/src/hooks/color-panel.js +3 -0
  416. package/src/hooks/color-panel.native.js +63 -0
  417. package/src/hooks/color.js +8 -7
  418. package/src/hooks/dimensions.scss +5 -0
  419. package/src/hooks/index.native.js +1 -0
  420. package/src/hooks/layout.native.js +23 -0
  421. package/src/hooks/letter-spacing.js +1 -1
  422. package/src/hooks/typography.js +1 -1
  423. package/src/store/actions.js +1 -2
  424. package/src/store/defaults.js +2 -0
  425. package/src/store/defaults.native.js +2 -6
  426. package/src/store/selectors.js +10 -5
  427. package/src/style.scss +4 -3
  428. package/src/utils/get-paste-event-data.js +1 -1
  429. package/src/utils/parse-css-unit-to-px.js +1 -1
  430. package/src/utils/test/parse-css-unit-to-px.js +3 -0
  431. package/tsconfig.tsbuildinfo +1 -1
  432. package/build/components/use-canvas-click-redirect/index.js +0 -66
  433. package/build/components/use-canvas-click-redirect/index.js.map +0 -1
  434. package/build-module/components/use-canvas-click-redirect/index.js +0 -54
  435. package/build-module/components/use-canvas-click-redirect/index.js.map +0 -1
  436. package/src/components/use-canvas-click-redirect/index.js +0 -57
@@ -13,19 +13,15 @@ var _lodash = require("lodash");
13
13
 
14
14
  var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
- var _data = require("@wordpress/data");
16
+ var _compose = require("@wordpress/compose");
17
17
 
18
18
  var _keycodes = require("@wordpress/keycodes");
19
19
 
20
- var _i18n = require("@wordpress/i18n");
20
+ var _components = require("@wordpress/components");
21
21
 
22
- var _blocks = require("@wordpress/blocks");
22
+ var _previewPanel = _interopRequireDefault(require("./preview-panel"));
23
23
 
24
- var _utils = require("./utils");
25
-
26
- var _blockPreview = _interopRequireDefault(require("../block-preview"));
27
-
28
- var _store = require("../../store");
24
+ var _useStylesForBlock = _interopRequireDefault(require("./use-styles-for-block"));
29
25
 
30
26
  /**
31
27
  * External dependencies
@@ -38,151 +34,131 @@ var _store = require("../../store");
38
34
  /**
39
35
  * Internal dependencies
40
36
  */
41
- const EMPTY_OBJECT = {};
42
-
43
- function useGenericPreviewBlock(block, type) {
44
- return (0, _element.useMemo)(() => {
45
- const example = type === null || type === void 0 ? void 0 : type.example;
46
- const blockName = type === null || type === void 0 ? void 0 : type.name;
47
-
48
- if (example && blockName) {
49
- return (0, _blocks.getBlockFromExample)(blockName, {
50
- attributes: example.attributes,
51
- innerBlocks: example.innerBlocks
52
- });
53
- }
54
-
55
- if (block) {
56
- return (0, _blocks.cloneBlock)(block);
57
- }
58
- }, [type !== null && type !== void 0 && type.example ? block === null || block === void 0 ? void 0 : block.name : block, type]);
37
+ function BlockStylesPreviewPanelSlot(_ref) {
38
+ let {
39
+ scope
40
+ } = _ref;
41
+ return (0, _element.createElement)(_components.Slot, {
42
+ name: `BlockStylesPreviewPanel/${scope}`
43
+ });
59
44
  }
60
45
 
61
- function BlockStyles(_ref) {
46
+ function BlockStylesPreviewPanelFill(_ref2) {
47
+ let {
48
+ children,
49
+ scope,
50
+ ...props
51
+ } = _ref2;
52
+ return (0, _element.createElement)(_components.Fill, {
53
+ name: `BlockStylesPreviewPanel/${scope}`
54
+ }, (0, _element.createElement)("div", props, children));
55
+ } // Top position (in px) of the Block Styles container
56
+ // relative to the editor pane.
57
+ // The value is the equivalent of the container's right position.
58
+
59
+
60
+ const DEFAULT_POSITION_TOP = 16; // Block Styles component for the Settings Sidebar.
61
+
62
+ function BlockStyles(_ref3) {
62
63
  let {
63
64
  clientId,
64
65
  onSwitch = _lodash.noop,
65
66
  onHoverClassName = _lodash.noop,
66
- itemRole
67
- } = _ref;
68
-
69
- const selector = select => {
70
- const {
71
- getBlock
72
- } = select(_store.store);
73
- const block = getBlock(clientId);
67
+ scope
68
+ } = _ref3;
69
+ const {
70
+ onSelect,
71
+ stylesToRender,
72
+ activeStyle,
73
+ genericPreviewBlock,
74
+ className: previewClassName
75
+ } = (0, _useStylesForBlock.default)({
76
+ clientId,
77
+ onSwitch
78
+ });
79
+ const [hoveredStyle, setHoveredStyle] = (0, _element.useState)(null);
80
+ const [containerScrollTop, setContainerScrollTop] = (0, _element.useState)(0);
81
+ const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
82
+ (0, _element.useLayoutEffect)(() => {
83
+ const scrollContainer = document.querySelector('.interface-interface-skeleton__content');
84
+ const scrollTop = (scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTop) || 0;
85
+ setContainerScrollTop(scrollTop + DEFAULT_POSITION_TOP);
86
+ }, [hoveredStyle]);
87
+
88
+ if (!stylesToRender || stylesToRender.length === 0) {
89
+ return null;
90
+ }
74
91
 
75
- if (!block) {
76
- return EMPTY_OBJECT;
77
- }
92
+ const debouncedSetHoveredStyle = (0, _lodash.debounce)(setHoveredStyle, 250);
78
93
 
79
- const blockType = (0, _blocks.getBlockType)(block.name);
80
- const {
81
- getBlockStyles
82
- } = select(_blocks.store);
83
- return {
84
- block,
85
- type: blockType,
86
- styles: getBlockStyles(block.name),
87
- className: block.attributes.className || ''
88
- };
94
+ const onSelectStylePreview = style => {
95
+ onSelect(style);
96
+ onHoverClassName(null);
97
+ setHoveredStyle(null);
98
+ debouncedSetHoveredStyle.cancel();
89
99
  };
90
100
 
91
- const {
92
- styles,
93
- block,
94
- type,
95
- className
96
- } = (0, _data.useSelect)(selector, [clientId]);
97
- const {
98
- updateBlockAttributes
99
- } = (0, _data.useDispatch)(_store.store);
100
- const genericPreviewBlock = useGenericPreviewBlock(block, type);
101
+ const styleItemHandler = item => {
102
+ var _item$name;
101
103
 
102
- if (!styles || styles.length === 0) {
103
- return null;
104
- }
104
+ if (hoveredStyle === item) {
105
+ debouncedSetHoveredStyle.cancel();
106
+ return;
107
+ }
108
+
109
+ debouncedSetHoveredStyle(item);
110
+ onHoverClassName((_item$name = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name !== void 0 ? _item$name : null);
111
+ };
105
112
 
106
- const renderedStyles = (0, _lodash.find)(styles, 'isDefault') ? styles : [{
107
- name: 'default',
108
- label: (0, _i18n._x)('Default', 'block style'),
109
- isDefault: true
110
- }, ...styles];
111
- const activeStyle = (0, _utils.getActiveStyle)(renderedStyles, className);
112
113
  return (0, _element.createElement)("div", {
113
114
  className: "block-editor-block-styles"
114
- }, renderedStyles.map(style => {
115
- var _type$example$viewpor, _type$example;
116
-
117
- const styleClassName = (0, _utils.replaceActiveStyle)(className, activeStyle, style);
118
- return (0, _element.createElement)(BlockStyleItem, {
119
- genericPreviewBlock: genericPreviewBlock,
120
- viewportWidth: (_type$example$viewpor = (_type$example = type.example) === null || _type$example === void 0 ? void 0 : _type$example.viewportWidth) !== null && _type$example$viewpor !== void 0 ? _type$example$viewpor : 500,
121
- className: className,
122
- isActive: activeStyle === style,
115
+ }, (0, _element.createElement)("div", {
116
+ className: "block-editor-block-styles__variants"
117
+ }, stylesToRender.map(style => {
118
+ const buttonText = style.label || style.name;
119
+ return (0, _element.createElement)(_components.Button, {
120
+ className: (0, _classnames.default)('block-editor-block-styles__item', {
121
+ 'is-active': activeStyle.name === style.name
122
+ }),
123
123
  key: style.name,
124
- onSelect: () => {
125
- updateBlockAttributes(clientId, {
126
- className: styleClassName
127
- });
128
- onHoverClassName(null);
129
- onSwitch();
124
+ variant: "secondary",
125
+ label: buttonText,
126
+ onMouseEnter: () => styleItemHandler(style),
127
+ onFocus: () => styleItemHandler(style),
128
+ onMouseLeave: () => styleItemHandler(null),
129
+ onBlur: () => styleItemHandler(null),
130
+ onKeyDown: event => {
131
+ if (_keycodes.ENTER === event.keyCode || _keycodes.SPACE === event.keyCode) {
132
+ event.preventDefault();
133
+ onSelectStylePreview(style);
134
+ }
130
135
  },
131
- onBlur: () => onHoverClassName(null),
132
- onHover: () => onHoverClassName(styleClassName),
133
- style: style,
134
- styleClassName: styleClassName,
135
- itemRole: itemRole
136
- });
137
- }));
138
- }
139
-
140
- function BlockStyleItem(_ref2) {
141
- let {
142
- genericPreviewBlock,
143
- viewportWidth,
144
- style,
145
- isActive,
146
- onBlur,
147
- onHover,
148
- onSelect,
149
- styleClassName,
150
- itemRole
151
- } = _ref2;
152
- const previewBlocks = (0, _element.useMemo)(() => {
153
- return { ...genericPreviewBlock,
154
- attributes: { ...genericPreviewBlock.attributes,
155
- className: styleClassName
156
- }
157
- };
158
- }, [genericPreviewBlock, styleClassName]);
159
- return (0, _element.createElement)("div", {
160
- key: style.name,
161
- className: (0, _classnames.default)('block-editor-block-styles__item', {
162
- 'is-active': isActive
163
- }),
164
- onClick: () => onSelect(),
165
- onKeyDown: event => {
166
- if (_keycodes.ENTER === event.keyCode || _keycodes.SPACE === event.keyCode) {
167
- event.preventDefault();
168
- onSelect();
169
- }
136
+ onClick: () => onSelectStylePreview(style),
137
+ role: "button",
138
+ tabIndex: "0"
139
+ }, (0, _element.createElement)(_components.__experimentalText, {
140
+ as: "span",
141
+ limit: 12,
142
+ ellipsizeMode: "tail",
143
+ className: "block-editor-block-styles__item-text",
144
+ truncate: true
145
+ }, buttonText));
146
+ })), hoveredStyle && !isMobileViewport && (0, _element.createElement)(BlockStylesPreviewPanelFill, {
147
+ scope: scope,
148
+ className: "block-editor-block-styles__preview-panel",
149
+ style: {
150
+ top: containerScrollTop
170
151
  },
171
- onMouseEnter: onHover,
172
- onMouseLeave: onBlur,
173
- role: itemRole || 'button',
174
- tabIndex: "0",
175
- "aria-label": style.label || style.name
176
- }, (0, _element.createElement)("div", {
177
- className: "block-editor-block-styles__item-preview"
178
- }, (0, _element.createElement)(_blockPreview.default, {
179
- viewportWidth: viewportWidth,
180
- blocks: previewBlocks
181
- })), (0, _element.createElement)("div", {
182
- className: "block-editor-block-styles__item-label"
183
- }, style.label || style.name));
152
+ onMouseLeave: () => styleItemHandler(null)
153
+ }, (0, _element.createElement)(_previewPanel.default, {
154
+ activeStyle: activeStyle,
155
+ className: previewClassName,
156
+ genericPreviewBlock: genericPreviewBlock,
157
+ style: hoveredStyle
158
+ })));
184
159
  }
185
160
 
161
+ BlockStyles.Slot = BlockStylesPreviewPanelSlot;
186
162
  var _default = BlockStyles;
187
163
  exports.default = _default;
188
164
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"names":["EMPTY_OBJECT","useGenericPreviewBlock","block","type","example","blockName","name","attributes","innerBlocks","BlockStyles","clientId","onSwitch","noop","onHoverClassName","itemRole","selector","select","getBlock","blockEditorStore","blockType","getBlockStyles","blocksStore","styles","className","updateBlockAttributes","genericPreviewBlock","length","renderedStyles","label","isDefault","activeStyle","map","style","styleClassName","viewportWidth","BlockStyleItem","isActive","onBlur","onHover","onSelect","previewBlocks","event","ENTER","keyCode","SPACE","preventDefault"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAUA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAIA;AACA;AACA;;AAYA;AACA;AACA;AAKA,MAAMA,YAAY,GAAG,EAArB;;AAEA,SAASC,sBAAT,CAAiCC,KAAjC,EAAwCC,IAAxC,EAA+C;AAC9C,SAAO,sBAAS,MAAM;AACrB,UAAMC,OAAO,GAAGD,IAAH,aAAGA,IAAH,uBAAGA,IAAI,CAAEC,OAAtB;AACA,UAAMC,SAAS,GAAGF,IAAH,aAAGA,IAAH,uBAAGA,IAAI,CAAEG,IAAxB;;AAEA,QAAKF,OAAO,IAAIC,SAAhB,EAA4B;AAC3B,aAAO,iCAAqBA,SAArB,EAAgC;AACtCE,QAAAA,UAAU,EAAEH,OAAO,CAACG,UADkB;AAEtCC,QAAAA,WAAW,EAAEJ,OAAO,CAACI;AAFiB,OAAhC,CAAP;AAIA;;AAED,QAAKN,KAAL,EAAa;AACZ,aAAO,wBAAYA,KAAZ,CAAP;AACA;AACD,GAdM,EAcJ,CAAEC,IAAI,SAAJ,IAAAA,IAAI,WAAJ,IAAAA,IAAI,CAAEC,OAAN,GAAgBF,KAAhB,aAAgBA,KAAhB,uBAA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Content":["/**\n * External dependencies\n */\nimport { find, noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ENTER, SPACE } from '@wordpress/keycodes';\nimport { _x } from '@wordpress/i18n';\nimport {\n\tgetBlockType,\n\tcloneBlock,\n\tgetBlockFromExample,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getActiveStyle, replaceActiveStyle } from './utils';\nimport BlockPreview from '../block-preview';\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_OBJECT = {};\n\nfunction useGenericPreviewBlock( block, type ) {\n\treturn useMemo( () => {\n\t\tconst example = type?.example;\n\t\tconst blockName = type?.name;\n\n\t\tif ( example && blockName ) {\n\t\t\treturn getBlockFromExample( blockName, {\n\t\t\t\tattributes: example.attributes,\n\t\t\t\tinnerBlocks: example.innerBlocks,\n\t\t\t} );\n\t\t}\n\n\t\tif ( block ) {\n\t\t\treturn cloneBlock( block );\n\t\t}\n\t}, [ type?.example ? block?.name : block, type ] );\n}\n\nfunction BlockStyles( {\n\tclientId,\n\tonSwitch = noop,\n\tonHoverClassName = noop,\n\titemRole,\n} ) {\n\tconst selector = ( select ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\t\tconst block = getBlock( clientId );\n\n\t\tif ( ! block ) {\n\t\t\treturn EMPTY_OBJECT;\n\t\t}\n\n\t\tconst blockType = getBlockType( block.name );\n\t\tconst { getBlockStyles } = select( blocksStore );\n\t\treturn {\n\t\t\tblock,\n\t\t\ttype: blockType,\n\t\t\tstyles: getBlockStyles( block.name ),\n\t\t\tclassName: block.attributes.className || '',\n\t\t};\n\t};\n\n\tconst { styles, block, type, className } = useSelect( selector, [\n\t\tclientId,\n\t] );\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst genericPreviewBlock = useGenericPreviewBlock( block, type );\n\n\tif ( ! styles || styles.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst renderedStyles = find( styles, 'isDefault' )\n\t\t? styles\n\t\t: [\n\t\t\t\t{\n\t\t\t\t\tname: 'default',\n\t\t\t\t\tlabel: _x( 'Default', 'block style' ),\n\t\t\t\t\tisDefault: true,\n\t\t\t\t},\n\t\t\t\t...styles,\n\t\t ];\n\n\tconst activeStyle = getActiveStyle( renderedStyles, className );\n\treturn (\n\t\t<div className=\"block-editor-block-styles\">\n\t\t\t{ renderedStyles.map( ( style ) => {\n\t\t\t\tconst styleClassName = replaceActiveStyle(\n\t\t\t\t\tclassName,\n\t\t\t\t\tactiveStyle,\n\t\t\t\t\tstyle\n\t\t\t\t);\n\t\t\t\treturn (\n\t\t\t\t\t<BlockStyleItem\n\t\t\t\t\t\tgenericPreviewBlock={ genericPreviewBlock }\n\t\t\t\t\t\tviewportWidth={ type.example?.viewportWidth ?? 500 }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tisActive={ activeStyle === style }\n\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\t\t\t\tclassName: styleClassName,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tonHoverClassName( null );\n\t\t\t\t\t\t\tonSwitch();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonBlur={ () => onHoverClassName( null ) }\n\t\t\t\t\t\tonHover={ () => onHoverClassName( styleClassName ) }\n\t\t\t\t\t\tstyle={ style }\n\t\t\t\t\t\tstyleClassName={ styleClassName }\n\t\t\t\t\t\titemRole={ itemRole }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n\nfunction BlockStyleItem( {\n\tgenericPreviewBlock,\n\tviewportWidth,\n\tstyle,\n\tisActive,\n\tonBlur,\n\tonHover,\n\tonSelect,\n\tstyleClassName,\n\titemRole,\n} ) {\n\tconst previewBlocks = useMemo( () => {\n\t\treturn {\n\t\t\t...genericPreviewBlock,\n\t\t\tattributes: {\n\t\t\t\t...genericPreviewBlock.attributes,\n\t\t\t\tclassName: styleClassName,\n\t\t\t},\n\t\t};\n\t}, [ genericPreviewBlock, styleClassName ] );\n\n\treturn (\n\t\t<div\n\t\t\tkey={ style.name }\n\t\t\tclassName={ classnames( 'block-editor-block-styles__item', {\n\t\t\t\t'is-active': isActive,\n\t\t\t} ) }\n\t\t\tonClick={ () => onSelect() }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( ENTER === event.keyCode || SPACE === event.keyCode ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonSelect();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonMouseEnter={ onHover }\n\t\t\tonMouseLeave={ onBlur }\n\t\t\trole={ itemRole || 'button' }\n\t\t\ttabIndex=\"0\"\n\t\t\taria-label={ style.label || style.name }\n\t\t>\n\t\t\t<div className=\"block-editor-block-styles__item-preview\">\n\t\t\t\t<BlockPreview\n\t\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\t\tblocks={ previewBlocks }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-block-styles__item-label\">\n\t\t\t\t{ style.label || style.name }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default BlockStyles;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"names":["BlockStylesPreviewPanelSlot","scope","BlockStylesPreviewPanelFill","children","props","DEFAULT_POSITION_TOP","BlockStyles","clientId","onSwitch","noop","onHoverClassName","onSelect","stylesToRender","activeStyle","genericPreviewBlock","className","previewClassName","hoveredStyle","setHoveredStyle","containerScrollTop","setContainerScrollTop","isMobileViewport","scrollContainer","document","querySelector","scrollTop","length","debouncedSetHoveredStyle","onSelectStylePreview","style","cancel","styleItemHandler","item","name","map","buttonText","label","event","ENTER","keyCode","SPACE","preventDefault","top","Slot"],"mappings":";;;;;;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W,CAACqC,IAAZ,GAAmB3C,2BAAnB;eACeM,W","sourcesContent":["/**\n * External dependencies\n */\nimport { noop, debounce } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useLayoutEffect } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { ENTER, SPACE } from '@wordpress/keycodes';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\tSlot,\n\tFill,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockStylesPreviewPanel from './preview-panel';\nimport useStylesForBlocks from './use-styles-for-block';\n\nfunction BlockStylesPreviewPanelSlot( { scope } ) {\n\treturn <Slot name={ `BlockStylesPreviewPanel/${ scope }` } />;\n}\n\nfunction BlockStylesPreviewPanelFill( { children, scope, ...props } ) {\n\treturn (\n\t\t<Fill name={ `BlockStylesPreviewPanel/${ scope }` }>\n\t\t\t<div { ...props }>{ children }</div>\n\t\t</Fill>\n\t);\n}\n\n// Top position (in px) of the Block Styles container\n// relative to the editor pane.\n// The value is the equivalent of the container's right position.\nconst DEFAULT_POSITION_TOP = 16;\n\n// Block Styles component for the Settings Sidebar.\nfunction BlockStyles( {\n\tclientId,\n\tonSwitch = noop,\n\tonHoverClassName = noop,\n\tscope,\n} ) {\n\tconst {\n\t\tonSelect,\n\t\tstylesToRender,\n\t\tactiveStyle,\n\t\tgenericPreviewBlock,\n\t\tclassName: previewClassName,\n\t} = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\tconst [ hoveredStyle, setHoveredStyle ] = useState( null );\n\tconst [ containerScrollTop, setContainerScrollTop ] = useState( 0 );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tuseLayoutEffect( () => {\n\t\tconst scrollContainer = document.querySelector(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tconst scrollTop = scrollContainer?.scrollTop || 0;\n\t\tsetContainerScrollTop( scrollTop + DEFAULT_POSITION_TOP );\n\t}, [ hoveredStyle ] );\n\n\tif ( ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst debouncedSetHoveredStyle = debounce( setHoveredStyle, 250 );\n\n\tconst onSelectStylePreview = ( style ) => {\n\t\tonSelect( style );\n\t\tonHoverClassName( null );\n\t\tsetHoveredStyle( null );\n\t\tdebouncedSetHoveredStyle.cancel();\n\t};\n\n\tconst styleItemHandler = ( item ) => {\n\t\tif ( hoveredStyle === item ) {\n\t\t\tdebouncedSetHoveredStyle.cancel();\n\t\t\treturn;\n\t\t}\n\t\tdebouncedSetHoveredStyle( item );\n\t\tonHoverClassName( item?.name ?? null );\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-block-styles\">\n\t\t\t<div className=\"block-editor-block-styles__variants\">\n\t\t\t\t{ stylesToRender.map( ( style ) => {\n\t\t\t\t\tconst buttonText = style.label || style.name;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-block-styles__item',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-active':\n\t\t\t\t\t\t\t\t\t\tactiveStyle.name === style.name,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tlabel={ buttonText }\n\t\t\t\t\t\t\tonMouseEnter={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonFocus={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonBlur={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tENTER === event.keyCode ||\n\t\t\t\t\t\t\t\t\tSPACE === event.keyCode\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tonSelectStylePreview( style );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ () => onSelectStylePreview( style ) }\n\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\ttabIndex=\"0\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tlimit={ 12 }\n\t\t\t\t\t\t\t\tellipsizeMode=\"tail\"\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__item-text\"\n\t\t\t\t\t\t\t\ttruncate\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonText }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t\t{ hoveredStyle && ! isMobileViewport && (\n\t\t\t\t<BlockStylesPreviewPanelFill\n\t\t\t\t\tscope={ scope }\n\t\t\t\t\tclassName=\"block-editor-block-styles__preview-panel\"\n\t\t\t\t\tstyle={ { top: containerScrollTop } }\n\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t>\n\t\t\t\t\t<BlockStylesPreviewPanel\n\t\t\t\t\t\tactiveStyle={ activeStyle }\n\t\t\t\t\t\tclassName={ previewClassName }\n\t\t\t\t\t\tgenericPreviewBlock={ genericPreviewBlock }\n\t\t\t\t\t\tstyle={ hoveredStyle }\n\t\t\t\t\t/>\n\t\t\t\t</BlockStylesPreviewPanelFill>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nBlockStyles.Slot = BlockStylesPreviewPanelSlot;\nexport default BlockStyles;\n"]}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = BlockStylesMenuItems;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _lodash = require("lodash");
13
+
14
+ var _components = require("@wordpress/components");
15
+
16
+ var _icons = require("@wordpress/icons");
17
+
18
+ var _useStylesForBlock = _interopRequireDefault(require("./use-styles-for-block"));
19
+
20
+ /**
21
+ * External dependencies
22
+ */
23
+
24
+ /**
25
+ * WordPress dependencies
26
+ */
27
+
28
+ /**
29
+ * Internal dependencies
30
+ */
31
+ function BlockStylesMenuItems(_ref) {
32
+ let {
33
+ clientId,
34
+ onSwitch = _lodash.noop
35
+ } = _ref;
36
+ const {
37
+ onSelect,
38
+ stylesToRender,
39
+ activeStyle
40
+ } = (0, _useStylesForBlock.default)({
41
+ clientId,
42
+ onSwitch
43
+ });
44
+
45
+ if (!stylesToRender || stylesToRender.length === 0) {
46
+ return null;
47
+ }
48
+
49
+ return (0, _element.createElement)(_element.Fragment, null, stylesToRender.map(style => {
50
+ const menuItemText = style.label || style.name;
51
+ return (0, _element.createElement)(_components.MenuItem, {
52
+ key: style.name,
53
+ icon: activeStyle.name === style.name ? _icons.check : null,
54
+ onClick: () => onSelect(style)
55
+ }, (0, _element.createElement)(_components.__experimentalText, {
56
+ as: "span",
57
+ limit: 18,
58
+ ellipsizeMode: "tail",
59
+ truncate: true
60
+ }, menuItemText));
61
+ }));
62
+ }
63
+ //# sourceMappingURL=menu-items.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/menu-items.js"],"names":["BlockStylesMenuItems","clientId","onSwitch","noop","onSelect","stylesToRender","activeStyle","length","map","style","menuItemText","label","name","check"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,oBAAT,OAA+D;AAAA,MAAhC;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,QAAQ,GAAGC;AAAvB,GAAgC;AAC7E,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,cAAZ;AAA4BC,IAAAA;AAA5B,MAA4C,gCAAoB;AACrEL,IAAAA,QADqE;AAErEC,IAAAA;AAFqE,GAApB,CAAlD;;AAKA,MAAK,CAAEG,cAAF,IAAoBA,cAAc,CAACE,MAAf,KAA0B,CAAnD,EAAuD;AACtD,WAAO,IAAP;AACA;;AACD,SACC,qDACGF,cAAc,CAACG,GAAf,CAAsBC,KAAF,IAAa;AAClC,UAAMC,YAAY,GAAGD,KAAK,CAACE,KAAN,IAAeF,KAAK,CAACG,IAA1C;AACA,WACC,4BAAC,oBAAD;AACC,MAAA,GAAG,EAAGH,KAAK,CAACG,IADb;AAEC,MAAA,IAAI,EAAGN,WAAW,CAACM,IAAZ,KAAqBH,KAAK,CAACG,IAA3B,GAAkCC,YAAlC,GAA0C,IAFlD;AAGC,MAAA,OAAO,EAAG,MAAMT,QAAQ,CAAEK,KAAF;AAHzB,OAKC,4BAAC,8BAAD;AACC,MAAA,EAAE,EAAC,MADJ;AAEC,MAAA,KAAK,EAAG,EAFT;AAGC,MAAA,aAAa,EAAC,MAHf;AAIC,MAAA,QAAQ;AAJT,OAMGC,YANH,CALD,CADD;AAgBA,GAlBC,CADH,CADD;AAuBA","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { MenuItem, __experimentalText as Text } from '@wordpress/components';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport useStylesForBlocks from './use-styles-for-block';\n\nexport default function BlockStylesMenuItems( { clientId, onSwitch = noop } ) {\n\tconst { onSelect, stylesToRender, activeStyle } = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\n\tif ( ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ stylesToRender.map( ( style ) => {\n\t\t\t\tconst menuItemText = style.label || style.name;\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\ticon={ activeStyle.name === style.name ? check : null }\n\t\t\t\t\t\tonClick={ () => onSelect( style ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\tlimit={ 18 }\n\t\t\t\t\t\t\tellipsizeMode=\"tail\"\n\t\t\t\t\t\t\ttruncate\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ menuItemText }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = BlockStylesPreviewPanel;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _previewPanel = _interopRequireDefault(require("../inserter/preview-panel"));
13
+
14
+ var _utils = require("./utils");
15
+
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+ function BlockStylesPreviewPanel(_ref) {
24
+ let {
25
+ genericPreviewBlock,
26
+ style,
27
+ className,
28
+ activeStyle
29
+ } = _ref;
30
+ const styleClassName = (0, _utils.replaceActiveStyle)(className, activeStyle, style);
31
+ const previewBlocks = (0, _element.useMemo)(() => {
32
+ return { ...genericPreviewBlock,
33
+ title: style.label || style.name,
34
+ description: style.description,
35
+ initialAttributes: { ...genericPreviewBlock.attributes,
36
+ className: styleClassName + ' block-editor-block-styles__block-preview-container'
37
+ }
38
+ };
39
+ }, [genericPreviewBlock, styleClassName]);
40
+ return (0, _element.createElement)(_previewPanel.default, {
41
+ item: previewBlocks,
42
+ isStylePreview: true
43
+ });
44
+ }
45
+ //# sourceMappingURL=preview-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/preview-panel.js"],"names":["BlockStylesPreviewPanel","genericPreviewBlock","style","className","activeStyle","styleClassName","previewBlocks","title","label","name","description","initialAttributes","attributes"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIe,SAASA,uBAAT,OAKX;AAAA,MAL6C;AAChDC,IAAAA,mBADgD;AAEhDC,IAAAA,KAFgD;AAGhDC,IAAAA,SAHgD;AAIhDC,IAAAA;AAJgD,GAK7C;AACH,QAAMC,cAAc,GAAG,+BAAoBF,SAApB,EAA+BC,WAA/B,EAA4CF,KAA5C,CAAvB;AACA,QAAMI,aAAa,GAAG,sBAAS,MAAM;AACpC,WAAO,EACN,GAAGL,mBADG;AAENM,MAAAA,KAAK,EAAEL,KAAK,CAACM,KAAN,IAAeN,KAAK,CAACO,IAFtB;AAGNC,MAAAA,WAAW,EAAER,KAAK,CAACQ,WAHb;AAINC,MAAAA,iBAAiB,EAAE,EAClB,GAAGV,mBAAmB,CAACW,UADL;AAElBT,QAAAA,SAAS,EACRE,cAAc,GACd;AAJiB;AAJb,KAAP;AAWA,GAZqB,EAYnB,CAAEJ,mBAAF,EAAuBI,cAAvB,CAZmB,CAAtB;AAcA,SACC,4BAAC,qBAAD;AAAsB,IAAA,IAAI,EAAGC,aAA7B;AAA6C,IAAA,cAAc,EAAG;AAA9D,IADD;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InserterPreviewPanel from '../inserter/preview-panel';\nimport { replaceActiveStyle } from './utils';\n\nexport default function BlockStylesPreviewPanel( {\n\tgenericPreviewBlock,\n\tstyle,\n\tclassName,\n\tactiveStyle,\n} ) {\n\tconst styleClassName = replaceActiveStyle( className, activeStyle, style );\n\tconst previewBlocks = useMemo( () => {\n\t\treturn {\n\t\t\t...genericPreviewBlock,\n\t\t\ttitle: style.label || style.name,\n\t\t\tdescription: style.description,\n\t\t\tinitialAttributes: {\n\t\t\t\t...genericPreviewBlock.attributes,\n\t\t\t\tclassName:\n\t\t\t\t\tstyleClassName +\n\t\t\t\t\t' block-editor-block-styles__block-preview-container',\n\t\t\t},\n\t\t};\n\t}, [ genericPreviewBlock, styleClassName ] );\n\n\treturn (\n\t\t<InserterPreviewPanel item={ previewBlocks } isStylePreview={ true } />\n\t);\n}\n"]}
@@ -54,10 +54,10 @@ function StylePreview(_ref) {
54
54
  (0, _element.useEffect)(() => {
55
55
  onLayout();
56
56
 
57
- _reactNative.Dimensions.addEventListener('change', onLayout);
57
+ const dimensionsChangeSubscription = _reactNative.Dimensions.addEventListener('change', onLayout);
58
58
 
59
59
  return () => {
60
- _reactNative.Dimensions.removeEventListener('change', onLayout);
60
+ dimensionsChangeSubscription.remove();
61
61
  };
62
62
  }, []);
63
63
  const labelStyle = (0, _compose.usePreferredColorSchemeStyle)(_style.default.label, _style.default.labelDark);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/preview.native.js"],"names":["MAX_ITEM_WIDTH","HALF_COLUMN","StylePreview","onPress","isActive","style","url","itemWidth","setItemWidth","label","name","opacity","Animated","Value","current","onLayout","columnsNum","Math","floor","BottomSheet","getWidth","Dimensions","addEventListener","removeEventListener","labelStyle","styles","labelDark","animateOutline","setValue","timing","toValue","duration","useNativeDriver","easing","Easing","linear","start","innerOutlineStyle","innerOutline","innerOutlineDark","getOutline","outlineStyles","map","outlineStyle","index","container","width","imageWrapper","outline","image","uri","labelSelected"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAYA;;AAEA;;AAKA;;AAtBA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,cAAc,GAAG,GAAvB;AACA,MAAMC,WAAW,GAAG,GAApB;;AAEA,SAASC,YAAT,OAA2D;AAAA,MAApC;AAAEC,IAAAA,OAAF;AAAWC,IAAA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,EAAgBC,KAAhB,KAA2B;AAC7C,WACC,4BAAC,qBAAD,CAAU,IAAV;AACC,MAAA,KAAK,EAAG,CAAED,YAAF,EAAgB;AAAEhC,QAAAA;AAAF,OAAhB,EAA6Bc,eAAQf,IAAR,CAA7B,CADT;AAEC,MAAA,GAAG,EAAGkC;AAFP,MADD;AAMA,GAPD,CADD;;AAUA,SACC,4BAAC,qCAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfzC,MAAAA,OAAO;AACPwB,MAAAA,cAAc;AACd;AAJF,KAMC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAG,CAAEF,eAAOoB,SAAT,EAAoB;AAAEC,MAAAA,KAAK,EAAEvC;AAAT,KAApB;AAAd,KACC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGkB,eAAOsB;AAArB,KACG3C,QAAQ,IACToC,UAAU,CAAE,CAAEf,eAAOuB,OAAT,EAAkBX,iBAAlB,CAAF,CAFZ,EAGC,4BAAC,kBAAD;AACC,IAAA,KAAK,EAAG,CAAEZ,eAAOwB,KAAT,EAAgBxB,eAAQf,IAAR,CAAhB,CADT;AAEC,IAAA,MAAM,EAAG;AAAEwC,MAAAA,GAAG,EAAE5C;AAAP;AAFV,IAHD,CADD,EASC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAG,CAAEkB,UAAF,EAAcpB,QAAQ,IAAIqB,eAAO0B,aAAjC;AADT,KAGG1C,KAHH,CATD,CAND,CADD;AAwBA;;eAEcP,Y","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tTouchableWithoutFeedback,\n\tText,\n\tDimensions,\n\tAnimated,\n\tEasing,\n\tImage,\n} from 'react-native';\n/**\n * WordPress dependencies\n */\nimport { BottomSheet } from '@wordpress/components';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst MAX_ITEM_WIDTH = 120;\nconst HALF_COLUMN = 0.5;\n\nfunction StylePreview( { onPress, isActive, style, url } ) {\n\tconst [ itemWidth, setItemWidth ] = useState( MAX_ITEM_WIDTH );\n\tconst { label, name } = style;\n\tconst opacity = useRef( new Animated.Value( 1 ) ).current;\n\n\tfunction onLayout() {\n\t\tconst columnsNum =\n\t\t\t// To indicate scroll availabilty, there is a need to display additional half the column\n\t\t\tMath.floor( BottomSheet.getWidth() / MAX_ITEM_WIDTH ) + HALF_COLUMN;\n\t\tsetItemWidth( BottomSheet.getWidth() / columnsNum );\n\t}\n\n\tuseEffect( () => {\n\t\tonLayout();\n\t\tDimensions.addEventListener( 'change', onLayout );\n\n\t\treturn () => {\n\t\t\tDimensions.removeEventListener( 'change', onLayout );\n\t\t};\n\t}, [] );\n\n\tconst labelStyle = usePreferredColorSchemeStyle(\n\t\tstyles.label,\n\t\tstyles.labelDark\n\t);\n\n\tconst animateOutline = () => {\n\t\topacity.setValue( 0 );\n\t\tAnimated.timing( opacity, {\n\t\t\ttoValue: 1,\n\t\t\tduration: 100,\n\t\t\tuseNativeDriver: true,\n\t\t\teasing: Easing.linear,\n\t\t} ).start();\n\t};\n\n\tconst innerOutlineStyle = usePreferredColorSchemeStyle(\n\t\tstyles.innerOutline,\n\t\tstyles.innerOutlineDark\n\t);\n\n\tconst getOutline = ( outlineStyles ) =>\n\t\toutlineStyles.map( ( outlineStyle, index ) => {\n\t\t\treturn (\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={ [ outlineStyle, { opacity }, styles[ name ] ] }\n\t\t\t\t\tkey={ index }\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\tonPress={ () => {\n\t\t\t\tonPress();\n\t\t\t\tanimateOutline();\n\t\t\t} }\n\t\t>\n\t\t\t<View style={ [ styles.container, { width: itemWidth } ] }>\n\t\t\t\t<View style={ styles.imageWrapper }>\n\t\t\t\t\t{ isActive &&\n\t\t\t\t\t\tgetOutline( [ styles.outline, innerOutlineStyle ] ) }\n\t\t\t\t\t<Image\n\t\t\t\t\t\tstyle={ [ styles.image, styles[ name ] ] }\n\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t\t<Text\n\t\t\t\t\tstyle={ [ labelStyle, isActive && styles.labelSelected ] }\n\t\t\t\t>\n\t\t\t\t\t{ label }\n\t\t\t\t</Text>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n}\n\nexport default StylePreview;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/preview.native.js"],"names":["MAX_ITEM_WIDTH","HALF_COLUMN","StylePreview","onPress","isActive","style","url","itemWidth","setItemWidth","label","name","opacity","Animated","Value","current","onLayout","columnsNum","Math","floor","BottomSheet","getWidth","dimensionsChangeSubscription","Dimensions","addEventListener","remove","labelStyle","styles","labelDark","animateOutline","setValue","timing","toValue","duration","useNativeDriver","easing","Easing","linear","start","innerOutlineStyle","innerOutline","innerOutlineDark","getOutline","outlineStyles","map","outlineStyle","index","container","width","imageWrapper","outline","image","uri","labelSelected"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAYA;;AAEA;;AAKA;;AAtBA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,cAAc,GAAG,GAAvB;AACA,MAAMC,WAAW,GAAG,GAApB;;AAEA,SAASC,YAAT,OAA2D;AAAA,MAApC;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA,KAArB;AAA4BC,IAAAA;AAA5B,GAAoC;AAC1D,QAAM,CAAEC,SAAF,EAAaC,YAAb,IAA8B,uBAAUR,cAAV,CAApC;AACA,QAAM;AAAES,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAkBL,KAAxB;AACA,QAAMM,OAAO,GAAG,qBAAQ,IAAIC,sBAASC,KAAb,CAAoB,CAApB,CAAR,EAAkCC,OAAlD;;AAEA,WAASC,QAAT,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A,OAAO;AACPyB,MAAAA,cAAc;AACd;AAJF,KAMC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAG,CAAEF,eAAOoB,SAAT,EAAoB;AAAEC,MAAAA,KAAK,EAAExC;AAAT,KAApB;AAAd,KACC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGmB,eAAOsB;AAArB,KACG5C,QAAQ,IACTqC,UAAU,CAAE,CAAEf,eAAOuB,OAAT,EAAkBX,iBAAlB,CAAF,CAFZ,EAGC,4BAAC,kBAAD;AACC,IAAA,KAAK,EAAG,CAAEZ,eAAOwB,KAAT,EAAgBxB,eAAQhB,IAAR,CAAhB,CADT;AAEC,IAAA,MAAM,EAAG;AAAEyC,MAAAA,GAAG,EAAE7C;AAAP;AAFV,IAHD,CADD,EASC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAG,CAAEmB,UAAF,EAAcrB,QAAQ,IAAIsB,eAAO0B,aAAjC;AADT,KAGG3C,KAHH,CATD,CAND,CADD;AAwBA;;eAEcP,Y","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tTouchableWithoutFeedback,\n\tText,\n\tDimensions,\n\tAnimated,\n\tEasing,\n\tImage,\n} from 'react-native';\n/**\n * WordPress dependencies\n */\nimport { BottomSheet } from '@wordpress/components';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst MAX_ITEM_WIDTH = 120;\nconst HALF_COLUMN = 0.5;\n\nfunction StylePreview( { onPress, isActive, style, url } ) {\n\tconst [ itemWidth, setItemWidth ] = useState( MAX_ITEM_WIDTH );\n\tconst { label, name } = style;\n\tconst opacity = useRef( new Animated.Value( 1 ) ).current;\n\n\tfunction onLayout() {\n\t\tconst columnsNum =\n\t\t\t// To indicate scroll availabilty, there is a need to display additional half the column\n\t\t\tMath.floor( BottomSheet.getWidth() / MAX_ITEM_WIDTH ) + HALF_COLUMN;\n\t\tsetItemWidth( BottomSheet.getWidth() / columnsNum );\n\t}\n\n\tuseEffect( () => {\n\t\tonLayout();\n\t\tconst dimensionsChangeSubscription = Dimensions.addEventListener(\n\t\t\t'change',\n\t\t\tonLayout\n\t\t);\n\n\t\treturn () => {\n\t\t\tdimensionsChangeSubscription.remove();\n\t\t};\n\t}, [] );\n\n\tconst labelStyle = usePreferredColorSchemeStyle(\n\t\tstyles.label,\n\t\tstyles.labelDark\n\t);\n\n\tconst animateOutline = () => {\n\t\topacity.setValue( 0 );\n\t\tAnimated.timing( opacity, {\n\t\t\ttoValue: 1,\n\t\t\tduration: 100,\n\t\t\tuseNativeDriver: true,\n\t\t\teasing: Easing.linear,\n\t\t} ).start();\n\t};\n\n\tconst innerOutlineStyle = usePreferredColorSchemeStyle(\n\t\tstyles.innerOutline,\n\t\tstyles.innerOutlineDark\n\t);\n\n\tconst getOutline = ( outlineStyles ) =>\n\t\toutlineStyles.map( ( outlineStyle, index ) => {\n\t\t\treturn (\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={ [ outlineStyle, { opacity }, styles[ name ] ] }\n\t\t\t\t\tkey={ index }\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\tonPress={ () => {\n\t\t\t\tonPress();\n\t\t\t\tanimateOutline();\n\t\t\t} }\n\t\t>\n\t\t\t<View style={ [ styles.container, { width: itemWidth } ] }>\n\t\t\t\t<View style={ styles.imageWrapper }>\n\t\t\t\t\t{ isActive &&\n\t\t\t\t\t\tgetOutline( [ styles.outline, innerOutlineStyle ] ) }\n\t\t\t\t\t<Image\n\t\t\t\t\t\tstyle={ [ styles.image, styles[ name ] ] }\n\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t\t<Text\n\t\t\t\t\tstyle={ [ labelStyle, isActive && styles.labelSelected ] }\n\t\t\t\t>\n\t\t\t\t\t{ label }\n\t\t\t\t</Text>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n}\n\nexport default StylePreview;\n"]}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useStylesForBlocks;
7
+
8
+ var _data = require("@wordpress/data");
9
+
10
+ var _blocks = require("@wordpress/blocks");
11
+
12
+ var _element = require("@wordpress/element");
13
+
14
+ var _utils = require("./utils");
15
+
16
+ var _store = require("../../store");
17
+
18
+ /**
19
+ * WordPress dependencies
20
+ */
21
+
22
+ /**
23
+ * Internal dependencies
24
+ */
25
+
26
+ /**
27
+ *
28
+ * @param {WPBlock} block Block object.
29
+ * @param {WPBlockType} type Block type settings.
30
+ * @return {WPBlock} A generic block ready for styles preview.
31
+ */
32
+ function useGenericPreviewBlock(block, type) {
33
+ return (0, _element.useMemo)(() => {
34
+ const example = type === null || type === void 0 ? void 0 : type.example;
35
+ const blockName = type === null || type === void 0 ? void 0 : type.name;
36
+
37
+ if (example && blockName) {
38
+ return (0, _blocks.getBlockFromExample)(blockName, {
39
+ attributes: example.attributes,
40
+ innerBlocks: example.innerBlocks
41
+ });
42
+ }
43
+
44
+ if (block) {
45
+ return (0, _blocks.cloneBlock)(block);
46
+ }
47
+ }, [type !== null && type !== void 0 && type.example ? block === null || block === void 0 ? void 0 : block.name : block, type]);
48
+ }
49
+ /**
50
+ * @typedef useStylesForBlocksArguments
51
+ * @property {string} clientId Block client ID.
52
+ * @property {() => void} onSwitch Block style switch callback function.
53
+ */
54
+
55
+ /**
56
+ *
57
+ * @param {useStylesForBlocksArguments} useStylesForBlocks arguments.
58
+ * @return {Object} Results of the select methods.
59
+ */
60
+
61
+
62
+ function useStylesForBlocks(_ref) {
63
+ let {
64
+ clientId,
65
+ onSwitch
66
+ } = _ref;
67
+
68
+ const selector = select => {
69
+ const {
70
+ getBlock
71
+ } = select(_store.store);
72
+ const block = getBlock(clientId);
73
+
74
+ if (!block) {
75
+ return {};
76
+ }
77
+
78
+ const blockType = (0, _blocks.getBlockType)(block.name);
79
+ const {
80
+ getBlockStyles
81
+ } = select(_blocks.store);
82
+ return {
83
+ block,
84
+ blockType,
85
+ styles: getBlockStyles(block.name),
86
+ className: block.attributes.className || ''
87
+ };
88
+ };
89
+
90
+ const {
91
+ styles,
92
+ block,
93
+ blockType,
94
+ className
95
+ } = (0, _data.useSelect)(selector, [clientId]);
96
+ const {
97
+ updateBlockAttributes
98
+ } = (0, _data.useDispatch)(_store.store);
99
+ const stylesToRender = (0, _utils.getRenderedStyles)(styles);
100
+ const activeStyle = (0, _utils.getActiveStyle)(stylesToRender, className);
101
+ const genericPreviewBlock = useGenericPreviewBlock(block, blockType);
102
+
103
+ const onSelect = style => {
104
+ const styleClassName = (0, _utils.replaceActiveStyle)(className, activeStyle, style);
105
+ updateBlockAttributes(clientId, {
106
+ className: styleClassName
107
+ });
108
+ onSwitch();
109
+ };
110
+
111
+ return {
112
+ onSelect,
113
+ stylesToRender,
114
+ activeStyle,
115
+ genericPreviewBlock,
116
+ className
117
+ };
118
+ }
119
+ //# sourceMappingURL=use-styles-for-block.js.map