@wordpress/edit-site 5.5.0 → 5.7.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 (310) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/new-template-part.js +3 -11
  3. package/build/components/add-new-template/new-template-part.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +23 -17
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +1 -1
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/app/index.js +4 -2
  9. package/build/components/app/index.js.map +1 -1
  10. package/build/components/block-editor/editor-canvas.js +7 -9
  11. package/build/components/block-editor/editor-canvas.js.map +1 -1
  12. package/build/components/editor/index.js +2 -4
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/global-styles/border-panel.js +20 -159
  15. package/build/components/global-styles/border-panel.js.map +1 -1
  16. package/build/components/global-styles/context-menu.js +4 -6
  17. package/build/components/global-styles/context-menu.js.map +1 -1
  18. package/build/components/global-styles/hooks.js +0 -72
  19. package/build/components/global-styles/hooks.js.map +1 -1
  20. package/build/components/global-styles/preview.js +3 -4
  21. package/build/components/global-styles/preview.js.map +1 -1
  22. package/build/components/global-styles/screen-block-list.js +5 -7
  23. package/build/components/global-styles/screen-block-list.js.map +1 -1
  24. package/build/components/global-styles/screen-border.js +13 -5
  25. package/build/components/global-styles/screen-border.js.map +1 -1
  26. package/build/components/global-styles/screen-colors.js +22 -211
  27. package/build/components/global-styles/screen-colors.js.map +1 -1
  28. package/build/components/global-styles/screen-root.js +2 -1
  29. package/build/components/global-styles/screen-root.js.map +1 -1
  30. package/build/components/global-styles/screen-style-variations.js +2 -1
  31. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  32. package/build/components/global-styles/screen-typography-element.js +4 -0
  33. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  34. package/build/components/global-styles/screen-typography.js +5 -0
  35. package/build/components/global-styles/screen-typography.js.map +1 -1
  36. package/build/components/global-styles/ui.js +5 -35
  37. package/build/components/global-styles/ui.js.map +1 -1
  38. package/build/components/global-styles-renderer/index.js +1 -2
  39. package/build/components/global-styles-renderer/index.js.map +1 -1
  40. package/build/components/layout/index.js +7 -0
  41. package/build/components/layout/index.js.map +1 -1
  42. package/build/components/list/added-by.js +128 -136
  43. package/build/components/list/added-by.js.map +1 -1
  44. package/build/components/list/index.js +2 -1
  45. package/build/components/list/index.js.map +1 -1
  46. package/build/components/list/table.js +6 -5
  47. package/build/components/list/table.js.map +1 -1
  48. package/build/components/routes/link.js +4 -1
  49. package/build/components/routes/link.js.map +1 -1
  50. package/build/components/save-button/index.js +2 -5
  51. package/build/components/save-button/index.js.map +1 -1
  52. package/build/components/save-hub/index.js +82 -0
  53. package/build/components/save-hub/index.js.map +1 -0
  54. package/build/components/secondary-sidebar/list-view-sidebar.js +6 -1
  55. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  56. package/build/components/sidebar/index.js +2 -4
  57. package/build/components/sidebar/index.js.map +1 -1
  58. package/build/components/sidebar-navigation-screen/index.js +5 -2
  59. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  60. package/build/components/sidebar-navigation-screen-main/index.js +13 -13
  61. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  62. package/build/components/sidebar-navigation-screen-navigation-item/index.js +9 -14
  63. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  64. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +87 -10
  65. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  66. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  67. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  68. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  69. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  70. package/build/components/sidebar-navigation-screen-template/index.js +59 -10
  71. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  72. package/build/components/sidebar-navigation-screen-templates/index.js +5 -2
  73. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  74. package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  75. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  76. package/build/components/site-hub/index.js +3 -1
  77. package/build/components/site-hub/index.js.map +1 -1
  78. package/build/components/start-template-options/index.js +44 -9
  79. package/build/components/start-template-options/index.js.map +1 -1
  80. package/build/components/style-book/index.js +133 -19
  81. package/build/components/style-book/index.js.map +1 -1
  82. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  83. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  84. package/build/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  85. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  86. package/build/components/template-details/index.js +0 -3
  87. package/build/components/template-details/index.js.map +1 -1
  88. package/build/components/template-part-converter/convert-to-regular.js +8 -12
  89. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  90. package/build/components/template-part-converter/convert-to-template-part.js +2 -2
  91. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  92. package/build/components/template-part-converter/index.js +19 -14
  93. package/build/components/template-part-converter/index.js.map +1 -1
  94. package/build/components/use-edited-entity-record/index.js +6 -6
  95. package/build/components/use-edited-entity-record/index.js.map +1 -1
  96. package/build/hooks/push-changes-to-global-styles/index.js +1 -0
  97. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  98. package/build/index.js +3 -0
  99. package/build/index.js.map +1 -1
  100. package/build/utils/history.js +8 -2
  101. package/build/utils/history.js.map +1 -1
  102. package/build-module/components/add-new-template/new-template-part.js +3 -9
  103. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  104. package/build-module/components/add-new-template/new-template.js +25 -18
  105. package/build-module/components/add-new-template/new-template.js.map +1 -1
  106. package/build-module/components/add-new-template/utils.js +1 -1
  107. package/build-module/components/add-new-template/utils.js.map +1 -1
  108. package/build-module/components/app/index.js +3 -2
  109. package/build-module/components/app/index.js.map +1 -1
  110. package/build-module/components/block-editor/editor-canvas.js +8 -10
  111. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  112. package/build-module/components/editor/index.js +2 -3
  113. package/build-module/components/editor/index.js.map +1 -1
  114. package/build-module/components/global-styles/border-panel.js +21 -157
  115. package/build-module/components/global-styles/border-panel.js.map +1 -1
  116. package/build-module/components/global-styles/context-menu.js +4 -4
  117. package/build-module/components/global-styles/context-menu.js.map +1 -1
  118. package/build-module/components/global-styles/hooks.js +0 -66
  119. package/build-module/components/global-styles/hooks.js.map +1 -1
  120. package/build-module/components/global-styles/preview.js +3 -4
  121. package/build-module/components/global-styles/preview.js.map +1 -1
  122. package/build-module/components/global-styles/screen-block-list.js +5 -5
  123. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  124. package/build-module/components/global-styles/screen-border.js +11 -2
  125. package/build-module/components/global-styles/screen-border.js.map +1 -1
  126. package/build-module/components/global-styles/screen-colors.js +23 -208
  127. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  128. package/build-module/components/global-styles/screen-root.js +2 -1
  129. package/build-module/components/global-styles/screen-root.js.map +1 -1
  130. package/build-module/components/global-styles/screen-style-variations.js +2 -1
  131. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  132. package/build-module/components/global-styles/screen-typography-element.js +4 -0
  133. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  134. package/build-module/components/global-styles/screen-typography.js +5 -0
  135. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  136. package/build-module/components/global-styles/ui.js +5 -30
  137. package/build-module/components/global-styles/ui.js.map +1 -1
  138. package/build-module/components/global-styles-renderer/index.js +1 -2
  139. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  140. package/build-module/components/layout/index.js +7 -0
  141. package/build-module/components/layout/index.js.map +1 -1
  142. package/build-module/components/list/added-by.js +126 -137
  143. package/build-module/components/list/added-by.js.map +1 -1
  144. package/build-module/components/list/index.js +2 -1
  145. package/build-module/components/list/index.js.map +1 -1
  146. package/build-module/components/list/table.js +6 -5
  147. package/build-module/components/list/table.js.map +1 -1
  148. package/build-module/components/routes/link.js +5 -2
  149. package/build-module/components/routes/link.js.map +1 -1
  150. package/build-module/components/save-button/index.js +2 -5
  151. package/build-module/components/save-button/index.js.map +1 -1
  152. package/build-module/components/save-hub/index.js +68 -0
  153. package/build-module/components/save-hub/index.js.map +1 -0
  154. package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -2
  155. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  156. package/build-module/components/sidebar/index.js +2 -4
  157. package/build-module/components/sidebar/index.js.map +1 -1
  158. package/build-module/components/sidebar-navigation-screen/index.js +5 -2
  159. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  160. package/build-module/components/sidebar-navigation-screen-main/index.js +13 -13
  161. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  162. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +13 -18
  163. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  164. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +81 -10
  165. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  166. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  167. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  168. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  169. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  170. package/build-module/components/sidebar-navigation-screen-template/index.js +60 -13
  171. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  172. package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -2
  173. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  174. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  175. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  176. package/build-module/components/site-hub/index.js +3 -1
  177. package/build-module/components/site-hub/index.js.map +1 -1
  178. package/build-module/components/start-template-options/index.js +45 -10
  179. package/build-module/components/start-template-options/index.js.map +1 -1
  180. package/build-module/components/style-book/index.js +133 -21
  181. package/build-module/components/style-book/index.js.map +1 -1
  182. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  183. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  184. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  185. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  186. package/build-module/components/template-details/index.js +0 -3
  187. package/build-module/components/template-details/index.js.map +1 -1
  188. package/build-module/components/template-part-converter/convert-to-regular.js +9 -13
  189. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  190. package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
  191. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  192. package/build-module/components/template-part-converter/index.js +20 -15
  193. package/build-module/components/template-part-converter/index.js.map +1 -1
  194. package/build-module/components/use-edited-entity-record/index.js +6 -6
  195. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  196. package/build-module/hooks/push-changes-to-global-styles/index.js +1 -0
  197. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  198. package/build-module/index.js +4 -1
  199. package/build-module/index.js.map +1 -1
  200. package/build-module/utils/history.js +9 -3
  201. package/build-module/utils/history.js.map +1 -1
  202. package/build-style/style-rtl.css +172 -128
  203. package/build-style/style.css +172 -128
  204. package/package.json +31 -31
  205. package/src/components/add-new-template/new-template-part.js +1 -6
  206. package/src/components/add-new-template/new-template.js +60 -38
  207. package/src/components/add-new-template/style.scss +12 -1
  208. package/src/components/add-new-template/utils.js +1 -1
  209. package/src/components/app/index.js +9 -6
  210. package/src/components/block-editor/editor-canvas.js +13 -22
  211. package/src/components/editor/index.js +61 -65
  212. package/src/components/global-styles/border-panel.js +24 -199
  213. package/src/components/global-styles/context-menu.js +4 -4
  214. package/src/components/global-styles/hooks.js +0 -101
  215. package/src/components/global-styles/preview.js +1 -1
  216. package/src/components/global-styles/screen-block-list.js +4 -4
  217. package/src/components/global-styles/screen-border.js +9 -2
  218. package/src/components/global-styles/screen-colors.js +25 -229
  219. package/src/components/global-styles/screen-root.js +1 -1
  220. package/src/components/global-styles/screen-style-variations.js +5 -1
  221. package/src/components/global-styles/screen-typography-element.js +4 -0
  222. package/src/components/global-styles/screen-typography.js +6 -0
  223. package/src/components/global-styles/stories/index.js +425 -0
  224. package/src/components/global-styles/style.scss +14 -18
  225. package/src/components/global-styles/ui.js +6 -31
  226. package/src/components/global-styles-renderer/index.js +1 -2
  227. package/src/components/layout/index.js +15 -0
  228. package/src/components/layout/style.scss +1 -3
  229. package/src/components/list/added-by.js +144 -140
  230. package/src/components/list/index.js +3 -1
  231. package/src/components/list/table.js +7 -4
  232. package/src/components/routes/link.js +9 -2
  233. package/src/components/save-button/index.js +2 -2
  234. package/src/components/save-hub/index.js +78 -0
  235. package/src/components/save-hub/style.scss +15 -0
  236. package/src/components/secondary-sidebar/list-view-sidebar.js +4 -3
  237. package/src/components/sidebar/index.js +2 -3
  238. package/src/components/sidebar/style.scss +4 -3
  239. package/src/components/sidebar-button/style.scss +2 -1
  240. package/src/components/sidebar-navigation-item/style.scss +1 -23
  241. package/src/components/sidebar-navigation-screen/index.js +6 -0
  242. package/src/components/sidebar-navigation-screen/style.scss +15 -0
  243. package/src/components/sidebar-navigation-screen-main/index.js +21 -8
  244. package/src/components/sidebar-navigation-screen-navigation-item/index.js +30 -21
  245. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +92 -9
  246. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  247. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  248. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +108 -1
  249. package/src/components/sidebar-navigation-screen-template/index.js +82 -11
  250. package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
  251. package/src/components/sidebar-navigation-screen-templates/index.js +7 -0
  252. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
  253. package/src/components/site-hub/index.js +5 -1
  254. package/src/components/site-hub/style.scss +5 -1
  255. package/src/components/start-template-options/index.js +40 -8
  256. package/src/components/style-book/index.js +203 -54
  257. package/src/components/style-book/style.scss +2 -46
  258. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  259. package/src/components/sync-state-with-url/use-sync-path-with-url.js +12 -7
  260. package/src/components/template-details/index.js +0 -3
  261. package/src/components/template-part-converter/convert-to-regular.js +10 -17
  262. package/src/components/template-part-converter/convert-to-template-part.js +9 -16
  263. package/src/components/template-part-converter/index.js +28 -12
  264. package/src/components/use-edited-entity-record/index.js +26 -18
  265. package/src/hooks/push-changes-to-global-styles/index.js +1 -0
  266. package/src/index.js +5 -1
  267. package/src/store/test/actions.js +0 -2
  268. package/src/style.scss +2 -1
  269. package/src/utils/history.js +13 -9
  270. package/build/components/global-styles/color-utils.js +0 -17
  271. package/build/components/global-styles/color-utils.js.map +0 -1
  272. package/build/components/global-styles/screen-background-color.js +0 -114
  273. package/build/components/global-styles/screen-background-color.js.map +0 -1
  274. package/build/components/global-styles/screen-button-color.js +0 -88
  275. package/build/components/global-styles/screen-button-color.js.map +0 -1
  276. package/build/components/global-styles/screen-heading-color.js +0 -165
  277. package/build/components/global-styles/screen-heading-color.js.map +0 -1
  278. package/build/components/global-styles/screen-link-color.js +0 -105
  279. package/build/components/global-styles/screen-link-color.js.map +0 -1
  280. package/build/components/global-styles/screen-text-color.js +0 -71
  281. package/build/components/global-styles/screen-text-color.js.map +0 -1
  282. package/build/components/navigation-inspector/index.js +0 -161
  283. package/build/components/navigation-inspector/index.js.map +0 -1
  284. package/build/components/navigation-inspector/navigation-menu.js +0 -79
  285. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  286. package/build-module/components/global-styles/color-utils.js +0 -9
  287. package/build-module/components/global-styles/color-utils.js.map +0 -1
  288. package/build-module/components/global-styles/screen-background-color.js +0 -97
  289. package/build-module/components/global-styles/screen-background-color.js.map +0 -1
  290. package/build-module/components/global-styles/screen-button-color.js +0 -73
  291. package/build-module/components/global-styles/screen-button-color.js.map +0 -1
  292. package/build-module/components/global-styles/screen-heading-color.js +0 -149
  293. package/build-module/components/global-styles/screen-heading-color.js.map +0 -1
  294. package/build-module/components/global-styles/screen-link-color.js +0 -89
  295. package/build-module/components/global-styles/screen-link-color.js.map +0 -1
  296. package/build-module/components/global-styles/screen-text-color.js +0 -56
  297. package/build-module/components/global-styles/screen-text-color.js.map +0 -1
  298. package/build-module/components/navigation-inspector/index.js +0 -146
  299. package/build-module/components/navigation-inspector/index.js.map +0 -1
  300. package/build-module/components/navigation-inspector/navigation-menu.js +0 -69
  301. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  302. package/src/components/global-styles/color-utils.js +0 -14
  303. package/src/components/global-styles/screen-background-color.js +0 -132
  304. package/src/components/global-styles/screen-button-color.js +0 -104
  305. package/src/components/global-styles/screen-heading-color.js +0 -206
  306. package/src/components/global-styles/screen-link-color.js +0 -124
  307. package/src/components/global-styles/screen-text-color.js +0 -62
  308. package/src/components/navigation-inspector/index.js +0 -191
  309. package/src/components/navigation-inspector/navigation-menu.js +0 -84
  310. package/src/components/navigation-inspector/style.scss +0 -46
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = AddedBy;
9
+ exports.useAddedBy = useAddedBy;
9
10
 
