@wordpress/edit-site 5.25.0 → 5.25.1-next.79a6196f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (438) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/components/block-editor/back-button.js +3 -2
  3. package/build/components/block-editor/back-button.js.map +1 -1
  4. package/build/components/block-editor/resizable-editor.js +2 -2
  5. package/build/components/block-editor/resizable-editor.js.map +1 -1
  6. package/build/components/block-editor/use-post-link-props.js +27 -0
  7. package/build/components/block-editor/use-post-link-props.js.map +1 -0
  8. package/build/components/block-editor/use-site-editor-settings.js +7 -24
  9. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  10. package/build/components/create-template-part-modal/index.js +15 -7
  11. package/build/components/create-template-part-modal/index.js.map +1 -1
  12. package/build/components/editor/index.js +15 -16
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/editor-canvas-container/index.js +9 -7
  15. package/build/components/editor-canvas-container/index.js.map +1 -1
  16. package/build/components/global-styles/font-library-modal/collection-font-variant.js +5 -2
  17. package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
  18. package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js +3 -3
  19. package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +1 -1
  20. package/build/components/global-styles/font-library-modal/context.js +5 -5
  21. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  22. package/build/components/global-styles/font-library-modal/font-collection.js +8 -4
  23. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  24. package/build/components/global-styles/font-library-modal/index.js +38 -21
  25. package/build/components/global-styles/font-library-modal/index.js.map +1 -1
  26. package/build/components/global-styles/font-library-modal/installed-fonts.js +2 -2
  27. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  28. package/build/components/global-styles/font-library-modal/library-font-variant.js +5 -2
  29. package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  30. package/build/components/global-styles/font-library-modal/local-fonts.js +26 -10
  31. package/build/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
  32. package/build/components/global-styles/font-library-modal/resolvers.js +6 -6
  33. package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  34. package/build/components/global-styles/font-library-modal/{tab-layout.js → tab-panel-layout.js} +4 -4
  35. package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -0
  36. package/build/components/global-styles/font-library-modal/utils/index.js +35 -38
  37. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  38. package/build/components/global-styles/preview.js +43 -1
  39. package/build/components/global-styles/preview.js.map +1 -1
  40. package/build/components/global-styles/screen-color-palette.js +16 -12
  41. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  42. package/build/components/global-styles/screen-revisions/index.js +52 -52
  43. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  44. package/build/components/global-styles/screen-revisions/revisions-buttons.js +26 -35
  45. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  46. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +40 -22
  47. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  48. package/build/components/global-styles/ui.js +13 -62
  49. package/build/components/global-styles/ui.js.map +1 -1
  50. package/build/components/header-edit-mode/document-tools/index.js +8 -106
  51. package/build/components/header-edit-mode/document-tools/index.js.map +1 -1
  52. package/build/components/header-edit-mode/index.js +7 -11
  53. package/build/components/header-edit-mode/index.js.map +1 -1
  54. package/build/components/header-edit-mode/mode-switcher/index.js +0 -2
  55. package/build/components/header-edit-mode/mode-switcher/index.js.map +1 -1
  56. package/build/components/header-edit-mode/more-menu/index.js +10 -7
  57. package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
  58. package/build/components/keyboard-shortcuts/edit-mode.js +0 -23
  59. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  60. package/build/components/keyboard-shortcuts/register.js +0 -36
  61. package/build/components/keyboard-shortcuts/register.js.map +1 -1
  62. package/build/components/layout/index.js +6 -13
  63. package/build/components/layout/index.js.map +1 -1
  64. package/build/components/page-main/index.js +4 -4
  65. package/build/components/page-main/index.js.map +1 -1
  66. package/build/components/page-pages/index.js +84 -37
  67. package/build/components/page-pages/index.js.map +1 -1
  68. package/build/components/page-patterns/dataviews-pattern-actions.js +305 -0
  69. package/build/components/page-patterns/dataviews-pattern-actions.js.map +1 -0
  70. package/build/components/page-patterns/dataviews-patterns.js +307 -0
  71. package/build/components/page-patterns/dataviews-patterns.js.map +1 -0
  72. package/build/components/page-patterns/duplicate-menu-item.js +1 -1
  73. package/build/components/page-patterns/duplicate-menu-item.js.map +1 -1
  74. package/build/components/page-patterns/grid-item.js +4 -3
  75. package/build/components/page-patterns/grid-item.js.map +1 -1
  76. package/build/components/page-patterns/patterns-list.js +2 -1
  77. package/build/components/page-patterns/patterns-list.js.map +1 -1
  78. package/build/components/page-patterns/use-patterns.js +23 -13
  79. package/build/components/page-patterns/use-patterns.js.map +1 -1
  80. package/build/components/page-templates/index.js +312 -36
  81. package/build/components/page-templates/index.js.map +1 -1
  82. package/build/components/{page-patterns/pagination.js → pagination/index.js} +25 -12
  83. package/build/components/pagination/index.js.map +1 -0
  84. package/build/components/{page-pages/side-editor.js → post-preview/index.js} +8 -4
  85. package/build/components/post-preview/index.js.map +1 -0
  86. package/build/components/preferences-modal/enable-feature.js +3 -2
  87. package/build/components/preferences-modal/enable-feature.js.map +1 -1
  88. package/build/components/preferences-modal/enable-panel-option.js +33 -0
  89. package/build/components/preferences-modal/enable-panel-option.js.map +1 -0
  90. package/build/components/preferences-modal/index.js +57 -9
  91. package/build/components/preferences-modal/index.js.map +1 -1
  92. package/build/components/revisions/index.js +3 -7
  93. package/build/components/revisions/index.js.map +1 -1
  94. package/build/components/routes/link.js +6 -2
  95. package/build/components/routes/link.js.map +1 -1
  96. package/build/components/save-button/index.js +6 -3
  97. package/build/components/save-button/index.js.map +1 -1
  98. package/build/components/sidebar/index.js +3 -11
  99. package/build/components/sidebar/index.js.map +1 -1
  100. package/build/components/sidebar-dataviews/add-new-view.js +2 -2
  101. package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
  102. package/build/components/sidebar-dataviews/default-views.js +18 -5
  103. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  104. package/build/components/sidebar-dataviews/index.js +3 -3
  105. package/build/components/sidebar-dataviews/index.js.map +1 -1
  106. package/build/components/sidebar-edit-mode/default-sidebar.js +1 -5
  107. package/build/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
  108. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +62 -10
  109. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  110. package/build/components/sidebar-edit-mode/page-panels/index.js +1 -1
  111. package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  112. package/build/components/sidebar-edit-mode/plugin-sidebar/index.js +0 -4
  113. package/build/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
  114. package/build/components/sidebar-edit-mode/template-panel/index.js +4 -13
  115. package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  116. package/build/components/sidebar-navigation-screen-details-footer/index.js +1 -1
  117. package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  118. package/build/components/sidebar-navigation-screen-global-styles/index.js +5 -2
  119. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  120. package/build/components/sidebar-navigation-screen-page/index.js +4 -1
  121. package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
  122. package/build/components/sidebar-navigation-screen-pages-dataviews/index.js +69 -0
  123. package/build/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -0
  124. package/build/components/sidebar-navigation-screen-templates/index.js +63 -8
  125. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  126. package/build/components/style-book/index.js +38 -8
  127. package/build/components/style-book/index.js.map +1 -1
  128. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
  129. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  130. package/build/hooks/commands/use-edit-mode-commands.js +11 -6
  131. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  132. package/build/index.js +12 -7
  133. package/build/index.js.map +1 -1
  134. package/build/store/actions.js +39 -44
  135. package/build/store/actions.js.map +1 -1
  136. package/build/store/private-actions.js +6 -2
  137. package/build/store/private-actions.js.map +1 -1
  138. package/build/store/reducer.js +0 -46
  139. package/build/store/reducer.js.map +1 -1
  140. package/build/store/selectors.js +32 -41
  141. package/build/store/selectors.js.map +1 -1
  142. package/build/utils/get-is-list-page.js +1 -1
  143. package/build/utils/get-is-list-page.js.map +1 -1
  144. package/build-module/components/block-editor/back-button.js +4 -3
  145. package/build-module/components/block-editor/back-button.js.map +1 -1
  146. package/build-module/components/block-editor/resizable-editor.js +2 -2
  147. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  148. package/build-module/components/block-editor/use-post-link-props.js +20 -0
  149. package/build-module/components/block-editor/use-post-link-props.js.map +1 -0
  150. package/build-module/components/block-editor/use-site-editor-settings.js +8 -25
  151. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  152. package/build-module/components/create-template-part-modal/index.js +14 -7
  153. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  154. package/build-module/components/editor/index.js +16 -17
  155. package/build-module/components/editor/index.js.map +1 -1
  156. package/build-module/components/editor-canvas-container/index.js +9 -7
  157. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  158. package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +5 -2
  159. package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
  160. package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js +3 -3
  161. package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +1 -1
  162. package/build-module/components/global-styles/font-library-modal/context.js +7 -7
  163. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  164. package/build-module/components/global-styles/font-library-modal/font-collection.js +8 -4
  165. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  166. package/build-module/components/global-styles/font-library-modal/index.js +39 -22
  167. package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
  168. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +2 -2
  169. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  170. package/build-module/components/global-styles/font-library-modal/library-font-variant.js +5 -2
  171. package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  172. package/build-module/components/global-styles/font-library-modal/local-fonts.js +27 -11
  173. package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
  174. package/build-module/components/global-styles/font-library-modal/resolvers.js +5 -5
  175. package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  176. package/build-module/components/global-styles/font-library-modal/{tab-layout.js → tab-panel-layout.js} +4 -4
  177. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -0
  178. package/build-module/components/global-styles/font-library-modal/utils/index.js +34 -36
  179. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  180. package/build-module/components/global-styles/preview.js +45 -3
  181. package/build-module/components/global-styles/preview.js.map +1 -1
  182. package/build-module/components/global-styles/screen-color-palette.js +17 -13
  183. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  184. package/build-module/components/global-styles/screen-revisions/index.js +53 -53
  185. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  186. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +27 -36
  187. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  188. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +40 -22
  189. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  190. package/build-module/components/global-styles/ui.js +15 -64
  191. package/build-module/components/global-styles/ui.js.map +1 -1
  192. package/build-module/components/header-edit-mode/document-tools/index.js +13 -110
  193. package/build-module/components/header-edit-mode/document-tools/index.js.map +1 -1
  194. package/build-module/components/header-edit-mode/index.js +7 -11
  195. package/build-module/components/header-edit-mode/index.js.map +1 -1
  196. package/build-module/components/header-edit-mode/mode-switcher/index.js +0 -2
  197. package/build-module/components/header-edit-mode/mode-switcher/index.js.map +1 -1
  198. package/build-module/components/header-edit-mode/more-menu/index.js +10 -7
  199. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
  200. package/build-module/components/keyboard-shortcuts/edit-mode.js +0 -23
  201. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  202. package/build-module/components/keyboard-shortcuts/register.js +0 -36
  203. package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
  204. package/build-module/components/layout/index.js +6 -13
  205. package/build-module/components/layout/index.js.map +1 -1
  206. package/build-module/components/page-main/index.js +4 -4
  207. package/build-module/components/page-main/index.js.map +1 -1
  208. package/build-module/components/page-pages/index.js +83 -36
  209. package/build-module/components/page-pages/index.js.map +1 -1
  210. package/build-module/components/page-patterns/dataviews-pattern-actions.js +292 -0
  211. package/build-module/components/page-patterns/dataviews-pattern-actions.js.map +1 -0
  212. package/build-module/components/page-patterns/dataviews-patterns.js +299 -0
  213. package/build-module/components/page-patterns/dataviews-patterns.js.map +1 -0
  214. package/build-module/components/page-patterns/duplicate-menu-item.js +1 -1
  215. package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -1
  216. package/build-module/components/page-patterns/grid-item.js +4 -3
  217. package/build-module/components/page-patterns/grid-item.js.map +1 -1
  218. package/build-module/components/page-patterns/patterns-list.js +2 -1
  219. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  220. package/build-module/components/page-patterns/use-patterns.js +23 -13
  221. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  222. package/build-module/components/page-templates/index.js +314 -38
  223. package/build-module/components/page-templates/index.js.map +1 -1
  224. package/build-module/components/{page-patterns/pagination.js → pagination/index.js} +24 -12
  225. package/build-module/components/pagination/index.js.map +1 -0
  226. package/build-module/components/{page-pages/side-editor.js → post-preview/index.js} +7 -3
  227. package/build-module/components/post-preview/index.js.map +1 -0
  228. package/build-module/components/preferences-modal/enable-feature.js +3 -2
  229. package/build-module/components/preferences-modal/enable-feature.js.map +1 -1
  230. package/build-module/components/preferences-modal/enable-panel-option.js +26 -0
  231. package/build-module/components/preferences-modal/enable-panel-option.js.map +1 -0
  232. package/build-module/components/preferences-modal/index.js +57 -9
  233. package/build-module/components/preferences-modal/index.js.map +1 -1
  234. package/build-module/components/revisions/index.js +4 -8
  235. package/build-module/components/revisions/index.js.map +1 -1
  236. package/build-module/components/routes/link.js +5 -2
  237. package/build-module/components/routes/link.js.map +1 -1
  238. package/build-module/components/save-button/index.js +6 -3
  239. package/build-module/components/save-button/index.js.map +1 -1
  240. package/build-module/components/sidebar/index.js +3 -11
  241. package/build-module/components/sidebar/index.js.map +1 -1
  242. package/build-module/components/sidebar-dataviews/add-new-view.js +1 -1
  243. package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
  244. package/build-module/components/sidebar-dataviews/default-views.js +17 -5
  245. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  246. package/build-module/components/sidebar-dataviews/index.js +2 -2
  247. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  248. package/build-module/components/sidebar-edit-mode/default-sidebar.js +1 -5
  249. package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
  250. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +64 -12
  251. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  252. package/build-module/components/sidebar-edit-mode/page-panels/index.js +2 -2
  253. package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  254. package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js +0 -4
  255. package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
  256. package/build-module/components/sidebar-edit-mode/template-panel/index.js +6 -15
  257. package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  258. package/build-module/components/sidebar-navigation-screen-details-footer/index.js +1 -1
  259. package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  260. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +5 -2
  261. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  262. package/build-module/components/sidebar-navigation-screen-page/index.js +4 -1
  263. package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
  264. package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js +61 -0
  265. package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -0
  266. package/build-module/components/sidebar-navigation-screen-templates/index.js +64 -9
  267. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  268. package/build-module/components/style-book/index.js +40 -10
  269. package/build-module/components/style-book/index.js.map +1 -1
  270. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
  271. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  272. package/build-module/hooks/commands/use-edit-mode-commands.js +11 -6
  273. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  274. package/build-module/index.js +12 -7
  275. package/build-module/index.js.map +1 -1
  276. package/build-module/store/actions.js +36 -41
  277. package/build-module/store/actions.js.map +1 -1
  278. package/build-module/store/private-actions.js +6 -2
  279. package/build-module/store/private-actions.js.map +1 -1
  280. package/build-module/store/reducer.js +0 -44
  281. package/build-module/store/reducer.js.map +1 -1
  282. package/build-module/store/selectors.js +30 -38
  283. package/build-module/store/selectors.js.map +1 -1
  284. package/build-module/utils/get-is-list-page.js +1 -1
  285. package/build-module/utils/get-is-list-page.js.map +1 -1
  286. package/build-style/style-rtl.css +366 -268
  287. package/build-style/style.css +366 -268
  288. package/package.json +42 -42
  289. package/src/components/add-new-template/style.scss +2 -1
  290. package/src/components/block-editor/back-button.js +4 -2
  291. package/src/components/block-editor/resizable-editor.js +1 -1
  292. package/src/components/block-editor/style.scss +1 -2
  293. package/src/components/block-editor/use-post-link-props.js +20 -0
  294. package/src/components/block-editor/use-site-editor-settings.js +10 -41
  295. package/src/components/code-editor/style.scss +0 -4
  296. package/src/components/create-template-part-modal/index.js +83 -82
  297. package/src/components/editor/index.js +24 -31
  298. package/src/components/editor-canvas-container/index.js +8 -6
  299. package/src/components/global-styles/font-library-modal/collection-font-variant.js +7 -2
  300. package/src/components/global-styles/font-library-modal/confirm-delete-dialog.js +3 -3
  301. package/src/components/global-styles/font-library-modal/context.js +7 -7
  302. package/src/components/global-styles/font-library-modal/font-collection.js +10 -5
  303. package/src/components/global-styles/font-library-modal/index.js +44 -24
  304. package/src/components/global-styles/font-library-modal/installed-fonts.js +3 -3
  305. package/src/components/global-styles/font-library-modal/library-font-variant.js +7 -2
  306. package/src/components/global-styles/font-library-modal/local-fonts.js +53 -26
  307. package/src/components/global-styles/font-library-modal/resolvers.js +5 -5
  308. package/src/components/global-styles/font-library-modal/style.scss +5 -2
  309. package/src/components/global-styles/font-library-modal/{tab-layout.js → tab-panel-layout.js} +9 -3
  310. package/src/components/global-styles/font-library-modal/utils/index.js +21 -23
  311. package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamily.spec.js +58 -0
  312. package/src/components/global-styles/preview.js +55 -3
  313. package/src/components/global-styles/screen-color-palette.js +16 -26
  314. package/src/components/global-styles/screen-revisions/index.js +91 -92
  315. package/src/components/global-styles/screen-revisions/revisions-buttons.js +37 -38
  316. package/src/components/global-styles/screen-revisions/style.scss +77 -20
  317. package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +67 -0
  318. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +73 -46
  319. package/src/components/global-styles/ui.js +13 -74
  320. package/src/components/header-edit-mode/document-tools/index.js +33 -165
  321. package/src/components/header-edit-mode/index.js +6 -17
  322. package/src/components/header-edit-mode/mode-switcher/index.js +0 -4
  323. package/src/components/header-edit-mode/more-menu/index.js +9 -7
  324. package/src/components/header-edit-mode/style.scss +0 -47
  325. package/src/components/keyboard-shortcuts/edit-mode.js +1 -26
  326. package/src/components/keyboard-shortcuts/register.js +0 -43
  327. package/src/components/layout/index.js +8 -27
  328. package/src/components/layout/style.scss +10 -3
  329. package/src/components/list/style.scss +0 -5
  330. package/src/components/page/style.scss +1 -1
  331. package/src/components/page-main/index.js +8 -8
  332. package/src/components/page-pages/index.js +112 -41
  333. package/src/components/page-pages/style.scss +3 -2
  334. package/src/components/page-patterns/dataviews-pattern-actions.js +329 -0
  335. package/src/components/page-patterns/dataviews-patterns.js +380 -0
  336. package/src/components/page-patterns/duplicate-menu-item.js +1 -1
  337. package/src/components/page-patterns/grid-item.js +3 -2
  338. package/src/components/page-patterns/patterns-list.js +2 -1
  339. package/src/components/page-patterns/style.scss +89 -26
  340. package/src/components/page-patterns/use-patterns.js +24 -15
  341. package/src/components/page-templates/index.js +399 -64
  342. package/src/components/{page-patterns/pagination.js → pagination/index.js} +21 -10
  343. package/src/components/pagination/style.scss +5 -0
  344. package/src/components/post-preview/index.js +16 -0
  345. package/src/components/preferences-modal/enable-feature.js +9 -5
  346. package/src/components/preferences-modal/enable-panel-option.js +23 -0
  347. package/src/components/preferences-modal/index.js +107 -22
  348. package/src/components/revisions/index.js +8 -15
  349. package/src/components/routes/link.js +11 -3
  350. package/src/components/save-button/index.js +16 -3
  351. package/src/components/sidebar/index.js +6 -13
  352. package/src/components/sidebar-dataviews/add-new-view.js +1 -1
  353. package/src/components/sidebar-dataviews/default-views.js +23 -6
  354. package/src/components/sidebar-dataviews/index.js +2 -2
  355. package/src/components/sidebar-edit-mode/default-sidebar.js +0 -12
  356. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +85 -14
  357. package/src/components/sidebar-edit-mode/page-panels/index.js +15 -1
  358. package/src/components/sidebar-edit-mode/plugin-sidebar/index.js +0 -12
  359. package/src/components/sidebar-edit-mode/style.scss +0 -10
  360. package/src/components/sidebar-edit-mode/template-panel/index.js +44 -40
  361. package/src/components/sidebar-edit-mode/template-panel/style.scss +0 -4
  362. package/src/components/sidebar-navigation-screen-details-footer/index.js +1 -1
  363. package/src/components/sidebar-navigation-screen-global-styles/index.js +3 -2
  364. package/src/components/sidebar-navigation-screen-page/index.js +2 -1
  365. package/src/components/sidebar-navigation-screen-pages-dataviews/index.js +77 -0
  366. package/src/components/sidebar-navigation-screen-templates/index.js +85 -28
  367. package/src/components/sidebar-navigation-screen-templates/style.scss +9 -0
  368. package/src/components/site-hub/style.scss +5 -2
  369. package/src/components/style-book/index.js +65 -21
  370. package/src/components/style-book/style.scss +3 -3
  371. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +4 -1
  372. package/src/hooks/commands/use-edit-mode-commands.js +8 -12
  373. package/src/index.js +11 -5
  374. package/src/store/actions.js +35 -45
  375. package/src/store/private-actions.js +7 -3
  376. package/src/store/reducer.js +0 -44
  377. package/src/store/selectors.js +32 -38
  378. package/src/store/test/actions.js +11 -39
  379. package/src/store/test/reducer.js +1 -82
  380. package/src/store/test/selectors.js +0 -24
  381. package/src/style.scss +2 -1
  382. package/src/utils/get-is-list-page.js +2 -3
  383. package/build/components/global-styles/font-library-modal/tab-layout.js.map +0 -1
  384. package/build/components/global-styles/screen-revisions/get-revision-changes.js +0 -146
  385. package/build/components/global-styles/screen-revisions/get-revision-changes.js.map +0 -1
  386. package/build/components/header-edit-mode/undo-redo/redo.js +0 -41
  387. package/build/components/header-edit-mode/undo-redo/redo.js.map +0 -1
  388. package/build/components/header-edit-mode/undo-redo/undo.js +0 -40
  389. package/build/components/header-edit-mode/undo-redo/undo.js.map +0 -1
  390. package/build/components/page-pages/side-editor.js.map +0 -1
  391. package/build/components/page-patterns/pagination.js.map +0 -1
  392. package/build/components/page-templates/dataviews-templates.js +0 -317
  393. package/build/components/page-templates/dataviews-templates.js.map +0 -1
  394. package/build/components/secondary-sidebar/inserter-sidebar.js +0 -60
  395. package/build/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
  396. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -109
  397. package/build/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
  398. package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js +0 -35
  399. package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +0 -1
  400. package/build/components/sidebar-edit-mode/template-panel/last-revision.js +0 -73
  401. package/build/components/sidebar-edit-mode/template-panel/last-revision.js.map +0 -1
  402. package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js +0 -219
  403. package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +0 -1
  404. package/build-module/components/global-styles/font-library-modal/tab-layout.js.map +0 -1
  405. package/build-module/components/global-styles/screen-revisions/get-revision-changes.js +0 -139
  406. package/build-module/components/global-styles/screen-revisions/get-revision-changes.js.map +0 -1
  407. package/build-module/components/header-edit-mode/undo-redo/redo.js +0 -33
  408. package/build-module/components/header-edit-mode/undo-redo/redo.js.map +0 -1
  409. package/build-module/components/header-edit-mode/undo-redo/undo.js +0 -32
  410. package/build-module/components/header-edit-mode/undo-redo/undo.js.map +0 -1
  411. package/build-module/components/page-pages/side-editor.js.map +0 -1
  412. package/build-module/components/page-patterns/pagination.js.map +0 -1
  413. package/build-module/components/page-templates/dataviews-templates.js +0 -309
  414. package/build-module/components/page-templates/dataviews-templates.js.map +0 -1
  415. package/build-module/components/secondary-sidebar/inserter-sidebar.js +0 -53
  416. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
  417. package/build-module/components/secondary-sidebar/list-view-sidebar.js +0 -102
  418. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
  419. package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js +0 -27
  420. package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +0 -1
  421. package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js +0 -65
  422. package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js.map +0 -1
  423. package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js +0 -209
  424. package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +0 -1
  425. package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamilies.spec.js +0 -62
  426. package/src/components/global-styles/font-library-modal/utils/test/wpKebabCase.spec.js +0 -28
  427. package/src/components/global-styles/screen-revisions/get-revision-changes.js +0 -171
  428. package/src/components/global-styles/screen-revisions/test/get-revision-changes.js +0 -191
  429. package/src/components/header-edit-mode/undo-redo/redo.js +0 -38
  430. package/src/components/header-edit-mode/undo-redo/undo.js +0 -34
  431. package/src/components/page-pages/side-editor.js +0 -14
  432. package/src/components/page-templates/dataviews-templates.js +0 -360
  433. package/src/components/secondary-sidebar/inserter-sidebar.js +0 -66
  434. package/src/components/secondary-sidebar/list-view-sidebar.js +0 -123
  435. package/src/components/secondary-sidebar/style.scss +0 -65
  436. package/src/components/sidebar-edit-mode/sidebar-fixed-bottom.js +0 -26
  437. package/src/components/sidebar-edit-mode/template-panel/last-revision.js +0 -82
  438. package/src/components/sidebar-edit-mode/template-panel/pattern-categories.js +0 -279
