@wordpress/editor 13.27.2 → 13.28.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 (346) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bindings/post-meta.js +1 -2
  3. package/build/bindings/post-meta.js.map +1 -1
  4. package/build/components/autocompleters/user.js +1 -2
  5. package/build/components/autocompleters/user.js.map +1 -1
  6. package/build/components/autosave-monitor/index.js +1 -2
  7. package/build/components/autosave-monitor/index.js.map +1 -1
  8. package/build/components/block-manager/category.js +1 -2
  9. package/build/components/block-manager/category.js.map +1 -1
  10. package/build/components/block-manager/checklist.js +1 -2
  11. package/build/components/block-manager/checklist.js.map +1 -1
  12. package/build/components/block-manager/index.js +1 -2
  13. package/build/components/block-manager/index.js.map +1 -1
  14. package/build/components/deprecated.js +52 -104
  15. package/build/components/deprecated.js.map +1 -1
  16. package/build/components/document-bar/index.js +5 -6
  17. package/build/components/document-bar/index.js.map +1 -1
  18. package/build/components/document-outline/check.js +1 -2
  19. package/build/components/document-outline/check.js.map +1 -1
  20. package/build/components/document-outline/index.js +1 -2
  21. package/build/components/document-outline/index.js.map +1 -1
  22. package/build/components/document-outline/item.js +1 -2
  23. package/build/components/document-outline/item.js.map +1 -1
  24. package/build/components/document-tools/index.js +1 -2
  25. package/build/components/document-tools/index.js.map +1 -1
  26. package/build/components/editor-canvas/edit-template-blocks-notification.js +11 -18
  27. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  28. package/build/components/editor-canvas/index.js +14 -10
  29. package/build/components/editor-canvas/index.js.map +1 -1
  30. package/build/components/editor-help/add-blocks.native.js +1 -2
  31. package/build/components/editor-help/add-blocks.native.js.map +1 -1
  32. package/build/components/editor-help/customize-blocks.native.js +1 -2
  33. package/build/components/editor-help/customize-blocks.native.js.map +1 -1
  34. package/build/components/editor-help/help-detail-navigation-screen.native.js +1 -2
  35. package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
  36. package/build/components/editor-help/help-get-support-button.native.js +1 -2
  37. package/build/components/editor-help/help-get-support-button.native.js.map +1 -1
  38. package/build/components/editor-help/help-section-title.native.js +1 -2
  39. package/build/components/editor-help/help-section-title.native.js.map +1 -1
  40. package/build/components/editor-help/help-topic-row.native.js +1 -2
  41. package/build/components/editor-help/help-topic-row.native.js.map +1 -1
  42. package/build/components/editor-help/icon-move-blocks.native.js +1 -2
  43. package/build/components/editor-help/icon-move-blocks.native.js.map +1 -1
  44. package/build/components/editor-help/index.native.js +1 -2
  45. package/build/components/editor-help/index.native.js.map +1 -1
  46. package/build/components/editor-help/intro-to-blocks.native.js +1 -2
  47. package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
  48. package/build/components/editor-help/move-blocks.native.js +1 -2
  49. package/build/components/editor-help/move-blocks.native.js.map +1 -1
  50. package/build/components/editor-help/remove-blocks.native.js +1 -2
  51. package/build/components/editor-help/remove-blocks.native.js.map +1 -1
  52. package/build/components/editor-history/redo.js +1 -2
  53. package/build/components/editor-history/redo.js.map +1 -1
  54. package/build/components/editor-history/undo.js +1 -2
  55. package/build/components/editor-history/undo.js.map +1 -1
  56. package/build/components/editor-notices/index.js +1 -2
  57. package/build/components/editor-notices/index.js.map +1 -1
  58. package/build/components/editor-snackbars/index.js +3 -1
  59. package/build/components/editor-snackbars/index.js.map +1 -1
  60. package/build/components/entities-saved-states/entity-record-item.js +1 -1
  61. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  62. package/build/components/entities-saved-states/entity-type-list.js +7 -7
  63. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  64. package/build/components/entities-saved-states/index.js +4 -1
  65. package/build/components/entities-saved-states/index.js.map +1 -1
  66. package/build/components/error-boundary/index.js +1 -2
  67. package/build/components/error-boundary/index.js.map +1 -1
  68. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -2
  69. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  70. package/build/components/index.js +4 -6
  71. package/build/components/index.js.map +1 -1
  72. package/build/components/list-view-sidebar/index.js +43 -36
  73. package/build/components/list-view-sidebar/index.js.map +1 -1
  74. package/build/components/local-autosave-monitor/index.js +1 -2
  75. package/build/components/local-autosave-monitor/index.js.map +1 -1
  76. package/build/components/media-categories/index.js +1 -2
  77. package/build/components/media-categories/index.js.map +1 -1
  78. package/build/components/offline-status/index.native.js +1 -2
  79. package/build/components/offline-status/index.native.js.map +1 -1
  80. package/build/components/page-attributes/check.js +1 -2
  81. package/build/components/page-attributes/check.js.map +1 -1
  82. package/build/components/page-attributes/panel.js +1 -2
  83. package/build/components/page-attributes/panel.js.map +1 -1
  84. package/build/components/page-attributes/parent.js +1 -2
  85. package/build/components/page-attributes/parent.js.map +1 -1
  86. package/build/components/post-author/combobox.js +6 -60
  87. package/build/components/post-author/combobox.js.map +1 -1
  88. package/build/components/post-author/constants.js +7 -5
  89. package/build/components/post-author/constants.js.map +1 -1
  90. package/build/components/post-author/hook.js +72 -0
  91. package/build/components/post-author/hook.js.map +1 -0
  92. package/build/components/post-author/index.js +1 -2
  93. package/build/components/post-author/index.js.map +1 -1
  94. package/build/components/post-author/panel.js +1 -2
  95. package/build/components/post-author/panel.js.map +1 -1
  96. package/build/components/post-author/select.js +6 -24
  97. package/build/components/post-author/select.js.map +1 -1
  98. package/build/components/post-comments/index.js +1 -2
  99. package/build/components/post-comments/index.js.map +1 -1
  100. package/build/components/post-discussion/panel.js +1 -2
  101. package/build/components/post-discussion/panel.js.map +1 -1
  102. package/build/components/post-excerpt/check.js +1 -2
  103. package/build/components/post-excerpt/check.js.map +1 -1
  104. package/build/components/post-excerpt/index.js +1 -2
  105. package/build/components/post-excerpt/index.js.map +1 -1
  106. package/build/components/post-excerpt/plugin.js +1 -2
  107. package/build/components/post-excerpt/plugin.js.map +1 -1
  108. package/build/components/post-featured-image/check.js +1 -2
  109. package/build/components/post-featured-image/check.js.map +1 -1
  110. package/build/components/post-featured-image/index.js +1 -2
  111. package/build/components/post-featured-image/index.js.map +1 -1
  112. package/build/components/post-featured-image/panel.js +1 -2
  113. package/build/components/post-featured-image/panel.js.map +1 -1
  114. package/build/components/post-format/check.js +1 -2
  115. package/build/components/post-format/check.js.map +1 -1
  116. package/build/components/post-format/index.js +1 -2
  117. package/build/components/post-format/index.js.map +1 -1
  118. package/build/components/post-last-revision/check.js +1 -2
  119. package/build/components/post-last-revision/check.js.map +1 -1
  120. package/build/components/post-last-revision/index.js +6 -5
  121. package/build/components/post-last-revision/index.js.map +1 -1
  122. package/build/components/post-last-revision/panel.js +1 -2
  123. package/build/components/post-last-revision/panel.js.map +1 -1
  124. package/build/components/post-panel-row/index.js +1 -2
  125. package/build/components/post-panel-row/index.js.map +1 -1
  126. package/build/components/post-pending-status/check.js +1 -2
  127. package/build/components/post-pending-status/check.js.map +1 -1
  128. package/build/components/post-pending-status/index.js +1 -2
  129. package/build/components/post-pending-status/index.js.map +1 -1
  130. package/build/components/post-pingbacks/index.js +1 -2
  131. package/build/components/post-pingbacks/index.js.map +1 -1
  132. package/build/components/post-publish-button/index.js +1 -2
  133. package/build/components/post-publish-button/index.js.map +1 -1
  134. package/build/components/post-publish-button/label.js +1 -2
  135. package/build/components/post-publish-button/label.js.map +1 -1
  136. package/build/components/post-publish-panel/index.js +1 -2
  137. package/build/components/post-publish-panel/index.js.map +1 -1
  138. package/build/components/post-publish-panel/maybe-category-panel.js +1 -2
  139. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  140. package/build/components/post-publish-panel/maybe-tags-panel.js +22 -26
  141. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  142. package/build/components/post-publish-panel/postpublish.js +1 -2
  143. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  144. package/build/components/post-publish-panel/prepublish.js +1 -2
  145. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  146. package/build/components/post-schedule/index.js +0 -1
  147. package/build/components/post-schedule/index.js.map +1 -1
  148. package/build/components/post-schedule/label.js +1 -1
  149. package/build/components/post-schedule/label.js.map +1 -1
  150. package/build/components/post-schedule/panel.js +1 -0
  151. package/build/components/post-schedule/panel.js.map +1 -1
  152. package/build/components/post-slug/index.js +1 -2
  153. package/build/components/post-slug/index.js.map +1 -1
  154. package/build/components/post-switch-to-draft-button/index.js +1 -0
  155. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  156. package/build/components/post-sync-status/index.js +1 -1
  157. package/build/components/post-sync-status/index.js.map +1 -1
  158. package/build/components/post-taxonomies/check.js +8 -15
  159. package/build/components/post-taxonomies/check.js.map +1 -1
  160. package/build/components/post-taxonomies/flat-term-selector.js +1 -2
  161. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  162. package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -2
  163. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  164. package/build/components/post-taxonomies/index.js +14 -15
  165. package/build/components/post-taxonomies/index.js.map +1 -1
  166. package/build/components/post-taxonomies/panel.js +1 -2
  167. package/build/components/post-taxonomies/panel.js.map +1 -1
  168. package/build/components/post-template/block-theme.js +12 -11
  169. package/build/components/post-template/block-theme.js.map +1 -1
  170. package/build/components/post-template/classic-theme.js +10 -11
  171. package/build/components/post-template/classic-theme.js.map +1 -1
  172. package/build/components/post-template/create-new-template-modal.js +4 -5
  173. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  174. package/build/components/post-template/panel.js +5 -1
  175. package/build/components/post-template/panel.js.map +1 -1
  176. package/build/components/post-title/constants.js +2 -4
  177. package/build/components/post-title/constants.js.map +1 -1
  178. package/build/components/post-title/index.js +2 -3
  179. package/build/components/post-title/index.js.map +1 -1
  180. package/build/components/post-title/index.native.js +1 -2
  181. package/build/components/post-title/index.native.js.map +1 -1
  182. package/build/components/post-title/post-title-raw.js +1 -2
  183. package/build/components/post-title/post-title-raw.js.map +1 -1
  184. package/build/components/post-trash/check.js +1 -2
  185. package/build/components/post-trash/check.js.map +1 -1
  186. package/build/components/post-trash/index.js +1 -0
  187. package/build/components/post-trash/index.js.map +1 -1
  188. package/build/components/post-type-support-check/index.js +1 -2
  189. package/build/components/post-type-support-check/index.js.map +1 -1
  190. package/build/components/post-url/panel.js +1 -0
  191. package/build/components/post-url/panel.js.map +1 -1
  192. package/build/components/post-visibility/utils.js +1 -2
  193. package/build/components/post-visibility/utils.js.map +1 -1
  194. package/build/components/preferences-modal/enable-panel.js +1 -2
  195. package/build/components/preferences-modal/enable-panel.js.map +1 -1
  196. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js +1 -2
  197. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -1
  198. package/build/components/preferences-modal/index.js +0 -1
  199. package/build/components/preferences-modal/index.js.map +1 -1
  200. package/build/components/provider/constants.js +1 -2
  201. package/build/components/provider/constants.js.map +1 -1
  202. package/build/components/provider/index.js +12 -6
  203. package/build/components/provider/index.js.map +1 -1
  204. package/build/components/provider/index.native.js +4 -6
  205. package/build/components/provider/index.native.js.map +1 -1
  206. package/build/components/provider/use-block-editor-settings.js +2 -3
  207. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  208. package/build/components/provider/use-block-editor-settings.native.js +1 -2
  209. package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
  210. package/build/components/provider/with-registry-provider.js +1 -2
  211. package/build/components/provider/with-registry-provider.js.map +1 -1
  212. package/build/components/table-of-contents/index.js +1 -2
  213. package/build/components/table-of-contents/index.js.map +1 -1
  214. package/build/components/table-of-contents/panel.js +1 -2
  215. package/build/components/table-of-contents/panel.js.map +1 -1
  216. package/build/components/template-validation-notice/index.js +1 -2
  217. package/build/components/template-validation-notice/index.js.map +1 -1
  218. package/build/components/theme-support-check/index.js +1 -2
  219. package/build/components/theme-support-check/index.js.map +1 -1
  220. package/build/hooks/pattern-partial-syncing.js +9 -2
  221. package/build/hooks/pattern-partial-syncing.js.map +1 -1
  222. package/build/private-apis.js +1 -2
  223. package/build/private-apis.js.map +1 -1
  224. package/build/store/actions.js +31 -62
  225. package/build/store/actions.js.map +1 -1
  226. package/build/store/constants.js +7 -14
  227. package/build/store/constants.js.map +1 -1
  228. package/build/store/defaults.js +1 -2
  229. package/build/store/defaults.js.map +1 -1
  230. package/build/store/index.js +4 -6
  231. package/build/store/index.js.map +1 -1
  232. package/build/store/private-selectors.js +1 -2
  233. package/build/store/private-selectors.js.map +1 -1
  234. package/build/store/reducer.js +1 -2
  235. package/build/store/reducer.js.map +1 -1
  236. package/build/store/reducer.native.js +2 -4
  237. package/build/store/reducer.native.js.map +1 -1
  238. package/build/store/selectors.js +72 -144
  239. package/build/store/selectors.js.map +1 -1
  240. package/build/store/selectors.native.js +1 -2
  241. package/build/store/selectors.native.js.map +1 -1
  242. package/build-module/components/document-bar/index.js +5 -6
  243. package/build-module/components/document-bar/index.js.map +1 -1
  244. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +11 -18
  245. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  246. package/build-module/components/editor-canvas/index.js +13 -8
  247. package/build-module/components/editor-canvas/index.js.map +1 -1
  248. package/build-module/components/editor-snackbars/index.js +4 -1
  249. package/build-module/components/editor-snackbars/index.js.map +1 -1
  250. package/build-module/components/entities-saved-states/entity-record-item.js +1 -1
  251. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  252. package/build-module/components/entities-saved-states/entity-type-list.js +8 -8
  253. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  254. package/build-module/components/entities-saved-states/index.js +6 -3
  255. package/build-module/components/entities-saved-states/index.js.map +1 -1
  256. package/build-module/components/list-view-sidebar/index.js +44 -37
  257. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  258. package/build-module/components/post-author/combobox.js +8 -61
  259. package/build-module/components/post-author/combobox.js.map +1 -1
  260. package/build-module/components/post-author/constants.js +5 -2
  261. package/build-module/components/post-author/constants.js.map +1 -1
  262. package/build-module/components/post-author/hook.js +65 -0
  263. package/build-module/components/post-author/hook.js.map +1 -0
  264. package/build-module/components/post-author/select.js +7 -24
  265. package/build-module/components/post-author/select.js.map +1 -1
  266. package/build-module/components/post-last-revision/index.js +6 -4
  267. package/build-module/components/post-last-revision/index.js.map +1 -1
  268. package/build-module/components/post-publish-panel/maybe-tags-panel.js +24 -27
  269. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  270. package/build-module/components/post-schedule/index.js +0 -1
  271. package/build-module/components/post-schedule/index.js.map +1 -1
  272. package/build-module/components/post-schedule/label.js +1 -1
  273. package/build-module/components/post-schedule/label.js.map +1 -1
  274. package/build-module/components/post-schedule/panel.js +1 -0
  275. package/build-module/components/post-schedule/panel.js.map +1 -1
  276. package/build-module/components/post-switch-to-draft-button/index.js +1 -0
  277. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  278. package/build-module/components/post-sync-status/index.js +1 -1
  279. package/build-module/components/post-sync-status/index.js.map +1 -1
  280. package/build-module/components/post-taxonomies/check.js +9 -14
  281. package/build-module/components/post-taxonomies/check.js.map +1 -1
  282. package/build-module/components/post-taxonomies/index.js +15 -15
  283. package/build-module/components/post-taxonomies/index.js.map +1 -1
  284. package/build-module/components/post-template/block-theme.js +12 -11
  285. package/build-module/components/post-template/block-theme.js.map +1 -1
  286. package/build-module/components/post-template/classic-theme.js +9 -9
  287. package/build-module/components/post-template/classic-theme.js.map +1 -1
  288. package/build-module/components/post-template/create-new-template-modal.js +4 -5
  289. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  290. package/build-module/components/post-template/panel.js +5 -1
  291. package/build-module/components/post-template/panel.js.map +1 -1
  292. package/build-module/components/post-title/index.js +1 -2
  293. package/build-module/components/post-title/index.js.map +1 -1
  294. package/build-module/components/post-trash/index.js +1 -0
  295. package/build-module/components/post-trash/index.js.map +1 -1
  296. package/build-module/components/post-url/panel.js +1 -0
  297. package/build-module/components/post-url/panel.js.map +1 -1
  298. package/build-module/components/preferences-modal/index.js +0 -1
  299. package/build-module/components/preferences-modal/index.js.map +1 -1
  300. package/build-module/components/provider/index.js +10 -2
  301. package/build-module/components/provider/index.js.map +1 -1
  302. package/build-module/components/provider/use-block-editor-settings.js +1 -1
  303. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  304. package/build-module/components/table-of-contents/panel.js +0 -1
  305. package/build-module/components/table-of-contents/panel.js.map +1 -1
  306. package/build-module/hooks/pattern-partial-syncing.js +9 -2
  307. package/build-module/hooks/pattern-partial-syncing.js.map +1 -1
  308. package/build-style/style-rtl.css +28 -22
  309. package/build-style/style.css +28 -22
  310. package/package.json +32 -32
  311. package/src/components/document-bar/index.js +22 -17
  312. package/src/components/editor-canvas/edit-template-blocks-notification.js +31 -30
  313. package/src/components/editor-canvas/index.js +14 -4
  314. package/src/components/editor-snackbars/index.js +6 -3
  315. package/src/components/entities-saved-states/entity-record-item.js +1 -4
  316. package/src/components/entities-saved-states/entity-type-list.js +8 -8
  317. package/src/components/entities-saved-states/index.js +17 -4
  318. package/src/components/entities-saved-states/style.scss +5 -0
  319. package/src/components/list-view-sidebar/index.js +60 -47
  320. package/src/components/list-view-sidebar/style.scss +20 -20
  321. package/src/components/post-author/combobox.js +5 -61
  322. package/src/components/post-author/constants.js +6 -2
  323. package/src/components/post-author/hook.js +63 -0
  324. package/src/components/post-author/select.js +5 -25
  325. package/src/components/post-last-revision/index.js +6 -6
  326. package/src/components/post-last-revision/style.scss +3 -6
  327. package/src/components/post-panel-row/style.scss +3 -3
  328. package/src/components/post-publish-panel/maybe-tags-panel.js +27 -37
  329. package/src/components/post-publish-panel/style.scss +3 -1
  330. package/src/components/post-schedule/label.js +1 -1
  331. package/src/components/post-schedule/panel.js +1 -0
  332. package/src/components/post-schedule/test/label.js +19 -7
  333. package/src/components/post-switch-to-draft-button/index.js +1 -0
  334. package/src/components/post-sync-status/index.js +8 -2
  335. package/src/components/post-taxonomies/check.js +11 -15
  336. package/src/components/post-taxonomies/index.js +15 -22
  337. package/src/components/post-taxonomies/test/index.js +37 -51
  338. package/src/components/post-template/block-theme.js +29 -22
  339. package/src/components/post-template/classic-theme.js +10 -13
  340. package/src/components/post-template/create-new-template-modal.js +7 -9
  341. package/src/components/post-template/panel.js +5 -1
  342. package/src/components/post-trash/index.js +1 -0
  343. package/src/components/post-url/panel.js +1 -0
  344. package/src/components/provider/index.js +22 -2
  345. package/src/components/provider/use-block-editor-settings.js +1 -1
  346. package/src/hooks/pattern-partial-syncing.js +23 -4
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_htmlEntities","_coreData","getExternalLink","url","text","getExternalLinkAttributes","getOpenverseLicense","license","licenseVersion","licenseName","trim","toUpperCase","replace","includes","getOpenverseCaption","item","title","foreign_landing_url","foreignLandingUrl","creator","creator_url","creatorUrl","license_version","license_url","licenseUrl","fullLicense","_creator","decodeEntities","_caption","sprintf","_x","coreMediaFetch","query","mediaItems","resolveSelect","coreStore","getMediaItems","orderBy","search","map","mediaItem","alt","alt_text","source_url","previewUrl","media_details","sizes","medium","caption","raw","inserterMediaCategories","name","labels","__","search_items","mediaType","fetch","media_type","defaultArgs","mature","excluded_source","finalQuery","mapFromInserterMediaRequest","per_page","URL","Object","entries","forEach","key","value","queryKey","searchParams","set","response","window","headers","jsonResponse","json","results","result","toLowerCase","startsWith","slice","sourceId","id","undefined","thumbnail","getReportUrl","isExternalResource","_default","exports","default"],"sources":["@wordpress/editor/src/components/media-categories/index.js"],"sourcesContent":["/**\n * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.\n * See `packages/editor/src/components/media-categories/index.js`.\n *\n * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.\n * The rest of the settings would still need to be in sync though.\n */\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\n\n/** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */\n/** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */\n/** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */\n\nconst getExternalLink = ( url, text ) =>\n\t`<a ${ getExternalLinkAttributes( url ) }>${ text }</a>`;\n\nconst getExternalLinkAttributes = ( url ) =>\n\t`href=\"${ url }\" target=\"_blank\" rel=\"noreferrer noopener\"`;\n\nconst getOpenverseLicense = ( license, licenseVersion ) => {\n\tlet licenseName = license.trim();\n\t// PDM has no abbreviation\n\tif ( license !== 'pdm' ) {\n\t\tlicenseName = license.toUpperCase().replace( 'SAMPLING', 'Sampling' );\n\t}\n\t// If version is known, append version to the name.\n\t// The license has to have a version to be valid. Only\n\t// PDM (public domain mark) doesn't have a version.\n\tif ( licenseVersion ) {\n\t\tlicenseName += ` ${ licenseVersion }`;\n\t}\n\t// For licenses other than public-domain marks, prepend 'CC' to the name.\n\tif ( ! [ 'pdm', 'cc0' ].includes( license ) ) {\n\t\tlicenseName = `CC ${ licenseName }`;\n\t}\n\treturn licenseName;\n};\n\nconst getOpenverseCaption = ( item ) => {\n\tconst {\n\t\ttitle,\n\t\tforeign_landing_url: foreignLandingUrl,\n\t\tcreator,\n\t\tcreator_url: creatorUrl,\n\t\tlicense,\n\t\tlicense_version: licenseVersion,\n\t\tlicense_url: licenseUrl,\n\t} = item;\n\tconst fullLicense = getOpenverseLicense( license, licenseVersion );\n\tconst _creator = decodeEntities( creator );\n\tlet _caption;\n\tif ( _creator ) {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\" by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a> by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t} else {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\"/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a>/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t}\n\treturn _caption.replace( /\\s{2}/g, ' ' );\n};\n\nconst coreMediaFetch = async ( query = {} ) => {\n\tconst mediaItems = await resolveSelect( coreStore ).getMediaItems( {\n\t\t...query,\n\t\torderBy: !! query?.search ? 'relevance' : 'date',\n\t} );\n\treturn mediaItems.map( ( mediaItem ) => ( {\n\t\t...mediaItem,\n\t\talt: mediaItem.alt_text,\n\t\turl: mediaItem.source_url,\n\t\tpreviewUrl: mediaItem.media_details?.sizes?.medium?.source_url,\n\t\tcaption: mediaItem.caption?.raw,\n\t} ) );\n};\n\n/** @type {InserterMediaCategory[]} */\nconst inserterMediaCategories = [\n\t{\n\t\tname: 'images',\n\t\tlabels: {\n\t\t\tname: __( 'Images' ),\n\t\t\tsearch_items: __( 'Search images' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'image' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'videos',\n\t\tlabels: {\n\t\t\tname: __( 'Videos' ),\n\t\t\tsearch_items: __( 'Search videos' ),\n\t\t},\n\t\tmediaType: 'video',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'video' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'audio',\n\t\tlabels: {\n\t\t\tname: __( 'Audio' ),\n\t\t\tsearch_items: __( 'Search audio' ),\n\t\t},\n\t\tmediaType: 'audio',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'audio' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'openverse',\n\t\tlabels: {\n\t\t\tname: __( 'Openverse' ),\n\t\t\tsearch_items: __( 'Search Openverse' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\tconst defaultArgs = {\n\t\t\t\tmature: false,\n\t\t\t\texcluded_source: 'flickr,inaturalist,wikimedia',\n\t\t\t\tlicense: 'pdm,cc0',\n\t\t\t};\n\t\t\tconst finalQuery = { ...query, ...defaultArgs };\n\t\t\tconst mapFromInserterMediaRequest = {\n\t\t\t\tper_page: 'page_size',\n\t\t\t\tsearch: 'q',\n\t\t\t};\n\t\t\tconst url = new URL(\n\t\t\t\t'https://api.openverse.engineering/v1/images/'\n\t\t\t);\n\t\t\tObject.entries( finalQuery ).forEach( ( [ key, value ] ) => {\n\t\t\t\tconst queryKey = mapFromInserterMediaRequest[ key ] || key;\n\t\t\t\turl.searchParams.set( queryKey, value );\n\t\t\t} );\n\t\t\tconst response = await window.fetch( url, {\n\t\t\t\theaders: {\n\t\t\t\t\t'User-Agent': 'WordPress/inserter-media-fetch',\n\t\t\t\t},\n\t\t\t} );\n\t\t\tconst jsonResponse = await response.json();\n\t\t\tconst results = jsonResponse.results;\n\t\t\treturn results.map( ( result ) => ( {\n\t\t\t\t...result,\n\t\t\t\t// This is a temp solution for better titles, until Openverse API\n\t\t\t\t// completes the cleaning up of some titles of their upstream data.\n\t\t\t\ttitle: result.title?.toLowerCase().startsWith( 'file:' )\n\t\t\t\t\t? result.title.slice( 5 )\n\t\t\t\t\t: result.title,\n\t\t\t\tsourceId: result.id,\n\t\t\t\tid: undefined,\n\t\t\t\tcaption: getOpenverseCaption( result ),\n\t\t\t\tpreviewUrl: result.thumbnail,\n\t\t\t} ) );\n\t\t},\n\t\tgetReportUrl: ( { sourceId } ) =>\n\t\t\t`https://wordpress.org/openverse/image/${ sourceId }/report/`,\n\t\tisExternalResource: true,\n\t},\n];\n\nexport default inserterMediaCategories;\n"],"mappings":";;;;;;AAWA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,I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EAAE;MACzCwE,OAAO,EAAE;QACR,YAAY,EAAE;MACf;IACD,CAAE,CAAC;IACH,MAAMC,YAAY,GAAG,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAC;IAC1C,MAAMC,OAAO,GAAGF,YAAY,CAACE,OAAO;IACpC,OAAOA,OAAO,CAACvC,GAAG,CAAIwC,MAAM,KAAQ;MACnC,GAAGA,MAAM;MACT;MACA;MACA/D,KAAK,EAAE+D,MAAM,CAAC/D,KAAK,EAAEgE,WAAW,CAAC,CAAC,CAACC,UAAU,CAAE,OAAQ,CAAC,GACrDF,MAAM,CAAC/D,KAAK,CAACkE,KAAK,CAAE,CAAE,CAAC,GACvBH,MAAM,CAAC/D,KAAK;MACfmE,QAAQ,EAAEJ,MAAM,CAACK,EAAE;MACnBA,EAAE,EAAEC,SAAS;MACbrC,OAAO,EAAElC,mBAAmB,CAAEiE,MAAO,CAAC;MACtCnC,UAAU,EAAEmC,MAAM,CAACO;IACpB,CAAC,CAAG,CAAC;EACN,CAAC;EACDC,YAAY,EAAEA,CAAE;IAAEJ;EAAS,CAAC,KAC1B,yCAAyCA,QAAU,UAAS;EAC9DK,kBAAkB,EAAE;AACrB,CAAC,CACD;AAAC,IAAAC,QAAA,GAEavC,uBAAuB;AAAAwC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_i18n","require","_data","_htmlEntities","_coreData","getExternalLink","url","text","getExternalLinkAttributes","getOpenverseLicense","license","licenseVersion","licenseName","trim","toUpperCase","replace","includes","getOpenverseCaption","item","title","foreign_landing_url","foreignLandingUrl","creator","creator_url","creatorUrl","license_version","license_url","licenseUrl","fullLicense","_creator","decodeEntities","_caption","sprintf","_x","coreMediaFetch","query","mediaItems","resolveSelect","coreStore","getMediaItems","orderBy","search","map","mediaItem","alt","alt_text","source_url","previewUrl","media_details","sizes","medium","caption","raw","inserterMediaCategories","name","labels","__","search_items","mediaType","fetch","media_type","defaultArgs","mature","excluded_source","finalQuery","mapFromInserterMediaRequest","per_page","URL","Object","entries","forEach","key","value","queryKey","searchParams","set","response","window","headers","jsonResponse","json","results","result","toLowerCase","startsWith","slice","sourceId","id","undefined","thumbnail","getReportUrl","isExternalResource","_default","exports","default"],"sources":["@wordpress/editor/src/components/media-categories/index.js"],"sourcesContent":["/**\n * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.\n * See `packages/editor/src/components/media-categories/index.js`.\n *\n * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.\n * The rest of the settings would still need to be in sync though.\n */\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\n\n/** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */\n/** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */\n/** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */\n\nconst getExternalLink = ( url, text ) =>\n\t`<a ${ getExternalLinkAttributes( url ) }>${ text }</a>`;\n\nconst getExternalLinkAttributes = ( url ) =>\n\t`href=\"${ url }\" target=\"_blank\" rel=\"noreferrer noopener\"`;\n\nconst getOpenverseLicense = ( license, licenseVersion ) => {\n\tlet licenseName = license.trim();\n\t// PDM has no abbreviation\n\tif ( license !== 'pdm' ) {\n\t\tlicenseName = license.toUpperCase().replace( 'SAMPLING', 'Sampling' );\n\t}\n\t// If version is known, append version to the name.\n\t// The license has to have a version to be valid. Only\n\t// PDM (public domain mark) doesn't have a version.\n\tif ( licenseVersion ) {\n\t\tlicenseName += ` ${ licenseVersion }`;\n\t}\n\t// For licenses other than public-domain marks, prepend 'CC' to the name.\n\tif ( ! [ 'pdm', 'cc0' ].includes( license ) ) {\n\t\tlicenseName = `CC ${ licenseName }`;\n\t}\n\treturn licenseName;\n};\n\nconst getOpenverseCaption = ( item ) => {\n\tconst {\n\t\ttitle,\n\t\tforeign_landing_url: foreignLandingUrl,\n\t\tcreator,\n\t\tcreator_url: creatorUrl,\n\t\tlicense,\n\t\tlicense_version: licenseVersion,\n\t\tlicense_url: licenseUrl,\n\t} = item;\n\tconst fullLicense = getOpenverseLicense( license, licenseVersion );\n\tconst _creator = decodeEntities( creator );\n\tlet _caption;\n\tif ( _creator ) {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\" by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a> by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t} else {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\"/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a>/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t}\n\treturn _caption.replace( /\\s{2}/g, ' ' );\n};\n\nconst coreMediaFetch = async ( query = {} ) => {\n\tconst mediaItems = await resolveSelect( coreStore ).getMediaItems( {\n\t\t...query,\n\t\torderBy: !! query?.search ? 'relevance' : 'date',\n\t} );\n\treturn mediaItems.map( ( mediaItem ) => ( {\n\t\t...mediaItem,\n\t\talt: mediaItem.alt_text,\n\t\turl: mediaItem.source_url,\n\t\tpreviewUrl: mediaItem.media_details?.sizes?.medium?.source_url,\n\t\tcaption: mediaItem.caption?.raw,\n\t} ) );\n};\n\n/** @type {InserterMediaCategory[]} */\nconst inserterMediaCategories = [\n\t{\n\t\tname: 'images',\n\t\tlabels: {\n\t\t\tname: __( 'Images' ),\n\t\t\tsearch_items: __( 'Search images' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'image' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'videos',\n\t\tlabels: {\n\t\t\tname: __( 'Videos' ),\n\t\t\tsearch_items: __( 'Search videos' ),\n\t\t},\n\t\tmediaType: 'video',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'video' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'audio',\n\t\tlabels: {\n\t\t\tname: __( 'Audio' ),\n\t\t\tsearch_items: __( 'Search audio' ),\n\t\t},\n\t\tmediaType: 'audio',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'audio' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'openverse',\n\t\tlabels: {\n\t\t\tname: __( 'Openverse' ),\n\t\t\tsearch_items: __( 'Search Openverse' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\tconst defaultArgs = {\n\t\t\t\tmature: false,\n\t\t\t\texcluded_source: 'flickr,inaturalist,wikimedia',\n\t\t\t\tlicense: 'pdm,cc0',\n\t\t\t};\n\t\t\tconst finalQuery = { ...query, ...defaultArgs };\n\t\t\tconst mapFromInserterMediaRequest = {\n\t\t\t\tper_page: 'page_size',\n\t\t\t\tsearch: 'q',\n\t\t\t};\n\t\t\tconst url = new URL(\n\t\t\t\t'https://api.openverse.engineering/v1/images/'\n\t\t\t);\n\t\t\tObject.entries( finalQuery ).forEach( ( [ key, value ] ) => {\n\t\t\t\tconst queryKey = mapFromInserterMediaRequest[ key ] || key;\n\t\t\t\turl.searchParams.set( queryKey, value );\n\t\t\t} );\n\t\t\tconst response = await window.fetch( url, {\n\t\t\t\theaders: {\n\t\t\t\t\t'User-Agent': 'WordPress/inserter-media-fetch',\n\t\t\t\t},\n\t\t\t} );\n\t\t\tconst jsonResponse = await response.json();\n\t\t\tconst results = jsonResponse.results;\n\t\t\treturn results.map( ( result ) => ( {\n\t\t\t\t...result,\n\t\t\t\t// This is a temp solution for better titles, until Openverse API\n\t\t\t\t// completes the cleaning up of some titles of their upstream data.\n\t\t\t\ttitle: result.title?.toLowerCase().startsWith( 'file:' )\n\t\t\t\t\t? result.title.slice( 5 )\n\t\t\t\t\t: result.title,\n\t\t\t\tsourceId: result.id,\n\t\t\t\tid: undefined,\n\t\t\t\tcaption: getOpenverseCaption( result ),\n\t\t\t\tpreviewUrl: result.thumbnail,\n\t\t\t} ) );\n\t\t},\n\t\tgetReportUrl: ( { sourceId } ) =>\n\t\t\t`https://wordpress.org/openverse/image/${ sourceId }/report/`,\n\t\tisExternalResource: true,\n\t},\n];\n\nexport default inserterMediaCategories;\n"],"mappings":";;;;;;AAWA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,SAAA,GAAAH,OAAA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,MAAMI,eAAe,GAAGA,CAAEC,GAAG,EAAEC,IAAI,KACjC,MAAMC,yBAAyB,CAAEF,GAAI,CAAG,IAAIC,IAAM,MAAK;AAEzD,MAAMC,yBAAyB,GAAKF,GAAG,IACrC,SAASA,GAAK,6CAA4C;AAE5D,MAAMG,mBAAmB,GAAGA,CAAEC,OAAO,EAAEC,cAAc,KAAM;EAC1D,IAAIC,WAAW,GAAGF,OAAO,CAACG,IAAI,CAAC,CAAC;EAChC;EACA,IAAKH,OAAO,KAAK,KAAK,EAAG;IACxBE,WAAW,GAAGF,OAAO,CAACI,WAAW,CAAC,CAAC,CAACC,OAAO,CAAE,UAAU,EAAE,UAAW,CAAC;EACtE;EACA;EACA;EACA;EACA,IAAKJ,cAAc,EAAG;IACrBC,WAAW,IAAK,IAAID,cAAgB,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IAAEJ;EAAS,CAAC,KAC1B,yCAAyCA,QAAU,UAAS;EAC9DK,kBAAkB,EAAE;AACrB,CAAC,CACD;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEazC,uBAAuB"}
@@ -78,6 +78,5 @@ const OfflineStatus = () => {
78
78
  style: textStyle
79
79
  }, (0, _i18n.__)('Working Offline'), " ")) : null;