10
11
  var _element = require("@wordpress/element");
11
12
 
@@ -21,6 +22,8 @@ var _icons = require("@wordpress/icons");
21
22
 
22
23
  var _i18n = require("@wordpress/i18n");
23
24
 
25
+ // @ts-check
26
+
24
27
  /**
25
28
  * External dependencies
26
29
  */
@@ -28,20 +31,111 @@ var _i18n = require("@wordpress/i18n");
28
31
  /**
29
32
  * WordPress dependencies
30
33
  */
34
+
35
+ /** @typedef {'wp_template'|'wp_template_part'} TemplateType */
36
+
37
+ /** @type {TemplateType} */
31
38
  const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
39
+ /**
40
+ * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType
41
+ *
42
+ * @typedef AddedByData
43
+ * @type {Object}
44
+ * @property {AddedByType} type The type of the data.
45
+ * @property {JSX.Element} icon The icon to display.
46
+ * @property {string} [imageUrl] The optional image URL to display.
47
+ * @property {string} [text] The text to display.
48
+ * @property {boolean} isCustomized Whether the template has been customized.
49
+ *
50
+ * @param {TemplateType} postType The template post type.
51
+ * @param {number} postId The template post id.
52
+ * @return {AddedByData} The added by object or null.
53
+ */
54
+
55
+ function useAddedBy(postType, postId) {
56
+ return (0, _data.useSelect)(select => {
57
+ var _user$avatar_urls;
58
+
59
+ const {
60
+ getTheme,
61
+ getPlugin,
62
+ getEntityRecord,
63
+ getMedia,
64
+ getUser,
65
+ getEditedEntityRecord
66
+ } = select(_coreData.store);
67
+ const template = getEditedEntityRecord('postType', postType, postId);
68
+
69
+ if (TEMPLATE_POST_TYPE_NAMES.includes(template.type)) {
70
+ // Added by theme.
71
+ // Template originally provided by a theme, but customized by a user.
72
+ // Templates originally didn't have the 'origin' field so identify
73
+ // older customized templates by checking for no origin and a 'theme'
74
+ // or 'custom' source.
75
+ if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
76
+ var _getTheme, _getTheme$name;
77
+
78
+ return {
79
+ type: 'theme',
80
+ icon: _icons.layout,
81
+ text: ((_getTheme = getTheme(template.theme)) === null || _getTheme === void 0 ? void 0 : (_getTheme$name = _getTheme.name) === null || _getTheme$name === void 0 ? void 0 : _getTheme$name.rendered) || template.theme,
82
+ isCustomized: template.source === 'custom'
83
+ };
84
+ } // Added by plugin.
85
+
86
+
87
+ if (template.has_theme_file && template.origin === 'plugin') {
88
+ var _getPlugin;
89
+
90
+ return {
91
+ type: 'plugin',
92
+ icon: _icons.plugins,
93
+ text: ((_getPlugin = getPlugin(template.theme)) === null || _getPlugin === void 0 ? void 0 : _getPlugin.name) || template.theme,
94
+ isCustomized: template.source === 'custom'
95
+ };
96
+ } // Added by site.
97
+ // Template was created from scratch, but has no author. Author support
98
+ // was only added to templates in WordPress 5.9. Fallback to showing the
99
+ // site logo and title.
100
+
101
+
102
+ if (!template.has_theme_file && template.source === 'custom' && !template.author) {
103
+ var _getMedia;
104
+
105
+ const siteData = getEntityRecord('root', '__unstableBase');
106
+ return {
107
+ type: 'site',
108
+ icon: _icons.globe,
109
+ imageUrl: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined,
110
+ text: siteData === null || siteData === void 0 ? void 0 : siteData.name,
111
+ isCustomized: false
112
+ };
113
+ }
114
+ } // Added by user.
115
+
116
+
117
+ const user = getUser(template.author);
118
+ return {
119
+ type: 'user',
120
+ icon: _icons.commentAuthorAvatar,
121
+ imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
122
+ text: user === null || user === void 0 ? void 0 : user.nickname,
123
+ isCustomized: false
124
+ };
125
+ }, [postType, postId]);
126
+ }
127
+ /**
128
+ * @param {Object} props
129
+ * @param {string} props.imageUrl
130
+ */
32
131
 
