@wordpress/edit-site 3.0.8 → 3.0.12

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 (258) 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 +56 -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/index.js +3 -2
  70. package/build/components/template-details/index.js.map +1 -1
  71. package/build/components/template-part-converter/convert-to-template-part.js +20 -84
  72. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  73. package/build/components/welcome-guide/editor.js +58 -0
  74. package/build/components/welcome-guide/editor.js.map +1 -0
  75. package/build/components/welcome-guide/image.js +27 -0
  76. package/build/components/welcome-guide/image.js.map +1 -0
  77. package/build/components/welcome-guide/index.js +49 -0
  78. package/build/components/welcome-guide/index.js.map +1 -0
  79. package/build/components/welcome-guide/styles.js +83 -0
  80. package/build/components/welcome-guide/styles.js.map +1 -0
  81. package/build/index.js +36 -6
  82. package/build/index.js.map +1 -1
  83. package/build/plugins/index.js +4 -2
  84. package/build/plugins/index.js.map +1 -1
  85. package/build/plugins/welcome-guide-menu-item.js +39 -0
  86. package/build/plugins/welcome-guide-menu-item.js.map +1 -0
  87. package/build/store/actions.js +50 -24
  88. package/build/store/actions.js.map +1 -1
  89. package/build/store/defaults.js +4 -1
  90. package/build/store/defaults.js.map +1 -1
  91. package/build/store/selectors.js +25 -5
  92. package/build/store/selectors.js.map +1 -1
  93. package/build/utils/is-template-removable.js +21 -0
  94. package/build/utils/is-template-removable.js.map +1 -0
  95. package/build-module/components/add-new-template/index.js +36 -0
  96. package/build-module/components/add-new-template/index.js.map +1 -0
  97. package/build-module/components/add-new-template/new-template-part.js +79 -0
  98. package/build-module/components/add-new-template/new-template-part.js.map +1 -0
  99. package/build-module/components/add-new-template/new-template.js +114 -0
  100. package/build-module/components/add-new-template/new-template.js.map +1 -0
  101. package/build-module/components/block-editor/index.js +2 -1
  102. package/build-module/components/block-editor/index.js.map +1 -1
  103. package/build-module/components/create-template-part-modal/index.js +102 -0
  104. package/build-module/components/create-template-part-modal/index.js.map +1 -0
  105. package/build-module/components/editor/index.js +19 -17
  106. package/build-module/components/editor/index.js.map +1 -1
  107. package/build-module/components/global-styles/color-palette-panel.js +29 -7
  108. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  109. package/build-module/components/global-styles/global-styles-provider.js +10 -43
  110. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  111. package/build-module/components/global-styles/gradients-palette-panel.js +46 -0
  112. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -0
  113. package/build-module/components/global-styles/hooks.js +30 -28
  114. package/build-module/components/global-styles/hooks.js.map +1 -1
  115. package/build-module/components/global-styles/palette.js +12 -5
  116. package/build-module/components/global-styles/palette.js.map +1 -1
  117. package/build-module/components/global-styles/screen-background-color.js +2 -1
  118. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  119. package/build-module/components/global-styles/screen-block-list.js +7 -1
  120. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  121. package/build-module/components/global-styles/screen-color-palette.js +22 -3
  122. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  123. package/build-module/components/global-styles/screen-link-color.js +2 -1
  124. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  125. package/build-module/components/global-styles/screen-text-color.js +2 -1
  126. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  127. package/build-module/components/global-styles/screen-typography-element.js +41 -0
  128. package/build-module/components/global-styles/screen-typography-element.js.map +1 -0
  129. package/build-module/components/global-styles/screen-typography.js +70 -6
  130. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  131. package/build-module/components/global-styles/typography-panel.js +28 -8
  132. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  133. package/build-module/components/global-styles/ui.js +11 -0
  134. package/build-module/components/global-styles/ui.js.map +1 -1
  135. package/build-module/components/global-styles/use-global-styles-output.js +2 -2
  136. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  137. package/build-module/components/global-styles/utils.js +1 -1
  138. package/build-module/components/global-styles/utils.js.map +1 -1
  139. package/build-module/components/header/index.js +1 -3
  140. package/build-module/components/header/index.js.map +1 -1
  141. package/build-module/components/keyboard-shortcuts/index.js +26 -0
  142. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  143. package/build-module/components/list/actions/index.js +85 -0
  144. package/build-module/components/list/actions/index.js.map +1 -0
  145. package/build-module/components/list/actions/rename-menu-item.js +101 -0
  146. package/build-module/components/list/actions/rename-menu-item.js.map +1 -0
  147. package/build-module/components/list/added-by.js +166 -0
  148. package/build-module/components/list/added-by.js.map +1 -0
  149. package/build-module/components/list/header.js +37 -0
  150. package/build-module/components/list/header.js.map +1 -0
  151. package/build-module/components/list/index.js +81 -0
  152. package/build-module/components/list/index.js.map +1 -0
  153. package/build-module/components/list/table.js +98 -0
  154. package/build-module/components/list/table.js.map +1 -0
  155. package/build-module/components/list/use-register-shortcuts.js +41 -0
  156. package/build-module/components/list/use-register-shortcuts.js.map +1 -0
  157. package/build-module/components/navigation-sidebar/index.js +26 -10
  158. package/build-module/components/navigation-sidebar/index.js.map +1 -1
  159. package/build-module/components/navigation-sidebar/navigation-panel/index.js +41 -44
  160. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
  161. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +6 -18
  162. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  163. package/build-module/components/template-details/index.js +3 -2
  164. package/build-module/components/template-details/index.js.map +1 -1
  165. package/build-module/components/template-part-converter/convert-to-template-part.js +20 -84
  166. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  167. package/build-module/components/welcome-guide/editor.js +45 -0
  168. package/build-module/components/welcome-guide/editor.js.map +1 -0
  169. package/build-module/components/welcome-guide/image.js +19 -0
  170. package/build-module/components/welcome-guide/image.js.map +1 -0
  171. package/build-module/components/welcome-guide/index.js +35 -0
  172. package/build-module/components/welcome-guide/index.js.map +1 -0
  173. package/build-module/components/welcome-guide/styles.js +69 -0
  174. package/build-module/components/welcome-guide/styles.js.map +1 -0
  175. package/build-module/index.js +28 -3
  176. package/build-module/index.js.map +1 -1
  177. package/build-module/plugins/index.js +3 -2
  178. package/build-module/plugins/index.js.map +1 -1
  179. package/build-module/plugins/welcome-guide-menu-item.js +27 -0
  180. package/build-module/plugins/welcome-guide-menu-item.js.map +1 -0
  181. package/build-module/store/actions.js +51 -25
  182. package/build-module/store/actions.js.map +1 -1
  183. package/build-module/store/defaults.js +4 -1
  184. package/build-module/store/defaults.js.map +1 -1
  185. package/build-module/store/selectors.js +21 -3
  186. package/build-module/store/selectors.js.map +1 -1
  187. package/build-module/utils/is-template-removable.js +14 -0
  188. package/build-module/utils/is-template-removable.js.map +1 -0
  189. package/build-style/style-rtl.css +468 -33
  190. package/build-style/style.css +468 -33
  191. package/package.json +10 -8
  192. package/src/components/add-new-template/index.js +30 -0
  193. package/src/components/add-new-template/new-template-part.js +81 -0
  194. package/src/components/add-new-template/new-template.js +136 -0
  195. package/src/components/add-new-template/style.scss +11 -0
  196. package/src/components/block-editor/index.js +2 -0
  197. package/src/components/create-template-part-modal/index.js +132 -0
  198. package/src/components/{template-part-converter → create-template-part-modal}/style.scss +9 -9
  199. package/src/components/editor/index.js +22 -15
  200. package/src/components/editor/style.scss +8 -0
  201. package/src/components/global-styles/color-palette-panel.js +64 -7
  202. package/src/components/global-styles/global-styles-provider.js +7 -36
  203. package/src/components/global-styles/gradients-palette-panel.js +79 -0
  204. package/src/components/global-styles/hooks.js +59 -27
  205. package/src/components/global-styles/palette.js +30 -10
  206. package/src/components/global-styles/screen-background-color.js +1 -0
  207. package/src/components/global-styles/screen-block-list.js +11 -1
  208. package/src/components/global-styles/screen-color-palette.js +30 -3
  209. package/src/components/global-styles/screen-link-color.js +1 -0
  210. package/src/components/global-styles/screen-text-color.js +1 -0
  211. package/src/components/global-styles/screen-typography-element.js +39 -0
  212. package/src/components/global-styles/screen-typography.js +84 -3
  213. package/src/components/global-styles/style.scss +33 -0
  214. package/src/components/global-styles/test/use-global-styles-output.js +3 -3
  215. package/src/components/global-styles/test/utils.js +1 -1
  216. package/src/components/global-styles/typography-panel.js +37 -7
  217. package/src/components/global-styles/ui.js +9 -0
  218. package/src/components/global-styles/use-global-styles-output.js +2 -2
  219. package/src/components/global-styles/utils.js +1 -1
  220. package/src/components/header/index.js +0 -6
  221. package/src/components/keyboard-shortcuts/index.js +32 -0
  222. package/src/components/list/actions/index.js +95 -0
  223. package/src/components/list/actions/rename-menu-item.js +134 -0
  224. package/src/components/list/added-by.js +179 -0
  225. package/src/components/list/header.js +34 -0
  226. package/src/components/list/index.js +96 -0
  227. package/src/components/list/style.scss +208 -0
  228. package/src/components/list/table.js +121 -0
  229. package/src/components/list/use-register-shortcuts.js +45 -0
  230. package/src/components/navigation-sidebar/index.js +24 -8
  231. package/src/components/navigation-sidebar/navigation-panel/index.js +57 -51
  232. package/src/components/navigation-sidebar/navigation-panel/style.scss +4 -2
  233. package/src/components/navigation-sidebar/navigation-toggle/index.js +24 -36
  234. package/src/components/navigation-sidebar/navigation-toggle/test/index.js +2 -0
  235. package/src/components/sidebar/style.scss +2 -1
  236. package/src/components/template-details/index.js +3 -2
  237. package/src/components/template-part-converter/convert-to-template-part.js +20 -140
  238. package/src/components/welcome-guide/editor.js +63 -0
  239. package/src/components/welcome-guide/image.js +11 -0
  240. package/src/components/welcome-guide/index.js +33 -0
  241. package/src/components/welcome-guide/style.scss +37 -0
  242. package/src/components/welcome-guide/styles.js +116 -0
  243. package/src/index.js +31 -3
  244. package/src/plugins/index.js +3 -1
  245. package/src/plugins/welcome-guide-menu-item.js +35 -0
  246. package/src/store/actions.js +85 -35
  247. package/src/store/defaults.js +4 -1
  248. package/src/store/selectors.js +22 -4
  249. package/src/store/test/actions.js +0 -30
  250. package/src/store/test/selectors.js +24 -0
  251. package/src/style.scss +9 -6
  252. package/src/utils/is-template-removable.js +13 -0
  253. package/build/components/header/navigation-link/index.js +0 -87
  254. package/build/components/header/navigation-link/index.js.map +0 -1
  255. package/build-module/components/header/navigation-link/index.js +0 -74
  256. package/build-module/components/header/navigation-link/index.js.map +0 -1
  257. package/src/components/header/navigation-link/index.js +0 -71
  258. package/src/components/header/navigation-link/style.scss +0 -69