80
80
  };
81
- var _default = OfflineStatus;
82
- exports.default = _default;
81
+ var _default = exports.default = OfflineStatus;
83
82
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_compose","_components","_icons","_i18n","_element","_styleNative","_interopRequireDefault","useAccessibilityLiveRegion","message","isActive","inactiveMessage","announceForAccessibility","AccessibilityInfo","prevIsActive","usePrevious","useEffect","unconditionalMessage","initialRender","OfflineStatus","isConnected","useNetworkConnectivity","__","containerStyle","usePreferredColorSchemeStyle","styles","offline","offline__dark","textStyle","iconStyle","_react","createElement","View","accessible","accessibilityRole","accessibilityLabel","style","Icon","fill","icon","offlineIcon","Text","_default","exports","default"],"sources":["@wordpress/editor/src/components/offline-status/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo, Text, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tusePreferredColorSchemeStyle,\n\tuseNetworkConnectivity,\n\tusePrevious,\n} from '@wordpress/compose';\nimport { Icon } from '@wordpress/components';\nimport { offline as offlineIcon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.native.scss';\n\n/**\n * Conditionally announces messages for screen reader users. This Hook provides\n * two benefits over React Native's `accessibilityLiveRegion`:\n *\n * 1. It works on both iOS and Android.\n * 2. It allows announcing a secondary message when the component is inactive.\n *\n * @param {string} message The message to announce.\n * @param {Object} options Options for the Hook.\n * @param {boolean} [options.isActive] Whether the message should be announced.\n * @param {string} [options.inactiveMessage] The message to announce when inactive.\n */\nfunction useAccessibilityLiveRegion( message, { isActive, inactiveMessage } ) {\n\tconst { announceForAccessibility } = AccessibilityInfo;\n\tconst prevIsActive = usePrevious( isActive );\n\n\tuseEffect( () => {\n\t\tconst unconditionalMessage = typeof isActive === 'undefined';\n\t\tconst initialRender = typeof prevIsActive === 'undefined';\n\n\t\tif (\n\t\t\tunconditionalMessage ||\n\t\t\t( isActive && ! prevIsActive && ! initialRender )\n\t\t) {\n\t\t\tannounceForAccessibility( message );\n\t\t} else if ( ! isActive && prevIsActive && inactiveMessage ) {\n\t\t\tannounceForAccessibility( inactiveMessage );\n\t\t}\n\t}, [\n\t\tmessage,\n\t\tisActive,\n\t\tprevIsActive,\n\t\tinactiveMessage,\n\t\tannounceForAccessibility,\n\t] );\n}\n\nconst OfflineStatus = () => {\n\tconst { isConnected } = useNetworkConnectivity();\n\n\tuseAccessibilityLiveRegion( __( 'Network connection re-established' ), {\n\t\tisActive: isConnected,\n\t\tinactiveMessage: __( 'Network connection lost, working offline' ),\n\t} );\n\n\tconst containerStyle = usePreferredColorSchemeStyle(\n\t\tstyles.offline,\n\t\tstyles.offline__dark\n\t);\n\n\tconst textStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'offline--text' ],\n\t\tstyles[ 'offline--text__dark' ]\n\t);\n\n\tconst iconStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'offline--icon' ],\n\t\tstyles[ 'offline--icon__dark' ]\n\t);\n\n\treturn ! isConnected ? (\n\t\t<View\n\t\t\taccessible\n\t\t\taccessibilityRole=\"alert\"\n\t\t\taccessibilityLabel={ __(\n\t\t\t\t'Network connection lost, working offline'\n\t\t\t) }\n\t\t\tstyle={ containerStyle }\n\t\t>\n\t\t\t<Icon fill={ iconStyle.fill } icon={ offlineIcon } />\n\t\t\t<Text style={ textStyle }>{ __( 'Working Offline' ) } </Text>\n\t\t</View>\n\t) : null;\n};\n\nexport default OfflineStatus;\n"],"mappings":";;;;;;;;AAGA,IA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E,0CAA2C;EACjE,CAAE,CAAC;EAEH,MAAMC,cAAc,GAAG,IAAAC,qCAA4B,EAClDC,oBAAM,CAACC,OAAO,EACdD,oBAAM,CAACE,aACR,CAAC;EAED,MAAMC,SAAS,GAAG,IAAAJ,qCAA4B,EAC7CC,oBAAM,CAAE,eAAe,CAAE,EACzBA,oBAAM,CAAE,qBAAqB,CAC9B,CAAC;EAED,MAAMI,SAAS,GAAG,IAAAL,qCAA4B,EAC7CC,oBAAM,CAAE,eAAe,CAAE,EACzBA,oBAAM,CAAE,qBAAqB,CAC9B,CAAC;EAED,OAAO,CAAEL,WAAW,GACnB,IAAAU,MAAA,CAAAC,aAAA,EAAChC,YAAA,CAAAiC,IAAI;IACJC,UAAU;IACVC,iBAAiB,EAAC,OAAO;IACzBC,kBAAkB,EAAG,IAAAb,QAAE,EACtB,0CACD,CAAG;IACHc,KAAK,EAAGb;EAAgB,GAExB,IAAAO,MAAA,CAAAC,aAAA,EAAC7B,WAAA,CAAAmC,IAAI;IAACC,IAAI,EAAGT,SAAS,CAACS,IAAM;IAACC,IAAI,EAAGC;EAAa,CAAE,CAAC,EACrD,IAAAV,MAAA,CAAAC,aAAA,EAAChC,YAAA,CAAA0C,IAAI;IAACL,KAAK,EAAGR;EAAW,GAAG,IAAAN,QAAE,EAAE,iBAAkB,CAAC,EAAE,GAAO,CACvD,CAAC,GACJ,IAAI;AACT,CAAC;AAAC,IAAAoB,QAAA,GAEavB,aAAa;AAAAwB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_compose","_components","_icons","_i18n","_element","_styleNative","_interopRequireDefault","useAccessibilityLiveRegion","message","isActive","inactiveMessage","announceForAccessibility","AccessibilityInfo","prevIsActive","usePrevious","useEffect","unconditionalMessage","initialRender","OfflineStatus","isConnected","useNetworkConnectivity","__","containerStyle","usePreferredColorSchemeStyle","styles","offline","offline__dark","textStyle","iconStyle","_react","createElement","View","accessible","accessibilityRole","accessibilityLabel","style","Icon","fill","icon","offlineIcon","Text","_default","exports","default"],"sources":["@wordpress/editor/src/components/offline-status/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo, Text, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tusePreferredColorSchemeStyle,\n\tuseNetworkConnectivity,\n\tusePrevious,\n} from '@wordpress/compose';\nimport { Icon } from '@wordpress/components';\nimport { offline as offlineIcon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.native.scss';\n\n/**\n * Conditionally announces messages for screen reader users. This Hook provides\n * two benefits over React Native's `accessibilityLiveRegion`:\n *\n * 1. It works on both iOS and Android.\n * 2. It allows announcing a secondary message when the component is inactive.\n *\n * @param {string} message The message to announce.\n * @param {Object} options Options for the Hook.\n * @param {boolean} [options.isActive] Whether the message should be announced.\n * @param {string} [options.inactiveMessage] The message to announce when inactive.\n */\nfunction useAccessibilityLiveRegion( message, { isActive, inactiveMessage } ) {\n\tconst { announceForAccessibility } = AccessibilityInfo;\n\tconst prevIsActive = usePrevious( isActive );\n\n\tuseEffect( () => {\n\t\tconst unconditionalMessage = typeof isActive === 'undefined';\n\t\tconst initialRender = typeof prevIsActive === 'undefined';\n\n\t\tif (\n\t\t\tunconditionalMessage ||\n\t\t\t( isActive && ! prevIsActive && ! initialRender )\n\t\t) {\n\t\t\tannounceForAccessibility( message );\n\t\t} else if ( ! isActive && prevIsActive && inactiveMessage ) {\n\t\t\tannounceForAccessibility( inactiveMessage );\n\t\t}\n\t}, [\n\t\tmessage,\n\t\tisActive,\n\t\tprevIsActive,\n\t\tinactiveMessage,\n\t\tannounceForAccessibility,\n\t] );\n}\n\nconst OfflineStatus = () => {\n\tconst { isConnected } = useNetworkConnectivity();\n\n\tuseAccessibilityLiveRegion( __( 'Network connection re-established' ), {\n\t\tisActive: isConnected,\n\t\tinactiveMessage: __( 'Network connection lost, working offline' ),\n\t} );\n\n\tconst containerStyle = usePreferredColorSchemeStyle(\n\t\tstyles.offline,\n\t\tstyles.offline__dark\n\t);\n\n\tconst textStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'offline--text' ],\n\t\tstyles[ 'offline--text__dark' ]\n\t);\n\n\tconst iconStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'offline--icon' ],\n\t\tstyles[ 'offline--icon__dark' ]\n\t);\n\n\treturn ! isConnected ? (\n\t\t<View\n\t\t\taccessible\n\t\t\taccessibilityRole=\"alert\"\n\t\t\taccessibilityLabel={ __(\n\t\t\t\t'Network connection lost, working offline'\n\t\t\t) }\n\t\t\tstyle={ containerStyle }\n\t\t>\n\t\t\t<Icon fill={ iconStyle.fill } icon={ offlineIcon } />\n\t\t\t<Text style={ textStyle }>{ __( 'Working Offline' ) } </Text>\n\t\t</View>\n\t) : null;\n};\n\nexport default OfflineStatus;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,YAAA,GAAAC,sBAAA,CAAAP,OAAA;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,0BAA0BA,CAAEC,OAAO,EAAE;EAAEC,QAAQ;EAAEC;AAAgB,CAAC,EAAG;EAC7E,MAAM;IAAEC;EAAyB,CAAC,GAAGC,8BAAiB;EACtD,MAAMC,YAAY,GAAG,IAAAC,oBAAW,EAAEL,QAAS,CAAC;EAE5C,IAAAM,kBAAS,EAAE,MAAM;IAChB,MAAMC,oBAAoB,GAAG,OAAOP,QAAQ,KAAK,WAAW;IAC5D,MAAMQ,aAAa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T,SAAS,CAACS,IAAM;IAACC,IAAI,EAAGC;EAAa,CAAE,CAAC,EACrD,IAAAV,MAAA,CAAAC,aAAA,EAAChC,YAAA,CAAA0C,IAAI;IAACL,KAAK,EAAGR;EAAW,GAAG,IAAAN,QAAE,EAAE,iBAAkB,CAAC,EAAE,GAAO,CACvD,CAAC,GACJ,IAAI;AACT,CAAC;AAAC,IAAAoB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEazB,aAAa"}
@@ -36,6 +36,5 @@ function PageAttributesCheck({
36
36
  }
37
37
  return children;
38
38
  }
