@wordpress/edit-site 3.0.9 → 3.0.13

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 (263) hide show
  1. package/build/components/add-new-template/index.js +49 -0
  2. package/build/components/add-new-template/index.js.map +1 -0
  3. package/build/components/add-new-template/new-template-part.js +95 -0
  4. package/build/components/add-new-template/new-template-part.js.map +1 -0
  5. package/build/components/add-new-template/new-template.js +133 -0
  6. package/build/components/add-new-template/new-template.js.map +1 -0
  7. package/build/components/block-editor/index.js +3 -1
  8. package/build/components/block-editor/index.js.map +1 -1
  9. package/build/components/create-template-part-modal/index.js +115 -0
  10. package/build/components/create-template-part-modal/index.js.map +1 -0
  11. package/build/components/editor/index.js +20 -16
  12. package/build/components/editor/index.js.map +1 -1
  13. package/build/components/global-styles/color-palette-panel.js +29 -6
  14. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  15. package/build/components/global-styles/global-styles-provider.js +9 -47
  16. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  17. package/build/components/global-styles/gradients-palette-panel.js +71 -0
  18. package/build/components/global-styles/gradients-palette-panel.js.map +1 -0
  19. package/build/components/global-styles/hooks.js +29 -27
  20. package/build/components/global-styles/hooks.js.map +1 -1
  21. package/build/components/global-styles/palette.js +11 -5
  22. package/build/components/global-styles/palette.js.map +1 -1
  23. package/build/components/global-styles/screen-background-color.js +2 -1
  24. package/build/components/global-styles/screen-background-color.js.map +1 -1
  25. package/build/components/global-styles/screen-block-list.js +9 -1
  26. package/build/components/global-styles/screen-block-list.js.map +1 -1
  27. package/build/components/global-styles/screen-color-palette.js +23 -3
  28. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  29. package/build/components/global-styles/screen-link-color.js +2 -1
  30. package/build/components/global-styles/screen-link-color.js.map +1 -1
  31. package/build/components/global-styles/screen-text-color.js +2 -1
  32. package/build/components/global-styles/screen-text-color.js.map +1 -1
  33. package/build/components/global-styles/screen-typography-element.js +54 -0
  34. package/build/components/global-styles/screen-typography-element.js.map +1 -0
  35. package/build/components/global-styles/screen-typography.js +74 -6
  36. package/build/components/global-styles/screen-typography.js.map +1 -1
  37. package/build/components/global-styles/typography-panel.js +28 -8
  38. package/build/components/global-styles/typography-panel.js.map +1 -1
  39. package/build/components/global-styles/ui.js +12 -0
  40. package/build/components/global-styles/ui.js.map +1 -1
  41. package/build/components/global-styles/use-global-styles-output.js +2 -2
  42. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  43. package/build/components/global-styles/utils.js +1 -1
  44. package/build/components/global-styles/utils.js.map +1 -1
  45. package/build/components/header/index.js +1 -5
  46. package/build/components/header/index.js.map +1 -1
  47. package/build/components/keyboard-shortcuts/index.js +26 -0
  48. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  49. package/build/components/list/actions/index.js +104 -0
  50. package/build/components/list/actions/index.js.map +1 -0
  51. package/build/components/list/actions/rename-menu-item.js +112 -0
  52. package/build/components/list/actions/rename-menu-item.js.map +1 -0
  53. package/build/components/list/added-by.js +180 -0
  54. package/build/components/list/added-by.js.map +1 -0
  55. package/build/components/list/header.js +50 -0
  56. package/build/components/list/header.js.map +1 -0
  57. package/build/components/list/index.js +102 -0
  58. package/build/components/list/index.js.map +1 -0
  59. package/build/components/list/table.js +114 -0
  60. package/build/components/list/table.js.map +1 -0
  61. package/build/components/list/use-register-shortcuts.js +52 -0
  62. package/build/components/list/use-register-shortcuts.js.map +1 -0
  63. package/build/components/navigation-sidebar/index.js +26 -10
  64. package/build/components/navigation-sidebar/index.js.map +1 -1
  65. package/build/components/navigation-sidebar/navigation-panel/index.js +42 -44
  66. package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  67. package/build/components/navigation-sidebar/navigation-toggle/index.js +5 -17
  68. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  69. package/build/components/template-details/edit-template-title.js +33 -0
  70. package/build/components/template-details/edit-template-title.js.map +1 -0
  71. package/build/components/template-details/index.js +8 -3
  72. package/build/components/template-details/index.js.map +1 -1
  73. package/build/components/template-part-converter/convert-to-template-part.js +20 -84
  74. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  75. package/build/components/welcome-guide/editor.js +58 -0
  76. package/build/components/welcome-guide/editor.js.map +1 -0
  77. package/build/components/welcome-guide/image.js +27 -0
  78. package/build/components/welcome-guide/image.js.map +1 -0
  79. package/build/components/welcome-guide/index.js +49 -0
  80. package/build/components/welcome-guide/index.js.map +1 -0
  81. package/build/components/welcome-guide/styles.js +83 -0
  82. package/build/components/welcome-guide/styles.js.map +1 -0
  83. package/build/index.js +36 -6
  84. package/build/index.js.map +1 -1
  85. package/build/plugins/index.js +4 -2
  86. package/build/plugins/index.js.map +1 -1
  87. package/build/plugins/welcome-guide-menu-item.js +39 -0
  88. package/build/plugins/welcome-guide-menu-item.js.map +1 -0
  89. package/build/store/actions.js +50 -24
  90. package/build/store/actions.js.map +1 -1
  91. package/build/store/defaults.js +4 -1
  92. package/build/store/defaults.js.map +1 -1
  93. package/build/store/selectors.js +25 -5
  94. package/build/store/selectors.js.map +1 -1
  95. package/build/utils/is-template-removable.js +21 -0
  96. package/build/utils/is-template-removable.js.map +1 -0
  97. package/build-module/components/add-new-template/index.js +36 -0
  98. package/build-module/components/add-new-template/index.js.map +1 -0
  99. package/build-module/components/add-new-template/new-template-part.js +79 -0
  100. package/build-module/components/add-new-template/new-template-part.js.map +1 -0
  101. package/build-module/components/add-new-template/new-template.js +114 -0
  102. package/build-module/components/add-new-template/new-template.js.map +1 -0
  103. package/build-module/components/block-editor/index.js +2 -1
  104. package/build-module/components/block-editor/index.js.map +1 -1
  105. package/build-module/components/create-template-part-modal/index.js +102 -0
  106. package/build-module/components/create-template-part-modal/index.js.map +1 -0
  107. package/build-module/components/editor/index.js +19 -17
  108. package/build-module/components/editor/index.js.map +1 -1
  109. package/build-module/components/global-styles/color-palette-panel.js +29 -7
  110. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  111. package/build-module/components/global-styles/global-styles-provider.js +10 -43
  112. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  113. package/build-module/components/global-styles/gradients-palette-panel.js +60 -0
  114. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -0
  115. package/build-module/components/global-styles/hooks.js +30 -28
  116. package/build-module/components/global-styles/hooks.js.map +1 -1
  117. package/build-module/components/global-styles/palette.js +12 -5
  118. package/build-module/components/global-styles/palette.js.map +1 -1
  119. package/build-module/components/global-styles/screen-background-color.js +2 -1
  120. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  121. package/build-module/components/global-styles/screen-block-list.js +7 -1
  122. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  123. package/build-module/components/global-styles/screen-color-palette.js +22 -3
  124. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  125. package/build-module/components/global-styles/screen-link-color.js +2 -1
  126. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  127. package/build-module/components/global-styles/screen-text-color.js +2 -1
  128. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  129. package/build-module/components/global-styles/screen-typography-element.js +41 -0
  130. package/build-module/components/global-styles/screen-typography-element.js.map +1 -0
  131. package/build-module/components/global-styles/screen-typography.js +70 -6
  132. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  133. package/build-module/components/global-styles/typography-panel.js +28 -8
  134. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  135. package/build-module/components/global-styles/ui.js +11 -0
  136. package/build-module/components/global-styles/ui.js.map +1 -1
  137. package/build-module/components/global-styles/use-global-styles-output.js +2 -2
  138. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  139. package/build-module/components/global-styles/utils.js +1 -1
  140. package/build-module/components/global-styles/utils.js.map +1 -1
  141. package/build-module/components/header/index.js +1 -3
  142. package/build-module/components/header/index.js.map +1 -1
  143. package/build-module/components/keyboard-shortcuts/index.js +26 -0
  144. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  145. package/build-module/components/list/actions/index.js +85 -0
  146. package/build-module/components/list/actions/index.js.map +1 -0
  147. package/build-module/components/list/actions/rename-menu-item.js +101 -0
  148. package/build-module/components/list/actions/rename-menu-item.js.map +1 -0
  149. package/build-module/components/list/added-by.js +166 -0
  150. package/build-module/components/list/added-by.js.map +1 -0
  151. package/build-module/components/list/header.js +37 -0
  152. package/build-module/components/list/header.js.map +1 -0
  153. package/build-module/components/list/index.js +81 -0
  154. package/build-module/components/list/index.js.map +1 -0
  155. package/build-module/components/list/table.js +98 -0
  156. package/build-module/components/list/table.js.map +1 -0
  157. package/build-module/components/list/use-register-shortcuts.js +41 -0
  158. package/build-module/components/list/use-register-shortcuts.js.map +1 -0
  159. package/build-module/components/navigation-sidebar/index.js +26 -10
  160. package/build-module/components/navigation-sidebar/index.js.map +1 -1
  161. package/build-module/components/navigation-sidebar/navigation-panel/index.js +41 -44
  162. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  163. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +6 -18
  164. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  165. package/build-module/components/template-details/edit-template-title.js +23 -0
  166. package/build-module/components/template-details/edit-template-title.js.map +1 -0
  167. package/build-module/components/template-details/index.js +7 -3
  168. package/build-module/components/template-details/index.js.map +1 -1
  169. package/build-module/components/template-part-converter/convert-to-template-part.js +20 -84
  170. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  171. package/build-module/components/welcome-guide/editor.js +45 -0
  172. package/build-module/components/welcome-guide/editor.js.map +1 -0
  173. package/build-module/components/welcome-guide/image.js +19 -0
  174. package/build-module/components/welcome-guide/image.js.map +1 -0
  175. package/build-module/components/welcome-guide/index.js +35 -0
  176. package/build-module/components/welcome-guide/index.js.map +1 -0
  177. package/build-module/components/welcome-guide/styles.js +69 -0
  178. package/build-module/components/welcome-guide/styles.js.map +1 -0
  179. package/build-module/index.js +28 -3
  180. package/build-module/index.js.map +1 -1
  181. package/build-module/plugins/index.js +3 -2
  182. package/build-module/plugins/index.js.map +1 -1
  183. package/build-module/plugins/welcome-guide-menu-item.js +27 -0
  184. package/build-module/plugins/welcome-guide-menu-item.js.map +1 -0
  185. package/build-module/store/actions.js +51 -25
  186. package/build-module/store/actions.js.map +1 -1
  187. package/build-module/store/defaults.js +4 -1
  188. package/build-module/store/defaults.js.map +1 -1
  189. package/build-module/store/selectors.js +21 -3
  190. package/build-module/store/selectors.js.map +1 -1
  191. package/build-module/utils/is-template-removable.js +14 -0
  192. package/build-module/utils/is-template-removable.js.map +1 -0
  193. package/build-style/style-rtl.css +477 -34
  194. package/build-style/style.css +477 -34
  195. package/package.json +10 -8
  196. package/src/components/add-new-template/index.js +30 -0
  197. package/src/components/add-new-template/new-template-part.js +81 -0
  198. package/src/components/add-new-template/new-template.js +136 -0
  199. package/src/components/add-new-template/style.scss +11 -0
  200. package/src/components/block-editor/index.js +2 -0
  201. package/src/components/create-template-part-modal/index.js +132 -0
  202. package/src/components/{template-part-converter → create-template-part-modal}/style.scss +9 -9
  203. package/src/components/editor/index.js +22 -15
  204. package/src/components/editor/style.scss +8 -0
  205. package/src/components/global-styles/color-palette-panel.js +64 -7
  206. package/src/components/global-styles/global-styles-provider.js +7 -36
  207. package/src/components/global-styles/gradients-palette-panel.js +99 -0
  208. package/src/components/global-styles/hooks.js +59 -27
  209. package/src/components/global-styles/palette.js +30 -10
  210. package/src/components/global-styles/screen-background-color.js +1 -0
  211. package/src/components/global-styles/screen-block-list.js +11 -1
  212. package/src/components/global-styles/screen-color-palette.js +30 -3
  213. package/src/components/global-styles/screen-link-color.js +1 -0
  214. package/src/components/global-styles/screen-text-color.js +1 -0
  215. package/src/components/global-styles/screen-typography-element.js +39 -0
  216. package/src/components/global-styles/screen-typography.js +84 -3
  217. package/src/components/global-styles/style.scss +42 -1
  218. package/src/components/global-styles/test/use-global-styles-output.js +3 -3
  219. package/src/components/global-styles/test/utils.js +1 -1
  220. package/src/components/global-styles/typography-panel.js +37 -7
  221. package/src/components/global-styles/ui.js +9 -0
  222. package/src/components/global-styles/use-global-styles-output.js +2 -2
  223. package/src/components/global-styles/utils.js +1 -1
  224. package/src/components/header/index.js +0 -6
  225. package/src/components/keyboard-shortcuts/index.js +32 -0
  226. package/src/components/list/actions/index.js +95 -0
  227. package/src/components/list/actions/rename-menu-item.js +134 -0
  228. package/src/components/list/added-by.js +179 -0
  229. package/src/components/list/header.js +34 -0
  230. package/src/components/list/index.js +96 -0
  231. package/src/components/list/style.scss +208 -0
  232. package/src/components/list/table.js +121 -0
  233. package/src/components/list/use-register-shortcuts.js +45 -0
  234. package/src/components/navigation-sidebar/index.js +24 -8
  235. package/src/components/navigation-sidebar/navigation-panel/index.js +57 -51
  236. package/src/components/navigation-sidebar/navigation-panel/style.scss +4 -2
  237. package/src/components/navigation-sidebar/navigation-toggle/index.js +24 -36
  238. package/src/components/navigation-sidebar/navigation-toggle/test/index.js +2 -0
  239. package/src/components/sidebar/style.scss +2 -1
  240. package/src/components/template-details/edit-template-title.js +28 -0
  241. package/src/components/template-details/index.js +15 -9
  242. package/src/components/template-part-converter/convert-to-template-part.js +20 -140
  243. package/src/components/welcome-guide/editor.js +63 -0
  244. package/src/components/welcome-guide/image.js +11 -0
  245. package/src/components/welcome-guide/index.js +33 -0
  246. package/src/components/welcome-guide/style.scss +37 -0
  247. package/src/components/welcome-guide/styles.js +116 -0
  248. package/src/index.js +31 -3
  249. package/src/plugins/index.js +3 -1
  250. package/src/plugins/welcome-guide-menu-item.js +35 -0
  251. package/src/store/actions.js +85 -35
  252. package/src/store/defaults.js +4 -1
  253. package/src/store/selectors.js +22 -4
  254. package/src/store/test/actions.js +0 -30
  255. package/src/store/test/selectors.js +24 -0
  256. package/src/style.scss +9 -6
  257. package/src/utils/is-template-removable.js +13 -0
  258. package/build/components/header/navigation-link/index.js +0 -87
  259. package/build/components/header/navigation-link/index.js.map +0 -1
  260. package/build-module/components/header/navigation-link/index.js +0 -74
  261. package/build-module/components/header/navigation-link/index.js.map +0 -1
  262. package/src/components/header/navigation-link/index.js +0 -71
  263. package/src/components/header/navigation-link/style.scss +0 -69