33
- function BaseAddedBy(_ref) {
132
+
133
+ function AvatarImage(_ref) {
34
134
  let {
35
- text,
36
- icon,
37
- imageUrl,
38
- isCustomized,
39
- templateType
135
+ imageUrl
40
136
  } = _ref;
41
137
  const [isImageLoaded, setIsImageLoaded] = (0, _element.useState)(false);
42
- return (0, _element.createElement)(_components.__experimentalHStack, {
43
- alignment: "left"
44
- }, imageUrl ? (0, _element.createElement)("div", {
138
+ return (0, _element.createElement)("div", {
45
139
  className: (0, _classnames.default)('edit-site-list-added-by__avatar', {
46
140
  'is-loaded': isImageLoaded
47
141
  })
@@ -49,138 +143,36 @@ function BaseAddedBy(_ref) {
49
143
  onLoad: () => setIsImageLoaded(true),
50
144
  alt: "",
51
145
  src: imageUrl
52
- })) : (0, _element.createElement)("div", {
53
- className: "edit-site-list-added-by__icon"
54
- }, (0, _element.createElement)(_components.Icon, {
55
- icon: icon
56
- })), (0, _element.createElement)("span", null, text, isCustomized && (0, _element.createElement)("span", {
57
- className: "edit-site-list-added-by__customized-info"
58
- }, templateType === 'wp_template' ? (0, _i18n._x)('Customized', 'template') : (0, _i18n._x)('Customized', 'template part'))));
146
+ }));
59
147
  }
148
+ /**
149
+ * @param {Object} props
150
+ * @param {TemplateType} props.postType The template post type.
151
+ * @param {number} props.postId The template post id.
152
+ */
60
153
 