39
- var _default = PageAttributesCheck;
40
- exports.default = _default;
39
+ var _default = exports.default = PageAttributesCheck;
41
40
  //# sourceMappingURL=check.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_coreData","_store","PageAttributesCheck","children","supportsPageAttributes","useSelect","select","getEditedPostAttribute","editorStore","getPostType","coreStore","postType","supports","_default","exports","default"],"sources":["@wordpress/editor/src/components/page-attributes/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PageAttributesCheck( { children } ) {\n\tconst supportsPageAttributes = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn !! postType?.supports?.[ 'page-attributes' ];\n\t}, [] );\n\n\t// Only render fields if post type supports page attributes or available templates exist.\n\tif ( ! supportsPageAttributes ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default PageAttributesCheck;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGO,SAASG,mBAAmBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACnD,MAAMC,sBAAsB,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACvD,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEE,YAAY,CAAC;IACxD,MAAM;MAAEC;IAAY,CAAC,GAAGH,MAAM,CAAEI,eAAU,CAAC;IAC3C,MAAMC,QAAQ,GAAGF,WAAW,CAAEF,sBAAsB,CAAE,MAAO,CAAE,CAAC;IAEhE,OAAO,CAAC,CAAEI,QAAQ,EAAEC,QAAQ,GAAI,iBAAiB,CAAE;EACpD,CAAC,EAAE,EAAG,CAAC;;EAEP;EACA,IAAK,CAAER,sBAAsB,EAAG;IAC/B,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB;AAAC,IAAAU,QAAA,GAEcX,mBAAmB;AAAAY,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_data","require","_coreData","_store","PageAttributesCheck","children","supportsPageAttributes","useSelect","select","getEditedPostAttribute","editorStore","getPostType","coreStore","postType","supports","_default","exports","default"],"sources":["@wordpress/editor/src/components/page-attributes/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PageAttributesCheck( { children } ) {\n\tconst supportsPageAttributes = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn !! postType?.supports?.[ 'page-attributes' ];\n\t}, [] );\n\n\t// Only render fields if post type supports page attributes or available templates exist.\n\tif ( ! supportsPageAttributes ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default PageAttributesCheck;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGO,SAASG,mBAAmBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACnD,MAAMC,sBAAsB,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACvD,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEE,YAAY,CAAC;IACxD,MAAM;MAAEC;IAAY,CAAC,GAAGH,MAAM,CAAEI,eAAU,CAAC;IAC3C,MAAMC,QAAQ,GAAGF,WAAW,CAAEF,sBAAsB,CAAE,MAAO,CAAE,CAAC;IAEhE,OAAO,CAAC,CAAEI,QAAQ,EAAEC,QAAQ,GAAI,iBAAiB,CAAE;EACpD,CAAC,EAAE,EAAG,CAAC;;EAEP;EACA,IAAK,CAAER,sBAAsB,EAAG;IAC/B,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcb,mBAAmB"}
