@wordpress/block-editor 7.0.4 → 8.0.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 (347) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +31 -0
  3. package/build/components/alignment-control/ui.js +1 -2
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/block-icon/index.js +5 -1
  6. package/build/components/block-icon/index.js.map +1 -1
  7. package/build/components/block-inspector/index.js +4 -0
  8. package/build/components/block-inspector/index.js.map +1 -1
  9. package/build/components/block-list/index.native.js +1 -1
  10. package/build/components/block-list/index.native.js.map +1 -1
  11. package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
  12. package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  13. package/build/components/block-navigation/dropdown.js +0 -1
  14. package/build/components/block-navigation/dropdown.js.map +1 -1
  15. package/build/components/block-patterns-list/index.js +1 -8
  16. package/build/components/block-patterns-list/index.js.map +1 -1
  17. package/build/components/block-settings/container.native.js +5 -2
  18. package/build/components/block-settings/container.native.js.map +1 -1
  19. package/build/components/block-settings-menu/block-settings-dropdown.js +22 -2
  20. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  21. package/build/components/block-styles/preview.native.js +2 -2
  22. package/build/components/block-styles/preview.native.js.map +1 -1
  23. package/build/components/colors-gradients/control.js +8 -47
  24. package/build/components/colors-gradients/control.js.map +1 -1
  25. package/build/components/colors-gradients/panel-color-gradient-settings.js +81 -6
  26. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  27. package/build/components/duotone-control/index.js +5 -2
  28. package/build/components/duotone-control/index.js.map +1 -1
  29. package/build/components/font-appearance-control/index.js +27 -15
  30. package/build/components/font-appearance-control/index.js.map +1 -1
  31. package/build/components/iframe/index.js +1 -1
  32. package/build/components/iframe/index.js.map +1 -1
  33. package/build/components/index.js +20 -2
  34. package/build/components/index.js.map +1 -1
  35. package/build/components/index.native.js +2 -2
  36. package/build/components/index.native.js.map +1 -1
  37. package/build/components/inner-blocks/index.js +5 -4
  38. package/build/components/inner-blocks/index.js.map +1 -1
  39. package/build/components/inner-blocks/index.native.js +4 -3
  40. package/build/components/inner-blocks/index.native.js.map +1 -1
  41. package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
  42. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  43. package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
  44. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  45. package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
  46. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  47. package/build/components/inserter/block-patterns-tab.js +74 -45
  48. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  49. package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  50. package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  51. package/build/components/inserter/pattern-panel.js +19 -10
  52. package/build/components/inserter/pattern-panel.js.map +1 -1
  53. package/build/components/inspector-controls/groups.js +3 -1
  54. package/build/components/inspector-controls/groups.js.map +1 -1
  55. package/build/components/letter-spacing-control/index.js +9 -6
  56. package/build/components/letter-spacing-control/index.js.map +1 -1
  57. package/build/components/link-control/index.js +88 -35
  58. package/build/components/link-control/index.js.map +1 -1
  59. package/build/components/link-control/link-preview.js +19 -6
  60. package/build/components/link-control/link-preview.js.map +1 -1
  61. package/build/components/link-control/search-input.js +12 -3
  62. package/build/components/link-control/search-input.js.map +1 -1
  63. package/build/components/list-view/block.js +49 -23
  64. package/build/components/list-view/block.js.map +1 -1
  65. package/build/components/list-view/branch.js +92 -73
  66. package/build/components/list-view/branch.js.map +1 -1
  67. package/build/components/list-view/index.js +39 -16
  68. package/build/components/list-view/index.js.map +1 -1
  69. package/build/components/list-view/leaf.js +1 -1
  70. package/build/components/list-view/leaf.js.map +1 -1
  71. package/build/components/list-view/use-list-view-client-ids.js +8 -58
  72. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  73. package/build/components/rich-text/embed-handler-picker.native.js +1 -0
  74. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
  75. package/build/components/rich-text/format-edit.js +28 -2
  76. package/build/components/rich-text/format-edit.js.map +1 -1
  77. package/build/components/rich-text/format-toolbar/index.js +2 -1
  78. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  79. package/build/components/url-input/index.js +11 -4
  80. package/build/components/url-input/index.js.map +1 -1
  81. package/build/components/use-setting/index.js +48 -9
  82. package/build/components/use-setting/index.js.map +1 -1
  83. package/build/hooks/border.js +5 -5
  84. package/build/hooks/border.js.map +1 -1
  85. package/build/hooks/color-panel.js +2 -1
  86. package/build/hooks/color-panel.js.map +1 -1
  87. package/build/hooks/duotone.js +16 -5
  88. package/build/hooks/duotone.js.map +1 -1
  89. package/build/hooks/font-appearance.js +49 -6
  90. package/build/hooks/font-appearance.js.map +1 -1
  91. package/build/hooks/font-family.js +37 -16
  92. package/build/hooks/font-family.js.map +1 -1
  93. package/build/hooks/font-size.js +51 -9
  94. package/build/hooks/font-size.js.map +1 -1
  95. package/build/hooks/index.js +8 -0
  96. package/build/hooks/index.js.map +1 -1
  97. package/build/hooks/index.native.js +8 -0
  98. package/build/hooks/index.native.js.map +1 -1
  99. package/build/hooks/letter-spacing.js +44 -7
  100. package/build/hooks/letter-spacing.js.map +1 -1
  101. package/build/hooks/line-height.js +45 -8
  102. package/build/hooks/line-height.js.map +1 -1
  103. package/build/hooks/margin.js +1 -1
  104. package/build/hooks/margin.js.map +1 -1
  105. package/build/hooks/padding.js +1 -1
  106. package/build/hooks/padding.js.map +1 -1
  107. package/build/hooks/text-decoration.js +42 -6
  108. package/build/hooks/text-decoration.js.map +1 -1
  109. package/build/hooks/text-transform.js +42 -6
  110. package/build/hooks/text-transform.js.map +1 -1
  111. package/build/hooks/typography.js +108 -8
  112. package/build/hooks/typography.js.map +1 -1
  113. package/build/hooks/use-cached-truthy.js +29 -0
  114. package/build/hooks/use-cached-truthy.js.map +1 -0
  115. package/build/index.js +7 -0
  116. package/build/index.js.map +1 -1
  117. package/build/layouts/flex.js +120 -28
  118. package/build/layouts/flex.js.map +1 -1
  119. package/build/store/actions.js +303 -265
  120. package/build/store/actions.js.map +1 -1
  121. package/build/store/index.js +1 -3
  122. package/build/store/index.js.map +1 -1
  123. package/build/store/reducer.js +23 -22
  124. package/build/store/reducer.js.map +1 -1
  125. package/build/store/selectors.js +44 -35
  126. package/build/store/selectors.js.map +1 -1
  127. package/build-module/components/alignment-control/ui.js +1 -2
  128. package/build-module/components/alignment-control/ui.js.map +1 -1
  129. package/build-module/components/block-icon/index.js +5 -1
  130. package/build-module/components/block-icon/index.js.map +1 -1
  131. package/build-module/components/block-inspector/index.js +4 -0
  132. package/build-module/components/block-inspector/index.js.map +1 -1
  133. package/build-module/components/block-list/index.native.js +1 -1
  134. package/build-module/components/block-list/index.native.js.map +1 -1
  135. package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
  136. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  137. package/build-module/components/block-navigation/dropdown.js +0 -1
  138. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  139. package/build-module/components/block-patterns-list/index.js +1 -6
  140. package/build-module/components/block-patterns-list/index.js.map +1 -1
  141. package/build-module/components/block-settings/container.native.js +6 -3
  142. package/build-module/components/block-settings/container.native.js.map +1 -1
  143. package/build-module/components/block-settings-menu/block-settings-dropdown.js +24 -4
  144. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  145. package/build-module/components/block-styles/preview.native.js +2 -2
  146. package/build-module/components/block-styles/preview.native.js.map +1 -1
  147. package/build-module/components/colors-gradients/control.js +12 -53
  148. package/build-module/components/colors-gradients/control.js.map +1 -1
  149. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +82 -6
  150. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  151. package/build-module/components/duotone-control/index.js +5 -2
  152. package/build-module/components/duotone-control/index.js.map +1 -1
  153. package/build-module/components/font-appearance-control/index.js +23 -15
  154. package/build-module/components/font-appearance-control/index.js.map +1 -1
  155. package/build-module/components/iframe/index.js +1 -1
  156. package/build-module/components/iframe/index.js.map +1 -1
  157. package/build-module/components/index.js +3 -1
  158. package/build-module/components/index.js.map +1 -1
  159. package/build-module/components/index.native.js +1 -1
  160. package/build-module/components/index.native.js.map +1 -1
  161. package/build-module/components/inner-blocks/index.js +6 -5
  162. package/build-module/components/inner-blocks/index.js.map +1 -1
  163. package/build-module/components/inner-blocks/index.native.js +5 -4
  164. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  165. package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
  166. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  167. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
  168. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  169. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
  170. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  171. package/build-module/components/inserter/block-patterns-tab.js +75 -46
  172. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  173. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  174. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  175. package/build-module/components/inserter/pattern-panel.js +21 -13
  176. package/build-module/components/inserter/pattern-panel.js.map +1 -1
  177. package/build-module/components/inspector-controls/groups.js +3 -1
  178. package/build-module/components/inspector-controls/groups.js.map +1 -1
  179. package/build-module/components/letter-spacing-control/index.js +9 -6
  180. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  181. package/build-module/components/link-control/index.js +88 -36
  182. package/build-module/components/link-control/index.js.map +1 -1
  183. package/build-module/components/link-control/link-preview.js +19 -7
  184. package/build-module/components/link-control/link-preview.js.map +1 -1
  185. package/build-module/components/link-control/search-input.js +11 -3
  186. package/build-module/components/link-control/search-input.js.map +1 -1
  187. package/build-module/components/list-view/block.js +49 -24
  188. package/build-module/components/list-view/block.js.map +1 -1
  189. package/build-module/components/list-view/branch.js +92 -73
  190. package/build-module/components/list-view/branch.js.map +1 -1
  191. package/build-module/components/list-view/index.js +41 -18
  192. package/build-module/components/list-view/index.js.map +1 -1
  193. package/build-module/components/list-view/leaf.js +1 -1
  194. package/build-module/components/list-view/leaf.js.map +1 -1
  195. package/build-module/components/list-view/use-list-view-client-ids.js +8 -58
  196. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  197. package/build-module/components/rich-text/embed-handler-picker.native.js +1 -0
  198. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
  199. package/build-module/components/rich-text/format-edit.js +28 -3
  200. package/build-module/components/rich-text/format-edit.js.map +1 -1
  201. package/build-module/components/rich-text/format-toolbar/index.js +2 -1
  202. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  203. package/build-module/components/url-input/index.js +11 -4
  204. package/build-module/components/url-input/index.js.map +1 -1
  205. package/build-module/components/use-setting/index.js +48 -9
  206. package/build-module/components/use-setting/index.js.map +1 -1
  207. package/build-module/hooks/border.js +5 -5
  208. package/build-module/hooks/border.js.map +1 -1
  209. package/build-module/hooks/color-panel.js +2 -1
  210. package/build-module/hooks/color-panel.js.map +1 -1
  211. package/build-module/hooks/duotone.js +16 -5
  212. package/build-module/hooks/duotone.js.map +1 -1
  213. package/build-module/hooks/font-appearance.js +45 -6
  214. package/build-module/hooks/font-appearance.js.map +1 -1
  215. package/build-module/hooks/font-family.js +33 -16
  216. package/build-module/hooks/font-family.js.map +1 -1
  217. package/build-module/hooks/font-size.js +47 -9
  218. package/build-module/hooks/font-size.js.map +1 -1
  219. package/build-module/hooks/index.js +1 -0
  220. package/build-module/hooks/index.js.map +1 -1
  221. package/build-module/hooks/index.native.js +1 -0
  222. package/build-module/hooks/index.native.js.map +1 -1
  223. package/build-module/hooks/letter-spacing.js +40 -7
  224. package/build-module/hooks/letter-spacing.js.map +1 -1
  225. package/build-module/hooks/line-height.js +41 -8
  226. package/build-module/hooks/line-height.js.map +1 -1
  227. package/build-module/hooks/margin.js +1 -1
  228. package/build-module/hooks/margin.js.map +1 -1
  229. package/build-module/hooks/padding.js +1 -1
  230. package/build-module/hooks/padding.js.map +1 -1
  231. package/build-module/hooks/text-decoration.js +38 -6
  232. package/build-module/hooks/text-decoration.js.map +1 -1
  233. package/build-module/hooks/text-transform.js +38 -6
  234. package/build-module/hooks/text-transform.js.map +1 -1
  235. package/build-module/hooks/typography.js +117 -17
  236. package/build-module/hooks/typography.js.map +1 -1
  237. package/build-module/hooks/use-cached-truthy.js +21 -0
  238. package/build-module/hooks/use-cached-truthy.js.map +1 -0
  239. package/build-module/index.js +1 -1
  240. package/build-module/index.js.map +1 -1
  241. package/build-module/layouts/flex.js +124 -32
  242. package/build-module/layouts/flex.js.map +1 -1
  243. package/build-module/store/actions.js +266 -241
  244. package/build-module/store/actions.js.map +1 -1
  245. package/build-module/store/index.js +1 -2
  246. package/build-module/store/index.js.map +1 -1
  247. package/build-module/store/reducer.js +23 -22
  248. package/build-module/store/reducer.js.map +1 -1
  249. package/build-module/store/selectors.js +42 -30
  250. package/build-module/store/selectors.js.map +1 -1
  251. package/build-style/style-rtl.css +160 -57
  252. package/build-style/style.css +160 -57
  253. package/package.json +13 -14
  254. package/src/components/alignment-control/test/__snapshots__/index.js.snap +0 -2
  255. package/src/components/alignment-control/ui.js +1 -4
  256. package/src/components/block-draggable/style.scss +19 -4
  257. package/src/components/block-icon/index.js +4 -1
  258. package/src/components/block-inspector/index.js +5 -0
  259. package/src/components/block-list/index.native.js +1 -1
  260. package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
  261. package/src/components/block-navigation/dropdown.js +0 -1
  262. package/src/components/block-patterns-list/index.js +1 -8
  263. package/src/components/block-patterns-list/style.scss +22 -12
  264. package/src/components/block-settings/container.native.js +7 -0
  265. package/src/components/block-settings-menu/block-settings-dropdown.js +19 -7
  266. package/src/components/block-styles/preview.native.js +2 -2
  267. package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
  268. package/src/components/color-palette/test/__snapshots__/control.js.snap +88 -63
  269. package/src/components/colors-gradients/control.js +19 -62
  270. package/src/components/colors-gradients/panel-color-gradient-settings.js +76 -6
  271. package/src/components/colors-gradients/style.scss +3 -14
  272. package/src/components/colors-gradients/test/control.js +0 -16
  273. package/src/components/duotone-control/index.js +6 -0
  274. package/src/components/duotone-control/style.scss +27 -12
  275. package/src/components/font-appearance-control/index.js +22 -14
  276. package/src/components/iframe/index.js +1 -1
  277. package/src/components/index.js +3 -4
  278. package/src/components/index.native.js +1 -4
  279. package/src/components/inner-blocks/index.js +4 -4
  280. package/src/components/inner-blocks/index.native.js +7 -4
  281. package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
  282. package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
  283. package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
  284. package/src/components/inserter/block-patterns-tab.js +107 -80
  285. package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
  286. package/src/components/inserter/pattern-panel.js +33 -16
  287. package/src/components/inserter/style.scss +64 -1
  288. package/src/components/inserter/test/block-types-tab.native.js +1 -1
  289. package/src/components/inserter/test/fixtures/index.native.js +12 -0
  290. package/src/components/inspector-controls/groups.js +4 -0
  291. package/src/components/letter-spacing-control/index.js +12 -6
  292. package/src/components/link-control/README.md +7 -0
  293. package/src/components/link-control/index.js +99 -34
  294. package/src/components/link-control/link-preview.js +21 -9
  295. package/src/components/link-control/search-input.js +9 -3
  296. package/src/components/link-control/style.scss +32 -16
  297. package/src/components/link-control/test/index.js +179 -4
  298. package/src/components/list-view/block.js +67 -23
  299. package/src/components/list-view/branch.js +113 -91
  300. package/src/components/list-view/index.js +58 -19
  301. package/src/components/list-view/leaf.js +1 -1
  302. package/src/components/list-view/style.scss +14 -3
  303. package/src/components/list-view/use-list-view-client-ids.js +7 -66
  304. package/src/components/rich-text/embed-handler-picker.native.js +1 -0
  305. package/src/components/rich-text/format-edit.js +36 -2
  306. package/src/components/rich-text/format-toolbar/index.js +3 -0
  307. package/src/components/url-input/index.js +14 -4
  308. package/src/components/use-setting/index.js +49 -11
  309. package/src/hooks/border.js +8 -11
  310. package/src/hooks/color-panel.js +1 -0
  311. package/src/hooks/duotone.js +21 -7
  312. package/src/hooks/font-appearance.js +38 -7
  313. package/src/hooks/font-family.js +29 -13
  314. package/src/hooks/font-size.js +42 -6
  315. package/src/hooks/index.js +1 -0
  316. package/src/hooks/index.native.js +1 -0
  317. package/src/hooks/layout.scss +3 -1
  318. package/src/hooks/letter-spacing.js +35 -7
  319. package/src/hooks/line-height.js +37 -9
  320. package/src/hooks/margin.js +1 -1
  321. package/src/hooks/padding.js +1 -1
  322. package/src/hooks/text-decoration.js +34 -6
  323. package/src/hooks/text-transform.js +34 -6
  324. package/src/hooks/typography.js +165 -15
  325. package/src/hooks/typography.scss +16 -0
  326. package/src/hooks/use-cached-truthy.js +20 -0
  327. package/src/index.js +1 -0
  328. package/src/layouts/flex.js +137 -41
  329. package/src/store/actions.js +223 -391
  330. package/src/store/index.js +1 -2
  331. package/src/store/reducer.js +36 -18
  332. package/src/store/selectors.js +52 -47
  333. package/src/store/test/actions.js +395 -694
  334. package/src/store/test/selectors.js +79 -21
  335. package/src/style.scss +1 -1
  336. package/src/utils/test/parse-css-unit-to-px.js +127 -167
  337. package/build/components/text-decoration-and-transform/index.js +0 -39
  338. package/build/components/text-decoration-and-transform/index.js.map +0 -1
  339. package/build/store/controls.js +0 -44
  340. package/build/store/controls.js.map +0 -1
  341. package/build-module/components/text-decoration-and-transform/index.js +0 -30
  342. package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
  343. package/build-module/store/controls.js +0 -32
  344. package/build-module/store/controls.js.map +0 -1
  345. package/src/components/text-decoration-and-transform/index.js +0 -36
  346. package/src/components/text-decoration-and-transform/style.scss +0 -3
  347. package/src/store/controls.js +0 -39
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/patterns-list.js"],"names":["useMemo","useEffect","_n","sprintf","useDebounce","useAsyncList","__experimentalHeading","Heading","speak","BlockPatternsList","InserterNoResults","useInsertionPoint","usePatternsState","InserterListbox","searchItems","INITIAL_INSERTER_RESULTS","PatternsListHeader","filterValue","filteredBlockPatternsLength","PatternList","selectedCategory","patternCategories","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","allPatterns","onSelectBlockPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filter","pattern","categories","length","every","category","includes","count","resultsFoundMessage","currentShownPatterns","step","hasItems"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,SAAlB,QAAmC,oBAAnC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,YAAtB,QAA0C,oBAA1C;AACA,SAASC,qBAAqB,IAAIC,OAAlC,QAAiD,uBAAjD;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,2BAA9B;AACA,OAAOC,iBAAP,MAA8B,eAA9B;AACA,OAAOC,iBAAP,MAA8B,8BAA9B;AACA,OAAOC,gBAAP,MAA6B,6BAA7B;AACA,OAAOC,eAAP,MAA4B,wBAA5B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA,MAAMC,wBAAwB,GAAG,CAAjC;;AAEA,SAASC,kBAAT,CAA6B;AAAEC,EAAAA,WAAF;AAAeC,EAAAA;AAAf,CAA7B,EAA4E;AAC3E,MAAK,CAAED,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AACD,SACC,cAAC,OAAD;AACC,IAAA,KAAK,EAAG,CADT;AAEC,IAAA,UAAU,EAAG,MAFd;AAGC,IAAA,SAAS,EAAC;AAHX,KAKGd,OAAO;AACR;AACAD,EAAAA,EAAE,CACD,+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;AAChB,QAAK,CAAEgB,WAAP,EAAqB;AACpB;AACA;;AACD,UAAMuB,KAAK,GAAGR,qBAAqB,CAACI,MAApC;AACA,UAAMK,mBAAmB,GAAGtC,OAAO;AAClC;AACAD,IAAAA,EAAE,CAAE,kBAAF,EAAsB,mBAAtB,EAA2CsC,KAA3C,CAFgC,EAGlCA,KAHkC,CAAnC;AAKAlB,IAAAA,cAAc,CAAEmB,mBAAF,CAAd;AACA,GAXQ,EAWN,CAAExB,WAAF,EAAeK,cAAf,CAXM,CAAT;AAaA,QAAMoB,oBAAoB,GAAGrC,YAAY,CAAE2B,qBAAF,EAAyB;AACjEW,IAAAA,IAAI,EAAE5B;AAD2D,GAAzB,CAAzC;AAIA,QAAM6B,QAAQ,GAAG,CAAC,EAAEZ,qBAAF,aAAEA,qBAAF,eAAEA,qBAAqB,CAAEI,MAAzB,CAAlB;AACA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGQ,QAAQ,IACT,cAAC,kBAAD;AACC,IAAA,WAAW,EAAG3B,WADf;AAEC,IAAA,2BAA2B,EAAGe,qBAAqB,CAACI;AAFrD,IAFF,EAOC,cAAC,eAAD,QACG,CAAEQ,QAAF,IAAc,cAAC,iBAAD,OADjB,EAEGA,QAAQ,IACT,cAAC,iBAAD;AACC,IAAA,aAAa,EAAGF,oBADjB;AAEC,IAAA,aAAa,EAAGV,qBAFjB;AAGC,IAAA,cAAc,EAAGL,oBAHlB;AAIC,IAAA,WAAW,EAAG;AAJf,IAHF,CAPD,CADD;AAqBA;;AAED,eAAeR,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce, useAsyncList } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport InserterNoResults from '../no-results';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\n\nconst INITIAL_INSERTER_RESULTS = 2;\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight={ '48px' }\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. %s: block pattern search query */\n\t\t\t\t_n(\n\t\t\t\t\t'%1$d pattern found for \"%2$s\"',\n\t\t\t\t\t'%1$d patterns found for \"%2$s\"',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength,\n\t\t\t\tfilterValue\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( { filterValue, selectedCategory, patternCategories } ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ allPatterns, , onSelectBlockPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn allPatterns.filter( ( pattern ) =>\n\t\t\t\tselectedCategory === 'uncategorized'\n\t\t\t\t\t? ! pattern.categories?.length ||\n\t\t\t\t\t pattern.categories.every(\n\t\t\t\t\t\t\t( category ) =>\n\t\t\t\t\t\t\t\t! registeredPatternCategories.includes(\n\t\t\t\t\t\t\t\t\tcategory\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t )\n\t\t\t\t\t: pattern.categories?.includes( selectedCategory )\n\t\t\t);\n\t\t}\n\t\treturn searchItems( allPatterns, filterValue );\n\t}, [ filterValue, selectedCategory, allPatterns ] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ filterValue, debouncedSpeak ] );\n\n\tconst currentShownPatterns = useAsyncList( filteredBlockPatterns, {\n\t\tstep: INITIAL_INSERTER_RESULTS,\n\t} );\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-explorer__list\">\n\t\t\t{ hasItems && (\n\t\t\t\t<PatternsListHeader\n\t\t\t\t\tfilterValue={ filterValue }\n\t\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<InserterListbox>\n\t\t\t\t{ ! hasItems && <InserterNoResults /> }\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\t\t\tblockPatterns={ filteredBlockPatterns }\n\t\t\t\t\t\tonClickPattern={ onSelectBlockPattern }\n\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"]}
@@ -0,0 +1,69 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { Button, SearchControl } from '@wordpress/components';
7
+ import { __ } from '@wordpress/i18n';
8
+
9
+ function PatternCategoriesList({
10
+ selectedCategory,
11
+ patternCategories,
12
+ onClickCategory
13
+ }) {
14
+ const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
15
+ return createElement("div", {
16
+ className: `${baseClassName}__categories-list`
17
+ }, patternCategories.map(({
18
+ name,
19
+ label
20
+ }) => {
21
+ return createElement(Button, {
22
+ key: name,
23
+ label: label,
24
+ className: `${baseClassName}__categories-list__item`,
25
+ isPressed: selectedCategory === name,
26
+ onClick: () => {
27
+ onClickCategory(name);
28
+ }
29
+ }, label);
30
+ }));
31
+ }
32
+
33
+ function PatternsExplorerSearch({
34
+ filterValue,
35
+ setFilterValue
36
+ }) {
37
+ const baseClassName = 'block-editor-block-patterns-explorer__search';
38
+ return createElement("div", {
39
+ className: baseClassName
40
+ }, createElement(SearchControl, {
41
+ onChange: setFilterValue,
42
+ value: filterValue,
43
+ label: __('Search for patterns'),
44
+ placeholder: __('Search')
45
+ }));
46
+ }
47
+
48
+ function PatternExplorerSidebar({
49
+ selectedCategory,
50
+ patternCategories,
51
+ onClickCategory,
52
+ filterValue,
53
+ setFilterValue
54
+ }) {
55
+ const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
56
+ return createElement("div", {
57
+ className: baseClassName
58
+ }, createElement(PatternsExplorerSearch, {
59
+ filterValue: filterValue,
60
+ setFilterValue: setFilterValue
61
+ }), !filterValue && createElement(PatternCategoriesList, {
62
+ selectedCategory: selectedCategory,
63
+ patternCategories: patternCategories,
64
+ onClickCategory: onClickCategory
65
+ }));
66
+ }
67
+
68
+ export default PatternExplorerSidebar;
69
+ //# sourceMappingURL=sidebar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"names":["Button","SearchControl","__","PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","map","name","label","PatternsExplorerSearch","filterValue","setFilterValue","PatternExplorerSidebar"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,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C,cAAC,sBAAD;AACC,IAAA,WAAW,EAAGK,WADf;AAEC,IAAA,cAAc,EAAGC;AAFlB,IADD,EAKG,CAAED,WAAF,IACD,cAAC,qBAAD;AACC,IAAA,gBAAgB,EAAGR,gBADpB;AAEC,IAAA,iBAAiB,EAAGC,iBAFrB;AAGC,IAAA,eAAe,EAAGC;AAHnB,IANF,CADD;AAeA;;AAED,eAAeQ,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nfunction PatternCategoriesList( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ `${ baseClassName }__categories-list` }>\n\t\t\t{ patternCategories.map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tclassName={ `${ baseClassName }__categories-list__item` }\n\t\t\t\t\t\tisPressed={ selectedCategory === name }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonClickCategory( name );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerSearch( { filterValue, setFilterValue } ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__search';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<SearchControl\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tlabel={ __( 'Search for patterns' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternExplorerSidebar( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\tfilterValue,\n\tsetFilterValue,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<PatternsExplorerSearch\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tsetFilterValue={ setFilterValue }\n\t\t\t/>\n\t\t\t{ ! filterValue && (\n\t\t\t\t<PatternCategoriesList\n\t\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default PatternExplorerSidebar;\n"]}
@@ -1,14 +1,9 @@
1
1
  import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