@@ -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,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;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,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;AAAQH,IAAAA;AAAR,GAAyB;AAC/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AAO,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,KAAP;AAWA,GAboE,EAcrE,EAd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 '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"]}
@@ -0,0 +1,98 @@
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 { __, sprintf } from '@wordpress/i18n';
9
+ import { VisuallyHidden, __experimentalHeading as Heading } from '@wordpress/components';
10
+ import { addQueryArgs } from '@wordpress/url';
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+
15
+ import Actions from './actions';
16
+ import AddedBy from './added-by';
17
+ export default function Table(_ref) {
18
+ let {
19
+ templateType
20
+ } = _ref;
21
+ const {
22
+ templates,
23
+ isLoading,
24
+ postType
25
+ } = useSelect(select => {
26
+ const {
27
+ getEntityRecords,
28
+ hasFinishedResolution,
29
+ getPostType
30
+ } = select(coreStore);
31
+ return {
32
+ templates: getEntityRecords('postType', templateType, {
33
+ per_page: -1
34
+ }),
35
+ isLoading: !hasFinishedResolution('getEntityRecords', ['postType', templateType, {
36
+ per_page: -1
37
+ }]),
38
+ postType: getPostType(templateType)
39
+ };
40
+ }, [templateType]);
41
+
42
+ if (!templates || isLoading) {
43
+ return null;
44
+ }
45
+
46
+ if (!templates.length) {
47
+ var _postType$labels, _postType$labels$name;
48
+
49
+ return createElement("div", null, sprintf( // translators: The template type name, should be either "templates" or "template parts".
50
+ __('No %s found.'), postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : (_postType$labels$name = _postType$labels.name) === null || _postType$labels$name === void 0 ? void 0 : _postType$labels$name.toLowerCase()));
51
+ }
52
+
53
+ return (// These explicit aria roles are needed for Safari.
54
+ // See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
55
+ createElement("table", {
56
+ className: "edit-site-list-table",
57
+ role: "table"
58
+ }, createElement("thead", null, createElement("tr", {
59
+ className: "edit-site-list-table-head",
60
+ role: "row"
61
+ }, createElement("th", {
62
+ className: "edit-site-list-table-column",
63
+ role: "columnheader"
64
+ }, __('Template')), createElement("th", {
65
+ className: "edit-site-list-table-column",
66
+ role: "columnheader"
67
+ }, __('Added by')), createElement("th", {
68
+ className: "edit-site-list-table-column",
69
+ role: "columnheader"
70
+ }, createElement(VisuallyHidden, null, __('Actions'))))), createElement("tbody", null, templates.map(template => createElement("tr", {
71
+ key: template.id,
72
+ className: "edit-site-list-table-row",
73
+ role: "row"
74
+ }, createElement("td", {
75
+ className: "edit-site-list-table-column",
76
+ role: "cell"
77
+ }, createElement(Heading, {
78
+ level: 4
79
+ }, createElement("a", {
80
+ href: addQueryArgs(window.location.href, {
81
+ postId: template.id,
82
+ postType: template.type
83
+ })
84
+ }, template.title.rendered)), template.description), createElement("td", {
85
+ className: "edit-site-list-table-column",
86
+ role: "cell"
87
+ }, createElement(AddedBy, {
88
+ templateType: templateType,
89
+ template: template
90
+ })), createElement("td", {
91
+ className: "edit-site-list-table-column",
92
+ role: "cell"
93
+ }, createElement(Actions, {
94
+ template: template
95
+ }))))))
96
+ );
97
+ }
98
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["useSelect","store","coreStore","__","sprintf","VisuallyHidden","__experimentalHeading","Heading","addQueryArgs","Actions","AddedBy","Table","templateType","templates","isLoading","postType","select","getEntityRecords","hasFinishedResolution","getPostType","per_page","length","labels","name","toLowerCase","map","template","id","window","location","href","postId","type","title","rendered","description"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,cADD,EAECC,qBAAqB,IAAIC,OAF1B,QAGO,uBAHP;AAIA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,OAAP,MAAoB,YAApB;AAEA,eAAe,SAASC,KAAT,OAAmC;AAAA,MAAnB;AAAEC,IAAAA;AAAF,GAAmB;AACjD,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,SAAb;AAAwBC,IAAAA;AAAxB,MAAqCf,SAAS,CACjDgB,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,gBADK;AAELC,MAAAA,qBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEd,SAAF,CAJV;AAMA,WAAO;AACNW,MAAAA,SAAS,EAAEI,gBAAgB,CAAE,UAAF,EAAcL,YAAd,EAA4B;AACtDQ,QAAAA,QAAQ,EAAE,CAAC;AAD2C,OAA5B,CADrB;AAINN,MAAAA,SAAS,EAAE,CAAEI,qBAAqB,CAAE,kBAAF,EAAsB,CACvD,UADuD,EAEvDN,YAFuD,EAGvD;AAAEQ,QAAAA,QAAQ,EAAE,CAAC;AAAb,OAHuD,CAAtB,CAJ5B;AASNL,MAAAA,QAAQ,EAAEI,WAAW,CAA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BC,IAAlB,EAAwB;AAC1CC,QAAAA,MAAM,EAAEL,QAAQ,CAACC,EADyB;AAE1CZ,QAAAA,QAAQ,EAAEW,QAAQ,CAACM;AAFuB,OAAxB;AADpB,OAMGN,QAAQ,CAACO,KAAT,CAAeC,QANlB,CADD,CADD,EAWGR,QAAQ,CAACS,WAXZ,CALD,EAmBC;AAAI,MAAA,SAAS,EAAC,6BAAd;AAA4C,MAAA,IAAI,EAAC;AAAjD,OACC,cAAC,OAAD;AACC,MAAA,YAAY,EAAGvB,YADhB;AAEC,MAAA,QAAQ,EAAGc;AAFZ,MADD,CAnBD,EAyBC;AAAI,MAAA,SAAS,EAAC,6BAAd;AAA4C,MAAA,IAAI,EAAC;AAAjD,OACC,cAAC,OAAD;AAAS,MAAA,QAAQ,EAAGA;AAApB,MADD,CAzBD,CADC,CADH,CAxBD;AAHD;AA8DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tVisuallyHidden,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport Actions from './actions';\nimport AddedBy from './added-by';\n\nexport default function Table( { templateType } ) {\n\tconst { templates, isLoading, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEntityRecords,\n\t\t\t\thasFinishedResolution,\n\t\t\t\tgetPostType,\n\t\t\t} = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\ttemplates: getEntityRecords( 'postType', templateType, {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} ),\n\t\t\t\tisLoading: ! hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\t{ per_page: -1 },\n\t\t\t\t] ),\n\t\t\t\tpostType: getPostType( templateType ),\n\t\t\t};\n\t\t},\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\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{ templates.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<a\n\t\t\t\t\t\t\t\t\thref={ addQueryArgs( window.location.href, {\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{ template.title.rendered }\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t{ 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"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useDispatch } from '@wordpress/data';
5
+ import { useEffect } from '@wordpress/element';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
8
+ export default function useRegisterShortcuts() {
9
+ const {
10
+ registerShortcut
11
+ } = useDispatch(keyboardShortcutsStore);
12
+ useEffect(() => {
13
+ registerShortcut({
14
+ name: 'core/edit-site/next-region',
15
+ category: 'global',
16
+ description: __('Navigate to the next part of the editor.'),
17
+ keyCombination: {
18
+ modifier: 'ctrl',
19
+ character: '`'
20
+ },
21
+ aliases: [{
22
+ modifier: 'access',
23
+ character: 'n'
24
+ }]
25
+ });
26
+ registerShortcut({
27
+ name: 'core/edit-site/previous-region',
28
+ category: 'global',
29
+ description: __('Navigate to the previous part of the editor.'),
30
+ keyCombination: {
31
+ modifier: 'ctrlShift',
32
+ character: '`'
33
+ },
34
+ aliases: [{
35
+ modifier: 'access',
36
+ character: 'p'
37
+ }]
38
+ });
39
+ }, []);
40
+ }
41
+ //# sourceMappingURL=use-register-shortcuts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/use-register-shortcuts.js"],"names":["useDispatch","useEffect","__","store","keyboardShortcutsStore","useRegisterShortcuts","registerShortcut","name","category","description","keyCombination","modifier","character","aliases"],"mappings":"AAAA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,iBAA5B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,sBAAlB,QAAgD,+BAAhD;AAEA,eAAe,SAASC,oBAAT,GAAgC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAAuBN,WAAW,CAAEI,sBAAF,CAAxC;AACAH,EAAAA,SAAS,CAAE,MAAM;AAChBK,IAAAA,gBAAgB,CAAE;AACjBC,MAAAA,IAAI,EAAE,4BADW;AAEjBC,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAEP,EAAE,CAAE,0CAAF,CAHE;AAIjBQ,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,MADK;AAEfC,QAAAA,SAAS,EAAE;AAFI,OAJC;AAQjBC,MAAAA,OAAO,EAAE,CACR;AACCF,QAAAA,QAAQ,EAAE,QADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OADQ;AARQ,KAAF,CAAhB;AAgBAN,IAAAA,gBAAgB,CAAE;AACjBC,MAAAA,IAAI,EAAE,gCADW;AAEjBC,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAEP,EAAE,CAAE,8CAAF,CAHE;AAIjBQ,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,WADK;AAEfC,QAAAA,SAAS,EAAE;AAFI,OAJC;AAQjBC,MAAAA,OAAO,EAAE,CACR;AACCF,QAAAA,QAAQ,EAAE,QADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OADQ;AARQ,KAAF,CAAhB;AAeA,GAhCQ,EAgCN,EAhCM,CAAT;AAiCA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\nexport default function useRegisterShortcuts() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\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}, [] );\n}\n"]}