@@ -58,6 +58,5 @@ function PageAttributesPanel() {
58
58
  onToggle: onTogglePanel
59
59
  }, (0, _react.createElement)(_parent.default, null), (0, _react.createElement)(_components.PanelRow, null, (0, _react.createElement)(_order.default, null))));
60
60
  }
61
- var _default = PageAttributesPanel;
62
- exports.default = _default;
61
+ var _default = exports.default = PageAttributesPanel;
63
62
  //# sourceMappingURL=panel.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_components","_data","_coreData","_store","_check","_interopRequireDefault","_order","_parent","PANEL_NAME","PageAttributesPanel","_postType$labels$attr","isEnabled","isOpened","postType","useSelect","select","getEditedPostAttribute","isEditorPanelEnabled","isEditorPanelOpened","editorStore","getPostType","coreStore","toggleEditorPanelOpened","useDispatch","onTogglePanel","args","_react","createElement","default","PanelBody","title","labels","attributes","__","opened","onToggle","PanelRow","_default","exports"],"sources":["@wordpress/editor/src/components/page-attributes/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, PanelRow } from '@wordpress/components';\n\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PageAttributesCheck from './check';\nimport PageAttributesOrder from './order';\nimport PageAttributesParent from './parent';\n\nconst PANEL_NAME = 'page-attributes';\n\nexport function PageAttributesPanel() {\n\tconst { isEnabled, isOpened, postType } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostAttribute,\n\t\t\tisEditorPanelEnabled,\n\t\t\tisEditorPanelOpened,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( ! isEnabled || ! postType ) {\n\t\treturn null;\n\t}\n\n\tconst onTogglePanel = ( ...args ) =>\n\t\ttoggleEditorPanelOpened( PANEL_NAME, ...args );\n\n\treturn (\n\t\t<PageAttributesCheck>\n\t\t\t<PanelBody\n\t\t\t\ttitle={\n\t\t\t\t\tpostType?.labels?.attributes ?? __( 'Page attributes' )\n\t\t\t\t}\n\t\t\t\topened={ isOpened }\n\t\t\t\tonToggle={ onTogglePanel }\n\t\t\t>\n\t\t\t\t<PageAttributesParent />\n\t\t\t\t<PanelRow>\n\t\t\t\t\t<PageAttributesOrder />\n\t\t\t\t</PanelRow>\n\t\t\t</PanelBody>\n\t\t</PageAttributesCheck>\n\t);\n}\n\nexport default PageAttributesPanel;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAA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AAEC,UAAU,cAAAtB,qBAAA,cAAAA,qBAAA,GAAI,IAAAuB,QAAE,EAAE,iBAAkB,CACtD;IACDC,MAAM,EAAGtB,QAAU;IACnBuB,QAAQ,EAAGX;EAAe,GAE1B,IAAAE,MAAA,CAAAC,aAAA,EAACpB,OAAA,CAAAqB,OAAoB,MAAE,CAAC,EACxB,IAAAF,MAAA,CAAAC,aAAA,EAAC3B,WAAA,CAAAoC,QAAQ,QACR,IAAAV,MAAA,CAAAC,aAAA,EAACrB,MAAA,CAAAsB,OAAmB,MAAE,CACb,CACA,CACS,CAAC;AAExB;AAAC,IAAAS,QAAA,GAEc5B,mBAAmB;AAAA6B,OAAA,CAAAV,OAAA,GAAAS,QAAA"}