- /**
4
- * External dependencies
5
- */
6
- import { fromPairs } from 'lodash';
7
3
  /**
8
4
  * WordPress dependencies
9
5
  */
10
-
11
- import { useMemo, useCallback, useEffect } from '@wordpress/element';
6
+ import { useMemo, useState, useCallback } from '@wordpress/element';
12
7
  import { _x } from '@wordpress/i18n';
13
8
  import { useAsyncList } from '@wordpress/compose';
14
9
  /**
@@ -18,50 +13,35 @@ import { useAsyncList } from '@wordpress/compose';
18
13
  import PatternInserterPanel from './pattern-panel';
19
14
  import usePatternsState from './hooks/use-patterns-state';
20
15
  import BlockPatternList from '../block-patterns-list';
16
+ import PatternsExplorerModal from './block-patterns-explorer/explorer';
21
17
 
22
18
  function BlockPatternsCategory({
23
19
  rootClientId,
24
20
  onInsert,
25
21
  selectedCategory,
26
- onClickCategory
22
+ populatedCategories
27
23
  }) {
28
- const [allPatterns, allCategories, onClick] = usePatternsState(onInsert, rootClientId); // Remove any empty categories
29
-
30
- const populatedCategories = useMemo(() => allCategories.filter(category => allPatterns.some(pattern => {
24
+ const [allPatterns,, onClick] = usePatternsState(onInsert, rootClientId);
25
+ const getPatternIndex = useCallback(pattern => {
31
26
  var _pattern$categories;
32
27
 
33
- return (_pattern$categories = pattern.categories) === null || _pattern$categories === void 0 ? void 0 : _pattern$categories.includes(category.name);
34
- })).sort(({
35
- name: currentName
36
- }, {
37
- name: nextName
38
- }) => {
39
- if (![currentName, nextName].includes('featured')) {
40
- return 0;
41
- }
42
-
43
- return currentName === 'featured' ? -1 : 1;
44
- }), [allPatterns, allCategories]);
45
- const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
46
- useEffect(() => {
47
- if (allPatterns.some(pattern => getPatternIndex(pattern) === Infinity) && !populatedCategories.find(category => category.name === 'uncategorized')) {
48
- populatedCategories.push({
49
- name: 'uncategorized',
50
- label: _x('Uncategorized')
51
- });
52
- }
53
- }, [populatedCategories, allPatterns]);
54
- const getPatternIndex = useCallback(pattern => {
55
- if (!pattern.categories || !pattern.categories.length) {
28
+ if (!((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length)) {
56
29
  return Infinity;
57
30
  }
58
31
 
59
- const indexedCategories = fromPairs(populatedCategories.map(({
32
+ const indexedCategories = populatedCategories.reduce((accumulator, {
60
33
  name
61
- }, index) => [name, index]));
34
+ }, index) => {
35
+ accumulator[name] = index;
36
+ return accumulator;
37
+ }, {});
62
38
  return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
63
39
  }, [populatedCategories]);
64
- const currentCategoryPatterns = useMemo(() => allPatterns.filter(pattern => patternCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : pattern.categories && pattern.categories.includes(patternCategory.name)), [allPatterns, patternCategory]); // Ordering the patterns is important for the async rendering.
40
+ const currentCategoryPatterns = useMemo(() => allPatterns.filter(pattern => {
41
+ var _pattern$categories2;
42
+
43
+ return selectedCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory.name);
44
+ }), [allPatterns, selectedCategory]); // Ordering the patterns is important for the async rendering.
65
45
 
66
46
  const orderedPatterns = useMemo(() => {
67
47
  return currentCategoryPatterns.sort((a, b) => {
@@ -69,18 +49,21 @@ function BlockPatternsCategory({
69
49
  });
70
50
  }, [currentCategoryPatterns, getPatternIndex]);
71
51
  const currentShownPatterns = useAsyncList(orderedPatterns);
72
- return createElement(Fragment, null, !!currentCategoryPatterns.length && createElement(PatternInserterPanel, {
73
- selectedCategory: patternCategory,
74
- patternCategories: populatedCategories,
75
- onClickCategory: onClickCategory
52
+
53
+ if (!currentCategoryPatterns.length) {
54
+ return null;
55
+ }
56
+
57
+ return createElement("div", {
58
+ className: "block-editor-inserter__panel-content"
76
59
  }, createElement(BlockPatternList, {
77
60
  shownPatterns: currentShownPatterns,
78
61
  blockPatterns: currentCategoryPatterns,
79
62
  onClickPattern: onClick,
80
- label: patternCategory.label,
63
+ label: selectedCategory.label,
81
64
  orientation: "vertical",
82
65
  isDraggable: true
83
- })));
66
+ }));
84
67
  }
85
68
 
86
69
  function BlockPatternsTabs({
@@ -89,12 +72,58 @@ function BlockPatternsTabs({
89
72
  onClickCategory,
90
73
  selectedCategory
91
74
  }) {
92
- return createElement(BlockPatternsCategory, {
75
+ const [showPatternsExplorer, setShowPatternsExplorer] = useState(false);
76
+ const [allPatterns, allCategories] = usePatternsState();
77
+ const hasRegisteredCategory = useCallback(pattern => {
78
+ if (!pattern.categories || !pattern.categories.length) {
79
+ return false;
80
+ }
81
+
82
+ return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
83
+ }, [allCategories]); // Remove any empty categories
84
+
85
+ const populatedCategories = useMemo(() => {
86
+ const categories = allCategories.filter(category => allPatterns.some(pattern => {
87
+ var _pattern$categories3;
88
+
89
+ return (_pattern$categories3 = pattern.categories) === null || _pattern$categories3 === void 0 ? void 0 : _pattern$categories3.includes(category.name);
90
+ })).sort(({
91
+ name: currentName
92
+ }, {
93
+ name: nextName
94
+ }) => {
95
+ if (![currentName, nextName].includes('featured')) {
96
+ return 0;
97
+ }
98
+
99
+ return currentName === 'featured' ? -1 : 1;
100
+ });
101
+
102
+ if (allPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
103
+ categories.push({
104
+ name: 'uncategorized',
105
+ label: _x('Uncategorized')
106
+ });
107
+ }
108
+
109
+ return categories;
110
+ }, [allPatterns, allCategories]);
111
+ const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
112
+ return createElement(Fragment, null, !showPatternsExplorer && createElement(Fragment, null, createElement(PatternInserterPanel, {
113
+ selectedCategory: patternCategory,
114
+ patternCategories: populatedCategories,
115
+ onClickCategory: onClickCategory,
116
+ openPatternExplorer: () => setShowPatternsExplorer(true)
117
+ }), createElement(BlockPatternsCategory, {
93
118
  rootClientId: rootClientId,
94
- selectedCategory: selectedCategory,
95
119
  onInsert: onInsert,
96
- onClickCategory: onClickCategory
97
- });
120
+ selectedCategory: patternCategory,
121
+ populatedCategories: populatedCategories
122
+ })), showPatternsExplorer && createElement(PatternsExplorerModal, {
123
+ initialCategory: patternCategory,
124
+ patternCategories: populatedCategories,
125
+ onModalClose: () => setShowPatternsExplorer(false)
126
+ }));
98
127
  }
99
128
 
100
129
  export default BlockPatternsTabs;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["fromPairs","useMemo","useCallback","useEffect","_x","useAsyncList","PatternInserterPanel","usePatternsState","BlockPatternList","BlockPatternsCategory","rootClientId","onInsert","selectedCategory","onClickCategory","allPatterns","allCategories","onClick","populatedCategories","filter","category","some","pattern","categories","includes","name","sort","currentName","nextName","patternCategory","getPatternIndex","Infinity","find","push","label","length","indexedCategories","map","index","Math","min","cat","undefined","currentCategoryPatterns","orderedPatterns","a","b","currentShownPatterns","BlockPatternsTabs"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,WAAlB,EAA+BC,SAA/B,QAAgD,oBAAhD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAAS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QAAMe,eAAe,GAAG1C,OAAO,CAAE,MAAM;AACtC,WAAOyC,uBAAuB,CAACjB,IAAxB,CAA8B,CAAEmB,CAAF,EAAKC,CAAL,KAAY;AAChD,aAAOhB,eAAe,CAAEe,CAAF,CAAf,GAAuBf,eAAe,CAAEgB,CAAF,CAA7C;AACA,KAFM,CAAP;AAGA,GAJ8B,EAI5B,CAAEH,uBAAF,EAA2Bb,eAA3B,CAJ4B,CAA/B;AAMA,QAAMiB,oBAAoB,GAAGzC,YAAY,CAAEsC,eAAF,CAAzC;AAEA,SACC,8BACG,CAAC,CAAED,uBAAuB,CAACR,MAA3B,IACD,cAAC,oBAAD;AACC,IAAA,gBAAgB,EAAGN,eADpB;AAEC,IAAA,iBAAiB,EAAGX,mBAFrB;AAGC,IAAA,eAAe,EAAGJ;AAHnB,KAKC,cAAC,gBAAD;AACC,IAAA,aAAa,EAAGiC,oBADjB;AAEC,IAAA,aAAa,EAAGJ,uBAFjB;AAGC,IAAA,cAAc,EAAG1B,OAHlB;AAIC,IAAA,KAAK,EAAGY,eAAe,CAACK,KAJzB;AAKC,IAAA,WAAW,EAAC,UALb;AAMC,IAAA,WAAW;AANZ,IALD,CAFF,CADD;AAoBA;;AAED,SAASc,iBAAT,CAA4B;AAC3BrC,EAAAA,YAD2B;AAE3BC,EAAAA,QAF2B;AAG3BE,EAAAA,eAH2B;AAI3BD,EAAAA;AAJ2B,CAA5B,EAKI;AACH,SACC,cAAC,qBAAD;AACC,IAAA,YAAY,EAAGF,YADhB;AAEC,IAAA,gBAAgB,EAAGE,gBAFpB;AAGC,IAAA,QAAQ,EAAGD,QAHZ;AAIC,IAAA,eAAe,EAAGE;AAJnB,IADD;AAQA;;AAED,eAAekC,iBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { fromPairs } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\nimport { useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PatternInserterPanel from './pattern-panel';\nimport usePatternsState from './hooks/use-patterns-state';\nimport BlockPatternList from '../block-patterns-list';\n\nfunction BlockPatternsCategory( {\n\trootClientId,\n\tonInsert,\n\tselectedCategory,\n\tonClickCategory,\n} ) {\n\tconst [ allPatterns, allCategories, onClick ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\n\t// Remove any empty categories\n\tconst populatedCategories = useMemo(\n\t\t() =>\n\t\t\tallCategories\n\t\t\t\t.filter( ( category ) =>\n\t\t\t\t\tallPatterns.some( ( pattern ) =>\n\t\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.sort( ( { name: currentName }, { name: nextName } ) => {\n\t\t\t\t\tif ( ! [ currentName, nextName ].includes( 'featured' ) ) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn currentName === 'featured' ? -1 : 1;\n\t\t\t\t} ),\n\t\t[ allPatterns, allCategories ]\n\t);\n\n\tconst patternCategory = selectedCategory\n\t\t? selectedCategory\n\t\t: populatedCategories[ 0 ];\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tallPatterns.some(\n\t\t\t\t( pattern ) => getPatternIndex( pattern ) === Infinity\n\t\t\t) &&\n\t\t\t! populatedCategories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tpopulatedCategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\t}, [ populatedCategories, allPatterns ] );\n\n\tconst getPatternIndex = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn Infinity;\n\t\t\t}\n\t\t\tconst indexedCategories = fromPairs(\n\t\t\t\tpopulatedCategories.map( ( { name }, index ) => [\n\t\t\t\t\tname,\n\t\t\t\t\tindex,\n\t\t\t\t] )\n\t\t\t);\n\t\t\treturn Math.min(\n\t\t\t\t...pattern.categories.map( ( cat ) =>\n\t\t\t\t\tindexedCategories[ cat ] !== undefined\n\t\t\t\t\t\t? indexedCategories[ cat ]\n\t\t\t\t\t\t: Infinity\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ populatedCategories ]\n\t);\n\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) =>\n\t\t\t\tpatternCategory.name === 'uncategorized'\n\t\t\t\t\t? getPatternIndex( pattern ) === Infinity\n\t\t\t\t\t: pattern.categories &&\n\t\t\t\t\t pattern.categories.includes( patternCategory.name )\n\t\t\t),\n\t\t[ allPatterns, patternCategory ]\n\t);\n\n\t// Ordering the patterns is important for the async rendering.\n\tconst orderedPatterns = useMemo( () => {\n\t\treturn currentCategoryPatterns.sort( ( a, b ) => {\n\t\t\treturn getPatternIndex( a ) - getPatternIndex( b );\n\t\t} );\n\t}, [ currentCategoryPatterns, getPatternIndex ] );\n\n\tconst currentShownPatterns = useAsyncList( orderedPatterns );\n\n\treturn (\n\t\t<>\n\t\t\t{ !! currentCategoryPatterns.length && (\n\t\t\t\t<PatternInserterPanel\n\t\t\t\t\tselectedCategory={ patternCategory }\n\t\t\t\t\tpatternCategories={ populatedCategories }\n\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t>\n\t\t\t\t\t<BlockPatternList\n\t\t\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\t\t\tblockPatterns={ currentCategoryPatterns }\n\t\t\t\t\t\tonClickPattern={ onClick }\n\t\t\t\t\t\tlabel={ patternCategory.label }\n\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\tisDraggable\n\t\t\t\t\t/>\n\t\t\t\t</PatternInserterPanel>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction BlockPatternsTabs( {\n\trootClientId,\n\tonInsert,\n\tonClickCategory,\n\tselectedCategory,\n} ) {\n\treturn (\n\t\t<BlockPatternsCategory\n\t\t\trootClientId={ rootClientId }\n\t\t\tselectedCategory={ selectedCategory }\n\t\t\tonInsert={ onInsert }\n\t\t\tonClickCategory={ onClickCategory }\n\t\t/>\n\t);\n}\n\nexport default BlockPatternsTabs;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["useMemo","useState","useCallback","_x","useAsyncList","PatternInserterPanel","usePatternsState","BlockPatternList","PatternsExplorerModal","BlockPatternsCategory","rootClientId","onInsert","selectedCategory","populatedCategories","allPatterns","onClick","getPatternIndex","pattern","categories","length","Infinity","indexedCategories","reduce","accumulator","name","index","Math","min","map","cat","undefined","currentCategoryPatterns","filter","includes","orderedPatterns","sort","a","b","currentShownPatterns","label","BlockPatternsTabs","onClickCategory","showPatternsExplorer","setShowPatternsExplorer","allCategories","hasRegisteredCategory","some","category","currentName","nextName","find","push","patternCategory"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,QAAlB,EAA4BC,WAA5B,QAA+C,oBAA/C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,iBAAjC;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AACA,OAAOC,qBAAP,MAAkC,oCAAlC;;AAEA,SAASC,qBAAT,CAAgC;AAC/BC,EAAAA,YAD+B;AAE/BC,EAAAA,QAF+B;AAG/BC,EAAAA,gBAH+B;AAI/BC,EAAAA;AAJ+B,CAAhC,EAKI;AACH,QAAM,CAAEC,WAAF,GAAiBC,OAAjB,IAA6BT,gBAAgB,CAClDK,QADkD,EAElDD,YAFkD,CAAnD;AAKA,QAAMM,eAAe,GAAGd,WAAW,CAChCe,OAAF,IAAe;AAAA;;AACd,QAAK,yBAAEA,OAAO,CAACC,UAAV,gDAAE,oBA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AHpB;AAIC,IAAA,mBAAmB,EAAGvC;AAJvB,IATD,CAFF,EAmBG6B,oBAAoB,IACrB,cAAC,qBAAD;AACC,IAAA,eAAe,EAAGU,eADnB;AAEC,IAAA,iBAAiB,EAAGvC,mBAFrB;AAGC,IAAA,YAAY,EAAG,MAAM8B,uBAAuB,CAAE,KAAF;AAH7C,IApBF,CADD;AA6BA;;AAED,eAAeH,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\nimport { useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PatternInserterPanel from './pattern-panel';\nimport usePatternsState from './hooks/use-patterns-state';\nimport BlockPatternList from '../block-patterns-list';\nimport PatternsExplorerModal from './block-patterns-explorer/explorer';\n\nfunction BlockPatternsCategory( {\n\trootClientId,\n\tonInsert,\n\tselectedCategory,\n\tpopulatedCategories,\n} ) {\n\tconst [ allPatterns, , onClick ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\n\tconst getPatternIndex = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories?.length ) {\n\t\t\t\treturn Infinity;\n\t\t\t}\n\t\t\tconst indexedCategories = populatedCategories.reduce(\n\t\t\t\t( accumulator, { name }, index ) => {\n\t\t\t\t\taccumulator[ name ] = index;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t\treturn Math.min(\n\t\t\t\t...pattern.categories.map( ( cat ) =>\n\t\t\t\t\tindexedCategories[ cat ] !== undefined\n\t\t\t\t\t\t? indexedCategories[ cat ]\n\t\t\t\t\t\t: Infinity\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ populatedCategories ]\n\t);\n\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) =>\n\t\t\t\tselectedCategory.name === 'uncategorized'\n\t\t\t\t\t? getPatternIndex( pattern ) === Infinity\n\t\t\t\t\t: pattern.categories?.includes( selectedCategory.name )\n\t\t\t),\n\t\t[ allPatterns, selectedCategory ]\n\t);\n\n\t// Ordering the patterns is important for the async rendering.\n\tconst orderedPatterns = useMemo( () => {\n\t\treturn currentCategoryPatterns.sort( ( a, b ) => {\n\t\t\treturn getPatternIndex( a ) - getPatternIndex( b );\n\t\t} );\n\t}, [ currentCategoryPatterns, getPatternIndex ] );\n\n\tconst currentShownPatterns = useAsyncList( orderedPatterns );\n\n\tif ( ! currentCategoryPatterns.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__panel-content\">\n\t\t\t<BlockPatternList\n\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\tblockPatterns={ currentCategoryPatterns }\n\t\t\t\tonClickPattern={ onClick }\n\t\t\t\tlabel={ selectedCategory.label }\n\t\t\t\torientation=\"vertical\"\n\t\t\t\tisDraggable\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction BlockPatternsTabs( {\n\trootClientId,\n\tonInsert,\n\tonClickCategory,\n\tselectedCategory,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\tconst [ allPatterns, allCategories ] = usePatternsState();\n\n\tconst hasRegisteredCategory = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn pattern.categories.some( ( cat ) =>\n\t\t\t\tallCategories.some( ( category ) => category.name === cat )\n\t\t\t);\n\t\t},\n\t\t[ allCategories ]\n\t);\n\n\t// Remove any empty categories\n\tconst populatedCategories = useMemo( () => {\n\t\tconst categories = allCategories\n\t\t\t.filter( ( category ) =>\n\t\t\t\tallPatterns.some( ( pattern ) =>\n\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.sort( ( { name: currentName }, { name: nextName } ) => {\n\t\t\t\tif ( ! [ currentName, nextName ].includes( 'featured' ) ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn currentName === 'featured' ? -1 : 1;\n\t\t\t} );\n\n\t\tif (\n\t\t\tallPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern )\n\t\t\t) &&\n\t\t\t! categories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tcategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\n\t\treturn categories;\n\t}, [ allPatterns, allCategories ] );\n\n\tconst patternCategory = selectedCategory\n\t\t? selectedCategory\n\t\t: populatedCategories[ 0 ];\n\n\treturn (\n\t\t<>\n\t\t\t{ ! showPatternsExplorer && (\n\t\t\t\t<>\n\t\t\t\t\t<PatternInserterPanel\n\t\t\t\t\t\tselectedCategory={ patternCategory }\n\t\t\t\t\t\tpatternCategories={ populatedCategories }\n\t\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t\t\topenPatternExplorer={ () =>\n\t\t\t\t\t\t\tsetShowPatternsExplorer( true )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockPatternsCategory\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tselectedCategory={ patternCategory }\n\t\t\t\t\t\tpopulatedCategories={ populatedCategories }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showPatternsExplorer && (\n\t\t\t\t<PatternsExplorerModal\n\t\t\t\t\tinitialCategory={ patternCategory }\n\t\t\t\t\tpatternCategories={ populatedCategories }\n\t\t\t\t\tonModalClose={ () => setShowPatternsExplorer( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default BlockPatternsTabs;\n"]}
@@ -11,27 +11,24 @@ import { store as blockEditorStore } from '../../../store';
11
11
 
12
12
  function useBlockTypeImpressions(blockTypes) {
13
13
  const {
14
- blockTypeImpressions,
15
- enableEditorOnboarding
14
+ blockTypeImpressions
16
15
  } = useSelect(select => {
17
16
  const {
18
17
  getSettings: getBlockEditorSettings
19
18
  } = select(blockEditorStore);
20
19
  const {
21
- editorOnboarding,
22
20
  impressions
23
21
  } = getBlockEditorSettings();
24
22
  return {
25
- blockTypeImpressions: impressions,
26
- enableEditorOnboarding: editorOnboarding
23
+ blockTypeImpressions: impressions
27
24
  };
28
25
  }, []);
29
26
  const {
30
27
  updateSettings
31
28
  } = useDispatch(blockEditorStore);
32
- const items = enableEditorOnboarding ? blockTypes.map(blockType => ({ ...blockType,
29
+ const items = blockTypes.map(blockType => ({ ...blockType,
33
30
  isNew: blockTypeImpressions[blockType.name] > 0
34
- })) : blockTypes;
31
+ }));
35
32
 
36
33
  const trackBlockTypeSelected = ({
37
34
  name
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-type-impressions.native.js"],"names":["useSelect","useDispatch","setBlockTypeImpressions","store","blockEditorStore","useBlockTypeImpressions","blockTypes","blockTypeImpressions","enableEditorOnboarding","select","getSettings","getBlockEditorSettings","editorOnboarding","impressions","updateSettings","items","map","blockType","isNew","name","trackBlockTypeSelected","updatedBlockTypeImpressions"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,uBAAT,QAAwC,gCAAxC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,gBAA1C;;AAEA,SAASC,uBAAT,CAAkCC,UAAlC,EAA+C;AAC9C,QAAM;AAAEC,IAAAA,oBAAF;AAAwBC,IAAAA;AAAxB,MAAmDR,SAAS,CAC/DS,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,WAAW,EAAEC;AAAf,QAA0CF,MAAM,CACrDL,gBADqD,CAAtD;AAGA,UAAM;AAAEQ,MAAAA,gBAAF;AAAoBC,MAAAA;AAApB,QAAoCF,sBAAsB,EAAhE;AAEA,WAAO;AACNJ,MAAAA,oBAAoB,EAAEM,WADhB;AAENL,MAAAA,sBAAsB,EAAEI;AAFlB,KAAP;AAIA,GAXgE,EAYjE,EAZiE,CAAlE;AAcA,QAAM;AAAEE,IAAAA;AAAF,MAAqBb,WAAW,CAAEG,gBAAF,CAAtC;AAEA,QAAMW,KAAK,GAAGP,sBAAsB,GACjCF,UAAU,CAACU,GAAX,CAAkBC,SAAF,KAAmB,EACnC,GAAGA,SADgC;AAEnCC,IAAAA,KAAK,EAAEX,oBAAoB,CAAEU,SAAS,CAACE,IAAZ,CAApB,GAAyC;AAFb,GAAnB,CAAhB,CADiC,GAKjCb,UALH;;AAOA,QAAMc,sBAAsB,GAAG,CAAE;AAAED,IAAAA;AAAF,GAAF,KAAgB;AAC9C,QAAKZ,oBAAoB,CAAEY,IAAF,CAApB,GAA+B,CAApC,EAAwC;AACvC,YAAME,2BAA2B,GAAG,EACnC,GAAGd,oBADgC;AAEnC,SAAEY,IAAF,GAAU;AAFyB,OAApC,CADuC,CAKvC;;AACAL,MAAAA,cAAc,CAAE;AACfD,QAAAA,WAAW,EAAEQ;AADE,OAAF,CAAd,CANuC,CAUvC;;AACAnB,MAAAA,uBAAuB,CAAEmB,2BAAF,CAAvB;AACA;AACD,GAdD;;AAgBA,SAAO;AAAEN,IAAAA,KAAF;AAASK,IAAAA;AAAT,GAAP;AACA;;AAED,eAAef,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\nfunction useBlockTypeImpressions( blockTypes ) {\n\tconst { blockTypeImpressions, enableEditorOnboarding } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings: getBlockEditorSettings } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst { editorOnboarding, impressions } = getBlockEditorSettings();\n\n\t\t\treturn {\n\t\t\t\tblockTypeImpressions: impressions,\n\t\t\t\tenableEditorOnboarding: editorOnboarding,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { updateSettings } = useDispatch( blockEditorStore );\n\n\tconst items = enableEditorOnboarding\n\t\t? blockTypes.map( ( blockType ) => ( {\n\t\t\t\t...blockType,\n\t\t\t\tisNew: blockTypeImpressions[ blockType.name ] > 0,\n\t\t } ) )\n\t\t: blockTypes;\n\n\tconst trackBlockTypeSelected = ( { name } ) => {\n\t\tif ( blockTypeImpressions[ name ] > 0 ) {\n\t\t\tconst updatedBlockTypeImpressions = {\n\t\t\t\t...blockTypeImpressions,\n\t\t\t\t[ name ]: 0,\n\t\t\t};\n\t\t\t// Persist block type impression to JavaScript store\n\t\t\tupdateSettings( {\n\t\t\t\timpressions: updatedBlockTypeImpressions,\n\t\t\t} );\n\n\t\t\t// Persist block type impression count to native app store\n\t\t\tsetBlockTypeImpressions( updatedBlockTypeImpressions );\n\t\t}\n\t};\n\n\treturn { items, trackBlockTypeSelected };\n}\n\nexport default useBlockTypeImpressions;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-type-impressions.native.js"],"names":["useSelect","useDispatch","setBlockTypeImpressions","store","blockEditorStore","useBlockTypeImpressions","blockTypes","blockTypeImpressions","select","getSettings","getBlockEditorSettings","impressions","updateSettings","items","map","blockType","isNew","name","trackBlockTypeSelected","updatedBlockTypeImpressions"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,uBAAT,QAAwC,gCAAxC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,gBAA1C;;AAEA,SAASC,uBAAT,CAAkCC,UAAlC,EAA+C;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAA2BP,SAAS,CAAIQ,MAAF,IAAc;AACzD,UAAM;AAAEC,MAAAA,WAAW,EAAEC;AAAf,QAA0CF,MAAM,CACrDJ,gBADqD,CAAtD;AAGA,UAAM;AAAEO,MAAAA;AAAF,QAAkBD,sBAAsB,EAA9C;AAEA,WAAO;AACNH,MAAAA,oBAAoB,EAAEI;AADhB,KAAP;AAGA,GATyC,EASvC,EATuC,CAA1C;AAUA,QAAM;AAAEC,IAAAA;AAAF,MAAqBX,WAAW,CAAEG,gBAAF,CAAtC;AAEA,QAAMS,KAAK,GAAGP,UAAU,CAACQ,GAAX,CAAkBC,SAAF,KAAmB,EAChD,GAAGA,SAD6C;AAEhDC,IAAAA,KAAK,EAAET,oBAAoB,CAAEQ,SAAS,CAACE,IAAZ,CAApB,GAAyC;AAFA,GAAnB,CAAhB,CAAd;;AAIA,QAAMC,sBAAsB,GAAG,CAAE;AAAED,IAAAA;AAAF,GAAF,KAAgB;AAC9C,QAAKV,oBAAoB,CAAEU,IAAF,CAApB,GAA+B,CAApC,EAAwC;AACvC,YAAME,2BAA2B,GAAG,EACnC,GAAGZ,oBADgC;AAEnC,SAAEU,IAAF,GAAU;AAFyB,OAApC,CADuC,CAKvC;;AACAL,MAAAA,cAAc,CAAE;AACfD,QAAAA,WAAW,EAAEQ;AADE,OAAF,CAAd,CANuC,CAUvC;;AACAjB,MAAAA,uBAAuB,CAAEiB,2BAAF,CAAvB;AACA;AACD,GAdD;;AAgBA,SAAO;AAAEN,IAAAA,KAAF;AAASK,IAAAA;AAAT,GAAP;AACA;;AAED,eAAeb,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\nfunction useBlockTypeImpressions( blockTypes ) {\n\tconst { blockTypeImpressions } = useSelect( ( select ) => {\n\t\tconst { getSettings: getBlockEditorSettings } = select(\n\t\t\tblockEditorStore\n\t\t);\n\t\tconst { impressions } = getBlockEditorSettings();\n\n\t\treturn {\n\t\t\tblockTypeImpressions: impressions,\n\t\t};\n\t}, [] );\n\tconst { updateSettings } = useDispatch( blockEditorStore );\n\n\tconst items = blockTypes.map( ( blockType ) => ( {\n\t\t...blockType,\n\t\tisNew: blockTypeImpressions[ blockType.name ] > 0,\n\t} ) );\n\tconst trackBlockTypeSelected = ( { name } ) => {\n\t\tif ( blockTypeImpressions[ name ] > 0 ) {\n\t\t\tconst updatedBlockTypeImpressions = {\n\t\t\t\t...blockTypeImpressions,\n\t\t\t\t[ name ]: 0,\n\t\t\t};\n\t\t\t// Persist block type impression to JavaScript store\n\t\t\tupdateSettings( {\n\t\t\t\timpressions: updatedBlockTypeImpressions,\n\t\t\t} );\n\n\t\t\t// Persist block type impression count to native app store\n\t\t\tsetBlockTypeImpressions( updatedBlockTypeImpressions );\n\t\t}\n\t};\n\n\treturn { items, trackBlockTypeSelected };\n}\n\nexport default useBlockTypeImpressions;\n"]}
@@ -1,4 +1,4 @@
1
- import { createElement, Fragment } from "@wordpress/element";
1
+ import { createElement } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * External dependencies
@@ -8,15 +8,18 @@ import classnames from 'classnames';
8
8
  * WordPress dependencies
9
9
  */