61
- function AddedByTheme(_ref2) {
62
- var _theme$name;
63
154
 
155
+ function AddedBy(_ref2) {
64
156
  let {
65
- slug,
66
- isCustomized,
67
- templateType
157
+ postType,
158
+ postId
68
159
  } = _ref2;
69
- const theme = (0, _data.useSelect)(select => select(_coreData.store).getTheme(slug), [slug]);
70
- return (0, _element.createElement)(BaseAddedBy, {
71
- icon: _icons.layout,
72
- text: (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug,
73
- isCustomized: isCustomized,
74
- templateType: templateType
75
- });
76
- }
77
-
78
- function AddedByPlugin(_ref3) {
79
- let {
80
- slug,
81
- isCustomized,
82
- templateType
83
- } = _ref3;
84
- const plugin = (0, _data.useSelect)(select => select(_coreData.store).getPlugin(slug), [slug]);
85
- return (0, _element.createElement)(BaseAddedBy, {
86
- icon: _icons.plugins,
87
- text: (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug,
88
- isCustomized: isCustomized,
89
- templateType: templateType
90
- });
91
- }
92
-
93
- function AddedByAuthor(_ref4) {
94
- var _user$avatar_urls;
95
-
96
- let {
97
- id,
98
- templateType
99
- } = _ref4;
100
- const user = (0, _data.useSelect)(select => select(_coreData.store).getUser(id), [id]);
101
- return (0, _element.createElement)(BaseAddedBy, {
102
- icon: _icons.commentAuthorAvatar,
103
- imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
104
- text: user === null || user === void 0 ? void 0 : user.nickname,
105
- templateType: templateType
106
- });
107
- }
108
-
109
- function AddedBySite(_ref5) {
110
- let {
111
- templateType
112
- } = _ref5;
113
160
  const {
114
- name,
115
- logoURL
116
- } = (0, _data.useSelect)(select => {
117
- var _getMedia;
118
-
119
- const {
120
- getEntityRecord,
121
- getMedia
122
- } = select(_coreData.store);
123
- const siteData = getEntityRecord('root', '__unstableBase');
124
- return {
125
- name: siteData === null || siteData === void 0 ? void 0 : siteData.name,
126
- logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
127
- };
128
- }, []);
129
- return (0, _element.createElement)(BaseAddedBy, {
130
- icon: _icons.globe,
131
- imageUrl: logoURL,
132
- text: name,
133
- templateType: templateType
134
- });
135
- }
136
-
137
- function AddedBy(_ref6) {
138
- let {
139
- templateType,
140
- template
141
- } = _ref6;
142
-
143
- if (!template) {
144
- return;
145
- }
146
-
147
- if (TEMPLATE_POST_TYPE_NAMES.includes(templateType)) {
148
- // Template originally provided by a theme, but customized by a user.
149
- // Templates originally didn't have the 'origin' field so identify
150
- // older customized templates by checking for no origin and a 'theme'
151
- // or 'custom' source.
152
- if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
153
- return (0, _element.createElement)(AddedByTheme, {
154
- slug: template.theme,
155
- isCustomized: template.source === 'custom',
156
- templateType: templateType
157
- });
158
- } // Template originally provided by a plugin, but customized by a user.
159
-
160
-
161
- if (template.has_theme_file && template.origin === 'plugin') {
162
- return (0, _element.createElement)(AddedByPlugin, {
163
- slug: template.theme,
164
- isCustomized: template.source === 'custom',
165
- templateType: templateType
166
- });
167
- } // Template was created from scratch, but has no author. Author support
168
- // was only added to templates in WordPress 5.9. Fallback to showing the
169
- // site logo and title.
170
-
171
-
172
- if (!template.has_theme_file && template.source === 'custom' && !template.author) {
173
- return (0, _element.createElement)(AddedBySite, {
174
- templateType: templateType
175
- });
176
- }
177
- } // Simply show the author for templates created from scratch that have an
178
- // author or for any other post type.
179
-
180
-
181
- return (0, _element.createElement)(AddedByAuthor, {
182
- id: template.author,
183
- templateType: templateType
184
- });
161
+ text,
162
+ icon,
163
+ imageUrl,
164
+ isCustomized
165
+ } = useAddedBy(postType, postId);
166
+ return (0, _element.createElement)(_components.__experimentalHStack, {
167
+ alignment: "left"
168
+ }, imageUrl ? (0, _element.createElement)(AvatarImage, {
169
+ imageUrl: imageUrl
170
+ }) : (0, _element.createElement)("div", {
171
+ className: "edit-site-list-added-by__icon"
172
+ }, (0, _element.createElement)(_components.Icon, {
173
+ icon: icon
174
+ })), (0, _element.createElement)("span", null, text, isCustomized && (0, _element.createElement)("span", {
175
+ className: "edit-site-list-added-by__customized-info"
176
+ }, postType === 'wp_template' ? (0, _i18n._x)('Customized', 'template') : (0, _i18n._x)('Customized', 'template part'))));
185
177
  }
186
178
  //# sourceMappingURL=added-by.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["TEMPLATE_POST_TYPE_NAMES","BaseAddedBy","text","icon","imageUrl","isCustomized","templateType","isImageLoaded","setIsImageLoaded","AddedByTheme","slug","theme","select","coreStore","getTheme","themeIcon","name","rendered","AddedByPlugin","plugin","getPlugin","pluginIcon","AddedByAuthor","id","user","getUser","authorIcon","avatar_urls","nickname","AddedBySite","logoURL","getEntityRecord","getMedia","siteData","site_logo","source_url","undefined","globeIcon","AddedBy","template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AC,YAAD;AACC,QAAA,IAAI,EAAGJ,QAAQ,CAAC5B,KADjB;AAEC,QAAA,YAAY,EAAG4B,QAAQ,CAACI,MAAT,KAAoB,QAFpC;AAGC,QAAA,YAAY,EAAGrC;AAHhB,QADD;AAOA,KAlBuD,CAoBxD;;;AACA,QAAKiC,QAAQ,CAACE,cAAT,IAA2BF,QAAQ,CAACG,MAAT,KAAoB,QAApD,EAA+D;AAC9D,aACC,4BAAC,aAAD;AACC,QAAA,IAAI,EAAGH,QAAQ,CAAC5B,KADjB;AAEC,QAAA,YAAY,EAAG4B,QAAQ,CAACI,MAAT,KAAoB,QAFpC;AAGC,QAAA,YAAY,EAAGrC;AAHhB,QADD;AAOA,KA7BuD,CA+BxD;AACA;AACA;;;AACA,QACC,CAAEiC,QAAQ,CAACE,cAAX,IACAF,QAAQ,CAACI,MAAT,KAAoB,QADpB,IAEA,CAAEJ,QAAQ,CAACK,MAHZ,EAIE;AACD,aAAO,4BAAC,WAAD;AAAa,QAAA,YAAY,EAAGtC;AAA5B,QAAP;AACA;AACD,GA9C4D,CAgD7D;AACA;;;AACA,SACC,4BAAC,aAAD;AAAe,IAAA,EAAE,EAAGiC,QAAQ,CAACK,MAA7B;AAAsC,IAAA,YAAY,EAAGtC;AAArD,IADD;AAGA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\nimport { _x } from '@wordpress/i18n';\n\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\nfunction BaseAddedBy( { text, icon, imageUrl, isCustomized, templateType } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t{ imageUrl ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>\n\t\t\t\t{ text }\n\t\t\t\t{ isCustomized && (\n\t\t\t\t\t<span className=\"edit-site-list-added-by__customized-info\">\n\t\t\t\t\t\t{ templateType === 'wp_template'\n\t\t\t\t\t\t\t? _x( 'Customized', 'template' )\n\t\t\t\t\t\t\t: _x( 'Customized', 'template part' ) }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByTheme( { slug, isCustomized, templateType } ) {\n\tconst theme = useSelect(\n\t\t( select ) => select( coreStore ).getTheme( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ themeIcon }\n\t\t\ttext={ theme?.name?.rendered || slug }\n\t\t\tisCustomized={ isCustomized }\n\t\t\ttemplateType={ templateType }\n\t\t/>\n\t);\n}\n\nfunction AddedByPlugin( { slug, isCustomized, templateType } ) {\n\tconst plugin = useSelect(\n\t\t( select ) => select( coreStore ).getPlugin( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ pluginIcon }\n\t\t\ttext={ plugin?.name || slug }\n\t\t\tisCustomized={ isCustomized }\n\t\t\ttemplateType={ templateType }\n\t\t/>\n\t);\n}\n\nfunction AddedByAuthor( { id, templateType } ) {\n\tconst user = useSelect(\n\t\t( select ) => select( coreStore ).getUser( id ),\n\t\t[ id ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ authorIcon }\n\t\t\timageUrl={ user?.avatar_urls?.[ 48 ] }\n\t\t\ttext={ user?.nickname }\n\t\t\ttemplateType={ templateType }\n\t\t/>\n\t);\n}\n\nfunction AddedBySite( { templateType } ) {\n\tconst { name, logoURL } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getMedia } = select( coreStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tname: siteData?.name,\n\t\t\tlogoURL: siteData?.site_logo\n\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t: undefined,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ globeIcon }\n\t\t\timageUrl={ logoURL }\n\t\t\ttext={ name }\n\t\t\ttemplateType={ templateType }\n\t\t/>\n\t);\n}\n\nexport default function AddedBy( { templateType, template } ) {\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tif ( TEMPLATE_POST_TYPE_NAMES.includes( templateType ) ) {\n\t\t// Template originally provided by a theme, but customized by a user.\n\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t// or 'custom' source.\n\t\tif (\n\t\t\ttemplate.has_theme_file &&\n\t\t\t( template.origin === 'theme' ||\n\t\t\t\t( ! template.origin &&\n\t\t\t\t\t[ 'theme', 'custom' ].includes( template.source ) ) )\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<AddedByTheme\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t\ttemplateType={ templateType }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template originally provided by a plugin, but customized by a user.\n\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\treturn (\n\t\t\t\t<AddedByPlugin\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t\ttemplateType={ templateType }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template was created from scratch, but has no author. Author support\n\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t// site logo and title.\n\t\tif (\n\t\t\t! template.has_theme_file &&\n\t\t\ttemplate.source === 'custom' &&\n\t\t\t! template.author\n\t\t) {\n\t\t\treturn <AddedBySite templateType={ templateType } />;\n\t\t}\n\t}\n\n\t// Simply show the author for templates created from scratch that have an\n\t// author or for any other post type.\n\treturn (\n\t\t<AddedByAuthor id={ template.author } templateType={ templateType } />\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["TEMPLATE_POST_TYPE_NAMES","useAddedBy","postType","postId","select","getTheme","getPlugin","getEntityRecord","getMedia","getUser","getEditedEntityRecord","coreStore","template","includes","type","has_theme_file","origin","source","icon","themeIcon","text","theme","name","rendered","isCustomized","pluginIcon","author","siteData","globeIcon","imageUrl","site_logo","source_url","undefined","user","authorIcon","avatar_urls","nickname","AvatarImage","isImageLoaded","setIsImageLoaded","AddedBy"],"mappings":";;;;;;;;;;AAYA;;AARA;;AAKA;;AACA;;AACA;;AAEA;;AAMA;;AAnBA;;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;;AAEA;AACA,MAAMA,wBAAwB,GAAG,CAAE,aAAF,EAAiB,kBAAjB,CAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,UAAT,CAAqBC,QAArB,EAA+BC,MAA/B,EAAwC;AAC9C,SAAO,qBACJC,MAAF,IAAc;AAAA;;AACb,UAAM;AACLC,MAAAA,QADK;AAELC,MAAAA,SAFK;AAGLC,MAAAA,eAHK;AAILC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C;AAEC,IAAA,GAAG,EAAC,EAFL;AAGC,IAAA,GAAG,EAAGV;AAHP,IALD,CADD;AAaA;AAED;AACA;AACA;AACA;AACA;;;AACe,SAASW,OAAT,QAAyC;AAAA,MAAvB;AAAEtC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAuB;AACvD,QAAM;AAAEiB,IAAAA,IAAF;AAAQF,IAAAA,IAAR;AAAcW,IAAAA,QAAd;AAAwBL,IAAAA;AAAxB,MAAyCvB,UAAU,CACxDC,QADwD,EAExDC,MAFwD,CAAzD;AAKA,SACC,4BAAC,gCAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACG0B,QAAQ,GACT,4BAAC,WAAD;AAAa,IAAA,QAAQ,EAAGA;AAAxB,IADS,GAGT;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,gBAAD;AAAM,IAAA,IAAI,EAAGX;AAAb,IADD,CAJF,EAQC,0CACGE,IADH,EAEGI,YAAY,IACb;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGtB,QAAQ,KAAK,aAAb,GACC,cAAI,YAAJ,EAAkB,UAAlB,CADD,GAEC,cAAI,YAAJ,EAAkB,eAAlB,CAHJ,CAHF,CARD,CADD;AAqBA","sourcesContent":["// @ts-check\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, __experimentalHStack as HStack } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\nimport { _x } from '@wordpress/i18n';\n\n/** @typedef {'wp_template'|'wp_template_part'} TemplateType */\n\n/** @type {TemplateType} */\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\n/**\n * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType\n *\n * @typedef AddedByData\n * @type {Object}\n * @property {AddedByType} type The type of the data.\n * @property {JSX.Element} icon The icon to display.\n * @property {string} [imageUrl] The optional image URL to display.\n * @property {string} [text] The text to display.\n * @property {boolean} isCustomized Whether the template has been customized.\n *\n * @param {TemplateType} postType The template post type.\n * @param {number} postId The template post id.\n * @return {AddedByData} The added by object or null.\n */\nexport function useAddedBy( postType, postId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetTheme,\n\t\t\t\tgetPlugin,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetMedia,\n\t\t\t\tgetUser,\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\tconst template = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\n\t\t\tif ( TEMPLATE_POST_TYPE_NAMES.includes( template.type ) ) {\n\t\t\t\t// Added by theme.\n\t\t\t\t// Template originally provided by a theme, but customized by a user.\n\t\t\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t\t\t// or 'custom' source.\n\t\t\t\tif (\n\t\t\t\t\ttemplate.has_theme_file &&\n\t\t\t\t\t( template.origin === 'theme' ||\n\t\t\t\t\t\t( ! template.origin &&\n\t\t\t\t\t\t\t[ 'theme', 'custom' ].includes(\n\t\t\t\t\t\t\t\ttemplate.source\n\t\t\t\t\t\t\t) ) )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'theme',\n\t\t\t\t\t\ticon: themeIcon,\n\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\tgetTheme( template.theme )?.name?.rendered ||\n\t\t\t\t\t\t\ttemplate.theme,\n\t\t\t\t\t\tisCustomized: template.source === 'custom',\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Added by plugin.\n\t\t\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'plugin',\n\t\t\t\t\t\ticon: pluginIcon,\n\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\tgetPlugin( template.theme )?.name || template.theme,\n\t\t\t\t\t\tisCustomized: template.source === 'custom',\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Added by site.\n\t\t\t\t// Template was created from scratch, but has no author. Author support\n\t\t\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t\t\t// site logo and title.\n\t\t\t\tif (\n\t\t\t\t\t! template.has_theme_file &&\n\t\t\t\t\ttemplate.source === 'custom' &&\n\t\t\t\t\t! template.author\n\t\t\t\t) {\n\t\t\t\t\tconst siteData = getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'site',\n\t\t\t\t\t\ticon: globeIcon,\n\t\t\t\t\t\timageUrl: siteData?.site_logo\n\t\t\t\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\ttext: siteData?.name,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Added by user.\n\t\t\tconst user = getUser( template.author );\n\t\t\treturn {\n\t\t\t\ttype: 'user',\n\t\t\t\ticon: authorIcon,\n\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\ttext: user?.nickname,\n\t\t\t\tisCustomized: false,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n}\n\n/**\n * @param {Object} props\n * @param {string} props.imageUrl\n */\nfunction AvatarImage( { imageUrl } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t} ) }\n\t\t>\n\t\t\t<img\n\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\talt=\"\"\n\t\t\t\tsrc={ imageUrl }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * @param {Object} props\n * @param {TemplateType} props.postType The template post type.\n * @param {number} props.postId The template post id.\n */\nexport default function AddedBy( { postType, postId } ) {\n\tconst { text, icon, imageUrl, isCustomized } = useAddedBy(\n\t\tpostType,\n\t\tpostId\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t{ imageUrl ? (\n\t\t\t\t<AvatarImage imageUrl={ imageUrl } />\n\t\t\t) : (\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>\n\t\t\t\t{ text }\n\t\t\t\t{ isCustomized && (\n\t\t\t\t\t<span className=\"edit-site-list-added-by__customized-info\">\n\t\t\t\t\t\t{ postType === 'wp_template'\n\t\t\t\t\t\t\t? _x( 'Customized', 'template' )\n\t\t\t\t\t\t\t: _x( 'Customized', 'template part' ) }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</HStack>\n\t);\n}\n"]}
@@ -43,9 +43,10 @@ function List() {
43
43
 
44
44
  const {
45
45
  params: {
46
- postType: templateType
46
+ path
47
47
  }
48
48
  } = (0, _routes.useLocation)();
49
+ const templateType = path === '/wp_template/all' ? 'wp_template' : 'wp_template_part';
49
50
  (0, _useRegisterShortcuts.default)();
50
51
  const {
51
52
  previousShortcut,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["List","params","postType","templateType","previousShortcut","nextShortcut","select","keyboardShortcutsStore","getAllShortcutKeyCombinations","coreStore","getPostType","labels","name","itemsListLabel","items_list","detailedRegionLabels","header","body","undefined","previous","next"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;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;AAAvB,MAHV;AAIC,IAAA,OAAO,EAAG,4BAAC,uBAAD,OAJX;AAKC,IAAA,OAAO,EAAG,4BAAC,cAAD;AAAO,MAAA,YAAY,EAAGA;AAAtB,MALX;AAMC,IAAA,SAAS,EAAG;AACXgB,MAAAA,QAAQ,EAAEf,gBADC;AAEXgB,MAAAA,IAAI,EAAEf;AAFK;AANb,IADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { InterfaceSkeleton } from '@wordpress/interface';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useRegisterShortcuts from './use-register-shortcuts';\nimport Header from './header';\nimport Table from './table';\nimport { useLocation } from '../routes';\nimport useTitle from '../routes/use-title';\n\nexport default function List() {\n\tconst {\n\t\tparams: { postType: templateType },\n\t} = useLocation();\n\n\tuseRegisterShortcuts();\n\n\tconst { previousShortcut, nextShortcut } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/previous-region' ),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t};\n\t}, [] );\n\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tuseTitle( postType?.labels?.name );\n\n\t// `postType` could load in asynchronously. Only provide the detailed region labels if\n\t// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.\n\tconst itemsListLabel = postType?.labels?.items_list;\n\tconst detailedRegionLabels = postType\n\t\t? {\n\t\t\t\theader: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Header' as in the header area of that page.\n\t\t\t\t\t__( '%s - Header' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t\t\tbody: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Content' as in the content area of that page.\n\t\t\t\t\t__( '%s - Content' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t }\n\t\t: undefined;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tclassName=\"edit-site-list\"\n\t\t\tlabels={ detailedRegionLabels }\n\t\t\theader={ <Header templateType={ templateType } /> }\n\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\tcontent={ <Table templateType={ templateType } /> }\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["List","params","path","templateType","previousShortcut","nextShortcut","select","keyboardShortcutsStore","getAllShortcutKeyCombinations","postType","coreStore","getPostType","labels","name","itemsListLabel","items_list","detailedRegionLabels","header","body","undefined","previous","next"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAQA;AACA;AACA;AAOe,SAASA,IAAT,GAAgB;AAAA;;AAC9B,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA;AAAF;AADH,MAEF,0BAFJ;AAGA,QAAMC,YAAY,GACjBD,IAAI,KAAK,kBAAT,GAA8B,aAA9B,GAA8C,kBAD/C;AAGA;AAEA,QAAM;AAAEE,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAqC,qBAAaC,MAAF,IAAc;AACnE,WAAO;AACNF,MAAAA,gBAAgB,EAAEE,MAAM,CACvBC,wBADuB,CAAN,CAEhBC,6BAFgB,CAEe,gCAFf,CADZ;AAINH,MAAAA,YAAY,EAAEC,MAAM,CACnBC,wBADmB,CAAN,CAEZC,6BAFY,CAEmB,4BAFnB;AAJR,KAAP;AAQA,GAT0C,EASxC,EATwC,CAA3C;AAWA,QAAMC,QAAQ,GAAG,qBACdH,MAAF,IAAcA,MAAM,CAAEI,eAAF,CAAN,CAAoBC,WAApB,CAAiCR,YAAjC,CADE,EAEhB,CAAEA,YAAF,CAFgB,CAAjB;AAKA,yBAAUM,QAAV,aAAUA,QAAV,2CAAUA,QAAQ,CAAEG,MAApB,qDAAU,iBAAkBC,IAA5B,EAzB8B,CA2B9B;AACA;;AACA,QAAMC,cAAc,GAAGL,QAAH,aAAGA,QAAH,4CAAGA,QAAQ,CAAEG,MAAb,sDAAG,kBAAkBG,UAAzC;AACA,QAAMC,oBAAoB,GAAGP,QAAQ,GAClC;AACAQ,IAAAA,MAAM,EAAE,oBACP;AACA,kBAAI,aAAJ,CAFO,EAGPH,cAHO,CADR;AAMAI,IAAAA,IAAI,EAAE,oBACL;AACA,kBAAI,cAAJ,CAFK,EAGLJ,cAHK;AANN,GADkC,GAalCK,SAbH;AAeA,SACC,4BAAC,4BAAD;AACC,IAAA,SAAS,EAAC,gBADX;AAEC,IAAA,MAAM,EAAGH,oBAFV;AAGC,IAAA,MAAM,EAAG,4BAAC,eAAD;AAAQ,MAAA,YAAY,EAAGb;AAAvB,MAHV;AAIC,IAAA,OAAO,EAAG,4BAAC,uBAAD,OAJX;AAKC,IAAA,OAAO,EAAG,4BAAC,cAAD;AAAO,MAAA,YAAY,EAAGA;AAAtB,MALX;AAMC,IAAA,SAAS,EAAG;AACXiB,MAAAA,QAAQ,EAAEhB,gBADC;AAEXiB,MAAAA,IAAI,EAAEhB;AAFK;AANb,IADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { InterfaceSkeleton } from '@wordpress/interface';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useRegisterShortcuts from './use-register-shortcuts';\nimport Header from './header';\nimport Table from './table';\nimport { useLocation } from '../routes';\nimport useTitle from '../routes/use-title';\n\nexport default function List() {\n\tconst {\n\t\tparams: { path },\n\t} = useLocation();\n\tconst templateType =\n\t\tpath === '/wp_template/all' ? 'wp_template' : 'wp_template_part';\n\n\tuseRegisterShortcuts();\n\n\tconst { previousShortcut, nextShortcut } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/previous-region' ),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t};\n\t}, [] );\n\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tuseTitle( postType?.labels?.name );\n\n\t// `postType` could load in asynchronously. Only provide the detailed region labels if\n\t// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.\n\tconst itemsListLabel = postType?.labels?.items_list;\n\tconst detailedRegionLabels = postType\n\t\t? {\n\t\t\t\theader: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Header' as in the header area of that page.\n\t\t\t\t\t__( '%s - Header' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t\t\tbody: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Content' as in the content area of that page.\n\t\t\t\t\t__( '%s - Content' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t }\n\t\t: undefined;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tclassName=\"edit-site-list\"\n\t\t\tlabels={ detailedRegionLabels }\n\t\t\theader={ <Header templateType={ templateType } /> }\n\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\tcontent={ <Table templateType={ templateType } /> }\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
@@ -89,15 +89,16 @@ function Table(_ref) {
89
89
  }, (0, _element.createElement)(_link.default, {
90
90
  params: {
91
91
  postId: template.id,
92
- postType: template.type
92
+ postType: template.type,
93
+ canvas: 'edit'
93
94
  }
94
95
  }, (0, _htmlEntities.decodeEntities)(((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug))), (0, _htmlEntities.decodeEntities)(template.description)), (0, _element.createElement)("td", {
95
96
  className: "edit-site-list-table-column",
96
97
  role: "cell"
97
- }, (0, _element.createElement)(_addedBy.default, {
98
- templateType: templateType,
99
- template: template
100
- })), (0, _element.createElement)("td", {
98
+ }, template ? (0, _element.createElement)(_addedBy.default, {
99
+ postType: template.type,
100
+ postId: template.id
101
+ }) : null), (0, _element.createElement)("td", {
101
102
  className: "edit-site-list-table-column",
102
103
  role: "cell"
103
104
  }, (0, _element.createElement)(_actions.default, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["Table","templateType","records","templates","isResolving","isLoading","per_page","postType","select","coreStore","getPostType","length","labels","name","toLowerCase","sortedTemplates","sort","a","b","slug","localeCompare","map","template","id","postId","type","title","rendered","description"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAUA;AACA;AACA;AAKe,SAASA,KAAT,OAAmC;AAAA,MAAnB;AAAEC,IAAAA;AAAF,GAAmB;AACjD,QAAM;AAAEC,IAAAA,OAAO,EAAEC,SAAX;AAAsBC,IAAAA,WAAW,EAAEC;AAAnC,MAAiD,gCACtD,UADsD,EAEtDJ,YAFsD,EAGtD;AACCK,IAAAA,QAAQ,EAAE,CAAC;AADZ,GAHsD,CAAvD;AAOA,QAAMC,QAAQ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C,0BAFX;AAGC,QAAA,IAAI,EAAC;AAHN,SAKC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACC,4BAAC,iCAAD;AAAS,QAAA,KAAK,EAAG;AAAjB,SACC,4BAAC,aAAD;AACC,QAAA,MAAM,EAAG;AACRC,UAAAA,MAAM,EAAEF,QAAQ,CAACC,EADT;AAERhB,UAAAA,QAAQ,EAAEe,QAAQ,CAACG;AAFX;AADV,SAMG,kCACD,oBAAAH,QAAQ,CAACI,KAAT,oEAAgBC,QAAhB,KACCL,QAAQ,CAACH,IAFT,CANH,CADD,CADD,EAcG,kCAAgBG,QAAQ,CAACM,WAAzB,CAdH,CALD,EAsBC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACC,4BAAC,gBAAD;AACC,QAAA,YAAY,EAAG3B,YADhB;AAEC,QAAA,QAAQ,EAAGqB;AAFZ,QADD,CAtBD,EA4BC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACC,4BAAC,gBAAD;AAAS,QAAA,QAAQ,EAAGA;AAApB,QADD,CA5BD,CADsB;AAAA,KAArB,CADH,CAxBD;AAHD;AAiEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore, useEntityRecords } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tVisuallyHidden,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport Link from '../routes/link';\nimport Actions from './actions';\nimport AddedBy from './added-by';\n\nexport default function Table( { templateType } ) {\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\ttemplateType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tif ( ! templates || isLoading ) {\n\t\treturn null;\n\t}\n\n\tif ( ! templates.length ) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: The template type name, should be either \"templates\" or \"template parts\".\n\t\t\t\t\t__( 'No %s found.' ),\n\t\t\t\t\tpostType?.labels?.name?.toLowerCase()\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst sortedTemplates = [ ...templates ];\n\tsortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );\n\n\treturn (\n\t\t// These explicit aria roles are needed for Safari.\n\t\t// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables\n\t\t<table className=\"edit-site-list-table\" role=\"table\">\n\t\t\t<thead>\n\t\t\t\t<tr className=\"edit-site-list-table-head\" role=\"row\">\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Added by' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>\n\t\t\t\t\t</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\n\t\t\t<tbody>\n\t\t\t\t{ sortedTemplates.map( ( template ) => (\n\t\t\t\t\t<tr\n\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\tclassName=\"edit-site-list-table-row\"\n\t\t\t\t\t\trole=\"row\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Heading level={ 4 }>\n\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: template.type,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t{ decodeEntities( template.description ) }\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<AddedBy\n\t\t\t\t\t\t\t\ttemplateType={ templateType }\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Actions template={ template } />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t) ) }\n\t\t\t</tbody>\n\t\t</table>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["Table","templateType","records","templates","isResolving","isLoading","per_page","postType","select","coreStore","getPostType","length","labels","name","toLowerCase","sortedTemplates","sort","a","b","slug","localeCompare","map","template","id","postId","type","canvas","title","rendered","description"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAUA;AACA;AACA;AAKe,SAASA,KAAT,OAAmC;AAAA,MAAnB;AAAEC,IAAAA;AAAF,GAAmB;AACjD,QA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0BAAD,QAAkB,cAAI,SAAJ,CAAlB,CAJD,CAbD,CADD,CADD,EAwBC,2CACGJ,eAAe,CAACM,GAAhB,CAAuBC,QAAF;AAAA;;AAAA,aACtB;AACC,QAAA,GAAG,EAAGA,QAAQ,CAACC,EADhB;AAEC,QAAA,SAAS,EAAC,0BAFX;AAGC,QAAA,IAAI,EAAC;AAHN,SAKC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACC,4BAAC,iCAAD;AAAS,QAAA,KAAK,EAAG;AAAjB,SACC,4BAAC,aAAD;AACC,QAAA,MAAM,EAAG;AACRC,UAAAA,MAAM,EAAEF,QAAQ,CAACC,EADT;AAERhB,UAAAA,QAAQ,EAAEe,QAAQ,CAACG,IAFX;AAGRC,UAAAA,MAAM,EAAE;AAHA;AADV,SAOG,kCACD,oBAAAJ,QAAQ,CAACK,KAAT,oEAAgBC,QAAhB,KACCN,QAAQ,CAACH,IAFT,CAPH,CADD,CADD,EAeG,kCAAgBG,QAAQ,CAACO,WAAzB,CAfH,CALD,EAuBC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACGP,QAAQ,GACT,4BAAC,gBAAD;AACC,QAAA,QAAQ,EAAGA,QAAQ,CAACG,IADrB;AAEC,QAAA,MAAM,EAAGH,QAAQ,CAACC;AAFnB,QADS,GAKN,IANL,CAvBD,EA+BC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACC,4BAAC,gBAAD;AAAS,QAAA,QAAQ,EAAGD;AAApB,QADD,CA/BD,CADsB;AAAA,KAArB,CADH,CAxBD;AAHD;AAoEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore, useEntityRecords } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tVisuallyHidden,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport Link from '../routes/link';\nimport Actions from './actions';\nimport AddedBy from './added-by';\n\nexport default function Table( { templateType } ) {\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\ttemplateType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tif ( ! templates || isLoading ) {\n\t\treturn null;\n\t}\n\n\tif ( ! templates.length ) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: The template type name, should be either \"templates\" or \"template parts\".\n\t\t\t\t\t__( 'No %s found.' ),\n\t\t\t\t\tpostType?.labels?.name?.toLowerCase()\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst sortedTemplates = [ ...templates ];\n\tsortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );\n\n\treturn (\n\t\t// These explicit aria roles are needed for Safari.\n\t\t// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables\n\t\t<table className=\"edit-site-list-table\" role=\"table\">\n\t\t\t<thead>\n\t\t\t\t<tr className=\"edit-site-list-table-head\" role=\"row\">\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Added by' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>\n\t\t\t\t\t</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\n\t\t\t<tbody>\n\t\t\t\t{ sortedTemplates.map( ( template ) => (\n\t\t\t\t\t<tr\n\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\tclassName=\"edit-site-list-table-row\"\n\t\t\t\t\t\trole=\"row\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Heading level={ 4 }>\n\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: template.type,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t{ decodeEntities( template.description ) }\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t{ template ? (\n\t\t\t\t\t\t\t\t<AddedBy\n\t\t\t\t\t\t\t\t\tpostType={ template.type }\n\t\t\t\t\t\t\t\t\tpostId={ template.id }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Actions template={ template } />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t) ) }\n\t\t\t</tbody>\n\t\t</table>\n\t);\n}\n"]}
@@ -39,8 +39,11 @@ function useLink() {
39
39
  }
40
40
  }
41
41
 
42
+ const currentArgs = (0, _url.getQueryArgs)(window.location.href);
43
+ const currentUrlWithoutArgs = (0, _url.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs));
44
+ const newUrl = (0, _url.addQueryArgs)(currentUrlWithoutArgs, params);
42
45
  return {
43
- href: (0, _url.addQueryArgs)(window.location.href, params),
46
+ href: newUrl,
44
47
  onClick
45
48
  };
46
49
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","href","window","location","Link","children","props"],"mappings":";;;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGO,SAASA,OAAT,GAA8D;AAAA,MAA5CC,MAA4C,uEAAnC,EAAmC;AAAA,MAA/BC,KAA+B;AAAA,MAAxBC,aAAwB,uEAAR,KAAQ;AACpE,QAAMC,OAAO,GAAG,wBAAhB;;AAEA,WAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzBA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAKJ,aAAL,EAAqB;AACpBC,MAAAA,OAAO,CAACI,OAAR,CAAiBP,MAAjB,EAAyBC,KAAzB;AACA,KAFD,MAEO;AACNE,MAAAA,OAAO,CAACK,IAAR,CAAcR,MAAd,EAAsBC,KAAtB;AACA;AACD;;AAED,SAAO;AACNQ,IAAAA,IAAI,EAAE,uBAAcC,MAAM,CAACC,QAAP,CAAgBF,IAA9B,EAAoCT,MAApC,CADA;AAENI,IAAAA;AAFM,GAAP;AAIA;;AAEc,SAASQ,IAAT,OAMX;AAAA,MAN0B;AAC7BZ,IAAAA,MAAM,GAAG,EADoB;AAE7BC,IAAAA,KAF6B;AAG7BM,IAAAA,OAAO,EAAEL,aAAa,GAAG,KAHI;AAI7BW,IAAAA,QAJ6B;AAK7B,OAAGC;AAL0B,GAM1B;AACH,QAAM;AAAEL,IAAAA,IAAF;AAAQL,IAAAA;AAAR,MAAoBL,OAAO,CAAEC,MAAF,EAAUC,KAAV,EAAiBC,aAAjB,CAAjC;AAEA,SACC;AAAG,IAAA,IAAI,EAAGO,IAAV;AAAiB,IAAA,OAAO,EAAGL;AAA3B,KAA0CU,KAA1C,GACGD,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from './index';\n\nexport function useLink( params = {}, state, shouldReplace = false ) {\n\tconst history = useHistory();\n\n\tfunction onClick( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( shouldReplace ) {\n\t\t\thistory.replace( params, state );\n\t\t} else {\n\t\t\thistory.push( params, state );\n\t\t}\n\t}\n\n\treturn {\n\t\thref: addQueryArgs( window.location.href, params ),\n\t\tonClick,\n\t};\n}\n\nexport default function Link( {\n\tparams = {},\n\tstate,\n\treplace: shouldReplace = false,\n\tchildren,\n\t...props\n} ) {\n\tconst { href, onClick } = useLink( params, state, shouldReplace );\n\n\treturn (\n\t\t<a href={ href } onClick={ onClick } { ...props }>\n\t\t\t{ children }\n\t\t</a>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","currentArgs","window","location","href","currentUrlWithoutArgs","Object","keys","newUrl","Link","children","props"],"mappings":";;;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGO,SAASA,OAAT,GAA8D;AAAA,MAA5CC,MAA4C,uEAAnC,EAAmC;AAAA,MAA/BC,KAA+B;AAAA,MAAxBC,aAAwB,uEAAR,KAAQ;AACpE,QAAMC,OAAO,GAAG,wBAAhB;;AAEA,WAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzBA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAKJ,aAAL,EAAqB;AACpBC,MAAAA,OAAO,CAACI,OAAR,CAAiBP,MAAjB,EAAyBC,KAAzB;AACA,KAFD,MAEO;AACNE,MAAAA,OAAO,CAACK,IAAR,CAAcR,MAAd,EAAsBC,KAAtB;AACA;AACD;;AAED,QAAMQ,WAAW,GAAG,uBAAcC,MAAM,CAACC,QAAP,CAAgBC,IAA9B,CAApB;AACA,QAAMC,qBAAqB,GAAG,0BAC7BH,MAAM,CAACC,QAAP,CAAgBC,IADa,EAE7B,GAAGE,MAAM,CAACC,IAAP,CAAaN,WAAb,CAF0B,CAA9B;AAIA,QAAMO,MAAM,GAAG,uBAAcH,qBAAd,EAAqCb,MAArC,CAAf;AAEA,SAAO;AACNY,IAAAA,IAAI,EAAEI,MADA;AAENZ,IAAAA;AAFM,GAAP;AAIA;;AAEc,SAASa,IAAT,OAMX;AAAA,MAN0B;AAC7BjB,IAAAA,MAAM,GAAG,EADoB;AAE7BC,IAAAA,KAF6B;AAG7BM,IAAAA,OAAO,EAAEL,aAAa,GAAG,KAHI;AAI7BgB,IAAAA,QAJ6B;AAK7B,OAAGC;AAL0B,GAM1B;AACH,QAAM;AAAEP,IAAAA,IAAF;AAAQR,IAAAA;AAAR,MAAoBL,OAAO,CAAEC,MAAF,EAAUC,KAAV,EAAiBC,aAAjB,CAAjC;AAEA,SACC;AAAG,IAAA,IAAI,EAAGU,IAAV;AAAiB,IAAA,OAAO,EAAGR;AAA3B,KAA0Ce,KAA1C,GACGD,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from './index';\n\nexport function useLink( params = {}, state, shouldReplace = false ) {\n\tconst history = useHistory();\n\n\tfunction onClick( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( shouldReplace ) {\n\t\t\thistory.replace( params, state );\n\t\t} else {\n\t\t\thistory.push( params, state );\n\t\t}\n\t}\n\n\tconst currentArgs = getQueryArgs( window.location.href );\n\tconst currentUrlWithoutArgs = removeQueryArgs(\n\t\twindow.location.href,\n\t\t...Object.keys( currentArgs )\n\t);\n\tconst newUrl = addQueryArgs( currentUrlWithoutArgs, params );\n\n\treturn {\n\t\thref: newUrl,\n\t\tonClick,\n\t};\n}\n\nexport default function Link( {\n\tparams = {},\n\tstate,\n\treplace: shouldReplace = false,\n\tchildren,\n\t...props\n} ) {\n\tconst { href, onClick } = useLink( params, state, shouldReplace );\n\n\treturn (\n\t\t<a href={ href } onClick={ onClick } { ...props }>\n\t\t\t{ children }\n\t\t</a>\n\t);\n}\n"]}
@@ -26,10 +26,7 @@ var _store = require("../../store");
26
26
  /**
27
27
  * Internal dependencies
28
28
  */
29
- function SaveButton(_ref) {
30
- let {
31
- showTooltip = true
32
- } = _ref;
29
+ function SaveButton() {
33
30
  const {
34
31
  isDirty,
35
32
  isSaving,
@@ -77,7 +74,7 @@ function SaveButton(_ref) {
77
74
  & the tooltip is always rendered even when there's no keyboard shortcut.
78
75
  */
79
76
  ,
80
- showTooltip: showTooltip
77
+ showTooltip: true
81
78
  }, label);
82
79
  }
83
80
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/save-button/index.js"],"names":["SaveButton","showTooltip","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","coreStore","dirtyEntityRecords","isSaveViewOpened","editSiteStore","length","some","record","kind","name","key","setIsSaveViewOpened","disabled","label","undefined","displayShortcut","primary"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,UAAT,OAA8C;AAAA,MAAzB;AAAEC,IAAAA,WAAW,GAAG;AAAhB,GAAyB;AAC5D,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA;AAArB,MAAwC,qBAAaC,MAAF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ch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function SaveButton( { showTooltip = true } ) {\n\tconst { isDirty, isSaving, isSaveViewOpen } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\tconst { isSaveViewOpened } = select( editSiteStore );\n\t\treturn {\n\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t\tisSaving: dirtyEntityRecords.some( ( record ) =>\n\t\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t\t),\n\t\t\tisSaveViewOpen: isSaveViewOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsSaveViewOpened } = useDispatch( editSiteStore );\n\n\tconst disabled = ! isDirty || isSaving;\n\n\tconst label = __( 'Save' );\n\n\treturn (\n\t\t<Button\n\t\t\tvariant=\"primary\"\n\t\t\tclassName=\"edit-site-save-button__button\"\n\t\t\taria-disabled={ disabled }\n\t\t\taria-expanded={ isSaveViewOpen }\n\t\t\tisBusy={ isSaving }\n\t\t\tonClick={ disabled ? undefined : () => setIsSaveViewOpened( true ) }\n\t\t\tlabel={ label }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ disabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\t/*\n\t\t\t * Displaying the keyboard shortcut conditionally makes the tooltip\n\t\t\t * itself show conditionally. This would trigger a full-rerendering\n\t\t\t * of the button that we want to avoid. By setting `showTooltip`,\n\t\t\t & the tooltip is always rendered even when there's no keyboard shortcut.\n\t\t\t */\n\t\t\tshowTooltip={ showTooltip }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/save-button/index.js"],"names":["SaveButton","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","coreStore","dirtyEntityRecords","isSaveViewOpened","editSiteStore","length","some","record","kind","name","key","setIsSaveViewOpened","disabled","label","undefined","displayShortcut","primary"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA;AAArB,MAAwC,qBAAaC,MAAF,IAAc;AACtE,UAAM;AAAEC,MAAAA,mCAAF;AAAuCC,MAAAA;AAAvC,QACLF,MAAM,CAAEG,eAAF,CADP;;AAEA,UAAMC,kBAAkB,GAAGH,mCAAmC,EAA9D;;AACA,UAAM;AAAEI,MAAAA;AAAF,QAAuBL,MAAM,CAAEM,YAAF,CAAnC;AACA,WAAO;AACNT,MAAAA,OAAO,EAAEO,kBAAkB,CAACG,MAAnB,GAA4B,CAD/B;AAENT,MAAAA,QAAQ,EAAEM,kBAAkB,CAACI,IAAnB,CAA2BC,MAAF,IAClCP,oBAAoB,CAAEO,MAAM,CAACC,IAAT,EAAeD,MAAM,CAACE,IAAtB,EAA4BF,MAAM,CAACG,GAAnC,CADX,CAFJ;AAKNb,MAAAA,cAAc,EAAEM,gBAAgB;AAL1B,KAAP;AAOA,GAZ6C,EAY3C,EAZ2C,CAA9C;AAaA,QAAM;AAAEQ,IAAAA;AAAF,MAA0B,uBAAaP,YAAb,CAAhC;AAEA,QAAMQ,QAAQ,GAAG,CAAEjB,OAAF,IAAaC,QAA9B;AAEA,QAAMiB,KAAK,GAAG,cAAI,MAAJ,CAAd;AAEA,SACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,SAAS,EAAC,+BAFX;AAGC,qBAAgBD,QAHjB;AAIC,qBAAgBf,cAJjB;AAKC,IAAA,MAAM,EAAGD,QALV;AAMC,IAAA,OAAO,EAAGgB,QAAQ,GAAGE,SAAH,GAAe,MAAMH,mBAAmB,CAAE,IAAF,CAN3D;AAOC,IAAA,KAAK,EAAGE;AACR;AACH;AACA;AACA;AAXE;AAYC,IAAA,QAAQ,EAAGD,QAAQ,GAAGE,SAAH,GAAeC,0BAAgBC,OAAhB,CAAyB,GAAzB;AAClC;AACH;AACA;AACA;AACA;AACA;AAlBE;AAmBC,IAAA,WAAW;AAnBZ,KAqBGH,KArBH,CADD;AAyBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function SaveButton() {\n\tconst { isDirty, isSaving, isSaveViewOpen } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\tconst { isSaveViewOpened } = select( editSiteStore );\n\t\treturn {\n\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t\tisSaving: dirtyEntityRecords.some( ( record ) =>\n\t\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t\t),\n\t\t\tisSaveViewOpen: isSaveViewOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsSaveViewOpened } = useDispatch( editSiteStore );\n\n\tconst disabled = ! isDirty || isSaving;\n\n\tconst label = __( 'Save' );\n\n\treturn (\n\t\t<Button\n\t\t\tvariant=\"primary\"\n\t\t\tclassName=\"edit-site-save-button__button\"\n\t\t\taria-disabled={ disabled }\n\t\t\taria-expanded={ isSaveViewOpen }\n\t\t\tisBusy={ isSaving }\n\t\t\tonClick={ disabled ? undefined : () => setIsSaveViewOpened( true ) }\n\t\t\tlabel={ label }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ disabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\t/*\n\t\t\t * Displaying the keyboard shortcut conditionally makes the tooltip\n\t\t\t * itself show conditionally. This would trigger a full-rerendering\n\t\t\t * of the button that we want to avoid. By setting `showTooltip`,\n\t\t\t & the tooltip is always rendered even when there's no keyboard shortcut.\n\t\t\t */\n\t\t\tshowTooltip\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"]}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = SaveButton;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _data = require("@wordpress/data");
11
+
12
+ var _components = require("@wordpress/components");
13
+
14
+ var _i18n = require("@wordpress/i18n");
15
+
16
+ var _coreData = require("@wordpress/core-data");
17
+
18
+ var _keycodes = require("@wordpress/keycodes");
19
+
20
+ var _icons = require("@wordpress/icons");
21
+
22
+ var _store = require("../../store");
23
+
24
+ /**
25
+ * WordPress dependencies
26
+ */
27
+
28
+ /**
29
+ * Internal dependencies
30
+ */
31
+ function SaveButton() {
32
+ const {
33
+ countUnsavedChanges,
34
+ isDirty,
35
+ isSaving,
36
+ isSaveViewOpen
37
+ } = (0, _data.useSelect)(select => {
38
+ const {
39
+ __experimentalGetDirtyEntityRecords,
40
+ isSavingEntityRecord
41
+ } = select(_coreData.store);
42
+
43
+ const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
44
+
45
+ const {
46
+ isSaveViewOpened
47
+ } = select(_store.store);
48
+ return {
49
+ isDirty: dirtyEntityRecords.length > 0,
50
+ isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)),
51
+ isSaveViewOpen: isSaveViewOpened(),
52
+ countUnsavedChanges: dirtyEntityRecords.length
53
+ };
54
+ }, []);
55
+ const {
56
+ setIsSaveViewOpened
57
+ } = (0, _data.useDispatch)(_store.store);
58
+ const disabled = !isDirty || isSaving;
59
+ const label = disabled ? (0, _i18n.__)('Saved') : (0, _i18n.__)('Save');
60
+ return (0, _element.createElement)(_components.__experimentalHStack, {
61
+ className: "edit-site-save-hub",
62
+ alignment: "right",
63
+ spacing: 4
64
+ }, isDirty && (0, _element.createElement)("span", null, (0, _i18n.sprintf)( // translators: %d: number of unsaved changes (number).
65
+ (0, _i18n._n)('%d unsaved change', '%d unsaved changes', countUnsavedChanges), countUnsavedChanges)), (0, _element.createElement)(_components.Button, {
66
+ className: "edit-site-save-hub__button",
67
+ variant: disabled ? undefined : 'primary',
68
+ "aria-disabled": disabled,
69
+ "aria-expanded": isSaveViewOpen,
70
+ isBusy: isSaving,
71
+ onClick: disabled ? undefined : () => setIsSaveViewOpened(true),
72
+ label: label
73
+ /*
74
+ * We want the tooltip to show the keyboard shortcut only when the
75
+ * button does something, i.e. when it's not disabled.
76
+ */
77
+ ,
78
+ shortcut: disabled ? undefined : _keycodes.displayShortcut.primary('s'),
79
+ icon: disabled ? _icons.check : undefined
80
+ }, label));
81
+ }
82
+ //# sourceMappingURL=index.js.map