1
+ {"version":3,"names":["_i18n","require","_components","_data","_coreData","_store","_check","_interopRequireDefault","_order","_parent","PANEL_NAME","PageAttributesPanel","_postType$labels$attr","isEnabled","isOpened","postType","useSelect","select","getEditedPostAttribute","isEditorPanelEnabled","isEditorPanelOpened","editorStore","getPostType","coreStore","toggleEditorPanelOpened","useDispatch","onTogglePanel","args","_react","createElement","default","PanelBody","title","labels","attributes","__","opened","onToggle","PanelRow","_default","exports"],"sources":["@wordpress/editor/src/components/page-attributes/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, PanelRow } from '@wordpress/components';\n\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PageAttributesCheck from './check';\nimport PageAttributesOrder from './order';\nimport PageAttributesParent from './parent';\n\nconst PANEL_NAME = 'page-attributes';\n\nexport function PageAttributesPanel() {\n\tconst { isEnabled, isOpened, postType } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostAttribute,\n\t\t\tisEditorPanelEnabled,\n\t\t\tisEditorPanelOpened,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( ! isEnabled || ! postType ) {\n\t\treturn null;\n\t}\n\n\tconst onTogglePanel = ( ...args ) =>\n\t\ttoggleEditorPanelOpened( PANEL_NAME, ...args );\n\n\treturn (\n\t\t<PageAttributesCheck>\n\t\t\t<PanelBody\n\t\t\t\ttitle={\n\t\t\t\t\tpostType?.labels?.attributes ?? __( 'Page attributes' )\n\t\t\t\t}\n\t\t\t\topened={ isOpened }\n\t\t\t\tonToggle={ onTogglePanel }\n\t\t\t>\n\t\t\t\t<PageAttributesParent />\n\t\t\t\t<PanelRow>\n\t\t\t\t\t<PageAttributesOrder />\n\t\t\t\t</PanelRow>\n\t\t\t</PanelBody>\n\t\t</PageAttributesCheck>\n\t);\n}\n\nexport default PageAttributesPanel;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,OAAA,GAAAF,sBAAA,CAAAN,OAAA;AAfA;AACA;AACA;;AAOA;AACA;AACA;;AAMA,MAAMS,UAAU,GAAG,iBAAiB;AAE7B,SAASC,mBAAmBA,CAAA,EAAG;EAAA,IAAAC,qBAAA;EACrC,MAAM;IAAEC,SAAS;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAClE,MAAM;MACLC,sBAAsB;MAC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ageAttributesParent() {
163
163
  onChange: handleChange
164
164
  });
165
165
  }
166
- var _default = PageAttributesParent;
167
- exports.default = _default;
166
+ var _default = exports.default = PageAttributesParent;
168
167
  //# sourceMappingURL=parent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_removeAccents","_interopRequireDefault","require","_i18n","_components","_compose","_element","_data","_htmlEntities","_coreData","_terms","_store","getTitle","post","title","rendered","decodeEntities","id","__","getItemPriority","name","searchValue","normalizedName","removeAccents","toLowerCase","normalizedSearch","startsWith","length","Infinity","exports","PageAttributesParent","editPost","useDispatch","editorStore","fieldValue","setFieldValue","useState","isHierarchical","parentPostId","parentPostTitle","pageItems","useSelect","select","_pType$hierarchical","getPostType","getEntityRecords","getEntityRecord","coreStore","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","postIsHierarchical","hierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPost","parentOptions","useMemo","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","buildTermsTree","opts","optsHasParent","find","unshift","handleKeydown","inputValue","handleChange","selectedPostId","_react","createElement","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","className","options","onFilterValueChange","debounce","onChange","_default","default"],"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { isHierarchical, parentPostId, parentPostTitle, pageItems } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\t\tselect( coreStore );\n\t\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\t\tselect( editorStore );\n\t\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\t\tconst query = {\n\t\t\t\t\tper_page: 100,\n\t\t\t\t\texclude: postId,\n\t\t\t\t\tparent_exclude: postId,\n\t\t\t\t\torderby: 'menu_order',\n\t\t\t\t\torder: 'asc',\n\t\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t};\n\n\t\t\t\t// Perform a search when the field is changed.\n\t\t\t\tif ( !! fieldValue ) {\n\t\t\t\t\tquery.search = fieldValue;\n\t\t\t\t}\n\n\t\t\t\tconst parentPost = pageId\n\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t: null;\n\n\t\t\t\treturn {\n\t\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\t\tparentPostId: pageId,\n\t\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ fieldValue ]\n\t\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t/>\n\t);\n}\n\nexport default PageAttributesParent;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;;AAIA,SAASU,QAAQA,CAAEC,IAAI,EAAG;EACzB,OAAOA,IAAI,EAAEC,KAAK,EAAEC,QAAQ,GACzB,IAAAC,4BAAc,EAAEH,IAAI,CAACC,KAAK,CAACC,QAAS,CAAC,GACpC,IAAIF,IAAI,CAACI,EAAI,KAAK,IAAAC,QAAE,EAAE,UAAW,CAAG,GAAE;AAC3C;AAEO,MAA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,IAAI;EACZ;EACA;AACD;AACA;AACA;AACA;EACC,MAAMuD,aAAa,GAAKC,UAAU,IAAM;IACvC1D,aAAa,CAAE0D,UAAW,CAAC;EAC5B,CAAC;;EAED;AACD;AACA;AACA;AACA;EACC,MAAMC,YAAY,GAAKC,cAAc,IAAM;IAC1ChE,QAAQ,CAAE;MAAEuD,MAAM,EAAES;IAAe,CAAE,CAAC;EACvC,CAAC;EAED,OACC,IAAAC,MAAA,CAAAC,aAAA,EAAC7F,WAAA,CAAA8F,eAAe;IACfC,uBAAuB;IACvBC,qBAAqB;IACrBC,SAAS,EAAC,gCAAgC;IAC1C3B,KAAK,EAAG,IAAAxD,QAAE,EAAE,QAAS,CAAG;IACxBuD,KAAK,EAAGnC,YAAc;IACtBgE,OAAO,EAAGrC,aAAe;IACzBsC,mBAAmB,EAAG,IAAAC,iBAAQ,EAAEZ,aAAa,EAAE,GAAI,CAAG;IACtDa,QAAQ,EAAGX;EAAc,CACzB,CAAC;AAEJ;AAAC,IAAAY,QAAA,GAEc5E,oBAAoB;AAAAD,OAAA,CAAA8E,OAAA,GAAAD,QAAA"}