10
10
 
11
- import { SelectControl } from '@wordpress/components';
12
- import { __ } from '@wordpress/i18n';
11
+ import { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';
12
+ import { __, _x } from '@wordpress/i18n';
13
+ import { useViewportMatch } from '@wordpress/compose';
13
14
 
14
15
  function PatternInserterPanel({
15
16
  selectedCategory,
16
17
  patternCategories,
17
18
  onClickCategory,
18
- children
19
+ openPatternExplorer
19
20
  }) {
21
+ const isMobile = useViewportMatch('medium', '<');
22
+
20
23
  const categoryOptions = () => {
21
24
  const options = [];
22
25
  patternCategories.map(patternCategory => {
@@ -32,22 +35,24 @@ function PatternInserterPanel({
32
35
  onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
33
36
  };
34
37
 
35
- const getPanelHeaderClassName = () => {
36
- return classnames('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns');
37
- }; // In iOS-based mobile devices, the onBlur will fire when selecting an option
38
+ const className = classnames('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns'); // In iOS-based mobile devices, the onBlur will fire when selecting an option
38
39
  // from a Select element. To prevent closing the useDialog on iOS devices, we
39
40
  // stop propagating the onBlur event if there is no relatedTarget, which means
40
41
  // that the user most likely did not click on an element within the editor canvas.
41
42
 
42
-
43
43
  const onBlur = event => {
44
44
  if (!(event !== null && event !== void 0 && event.relatedTarget)) {
45
45
  event.stopPropagation();
46
46
  }
47
47
  };
48
48
 
49
- return createElement(Fragment, null, createElement("div", {
50
- className: getPanelHeaderClassName()
49
+ return createElement(Flex, {
50
+ justify: "space-between",
51
+ align: "start",
52
+ gap: "4",
53
+ className: className
54
+ }, createElement(FlexItem, {
55
+ isBlock: true
51
56
  }, createElement(SelectControl, {
52
57
  className: "block-editor-inserter__panel-dropdown",
53
58
  label: __('Filter patterns'),
@@ -56,9 +61,12 @@ function PatternInserterPanel({
56
61
  onChange: onChangeSelect,
57
62
  onBlur: onBlur,
58
63
  options: categoryOptions()
59
- })), createElement("div", {
60
- className: "block-editor-inserter__panel-content"
61
- }, children));
64
+ })), !isMobile && createElement(FlexItem, null, createElement(Button, {
65
+ variant: "secondary",
66
+ className: "block-editor-inserter__patterns-explorer-expand",
67
+ label: __('Explore all patterns'),
68
+ onClick: () => openPatternExplorer()
69
+ }, _x('Explore', 'Label for showing all block patterns'))));
62
70
  }
63
71
 
64
72
  export default PatternInserterPanel;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/pattern-panel.js"],"names":["classnames","SelectControl","__","PatternInserterPanel","selectedCategory","patternCategories","onClickCategory","children","categoryOptions","options","map","patternCategory","push","value","name","label","onChangeSelect","selected","find","getPanelHeaderClassName","onBlur","event","relat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AAmB,MAHpB;AAIC,IAAA,KAAK,EAAGE,gBAAgB,CAACU,IAJ1B;AAKC,IAAA,QAAQ,EAAGE,cALZ;AAMC,IAAA,MAAM,EAAGI,MANV;AAOC,IAAA,OAAO,EAAGZ,eAAe;AAP1B,IADD,CADD,EAYC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGD,QADH,CAZD,CADD;AAkBA;;AAED,eAAeJ,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nfunction PatternInserterPanel( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\tchildren,\n} ) {\n\tconst categoryOptions = () => {\n\t\tconst options = [];\n\n\t\tpatternCategories.map( ( patternCategory ) => {\n\t\t\treturn options.push( {\n\t\t\t\tvalue: patternCategory.name,\n\t\t\t\tlabel: patternCategory.label,\n\t\t\t} );\n\t\t} );\n\n\t\treturn options;\n\t};\n\n\tconst onChangeSelect = ( selected ) => {\n\t\tonClickCategory(\n\t\t\tpatternCategories.find(\n\t\t\t\t( patternCategory ) => selected === patternCategory.name\n\t\t\t)\n\t\t);\n\t};\n\n\tconst getPanelHeaderClassName = () => {\n\t\treturn classnames(\n\t\t\t'block-editor-inserter__panel-header',\n\t\t\t'block-editor-inserter__panel-header-patterns'\n\t\t);\n\t};\n\n\t// In iOS-based mobile devices, the onBlur will fire when selecting an option\n\t// from a Select element. To prevent closing the useDialog on iOS devices, we\n\t// stop propagating the onBlur event if there is no relatedTarget, which means\n\t// that the user most likely did not click on an element within the editor canvas.\n\tconst onBlur = ( event ) => {\n\t\tif ( ! event?.relatedTarget ) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<div className={ getPanelHeaderClassName() }>\n\t\t\t\t<SelectControl\n\t\t\t\t\tclassName=\"block-editor-inserter__panel-dropdown\"\n\t\t\t\t\tlabel={ __( 'Filter patterns' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tvalue={ selectedCategory.name }\n\t\t\t\t\tonChange={ onChangeSelect }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\toptions={ categoryOptions() }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-inserter__panel-content\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default PatternInserterPanel;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/pattern-panel.js"],"names":["classnames","Flex","FlexItem","SelectControl","Button","__","_x","useViewportMatch","PatternInserterPanel","selectedCategory","patternCategories","onClickCategory","openPatternExplorer","isMobile","categoryOptions","options","map","patternCategory","push","value","name","label","onChangeSelect","selected","find","className","onBlur","event","relatedTarget","stopPropagation"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,EAAeC,QAAf,EAAyBC,aAAzB,EAAwCC,MAAxC,QAAsD,uBAAtD;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,gBAAT,QAAiC,oBAAjC;;AAEA,SAASC,oBAAT,CAA+B;AAC9BC,EAAAA,gBAD8B;AAE9BC,EAAAA,iBAF8B;AAG9BC,EAAAA,eAH8B;AAI9BC,EAAAA;AAJ8B,CAA/B,EAKI;AACH,QAAMC,QAAQ,GAAGN,gBAAgB,CAAE,QAAF,EAAY,GAAZ,CAAjC;;AACA,QAAMO,eAAe,GAAG,MAAM;AAC7B,UAAMC,OAAO,GAAG,EAAhB;AAEAL,IAAAA,iBAAiB,CAACM,GAAlB,CAAyBC,eAAF,IAAuB;AAC7C,aAAOF,OAAO,CAACG,IAAR,CAAc;AACpBC,QAAAA,KAAK,EAAEF,eAAe,CAACG,IADH;AAEpBC,QAAAA,KAAK,EAAEJ,eAAe,CAACI;AAFH,OAAd,CAAP;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eE,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\n\nfunction PatternInserterPanel( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\topenPatternExplorer,\n} ) {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst categoryOptions = () => {\n\t\tconst options = [];\n\n\t\tpatternCategories.map( ( patternCategory ) => {\n\t\t\treturn options.push( {\n\t\t\t\tvalue: patternCategory.name,\n\t\t\t\tlabel: patternCategory.label,\n\t\t\t} );\n\t\t} );\n\n\t\treturn options;\n\t};\n\n\tconst onChangeSelect = ( selected ) => {\n\t\tonClickCategory(\n\t\t\tpatternCategories.find(\n\t\t\t\t( patternCategory ) => selected === patternCategory.name\n\t\t\t)\n\t\t);\n\t};\n\n\tconst className = classnames(\n\t\t'block-editor-inserter__panel-header',\n\t\t'block-editor-inserter__panel-header-patterns'\n\t);\n\n\t// In iOS-based mobile devices, the onBlur will fire when selecting an option\n\t// from a Select element. To prevent closing the useDialog on iOS devices, we\n\t// stop propagating the onBlur event if there is no relatedTarget, which means\n\t// that the user most likely did not click on an element within the editor canvas.\n\tconst onBlur = ( event ) => {\n\t\tif ( ! event?.relatedTarget ) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\t};\n\n\treturn (\n\t\t<Flex\n\t\t\tjustify=\"space-between\"\n\t\t\talign=\"start\"\n\t\t\tgap=\"4\"\n\t\t\tclassName={ className }\n\t\t>\n\t\t\t<FlexItem isBlock>\n\t\t\t\t<SelectControl\n\t\t\t\t\tclassName=\"block-editor-inserter__panel-dropdown\"\n\t\t\t\t\tlabel={ __( 'Filter patterns' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tvalue={ selectedCategory.name }\n\t\t\t\t\tonChange={ onChangeSelect }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\toptions={ categoryOptions() }\n\t\t\t\t/>\n\t\t\t</FlexItem>\n\t\t\t{ ! isMobile && (\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explorer-expand\"\n\t\t\t\t\t\tlabel={ __( 'Explore all patterns' ) }\n\t\t\t\t\t\tonClick={ () => openPatternExplorer() }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x(\n\t\t\t\t\t\t\t'Explore',\n\t\t\t\t\t\t\t'Label for showing all block patterns'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\nexport default PatternInserterPanel;\n"]}
@@ -5,10 +5,12 @@ import { createSlotFill } from '@wordpress/components';
5
5
  const InspectorControlsDefault = createSlotFill('InspectorControls');
6
6
  const InspectorControlsAdvanced = createSlotFill('InspectorAdvancedControls');
7
7
  const InspectorControlsDimensions = createSlotFill('InspectorControlsDimensions');
8
+ const InspectorControlsTypography = createSlotFill('InspectorControlsTypography');
8
9
  const groups = {
9
10
  default: InspectorControlsDefault,
10
11
  advanced: InspectorControlsAdvanced,
11
- dimensions: InspectorControlsDimensions
12
+ dimensions: InspectorControlsDimensions,
13
+ typography: InspectorControlsTypography
12
14
  };
13
15
  export default groups;
14
16
  //# sourceMappingURL=groups.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["createSlotFill","InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsDimensions","groups","default","advanced","dimensions"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AAEA,MAAMC,wBAAwB,GAAGD,cAAc,CAAE,mBAAF,CAA/C;AACA,MAAME,yBAAyB,GAAGF,cAAc,CAAE,2BAAF,CAAhD;AACA,MAAMG,2BAA2B,GAAGH,cAAc,CACjD,6BADiD,CAAlD;AAIA,MAAMI,MAAM,GAAG;AACdC,EAAAA,OAAO,EAAEJ,wBADK;AAEdK,EAAAA,QAAQ,EAAEJ,yBAFI;AAGdK,EAAAA,UAAU,EAAEJ;AAHE,CAAf;AAMA,eAAeC,MAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill } from '@wordpress/components';\n\nconst InspectorControlsDefault = createSlotFill( 'InspectorControls' );\nconst InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );\nconst InspectorControlsDimensions = createSlotFill(\n\t'InspectorControlsDimensions'\n);\n\nconst groups = {\n\tdefault: InspectorControlsDefault,\n\tadvanced: InspectorControlsAdvanced,\n\tdimensions: InspectorControlsDimensions,\n};\n\nexport default groups;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["createSlotFill","InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsDimensions","InspectorControlsTypography","groups","default","advanced","dimensions","typography"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AAEA,MAAMC,wBAAwB,GAAGD,cAAc,CAAE,mBAAF,CAA/C;AACA,MAAME,yBAAyB,GAAGF,cAAc,CAAE,2BAAF,CAAhD;AACA,MAAMG,2BAA2B,GAAGH,cAAc,CACjD,6BADiD,CAAlD;AAGA,MAAMI,2BAA2B,GAAGJ,cAAc,CACjD,6BADiD,CAAlD;AAIA,MAAMK,MAAM,GAAG;AACdC,EAAAA,OAAO,EAAEL,wBADK;AAEdM,EAAAA,QAAQ,EAAEL,yBAFI;AAGdM,EAAAA,UAAU,EAAEL,2BAHE;AAIdM,EAAAA,UAAU,EAAEL;AAJE,CAAf;AAOA,eAAeC,MAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill } from '@wordpress/components';\n\nconst InspectorControlsDefault = createSlotFill( 'InspectorControls' );\nconst InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );\nconst InspectorControlsDimensions = createSlotFill(\n\t'InspectorControlsDimensions'\n);\nconst InspectorControlsTypography = createSlotFill(\n\t'InspectorControlsTypography'\n);\n\nconst groups = {\n\tdefault: InspectorControlsDefault,\n\tadvanced: InspectorControlsAdvanced,\n\tdimensions: InspectorControlsDimensions,\n\ttypography: InspectorControlsTypography,\n};\n\nexport default groups;\n"]}
@@ -13,15 +13,18 @@ import useSetting from '../../components/use-setting';
13
13
  /**
14
14
  * Control for letter-spacing.
15
15
  *
16
- * @param {Object} props Component props.
17
- * @param {string} props.value Currently selected letter-spacing.
18
- * @param {Function} props.onChange Handles change in letter-spacing selection.
19
- * @return {WPElement} Letter-spacing control.
16
+ * @param {Object} props Component props.
17
+ * @param {string} props.value Currently selected letter-spacing.
18
+ * @param {Function} props.onChange Handles change in letter-spacing selection.
19
+ * @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.
20
+ *
21
+ * @return {WPElement} Letter-spacing control.
20
22
  */
21
23
 
22
24
  export default function LetterSpacingControl({
23
25
  value,
24
- onChange
26
+ onChange,
27
+ __unstableInputWidth = '60px'
25
28
  }) {
26
29
  const units = useCustomUnits({
27
30
  availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem'],
@@ -34,7 +37,7 @@ export default function LetterSpacingControl({
34
37
  return createElement(UnitControl, {
35
38
  label: __('Letter-spacing'),
36
39
  value: value,
37
- __unstableInputWidth: "60px",
40
+ __unstableInputWidth: __unstableInputWidth,
38
41
  units: units,
39
42
  onChange: onChange
40
43
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/letter-spacing-control/index.js"],"names":["__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__","useSetting","LetterSpacingControl","value","onChange","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,yBAAyB,IAAIC,WAD9B,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,8BAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,oBAAT,CAA+B;AAAEC,EAAAA,KAAF;AAASC,EAAAA;AAAT,CAA/B,EAAqD;AACnE,QAAMC,KAAK,GAAGN,cAAc,CAAE;AAC7BO,IAAAA,cAAc,EAAEL,UAAU,CAAE,eAAF,CAAV,IAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADpB;AAE7BM,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,GAAN;AAAWC,MAAAA,EAAE,EAAE,IAAf;AAAqBC,MAAAA,GAAG,EAAE;AAA1B;AAFc,GAAF,CAA5B;AAIA,SACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGV,EAAE,CAAE,gBAAF,CADX;AAEC,IAAA,KAAK,EAAGG,KAFT;AAGC,IAAA,oBAAoB,EAAC,MAHtB;AAIC,IAAA,KAAK,EAAGE,KAJT;AAKC,IAAA,QAAQ,EAAGD;AALZ,IADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../../components/use-setting';\n\n/**\n * Control for letter-spacing.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected letter-spacing.\n * @param {Function} props.onChange Handles change in letter-spacing selection.\n * @return {WPElement} Letter-spacing control.\n */\nexport default function LetterSpacingControl( { value, onChange } ) {\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t\tdefaultValues: { px: '2', em: '.2', rem: '.2' },\n\t} );\n\treturn (\n\t\t<UnitControl\n\t\t\tlabel={ __( 'Letter-spacing' ) }\n\t\t\tvalue={ value }\n\t\t\t__unstableInputWidth=\"60px\"\n\t\t\tunits={ units }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/letter-spacing-control/index.js"],"names":["__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__","useSetting","LetterSpacingControl","value","onChange","__unstableInputWidth","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,yBAAyB,IAAIC,WAD9B,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,8BAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,oBAAT,CAA+B;AAC7CC,EAAAA,KAD6C;AAE7CC,EAAAA,QAF6C;AAG7CC,EAAAA,oBAAoB,GAAG;AAHsB,CAA/B,EAIX;AACH,QAAMC,KAAK,GAAGP,cAAc,CAAE;AAC7BQ,IAAAA,cAAc,EAAEN,UAAU,CAAE,eAAF,CAAV,IAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADpB;AAE7BO,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,GAAN;AAAWC,MAAAA,EAAE,EAAE,IAAf;AAAqBC,MAAAA,GAAG,EAAE;AAA1B;AAFc,GAAF,CAA5B;AAIA,SACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGX,EAAE,CAAE,gBAAF,CADX;AAEC,IAAA,KAAK,EAAGG,KAFT;AAGC,IAAA,oBAAoB,EAAGE,oBAHxB;AAIC,IAAA,KAAK,EAAGC,KAJT;AAKC,IAAA,QAAQ,EAAGF;AALZ,IADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../../components/use-setting';\n\n/**\n * Control for letter-spacing.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected letter-spacing.\n * @param {Function} props.onChange Handles change in letter-spacing selection.\n * @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.\n *\n * @return {WPElement} Letter-spacing control.\n */\nexport default function LetterSpacingControl( {\n\tvalue,\n\tonChange,\n\t__unstableInputWidth = '60px',\n} ) {\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t\tdefaultValues: { px: '2', em: '.2', rem: '.2' },\n\t} );\n\treturn (\n\t\t<UnitControl\n\t\t\tlabel={ __( 'Letter-spacing' ) }\n\t\t\tvalue={ value }\n\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\tunits={ units }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n"]}