@@ -1,53 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { useSelect, useDispatch } from '@wordpress/data';
6
- import { Button, VisuallyHidden } from '@wordpress/components';
7
- import { __experimentalLibrary as Library } from '@wordpress/block-editor';
8
- import { close } from '@wordpress/icons';
9
- import { useViewportMatch, __experimentalUseDialog as useDialog } from '@wordpress/compose';
10
- import { __ } from '@wordpress/i18n';
11
- import { useEffect, useRef } from '@wordpress/element';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { store as editSiteStore } from '../../store';
17
- export default function InserterSidebar() {
18
- const {
19
- setIsInserterOpened
20
- } = useDispatch(editSiteStore);
21
- const insertionPoint = useSelect(select => select(editSiteStore).__experimentalGetInsertionPoint(), []);
22
- const isMobile = useViewportMatch('medium', '<');
23
- const TagName = !isMobile ? VisuallyHidden : 'div';
24
- const [inserterDialogRef, inserterDialogProps] = useDialog({
25
- onClose: () => setIsInserterOpened(false),
26
- focusOnMount: null
27
- });
28
- const libraryRef = useRef();
29
- useEffect(() => {
30
- libraryRef.current.focusSearch();
31
- }, []);
32
- return createElement("div", {
33
- ref: inserterDialogRef,
34
- ...inserterDialogProps,
35
- className: "edit-site-editor__inserter-panel"
36
- }, createElement(TagName, {
37
- className: "edit-site-editor__inserter-panel-header"
38
- }, createElement(Button, {
39
- icon: close,
40
- label: __('Close block inserter'),
41
- onClick: () => setIsInserterOpened(false)
42
- })), createElement("div", {
43
- className: "edit-site-editor__inserter-panel-content"
44
- }, createElement(Library, {
45
- showInserterHelpPanel: true,
46
- shouldFocusBlock: isMobile,
47
- rootClientId: insertionPoint.rootClientId,
48
- __experimentalInsertionIndex: insertionPoint.insertionIndex,
49
- __experimentalFilterValue: insertionPoint.filterValue,
50
- ref: libraryRef
51
- })));
52
- }
53
- //# sourceMappingURL=inserter-sidebar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useSelect","useDispatch","Button","VisuallyHidden","__experimentalLibrary","Library","close","useViewportMatch","__experimentalUseDialog","useDialog","__","useEffect","useRef","store","editSiteStore","InserterSidebar","setIsInserterOpened","insertionPoint","select","__experimentalGetInsertionPoint","isMobile","TagName","inserterDialogRef","inserterDialogProps","onClose","focusOnMount","libraryRef","current","focusSearch","createElement","ref","className","icon","label","onClick","showInserterHelpPanel","shouldFocusBlock","rootClientId","__experimentalInsertionIndex","insertionIndex","__experimentalFilterValue","filterValue"],"sources":["@wordpress/edit-site/src/components/secondary-sidebar/inserter-sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport { close } from '@wordpress/icons';\nimport {\n\tuseViewportMatch,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function InserterSidebar() {\n\tconst { setIsInserterOpened } = useDispatch( editSiteStore );\n\tconst insertionPoint = useSelect(\n\t\t( select ) => select( editSiteStore ).__experimentalGetInsertionPoint(),\n\t\t[]\n\t);\n\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst TagName = ! isMobile ? VisuallyHidden : 'div';\n\tconst [ inserterDialogRef, inserterDialogProps ] = useDialog( {\n\t\tonClose: () => setIsInserterOpened( false ),\n\t\tfocusOnMount: null,\n\t} );\n\n\tconst libraryRef = useRef();\n\tuseEffect( () => {\n\t\tlibraryRef.current.focusSearch();\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ inserterDialogRef }\n\t\t\t{ ...inserterDialogProps }\n\t\t\tclassName=\"edit-site-editor__inserter-panel\"\n\t\t>\n\t\t\t<TagName className=\"edit-site-editor__inserter-panel-header\">\n\t\t\t\t<Button\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Close block inserter' ) }\n\t\t\t\t\tonClick={ () => setIsInserterOpened( false ) }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t\t<div className=\"edit-site-editor__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tshouldFocusBlock={ isMobile }\n\t\t\t\t\trootClientId={ insertionPoint.rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\tinsertionPoint.insertionIndex\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFilterValue={ insertionPoint.filterValue }\n\t\t\t\t\tref={ libraryRef }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,MAAM,EAAEC,cAAc,QAAQ,uBAAuB;AAC9D,SAASC,qBAAqB,IAAIC,OAAO,QAAQ,yBAAyB;AA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G,CAC9C,CACO,CAAC,EACVa,aAAA;IAAKE,SAAS,EAAC;EAA0C,GACxDF,aAAA,CAACxB,OAAO;IACP8B,qBAAqB;IACrBC,gBAAgB,EAAGhB,QAAU;IAC7BiB,YAAY,EAAGpB,cAAc,CAACoB,YAAc;IAC5CC,4BAA4B,EAC3BrB,cAAc,CAACsB,cACf;IACDC,yBAAyB,EAAGvB,cAAc,CAACwB,WAAa;IACxDX,GAAG,EAAGJ;EAAY,CAClB,CACG,CACD,CAAC;AAER"}
@@ -1,102 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
6
- import { Button } from '@wordpress/components';
7
- import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
8
- import { useDispatch } from '@wordpress/data';
9
- import { useCallback, useRef, useState } from '@wordpress/element';
10
- import { __ } from '@wordpress/i18n';
11
- import { closeSmall } from '@wordpress/icons';
12
- import { ESCAPE } from '@wordpress/keycodes';
13
- import { focus } from '@wordpress/dom';
14
- import { useShortcut } from '@wordpress/keyboard-shortcuts';
15
-
16
- /**
17
- * Internal dependencies
18
- */
19
- import { store as editSiteStore } from '../../store';
20
- import { unlock } from '../../lock-unlock';
21
- const {
22
- PrivateListView
23
- } = unlock(blockEditorPrivateApis);
24
- export default function ListViewSidebar({
25
- listViewToggleElement
26
- }) {
27
- const {
28
- setIsListViewOpened
29
- } = useDispatch(editSiteStore);
30
-
31
- // This hook handles focus when the sidebar first renders.
32
- const focusOnMountRef = useFocusOnMount('firstElement');
33
-
34
- // When closing the list view, focus should return to the toggle button.
35
- const closeListView = useCallback(() => {
36
- setIsListViewOpened(false);
37
- listViewToggleElement?.focus();
38
- }, [listViewToggleElement, setIsListViewOpened]);
39
- const closeOnEscape = useCallback(event => {
40
- if (event.keyCode === ESCAPE && !event.defaultPrevented) {
41
- event.preventDefault();
42
- closeListView();
43
- }
44
- }, [closeListView]);
45
-
46
- // Use internal state instead of a ref to make sure that the component
47
- // re-renders when the dropZoneElement updates.
48
- const [dropZoneElement, setDropZoneElement] = useState(null);
49
-
50
- // This ref refers to the sidebar as a whole.
51
- const sidebarRef = useRef();
52
- // This ref refers to the close button.
53
- const sidebarCloseButtonRef = useRef();
54
- // This ref refers to the list view application area.
55
- const listViewRef = useRef();
56
-
57
- /*
58
- * Callback function to handle list view or close button focus.
59
- *
60
- * @return void
61
- */
62
- function handleSidebarFocus() {
63
- // Either focus the list view or the sidebar close button. Must have a fallback because the list view does not render when there are no blocks.
64
- const listViewApplicationFocus = focus.tabbable.find(listViewRef.current)[0];
65
- const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : sidebarCloseButtonRef.current;
66
- listViewFocusArea.focus();
67
- }
68
- const handleToggleListViewShortcut = useCallback(() => {
69
- // If the sidebar has focus, it is safe to close.
70
- if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) {
71
- closeListView();
72
- } else {
73
- // If the list view or close button does not have focus, focus should be moved to it.
74
- handleSidebarFocus();
75
- }
76
- }, [closeListView]);
77
-
78
- // This only fires when the sidebar is open because of the conditional rendering.
79
- // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
80
- useShortcut('core/edit-site/toggle-list-view', handleToggleListViewShortcut);
81
- return (
82
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
83
- createElement("div", {
84
- className: "edit-site-editor__list-view-panel",
85
- onKeyDown: closeOnEscape,
86
- ref: sidebarRef
87
- }, createElement("div", {
88
- className: "edit-site-editor__list-view-panel-header"
89
- }, createElement("strong", null, __('List View')), createElement(Button, {
90
- icon: closeSmall,
91
- label: __('Close'),
92
- onClick: closeListView,
93
- ref: sidebarCloseButtonRef
94
- })), createElement("div", {
95
- className: "edit-site-editor__list-view-panel-content",
96
- ref: useMergeRefs([focusOnMountRef, setDropZoneElement, listViewRef])
97
- }, createElement(PrivateListView, {
98
- dropZoneElement: dropZoneElement
99
- })))
100
- );
101
- }
102
- //# sourceMappingURL=list-view-sidebar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["privateApis","blockEditorPrivateApis","Button","useFocusOnMount","useMergeRefs","useDispatch","useCallback","useRef","useState","__","closeSmall","ESCAPE","focus","useShortcut","store","editSiteStore","unlock","PrivateListView","ListViewSidebar","listViewToggleElement","setIsListViewOpened","focusOnMountRef","closeListView","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","dropZoneElement","setDropZoneElement","sidebarRef","sidebarCloseButtonRef","listViewRef","handleSidebarFocus","listViewApplicationFocus","tabbable","find","current","listViewFocusArea","contains","handleToggleListViewShortcut","ownerDocument","activeElement","createElement","className","onKeyDown","ref","icon","label","onClick"],"sources":["@wordpress/edit-site/src/components/secondary-sidebar/list-view-sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { PrivateListView } = unlock( blockEditorPrivateApis );\n\nexport default function ListViewSidebar( { listViewToggleElement } ) {\n\tconst { setIsListViewOpened } = useDispatch( editSiteStore );\n\n\t// This hook handles focus when the sidebar first renders.\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\t// When closing the list view, focus should return to the toggle button.\n\tconst closeListView = useCallback( () => {\n\t\tsetIsListViewOpened( false );\n\t\tlistViewToggleElement?.focus();\n\t}, [ listViewToggleElement, setIsListViewOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseListView();\n\t\t\t}\n\t\t},\n\t\t[ closeListView ]\n\t);\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the dropZoneElement updates.\n\tconst [ dropZoneElement, setDropZoneElement ] = useState( null );\n\n\t// This ref refers to the sidebar as a whole.\n\tconst sidebarRef = useRef();\n\t// This ref refers to the close button.\n\tconst sidebarCloseButtonRef = useRef();\n\t// This ref refers to the list view application area.\n\tconst listViewRef = useRef();\n\n\t/*\n\t * Callback function to handle list view or close button focus.\n\t *\n\t * @return void\n\t */\n\tfunction handleSidebarFocus() {\n\t\t// Either focus the list view or the sidebar close button. Must have a fallback because the list view does not render when there are no blocks.\n\t\tconst listViewApplicationFocus = focus.tabbable.find(\n\t\t\tlistViewRef.current\n\t\t)[ 0 ];\n\t\tconst listViewFocusArea = sidebarRef.current.contains(\n\t\t\tlistViewApplicationFocus\n\t\t)\n\t\t\t? listViewApplicationFocus\n\t\t\t: sidebarCloseButtonRef.current;\n\t\tlistViewFocusArea.focus();\n\t}\n\n\tconst handleToggleListViewShortcut = useCallback( () => {\n\t\t// If the sidebar has focus, it is safe to close.\n\t\tif (\n\t\t\tsidebarRef.current.contains(\n\t\t\t\tsidebarRef.current.ownerDocument.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcloseListView();\n\t\t} else {\n\t\t\t// If the list view or close button does not have focus, focus should be moved to it.\n\t\t\thandleSidebarFocus();\n\t\t}\n\t}, [ closeListView ] );\n\n\t// This only fires when the sidebar is open because of the conditional rendering.\n\t// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.\n\tuseShortcut(\n\t\t'core/edit-site/toggle-list-view',\n\t\thandleToggleListViewShortcut\n\t);\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName=\"edit-site-editor__list-view-panel\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t\tref={ sidebarRef }\n\t\t>\n\t\t\t<div className=\"edit-site-editor__list-view-panel-header\">\n\t\t\t\t<strong>{ __( 'List View' ) }</strong>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\tonClick={ closeListView }\n\t\t\t\t\tref={ sidebarCloseButtonRef }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-content\"\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t\tsetDropZoneElement,\n\t\t\t\t\tlistViewRef,\n\t\t\t\t] ) }\n\t\t\t>\n\t\t\t\t<PrivateListView dropZoneElement={ dropZoneElement } />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,eAAe,EAAEC,YAAY,QAAQ,oBAAoB;AAClE,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAClE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,WAAW,QAAQ,+BAA+B;;AAE3D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,aAAa;AACpD,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EAAEC;AAAgB,CAAC,GAAGD,MAAM,CAAEf,sBAAuB,CAAC;AAE5D,eAAe,SAASiB,eAAeA,CAAE;EAAEC;AAAsB,CAAC,EAAG;EACpE,MAAM;IAAEC;EAA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CAACE,QAAQ,CAC1BT,UAAU,CAACO,OAAO,CAACI,aAAa,CAACC,aAClC,CAAC,EACA;MACDpB,aAAa,CAAC,CAAC;IAChB,CAAC,MAAM;MACN;MACAW,kBAAkB,CAAC,CAAC;IACrB;EACD,CAAC,EAAE,CAAEX,aAAa,CAAG,CAAC;;EAEtB;EACA;EACAT,WAAW,CACV,iCAAiC,EACjC2B,4BACD,CAAC;EAED;IACC;IACAG,aAAA;MACCC,SAAS,EAAC,mCAAmC;MAC7CC,SAAS,EAAGtB,aAAe;MAC3BuB,GAAG,EAAGhB;IAAY,GAElBa,aAAA;MAAKC,SAAS,EAAC;IAA0C,GACxDD,aAAA,iBAAUlC,EAAE,CAAE,WAAY,CAAW,CAAC,EACtCkC,aAAA,CAACzC,MAAM;MACN6C,IAAI,EAAGrC,UAAY;MACnBsC,KAAK,EAAGvC,EAAE,CAAE,OAAQ,CAAG;MACvBwC,OAAO,EAAG3B,aAAe;MACzBwB,GAAG,EAAGf;IAAuB,CAC7B,CACG,CAAC,EACNY,aAAA;MACCC,SAAS,EAAC,2CAA2C;MACrDE,GAAG,EAAG1C,YAAY,CAAE,CACnBiB,eAAe,EACfQ,kBAAkB,EAClBG,WAAW,CACV;IAAG,GAELW,aAAA,CAAC1B,eAAe;MAACW,eAAe,EAAGA;IAAiB,CAAE,CAClD,CACD;EAAC;AAER"}
@@ -1,27 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { privateApis as componentsPrivateApis } from '@wordpress/components';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import { unlock } from '../../lock-unlock';
11
- const {
12
- createPrivateSlotFill
13
- } = unlock(componentsPrivateApis);
14
- const SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME = 'SidebarFixedBottom';
15
- const {
16
- Slot: SidebarFixedBottomSlot,
17
- Fill: SidebarFixedBottomFill
18
- } = createPrivateSlotFill(SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME);
19
- export default function SidebarFixedBottom({
20
- children
21
- }) {
22
- return createElement(SidebarFixedBottomFill, null, createElement("div", {
23
- className: "edit-site-sidebar-fixed-bottom-slot"
24
- }, children));
25
- }
26
- export { SidebarFixedBottomSlot };
27
- //# sourceMappingURL=sidebar-fixed-bottom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["privateApis","componentsPrivateApis","unlock","createPrivateSlotFill","SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME","Slot","SidebarFixedBottomSlot","Fill","SidebarFixedBottomFill","SidebarFixedBottom","children","createElement","className"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/sidebar-fixed-bottom.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { createPrivateSlotFill } = unlock( componentsPrivateApis );\nconst SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME = 'SidebarFixedBottom';\nconst { Slot: SidebarFixedBottomSlot, Fill: SidebarFixedBottomFill } =\n\tcreatePrivateSlotFill( SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME );\n\nexport default function SidebarFixedBottom( { children } ) {\n\treturn (\n\t\t<SidebarFixedBottomFill>\n\t\t\t<div className=\"edit-site-sidebar-fixed-bottom-slot\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</SidebarFixedBottomFill>\n\t);\n}\n\nexport { SidebarFixedBottomSlot };\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,qBAAqB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EAAEC;AAAsB,CAAC,GAAGD,MAAM,CAAED,qBAAsB,CAAC;AACjE,MAAMG,mCAAmC,GAAG,oBAAoB;AAChE,MAAM;EAAEC,IAAI,EAAEC,sBAAsB;EAAEC,IAAI,EAAEC;AAAuB,CAAC,GACnEL,qBAAqB,CAAEC,mCAAoC,CAAC;AAE7D,eAAe,SAASK,kBAAkBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC1D,OACCC,aAAA,CAACH,sBAAsB,QACtBG,aAAA;IAAKC,SAAS,EAAC;EAAqC,GACjDF,QACE,CACkB,CAAC;AAE3B;AAEA,SAASJ,sBAAsB"}
@@ -1,65 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { Button, PanelRow } from '@wordpress/components';
6
- import { sprintf, _n, __ } from '@wordpress/i18n';
7
- import { backup } from '@wordpress/icons';
8
- import { addQueryArgs } from '@wordpress/url';
9
- import { PostTypeSupportCheck } from '@wordpress/editor';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import useEditedEntityRecord from '../../use-edited-entity-record';
15
- const useRevisionData = () => {
16
- var _currentTemplate$_lin, _currentTemplate$_lin2;
17
- const {
18
- record: currentTemplate
19
- } = useEditedEntityRecord();
20
- const lastRevisionId = (_currentTemplate$_lin = currentTemplate?._links?.['predecessor-version']?.[0]?.id) !== null && _currentTemplate$_lin !== void 0 ? _currentTemplate$_lin : null;
21
- const revisionsCount = (_currentTemplate$_lin2 = currentTemplate?._links?.['version-history']?.[0]?.count) !== null && _currentTemplate$_lin2 !== void 0 ? _currentTemplate$_lin2 : 0;
22
- return {
23
- currentTemplate,
24
- lastRevisionId,
25
- revisionsCount
26
- };
27
- };
28
- function PostLastRevisionCheck({
29
- children
30
- }) {
31
- const {
32
- lastRevisionId,
33
- revisionsCount
34
- } = useRevisionData();
35
- if (!process.env.IS_GUTENBERG_PLUGIN) {
36
- return null;
37
- }
38
- if (!lastRevisionId || revisionsCount < 2) {
39
- return null;
40
- }
41
- return createElement(PostTypeSupportCheck, {
42
- supportKeys: "revisions"
43
- }, children);
44
- }
45
- const PostLastRevision = () => {
46
- const {
47
- lastRevisionId,
48
- revisionsCount
49
- } = useRevisionData();
50
- return createElement(PostLastRevisionCheck, null, createElement(PanelRow, {
51
- header: __('Editing history'),
52
- className: "edit-site-template-revisions"
53
- }, createElement(Button, {
54
- href: addQueryArgs('revision.php', {
55
- revision: lastRevisionId
56
- }),
57
- className: "edit-site-template-last-revision__title",
58
- icon: backup
59
- }, sprintf( /* translators: %d: number of revisions */
60
- _n('%d Revision', '%d Revisions', revisionsCount), revisionsCount))));
61
- };
62
- export default function LastRevision() {
63
- return createElement(PostLastRevisionCheck, null, createElement(PostLastRevision, null));
64
- }
65
- //# sourceMappingURL=last-revision.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Button","PanelRow","sprintf","_n","__","backup","addQueryArgs","PostTypeSupportCheck","useEditedEntityRecord","useRevisionData","_currentTemplate$_lin","_currentTemplate$_lin2","record","currentTemplate","lastRevisionId","_links","id","revisionsCount","count","PostLastRevisionCheck","children","process","env","IS_GUTENBERG_PLUGIN","createElement","supportKeys","PostLastRevision","header","className","href","revision","icon","LastRevision"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-panel/last-revision.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, PanelRow } from '@wordpress/components';\nimport { sprintf, _n, __ } from '@wordpress/i18n';\nimport { backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { PostTypeSupportCheck } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useEditedEntityRecord from '../../use-edited-entity-record';\n\nconst useRevisionData = () => {\n\tconst { record: currentTemplate } = useEditedEntityRecord();\n\n\tconst lastRevisionId =\n\t\tcurrentTemplate?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\n\tconst revisionsCount =\n\t\tcurrentTemplate?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\n\treturn {\n\t\tcurrentTemplate,\n\t\tlastRevisionId,\n\t\trevisionsCount,\n\t};\n};\n\nfunction PostLastRevisionCheck( { children } ) {\n\tconst { lastRevisionId, revisionsCount } = useRevisionData();\n\n\tif ( ! process.env.IS_GUTENBERG_PLUGIN ) {\n\t\treturn null;\n\t}\n\n\tif ( ! lastRevisionId || revisionsCount < 2 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"revisions\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nconst PostLastRevision = () => {\n\tconst { lastRevisionId, revisionsCount } = useRevisionData();\n\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PanelRow\n\t\t\t\theader={ __( 'Editing history' ) }\n\t\t\t\tclassName=\"edit-site-template-revisions\"\n\t\t\t>\n\t\t\t\t<Button\n\t\t\t\t\thref={ addQueryArgs( 'revision.php', {\n\t\t\t\t\t\trevision: lastRevisionId,\n\t\t\t\t\t} ) }\n\t\t\t\t\tclassName=\"edit-site-template-last-revision__title\"\n\t\t\t\t\ticon={ backup }\n\t\t\t\t>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of revisions */\n\t\t\t\t\t\t_n( '%d Revision', '%d Revisions', revisionsCount ),\n\t\t\t\t\t\trevisionsCount\n\t\t\t\t\t) }\n\t\t\t\t</Button>\n\t\t\t</PanelRow>\n\t\t</PostLastRevisionCheck>\n\t);\n};\n\nexport default function LastRevision() {\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PostLastRevision />\n\t\t</PostLastRevisionCheck>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,QAAQ,QAAQ,uBAAuB;AACxD,SAASC,OAAO,EAAEC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,oBAAoB,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,gCAAgC;AAElE,MAAMC,eAAe,GAAGA,CAAA,KAAM;EAAA,IAAAC,qBAAA,EAAAC,sBAA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1B;EAAQ,GAEbH,OAAO,EACR;EACAC,EAAE,CAAE,aAAa,EAAE,cAAc,EAAEc,cAAe,CAAC,EACnDA,cACD,CACO,CACC,CACY,CAAC;AAE1B,CAAC;AAED,eAAe,SAASe,YAAYA,CAAA,EAAG;EACtC,OACCR,aAAA,CAACL,qBAAqB,QACrBK,aAAA,CAACE,gBAAgB,MAAE,CACG,CAAC;AAE1B"}
@@ -1,209 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { __, _x, sprintf } from '@wordpress/i18n';
6
- import { useEffect, useMemo, useState } from '@wordpress/element';
7
- import { FormTokenField, FlexBlock, PanelRow } from '@wordpress/components';
8
- import { useSelect, useDispatch } from '@wordpress/data';
9
- import { store as coreStore } from '@wordpress/core-data';
10
- import { useDebounce } from '@wordpress/compose';
11
- import { store as noticesStore } from '@wordpress/notices';
12
- import { decodeEntities } from '@wordpress/html-entities';
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
- import { PATTERN_TYPES } from '../../../utils/constants';
18
- export const unescapeString = arg => {
19
- return decodeEntities(arg);
20
- };
21
-
22
- /**
23
- * Returns a term object with name unescaped.
24
- *
25
- * @param {Object} term The term object to unescape.
26
- *
27
- * @return {Object} Term object with name property unescaped.
28
- */
29
- export const unescapeTerm = term => {
30
- return {
31
- ...term,
32
- name: unescapeString(term.name)
33
- };
34
- };
35
-
36
- /**
37
- * Shared reference to an empty array for cases where it is important to avoid
38
- * returning a new array reference on every invocation.
39
- *
40
- * @type {Array<any>}
41
- */
42
- const EMPTY_ARRAY = [];
43
-
44
- /**
45
- * Module constants
46
- */
47
- const MAX_TERMS_SUGGESTIONS = 20;
48
- const DEFAULT_QUERY = {
49
- per_page: MAX_TERMS_SUGGESTIONS,
50
- _fields: 'id,name',
51
- context: 'view'
52
- };
53
- const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
54
- const termNamesToIds = (names, terms) => {
55
- return names.map(termName => terms.find(term => isSameTermName(term.name, termName)).id);
56
- };
57
- export default function PatternCategories({
58
- post
59
- }) {
60
- var _taxonomy$labels$sing;
61
- const slug = 'wp_pattern_category';
62
- const [values, setValues] = useState([]);
63
- const [search, setSearch] = useState('');
64
- const debouncedSearch = useDebounce(setSearch, 500);
65
- const {
66
- terms,
67
- taxonomy,
68
- hasAssignAction,
69
- hasCreateAction,
70
- hasResolvedTerms
71
- } = useSelect(select => {
72
- var _post$_links, _post$_links2;
73
- const {
74
- getEntityRecords,
75
- getTaxonomy,
76
- hasFinishedResolution
77
- } = select(coreStore);
78
- const _taxonomy = getTaxonomy(slug);
79
- const _termIds = post?.wp_pattern_category?.length > 0 ? post?.wp_pattern_category : EMPTY_ARRAY;
80
- const query = {
81
- ...DEFAULT_QUERY,
82
- include: _termIds?.join(','),
83
- per_page: -1
84
- };
85
- return {
86
- hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
87
- hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
88
- taxonomy: _taxonomy,
89
- termIds: _termIds,
90
- terms: _termIds?.length ? getEntityRecords('taxonomy', slug, query) : EMPTY_ARRAY,
91
- hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
92
- };
93
- }, [slug, post]);
94
- const {
95
- searchResults
96
- } = useSelect(select => {
97
- const {
98
- getEntityRecords
99
- } = select(coreStore);
100
- return {
101
- searchResults: !!search ? getEntityRecords('taxonomy', slug, {
102
- ...DEFAULT_QUERY,
103
- search
104
- }) : EMPTY_ARRAY
105
- };
106
- }, [search, slug]);
107
-
108
- // Update terms state only after the selectors are resolved.
109
- // We're using this to avoid terms temporarily disappearing on slow networks
110
- // while core data makes REST API requests.
111
- useEffect(() => {
112
- if (hasResolvedTerms) {
113
- const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
114
- setValues(newValues);
115
- }
116
- }, [terms, hasResolvedTerms]);
117
- const suggestions = useMemo(() => {
118
- return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
119
- }, [searchResults]);
120
- const {
121
- saveEntityRecord,
122
- editEntityRecord,
123
- invalidateResolution
124
- } = useDispatch(coreStore);
125
- const {
126
- createErrorNotice
127
- } = useDispatch(noticesStore);
128
- if (!hasAssignAction) {
129
- return null;
130
- }
131
- async function findOrCreateTerm(term) {
132
- try {
133
- const newTerm = await saveEntityRecord('taxonomy', slug, term, {
134
- throwOnError: true
135
- });
136
- invalidateResolution('getUserPatternCategories');
137
- return unescapeTerm(newTerm);
138
- } catch (error) {
139
- if (error.code !== 'term_exists') {
140
- throw error;
141
- }
142
- return {
143
- id: error.data.term_id,
144
- name: term.name
145
- };
146
- }
147
- }
148
- function onUpdateTerms(newTermIds) {
149
- editEntityRecord('postType', PATTERN_TYPES.user, post.id, {
150
- wp_pattern_category: newTermIds
151
- });
152
- }
153
- function onChange(termNames) {
154
- const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
155
- const uniqueTerms = termNames.reduce((acc, name) => {
156
- if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) {
157
- acc.push(name);
158
- }
159
- return acc;
160
- }, []);
161
- const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName)));
162
-
163
- // Optimistically update term values.
164
- // The selector will always re-fetch terms later.
165
- setValues(uniqueTerms);
166
- if (newTermNames.length === 0) {
167
- return onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
168
- }
169
- if (!hasCreateAction) {
170
- return;
171
- }
172
- Promise.all(newTermNames.map(termName => findOrCreateTerm({
173
- name: termName
174
- }))).then(newTerms => {
175
- const newAvailableTerms = availableTerms.concat(newTerms);
176
- return onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
177
- }).catch(error => {
178
- createErrorNotice(error.message, {
179
- type: 'snackbar'
180
- });
181
- });
182
- }
183
- const singularName = (_taxonomy$labels$sing = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing !== void 0 ? _taxonomy$labels$sing : slug === 'post_tag' ? __('Tag') : __('Term');
184
- const termAddedLabel = sprintf( /* translators: %s: term name. */
185
- _x('%s added', 'term'), singularName);
186
- const termRemovedLabel = sprintf( /* translators: %s: term name. */
187
- _x('%s removed', 'term'), singularName);
188
- const removeTermLabel = sprintf( /* translators: %s: term name. */
189
- _x('Remove %s', 'term'), singularName);
190
- return createElement(PanelRow, {
191
- initialOpen: true,
192
- title: __('Categories')
193
- }, createElement(FlexBlock, null, createElement(FormTokenField, {
194
- __next40pxDefaultSize: true,
195
- value: values,
196
- suggestions: suggestions,
197
- onChange: onChange,
198
- onInputChange: debouncedSearch,
199
- maxSuggestions: MAX_TERMS_SUGGESTIONS,
200
- label: __('Pattern categories'),
201
- messages: {
202
- added: termAddedLabel,
203
- removed: termRemovedLabel,
204
- remove: removeTermLabel
205
- },
206
- tokenizeOnBlur: true
207
- })));
208
- }
209
- //# sourceMappingURL=pattern-categories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__","_x","sprintf","useEffect","useMemo","useState","FormTokenField","FlexBlock","PanelRow","useSelect","useDispatch","store","coreStore","useDebounce","noticesStore","decodeEntities","PATTERN_TYPES","unescapeString","arg","unescapeTerm","term","name","EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","id","PatternCategories","post","_taxonomy$labels$sing","slug","values","setValues","search","setSearch","debouncedSearch","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","_post$_links","_post$_links2","getEntityRecords","getTaxonomy","hasFinishedResolution","_taxonomy","_termIds","wp_pattern_category","length","query","include","join","_links","rest_base","termIds","searchResults","newValues","suggestions","saveEntityRecord","editEntityRecord","invalidateResolution","createErrorNotice","findOrCreateTerm","newTerm","throwOnError","error","code","data","term_id","onUpdateTerms","newTermIds","user","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","Promise","all","then","newTerms","newAvailableTerms","concat","catch","message","type","singularName","labels","singular_name","termAddedLabel","termRemovedLabel","removeTermLabel","createElement","initialOpen","title","__next40pxDefaultSize","value","onInputChange","maxSuggestions","label","messages","added","removed","remove","tokenizeOnBlur"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-panel/pattern-categories.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, FlexBlock, PanelRow } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { PATTERN_TYPES } from '../../../utils/constants';\n\nexport const unescapeString = ( arg ) => {\n\treturn decodeEntities( arg );\n};\n\n/**\n * Returns a term object with name unescaped.\n *\n * @param {Object} term The term object to unescape.\n *\n * @return {Object} Term object with name property unescaped.\n */\nexport const unescapeTerm = ( term ) => {\n\treturn {\n\t\t...term,\n\t\tname: unescapeString( term.name ),\n\t};\n};\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\nexport default function PatternCategories( { post } ) {\n\tconst slug = 'wp_pattern_category';\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds =\n\t\t\t\tpost?.wp_pattern_category?.length > 0\n\t\t\t\t\t? post?.wp_pattern_category\n\t\t\t\t\t: EMPTY_ARRAY;\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds?.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds?.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug, post ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search, slug ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { saveEntityRecord, editEntityRecord, invalidateResolution } =\n\t\tuseDispatch( coreStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tasync function findOrCreateTerm( term ) {\n\t\ttry {\n\t\t\tconst newTerm = await saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\tinvalidateResolution( 'getUserPatternCategories' );\n\t\t\treturn unescapeTerm( newTerm );\n\t\t} catch ( error ) {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: term.name,\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditEntityRecord( 'postType', PATTERN_TYPES.user, post.id, {\n\t\t\twp_pattern_category: newTermIds,\n\t\t} );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( { name: termName } )\n\t\t\t)\n\t\t)\n\t\t\t.then( ( newTerms ) => {\n\t\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\t\treturn onUpdateTerms(\n\t\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t} );\n\t}\n\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<PanelRow initialOpen={ true } title={ __( 'Categories' ) }>\n\t\t\t<FlexBlock>\n\t\t\t\t<FormTokenField\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvalue={ values }\n\t\t\t\t\tsuggestions={ suggestions }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\t\tlabel={ __( 'Pattern categories' ) }\n\t\t\t\t\tmessages={ {\n\t\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t\t} }\n\t\t\t\t\ttokenizeOnBlur\n\t\t\t\t/>\n\t\t\t</FlexBlock>\n\t\t</PanelRow>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACjE,SAASC,cAAc,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AAC3E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASF,KAAK,IAAIG,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASC,aAAa,QAAQ,0BAA0B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,EACzBwG,YACD,CAAC;EAED,OACCM,aAAA,CAACvG,QAAQ;IAACwG,WAAW,EAAG,IAAM;IAACC,KAAK,EAAGjH,EAAE,CAAE,YAAa;EAAG,GAC1D+G,aAAA,CAACxG,SAAS,QACTwG,aAAA,CAACzG,cAAc;IACd4G,qBAAqB;IACrBC,KAAK,EAAGxE,MAAQ;IAChB2B,WAAW,EAAGA,WAAa;IAC3Be,QAAQ,EAAGA,QAAU;IACrB+B,aAAa,EAAGrE,eAAiB;IACjCsE,cAAc,EAAG9F,qBAAuB;IACxC+F,KAAK,EAAGtH,EAAE,CAAE,oBAAqB,CAAG;IACpCuH,QAAQ,EAAG;MACVC,KAAK,EAAEZ,cAAc;MACrBa,OAAO,EAAEZ,gBAAgB;MACzBa,MAAM,EAAEZ;IACT,CAAG;IACHa,cAAc;EAAA,CACd,CACS,CACF,CAAC;AAEb"}
@@ -1,62 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { makeFormDataFromFontFamilies } from '../index';
5
-
6
- /* global File */
7
-
8
- describe( 'makeFormDataFromFontFamilies', () => {
9
- it( 'should process fontFamilies and return FormData', () => {
10
- const mockFontFamilies = [
11
- {
12
- slug: 'bebas',
13
- name: 'Bebas',
14
- fontFamily: 'Bebas',
15
- fontFace: [
16
- {
17
- file: new File( [ 'content' ], 'test-font1.woff2' ),
18
- fontWeight: '500',
19
- fontStyle: 'normal',
20
- },
21
- {
22
- file: new File( [ 'content' ], 'test-font2.woff2' ),
23
- fontWeight: '400',
24
- fontStyle: 'normal',
25
- },
26
- ],
27
- },
28
- ];
29
-
30
- const formData = makeFormDataFromFontFamilies( mockFontFamilies );
31
-
32
- expect( formData instanceof FormData ).toBeTruthy();
33
-
34
- // Check if files are added correctly
35
- expect( formData.get( 'file-0-0' ).name ).toBe( 'test-font1.woff2' );
36
- expect( formData.get( 'file-0-1' ).name ).toBe( 'test-font2.woff2' );
37
-
38
- // Check if 'fontFamilies' key in FormData is correct
39
- const expectedFontFamilies = [
40
- {
41
- fontFace: [
42
- {
43
- fontWeight: '500',
44
- fontStyle: 'normal',
45
- uploadedFile: 'file-0-0',
46
- },
47
- {
48
- fontWeight: '400',
49
- fontStyle: 'normal',
50
- uploadedFile: 'file-0-1',
51
- },
52
- ],
53
- slug: 'bebas',
54
- name: 'Bebas',
55
- fontFamily: 'Bebas',
56
- },
57
- ];
58
- expect( JSON.parse( formData.get( 'font_families' ) ) ).toEqual(
59
- expectedFontFamilies
60
- );
61
- } );
62
- } );
@@ -1,28 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { wpKebabCase } from '../index';
5
-
6
- describe( 'wpKebabCase', () => {
7
- it( 'should insert a dash between a letter and a digit', () => {
8
- const input = 'abc1def';
9
- const expectedOutput = 'abc-1def';
10
- expect( wpKebabCase( input ) ).toEqual( expectedOutput );
11
-
12
- const input2 = 'abc1def2ghi';
13
- const expectedOutput2 = 'abc-1def-2ghi';
14
- expect( wpKebabCase( input2 ) ).toEqual( expectedOutput2 );
15
- } );
16
-
17
- it( 'should not insert a dash between two letters', () => {
18
- const input = 'abcdef';
19
- const expectedOutput = 'abcdef';
20
- expect( wpKebabCase( input ) ).toEqual( expectedOutput );
21
- } );
22
-
23
- it( 'should not insert a dash between a digit and a hyphen', () => {
24
- const input = 'abc1-def';
25
- const expectedOutput = 'abc-1-def';
26
- expect( wpKebabCase( input ) ).toEqual( expectedOutput );
27
- } );
28
- } );