1
+ {"version":3,"names":["_removeAccents","_interopRequireDefault","require","_i18n","_components","_compose","_element","_data","_htmlEntities","_coreData","_terms","_store","getTitle","post","title","rendered","decodeEntities","id","__","getItemPriority","name","searchValue","normalizedName","removeAccents","toLowerCase","normalizedSearch","startsWith","length","Infinity","exports","PageAttributesParent","editPost","useDispatch","editorStore","fieldValue","setFieldValue","useState","isHierarchical","parentPostId","parentPostTitle","pageItems","useSelect","select","_pType$hierarchical","getPostType","getEntityRecords","getEntityRecord","coreStore","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","postIsHierarchical","hierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPost","parentOptions","useMemo","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","buildTermsTree","opts","optsHasParent","find","unshift","handleKeydown","inputValue","handleChange","selectedPostId","_react","createElement","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","className","options","onFilterValueChange","debounce","onChange","_default","default"],"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { isHierarchical, parentPostId, parentPostTitle, pageItems } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\t\tselect( coreStore );\n\t\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\t\tselect( editorStore );\n\t\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\t\tconst query = {\n\t\t\t\t\tper_page: 100,\n\t\t\t\t\texclude: postId,\n\t\t\t\t\tparent_exclude: postId,\n\t\t\t\t\torderby: 'menu_order',\n\t\t\t\t\torder: 'asc',\n\t\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t};\n\n\t\t\t\t// Perform a search when the field is changed.\n\t\t\t\tif ( !! fieldValue ) {\n\t\t\t\t\tquery.search = fieldValue;\n\t\t\t\t}\n\n\t\t\t\tconst parentPost = pageId\n\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t: null;\n\n\t\t\t\treturn {\n\t\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\t\tparentPostId: pageId,\n\t\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ fieldValue ]\n\t\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t/>\n\t);\n}\n\nexport default PageAttributesParent;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;A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+3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = PostAuthorCombobox;
7
7
  var _react = require("react");
8
8
  var _compose = require("@wordpress/compose");
9
9
  var _element = require("@wordpress/element");
10
10
  var _data = require("@wordpress/data");
11
11
  var _i18n = require("@wordpress/i18n");
12
12
  var _components = require("@wordpress/components");
13
- var _htmlEntities = require("@wordpress/html-entities");
14
- var _coreData = require("@wordpress/core-data");
15
13
  var _store = require("../../store");
16
- var _constants = require("./constants");
14
+ var _hook = require("./hook");
17
15
  /**
18
16
  * WordPress dependencies
19
17
  */
@@ -24,59 +22,13 @@ var _constants = require("./constants");
24
22
 
25
23
  function PostAuthorCombobox() {
26
24
  const [fieldValue, setFieldValue] = (0, _element.useState)();
27
- const {
28
- authorId,
29
- isLoading,
30
- authors,
31
- postAuthor
32
- } = (0, _data.useSelect)(select => {
33
- const {
34
- getUser,
35
- getUsers,
36
- isResolving
37
- } = select(_coreData.store);
38
- const {
39
- getEditedPostAttribute
40
- } = select(_store.store);
41
- const author = getUser(getEditedPostAttribute('author'), {
42
- context: 'view'
43
- });
44
- const query = {
45
- ..._constants.AUTHORS_QUERY
46
- };
47
- if (fieldValue) {
48
- query.search = fieldValue;
49
- }
50
- return {
51
- authorId: getEditedPostAttribute('author'),
52
- postAuthor: author,
53
- authors: getUsers(query),
54
- isLoading: isResolving('core', 'getUsers', [query])
55
- };
56
- }, [fieldValue]);
57
25
  const {
58
26
  editPost
59
27
  } = (0, _data.useDispatch)(_store.store);
60
- const authorOptions = (0, _element.useMemo)(() => {
61
- const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
62
- return {
63
- value: author.id,
64
- label: (0, _htmlEntities.decodeEntities)(author.name)
65
- };
66
- });
67
-
68
- // Ensure the current author is included in the dropdown list.
69
- const foundAuthor = fetchedAuthors.findIndex(({
70
- value
71
- }) => postAuthor?.id === value);
72
- if (foundAuthor < 0 && postAuthor) {
73
- return [{
74
- value: postAuthor.id,
75
- label: (0, _htmlEntities.decodeEntities)(postAuthor.name)
76
- }, ...fetchedAuthors];
77
- }
78
- return fetchedAuthors;
79
- }, [authors, postAuthor]);
28
+ const {
29
+ authorId,
30
+ authorOptions
31
+ } = (0, _hook.useAuthorsQuery)(fieldValue);
80
32
 
