@wordpress/edit-site 6.11.0 → 6.12.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 (190) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/app/index.js +0 -2
  3. package/build/components/app/index.js.map +1 -1
  4. package/build/components/block-editor/use-editor-iframe-props.js +6 -8
  5. package/build/components/block-editor/use-editor-iframe-props.js.map +1 -1
  6. package/build/components/editor/index.js +9 -4
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/editor/use-editor-title.js +29 -12
  9. package/build/components/editor/use-editor-title.js.map +1 -1
  10. package/build/components/global-styles/screen-revisions/revisions-buttons.js +24 -22
  11. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  12. package/build/components/global-styles/shadows-edit-panel.js +2 -3
  13. package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
  14. package/build/components/global-styles/ui.js +42 -2
  15. package/build/components/global-styles/ui.js.map +1 -1
  16. package/build/components/global-styles-renderer/index.js +6 -8
  17. package/build/components/global-styles-renderer/index.js.map +1 -1
  18. package/build/components/layout/hooks.js +1 -10
  19. package/build/components/layout/hooks.js.map +1 -1
  20. package/build/components/layout/index.js +1 -0
  21. package/build/components/layout/index.js.map +1 -1
  22. package/build/components/page-patterns/fields.js +3 -7
  23. package/build/components/page-patterns/fields.js.map +1 -1
  24. package/build/components/page-templates/fields.js +1 -2
  25. package/build/components/page-templates/fields.js.map +1 -1
  26. package/build/components/post-edit/index.js +14 -8
  27. package/build/components/post-edit/index.js.map +1 -1
  28. package/build/components/post-fields/index.js +3 -197
  29. package/build/components/post-fields/index.js.map +1 -1
  30. package/build/components/post-list/index.js +11 -1
  31. package/build/components/post-list/index.js.map +1 -1
  32. package/build/components/sidebar/index.js +11 -3
  33. package/build/components/sidebar/index.js.map +1 -1
  34. package/build/components/sidebar-global-styles-wrapper/index.js +129 -0
  35. package/build/components/sidebar-global-styles-wrapper/index.js.map +1 -0
  36. package/build/components/sidebar-navigation-screen-global-styles/index.js +14 -72
  37. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  38. package/build/components/sidebar-navigation-screen-main/index.js +43 -42
  39. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  40. package/build/components/site-editor-routes/styles-edit.js +6 -1
  41. package/build/components/site-editor-routes/styles-edit.js.map +1 -1
  42. package/build/components/site-editor-routes/styles-view.js +8 -2
  43. package/build/components/site-editor-routes/styles-view.js.map +1 -1
  44. package/build/components/site-hub/index.js +19 -6
  45. package/build/components/site-hub/index.js.map +1 -1
  46. package/build/components/style-book/constants.js +10 -3
  47. package/build/components/style-book/constants.js.map +1 -1
  48. package/build/components/style-book/examples.js +71 -1
  49. package/build/components/style-book/examples.js.map +1 -1
  50. package/build/components/style-book/index.js +70 -11
  51. package/build/components/style-book/index.js.map +1 -1
  52. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
  53. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  54. package/build/components/welcome-guide/index.js +4 -2
  55. package/build/components/welcome-guide/index.js.map +1 -1
  56. package/build/components/welcome-guide/page.js +1 -9
  57. package/build/components/welcome-guide/page.js.map +1 -1
  58. package/build/components/welcome-guide/template.js +1 -12
  59. package/build/components/welcome-guide/template.js.map +1 -1
  60. package/build/hooks/commands/use-common-commands.js +15 -15
  61. package/build/hooks/commands/use-common-commands.js.map +1 -1
  62. package/build/index.js +1 -0
  63. package/build/index.js.map +1 -1
  64. package/build/posts.js +1 -0
  65. package/build/posts.js.map +1 -1
  66. package/build-module/components/app/index.js +0 -2
  67. package/build-module/components/app/index.js.map +1 -1
  68. package/build-module/components/block-editor/use-editor-iframe-props.js +6 -8
  69. package/build-module/components/block-editor/use-editor-iframe-props.js.map +1 -1
  70. package/build-module/components/editor/index.js +9 -4
  71. package/build-module/components/editor/index.js.map +1 -1
  72. package/build-module/components/editor/use-editor-title.js +29 -12
  73. package/build-module/components/editor/use-editor-title.js.map +1 -1
  74. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +25 -23
  75. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  76. package/build-module/components/global-styles/shadows-edit-panel.js +2 -3
  77. package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
  78. package/build-module/components/global-styles/ui.js +43 -3
  79. package/build-module/components/global-styles/ui.js.map +1 -1
  80. package/build-module/components/global-styles-renderer/index.js +6 -8
  81. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  82. package/build-module/components/layout/hooks.js +1 -9
  83. package/build-module/components/layout/hooks.js.map +1 -1
  84. package/build-module/components/layout/index.js +1 -0
  85. package/build-module/components/layout/index.js.map +1 -1
  86. package/build-module/components/page-patterns/fields.js +4 -8
  87. package/build-module/components/page-patterns/fields.js.map +1 -1
  88. package/build-module/components/page-templates/fields.js +1 -2
  89. package/build-module/components/page-templates/fields.js.map +1 -1
  90. package/build-module/components/post-edit/index.js +14 -8
  91. package/build-module/components/post-edit/index.js.map +1 -1
  92. package/build-module/components/post-fields/index.js +7 -202
  93. package/build-module/components/post-fields/index.js.map +1 -1
  94. package/build-module/components/post-list/index.js +11 -1
  95. package/build-module/components/post-list/index.js.map +1 -1
  96. package/build-module/components/sidebar/index.js +11 -3
  97. package/build-module/components/sidebar/index.js.map +1 -1
  98. package/build-module/components/sidebar-global-styles-wrapper/index.js +121 -0
  99. package/build-module/components/sidebar-global-styles-wrapper/index.js.map +1 -0
  100. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +15 -73
  101. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  102. package/build-module/components/sidebar-navigation-screen-main/index.js +43 -43
  103. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  104. package/build-module/components/site-editor-routes/styles-edit.js +6 -1
  105. package/build-module/components/site-editor-routes/styles-edit.js.map +1 -1
  106. package/build-module/components/site-editor-routes/styles-view.js +8 -2
  107. package/build-module/components/site-editor-routes/styles-view.js.map +1 -1
  108. package/build-module/components/site-hub/index.js +19 -6
  109. package/build-module/components/site-hub/index.js.map +1 -1
  110. package/build-module/components/style-book/constants.js +10 -3
  111. package/build-module/components/style-book/constants.js.map +1 -1
  112. package/build-module/components/style-book/examples.js +71 -1
  113. package/build-module/components/style-book/examples.js.map +1 -1
  114. package/build-module/components/style-book/index.js +71 -12
  115. package/build-module/components/style-book/index.js.map +1 -1
  116. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
  117. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  118. package/build-module/components/welcome-guide/index.js +4 -2
  119. package/build-module/components/welcome-guide/index.js.map +1 -1
  120. package/build-module/components/welcome-guide/page.js +1 -9
  121. package/build-module/components/welcome-guide/page.js.map +1 -1
  122. package/build-module/components/welcome-guide/template.js +1 -11
  123. package/build-module/components/welcome-guide/template.js.map +1 -1
  124. package/build-module/hooks/commands/use-common-commands.js +15 -15
  125. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  126. package/build-module/index.js +1 -0
  127. package/build-module/index.js.map +1 -1
  128. package/build-module/posts.js +1 -0
  129. package/build-module/posts.js.map +1 -1
  130. package/build-style/posts-rtl.css +54 -5
  131. package/build-style/posts.css +54 -5
  132. package/build-style/style-rtl.css +109 -28
  133. package/build-style/style.css +109 -28
  134. package/package.json +3 -4
  135. package/src/components/app/index.js +0 -2
  136. package/src/components/block-editor/use-editor-iframe-props.js +2 -3
  137. package/src/components/editor/index.js +16 -4
  138. package/src/components/editor/use-editor-title.js +37 -13
  139. package/src/components/editor-canvas-container/style.scss +0 -1
  140. package/src/components/global-styles/screen-revisions/revisions-buttons.js +28 -31
  141. package/src/components/global-styles/screen-revisions/style.scss +11 -17
  142. package/src/components/global-styles/shadows-edit-panel.js +4 -2
  143. package/src/components/global-styles/ui.js +42 -2
  144. package/src/components/global-styles-renderer/index.js +4 -10
  145. package/src/components/layout/hooks.js +1 -7
  146. package/src/components/layout/index.js +6 -1
  147. package/src/components/page-patterns/fields.js +6 -12
  148. package/src/components/page-patterns/style.scss +0 -5
  149. package/src/components/page-templates/fields.js +2 -3
  150. package/src/components/post-edit/index.js +38 -30
  151. package/src/components/post-edit/style.scss +7 -0
  152. package/src/components/post-fields/index.js +19 -273
  153. package/src/components/post-list/index.js +9 -3
  154. package/src/components/post-list/style.scss +29 -3
  155. package/src/components/sidebar/index.js +23 -7
  156. package/src/components/sidebar-global-styles-wrapper/index.js +150 -0
  157. package/src/components/sidebar-global-styles-wrapper/style.scss +35 -0
  158. package/src/components/sidebar-navigation-item/style.scss +2 -2
  159. package/src/components/sidebar-navigation-screen-global-styles/index.js +13 -88
  160. package/src/components/sidebar-navigation-screen-main/index.js +46 -45
  161. package/src/components/site-editor-routes/styles-edit.js +10 -1
  162. package/src/components/site-editor-routes/styles-view.js +11 -1
  163. package/src/components/site-hub/index.js +33 -16
  164. package/src/components/site-icon/style.scss +16 -0
  165. package/src/components/style-book/constants.ts +11 -3
  166. package/src/components/style-book/examples.tsx +105 -1
  167. package/src/components/style-book/index.js +86 -8
  168. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +54 -64
  169. package/src/components/welcome-guide/index.js +3 -3
  170. package/src/components/welcome-guide/page.js +1 -7
  171. package/src/components/welcome-guide/template.js +1 -8
  172. package/src/hooks/commands/use-common-commands.js +253 -246
  173. package/src/index.js +1 -0
  174. package/src/posts.js +1 -0
  175. package/src/style.scss +2 -3
  176. package/build/components/async/index.js +0 -51
  177. package/build/components/async/index.js.map +0 -1
  178. package/build/components/use-edited-entity-record/index.js +0 -60
  179. package/build/components/use-edited-entity-record/index.js.map +0 -1
  180. package/build/hooks/commands/use-edit-mode-commands.js +0 -179
  181. package/build/hooks/commands/use-edit-mode-commands.js.map +0 -1
  182. package/build-module/components/async/index.js +0 -44
  183. package/build-module/components/async/index.js.map +0 -1
  184. package/build-module/components/use-edited-entity-record/index.js +0 -53
  185. package/build-module/components/use-edited-entity-record/index.js.map +0 -1
  186. package/build-module/hooks/commands/use-edit-mode-commands.js +0 -171
  187. package/build-module/hooks/commands/use-edit-mode-commands.js.map +0 -1
  188. package/src/components/async/index.js +0 -43
  189. package/src/components/use-edited-entity-record/index.js +0 -58
  190. package/src/hooks/commands/use-edit-mode-commands.js +0 -168
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","__","DataForm","useDispatch","useSelect","store","coreDataStore","__experimentalVStack","VStack","useState","useMemo","useEffect","privateApis","editorPrivateApis","Page","usePostFields","unlock","jsx","_jsx","jsxs","_jsxs","PostCardPanel","PostEditForm","postType","postId","ids","split","record","select","length","getEditedEntityRecord","multiEdits","setMultiEdits","editEntityRecord","fields","_fields","map","field","id","elements","filter","element","value","form","type","fieldsWithBulkEditSupport","onChange","edits","status","Date","date","password","prev","spacing","children","data","includes","PostEdit","className","label"],"sources":["@wordpress/edit-site/src/components/post-edit/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { DataForm } from '@wordpress/dataviews';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport usePostFields from '../post-fields';\nimport { unlock } from '../../lock-unlock';\n\nconst { PostCardPanel } = unlock( editorPrivateApis );\n\nfunction PostEditForm( { postType, postId } ) {\n\tconst ids = useMemo( () => postId.split( ',' ), [ postId ] );\n\tconst { record } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\trecord:\n\t\t\t\t\tids.length === 1\n\t\t\t\t\t\t? select( coreDataStore ).getEditedEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\t\tids[ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ postType, ids ]\n\t);\n\tconst [ multiEdits, setMultiEdits ] = useState( {} );\n\tconst { editEntityRecord } = useDispatch( coreDataStore );\n\tconst { fields: _fields } = usePostFields();\n\tconst fields = useMemo(\n\t\t() =>\n\t\t\t_fields?.map( ( field ) => {\n\t\t\t\tif ( field.id === 'status' ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...field,\n\t\t\t\t\t\telements: field.elements.filter(\n\t\t\t\t\t\t\t( element ) => element.value !== 'trash'\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn field;\n\t\t\t} ),\n\t\t[ _fields ]\n\t);\n\tconst form = {\n\t\ttype: 'panel',\n\t\tfields: [\n\t\t\t'featured_media',\n\t\t\t'title',\n\t\t\t'author',\n\t\t\t'date',\n\t\t\t'slug',\n\t\t\t'parent',\n\t\t\t'comment_status',\n\t\t],\n\t};\n\n\tconst fieldsWithBulkEditSupport = [\n\t\t'title',\n\t\t'status',\n\t\t'date',\n\t\t'author',\n\t\t'comment_status',\n\t];\n\n\tconst onChange = ( edits ) => {\n\t\tfor ( const id of ids ) {\n\t\t\tif (\n\t\t\t\tedits.status &&\n\t\t\t\tedits.status !== 'future' &&\n\t\t\t\trecord?.status === 'future' &&\n\t\t\t\tnew Date( record.date ) > new Date()\n\t\t\t) {\n\t\t\t\tedits.date = null;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tedits.status &&\n\t\t\t\tedits.status === 'private' &&\n\t\t\t\trecord.password\n\t\t\t) {\n\t\t\t\tedits.password = '';\n\t\t\t}\n\t\t\teditEntityRecord( 'postType', postType, id, edits );\n\t\t\tif ( ids.length > 1 ) {\n\t\t\t\tsetMultiEdits( ( prev ) => ( {\n\t\t\t\t\t...prev,\n\t\t\t\t\t...edits,\n\t\t\t\t} ) );\n\t\t\t}\n\t\t}\n\t};\n\tuseEffect( () => {\n\t\tsetMultiEdits( {} );\n\t}, [ ids ] );\n\n\treturn (\n\t\t<VStack spacing={ 4 }>\n\t\t\t{ ids.length === 1 && (\n\t\t\t\t<PostCardPanel postType={ postType } postId={ ids[ 0 ] } />\n\t\t\t) }\n\t\t\t<DataForm\n\t\t\t\tdata={ ids.length === 1 ? record : multiEdits }\n\t\t\t\tfields={ fields }\n\t\t\t\tform={\n\t\t\t\t\tids.length === 1\n\t\t\t\t\t\t? form\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t...form,\n\t\t\t\t\t\t\t\tfields: form.fields.filter( ( field ) =>\n\t\t\t\t\t\t\t\t\tfieldsWithBulkEditSupport.includes( field )\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t }\n\t\t\t\t}\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n\nexport function PostEdit( { postType, postId } ) {\n\treturn (\n\t\t<Page\n\t\t\tclassName={ clsx( 'edit-site-post-edit', {\n\t\t\t\t'is-empty': ! postId,\n\t\t\t} ) }\n\t\t\tlabel={ __( 'Post Edit' ) }\n\t\t>\n\t\t\t{ postId && (\n\t\t\t\t<PostEditForm postType={ postType } postId={ postId } />\n\t\t\t) }\n\t\t\t{ ! postId && <p>{ __( 'Select a page to edit' ) }</p> }\n\t\t</Page>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,sBAAsB;AAC/C,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;AAC7D,SAASC,oBAAoB,IAAIC,MAAM,QAAQ,uBAAuB;AACtE,SAASC,QAAQ,EAAEC,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACjE,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;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MAAM,KAAK,CAAC,iBACjBX,IAAA,CAACG,aAAa;MAACE,QAAQ,EAAGA,QAAU;MAACC,MAAM,EAAGC,GAAG,CAAE,CAAC;IAAI,CAAE,CAC1D,eACDP,IAAA,CAAChB,QAAQ;MACRqD,IAAI,EAAG9B,GAAG,CAACI,MAAM,KAAK,CAAC,GAAGF,MAAM,GAAGI,UAAY;MAC/CG,MAAM,EAAGA,MAAQ;MACjBS,IAAI,EACHlB,GAAG,CAACI,MAAM,KAAK,CAAC,GACbc,IAAI,GACJ;QACA,GAAGA,IAAI;QACPT,MAAM,EAAES,IAAI,CAACT,MAAM,CAACM,MAAM,CAAIH,KAAK,IAClCQ,yBAAyB,CAACW,QAAQ,CAAEnB,KAAM,CAC3C;MACA,CACH;MACDS,QAAQ,EAAGA;IAAU,CACrB,CAAC;EAAA,CACK,CAAC;AAEX;AAEA,OAAO,SAASW,QAAQA,CAAE;EAAElC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAChD,oBACCJ,KAAA,CAACN,IAAI;IACJ4C,SAAS,EAAG1D,IAAI,CAAE,qBAAqB,EAAE;MACxC,UAAU,EAAE,CAAEwB;IACf,CAAE,CAAG;IACLmC,KAAK,EAAG1D,EAAE,CAAE,WAAY,CAAG;IAAAqD,QAAA,GAEzB9B,MAAM,iBACPN,IAAA,CAACI,YAAY;MAACC,QAAQ,EAAGA,QAAU;MAACC,MAAM,EAAGA;IAAQ,CAAE,CACvD,EACC,CAAEA,MAAM,iBAAIN,IAAA;MAAAoC,QAAA,EAAKrD,EAAE,CAAE,uBAAwB;IAAC,CAAK,CAAC;EAAA,CACjD,CAAC;AAET","ignoreList":[]}
1
+ {"version":3,"names":["clsx","__","DataForm","useDispatch","useSelect","store","coreDataStore","__experimentalVStack","VStack","useState","useMemo","useEffect","privateApis","editorPrivateApis","Page","usePostFields","unlock","jsx","_jsx","jsxs","_jsxs","PostCardPanel","fieldsWithBulkEditSupport","PostEditForm","postType","postId","ids","split","record","select","length","getEditedEntityRecord","multiEdits","setMultiEdits","editEntityRecord","fields","_fields","map","field","id","elements","filter","element","value","form","type","includes","combinedFields","label","children","direction","render","item","status","onChange","edits","Date","date","password","prev","spacing","data","PostEdit","className"],"sources":["@wordpress/edit-site/src/components/post-edit/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { DataForm } from '@wordpress/dataviews';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport usePostFields from '../post-fields';\nimport { unlock } from '../../lock-unlock';\n\nconst { PostCardPanel } = unlock( editorPrivateApis );\n\nconst fieldsWithBulkEditSupport = [\n\t'title',\n\t'status',\n\t'date',\n\t'author',\n\t'comment_status',\n];\n\nfunction PostEditForm( { postType, postId } ) {\n\tconst ids = useMemo( () => postId.split( ',' ), [ postId ] );\n\tconst { record } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\trecord:\n\t\t\t\t\tids.length === 1\n\t\t\t\t\t\t? select( coreDataStore ).getEditedEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\t\tids[ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ postType, ids ]\n\t);\n\tconst [ multiEdits, setMultiEdits ] = useState( {} );\n\tconst { editEntityRecord } = useDispatch( coreDataStore );\n\tconst { fields: _fields } = usePostFields();\n\tconst fields = useMemo(\n\t\t() =>\n\t\t\t_fields?.map( ( field ) => {\n\t\t\t\tif ( field.id === 'status' ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...field,\n\t\t\t\t\t\telements: field.elements.filter(\n\t\t\t\t\t\t\t( element ) => element.value !== 'trash'\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn field;\n\t\t\t} ),\n\t\t[ _fields ]\n\t);\n\n\tconst form = useMemo(\n\t\t() => ( {\n\t\t\ttype: 'panel',\n\t\t\tfields: [\n\t\t\t\t'featured_media',\n\t\t\t\t'title',\n\t\t\t\t'status_and_visibility',\n\t\t\t\t'author',\n\t\t\t\t'date',\n\t\t\t\t'slug',\n\t\t\t\t'parent',\n\t\t\t\t'comment_status',\n\t\t\t].filter(\n\t\t\t\t( field ) =>\n\t\t\t\t\tids.length === 1 ||\n\t\t\t\t\tfieldsWithBulkEditSupport.includes( field )\n\t\t\t),\n\t\t\tcombinedFields: [\n\t\t\t\t{\n\t\t\t\t\tid: 'status_and_visibility',\n\t\t\t\t\tlabel: __( 'Status & Visibility' ),\n\t\t\t\t\tchildren: [ 'status', 'password' ],\n\t\t\t\t\tdirection: 'vertical',\n\t\t\t\t\trender: ( { item } ) => item.status,\n\t\t\t\t},\n\t\t\t],\n\t\t} ),\n\t\t[ ids ]\n\t);\n\tconst onChange = ( edits ) => {\n\t\tfor ( const id of ids ) {\n\t\t\tif (\n\t\t\t\tedits.status &&\n\t\t\t\tedits.status !== 'future' &&\n\t\t\t\trecord?.status === 'future' &&\n\t\t\t\tnew Date( record.date ) > new Date()\n\t\t\t) {\n\t\t\t\tedits.date = null;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tedits.status &&\n\t\t\t\tedits.status === 'private' &&\n\t\t\t\trecord.password\n\t\t\t) {\n\t\t\t\tedits.password = '';\n\t\t\t}\n\t\t\teditEntityRecord( 'postType', postType, id, edits );\n\t\t\tif ( ids.length > 1 ) {\n\t\t\t\tsetMultiEdits( ( prev ) => ( {\n\t\t\t\t\t...prev,\n\t\t\t\t\t...edits,\n\t\t\t\t} ) );\n\t\t\t}\n\t\t}\n\t};\n\tuseEffect( () => {\n\t\tsetMultiEdits( {} );\n\t}, [ ids ] );\n\n\treturn (\n\t\t<VStack spacing={ 4 }>\n\t\t\t{ ids.length === 1 && (\n\t\t\t\t<PostCardPanel postType={ postType } postId={ ids[ 0 ] } />\n\t\t\t) }\n\t\t\t<DataForm\n\t\t\t\tdata={ ids.length === 1 ? record : multiEdits }\n\t\t\t\tfields={ fields }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n\nexport function PostEdit( { postType, postId } ) {\n\treturn (\n\t\t<Page\n\t\t\tclassName={ clsx( 'edit-site-post-edit', {\n\t\t\t\t'is-empty': ! postId,\n\t\t\t} ) }\n\t\t\tlabel={ __( 'Post Edit' ) }\n\t\t>\n\t\t\t{ postId && (\n\t\t\t\t<PostEditForm postType={ postType } postId={ postId } />\n\t\t\t) }\n\t\t\t{ ! postId && <p>{ __( 'Select a page to edit' ) }</p> }\n\t\t</Page>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,sBAAsB;AAC/C,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;AAC7D,SAASC,oBAAoB,IAAIC,MAAM,QAAQ,uBAAuB;AACtE,SAASC,QAAQ,EAAEC,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACjE,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,aAAa,MAAM,gBAAgB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE3C,MAAM;EAAEC;AAAc,CAAC,GAAGL,MAAM,CAAEH,iBAAkB,C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CAAC;MACN;IACD;EACD,CAAC;EACD5C,SAAS,CAAE,MAAM;IAChBsB,aAAa,CAAE,CAAC,CAAE,CAAC;EACpB,CAAC,EAAE,CAAEP,GAAG,CAAG,CAAC;EAEZ,oBACCN,KAAA,CAACZ,MAAM;IAACoD,OAAO,EAAG,CAAG;IAAAX,QAAA,GAClBvB,GAAG,CAACI,MAAM,KAAK,CAAC,iBACjBZ,IAAA,CAACG,aAAa;MAACG,QAAQ,EAAGA,QAAU;MAACC,MAAM,EAAGC,GAAG,CAAE,CAAC;IAAI,CAAE,CAC1D,eACDR,IAAA,CAAChB,QAAQ;MACR2D,IAAI,EAAGnC,GAAG,CAACI,MAAM,KAAK,CAAC,GAAGF,MAAM,GAAGI,UAAY;MAC/CG,MAAM,EAAGA,MAAQ;MACjBS,IAAI,EAAGA,IAAM;MACbU,QAAQ,EAAGA;IAAU,CACrB,CAAC;EAAA,CACK,CAAC;AAEX;AAEA,OAAO,SAASQ,QAAQA,CAAE;EAAEtC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAChD,oBACCL,KAAA,CAACN,IAAI;IACJiD,SAAS,EAAG/D,IAAI,CAAE,qBAAqB,EAAE;MACxC,UAAU,EAAE,CAAEyB;IACf,CAAE,CAAG;IACLuB,KAAK,EAAG/C,EAAE,CAAE,WAAY,CAAG;IAAAgD,QAAA,GAEzBxB,MAAM,iBACPP,IAAA,CAACK,YAAY;MAACC,QAAQ,EAAGA,QAAU;MAACC,MAAM,EAAGA;IAAQ,CAAE,CACvD,EACC,CAAEA,MAAM,iBAAIP,IAAA;MAAA+B,QAAA,EAAKhD,EAAE,CAAE,uBAAwB;IAAC,CAAK,CAAC;EAAA,CACjD,CAAC;AAET","ignoreList":[]}
@@ -6,77 +6,14 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { __, sprintf } from '@wordpress/i18n';
10
- import { decodeEntities } from '@wordpress/html-entities';
11
- import { featuredImageField, slugField, parentField } from '@wordpress/fields';
12
- import { createInterpolateElement, useMemo, useState } from '@wordpress/element';
13
- import { dateI18n, getDate, getSettings } from '@wordpress/date';
14
- import { trash, drafts, published, scheduled, pending, notAllowed, commentAuthorAvatar as authorIcon } from '@wordpress/icons';
9
+ import { __ } from '@wordpress/i18n';
10
+ import { featuredImageField, slugField, parentField, passwordField, statusField, commentStatusField, titleField, dateField } from '@wordpress/fields';
11
+ import { useMemo, useState } from '@wordpress/element';
12
+ import { commentAuthorAvatar as authorIcon } from '@wordpress/icons';
15
13
  import { __experimentalHStack as HStack, Icon } from '@wordpress/components';
16
14
  import { useSelect } from '@wordpress/data';
17
15
  import { useEntityRecords, store as coreStore } from '@wordpress/core-data';
18
-
19
- /**
20
- * Internal dependencies
21
- */
22
- import { LAYOUT_GRID, LAYOUT_TABLE, OPERATOR_IS_ANY } from '../../utils/constants';
23
- import { default as Link } from '../routes/link';
24
-
25
- // See https://github.com/WordPress/gutenberg/issues/55886
26
- // We do not support custom statutes at the moment.
27
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
28
- const STATUSES = [{
29
- value: 'draft',
30
- label: __('Draft'),
31
- icon: drafts,
32
- description: __('Not ready to publish.')
33
- }, {
34
- value: 'future',
35
- label: __('Scheduled'),
36
- icon: scheduled,
37
- description: __('Publish automatically on a chosen date.')
38
- }, {
39
- value: 'pending',
40
- label: __('Pending Review'),
41
- icon: pending,
42
- description: __('Waiting for review before publishing.')
43
- }, {
44
- value: 'private',
45
- label: __('Private'),
46
- icon: notAllowed,
47
- description: __('Only visible to site admins and editors.')
48
- }, {
49
- value: 'publish',
50
- label: __('Published'),
51
- icon: published,
52
- description: __('Visible to everyone.')
53
- }, {
54
- value: 'trash',
55
- label: __('Trash'),
56
- icon: trash
57
- }];
58
- const getFormattedDate = dateToDisplay => dateI18n(getSettings().formats.datetimeAbbreviated, getDate(dateToDisplay));
59
- function PostStatusField({
60
- item
61
- }) {
62
- const status = STATUSES.find(({
63
- value
64
- }) => value === item.status);
65
- const label = status?.label || item.status;
66
- const icon = status?.icon;
67
- return /*#__PURE__*/_jsxs(HStack, {
68
- alignment: "left",
69
- spacing: 0,
70
- children: [icon && /*#__PURE__*/_jsx("div", {
71
- className: "edit-site-post-list__status-icon",
72
- children: /*#__PURE__*/_jsx(Icon, {
73
- icon: icon
74
- })
75
- }), /*#__PURE__*/_jsx("span", {
76
- children: label
77
- })]
78
- });
79
- }
80
17
  function PostAuthorField({
81
18
  item
82
19
  }) {
@@ -117,69 +54,14 @@ function PostAuthorField({
117
54
  })]
118
55
  });
119
56
  }
120
- function usePostFields(viewType) {
57
+ function usePostFields() {
121
58
  const {
122
59
  records: authors,
123
60
  isResolving: isLoadingAuthors
124
61
  } = useEntityRecords('root', 'user', {
125
62
  per_page: -1
126
63
  });
127
- const {
128
- frontPageId,
129
- postsPageId
130
- } = useSelect(select => {
131
- const {
132
- getEntityRecord
133
- } = select(coreStore);
134
- const siteSettings = getEntityRecord('root', 'site');
135
- return {
136
- frontPageId: siteSettings?.page_on_front,
137
- postsPageId: siteSettings?.page_for_posts
138
- };
139
- }, []);
140
- const fields = useMemo(() => [featuredImageField, {
141
- label: __('Title'),
142
- id: 'title',
143
- type: 'text',
144
- getValue: ({
145
- item
146
- }) => typeof item.title === 'string' ? item.title : item.title?.raw,
147
- render: ({
148
- item
149
- }) => {
150
- const addLink = [LAYOUT_TABLE, LAYOUT_GRID].includes(viewType) && item.status !== 'trash';
151
- const renderedTitle = typeof item.title === 'string' ? item.title : item.title?.rendered;
152
- const title = addLink ? /*#__PURE__*/_jsx(Link, {
153
- params: {
154
- postId: item.id,
155
- postType: item.type,
156
- canvas: 'edit'
157
- },
158
- children: decodeEntities(renderedTitle) || __('(no title)')
159
- }) : /*#__PURE__*/_jsx("span", {
160
- children: decodeEntities(renderedTitle) || __('(no title)')
161
- });
162
- let suffix = '';
163
- if (item.id === frontPageId) {
164
- suffix = /*#__PURE__*/_jsx("span", {
165
- className: "edit-site-post-list__title-badge",
166
- children: __('Homepage')
167
- });
168
- } else if (item.id === postsPageId) {
169
- suffix = /*#__PURE__*/_jsx("span", {
170
- className: "edit-site-post-list__title-badge",
171
- children: __('Posts Page')
172
- });
173
- }
174
- return /*#__PURE__*/_jsxs(HStack, {
175
- className: "edit-site-post-list__title",
176
- alignment: "center",
177
- justify: "flex-start",
178
- children: [title, suffix]
179
- });
180
- },
181
- enableHiding: false
182
- }, {
64
+ const fields = useMemo(() => [featuredImageField, titleField, {
183
65
  label: __('Author'),
184
66
  id: 'author',
185
67
  type: 'integer',
@@ -196,84 +78,7 @@ function usePostFields(viewType) {
196
78
  const nameB = b._embedded?.author?.[0]?.name || '';
197
79
  return direction === 'asc' ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
198
80
  }
199
- }, {
200
- label: __('Status'),
201
- id: 'status',
202
- type: 'text',
203
- elements: STATUSES,
204
- render: PostStatusField,
205
- Edit: 'radio',
206
- enableSorting: false,
207
- filterBy: {
208
- operators: [OPERATOR_IS_ANY]
209
- }
210
- }, {
211
- label: __('Date'),
212
- id: 'date',
213
- type: 'datetime',
214
- render: ({
215
- item
216
- }) => {
217
- const isDraftOrPrivate = ['draft', 'private'].includes(item.status);
218
- if (isDraftOrPrivate) {
219
- return createInterpolateElement(sprintf(/* translators: %s: page creation or modification date. */
220
- __('<span>Modified: <time>%s</time></span>'), getFormattedDate(item.date)), {
221
- span: /*#__PURE__*/_jsx("span", {}),
222
- time: /*#__PURE__*/_jsx("time", {})
223
- });
224
- }
225
- const isScheduled = item.status === 'future';
226
- if (isScheduled) {
227
- return createInterpolateElement(sprintf(/* translators: %s: page creation date */
228
- __('<span>Scheduled: <time>%s</time></span>'), getFormattedDate(item.date)), {
229
- span: /*#__PURE__*/_jsx("span", {}),
230
- time: /*#__PURE__*/_jsx("time", {})
231
- });
232
- }
233
- const isPublished = item.status === 'publish';
234
- if (isPublished) {
235
- return createInterpolateElement(sprintf(/* translators: %s: page creation time */
236
- __('<span>Published: <time>%s</time></span>'), getFormattedDate(item.date)), {
237
- span: /*#__PURE__*/_jsx("span", {}),
238
- time: /*#__PURE__*/_jsx("time", {})
239
- });
240
- }
241
-
242
- // Pending posts show the modified date if it's newer.
243
- const dateToDisplay = getDate(item.modified) > getDate(item.date) ? item.modified : item.date;
244
- const isPending = item.status === 'pending';
245
- if (isPending) {
246
- return createInterpolateElement(sprintf(/* translators: %s: page creation or modification date. */
247
- __('<span>Modified: <time>%s</time></span>'), getFormattedDate(dateToDisplay)), {
248
- span: /*#__PURE__*/_jsx("span", {}),
249
- time: /*#__PURE__*/_jsx("time", {})
250
- });
251
- }
252
-
253
- // Unknow status.
254
- return /*#__PURE__*/_jsx("time", {
255
- children: getFormattedDate(item.date)
256
- });
257
- }
258
- }, slugField, parentField, {
259
- id: 'comment_status',
260
- label: __('Discussion'),
261
- type: 'text',
262
- Edit: 'radio',
263
- enableSorting: false,
264
- filterBy: {
265
- operators: []
266
- },
267
- elements: [{
268
- value: 'open',
269
- label: __('Open'),
270
- description: __('Visitors can add new comments and replies.')
271
- }, {
272
- value: 'closed',
273
- label: __('Closed'),
274
- description: __('Visitors cannot add new comments or replies. Existing comments remain visible.')
275
- }]
276
- }], [authors, viewType, frontPageId, postsPageId]);
81
+ }, statusField, dateField, slugField, parentField, commentStatusField, passwordField], [authors]);
277
82
  return {
278
83
  isLoading: isLoadingAuthors,
279
84
  fields
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","__","sprintf","decodeEntities","featuredImageField","slugField","parentField","createInterpolateElement","useMemo","useState","dateI18n","getDate","getSettings","trash","drafts","published","scheduled","pending","notAllowed","commentAuthorAvatar","authorIcon","__experimentalHStack","HStack","Icon","useSelect","useEntityRecords","store","coreStore","LAYOUT_GRID","LAYOUT_TABLE","OPERATOR_IS_ANY","default","Link","jsx","_jsx","jsxs","_jsxs","STATUSES","value","label","icon","description","getFormattedDate","dateToDisplay","formats","datetimeAbbreviated","PostStatusField","item","status","find","alignment","spacing","children","className","PostAuthorField","text","imageUrl","select","getUser","user","author","avatar_urls","name","isImageLoaded","setIsImageLoaded","onLoad","alt","src","usePostFields","viewType","records","authors","isResolving","isLoadingAuthors","per_page","frontPageId","postsPageId","getEntityRecord","siteSettings","page_on_front","page_for_posts","fields","id","type","getValue","title","raw","render","addLink","includes","renderedTitle","rendered","params","postId","postType","canvas","suffix","justify","enableHiding","elements","map","sort","a","b","direction","nameA","_embedded","nameB","localeCompare","Edit","enableSorting","filterBy","operators","isDraftOrPrivate","date","span","time","isScheduled","isPublished","modified","isPending","isLoading"],"sources":["@wordpress/edit-site/src/components/post-fields/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { featuredImageField, slugField, parentField } from '@wordpress/fields';\nimport {\n\tcreateInterpolateElement,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\nimport { dateI18n, getDate, getSettings } from '@wordpress/date';\nimport {\n\ttrash,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n\tcommentAuthorAvatar as authorIcon,\n} from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tOPERATOR_IS_ANY,\n} from '../../utils/constants';\nimport { default as Link } from '../routes/link';\n\n// See https://github.com/WordPress/gutenberg/issues/55886\n// We do not support custom statutes at the moment.\nconst STATUSES = [\n\t{\n\t\tvalue: 'draft',\n\t\tlabel: __( 'Draft' ),\n\t\ticon: drafts,\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tvalue: 'future',\n\t\tlabel: __( 'Scheduled' ),\n\t\ticon: scheduled,\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tvalue: 'pending',\n\t\tlabel: __( 'Pending Review' ),\n\t\ticon: pending,\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tvalue: 'private',\n\t\tlabel: __( 'Private' ),\n\t\ticon: notAllowed,\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tvalue: 'publish',\n\t\tlabel: __( 'Published' ),\n\t\ticon: published,\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n\t{ value: 'trash', label: __( 'Trash' ), icon: trash },\n];\n\nconst getFormattedDate = ( dateToDisplay ) =>\n\tdateI18n(\n\t\tgetSettings().formats.datetimeAbbreviated,\n\t\tgetDate( dateToDisplay )\n\t);\n\nfunction PostStatusField( { item } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction PostAuthorField( { item } ) {\n\tconst { text, imageUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser } = select( coreStore );\n\t\t\tconst user = getUser( item.author );\n\t\t\treturn {\n\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\ttext: user?.name,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction usePostFields( viewType ) {\n\tconst { records: authors, isResolving: isLoadingAuthors } =\n\t\tuseEntityRecords( 'root', 'user', { per_page: -1 } );\n\n\tconst { frontPageId, postsPageId } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tfrontPageId: siteSettings?.page_on_front,\n\t\t\tpostsPageId: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\tfeaturedImageField,\n\t\t\t{\n\t\t\t\tlabel: __( 'Title' ),\n\t\t\t\tid: 'title',\n\t\t\t\ttype: 'text',\n\t\t\t\tgetValue: ( { item } ) =>\n\t\t\t\t\ttypeof item.title === 'string'\n\t\t\t\t\t\t? item.title\n\t\t\t\t\t\t: item.title?.raw,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\tconst addLink =\n\t\t\t\t\t\t[ LAYOUT_TABLE, LAYOUT_GRID ].includes( viewType ) &&\n\t\t\t\t\t\titem.status !== 'trash';\n\t\t\t\t\tconst renderedTitle =\n\t\t\t\t\t\ttypeof item.title === 'string'\n\t\t\t\t\t\t\t? item.title\n\t\t\t\t\t\t\t: item.title?.rendered;\n\t\t\t\t\tconst title = addLink ? (\n\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\tpostId: item.id,\n\t\t\t\t\t\t\t\tpostType: item.type,\n\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ decodeEntities( renderedTitle ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t{ decodeEntities( renderedTitle ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t);\n\n\t\t\t\t\tlet suffix = '';\n\t\t\t\t\tif ( item.id === frontPageId ) {\n\t\t\t\t\t\tsuffix = (\n\t\t\t\t\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t\t\t\t\t{ __( 'Homepage' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if ( item.id === postsPageId ) {\n\t\t\t\t\t\tsuffix = (\n\t\t\t\t\t\t\t<span className=\"edit-site-post-list__title-badge\">\n\t\t\t\t\t\t\t\t{ __( 'Posts Page' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tclassName=\"edit-site-post-list__title\"\n\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t{ suffix }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tenableHiding: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\ttype: 'integer',\n\t\t\t\telements:\n\t\t\t\t\tauthors?.map( ( { id, name } ) => ( {\n\t\t\t\t\t\tvalue: id,\n\t\t\t\t\t\tlabel: name,\n\t\t\t\t\t} ) ) || [],\n\t\t\t\trender: PostAuthorField,\n\t\t\t\tsort: ( a, b, direction ) => {\n\t\t\t\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\t\t\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\t\t\t\treturn direction === 'asc'\n\t\t\t\t\t\t? nameA.localeCompare( nameB )\n\t\t\t\t\t\t: nameB.localeCompare( nameA );\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Status' ),\n\t\t\t\tid: 'status',\n\t\t\t\ttype: 'text',\n\t\t\t\telements: STATUSES,\n\t\t\t\trender: PostStatusField,\n\t\t\t\tEdit: 'radio',\n\t\t\t\tenableSorting: false,\n\t\t\t\tfilterBy: {\n\t\t\t\t\toperators: [ OPERATOR_IS_ANY ],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Date' ),\n\t\t\t\tid: 'date',\n\t\t\t\ttype: 'datetime',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\tconst isDraftOrPrivate = [ 'draft', 'private' ].includes(\n\t\t\t\t\t\titem.status\n\t\t\t\t\t);\n\t\t\t\t\tif ( isDraftOrPrivate ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation or modification date. */\n\t\t\t\t\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst isScheduled = item.status === 'future';\n\t\t\t\t\tif ( isScheduled ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation date */\n\t\t\t\t\t\t\t\t__( '<span>Scheduled: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst isPublished = item.status === 'publish';\n\t\t\t\t\tif ( isPublished ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation time */\n\t\t\t\t\t\t\t\t__( '<span>Published: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( item.date )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Pending posts show the modified date if it's newer.\n\t\t\t\t\tconst dateToDisplay =\n\t\t\t\t\t\tgetDate( item.modified ) > getDate( item.date )\n\t\t\t\t\t\t\t? item.modified\n\t\t\t\t\t\t\t: item.date;\n\n\t\t\t\t\tconst isPending = item.status === 'pending';\n\t\t\t\t\tif ( isPending ) {\n\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: page creation or modification date. */\n\t\t\t\t\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\t\t\t\t\tgetFormattedDate( dateToDisplay )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span />,\n\t\t\t\t\t\t\t\ttime: <time />,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Unknow status.\n\t\t\t\t\treturn <time>{ getFormattedDate( item.date ) }</time>;\n\t\t\t\t},\n\t\t\t},\n\t\t\tslugField,\n\t\t\tparentField,\n\t\t\t{\n\t\t\t\tid: 'comment_status',\n\t\t\t\tlabel: __( 'Discussion' ),\n\t\t\t\ttype: 'text',\n\t\t\t\tEdit: 'radio',\n\t\t\t\tenableSorting: false,\n\t\t\t\tfilterBy: {\n\t\t\t\t\toperators: [],\n\t\t\t\t},\n\t\t\t\telements: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'open',\n\t\t\t\t\t\tlabel: __( 'Open' ),\n\t\t\t\t\t\tdescription: __(\n\t\t\t\t\t\t\t'Visitors can add new comments and replies.'\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'closed',\n\t\t\t\t\t\tlabel: __( 'Closed' ),\n\t\t\t\t\t\tdescription: __(\n\t\t\t\t\t\t\t'Visitors cannot add new comments or replies. Existing comments remain visible.'\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t\t[ authors, viewType, frontPageId, postsPageId ]\n\t);\n\n\treturn {\n\t\tisLoading: isLoadingAuthors,\n\t\tfields,\n\t};\n}\n\nexport default usePostFields;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,kBAAkB,EAAEC,SAAS,EAAEC,WAAW,QAAQ,mBAAmB;AAC9E,SACCC,wBAAwB,EACxBC,OAAO,EACPC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,QAAQ,EAAEC,OAAO,EAAEC,WAAW,QAAQ,iBAAiB;AAChE,SACCC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,U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,CAAC;MACrBwC,WAAW,EAAExC,EAAE,CACd,gFACD;IACD,CAAC;EAEH,CAAC,CACD,EACD,CAAEsE,OAAO,EAAEF,QAAQ,EAAEM,WAAW,EAAEC,WAAW,CAC9C,CAAC;EAED,OAAO;IACN6C,SAAS,EAAEhD,gBAAgB;IAC3BQ;EACD,CAAC;AACF;AAEA,eAAeb,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["clsx","__","featuredImageField","slugField","parentField","passwordField","statusField","commentStatusField","titleField","dateField","useMemo","useState","commentAuthorAvatar","authorIcon","__experimentalHStack","HStack","Icon","useSelect","useEntityRecords","store","coreStore","jsx","_jsx","jsxs","_jsxs","PostAuthorField","item","text","imageUrl","select","getUser","user","author","avatar_urls","name","isImageLoaded","setIsImageLoaded","alignment","spacing","children","className","onLoad","alt","src","icon","usePostFields","records","authors","isResolving","isLoadingAuthors","per_page","fields","label","id","type","elements","map","value","render","sort","a","b","direction","nameA","_embedded","nameB","localeCompare","isLoading"],"sources":["@wordpress/edit-site/src/components/post-fields/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tfeaturedImageField,\n\tslugField,\n\tparentField,\n\tpasswordField,\n\tstatusField,\n\tcommentStatusField,\n\ttitleField,\n\tdateField,\n} from '@wordpress/fields';\nimport { useMemo, useState } from '@wordpress/element';\nimport { commentAuthorAvatar as authorIcon } from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\n\nfunction PostAuthorField( { item } ) {\n\tconst { text, imageUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser } = select( coreStore );\n\t\t\tconst user = getUser( item.author );\n\t\t\treturn {\n\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\ttext: user?.name,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction usePostFields() {\n\tconst { records: authors, isResolving: isLoadingAuthors } =\n\t\tuseEntityRecords( 'root', 'user', { per_page: -1 } );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\tfeaturedImageField,\n\t\t\ttitleField,\n\t\t\t{\n\t\t\t\tlabel: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\ttype: 'integer',\n\t\t\t\telements:\n\t\t\t\t\tauthors?.map( ( { id, name } ) => ( {\n\t\t\t\t\t\tvalue: id,\n\t\t\t\t\t\tlabel: name,\n\t\t\t\t\t} ) ) || [],\n\t\t\t\trender: PostAuthorField,\n\t\t\t\tsort: ( a, b, direction ) => {\n\t\t\t\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\t\t\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\t\t\t\treturn direction === 'asc'\n\t\t\t\t\t\t? nameA.localeCompare( nameB )\n\t\t\t\t\t\t: nameB.localeCompare( nameA );\n\t\t\t\t},\n\t\t\t},\n\t\t\tstatusField,\n\t\t\tdateField,\n\t\t\tslugField,\n\t\t\tparentField,\n\t\t\tcommentStatusField,\n\t\t\tpasswordField,\n\t\t],\n\t\t[ authors ]\n\t);\n\n\treturn {\n\t\tisLoading: isLoadingAuthors,\n\t\tfields,\n\t};\n}\n\nexport default usePostFields;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,kBAAkB,EAClBC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,kBAAkB,EAClBC,UAAU,EACVC,SAAS,QACH,mBAAmB;AAC1B,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,mBAAmB,IAAIC,UAAU,QAAQ,kBAAkB;AACpE,SAASC,oBAAoB,IAAIC,MAAM,EAAEC,IAAI,QAAQ,uBAAuB;AAC5E,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,gBAAgB,EAAEC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE5E,SAASC,eAAeA,CAAE;EAAEC;AAAK,CAAC,EAAG;EACpC,MAAM;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAGX,SAAS,CACjCY,MAAM,IAAM;IACb,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM,CAAET,SAAU,CAAC;IACvC,MAAMW,IAAI,GAAGD,OAAO,CAAEJ,IAAI,CAACM,MAAO,CAAC;IACnC,OAAO;MACNJ,QAAQ,EAAEG,IAAI,EAAEE,WAAW,GAAI,EAAE,CAAE;MACnCN,IAAI,EAAEI,IAAI,EAAEG;IACb,CAAC;EACF,CAAC,EACD,CAAER,IAAI,CACP,CAAC;EACD,MAAM,CAAES,aAAa,EAAEC,gBAAgB,CAAE,GAAGzB,QAAQ,CAAE,KA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EAAEjC,eAAe;IACvBkC,IAAI,EAAEA,CAAEC,CAAC,EAAEC,CAAC,EAAEC,SAAS,KAAM;MAC5B,MAAMC,KAAK,GAAGH,CAAC,CAACI,SAAS,EAAEhC,MAAM,GAAI,CAAC,CAAE,EAAEE,IAAI,IAAI,EAAE;MACpD,MAAM+B,KAAK,GAAGJ,CAAC,CAACG,SAAS,EAAEhC,MAAM,GAAI,CAAC,CAAE,EAAEE,IAAI,IAAI,EAAE;MAEpD,OAAO4B,SAAS,KAAK,KAAK,GACvBC,KAAK,CAACG,aAAa,CAAED,KAAM,CAAC,GAC5BA,KAAK,CAACC,aAAa,CAAEH,KAAM,CAAC;IAChC;EACD,CAAC,EACDzD,WAAW,EACXG,SAAS,EACTN,SAAS,EACTC,WAAW,EACXG,kBAAkB,EAClBF,aAAa,CACb,EACD,CAAE0C,OAAO,CACV,CAAC;EAED,OAAO;IACNoB,SAAS,EAAElB,gBAAgB;IAC3BE;EACD,CAAC;AACF;AAEA,eAAeN,aAAa","ignoreList":[]}
@@ -199,7 +199,7 @@ export default function PostList({
199
199
  const {
200
200
  isLoading: isLoadingFields,
201
201
  fields: _fields
202
- } = usePostFields(view.type);
202
+ } = usePostFields();
203
203
  const fields = useMemo(() => {
204
204
  const activeViewFilters = getActiveViewFilters(defaultViews, activeView).map(({
205
205
  field
@@ -344,6 +344,16 @@ export default function PostList({
344
344
  onChangeView: setView,
345
345
  selection: selection,
346
346
  onChangeSelection: onChangeSelection,
347
+ isItemClickable: item => item.status !== 'trash',
348
+ onClickItem: ({
349
+ id
350
+ }) => {
351
+ history.push({
352
+ postId: id,
353
+ postType,
354
+ canvas: 'edit'
355
+ });
356
+ },
347
357
  getItemId: getItemId,
348
358
  defaultLayouts: defaultLayouts,
349
359
  header: window.__experimentalQuickEditDataViews && view.type !== LAYOUT_LIST && postType === 'page' && /*#__PURE__*/_jsx(Button, {
@@ -1 +1 @@
1
- {"version":3,"names":["Button","store","coreStore","privateApis","coreDataPrivateApis","useState","useMemo","useCallback","useEffect","routerPrivateApis","useSelect","useDispatch","DataViews","filterSortAndPaginate","editorPrivateApis","__","drawerRight","Page","useDefaultViews","defaultLayouts","OPERATOR_IS_ANY","OPERATOR_IS_NONE","LAYOUT_LIST","AddNewPostModal","unlock","useEditPostAction","usePrevious","usePostFields","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","usePostActions","useLocation","useHistory","useEntityRecordsWithPermissions","EMPTY_ARRAY","getDefaultView","defaultViews","activeView","find","slug","view","getCustomView","editedEntityRecord","content","undefined","JSON","parse","layout","type","useView","postType","params","isCustom","history","editEntityRecord","select","getEditedEntityRecord","Number","setView","initialView","_getCustomView","_getDefaultView","setViewWithUrlUpdate","newView","getLocationWithParams","push","id","stringify","prevView","DEFAULT_STATUSES","getItemId","item","toString","PostList","_postId$split","_data$map","_usePrevious","location","postId","quickEdit","selection","setSelection","split","onChangeSelection","items","_params$isCustom","join","getActiveViewFilters","views","match","_found$filters","found","filters","isLoading","isLoadingFields","fields","_fields","activeViewFilters","map","field","elements","includes","queryArgs","forEach","filter","operator","status","value","author","author_exclude","per_page","perPage","page","_embed","order","sort","direction","orderby","search","records","isResolving","isLoadingData","totalItems","totalPages","data","ids","record","prevIds","deletedIds","postIdWasDeleted","paginationInfo","labels","canCreateRecord","getPostType","canUser","kind","name","postTypeActions","context","editAction","actions","showAddPostModal","setShowAddPostModal","openModal","closeModal","handleNewPage","canvas","title","add_new_item","children","variant","onClick","__next40pxDefaultSize","onSave","onClose","onChangeView","header","window","__experimentalQuickEditDataViews","size","isPressed","icon","label"],"sources":["@wordpress/edit-site/src/components/post-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport {\n\tstore as coreStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { drawerRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport {\n\tuseDefaultViews,\n\tdefaultLayouts,\n} from '../sidebar-dataviews/default-views';\nimport {\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport AddNewPostModal from '../add-new-post';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { usePrevious } from '@wordpress/compose';\nimport usePostFields from '../post-fields';\n\nconst { usePostActions } = unlock( editorPrivateApis );\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( coreDataPrivateApis );\nconst EMPTY_ARRAY = [];\n\nconst getDefaultView = ( defaultViews, activeView ) => {\n\treturn defaultViews.find( ( { slug } ) => slug === activeView )?.view;\n};\n\nconst getCustomView = ( editedEntityRecord ) => {\n\tif ( ! editedEntityRecord?.content ) {\n\t\treturn undefined;\n\t}\n\n\tconst content = JSON.parse( editedEntityRecord.content );\n\tif ( ! content ) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\t...content,\n\t\tlayout: defaultLayouts[ content.type ]?.layout,\n\t};\n};\n\n/**\n * This function abstracts working with default & custom views by\n * providing a [ state, setState ] tuple based on the URL parameters.\n *\n * Consumers use the provided tuple to work with state\n * and don't have to deal with the specifics of default & custom views.\n *\n * @param {string} postType Post type to retrieve default views for.\n * @return {Array} The [ state, setState ] tuple.\n */\nfunction useView( postType ) {\n\tconst {\n\t\tparams: { activeView = 'all', isCustom = 'false', layout },\n\t} = useLocation();\n\tconst history = useHistory();\n\n\tconst defaultViews = useDefaultViews( { postType } );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst editedEntityRecord = useSelect(\n\t\t( select ) => {\n\t\t\tif ( isCustom !== 'true' ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\t\treturn getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_dataviews',\n\t\t\t\tNumber( activeView )\n\t\t\t);\n\t\t},\n\t\t[ activeView, isCustom ]\n\t);\n\tconst [ view, setView ] = useState( () => {\n\t\tlet initialView;\n\t\tif ( isCustom === 'true' ) {\n\t\t\tinitialView = getCustomView( editedEntityRecord ) ?? {\n\t\t\t\ttype: layout ?? LAYOUT_LIST,\n\t\t\t};\n\t\t} else {\n\t\t\tinitialView = getDefaultView( defaultViews, activeView ) ?? {\n\t\t\t\ttype: layout ?? LAYOUT_LIST,\n\t\t\t};\n\t\t}\n\n\t\tconst type = layout ?? initialView.type;\n\t\treturn {\n\t\t\t...initialView,\n\t\t\ttype,\n\t\t};\n\t} );\n\n\tconst setViewWithUrlUpdate = useCallback(\n\t\t( newView ) => {\n\t\t\tconst { params } = history.getLocationWithParams();\n\n\t\t\tif ( newView.type === LAYOUT_LIST && ! params?.layout ) {\n\t\t\t\t// Skip updating the layout URL param if\n\t\t\t\t// it is not present and the newView.type is LAYOUT_LIST.\n\t\t\t} else if ( newView.type !== params?.layout ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tsetView( newView );\n\n\t\t\tif ( isCustom === 'true' && editedEntityRecord?.id ) {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_dataviews',\n\t\t\t\t\teditedEntityRecord?.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: JSON.stringify( newView ),\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, isCustom, editEntityRecord, editedEntityRecord?.id ]\n\t);\n\n\t// When layout URL param changes, update the view type\n\t// without affecting any other config.\n\tuseEffect( () => {\n\t\tsetView( ( prevView ) => ( {\n\t\t\t...prevView,\n\t\t\ttype: layout ?? LAYOUT_LIST,\n\t\t} ) );\n\t}, [ layout ] );\n\n\t// When activeView or isCustom URL parameters change, reset the view.\n\tuseEffect( () => {\n\t\tlet newView;\n\t\tif ( isCustom === 'true' ) {\n\t\t\tnewView = getCustomView( editedEntityRecord );\n\t\t} else {\n\t\t\tnewView = getDefaultView( defaultViews, activeView );\n\t\t}\n\n\t\tif ( newView ) {\n\t\t\tconst type = layout ?? newView.type;\n\t\t\tsetView( {\n\t\t\t\t...newView,\n\t\t\t\ttype,\n\t\t\t} );\n\t\t}\n\t}, [ activeView, isCustom, layout, defaultViews, editedEntityRecord ] );\n\n\treturn [ view, setViewWithUrlUpdate, setViewWithUrlUpdate ];\n}\n\nconst DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'.\n\nfunction getItemId( item ) {\n\treturn item.id.toString();\n}\n\nexport default function PostList( { postType } ) {\n\tconst [ view, setView ] = useView( postType );\n\tconst defaultViews = useDefaultViews( { postType } );\n\tconst history = useHistory();\n\tconst location = useLocation();\n\tconst {\n\t\tpostId,\n\t\tquickEdit = false,\n\t\tisCustom,\n\t\tactiveView = 'all',\n\t} = location.params;\n\tconst [ selection, setSelection ] = useState( postId?.split( ',' ) ?? [] );\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tconst { params } = history.getLocationWithParams();\n\t\t\tif ( ( params.isCustom ?? 'false' ) === 'false' ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.join( ',' ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\tconst getActiveViewFilters = ( views, match ) => {\n\t\tconst found = views.find( ( { slug } ) => slug === match );\n\t\treturn found?.filters ?? [];\n\t};\n\n\tconst { isLoading: isLoadingFields, fields: _fields } = usePostFields(\n\t\tview.type\n\t);\n\tconst fields = useMemo( () => {\n\t\tconst activeViewFilters = getActiveViewFilters(\n\t\t\tdefaultViews,\n\t\t\tactiveView\n\t\t).map( ( { field } ) => field );\n\t\treturn _fields.map( ( field ) => ( {\n\t\t\t...field,\n\t\t\telements: activeViewFilters.includes( field.id )\n\t\t\t\t? []\n\t\t\t\t: field.elements,\n\t\t} ) );\n\t}, [ _fields, defaultViews, activeView ] );\n\n\tconst queryArgs = useMemo( () => {\n\t\tconst filters = {};\n\t\tview.filters?.forEach( ( filter ) => {\n\t\t\tif (\n\t\t\t\tfilter.field === 'status' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.status = filter.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.author = filter.value;\n\t\t\t} else if (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_NONE\n\t\t\t) {\n\t\t\t\tfilters.author_exclude = filter.value;\n\t\t\t}\n\t\t} );\n\n\t\t// The bundled views want data filtered without displaying the filter.\n\t\tconst activeViewFilters = getActiveViewFilters(\n\t\t\tdefaultViews,\n\t\t\tactiveView\n\t\t);\n\t\tactiveViewFilters.forEach( ( filter ) => {\n\t\t\tif (\n\t\t\t\tfilter.field === 'status' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.status = filter.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.author = filter.value;\n\t\t\t} else if (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_NONE\n\t\t\t) {\n\t\t\t\tfilters.author_exclude = filter.value;\n\t\t\t}\n\t\t} );\n\n\t\t// We want to provide a different default item for the status filter\n\t\t// than the REST API provides.\n\t\tif ( ! filters.status || filters.status === '' ) {\n\t\t\tfilters.status = DEFAULT_STATUSES;\n\t\t}\n\n\t\treturn {\n\t\t\tper_page: view.perPage,\n\t\t\tpage: view.page,\n\t\t\t_embed: 'author',\n\t\t\torder: view.sort?.direction,\n\t\t\torderby: view.sort?.field,\n\t\t\tsearch: view.search,\n\t\t\t...filters,\n\t\t};\n\t}, [ view, activeView, defaultViews ] );\n\tconst {\n\t\trecords,\n\t\tisResolving: isLoadingData,\n\t\ttotalItems,\n\t\ttotalPages,\n\t} = useEntityRecordsWithPermissions( 'postType', postType, queryArgs );\n\n\t// The REST API sort the authors by ID, but we want to sort them by name.\n\tconst data = useMemo( () => {\n\t\tif ( ! isLoadingFields && view?.sort?.field === 'author' ) {\n\t\t\treturn filterSortAndPaginate(\n\t\t\t\trecords,\n\t\t\t\t{ sort: { ...view.sort } },\n\t\t\t\tfields\n\t\t\t).data;\n\t\t}\n\n\t\treturn records;\n\t}, [ records, fields, isLoadingFields, view?.sort ] );\n\n\tconst ids = data?.map( ( record ) => getItemId( record ) ) ?? [];\n\tconst prevIds = usePrevious( ids ) ?? [];\n\tconst deletedIds = prevIds.filter( ( id ) => ! ids.includes( id ) );\n\tconst postIdWasDeleted = deletedIds.includes( postId );\n\n\tuseEffect( () => {\n\t\tif ( postIdWasDeleted ) {\n\t\t\thistory.push( {\n\t\t\t\t...history.getLocationWithParams().params,\n\t\t\t\tpostId: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ postIdWasDeleted, history ] );\n\n\tconst paginationInfo = useMemo(\n\t\t() => ( {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t} ),\n\t\t[ totalItems, totalPages ]\n\t);\n\n\tconst { labels, canCreateRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t\tcanCreateRecord: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst [ showAddPostModal, setShowAddPostModal ] = useState( false );\n\n\tconst openModal = () => setShowAddPostModal( true );\n\tconst closeModal = () => setShowAddPostModal( false );\n\tconst handleNewPage = ( { type, id } ) => {\n\t\thistory.push( {\n\t\t\tpostId: id,\n\t\t\tpostType: type,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t\tcloseModal();\n\t};\n\n\treturn (\n\t\t<Page\n\t\t\ttitle={ labels?.name }\n\t\t\tactions={\n\t\t\t\tlabels?.add_new_item &&\n\t\t\t\tcanCreateRecord && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ openModal }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ labels.add_new_item }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{ showAddPostModal && (\n\t\t\t\t\t\t\t<AddNewPostModal\n\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\tonSave={ handleNewPage }\n\t\t\t\t\t\t\t\tonClose={ closeModal }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView + isCustom }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data || EMPTY_ARRAY }\n\t\t\t\tisLoading={ isLoadingData || isLoadingFields }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ setView }\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\theader={\n\t\t\t\t\twindow.__experimentalQuickEditDataViews &&\n\t\t\t\t\tview.type !== LAYOUT_LIST &&\n\t\t\t\t\tpostType === 'page' && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tisPressed={ quickEdit }\n\t\t\t\t\t\t\ticon={ drawerRight }\n\t\t\t\t\t\t\tlabel={ __( 'Details' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\t\t...location.params,\n\t\t\t\t\t\t\t\t\tquickEdit: quickEdit ? undefined : true,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SACCC,KAAK,IAAIC,SAAS,EAClBC,WAAW,IAAIC,mBAAmB,QAC5B,sBAAsB;AAC7B,SAASC,QAAQ,EAAEC,OAAO,EAAEC,WAAW,EAAEC,SAAS,QAAQ,oBAAoB;AAC9E,SAASL,WAAW,IAAIM,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,qBAAqB,QAAQ,sBAAsB;AACvE,SAASV,WAAW,IAAIW,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,kBAAkB;;AAE9C;AACA;AACA;AACA,OAAOC,IAAI,MAAM,SAAS;AAC1B,SACCC,eAAe,EACfC,cAAc,QAC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D,SAAS,EAAG4B,aAAa,IAAI3B,eAAiB;MAC9CtD,IAAI,EAAGA,IAAM;MACbmH,YAAY,EAAGjG,OAAS;MACxBsB,SAAS,EAAGA,SAAW;MACvBG,iBAAiB,EAAGA,iBAAmB;MACvCb,SAAS,EAAGA,SAAW;MACvBvD,cAAc,EAAGA,cAAgB;MACjC6I,MAAM,EACLC,MAAM,CAACC,gCAAgC,IACvCtH,IAAI,CAACQ,IAAI,KAAK9B,WAAW,IACzBgC,QAAQ,KAAK,MAAM,iBAClBzB,IAAA,CAAC7B,MAAM;QACNmK,IAAI,EAAC,SAAS;QACdC,SAAS,EAAGjF,SAAW;QACvBkF,IAAI,EAAGrJ,WAAa;QACpBsJ,KAAK,EAAGvJ,EAAE,CAAE,SAAU,CAAG;QACzB4I,OAAO,EAAGA,CAAA,KAAM;UACflG,OAAO,CAACY,IAAI,CAAE;YACb,GAAGY,QAAQ,CAAC1B,MAAM;YAClB4B,SAAS,EAAEA,SAAS,GAAGnC,SAAS,GAAG;UACpC,CAAE,CAAC;QACJ;MAAG,CACH;IAEF,GA7BKP,UAAU,GAAGe,QA8BnB;EAAC,CACG,CAAC;AAET","ignoreList":[]}
1
+ {"version":3,"names":["Button","store","coreStore","privateApis","coreDataPrivateApis","useState","useMemo","useCallback","useEffect","routerPrivateApis","useSelect","useDispatch","DataViews","filterSortAndPaginate","editorPrivateApis","__","drawerRight","Page","useDefaultViews","defaultLayouts","OPERATOR_IS_ANY","OPERATOR_IS_NONE","LAYOUT_LIST","AddNewPostModal","unlock","useEditPostAction","usePrevious","usePostFields","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","usePostActions","useLocation","useHistory","useEntityRecordsWithPermissions","EMPTY_ARRAY","getDefaultView","defaultViews","activeView","find","slug","view","getCustomView","editedEntityRecord","content","undefined","JSON","parse","layout","type","useView","postType","params","isCustom","history","editEntityRecord","select","getEditedEntityRecord","Number","setView","initialView","_getCustomView","_getDefaultView","setViewWithUrlUpdate","newView","getLocationWithParams","push","id","stringify","prevView","DEFAULT_STATUSES","getItemId","item","toString","PostList","_postId$split","_data$map","_usePrevious","location","postId","quickEdit","selection","setSelection","split","onChangeSelection","items","_params$isCustom","join","getActiveViewFilters","views","match","_found$filters","found","filters","isLoading","isLoadingFields","fields","_fields","activeViewFilters","map","field","elements","includes","queryArgs","forEach","filter","operator","status","value","author","author_exclude","per_page","perPage","page","_embed","order","sort","direction","orderby","search","records","isResolving","isLoadingData","totalItems","totalPages","data","ids","record","prevIds","deletedIds","postIdWasDeleted","paginationInfo","labels","canCreateRecord","getPostType","canUser","kind","name","postTypeActions","context","editAction","actions","showAddPostModal","setShowAddPostModal","openModal","closeModal","handleNewPage","canvas","title","add_new_item","children","variant","onClick","__next40pxDefaultSize","onSave","onClose","onChangeView","isItemClickable","onClickItem","header","window","__experimentalQuickEditDataViews","size","isPressed","icon","label"],"sources":["@wordpress/edit-site/src/components/post-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport {\n\tstore as coreStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { drawerRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport {\n\tuseDefaultViews,\n\tdefaultLayouts,\n} from '../sidebar-dataviews/default-views';\nimport {\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport AddNewPostModal from '../add-new-post';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { usePrevious } from '@wordpress/compose';\nimport usePostFields from '../post-fields';\n\nconst { usePostActions } = unlock( editorPrivateApis );\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( coreDataPrivateApis );\nconst EMPTY_ARRAY = [];\n\nconst getDefaultView = ( defaultViews, activeView ) => {\n\treturn defaultViews.find( ( { slug } ) => slug === activeView )?.view;\n};\n\nconst getCustomView = ( editedEntityRecord ) => {\n\tif ( ! editedEntityRecord?.content ) {\n\t\treturn undefined;\n\t}\n\n\tconst content = JSON.parse( editedEntityRecord.content );\n\tif ( ! content ) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\t...content,\n\t\tlayout: defaultLayouts[ content.type ]?.layout,\n\t};\n};\n\n/**\n * This function abstracts working with default & custom views by\n * providing a [ state, setState ] tuple based on the URL parameters.\n *\n * Consumers use the provided tuple to work with state\n * and don't have to deal with the specifics of default & custom views.\n *\n * @param {string} postType Post type to retrieve default views for.\n * @return {Array} The [ state, setState ] tuple.\n */\nfunction useView( postType ) {\n\tconst {\n\t\tparams: { activeView = 'all', isCustom = 'false', layout },\n\t} = useLocation();\n\tconst history = useHistory();\n\n\tconst defaultViews = useDefaultViews( { postType } );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst editedEntityRecord = useSelect(\n\t\t( select ) => {\n\t\t\tif ( isCustom !== 'true' ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\t\treturn getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_dataviews',\n\t\t\t\tNumber( activeView )\n\t\t\t);\n\t\t},\n\t\t[ activeView, isCustom ]\n\t);\n\tconst [ view, setView ] = useState( () => {\n\t\tlet initialView;\n\t\tif ( isCustom === 'true' ) {\n\t\t\tinitialView = getCustomView( editedEntityRecord ) ?? {\n\t\t\t\ttype: layout ?? LAYOUT_LIST,\n\t\t\t};\n\t\t} else {\n\t\t\tinitialView = getDefaultView( defaultViews, activeView ) ?? {\n\t\t\t\ttype: layout ?? LAYOUT_LIST,\n\t\t\t};\n\t\t}\n\n\t\tconst type = layout ?? initialView.type;\n\t\treturn {\n\t\t\t...initialView,\n\t\t\ttype,\n\t\t};\n\t} );\n\n\tconst setViewWithUrlUpdate = useCallback(\n\t\t( newView ) => {\n\t\t\tconst { params } = history.getLocationWithParams();\n\n\t\t\tif ( newView.type === LAYOUT_LIST && ! params?.layout ) {\n\t\t\t\t// Skip updating the layout URL param if\n\t\t\t\t// it is not present and the newView.type is LAYOUT_LIST.\n\t\t\t} else if ( newView.type !== params?.layout ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tsetView( newView );\n\n\t\t\tif ( isCustom === 'true' && editedEntityRecord?.id ) {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_dataviews',\n\t\t\t\t\teditedEntityRecord?.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: JSON.stringify( newView ),\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, isCustom, editEntityRecord, editedEntityRecord?.id ]\n\t);\n\n\t// When layout URL param changes, update the view type\n\t// without affecting any other config.\n\tuseEffect( () => {\n\t\tsetView( ( prevView ) => ( {\n\t\t\t...prevView,\n\t\t\ttype: layout ?? LAYOUT_LIST,\n\t\t} ) );\n\t}, [ layout ] );\n\n\t// When activeView or isCustom URL parameters change, reset the view.\n\tuseEffect( () => {\n\t\tlet newView;\n\t\tif ( isCustom === 'true' ) {\n\t\t\tnewView = getCustomView( editedEntityRecord );\n\t\t} else {\n\t\t\tnewView = getDefaultView( defaultViews, activeView );\n\t\t}\n\n\t\tif ( newView ) {\n\t\t\tconst type = layout ?? newView.type;\n\t\t\tsetView( {\n\t\t\t\t...newView,\n\t\t\t\ttype,\n\t\t\t} );\n\t\t}\n\t}, [ activeView, isCustom, layout, defaultViews, editedEntityRecord ] );\n\n\treturn [ view, setViewWithUrlUpdate, setViewWithUrlUpdate ];\n}\n\nconst DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'.\n\nfunction getItemId( item ) {\n\treturn item.id.toString();\n}\n\nexport default function PostList( { postType } ) {\n\tconst [ view, setView ] = useView( postType );\n\tconst defaultViews = useDefaultViews( { postType } );\n\tconst history = useHistory();\n\tconst location = useLocation();\n\tconst {\n\t\tpostId,\n\t\tquickEdit = false,\n\t\tisCustom,\n\t\tactiveView = 'all',\n\t} = location.params;\n\tconst [ selection, setSelection ] = useState( postId?.split( ',' ) ?? [] );\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tconst { params } = history.getLocationWithParams();\n\t\t\tif ( ( params.isCustom ?? 'false' ) === 'false' ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.join( ',' ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\tconst getActiveViewFilters = ( views, match ) => {\n\t\tconst found = views.find( ( { slug } ) => slug === match );\n\t\treturn found?.filters ?? [];\n\t};\n\n\tconst { isLoading: isLoadingFields, fields: _fields } = usePostFields();\n\tconst fields = useMemo( () => {\n\t\tconst activeViewFilters = getActiveViewFilters(\n\t\t\tdefaultViews,\n\t\t\tactiveView\n\t\t).map( ( { field } ) => field );\n\t\treturn _fields.map( ( field ) => ( {\n\t\t\t...field,\n\t\t\telements: activeViewFilters.includes( field.id )\n\t\t\t\t? []\n\t\t\t\t: field.elements,\n\t\t} ) );\n\t}, [ _fields, defaultViews, activeView ] );\n\n\tconst queryArgs = useMemo( () => {\n\t\tconst filters = {};\n\t\tview.filters?.forEach( ( filter ) => {\n\t\t\tif (\n\t\t\t\tfilter.field === 'status' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.status = filter.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.author = filter.value;\n\t\t\t} else if (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_NONE\n\t\t\t) {\n\t\t\t\tfilters.author_exclude = filter.value;\n\t\t\t}\n\t\t} );\n\n\t\t// The bundled views want data filtered without displaying the filter.\n\t\tconst activeViewFilters = getActiveViewFilters(\n\t\t\tdefaultViews,\n\t\t\tactiveView\n\t\t);\n\t\tactiveViewFilters.forEach( ( filter ) => {\n\t\t\tif (\n\t\t\t\tfilter.field === 'status' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.status = filter.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.author = filter.value;\n\t\t\t} else if (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_NONE\n\t\t\t) {\n\t\t\t\tfilters.author_exclude = filter.value;\n\t\t\t}\n\t\t} );\n\n\t\t// We want to provide a different default item for the status filter\n\t\t// than the REST API provides.\n\t\tif ( ! filters.status || filters.status === '' ) {\n\t\t\tfilters.status = DEFAULT_STATUSES;\n\t\t}\n\n\t\treturn {\n\t\t\tper_page: view.perPage,\n\t\t\tpage: view.page,\n\t\t\t_embed: 'author',\n\t\t\torder: view.sort?.direction,\n\t\t\torderby: view.sort?.field,\n\t\t\tsearch: view.search,\n\t\t\t...filters,\n\t\t};\n\t}, [ view, activeView, defaultViews ] );\n\tconst {\n\t\trecords,\n\t\tisResolving: isLoadingData,\n\t\ttotalItems,\n\t\ttotalPages,\n\t} = useEntityRecordsWithPermissions( 'postType', postType, queryArgs );\n\n\t// The REST API sort the authors by ID, but we want to sort them by name.\n\tconst data = useMemo( () => {\n\t\tif ( ! isLoadingFields && view?.sort?.field === 'author' ) {\n\t\t\treturn filterSortAndPaginate(\n\t\t\t\trecords,\n\t\t\t\t{ sort: { ...view.sort } },\n\t\t\t\tfields\n\t\t\t).data;\n\t\t}\n\n\t\treturn records;\n\t}, [ records, fields, isLoadingFields, view?.sort ] );\n\n\tconst ids = data?.map( ( record ) => getItemId( record ) ) ?? [];\n\tconst prevIds = usePrevious( ids ) ?? [];\n\tconst deletedIds = prevIds.filter( ( id ) => ! ids.includes( id ) );\n\tconst postIdWasDeleted = deletedIds.includes( postId );\n\n\tuseEffect( () => {\n\t\tif ( postIdWasDeleted ) {\n\t\t\thistory.push( {\n\t\t\t\t...history.getLocationWithParams().params,\n\t\t\t\tpostId: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ postIdWasDeleted, history ] );\n\n\tconst paginationInfo = useMemo(\n\t\t() => ( {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t} ),\n\t\t[ totalItems, totalPages ]\n\t);\n\n\tconst { labels, canCreateRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t\tcanCreateRecord: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst [ showAddPostModal, setShowAddPostModal ] = useState( false );\n\n\tconst openModal = () => setShowAddPostModal( true );\n\tconst closeModal = () => setShowAddPostModal( false );\n\tconst handleNewPage = ( { type, id } ) => {\n\t\thistory.push( {\n\t\t\tpostId: id,\n\t\t\tpostType: type,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t\tcloseModal();\n\t};\n\n\treturn (\n\t\t<Page\n\t\t\ttitle={ labels?.name }\n\t\t\tactions={\n\t\t\t\tlabels?.add_new_item &&\n\t\t\t\tcanCreateRecord && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ openModal }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ labels.add_new_item }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{ showAddPostModal && (\n\t\t\t\t\t\t\t<AddNewPostModal\n\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\tonSave={ handleNewPage }\n\t\t\t\t\t\t\t\tonClose={ closeModal }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView + isCustom }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data || EMPTY_ARRAY }\n\t\t\t\tisLoading={ isLoadingData || isLoadingFields }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ setView }\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ ( item ) => item.status !== 'trash' }\n\t\t\t\tonClickItem={ ( { id } ) => {\n\t\t\t\t\thistory.push( {\n\t\t\t\t\t\tpostId: id,\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\theader={\n\t\t\t\t\twindow.__experimentalQuickEditDataViews &&\n\t\t\t\t\tview.type !== LAYOUT_LIST &&\n\t\t\t\t\tpostType === 'page' && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tisPressed={ quickEdit }\n\t\t\t\t\t\t\ticon={ drawerRight }\n\t\t\t\t\t\t\tlabel={ __( 'Details' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\t\t...location.params,\n\t\t\t\t\t\t\t\t\tquickEdit: quickEdit ? undefined : true,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SACCC,KAAK,IAAIC,SAAS,EAClBC,WAAW,IAAIC,mBAAmB,QAC5B,sBAAsB;AAC7B,SAASC,QAAQ,EAAEC,OAAO,EAAEC,WAAW,EAAEC,SAAS,QAAQ,oBAAoB;AAC9E,SAASL,WAAW,IAAIM,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,qBAAqB,QAAQ,sBAAsB;AACvE,SAASV,WAAW,IAAIW,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,kBAAkB;;AAE9C;AACA;AACA;AACA,OAAOC,IAAI,MAAM,SAAS;AAC1B,SACCC,eAAe,EACfC,cAAc,QACR,oCAAoC;AAC3C,SACCC,eAAe,EACfC,gBAAgB,EAChBC,WAAW,QACL,uBAAuB;AAE9B,OAAOC,eAAe,MAAM,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,OAAOC,aAAa,MAAM,gBAAgB;A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AC,KAAM;QAC3Bb,OAAO,CAACY,IAAI,CAAE;UACba,MAAM,EAAEZ,EAAE;UACVhB,QAAQ;UACRgG,MAAM,EAAE;QACT,CAAE,CAAC;MACJ,CAAG;MACH5E,SAAS,EAAGA,SAAW;MACvBvD,cAAc,EAAGA,cAAgB;MACjC+I,MAAM,EACLC,MAAM,CAACC,gCAAgC,IACvCxH,IAAI,CAACQ,IAAI,KAAK9B,WAAW,IACzBgC,QAAQ,KAAK,MAAM,iBAClBzB,IAAA,CAAC7B,MAAM;QACNqK,IAAI,EAAC,SAAS;QACdC,SAAS,EAAGnF,SAAW;QACvBoF,IAAI,EAAGvJ,WAAa;QACpBwJ,KAAK,EAAGzJ,EAAE,CAAE,SAAU,CAAG;QACzB4I,OAAO,EAAGA,CAAA,KAAM;UACflG,OAAO,CAACY,IAAI,CAAE;YACb,GAAGY,QAAQ,CAAC1B,MAAM;YAClB4B,SAAS,EAAEA,SAAS,GAAGnC,SAAS,GAAG;UACpC,CAAE,CAAC;QACJ;MAAG,CACH;IAEF,GArCKP,UAAU,GAAGe,QAsCnB;EAAC,CACG,CAAC;AAET","ignoreList":[]}
@@ -45,7 +45,8 @@ function createNavState() {
45
45
  };
46
46
  }
47
47
  function SidebarContentWrapper({
48
- children
48
+ children,
49
+ shouldAnimate
49
50
  }) {
50
51
  const navState = useContext(SidebarNavigationContext);
51
52
  const wrapperRef = useRef();
@@ -58,10 +59,15 @@ function SidebarContentWrapper({
58
59
  focusSidebarElement(wrapperRef.current, direction, focusSelector);
59
60
  setNavAnimation(direction);
60
61
  }, [navState]);
61
- const wrapperCls = clsx('edit-site-sidebar__screen-wrapper', {
62
+ const wrapperCls = clsx('edit-site-sidebar__screen-wrapper',
63
+ /*
64
+ * Some panes do not have sub-panes and therefore
65
+ * should not animate when clicked on.
66
+ */
67
+ shouldAnimate ? {
62
68
  'slide-from-left': navAnimation === 'back',
63
69
  'slide-from-right': navAnimation === 'forward'
64
- });
70
+ } : {});
65
71
  return /*#__PURE__*/_jsx("div", {
66
72
  ref: wrapperRef,
67
73
  className: wrapperCls,
@@ -70,6 +76,7 @@ function SidebarContentWrapper({
70
76
  }
71
77
  export default function SidebarContent({
72
78
  routeKey,
79
+ shouldAnimate,
73
80
  children
74
81
  }) {
75
82
  const [navState] = useState(createNavState);
@@ -78,6 +85,7 @@ export default function SidebarContent({
78
85
  children: /*#__PURE__*/_jsx("div", {
79
86
  className: "edit-site-sidebar__content",
80
87
  children: /*#__PURE__*/_jsx(SidebarContentWrapper, {
88
+ shouldAnimate: shouldAnimate,
81
89
  children: children
82
90
  }, routeKey)
83
91
  })
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","createContext","useContext","useState","useRef","useLayoutEffect","focus","jsx","_jsx","SidebarNavigationContext","focusSidebarElement","el","direction","focusSelector","elementToFocus","querySelector","firstTabbable","tabbable","find","createNavState","state","get","navigate","SidebarContentWrapper","children","navState","wrapperRef","navAnimation","setNavAnimation","current","wrapperCls","ref","className","SidebarContent","routeKey","Provider","value"],"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseState,\n\tuseRef,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\n\nexport const SidebarNavigationContext = createContext( () => {} );\n// Focus a sidebar element after a navigation. The element to focus is either\n// specified by `focusSelector` (when navigating back) or it is the first\n// tabbable element (usually the \"Back\" button).\nfunction focusSidebarElement( el, direction, focusSelector ) {\n\tlet elementToFocus;\n\tif ( direction === 'back' && focusSelector ) {\n\t\telementToFocus = el.querySelector( focusSelector );\n\t}\n\tif ( direction !== null && ! elementToFocus ) {\n\t\tconst [ firstTabbable ] = focus.tabbable.find( el );\n\t\telementToFocus = firstTabbable ?? el;\n\t}\n\telementToFocus?.focus();\n}\n\n// Navigation state that is updated when navigating back or forward. Helps us\n// manage the animations and also focus.\nfunction createNavState() {\n\tlet state = {\n\t\tdirection: null,\n\t\tfocusSelector: null,\n\t};\n\n\treturn {\n\t\tget() {\n\t\t\treturn state;\n\t\t},\n\t\tnavigate( direction, focusSelector = null ) {\n\t\t\tstate = {\n\t\t\t\tdirection,\n\t\t\t\tfocusSelector:\n\t\t\t\t\tdirection === 'forward' && focusSelector\n\t\t\t\t\t\t? focusSelector\n\t\t\t\t\t\t: state.focusSelector,\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction SidebarContentWrapper( { children } ) {\n\tconst navState = useContext( SidebarNavigationContext );\n\tconst wrapperRef = useRef();\n\tconst [ navAnimation, setNavAnimation ] = useState( null );\n\n\tuseLayoutEffect( () => {\n\t\tconst { direction, focusSelector } = navState.get();\n\t\tfocusSidebarElement( wrapperRef.current, direction, focusSelector );\n\t\tsetNavAnimation( direction );\n\t}, [ navState ] );\n\n\tconst wrapperCls = clsx( 'edit-site-sidebar__screen-wrapper', {\n\t\t'slide-from-left': navAnimation === 'back',\n\t\t'slide-from-right': navAnimation === 'forward',\n\t} );\n\n\treturn (\n\t\t<div ref={ wrapperRef } className={ wrapperCls }>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default function SidebarContent( { routeKey, children } ) {\n\tconst [ navState ] = useState( createNavState );\n\n\treturn (\n\t\t<SidebarNavigationContext.Provider value={ navState }>\n\t\t\t<div className=\"edit-site-sidebar__content\">\n\t\t\t\t<SidebarContentWrapper key={ routeKey }>\n\t\t\t\t\t{ children }\n\t\t\t\t</SidebarContentWrapper>\n\t\t\t</div>\n\t\t</SidebarNavigationContext.Provider>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,aAAa,EACbC,UAAU,EACVC,QAAQ,EACRC,MAAM,EACNC,eAAe,QACT,oBAAoB;AAC3B,SAASC,KAAK,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEvC,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Ac,CAAC,GAAGY,QAAQ,CAACJ,GAAG,CAAC,CAAC;IACnDX,mBAAmB,CAAEgB,UAAU,CAACG,OAAO,EAAEjB,SAAS,EAAEC,aAAc,CAAC;IACnEe,eAAe,CAAEhB,SAAU,CAAC;EAC7B,CAAC,EAAE,CAAEa,QAAQ,CAAG,CAAC;EAEjB,MAAMK,UAAU,GAAG9B,IAAI,CAAE,mCAAmC,EAAE;IAC7D,iBAAiB,EAAE2B,YAAY,KAAK,MAAM;IAC1C,kBAAkB,EAAEA,YAAY,KAAK;EACtC,CAAE,CAAC;EAEH,oBACCnB,IAAA;IAAKuB,GAAG,EAAGL,UAAY;IAACM,SAAS,EAAGF,UAAY;IAAAN,QAAA,EAC7CA;EAAQ,CACN,CAAC;AAER;AAEA,eAAe,SAASS,cAAcA,CAAE;EAAEC,QAAQ;EAAEV;AAAS,CAAC,EAAG;EAChE,MAAM,CAAEC,QAAQ,CAAE,GAAGtB,QAAQ,CAAEgB,cAAe,CAAC;EAE/C,oBACCX,IAAA,CAACC,wBAAwB,CAAC0B,QAAQ;IAACC,KAAK,EAAGX,QAAU;IAAAD,QAAA,eACpDhB,IAAA;MAAKwB,SAAS,EAAC,4BAA4B;MAAAR,QAAA,eAC1ChB,IAAA,CAACe,qBAAqB;QAAAC,QAAA,EACnBA;MAAQ,GADkBU,QAEN;IAAC,CACpB;EAAC,CAC4B,CAAC;AAEtC","ignoreList":[]}
1
+ {"version":3,"names":["clsx","createContext","useContext","useState","useRef","useLayoutEffect","focus","jsx","_jsx","SidebarNavigationContext","focusSidebarElement","el","direction","focusSelector","elementToFocus","querySelector","firstTabbable","tabbable","find","createNavState","state","get","navigate","SidebarContentWrapper","children","shouldAnimate","navState","wrapperRef","navAnimation","setNavAnimation","current","wrapperCls","ref","className","SidebarContent","routeKey","Provider","value"],"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseState,\n\tuseRef,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\n\nexport const SidebarNavigationContext = createContext( () => {} );\n// Focus a sidebar element after a navigation. The element to focus is either\n// specified by `focusSelector` (when navigating back) or it is the first\n// tabbable element (usually the \"Back\" button).\nfunction focusSidebarElement( el, direction, focusSelector ) {\n\tlet elementToFocus;\n\tif ( direction === 'back' && focusSelector ) {\n\t\telementToFocus = el.querySelector( focusSelector );\n\t}\n\tif ( direction !== null && ! elementToFocus ) {\n\t\tconst [ firstTabbable ] = focus.tabbable.find( el );\n\t\telementToFocus = firstTabbable ?? el;\n\t}\n\telementToFocus?.focus();\n}\n\n// Navigation state that is updated when navigating back or forward. Helps us\n// manage the animations and also focus.\nfunction createNavState() {\n\tlet state = {\n\t\tdirection: null,\n\t\tfocusSelector: null,\n\t};\n\n\treturn {\n\t\tget() {\n\t\t\treturn state;\n\t\t},\n\t\tnavigate( direction, focusSelector = null ) {\n\t\t\tstate = {\n\t\t\t\tdirection,\n\t\t\t\tfocusSelector:\n\t\t\t\t\tdirection === 'forward' && focusSelector\n\t\t\t\t\t\t? focusSelector\n\t\t\t\t\t\t: state.focusSelector,\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction SidebarContentWrapper( { children, shouldAnimate } ) {\n\tconst navState = useContext( SidebarNavigationContext );\n\tconst wrapperRef = useRef();\n\tconst [ navAnimation, setNavAnimation ] = useState( null );\n\n\tuseLayoutEffect( () => {\n\t\tconst { direction, focusSelector } = navState.get();\n\t\tfocusSidebarElement( wrapperRef.current, direction, focusSelector );\n\t\tsetNavAnimation( direction );\n\t}, [ navState ] );\n\n\tconst wrapperCls = clsx(\n\t\t'edit-site-sidebar__screen-wrapper',\n\t\t/*\n\t\t * Some panes do not have sub-panes and therefore\n\t\t * should not animate when clicked on.\n\t\t */\n\t\tshouldAnimate\n\t\t\t? {\n\t\t\t\t\t'slide-from-left': navAnimation === 'back',\n\t\t\t\t\t'slide-from-right': navAnimation === 'forward',\n\t\t\t }\n\t\t\t: {}\n\t);\n\n\treturn (\n\t\t<div ref={ wrapperRef } className={ wrapperCls }>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default function SidebarContent( {\n\trouteKey,\n\tshouldAnimate,\n\tchildren,\n} ) {\n\tconst [ navState ] = useState( createNavState );\n\n\treturn (\n\t\t<SidebarNavigationContext.Provider value={ navState }>\n\t\t\t<div className=\"edit-site-sidebar__content\">\n\t\t\t\t<SidebarContentWrapper\n\t\t\t\t\tshouldAnimate={ shouldAnimate }\n\t\t\t\t\tkey={ routeKey }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</SidebarContentWrapper>\n\t\t\t</div>\n\t\t</SidebarNavigationContext.Provider>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,aAAa,EACbC,UAAU,EACVC,QAAQ,EACRC,MAAM,EACNC,eAAe,QACT,oBAAoB;AAC3B,SAASC,KAAK,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEvC,OAAO,MAAMC,wBAAwB,GAAGR,aAAa,CAAE,MAAM,CAAC,CAAE,CAAC;AACjE;AACA;AACA;AACA,SAASS,mBAAmBA,CAAEC,EAAE,EAAEC,SAAS,EAAEC,aAAa,EAAG;EAC5D,IAAIC,cAAc;EAClB,IAAKF,SAAS,KAAK,MAAM,IAAIC,aAAa,EAAG;IAC5CC,cAAc,GAAGH,EAAE,CAACI,aAAa,CAAEF,aAAc,CAAC;EACnD;EACA,IAAKD,SAAS,KAAK,IAAI,IAAI,CAAEE,cAAc,EAAG;IAC7C,MAAM,CAAEE,aAAa,CAAE,GAAGV,KAAK,CAACW,QAAQ,CAACC,IAAI,CAAEP,EAAG,CAAC;IACnDG,cAAc,GAAGE,aAAa,aAAbA,aAAa,cAAbA,aAAa,GAAIL,EAAE;E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