@@ -124,6 +124,32 @@ function KeyboardShortcutsRegister() {
124
124
  character: ','
125
125
  }
126
126
  });
127
+ registerShortcut({
128
+ name: 'core/edit-site/next-region',
129
+ category: 'global',
130
+ description: __('Navigate to the next part of the editor.'),
131
+ keyCombination: {
132
+ modifier: 'ctrl',
133
+ character: '`'
134
+ },
135
+ aliases: [{
136
+ modifier: 'access',
137
+ character: 'n'
138
+ }]
139
+ });
140
+ registerShortcut({
141
+ name: 'core/edit-site/previous-region',
142
+ category: 'global',
143
+ description: __('Navigate to the previous part of the editor.'),
144
+ keyCombination: {
145
+ modifier: 'ctrlShift',
146
+ character: '`'
147
+ },
148
+ aliases: [{
149
+ modifier: 'access',
150
+ character: 'p'
151
+ }]
152
+ });
127
153
  }, [registerShortcut]);
128
154
  return null;
129
155
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/keyboard-shortcuts/index.js"],"names":["useEffect","useShortcut","store","keyboardShortcutsStore","useDispatch","useSelect","__","coreStore","interfaceStore","editSiteStore","SIDEBAR_BLOCK","STORE_NAME","KeyboardShortcuts","openEntitiesSavedStates","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","isListViewOpen","select","isListViewOpened","isBlockInspectorOpen","getActiveComplementaryArea","name","redo","undo","setIsListViewOpened","enableComplementaryArea","disableComplementaryArea","event","preventDefault","dirtyEntityRecords","isDirty","length","isSaving","some","record","kind","key","KeyboardShortcutsRegister","registerShortcut","category","description","keyCombination","modifier","character","Register"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SACCC,WADD,EAECC,KAAK,IAAIC,sBAFV,QAGO,+BAHP;AAIA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASJ,KAAK,IAAIK,SAAlB,QAAmC,sBAAnC;AACA,SAASL,K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BC,MAAAA,WAAW,EAAElC,EAAE,CAAE,yBAAF,CAHE;AAIjBmC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,SADK;AAEfC,QAAAA,SAAS,EAAE;AAFI;AAJC,KAAF,CAAhB;AAUAL,IAAAA,gBAAgB,CAAE;AACjBjB,MAAAA,IAAI,EAAE,qBADW;AAEjBkB,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAElC,EAAE,CAAE,sBAAF,CAHE;AAIjBmC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,cADK;AAEfC,QAAAA,SAAS,EAAE;AAFI;AAJC,KAAF,CAAhB;AAUAL,IAAAA,gBAAgB,CAAE;AACjBjB,MAAAA,IAAI,EAAE,iCADW;AAEjBkB,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAElC,EAAE,CAAE,2BAAF,CAHE;AAIjBmC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,QADK;AAEfC,QAAAA,SAAS,EAAE;AAFI;AAJC,KAAF,CAAhB;AAUAL,IAAAA,gBAAgB,CAAE;AACjBjB,MAAAA,IAAI,EAAE,8CADW;AAEjBkB,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAElC,EAAE,CAAE,0CAAF,CAHE;AAIjBmC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,cADK;AAEfC,QAAAA,SAAS,EAAE;AAFI;AAJC,KAAF,CAAhB;AASA,GAlDQ,EAkDN,CAAEL,gBAAF,CAlDM,CAAT;AAoDA,SAAO,IAAP;AACA;;AAED1B,iBAAiB,CAACgC,QAAlB,GAA6BP,yBAA7B;AACA,eAAezB,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { SIDEBAR_BLOCK } from '../sidebar/constants';\nimport { STORE_NAME } from '../../store/constants';\n\nfunction KeyboardShortcuts( { openEntitiesSavedStates } ) {\n\tconst {\n\t\t__experimentalGetDirtyEntityRecords,\n\t\tisSavingEntityRecord,\n\t} = useSelect( coreStore );\n\tconst isListViewOpen = useSelect(\n\t\t( select ) => select( editSiteStore ).isListViewOpened(),\n\t\t[]\n\t);\n\tconst isBlockInspectorOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t) === SIDEBAR_BLOCK,\n\t\t[]\n\t);\n\tconst { redo, undo } = useDispatch( coreStore );\n\tconst { setIsListViewOpened } = useDispatch( editSiteStore );\n\tconst { enableComplementaryArea, disableComplementaryArea } = useDispatch(\n\t\tinterfaceStore\n\t);\n\n\tuseShortcut( 'core/edit-site/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\tconst isDirty = !! dirtyEntityRecords.length;\n\t\tconst isSaving = dirtyEntityRecords.some( ( record ) =>\n\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t);\n\n\t\tif ( ! isSaving && isDirty ) {\n\t\t\topenEntitiesSavedStates();\n\t\t}\n\t} );\n\n\tuseShortcut( 'core/edit-site/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-site/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-site/toggle-list-view', () => {\n\t\tsetIsListViewOpened( ! isListViewOpen );\n\t} );\n\n\tuseShortcut( 'core/edit-site/toggle-block-settings-sidebar', ( event ) => {\n\t\t// This shortcut has no known clashes, but use preventDefault to prevent any\n\t\t// obscure shortcuts from triggering.\n\t\tevent.preventDefault();\n\n\t\tif ( isBlockInspectorOpen ) {\n\t\t\tdisableComplementaryArea( STORE_NAME );\n\t\t} else {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );\n\t\t}\n\t} );\n\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/toggle-list-view',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the block list view.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'o',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/toggle-block-settings-sidebar',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Show or hide the block settings sidebar.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: ',',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\treturn null;\n}\n\nKeyboardShortcuts.Register = KeyboardShortcutsRegister;\nexport default KeyboardShortcuts;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/keyboard-shortcuts/index.js"],"names":["useEffect","useShortcut","store","keyboardShortcutsStore","useDispatch","useSelect","__","coreStore","interfaceStore","editSiteStore","SIDEBAR_BLOCK","STORE_NAME","KeyboardShortcuts","openEntitiesSavedStates","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","isListViewOpen","select","isListViewOpened","isBlockInspectorOpen","getActiveComplementaryArea","name","redo","undo","setIsListViewOpened","enableComplementaryArea","disableComplementaryArea","event","preventDefault","dirtyEntityRecords","isDirty","length","isSaving","some","record","kind","key","KeyboardShortcutsRegister","registerShortcut","category","description","keyCombination","modifier","character","aliases","Register"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SACCC,WADD,EAECC,KAAK,IAAIC,sBAFV,QAGO,+BAHP;AAIA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASJ,KAAK,IAAIK,SAAlB,QAAmC,sBAAnC;AACA,SAASL,KAAK,IAAIM,cAAlB,QAAwC,sBAAxC;AAEA;AACA;AACA;;AACA,SAASN,KAAK,IAAIO,aAAlB,QAAuC,aAAvC;AACA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,UAAT,QAA2B,uBAA3B;;AAEA,SAASC,iBAAT,OAA0D;AAAA,MAA9B;AAAEC,IAAAA;AAAF,GAA8B;AACzD,QAAM;AACLC,IAAAA,mCADK;AAELC,IAAAA;AAFK,MAGFV,SAAS,CAAEE,SAAF,CAHb;AAIA,QAAMS,cAAc,GAAGX,SAAS,CAC7BY,MAAF,IAAcA,MAAM,CAAER,aAAF,CAAN,CAAw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AQ,EAAE,QADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OADQ;AARQ,KAAF,CAAhB;AAeA,GAlFQ,EAkFN,CAAEL,gBAAF,CAlFM,CAAT;AAoFA,SAAO,IAAP;AACA;;AAED1B,iBAAiB,CAACiC,QAAlB,GAA6BR,yBAA7B;AACA,eAAezB,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { SIDEBAR_BLOCK } from '../sidebar/constants';\nimport { STORE_NAME } from '../../store/constants';\n\nfunction KeyboardShortcuts( { openEntitiesSavedStates } ) {\n\tconst {\n\t\t__experimentalGetDirtyEntityRecords,\n\t\tisSavingEntityRecord,\n\t} = useSelect( coreStore );\n\tconst isListViewOpen = useSelect(\n\t\t( select ) => select( editSiteStore ).isListViewOpened(),\n\t\t[]\n\t);\n\tconst isBlockInspectorOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t) === SIDEBAR_BLOCK,\n\t\t[]\n\t);\n\tconst { redo, undo } = useDispatch( coreStore );\n\tconst { setIsListViewOpened } = useDispatch( editSiteStore );\n\tconst { enableComplementaryArea, disableComplementaryArea } = useDispatch(\n\t\tinterfaceStore\n\t);\n\n\tuseShortcut( 'core/edit-site/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\tconst isDirty = !! dirtyEntityRecords.length;\n\t\tconst isSaving = dirtyEntityRecords.some( ( record ) =>\n\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t);\n\n\t\tif ( ! isSaving && isDirty ) {\n\t\t\topenEntitiesSavedStates();\n\t\t}\n\t} );\n\n\tuseShortcut( 'core/edit-site/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-site/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-site/toggle-list-view', () => {\n\t\tsetIsListViewOpened( ! isListViewOpen );\n\t} );\n\n\tuseShortcut( 'core/edit-site/toggle-block-settings-sidebar', ( event ) => {\n\t\t// This shortcut has no known clashes, but use preventDefault to prevent any\n\t\t// obscure shortcuts from triggering.\n\t\tevent.preventDefault();\n\n\t\tif ( isBlockInspectorOpen ) {\n\t\t\tdisableComplementaryArea( STORE_NAME );\n\t\t} else {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );\n\t\t}\n\t} );\n\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/toggle-list-view',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the block list view.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'o',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/toggle-block-settings-sidebar',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Show or hide the block settings sidebar.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: ',',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\treturn null;\n}\n\nKeyboardShortcuts.Register = KeyboardShortcutsRegister;\nexport default KeyboardShortcuts;\n"]}
@@ -0,0 +1,85 @@
1
+ import { createElement, Fragment } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { useDispatch } from '@wordpress/data';
7
+ import { store as coreStore } from '@wordpress/core-data';
8
+ import { __ } from '@wordpress/i18n';
9
+ import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
10
+ import { moreVertical } from '@wordpress/icons';
11
+ import { store as noticesStore } from '@wordpress/notices';
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ import { store as editSiteStore } from '../../../store';
17
+ import isTemplateRemovable from '../../../utils/is-template-removable';
18
+ import isTemplateRevertable from '../../../utils/is-template-revertable';
19
+ import RenameMenuItem from './rename-menu-item';
20
+ export default function Actions(_ref) {
21
+ let {
22
+ template
23
+ } = _ref;
24
+ const {
25
+ removeTemplate,
26
+ revertTemplate
27
+ } = useDispatch(editSiteStore);
28
+ const {
29
+ saveEditedEntityRecord
30
+ } = useDispatch(coreStore);
31
+ const {
32
+ createSuccessNotice,
33
+ createErrorNotice
34
+ } = useDispatch(noticesStore);
35
+ const isRemovable = isTemplateRemovable(template);
36
+ const isRevertable = isTemplateRevertable(template);
37
+
38
+ if (!isRemovable && !isRevertable) {
39
+ return null;
40
+ }
41
+
42
+ async function revertAndSaveTemplate() {
43
+ try {
44
+ await revertTemplate(template, {
45
+ allowUndo: false
46
+ });
47
+ await saveEditedEntityRecord('postType', template.type, template.id);
48
+ createSuccessNotice(__('Template reverted.'), {
49
+ type: 'snackbar'
50
+ });
51
+ } catch (error) {
52
+ const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while reverting the template.');
53
+ createErrorNotice(errorMessage, {
54
+ type: 'snackbar'
55
+ });
56
+ }
57
+ }
58
+
59
+ return createElement(DropdownMenu, {
60
+ icon: moreVertical,
61
+ label: __('Actions'),
62
+ className: "edit-site-list-table__actions"
63
+ }, _ref2 => {
64
+ let {
65
+ onClose
66
+ } = _ref2;
67
+ return createElement(MenuGroup, null, isRemovable && createElement(Fragment, null, createElement(RenameMenuItem, {
68
+ template: template,
69
+ onClose: onClose
70
+ }), createElement(MenuItem, {
71
+ isDestructive: true,
72
+ onClick: () => {
73
+ removeTemplate(template);
74
+ onClose();
75
+ }
76
+ }, __('Delete template'))), isRevertable && createElement(MenuItem, {
77
+ info: __('Restore template to theme default'),
78
+ onClick: () => {
79
+ revertAndSaveTemplate();
80
+ onClose();
81
+ }
82
+ }, __('Clear customizations')));
83
+ });
84
+ }
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/actions/index.js"],"names":["useDispatch","store","coreStore","__","DropdownMenu","MenuGroup","MenuItem","moreVertical","noticesStore","editSiteStore","isTemplateRemovable","isTemplateRevertable","RenameMenuItem","Actions","template","removeTemplate","revertTemplate","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","isRemovable","isRevertable","revertAndSaveTemplate","allowUndo","type","id","error","errorMessage","message","code","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,EAAuBC,SAAvB,EAAkCC,QAAlC,QAAkD,uBAAlD;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASN,KAAK,IAAIO,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,SAASP,KAAK,IAAIQ,aAAlB,QAAuC,gBAAvC;AACA,OAAOC,mBAAP,MAAgC,sCAAhC;AACA,OAAOC,oBAAP,MAAiC,uCAAjC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEA,eAAe,SAASC,OAAT,OAAiC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AAC/C,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAAqChB,WAAW,CAAES,aAAF,CAAtD;AACA,QAAM;AAAEQ,IAAAA;AAAF,MAA6BjB,WAAW,CAAEE,SAAF,CAA9C;AACA,QAAM;AAAEgB,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB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A,cAAc,CAAED,QAAF,CAAd;AACAgB,QAAAA,OAAO;AACP;AALF,OAOG3B,EAAE,CAAE,iBAAF,CAPL,CALD,CAFF,EAkBGkB,YAAY,IACb,cAAC,QAAD;AACC,MAAA,IAAI,EAAGlB,EAAE,CAAE,mCAAF,CADV;AAEC,MAAA,OAAO,EAAG,MAAM;AACfmB,QAAAA,qBAAqB;AACrBQ,QAAAA,OAAO;AACP;AALF,OAOG3B,EAAE,CAAE,sBAAF,CAPL,CAnBF,CADC;AAAA,GALH,CADD;AAwCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\nimport isTemplateRemovable from '../../../utils/is-template-removable';\nimport isTemplateRevertable from '../../../utils/is-template-revertable';\nimport RenameMenuItem from './rename-menu-item';\n\nexport default function Actions( { template } ) {\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } = useDispatch(\n\t\tnoticesStore\n\t);\n\n\tconst isRemovable = isTemplateRemovable( template );\n\tconst isRevertable = isTemplateRevertable( template );\n\n\tif ( ! isRemovable && ! isRevertable ) {\n\t\treturn null;\n\t}\n\n\tasync function revertAndSaveTemplate() {\n\t\ttry {\n\t\t\tawait revertTemplate( template, { allowUndo: false } );\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tcreateSuccessNotice( __( 'Template reverted.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while reverting the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Actions' ) }\n\t\t\tclassName=\"edit-site-list-table__actions\"\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ isRemovable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RenameMenuItem\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tremoveTemplate( template );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Delete template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isRevertable && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tinfo={ __( 'Restore template to theme default' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\trevertAndSaveTemplate();\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
@@ -0,0 +1,101 @@
1
+ import { createElement, Fragment } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { __ } from '@wordpress/i18n';
7
+ import { useState } from '@wordpress/element';
8
+ import { useDispatch, useSelect } from '@wordpress/data';
9
+ import { Button, Flex, FlexItem, MenuItem, Modal, TextControl } from '@wordpress/components';
10
+ import { store as coreStore } from '@wordpress/core-data';
11
+ import { store as noticesStore } from '@wordpress/notices';
12
+ export default function RenameMenuItem(_ref) {
13
+ let {
14
+ template,
15
+ onClose
16
+ } = _ref;
17
+ const [title, setTitle] = useState(() => template.title.rendered);
18
+ const [isModalOpen, setIsModalOpen] = useState(false);
19
+ const {
20
+ getLastEntitySaveError
21
+ } = useSelect(coreStore);
22
+ const {
23
+ editEntityRecord,
24
+ saveEditedEntityRecord
25
+ } = useDispatch(coreStore);
26
+ const {
27
+ createSuccessNotice,
28
+ createErrorNotice
29
+ } = useDispatch(noticesStore);
30
+
31
+ if (!template.is_custom) {
32
+ return null;
33
+ }
34
+
35
+ async function onTemplateRename(event) {
36
+ event.preventDefault();
37
+
38
+ try {
39
+ await editEntityRecord('postType', template.type, template.id, {
40
+ title
41
+ }); // Update state before saving rerenders the list.
42
+
43
+ setTitle('');
44
+ setIsModalOpen(false);
45
+ onClose(); // Persist edited entity.
46
+
47
+ await saveEditedEntityRecord('postType', template.type, template.id);
48
+ const lastError = getLastEntitySaveError('postType', template.type, template.id);
49
+
50
+ if (lastError) {
51
+ throw lastError;
52
+ }
53
+
54
+ createSuccessNotice(__('Template has been renamed.'), {
55
+ type: 'snackbar'
56
+ });
57
+ } catch (error) {
58
+ const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while renaming the template.');
59
+ createErrorNotice(errorMessage, {
60
+ type: 'snackbar'
61
+ });
62
+ }
63
+ }
64
+
65
+ return createElement(Fragment, null, createElement(MenuItem, {
66
+ onClick: () => {
67
+ setIsModalOpen(true);
68
+ setTitle(template.title.rendered);
69
+ }
70
+ }, __('Rename')), isModalOpen && createElement(Modal, {
71
+ title: __('Rename template'),
72
+ closeLabel: __('Close'),
73
+ onRequestClose: () => {
74
+ setIsModalOpen(false);
75
+ },
76
+ overlayClassName: "edit-site-list__rename-modal"
77
+ }, createElement("form", {
78
+ onSubmit: onTemplateRename
79
+ }, createElement(Flex, {
80
+ align: "flex-start",
81
+ gap: 8
82
+ }, createElement(FlexItem, null, createElement(TextControl, {
83
+ label: __('Name'),
84
+ value: title,
85
+ onChange: setTitle,
86
+ required: true
87
+ }))), createElement(Flex, {
88
+ className: "edit-site-list__rename-modal-actions",
89
+ justify: "flex-end",
90
+ expanded: false
91
+ }, createElement(FlexItem, null, createElement(Button, {
92
+ variant: "tertiary",
93
+ onClick: () => {
94
+ setIsModalOpen(false);
95
+ }
96
+ }, __('Cancel'))), createElement(FlexItem, null, createElement(Button, {
97
+ variant: "primary",
98
+ type: "submit"
99
+ }, __('Save')))))));
100
+ }
101
+ //# sourceMappingURL=rename-menu-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/actions/rename-menu-item.js"],"names":["__","useState","useDispatch","useSelect","Button","Flex","FlexItem","MenuItem","Modal","TextControl","store","coreStore","noticesStore","RenameMenuItem","template","onClose","title","setTitle","rendered","isModalOpen","setIsModalOpen","getLastEntitySaveError","editEntityRecord","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","is_custom","onTemplateRename","event","preventDefault","type","id","lastError","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SACCC,MADD,EAECC,IAFD,EAGCC,QAHD,EAICC,QAJD,EAKCC,KALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,YAAlB,QAAsC,oBAAtC;AAEA,eAAe,SAASC,cAAT,OAAiD;AAAA,MAAxB;AAAEC,IAAAA,QAA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ACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AAJF,KAMGpB,EAAE,CAAE,QAAF,CANL,CADD,CALD,EAeC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACGA,EAAE,CAAE,MAAF,CADL,CADD,CAfD,CAZD,CARD,CAVF,CADD;AAyDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tMenuItem,\n\tModal,\n\tTextControl,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenameMenuItem( { template, onClose } ) {\n\tconst [ title, setTitle ] = useState( () => template.title.rendered );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst { getLastEntitySaveError } = useSelect( coreStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } = useDispatch(\n\t\tcoreStore\n\t);\n\tconst { createSuccessNotice, createErrorNotice } = useDispatch(\n\t\tnoticesStore\n\t);\n\n\tif ( ! template.is_custom ) {\n\t\treturn null;\n\t}\n\n\tasync function onTemplateRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\ttitle,\n\t\t\t} );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tconst lastError = getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id\n\t\t\t);\n\n\t\t\tif ( lastError ) {\n\t\t\t\tthrow lastError;\n\t\t\t}\n\n\t\t\tcreateSuccessNotice( __( 'Template has been renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetTitle( template.title.rendered );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename template' ) }\n\t\t\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename-modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onTemplateRename }>\n\t\t\t\t\t\t<Flex align=\"flex-start\" gap={ 8 }>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tclassName=\"edit-site-list__rename-modal-actions\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\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{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,166 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+ import classnames from 'classnames';
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+
11
+ import { __experimentalHStack as HStack, Icon, Tooltip } from '@wordpress/components';
12
+ import { store as coreStore } from '@wordpress/core-data';
13
+ import { useSelect } from '@wordpress/data';
14
+ import { useState } from '@wordpress/element';
15
+ import { layout as themeIcon, plugins as pluginIcon } from '@wordpress/icons';
16
+ import { __ } from '@wordpress/i18n';
17
+ const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
18
+
19
+ function CustomizedTooltip(_ref) {
20
+ let {
21
+ isCustomized,
22
+ children
23
+ } = _ref;
24
+
25
+ if (!isCustomized) {
26
+ return children;
27
+ }
28
+
29
+ return createElement(Tooltip, {
30
+ text: __('This template has been customized')
31
+ }, children);
32
+ }
33
+
34
+ function AddedByTheme(_ref2) {
35
+ var _theme$name;
36
+
37
+ let {
38
+ slug,
39
+ isCustomized
40
+ } = _ref2;
41
+ const theme = useSelect(select => select(coreStore).getTheme(slug), [slug]);
42
+ return createElement(HStack, {
43
+ alignment: "left"
44
+ }, createElement(CustomizedTooltip, {
45
+ isCustomized: isCustomized
46
+ }, createElement("div", {
47
+ className: classnames('edit-site-list-added-by__icon', {
48
+ 'is-customized': isCustomized
49
+ })
50
+ }, createElement(Icon, {
51
+ icon: themeIcon
52
+ }))), createElement("span", null, (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug));
53
+ }
54
+
55
+ function AddedByPlugin(_ref3) {
56
+ let {
57
+ slug,
58
+ isCustomized
59
+ } = _ref3;
60
+ const plugin = useSelect(select => select(coreStore).getPlugin(slug), [slug]);
61
+ return createElement(HStack, {
62
+ alignment: "left"
63
+ }, createElement(CustomizedTooltip, {
64
+ isCustomized: isCustomized
65
+ }, createElement("div", {
66
+ className: "edit-site-list-added-by__icon"
67
+ }, createElement(Icon, {
68
+ icon: pluginIcon
69
+ }))), createElement("span", null, (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug));
70
+ }
71
+
72
+ function AddedByAuthor(_ref4) {
73
+ let {
74
+ id
75
+ } = _ref4;
76
+ const user = useSelect(select => select(coreStore).getUser(id), [id]);
77
+ const [isImageLoaded, setIsImageLoaded] = useState(false);
78
+ return createElement(HStack, {
79
+ alignment: "left"
80
+ }, createElement("div", {
81
+ className: classnames('edit-site-list-added-by__avatar', {
82
+ 'is-loaded': isImageLoaded
83
+ })
84
+ }, createElement("img", {
85
+ onLoad: () => setIsImageLoaded(true),
86
+ alt: "",
87
+ src: user === null || user === void 0 ? void 0 : user.avatar_urls[48]
88
+ })), createElement("span", null, user === null || user === void 0 ? void 0 : user.nickname));
89
+ }
90
+
91
+ function AddedBySite() {
92
+ const {
93
+ name,
94
+ logoURL
95
+ } = useSelect(select => {
96
+ var _getMedia;
97
+
98
+ const {
99
+ getEntityRecord,
100
+ getMedia
101
+ } = select(coreStore);
102
+ const siteData = getEntityRecord('root', '__unstableBase');
103
+ return {
104
+ name: siteData.name,
105
+ logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
106
+ };
107
+ }, []);
108
+ const [isImageLoaded, setIsImageLoaded] = useState(false);
109
+ return createElement(HStack, {
110
+ alignment: "left"
111
+ }, createElement("div", {
112
+ className: classnames('edit-site-list-added-by__avatar', {
113
+ 'is-loaded': isImageLoaded
114
+ })
115
+ }, createElement("img", {
116
+ onLoad: () => setIsImageLoaded(true),
117
+ alt: "",
118
+ src: logoURL
119
+ })), createElement("span", null, name));
120
+ }
121
+
122
+ export default function AddedBy(_ref5) {
123
+ let {
124
+ templateType,
125
+ template
126
+ } = _ref5;
127
+
128
+ if (!template) {
129
+ return;
130
+ }
131
+
132
+ if (TEMPLATE_POST_TYPE_NAMES.includes(templateType)) {
133
+ // Template originally provided by a theme, but customized by a user.
134
+ // Templates originally didn't have the 'origin' field so identify
135
+ // older customized templates by checking for no origin and a 'theme'
136
+ // or 'custom' source.
137
+ if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
138
+ return createElement(AddedByTheme, {
139
+ slug: template.theme,
140
+ isCustomized: template.source === 'custom'
141
+ });
142
+ } // Template originally provided by a plugin, but customized by a user.
143
+
144
+
145
+ if (template.has_theme_file && template.origin === 'plugin') {
146
+ return createElement(AddedByPlugin, {
147
+ slug: template.theme,
148
+ isCustomized: template.source === 'custom'
149
+ });
150
+ } // Template was created from scratch, but has no author. Author support
151
+ // was only added to templates in WordPress 5.9. Fallback to showing the
152
+ // site logo and title.
153
+
154
+
155
+ if (!template.has_theme_file && template.source === 'custom' && !template.author) {
156
+ return createElement(AddedBySite, null);
157
+ }
158
+ } // Simply show the author for templates created from scratch that have an
159
+ // author or for any other post type.
160
+
161
+
162
+ return createElement(AddedByAuthor, {
163
+ id: template.author
164
+ });
165
+ }
166
+ //# sourceMappingURL=added-by.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["classnames","__experimentalHStack","HStack","Icon","Tooltip","store","coreStore","useSelect","useState","layout","themeIcon","plugins","pluginIcon","__","TEMPLATE_POST_TYPE_NAMES","CustomizedTooltip","isCustomized","children","AddedByTheme","slug","theme","select","getTheme","name","rendered","AddedByPlugin","plugin","getPlugin","AddedByAuthor","id","user","getUser","isImageLoaded","setIsImageLoaded","avatar_urls","nickname","AddedBySite","logoURL","getEntityRecord","getMedia","siteData","site_logo","source_url","undefined","AddedBy","templateType","template","includes","has_theme_file","origin","source","author"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,oBAAoB,IAAIC,MADzB,EAECC,IAFD,EAGCC,OAHD,QAIO,uBAJP;AAKA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,MAAM,IAAIC,SAAnB,EAA8BC,OAAO,IAAIC,UAAzC,QAA2D,kBAA3D;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,MAAMC,wBAAwB,GAAG,CAAE,aAAF,EAAiB,kBAAjB,CAAjC;;AAEA,SAASC,iBAAT,OAAyD;AAAA,MAA7B;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAA6B;;AACxD,MAAK,CAAED,YAAP,EAAsB;AACrB,WAAOC,QAAP;AACA;;AAED,SACC,cAAC,OAAD;AAAS,IAAA,IAAI,EAAGJ,EAAE,CAAE,mCAAF;AAAlB,KACGI,QADH,CADD;AAKA;;AAED,SAASC,YAAT,QAAgD;AAAA;;AAAA,MAAzB;AAAEC,IAAAA,IAAF;A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AAQ,CAACK,MAHZ,EAIE;AACD,aAAO,cAAC,WAAD,OAAP;AACA;AACD,GA5C4D,CA8C7D;AACA;;;AACA,SAAO,cAAC,aAAD;AAAe,IAAA,EAAE,EAAGL,QAAQ,CAACK;AAA7B,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\tIcon,\n\tTooltip,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { layout as themeIcon, plugins as pluginIcon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\nfunction CustomizedTooltip( { isCustomized, children } ) {\n\tif ( ! isCustomized ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<Tooltip text={ __( 'This template has been customized' ) }>\n\t\t\t{ children }\n\t\t</Tooltip>\n\t);\n}\n\nfunction AddedByTheme( { slug, isCustomized } ) {\n\tconst theme = useSelect(\n\t\t( select ) => select( coreStore ).getTheme( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__icon', {\n\t\t\t\t\t\t'is-customized': isCustomized,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ themeIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ theme?.name?.rendered || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByPlugin( { slug, isCustomized } ) {\n\tconst plugin = useSelect(\n\t\t( select ) => select( coreStore ).getPlugin( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ pluginIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ plugin?.name || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByAuthor( { id } ) {\n\tconst user = useSelect( ( select ) => select( coreStore ).getUser( id ), [\n\t\tid,\n\t] );\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tsrc={ user?.avatar_urls[ 48 ] }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span>{ user?.nickname }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedBySite() {\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\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tsrc={ logoURL }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span>{ name }</span>\n\t\t</HStack>\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/>\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/>\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 />;\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 <AddedByAuthor id={ template.author } />;\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { useSelect } from '@wordpress/data';
7
+ import { store as coreStore } from '@wordpress/core-data';
8
+ import { __experimentalHeading as Heading } from '@wordpress/components';
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+
13
+ import AddNewTemplate from '../add-new-template';
14
+ export default function Header(_ref) {
15
+ var _postType$labels;
16
+
17
+ let {
18
+ templateType
19
+ } = _ref;
20
+ const postType = useSelect(select => select(coreStore).getPostType(templateType), [templateType]);
21
+
22
+ if (!postType) {
23
+ return null;
24
+ }
25
+
26
+ return createElement("header", {
27
+ className: "edit-site-list-header"
28
+ }, createElement(Heading, {
29
+ level: 1,
30
+ className: "edit-site-list-header__title"
31
+ }, (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.name), createElement("div", {
32
+ className: "edit-site-list-header__right"
33
+ }, createElement(AddNewTemplate, {
34
+ templateType: templateType
35
+ })));
36
+ }
37
+ //# sourceMappingURL=header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/header.js"],"names":["useSelect","store","coreStore","__experimentalHeading","Heading","AddNewTemplate","Header","templateType","postType","select","getPostType","labels","name"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,qBAAqB,IAAIC,OAAlC,QAAiD,uBAAjD;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AAEA,eAAe,SAASC,MAAT,OAAoC;AAAA;;AAAA,MAAnB;AAAEC,IAAAA;AAAF,GAAmB;AAClD,QAAMC,QAAQ,GAAGR,SAAS,CACvBS,MAAF,IAAcA,MAAM,CAAEP,SAAF,CAAN,CAAoBQ,WAApB,CAAiCH,YAAjC,CADW,EAEzB,CAAEA,YAAF,CAFyB,CAA1B;;AAKA,MAAK,CAAEC,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SACC;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,cAAC,OAAD;AAAS,IAAA,KAAK,EAAG,CAAjB;AAAqB,IAAA,SAAS,EAAC;AAA/B,yBACGA,QAAQ,CAACG,MADZ,qDACG,iBAAiBC,IADpB,CADD,EAKC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,cAAD;AAAgB,IAAA,YAAY,EAAGL;AAA/B,IADD,CALD,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport AddNewTemplate from '../add-new-template';\n\nexport default function Header( { templateType } ) {\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tif ( ! postType ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<header className=\"edit-site-list-header\">\n\t\t\t<Heading level={ 1 } className=\"edit-site-list-header__title\">\n\t\t\t\t{ postType.labels?.name }\n\t\t\t</Heading>\n\n\t\t\t<div className=\"edit-site-list-header__right\">\n\t\t\t\t<AddNewTemplate templateType={ templateType } />\n\t\t\t</div>\n\t\t</header>\n\t);\n}\n"]}
@@ -0,0 +1,81 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+ import classnames from 'classnames';
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+
11
+ import { store as coreStore } from '@wordpress/core-data';
12
+ import { useSelect } from '@wordpress/data';
13
+ import { InterfaceSkeleton } from '@wordpress/interface';
14
+ import { __, sprintf } from '@wordpress/i18n';
15
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
16
+ import { EditorSnackbars } from '@wordpress/editor';
17
+ /**
18
+ * Internal dependencies
19
+ */
20
+
21
+ import useRegisterShortcuts from './use-register-shortcuts';
22
+ import Header from './header';
23
+ import NavigationSidebar from '../navigation-sidebar';
24
+ import Table from './table';
25
+ import { store as editSiteStore } from '../../store';
26
+ export default function List(_ref) {
27
+ var _postType$labels;
28
+
29
+ let {
30
+ templateType
31
+ } = _ref;
32
+ useRegisterShortcuts();
33
+ const {
34
+ previousShortcut,
35
+ nextShortcut,
36
+ isNavigationOpen
37
+ } = useSelect(select => {
38
+ return {
39
+ previousShortcut: select(keyboardShortcutsStore).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
40
+ nextShortcut: select(keyboardShortcutsStore).getAllShortcutKeyCombinations('core/edit-site/next-region'),
41
+ isNavigationOpen: select(editSiteStore).isNavigationOpened()
42
+ };
43
+ }, []);
44
+ const postType = useSelect(select => select(coreStore).getPostType(templateType), [templateType]); // `postType` could load in asynchronously. Only provide the detailed region labels if
45
+ // the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
46
+
47
+ const itemsListLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.items_list;
48
+ const detailedRegionLabels = postType ? {
49
+ header: sprintf( // translators: %s - the name of the page, 'Header' as in the header area of that page.
50
+ __('%s - Header'), itemsListLabel),
51
+ body: sprintf( // translators: %s - the name of the page, 'Content' as in the content area of that page.
52
+ __('%s - Content'), itemsListLabel)
53
+ } : undefined;
54
+ return createElement(InterfaceSkeleton, {
55
+ className: classnames('edit-site-list', {
56
+ 'is-navigation-open': isNavigationOpen
57
+ }),
58
+ labels: {
59
+ drawer: __('Navigation Sidebar'),
60
+ ...detailedRegionLabels
61
+ },
62
+ header: createElement(Header, {
63
+ templateType: templateType
64
+ }),
65
+ drawer: createElement(NavigationSidebar, {
66
+ activeTemplateType: templateType,
67
+ isDefaultOpen: true
68
+ }),
69
+ notices: createElement(EditorSnackbars, null),
70
+ content: createElement("main", {
71
+ className: "edit-site-list-main"
72
+ }, createElement(Table, {
73
+ templateType: templateType
74
+ })),
75
+ shortcuts: {
76
+ previous: previousShortcut,
77
+ next: nextShortcut
78
+ }
79
+ });
80
+ }
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["classnames","store","coreStore","useSelect","InterfaceSkeleton","__","sprintf","keyboardShortcutsStore","EditorSnackbars","useRegisterShortcuts","Header","NavigationSidebar","Table","editSiteStore","List","templateType","previousShortcut","nextShortcut","isNavigationOpen","select","getAllShortcutKeyCombinations","isNavigationOpened","postType","getPostType","itemsListLabel","labels","items_list","detailedRegionLabels","header","body","undefined","drawer","previous","next"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASL,KAAK,IAAIM,sBAAlB,QAAgD,+BAAhD;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,SAASX,KAAK,IAAIY,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,IAAT,OAAkC;AAAA;;AAAA,MAAnB;AAAEC,IAAAA;AAAF,GAAmB;AAChDN,EAAAA,oBAAoB;AAEpB,QAAM;AAAEO,IAAAA,gBAAF;AAAoBC,IAAAA,YAApB;AAAkCC,IAAAA;AAAlC,MAAuDf,SAAS,CACnEgB,MAAF,IAAc;AACb,WAAO;AACNH,MAAAA,gBAAgB,EAAEG,MAAM,CACvBZ,sBADuB,CAAN,CAEhBa,6BAFgB,CAGjB,gCAHiB,CADZ;AAMNH,MAAAA,YAAY,EAAEE,MAAM,CACnBZ,sBADmB,CAAN,CAEZa,6BAFY,CAEmB,4BAFnB,CANR;AASNF,MAAAA,gBAAgB,EAAEC,MAAM,CAAEN,aAAF,CAAN,CAAwBQ,kBAAxB;AATZ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esContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\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 NavigationSidebar from '../navigation-sidebar';\nimport Table from './table';\nimport { store as editSiteStore } from '../../store';\n\nexport default function List( { templateType } ) {\n\tuseRegisterShortcuts();\n\n\tconst { previousShortcut, nextShortcut, isNavigationOpen } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tpreviousShortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getAllShortcutKeyCombinations(\n\t\t\t\t\t'core/edit-site/previous-region'\n\t\t\t\t),\n\t\t\t\tnextShortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t\t\tisNavigationOpen: select( editSiteStore ).isNavigationOpened(),\n\t\t\t};\n\t\t},\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\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={ classnames( 'edit-site-list', {\n\t\t\t\t'is-navigation-open': isNavigationOpen,\n\t\t\t} ) }\n\t\t\tlabels={ {\n\t\t\t\tdrawer: __( 'Navigation Sidebar' ),\n\t\t\t\t...detailedRegionLabels,\n\t\t\t} }\n\t\t\theader={ <Header templateType={ templateType } /> }\n\t\t\tdrawer={\n\t\t\t\t<NavigationSidebar\n\t\t\t\t\tactiveTemplateType={ templateType }\n\t\t\t\t\tisDefaultOpen\n\t\t\t\t/>\n\t\t\t}\n\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\tcontent={\n\t\t\t\t<main className=\"edit-site-list-main\">\n\t\t\t\t\t<Table templateType={ templateType } />\n\t\t\t\t</main>\n\t\t\t}\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"]}