81
33
  /**
82
34
  * Handle author selection.
@@ -100,9 +52,6 @@ function PostAuthorCombobox() {
100
52
  const handleKeydown = inputValue => {
101
53
  setFieldValue(inputValue);
102
54
  };
103
- if (!postAuthor) {
104
- return null;
105
- }
106
55
  return (0, _react.createElement)(_components.ComboboxControl, {
107
56
  __nextHasNoMarginBottom: true,
108
57
  __next40pxDefaultSize: true,
@@ -111,10 +60,7 @@ function PostAuthorCombobox() {
111
60
  value: authorId,
112
61
  onFilterValueChange: (0, _compose.debounce)(handleKeydown, 300),
113
62
  onChange: handleSelect,
114
- isLoading: isLoading,
115
63
  allowReset: false
116
64
  });
117
65
  }
118
- var _default = PostAuthorCombobox;
119
- exports.default = _default;
120
66
  //# sourceMappingURL=combobox.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_compose","require","_element","_data","_i18n","_components","_htmlEntities","_coreData","_store","_constants","PostAuthorCombobox","fieldValue","setFieldValue","useState","authorId","isLoading","authors","postAuthor","useSelect","select","getUser","getUsers","isResolving","coreStore","getEditedPostAttribute","editorStore","author","context","query","AUTHORS_QUERY","search","editPost","useDispatch","authorOptions","useMemo","fetchedAuthors","map","value","id","label","decodeEntities","name","foundAuthor","findIndex","handleSelect","postAuthorId","handleKeydown","inputValue","_react","createElement","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","__","options","onFilterValueChange","debounce","onChange","allowReset","_default","exports","default"],"sources":["@wordpress/editor/src/components/post-author/combobox.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\nfunction PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { authorId, isLoading, authors, postAuthor } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser, getUsers, isResolving } = select( coreStore );\n\t\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\t\tconst author = getUser( getEditedPostAttribute( 'author' ), {\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst query = { ...AUTHORS_QUERY };\n\n\t\t\tif ( fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tauthorId: getEditedPostAttribute( 'author' ),\n\t\t\t\tpostAuthor: author,\n\t\t\t\tauthors: getUsers( query ),\n\t\t\t\tisLoading: isResolving( 'core', 'getUsers', [ query ] ),\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst authorOptions = useMemo( () => {\n\t\tconst fetchedAuthors = ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\n\t\t// Ensure the current author is included in the dropdown list.\n\t\tconst foundAuthor = fetchedAuthors.findIndex(\n\t\t\t( { value } ) => postAuthor?.id === value\n\t\t);\n\n\t\tif ( foundAuthor < 0 && postAuthor ) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tvalue: postAuthor.id,\n\t\t\t\t\tlabel: decodeEntities( postAuthor.name ),\n\t\t\t\t},\n\t\t\t\t...fetchedAuthors,\n\t\t\t];\n\t\t}\n\n\t\treturn fetchedAuthors;\n\t}, [ authors, postAuthor ] );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\tif ( ! postAuthor ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tisLoading={ isLoading }\n\t\t\tallowReset={ false }\n\t\t/>\n\t);\n}\n\nexport default PostAuthorCombobox;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAfA;AACA;AACA;;AASA;AACA;AACA;;AAIA,SAASS,kBAAkBA,CAAA,EAAG;EAC7B,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE,GAAG,IAAAC,iBAAQ,EAAC,CAAC;EAEhD,MAAM;IAAEC,QAAQ;IAAEC,SAAS;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAG,IAAAC,eAAS,EAC3DC,MAAM,IAAM;IACb,MAAM;MAAEC,OAAO;MAAEC,QAAQ;MAAEC;IA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K,EAAE,IAAAC,4BAAc,EAAEvB,UAAU,CAACwB,IAAK;MACxC,CAAC,EACD,GAAGN,cAAc,CACjB;IACF;IAEA,OAAOA,cAAc;EACtB,CAAC,EAAE,CAAEnB,OAAO,EAAEC,UAAU,CAAG,CAAC;;EAE5B;AACD;AACA;AACA;AACA;EACC,MAAM2B,YAAY,GAAKC,YAAY,IAAM;IACxC,IAAK,CAAEA,YAAY,EAAG;MACrB;IACD;IACAd,QAAQ,CAAE;MAAEL,MAAM,EAAEmB;IAAa,CAAE,CAAC;EACrC,CAAC;;EAED;AACD;AACA;AACA;AACA;EACC,MAAMC,aAAa,GAAKC,UAAU,IAAM;IACvCnC,aAAa,CAAEmC,UAAW,CAAC;EAC5B,CAAC;EAED,IAAK,CAAE9B,UAAU,EAAG;IACnB,OAAO,IAAI;EACZ;EAEA,OACC,IAAA+B,MAAA,CAAAC,aAAA,EAAC5C,WAAA,CAAA6C,eAAe;IACfC,uBAAuB;IACvBC,qBAAqB;IACrBb,KAAK,EAAG,IAAAc,QAAE,EAAE,QAAS,CAAG;IACxBC,OAAO,EAAGrB,aAAe;IACzBI,KAAK,EAAGvB,QAAU;IAClByC,mBAAmB,EAAG,IAAAC,iBAAQ,EAAEV,aAAa,EAAE,GAAI,CAAG;IACtDW,QAAQ,EAAGb,YAAc;IACzB7B,SAAS,EAAGA,SAAW;IACvB2C,UAAU,EAAG;EAAO,CACpB,CAAC;AAEJ;AAAC,IAAAC,QAAA,GAEcjD,kBAAkB;AAAAkD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_compose","require","_element","_data","_i18n","_components","_store","_hook","PostAuthorCombobox","fieldValue","setFieldValue","useState","editPost","useDispatch","editorStore","authorId","authorOptions","useAuthorsQuery","handleSelect","postAuthorId","author","handleKeydown","inputValue","_react","createElement","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","label","__","options","value","onFilterValueChange","debounce","onChange","allowReset"],"sources":["@wordpress/editor/src/components/post-author/combobox.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions } = useAuthorsQuery( fieldValue );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tallowReset={ false }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIe,SAASO,kBAAkBA,CAAA,EAAG;EAC5C,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE,GAAG,IAAAC,iBAAQ,EAAC,CAAC;EAEhD,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAY,CAAC;EAC/C,MAAM;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAG,IAAAC,qBAAe,EAAER,UAAW,CAAC;;EAEjE;AACD;AACA;AACA;AACA;EACC,MAAMS,YAAY,GAAKC,YAAY,IAAM;IACxC,IAAK,CAAEA,YAAY,EAAG;MACrB;IACD;IACAP,QAAQ,CAAE;MAAEQ,MAAM,EAAED;IAAa,CAAE,CAAC;EACrC,CAAC;;EAED;AACD;AACA;AACA;AACA;EACC,MAAME,aAAa,GAAKC,UAAU,IAAM;IACvCZ,aAAa,CAAEY,UAAW,CAAC;EAC5B,CAAC;EAED,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACnB,WAAA,CAAAoB,eAAe;IACfC,uBAAuB;IACvBC,qBAAqB;IACrBC,KAAK,EAAG,IAAAC,QAAE,EAAE,QAAS,CAAG;IACxBC,OAAO,EAAGd,aAAe;IACzBe,KAAK,EAAGhB,QAAU;IAClBiB,mBAAmB,EAAG,IAAAC,iBAAQ,EAAEZ,aAAa,EAAE,GAAI,CAAG;IACtDa,QAAQ,EAAGhB,YAAc;IACzBiB,UAAU,EAAG;EAAO,CACpB,CAAC;AAEJ"}
@@ -3,12 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.AUTHORS_QUERY = void 0;
7
- const AUTHORS_QUERY = {
8
- who: 'authors',
9
- per_page: 50,
6
+ exports.BASE_QUERY = exports.AUTHORS_QUERY = void 0;
7
+ const BASE_QUERY = exports.BASE_QUERY = {
10
8
  _fields: 'id,name',
11
9
  context: 'view' // Allows non-admins to perform requests.
12
10
  };
13
- exports.AUTHORS_QUERY = AUTHORS_QUERY;
11
+ const AUTHORS_QUERY = exports.AUTHORS_QUERY = {
12
+ who: 'authors',
13
+ per_page: 50,
14
+ ...BASE_QUERY
15
+ };
14
16
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AUTHORS_QUERY","who","per_page","_fields","context","exports"],"sources":["@wordpress/editor/src/components/post-author/constants.js"],"sourcesContent":["export const AUTHORS_QUERY = {\n\twho: 'authors',\n\tper_page: 50,\n\t_fields: 'id,name',\n\tcontext: 'view', // Allows non-admins to perform requests.\n};\n"],"mappings":";;;;;;AAAO,MAAMA,aAAa,GAAG;EAC5BC,GAAG,EAAE,SAAS;EACdC,QAAQ,EAAE,EAAE;EACZC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,MAAM,CAAE;AAClB,CAAC;AAACC,OAAA,CAAAL,aAAA,GAAAA,aAAA"}
1
+ {"version":3,"names":["BASE_QUERY","exports","_fields","context","AUTHORS_QUERY","who","per_page"],"sources":["@wordpress/editor/src/components/post-author/constants.js"],"sourcesContent":["export const BASE_QUERY = {\n\t_fields: 'id,name',\n\tcontext: 'view', // Allows non-admins to perform requests.\n};\n\nexport const AUTHORS_QUERY = {\n\twho: 'authors',\n\tper_page: 50,\n\t...BASE_QUERY,\n};\n"],"mappings":";;;;;;AAAO,MAAMA,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG;EACzBE,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,MAAM,CAAE;AAClB,CAAC;AAEM,MAAMC,aAAa,GAAAH,OAAA,CAAAG,aAAA,GAAG;EAC5BC,GAAG,EAAE,SAAS;EACdC,QAAQ,EAAE,EAAE;EACZ,GAAGN;AACJ,CAAC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAuthorsQuery = useAuthorsQuery;
7
+ var _element = require("@wordpress/element");
8
+ var _data = require("@wordpress/data");
9
+ var _htmlEntities = require("@wordpress/html-entities");
10
+ var _coreData = require("@wordpress/core-data");
11
+ var _store = require("../../store");
12
+ var _constants = require("./constants");
13
+ /**
14
+ * WordPress dependencies
15
+ */
16
+
17
+ /**
18
+ * Internal dependencies
19
+ */
20
+
21
+ function useAuthorsQuery(search) {
22
+ const {
23
+ authorId,
24
+ authors,
25
+ postAuthor
26
+ } = (0, _data.useSelect)(select => {
27
+ const {
28
+ getUser,
29
+ getUsers
30
+ } = select(_coreData.store);
31
+ const {
32
+ getEditedPostAttribute
33
+ } = select(_store.store);
34
+ const _authorId = getEditedPostAttribute('author');
35
+ const query = {
36
+ ..._constants.AUTHORS_QUERY
37
+ };
38
+ if (search) {
39
+ query.search = search;
40
+ }
41
+ return {
42
+ authorId: _authorId,
43
+ authors: getUsers(query),
44
+ postAuthor: getUser(_authorId, _constants.BASE_QUERY)
45
+ };
46
+ }, [search]);
47
+ const authorOptions = (0, _element.useMemo)(() => {
48
+ const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
49
+ return {
50
+ value: author.id,
51
+ label: (0, _htmlEntities.decodeEntities)(author.name)
52
+ };
53
+ });
54
+
55
+ // Ensure the current author is included in the dropdown list.
56
+ const foundAuthor = fetchedAuthors.findIndex(({
57
+ value
58
+ }) => postAuthor?.id === value);
59
+ if (foundAuthor < 0 && postAuthor) {
60
+ return [{
61
+ value: postAuthor.id,
62
+ label: (0, _htmlEntities.decodeEntities)(postAuthor.name)
63
+ }, ...fetchedAuthors];
64
+ }
65
+ return fetchedAuthors;
66
+ }, [authors, postAuthor]);
67
+ return {
68
+ authorId,
69
+ authorOptions
70
+ };
71
+ }
72
+ //# sourceMappingURL=hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_element","require","_data","_htmlEntities","_coreData","_store","_constants","useAuthorsQuery","search","authorId","authors","postAuthor","useSelect","select","getUser","getUsers","coreStore","getEditedPostAttribute","editorStore","_authorId","query","AUTHORS_QUERY","BASE_QUERY","authorOptions","useMemo","fetchedAuthors","map","author","value","id","label","decodeEntities","name","foundAuthor","findIndex"],"sources":["@wordpress/editor/src/components/post-author/hook.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY, BASE_QUERY } from './constants';\n\nexport function useAuthorsQuery( search ) {\n\tconst { authorId, authors, postAuthor } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser, getUsers } = select( coreStore );\n\t\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\t\tconst _authorId = getEditedPostAttribute( 'author' );\n\t\t\tconst query = { ...AUTHORS_QUERY };\n\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tauthorId: _authorId,\n\t\t\t\tauthors: getUsers( query ),\n\t\t\t\tpostAuthor: getUser( _authorId, BASE_QUERY ),\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\tconst authorOptions = useMemo( () => {\n\t\tconst fetchedAuthors = ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\n\t\t// Ensure the current author is included in the dropdown list.\n\t\tconst foundAuthor = fetchedAuthors.findIndex(\n\t\t\t( { value } ) => postAuthor?.id === value\n\t\t);\n\n\t\tif ( foundAuthor < 0 && postAuthor ) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tvalue: postAuthor.id,\n\t\t\t\t\tlabel: decodeEntities( postAuthor.name ),\n\t\t\t\t},\n\t\t\t\t...fetchedAuthors,\n\t\t\t];\n\t\t}\n\n\t\treturn fetchedAuthors;\n\t}, [ authors, postAuthor ] );\n\n\treturn { authorId, authorOptions };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IA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ED,IAAKK,WAAW,GAAG,CAAC,IAAItB,UAAU,EAAG;MACpC,OAAO,CACN;QACCiB,KAAK,EAAEjB,UAAU,CAACkB,EAAE;QACpBC,KAAK,EAAE,IAAAC,4BAAc,EAAEpB,UAAU,CAACqB,IAAK;MACxC,CAAC,EACD,GAAGP,cAAc,CACjB;IACF;IAEA,OAAOA,cAAc;EACtB,CAAC,EAAE,CAAEf,OAAO,EAAEC,UAAU,CAAG,CAAC;EAE5B,OAAO;IAAEF,QAAQ;IAAEc;EAAc,CAAC;AACnC"}
@@ -30,6 +30,5 @@ function PostAuthor() {
30
30
  }
31
31
  return (0, _react.createElement)(_select.default, null);
32
32
  }
33
- var _default = PostAuthor;
34
- exports.default = _default;
33
+ var _default = exports.default = PostAuthor;
35
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_coreData","_combobox","_interopRequireDefault","_select","_constants","minimumUsersForCombobox","PostAuthor","showCombobox","useSelect","select","authors","coreStore","getUsers","AUTHORS_QUERY","length","_react","createElement","default","_default","exports"],"sources":["@wordpress/editor/src/components/post-author/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCombobox from './combobox';\nimport PostAuthorSelect from './select';\nimport { AUTHORS_QUERY } from './constants';\n\nconst minimumUsersForCombobox = 25;\n\nfunction PostAuthor() {\n\tconst showCombobox = useSelect( ( select ) => {\n\t\tconst authors = select( coreStore ).getUsers( AUTHORS_QUERY );\n\n\t\treturn authors?.length >= minimumUsersForCombobox;\n\t}, [] );\n\n\tif ( showCombobox ) {\n\t\treturn <PostAuthorCombobox />;\n\t}\n\treturn <PostAuthorSelect />;\n}\n\nexport default PostAuthor;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMM,uBAAuB,GAAG,EAAE;AAElC,SAASC,UAAUA,CAAA,EAAG;EACrB,MAAMC,YAAY,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC7C,MAAMC,OAAO,GAAGD,MAAM,CAAEE,eAAU,CAAC,CAACC,QAAQ,CAAEC,wBAAc,CAAC;IAE7D,OAAOH,OAAO,EAAEI,MAAM,IAAIT,uBAAuB;EAClD,CAAC,EAAE,EAAG,CAAC;EAEP,IAAKE,YAAY,EAAG;IACnB,OAAO,IAAAQ,MAAA,CAAAC,aAAA,EAACf,SAAA,CAAAgB,OAAkB,MAAE,CAAC;EAC9B;EACA,OAAO,IAAAF,MAAA,CAAAC,aAAA,EAACb,OAAA,CAAAc,OAAgB,MAAE,CAAC;AAC5B;AAAC,IAAAC,QAAA,GAEcZ,UAAU;AAAAa,OAAA,CAAAF,OAAA,GAAAC,QAAA"}
1
+ {"version":3,"names":["_data","require","_coreData","_combobox","_interopRequireDefault","_select","_constants","minimumUsersForCombobox","PostAuthor","showCombobox","useSelect","select","authors","coreStore","getUsers","AUTHORS_QUERY","length","_react","createElement","default","_default","exports"],"sources":["@wordpress/editor/src/components/post-author/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCombobox from './combobox';\nimport PostAuthorSelect from './select';\nimport { AUTHORS_QUERY } from './constants';\n\nconst minimumUsersForCombobox = 25;\n\nfunction PostAuthor() {\n\tconst showCombobox = useSelect( ( select ) => {\n\t\tconst authors = select( coreStore ).getUsers( AUTHORS_QUERY );\n\n\t\treturn authors?.length >= minimumUsersForCombobox;\n\t}, [] );\n\n\tif ( showCombobox ) {\n\t\treturn <PostAuthorCombobox />;\n\t}\n\treturn <PostAuthorSelect />;\n}\n\nexport default PostAuthor;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMM,uBAAuB,GAAG,EAAE;AAElC,SAASC,UAAUA,CAAA,EAAG;EACrB,MAAMC,YAAY,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC7C,MAAMC,OAAO,GAAGD,MAAM,CAAEE,eAAU,CAAC,CAACC,QAAQ,CAAEC,wBAAc,CAAC;IAE7D,OAAOH,OAAO,EAAEI,MAAM,IAAIT,uBAAuB;EAClD,CAAC,EAAE,EAAG,CAAC;EAEP,IAAKE,YAAY,EAAG;IACnB,OAAO,IAAAQ,MAAA,CAAAC,aAAA,EAACf,SAAA,CAAAgB,OAAkB,MAAE,CAAC;EAC9B;EACA,OAAO,IAAAF,MAAA,CAAAC,aAAA,EAACb,OAAA,CAAAc,OAAgB,MAAE,CAAC;AAC5B;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEcX,UAAU"}
@@ -19,6 +19,5 @@ function PostAuthor() {
19
19
  className: "editor-post-author__panel"
20
20
  }, (0, _react.createElement)(_index.default, null)));
21
21
  }
22
- var _default = PostAuthor;
23
- exports.default = _default;
22
+ var _default = exports.default = PostAuthor;
24
23
  //# sourceMappingURL=panel.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_check","_interopRequireDefault","require","_index","_postPanelRow","PostAuthor","_react","createElement","default","className","_default","exports"],"sources":["@wordpress/editor/src/components/post-author/panel.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport PostAuthorCheck from './check';\nimport PostAuthorForm from './index';\nimport PostPanelRow from '../post-panel-row';\n\nexport function PostAuthor() {\n\treturn (\n\t\t<PostAuthorCheck>\n\t\t\t<PostPanelRow className=\"editor-post-author__panel\">\n\t\t\t\t<PostAuthorForm />\n\t\t\t</PostPanelRow>\n\t\t</PostAuthorCheck>\n\t);\n}\n\nexport default PostAuthor;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AALA;AACA;AACA;;AAKO,SAASG,UAAUA,CAAA,EAAG;EAC5B,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACP,MAAA,CAAAQ,OAAe,QACf,IAAAF,MAAA,CAAAC,aAAA,EAACH,aAAA,CAAAI,OAAY;IAACC,SAAS,EAAC;EAA2B,GAClD,IAAAH,MAAA,CAAAC,aAAA,EAACJ,MAAA,CAAAK,OAAc,MAAE,CACJ,CACE,CAAC;AAEpB;AAAC,IAAAE,QAAA,GAEcL,UAAU;AAAAM,OAAA,CAAAH,OAAA,GAAAE,QAAA"}
1
+ {"version":3,"names":["_check","_interopRequireDefault","require","_index","_postPanelRow","PostAuthor","_react","createElement","default","className","_default","exports"],"sources":["@wordpress/editor/src/components/post-author/panel.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport PostAuthorCheck from './check';\nimport PostAuthorForm from './index';\nimport PostPanelRow from '../post-panel-row';\n\nexport function PostAuthor() {\n\treturn (\n\t\t<PostAuthorCheck>\n\t\t\t<PostPanelRow className=\"editor-post-author__panel\">\n\t\t\t\t<PostAuthorForm />\n\t\t\t</PostPanelRow>\n\t\t</PostAuthorCheck>\n\t);\n}\n\nexport default PostAuthor;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AALA;AACA;AACA;;AAKO,SAASG,UAAUA,CAAA,EAAG;EAC5B,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACP,MAAA,CAAAQ,OAAe,QACf,IAAAF,MAAA,CAAAC,aAAA,EAACH,aAAA,CAAAI,OAAY;IAACC,SAAS,EAAC;EAA2B,GAClD,IAAAH,MAAA,CAAAC,aAAA,EAACJ,MAAA,CAAAK,OAAc,MAAE,CACJ,CACE,CAAC;AAEpB;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAEcH,UAAU"}
@@ -3,16 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = PostAuthorSelect;
7
7
  var _react = require("react");
8
8
  var _i18n = require("@wordpress/i18n");
9
- var _element = require("@wordpress/element");
10
9
  var _data = require("@wordpress/data");
11
- var _htmlEntities = require("@wordpress/html-entities");
12
10
  var _components = require("@wordpress/components");
13
- var _coreData = require("@wordpress/core-data");
14
11
  var _store = require("../../store");
15
- var _constants = require("./constants");
12
+ var _hook = require("./hook");
16
13
  /**
17
14
  * WordPress dependencies
18
15
  */
@@ -26,22 +23,9 @@ function PostAuthorSelect() {
26
23
  editPost
27
24
  } = (0, _data.useDispatch)(_store.store);
28
25
  const {
29
- postAuthor,
30
- authors
31
- } = (0, _data.useSelect)(select => {
32
- return {
33
- postAuthor: select(_store.store).getEditedPostAttribute('author'),
34
- authors: select(_coreData.store).getUsers(_constants.AUTHORS_QUERY)
35
- };
36
- }, []);
37
- const authorOptions = (0, _element.useMemo)(() => {
38
- return (authors !== null && authors !== void 0 ? authors : []).map(author => {
39
- return {
40
- value: author.id,
41
- label: (0, _htmlEntities.decodeEntities)(author.name)
42
- };
43
- });
44
- }, [authors]);
26
+ authorId,
27
+ authorOptions
28
+ } = (0, _hook.useAuthorsQuery)();
45
29
  const setAuthorId = value => {
46
30
  const author = Number(value);
47
31
  editPost({
@@ -55,9 +39,7 @@ function PostAuthorSelect() {
55
39
  label: (0, _i18n.__)('Author'),
56
40
  options: authorOptions,
57
41
  onChange: setAuthorId,
58
- value: postAuthor
42
+ value: authorId
59
43
  });
60
44
  }
61
- var _default = PostAuthorSelect;
62
- exports.default = _default;
63
45
  //# sourceMappingURL=select.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_element","_data","_htmlEntities","_components","_coreData","_store","_constants","PostAuthorSelect","editPost","useDispatch","editorStore","postAuthor","authors","useSelect","select","getEditedPostAttribute","coreStore","getUsers","AUTHORS_QUERY","authorOptions","useMemo","map","author","value","id","label","decodeEntities","name","setAuthorId","Number","_react","createElement","SelectControl","__next40pxDefaultSize","__nextHasNoMarginBottom","className","__","options","onChange","_default","exports","default"],"sources":["@wordpress/editor/src/components/post-author/select.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { SelectControl } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\nfunction PostAuthorSelect() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { postAuthor, authors } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostAuthor:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'author' ),\n\t\t\tauthors: select( coreStore ).getUsers( AUTHORS_QUERY ),\n\t\t};\n\t}, [] );\n\n\tconst authorOptions = useMemo( () => {\n\t\treturn ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\t}, [ authors ] );\n\n\tconst setAuthorId = ( value ) => {\n\t\tconst author = Number( value );\n\t\teditPost( { author } );\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"post-author-selector\"\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tonChange={ setAuthorId }\n\t\t\tvalue={ postAuthor }\n\t\t/>\n\t);\n}\n\nexport default PostAuthorSelect;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAdA;AACA;AACA;;AAQA;AACA;AACA;;AAIA,SAASQ,gBAAgBA,CAAA,EAAG;EAC3B,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAY,CAAC;EAC/C,MAAM;IAAEC,UAAU;IAAEC;EAAQ,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACxD,OAAO;MACNH,UAAU,EACTG,MAAM,CAAEJ,YAAY,CAAC,CAACK,sBAAsB,CAAE,QAAS,CAAC;MACzDH,OAAO,EAAEE,MAAM,CAAEE,eAAU,CAAC,CAACC,QAAQ,CAAEC,wBAAc;IACtD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMC,aAAa,GAAG,IAAAC,gBAAO,EAAE,MAAM;IACpC,OAAO,CAAER,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE,EAAGS,GAAG,CAAIC,MAAM,IAAM;MAC3C,OAAO;QACNC,KAAK,EAAED,MAAM,CAACE,EAAE;QAChBC,KAAK,EAAE,IAAAC,4BAAc,EAAEJ,MAAM,CAACK,IAAK;MACpC,CAAC;IACF,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEf,OAAO,CAAG,CAAC;EAEhB,MAAMgB,WAAW,GAAKL,KAAK,IAAM;IAChC,MAAMD,MAAM,GAAGO,MAAM,CAAEN,KAAM,CAAC;IAC9Bf,QAAQ,CAAE;MAAEc;IAAO,CAAE,CAAC;EACvB,CAAC;EAED,OACC,IAAAQ,MAAA,CAAAC,aAAA,EAAC5B,WAAA,CAAA6B,aAAa;IACbC,qBAAqB;IACrBC,uBAAuB;IACvBC,SAAS,EAAC,sBAAsB;IAChCV,KAAK,EAAG,IAAAW,QAAE,EAAE,QAAS,CAAG;IACxBC,OAAO,EAAGlB,aAAe;IACzBmB,QAAQ,EAAGV,WAAa;IACxBL,KAAK,EAAGZ;EAAY,CACpB,CAAC;AAEJ;AAAC,IAAA4B,QAAA,GAEchC,gBAAgB;AAAAiC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_i18n","require","_data","_components","_store","_hook","PostAuthorSelect","editPost","useDispatch","editorStore","authorId","authorOptions","useAuthorsQuery","setAuthorId","value","author","Number","_react","createElement","SelectControl","__next40pxDefaultSize","__nextHasNoMarginBottom","className","label","__","options","onChange"],"sources":["@wordpress/editor/src/components/post-author/select.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { SelectControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorSelect() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions } = useAuthorsQuery();\n\n\tconst setAuthorId = ( value ) => {\n\t\tconst author = Number( value );\n\t\teditPost( { author } );\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"post-author-selector\"\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tonChange={ setAuthorId }\n\t\t\tvalue={ authorId }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAKA;AACA;AACA;;AAIe,SAASK,gBAAgBA,CAAA,EAAG;EAC1C,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAY,CAAC;EAC/C,MAAM;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAG,IAAAC,qBAAe,EAAC,CAAC;EAErD,MAAMC,WAAW,GAAKC,KAAK,IAAM;IAChC,MAAMC,MAAM,GAAGC,MAAM,CAAEF,KAAM,CAAC;IAC9BP,QAAQ,CAAE;MAAEQ;IAAO,CAAE,CAAC;EACvB,CAAC;EAED,OACC,IAAAE,MAAA,CAAAC,aAAA,EAACf,WAAA,CAAAgB,aAAa;IACbC,qBAAqB;IACrBC,uBAAuB;IACvBC,SAAS,EAAC,sBAAsB;IAChCC,KAAK,EAAG,IAAAC,QAAE,EAAE,QAAS,CAAG;IACxBC,OAAO,EAAGd,aAAe;IACzBe,QAAQ,EAAGb,WAAa;IACxBC,KAAK,EAAGJ;EAAU,CAClB,CAAC;AAEJ"}
@@ -35,6 +35,5 @@ function PostComments() {
35
35
  onChange: onToggleComments
36
36
  });
37
37
  }
38
- var _default = PostComments;
39
- exports.default = _default;
38
+ var _default = exports.default = PostComments;
40
39
  //# sourceMappingURL=index.js.map