@wordpress/editor 14.19.3 → 14.21.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 (107) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -1
  3. package/build/components/commands/index.js +1 -1
  4. package/build/components/commands/index.js.map +1 -1
  5. package/build/components/plugin-pre-publish-panel/index.js +1 -1
  6. package/build/components/plugin-pre-publish-panel/index.js.map +1 -1
  7. package/build/components/post-actions/actions.js +10 -8
  8. package/build/components/post-actions/actions.js.map +1 -1
  9. package/build/components/post-publish-panel/maybe-category-panel.js +19 -3
  10. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  11. package/build/components/post-publish-panel/maybe-tags-panel.js +16 -6
  12. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  13. package/build/components/post-status/index.js +5 -1
  14. package/build/components/post-status/index.js.map +1 -1
  15. package/build/components/post-sticky/index.js +1 -1
  16. package/build/components/post-sticky/index.js.map +1 -1
  17. package/build/components/post-template/block-theme.js +1 -3
  18. package/build/components/post-template/block-theme.js.map +1 -1
  19. package/build/components/post-template/create-new-template-modal.js +1 -0
  20. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  21. package/build/components/post-template/create-new-template.js +1 -4
  22. package/build/components/post-template/create-new-template.js.map +1 -1
  23. package/build/components/post-template/hooks.js +6 -5
  24. package/build/components/post-template/hooks.js.map +1 -1
  25. package/build/components/post-template/swap-template-button.js +2 -3
  26. package/build/components/post-template/swap-template-button.js.map +1 -1
  27. package/build/components/post-visibility/index.js +39 -109
  28. package/build/components/post-visibility/index.js.map +1 -1
  29. package/build/components/post-visibility/label.js +2 -2
  30. package/build/components/post-visibility/label.js.map +1 -1
  31. package/build/components/post-visibility/utils.js +14 -15
  32. package/build/components/post-visibility/utils.js.map +1 -1
  33. package/build/components/preview-dropdown/index.js +2 -4
  34. package/build/components/preview-dropdown/index.js.map +1 -1
  35. package/build-module/components/commands/index.js +1 -1
  36. package/build-module/components/commands/index.js.map +1 -1
  37. package/build-module/components/plugin-pre-publish-panel/index.js +1 -1
  38. package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -1
  39. package/build-module/components/post-actions/actions.js +10 -8
  40. package/build-module/components/post-actions/actions.js.map +1 -1
  41. package/build-module/components/post-publish-panel/maybe-category-panel.js +19 -3
  42. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  43. package/build-module/components/post-publish-panel/maybe-tags-panel.js +16 -6
  44. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  45. package/build-module/components/post-status/index.js +5 -1
  46. package/build-module/components/post-status/index.js.map +1 -1
  47. package/build-module/components/post-sticky/index.js +1 -1
  48. package/build-module/components/post-sticky/index.js.map +1 -1
  49. package/build-module/components/post-template/block-theme.js +1 -3
  50. package/build-module/components/post-template/block-theme.js.map +1 -1
  51. package/build-module/components/post-template/create-new-template-modal.js +1 -0
  52. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  53. package/build-module/components/post-template/create-new-template.js +1 -4
  54. package/build-module/components/post-template/create-new-template.js.map +1 -1
  55. package/build-module/components/post-template/hooks.js +6 -5
  56. package/build-module/components/post-template/hooks.js.map +1 -1
  57. package/build-module/components/post-template/swap-template-button.js +2 -3
  58. package/build-module/components/post-template/swap-template-button.js.map +1 -1
  59. package/build-module/components/post-visibility/index.js +41 -111
  60. package/build-module/components/post-visibility/index.js.map +1 -1
  61. package/build-module/components/post-visibility/label.js +3 -3
  62. package/build-module/components/post-visibility/label.js.map +1 -1
  63. package/build-module/components/post-visibility/utils.js +13 -14
  64. package/build-module/components/post-visibility/utils.js.map +1 -1
  65. package/build-module/components/preview-dropdown/index.js +2 -4
  66. package/build-module/components/preview-dropdown/index.js.map +1 -1
  67. package/build-style/style-rtl.css +6 -137
  68. package/build-style/style.css +6 -137
  69. package/build-types/components/plugin-pre-publish-panel/index.d.ts +1 -1
  70. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  71. package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
  72. package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts.map +1 -1
  73. package/build-types/components/post-status/index.d.ts.map +1 -1
  74. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  75. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  76. package/build-types/components/post-template/create-new-template.d.ts +1 -3
  77. package/build-types/components/post-template/create-new-template.d.ts.map +1 -1
  78. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  79. package/build-types/components/post-template/swap-template-button.d.ts +1 -1
  80. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  81. package/build-types/components/post-visibility/index.d.ts.map +1 -1
  82. package/build-types/components/post-visibility/label.d.ts.map +1 -1
  83. package/build-types/components/post-visibility/utils.d.ts +5 -20
  84. package/build-types/components/post-visibility/utils.d.ts.map +1 -1
  85. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  86. package/package.json +37 -37
  87. package/src/components/autocompleters/style.scss +2 -3
  88. package/src/components/commands/index.js +1 -1
  89. package/src/components/plugin-pre-publish-panel/index.js +1 -1
  90. package/src/components/post-actions/actions.js +13 -8
  91. package/src/components/post-publish-panel/maybe-category-panel.js +20 -5
  92. package/src/components/post-publish-panel/maybe-tags-panel.js +39 -22
  93. package/src/components/post-status/index.js +7 -2
  94. package/src/components/post-sticky/index.js +1 -1
  95. package/src/components/post-template/block-theme.js +1 -3
  96. package/src/components/post-template/create-new-template-modal.js +1 -0
  97. package/src/components/post-template/create-new-template.js +1 -2
  98. package/src/components/post-template/hooks.js +12 -8
  99. package/src/components/post-template/style.scss +4 -0
  100. package/src/components/post-template/swap-template-button.js +6 -4
  101. package/src/components/post-visibility/index.js +41 -118
  102. package/src/components/post-visibility/label.js +7 -4
  103. package/src/components/post-visibility/utils.js +11 -8
  104. package/src/components/preview-dropdown/index.js +6 -3
  105. package/src/style.scss +0 -1
  106. package/tsconfig.tsbuildinfo +1 -1
  107. package/src/components/post-visibility/style.scss +0 -27
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_components","_data","_check","_interopRequireDefault","_store","_jsxRuntime","PostSticky","postSticky","useSelect","select","_select$getEditedPost","editorStore","getEditedPostAttribute","editPost","useDispatch","jsx","default","children","CheckboxControl","className","label","__","help","checked","onChange","sticky","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostSticky() {\n\tconst postSticky = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false\n\t\t);\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"editor-post-sticky__checkbox-control\"\n\t\t\t\tlabel={ __( 'Sticky' ) }\n\t\t\t\thelp={ __( 'Pin this post to the top of the blog' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => editPost( { sticky: ! postSticky } ) }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAmD,IAAAM,WAAA,GAAAN,OAAA;AAXnD;AACA;AACA;;AAKA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,GACe,SAASO,UAAUA,CAAA,EAAG;EACpC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAC,qBAAA;IAC3C,QAAAA,qBAAA,GACCD,MAAM,CAAEE,YAAY,CAAC,CAACC,sBAAsB,CAAE,QAAS,CAAC,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,KAAK;EAEnE,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEG;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEH,YAAY,CAAC;EAE/C,oBACC,IAAAN,WAAA,CAAAU,GAAA,EAACb,MAAA,CAAAc,OAAe;IAAAC,QAAA,eACf,IAAAZ,WAAA,CAAAU,GAAA,EAACf,WAAA,CAAAkB,eAAe;MACfC,SAAS,EAAC,sCAAsC;MAChDC,KAAK,EAAG,IAAAC,QAAE,EAAE,QAAS,CAAG;MACxBC,IAAI,EAAG,IAAAD,QAAE,EAAE,sCAAuC,CAAG;MACrDE,OAAO,EAAGhB,UAAY;MACtBiB,QAAQ,EAAGA,CAAA,KAAMX,QAAQ,CAAE;QAAEY,MAAM,EAAE,CAAElB;MAAW,CAAE,CAAG;MACvDmB,uBAAuB;IAAA,CACvB;EAAC,CACc,CAAC;AAEpB","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_components","_data","_check","_interopRequireDefault","_store","_jsxRuntime","PostSticky","postSticky","useSelect","select","_select$getEditedPost","editorStore","getEditedPostAttribute","editPost","useDispatch","jsx","default","children","CheckboxControl","className","label","__","help","checked","onChange","sticky","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostSticky() {\n\tconst postSticky = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false\n\t\t);\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"editor-post-sticky__checkbox-control\"\n\t\t\t\tlabel={ __( 'Sticky' ) }\n\t\t\t\thelp={ __( 'Pin this post to the top of the blog.' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => editPost( { sticky: ! postSticky } ) }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAmD,IAAAM,WAAA,GAAAN,OAAA;AAXnD;AACA;AACA;;AAKA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,GACe,SAASO,UAAUA,CAAA,EAAG;EACpC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAC,qBAAA;IAC3C,QAAAA,qBAAA,GACCD,MAAM,CAAEE,YAAY,CAAC,CAACC,sBAAsB,CAAE,QAAS,CAAC,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,KAAK;EAEnE,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEG;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEH,YAAY,CAAC;EAE/C,oBACC,IAAAN,WAAA,CAAAU,GAAA,EAACb,MAAA,CAAAc,OAAe;IAAAC,QAAA,eACf,IAAAZ,WAAA,CAAAU,GAAA,EAACf,WAAA,CAAAkB,eAAe;MACfC,SAAS,EAAC,sCAAsC;MAChDC,KAAK,EAAG,IAAAC,QAAE,EAAE,QAAS,CAAG;MACxBC,IAAI,EAAG,IAAAD,QAAE,EAAE,uCAAwC,CAAG;MACtDE,OAAO,EAAGhB,UAAY;MACtBiB,QAAQ,EAAGA,CAAA,KAAMX,QAAQ,CAAE;QAAEY,MAAM,EAAE,CAAElB;MAAW,CAAE,CAAG;MACvDmB,uBAAuB;IAAA,CACvB;EAAC,CACc,CAAC;AAEpB","ignoreList":[]}
@@ -133,9 +133,7 @@ function BlockThemeControl({
133
133
  onClick: onClose
134
134
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_resetDefaultTemplate.default, {
135
135
  onClick: onClose
136
- }), canCreateTemplate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_createNewTemplate.default, {
137
- onClick: onClose
138
- })]
136
+ }), canCreateTemplate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_createNewTemplate.default, {})]
139
137
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuGroup, {
140
138
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
141
139
  icon: !isTemplateHidden ? _icons.check : undefined,
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_htmlEntities","_components","_element","_i18n","_coreData","_icons","_notices","_preferences","_postPanelRow","_interopRequireDefault","_store","_swapTemplateButton","_resetDefaultTemplate","_lockUnlock","_createNewTemplate","_jsxRuntime","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","useSelect","select","getRenderingMode","_getEditorSettings","unlock","editorStore","editorSettings","hasOwnProperty","get","getPreference","preferencesStore","editedRecord","template","hasResolved","useEntityRecord","createSuccessNotice","useDispatch","noticesStore","setRenderingMode","setDefaultRenderingMode","canCreateTemplate","coreStore","canUser","kind","name","popoverAnchor","setPopoverAnchor","useState","popoverProps","useMemo","anchor","className","placement","offset","shift","notificationAction","label","__","onClick","onNavigateToPreviousEntityRecord","undefined","mayShowTemplateEditNotice","type","actions","jsx","default","ref","children","DropdownMenu","focusOnMount","toggleProps","size","variant","tooltipPosition","text","decodeEntities","title","icon","onClose","jsxs","Fragment","MenuGroup","MenuItem","postId","postType","check","isSelected","role","newRenderingMode"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode, setDefaultRenderingMode } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst canCreateTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tclassName: 'editor-post-template__dropdown',\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\treturn (\n\t\t<PostPanelRow label={ __( 'Template' ) } ref={ setPopoverAnchor }>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t\tvariant: 'tertiary',\n\t\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Template options' ) }\n\t\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\t\ticon={ null }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tconst newRenderingMode = isTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only';\n\t\t\t\t\t\t\t\t\tsetRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t\tsetDefaultRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Show template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAKA,IAAAS,aAAA,GAAAC,sBAAA,CAAAV,OAAA;AAKA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,GAAAF,sBAAA,CAAAV,OAAA;AACA,IAAAa,qBAAA,GAAAH,sBAAA,CAAAV,OAAA;AACA,IAAAc,WAAA,GAAAd,OAAA;AACA,IAAAe,kBAAA,GAAAL,sBAAA,CAAAV,OAAA;AAAsD,IAAAgB,WAAA,GAAAhB,OAAA;AAzBtD;AACA;AACA;;AAWA;AACA;AACA;;AAGA;AACA;AACA;;AAOe,SAASiB,iBAAiBA,CAAE;EAAEC;AAAG,CAAC,EAAG;EACnD,MAAM;IACLC,gBAAgB;IAChBC,wBAAwB;IACxBC,iBAAiB;IACjBC;EACD,CAAC,GAAG,IAAAC,eA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B,CAAEiD,gBAAiB,CAAC;YAC5C,CAAG;YAAArB,QAAA,EAED,IAAAV,QAAE,EAAE,eAAgB;UAAC,CACd;QAAC,CACD,CAAC;MAAA,CACX;IACF,CACY;EAAC,CACF,CAAC;AAEjB","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_htmlEntities","_components","_element","_i18n","_coreData","_icons","_notices","_preferences","_postPanelRow","_interopRequireDefault","_store","_swapTemplateButton","_resetDefaultTemplate","_lockUnlock","_createNewTemplate","_jsxRuntime","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","useSelect","select","getRenderingMode","_getEditorSettings","unlock","editorStore","editorSettings","hasOwnProperty","get","getPreference","preferencesStore","editedRecord","template","hasResolved","useEntityRecord","createSuccessNotice","useDispatch","noticesStore","setRenderingMode","setDefaultRenderingMode","canCreateTemplate","coreStore","canUser","kind","name","popoverAnchor","setPopoverAnchor","useState","popoverProps","useMemo","anchor","className","placement","offset","shift","notificationAction","label","__","onClick","onNavigateToPreviousEntityRecord","undefined","mayShowTemplateEditNotice","type","actions","jsx","default","ref","children","DropdownMenu","focusOnMount","toggleProps","size","variant","tooltipPosition","text","decodeEntities","title","icon","onClose","jsxs","Fragment","MenuGroup","MenuItem","postId","postType","check","isSelected","role","newRenderingMode"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode, setDefaultRenderingMode } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst canCreateTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tclassName: 'editor-post-template__dropdown',\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\treturn (\n\t\t<PostPanelRow label={ __( 'Template' ) } ref={ setPopoverAnchor }>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t\tvariant: 'tertiary',\n\t\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Template options' ) }\n\t\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\t\ticon={ null }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t{ canCreateTemplate && <CreateNewTemplate /> }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tconst newRenderingMode = isTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only';\n\t\t\t\t\t\t\t\t\tsetRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t\tsetDefaultRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Show template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,MAA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AAC,EAC1CtC,iBAAiB,iBAAI,IAAA3B,WAAA,CAAAmD,GAAA,EAACpD,kBAAA,CAAAqD,OAAiB,IAAE,CAAC;QAAA,CAClC,CAAC,eACZ,IAAApD,WAAA,CAAAmD,GAAA,EAACjE,WAAA,CAAAkF,SAAS;UAAAd,QAAA,eACT,IAAAtD,WAAA,CAAAmD,GAAA,EAACjE,WAAA,CAAAmF,QAAQ;YACRL,IAAI,EAAG,CAAE7D,gBAAgB,GAAGqE,YAAK,GAAGzB,SAAW;YAC/C0B,UAAU,EAAG,CAAEtE,gBAAkB;YACjCuE,IAAI,EAAC,kBAAkB;YACvB7B,OAAO,EAAGA,CAAA,KAAM;cACf,MAAM8B,gBAAgB,GAAGxE,gBAAgB,GACtC,iBAAiB,GACjB,WAAW;cACdsB,gBAAgB,CAAEkD,gBAAiB,CAAC;cACpCjD,uBAAuB,CAAEiD,gBAAiB,CAAC;YAC5C,CAAG;YAAArB,QAAA,EAED,IAAAV,QAAE,EAAE,eAAgB;UAAC,CACd;QAAC,CACD,CAAC;MAAA,CACX;IACF,CACY;EAAC,CACF,CAAC;AAEjB","ignoreList":[]}
@@ -87,6 +87,7 @@ function CreateNewTemplateModal({
87
87
  onRequestClose: cancel,
88
88
  focusOnMount: "firstContentElement",
89
89
  size: "small",
90
+ overlayClassName: "editor-post-template__create-template-modal",
90
91
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
91
92
  className: "editor-post-template__create-form",
92
93
  onSubmit: submit,
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_blocks","_components","_i18n","_url","_lockUnlock","_store","_jsxRuntime","DEFAULT_TITLE","__","CreateNewTemplateModal","onClose","defaultBlockTemplate","onNavigateToEntityRecord","useSelect","select","getEditorSettings","getCurrentTemplateId","editorStore","getTemplateId","createTemplate","unlock","useDispatch","title","setTitle","useState","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","serialize","createBlock","tagName","layout","inherit","newTemplate","slug","cleanForSlug","content","postId","id","postType","jsx","Modal","onRequestClose","focusOnMount","size","children","className","onSubmit","jsxs","__experimentalVStack","spacing","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","__experimentalHStack","justify","Button","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst { defaultBlockTemplate, onNavigateToEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tdefaultBlockTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\t\tgetTemplateId: getCurrentTemplateId,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { createTemplate } = unlock( useDispatch( editorStore ) );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tconst newTemplate = await createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tonNavigateToEntityRecord( {\n\t\t\tpostId: newTemplate.id,\n\t\t\tpostType: 'wp_template',\n\t\t} );\n\t\tcancel();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAOA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,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eAEnB,IAAA3C,WAAA,CAAA8C,IAAA,EAACnD,WAAA,CAAAoD,oBAAM;QAACC,OAAO,EAAC,GAAG;QAAAL,QAAA,gBAClB,IAAA3C,WAAA,CAAAsC,GAAA,EAAC3C,WAAA,CAAAsD,WAAW;UACXC,qBAAqB;UACrBC,uBAAuB;UACvBC,KAAK,EAAG,IAAAlD,QAAE,EAAE,MAAO,CAAG;UACtBmD,KAAK,EAAGrC,KAAO;UACfsC,QAAQ,EAAGrC,QAAU;UACrBsC,WAAW,EAAGtD,aAAe;UAC7BuD,QAAQ,EAAGrC,MAAQ;UACnBsC,IAAI,EAAG,IAAAvD,QAAE;UACR;UACA,iHACD;QAAG,CACH,CAAC,eACF,IAAAF,WAAA,CAAA8C,IAAA,EAACnD,WAAA,CAAA+D,oBAAM;UAACC,OAAO,EAAC,OAAO;UAAAhB,QAAA,gBACtB,IAAA3C,WAAA,CAAAsC,GAAA,EAAC3C,WAAA,CAAAiE,MAAM;YACNV,qBAAqB;YACrBW,OAAO,EAAC,UAAU;YAClBC,OAAO,EAAGzC,MAAQ;YAAAsB,QAAA,EAEhB,IAAAzC,QAAE,EAAE,QAAS;UAAC,CACT,CAAC,eAET,IAAAF,WAAA,CAAAsC,GAAA,EAAC3C,WAAA,CAAAiE,MAAM;YACNV,qBAAqB;YACrBW,OAAO,EAAC,SAAS;YACjBE,IAAI,EAAC,QAAQ;YACb5C,MAAM,EAAGA,MAAQ;YACjB,iBAAgBA,MAAQ;YAAAwB,QAAA,EAEtB,IAAAzC,QAAE,EAAE,QAAS;UAAC,CACT,CAAC;QAAA,CACF,CAAC;MAAA,CACF;IAAC,CACJ;EAAC,CACD,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_blocks","_components","_i18n","_url","_lockUnlock","_store","_jsxRuntime","DEFAULT_TITLE","__","CreateNewTemplateModal","onClose","defaultBlockTemplate","onNavigateToEntityRecord","useSelect","select","getEditorSettings","getCurrentTemplateId","editorStore","getTemplateId","createTemplate","unlock","useDispatch","title","setTitle","useState","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","serialize","createBlock","tagName","layout","inherit","newTemplate","slug","cleanForSlug","content","postId","id","postType","jsx","Modal","onRequestClose","focusOnMount","size","overlayClassName","children","className","onSubmit","jsxs","__experimentalVStack","spacing","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","__experimentalHStack","justify","Button","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst { defaultBlockTemplate, onNavigateToEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tdefaultBlockTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\t\tgetTemplateId: getCurrentTemplateId,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { createTemplate } = unlock( useDispatch( editorStore ) );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tconst newTemplate = await createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tonNavigateToEntityRecord( {\n\t\t\tpostId: newTemplate.id,\n\t\t\tpostType: 'wp_template',\n\t\t} );\n\t\tcancel();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t\toverlayClassName=\"editor-post-template__create-template-modal\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OA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ignoreList":[]}
@@ -21,9 +21,7 @@ var _jsxRuntime = require("react/jsx-runtime");
21
21
  * Internal dependencies
22
22
  */
23
23
 
24
- function CreateNewTemplate({
25
- onClick
26
- }) {
24
+ function CreateNewTemplate() {
27
25
  const {
28
26
  canCreateTemplates
29
27
  } = (0, _data.useSelect)(select => {
@@ -53,7 +51,6 @@ function CreateNewTemplate({
53
51
  }), isCreateModalOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_createNewTemplateModal.default, {
54
52
  onClose: () => {
55
53
  setIsCreateModalOpen(false);
56
- onClick();
57
54
  }
58
55
  })]
59
56
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_i18n","_data","_coreData","_element","_createNewTemplateModal","_interopRequireDefault","_hooks","_jsxRuntime","CreateNewTemplate","onClick","canCreateTemplates","useSelect","select","canUser","coreStore","kind","name","isCreateModalOpen","setIsCreateModalOpen","useState","allowSwitchingTemplate","useAllowSwitchingTemplates","jsxs","Fragment","children","jsx","MenuItem","__","default","onClose"],"sources":["@wordpress/editor/src/components/post-template/create-new-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nexport default function CreateNewTemplate( { onClick } ) {\n\tconst { canCreateTemplates } = useSelect( ( select ) => {\n\t\tconst { canUser } = select( coreStore );\n\t\treturn {\n\t\t\tcanCreateTemplates: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! canCreateTemplates || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsCreateModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Create new template' ) }\n\t\t\t</MenuItem>\n\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsCreateModalOpen( false );\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,uBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAqD,IAAAQ,WAAA,GAAAR,OAAA;AAbrD;AACA;AACA;;AAOA;AACA;AACA;;AAIe,SAASS,iBAAiBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACxD,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACvD,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IACvC,OAAO;MACNJ,kBAAkB,EAAEG,OAAO,CAAE,QAAQ,EAAE;QACtCE,IAAI,EAAE,UAAU;QAChBC,IAAI,EAAE;MACP,CAAE;IACH,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACrE,MAAMC,sBAAsB,GAAG,IAAAC,iCAA0B,EAAC,CAAC;;EAE3D;EACA,IAAK,CAAEX,kBAAkB,IAAI,CAAEU,sBAAsB,EAAG;IACvD,OAAO,IAAI;EACZ;EACA,oBACC,IAAAb,WAAA,CAAAe,IAAA,EAAAf,WAAA,CAAAgB,QAAA;IAAAC,QAAA,gBACC,IAAAjB,WAAA,CAAAkB,GAAA,EAAC3B,WAAA,CAAA4B,QAAQ;MACRjB,OAAO,EAAGA,CAAA,KAAM;QACfS,oBAAoB,CAAE,IAAK,CAAC;MAC7B,CAAG;MAAAM,QAAA,EAED,IAAAG,QAAE,EAAE,qBAAsB;IAAC,CACpB,CAAC,EAETV,iBAAiB,iBAClB,IAAAV,WAAA,CAAAkB,GAAA,EAACrB,uBAAA,CAAAwB,OAAsB;MACtBC,OAAO,EAAGA,CAAA,KAAM;QACfX,oBAAoB,CAAE,KAAM,CAAC;QAC7BT,OAAO,CAAC,CAAC;MACV;IAAG,CACH,CACD;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_i18n","_data","_coreData","_element","_createNewTemplateModal","_interopRequireDefault","_hooks","_jsxRuntime","CreateNewTemplate","canCreateTemplates","useSelect","select","canUser","coreStore","kind","name","isCreateModalOpen","setIsCreateModalOpen","useState","allowSwitchingTemplate","useAllowSwitchingTemplates","jsxs","Fragment","children","jsx","MenuItem","onClick","__","default","onClose"],"sources":["@wordpress/editor/src/components/post-template/create-new-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nexport default function CreateNewTemplate() {\n\tconst { canCreateTemplates } = useSelect( ( select ) => {\n\t\tconst { canUser } = select( coreStore );\n\t\treturn {\n\t\t\tcanCreateTemplates: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! canCreateTemplates || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsCreateModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Create new template' ) }\n\t\t\t</MenuItem>\n\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsCreateModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,uBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAqD,IAAAQ,WAAA,GAAAR,OAAA;AAbrD;AACA;AACA;;AAOA;AACA;AACA;;AAIe,SAASS,iBAAiBA,CAAA,EAAG;EAC3C,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACvD,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IACvC,OAAO;MACNJ,kBAAkB,EAAEG,OAAO,CAAE,QAAQ,EAAE;QACtCE,IAAI,EAAE,UAAU;QAChBC,IAAI,EAAE;MACP,CAAE;IACH,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACrE,MAAMC,sBAAsB,GAAG,IAAAC,iCAA0B,EAAC,CAAC;;EAE3D;EACA,IAAK,CAAEX,kBAAkB,IAAI,CAAEU,sBAAsB,EAAG;IACvD,OAAO,IAAI;EACZ;EACA,oBACC,IAAAZ,WAAA,CAAAc,IAAA,EAAAd,WAAA,CAAAe,QAAA;IAAAC,QAAA,gBACC,IAAAhB,WAAA,CAAAiB,GAAA,EAAC1B,WAAA,CAAA2B,QAAQ;MACRC,OAAO,EAAGA,CAAA,KAAM;QACfT,oBAAoB,CAAE,IAAK,CAAC;MAC7B,CAAG;MAAAM,QAAA,EAED,IAAAI,QAAE,EAAE,qBAAsB;IAAC,CACpB,CAAC,EAETX,iBAAiB,iBAClB,IAAAT,WAAA,CAAAiB,GAAA,EAACpB,uBAAA,CAAAwB,OAAsB;MACtBC,OAAO,EAAGA,CAAA,KAAM;QACfZ,oBAAoB,CAAE,KAAM,CAAC;MAC9B;IAAG,CACH,CACD;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
@@ -46,16 +46,17 @@ function useAllowSwitchingTemplates() {
46
46
  kind: 'root',
47
47
  name: 'site'
48
48
  }) ? getEntityRecord('root', 'site') : undefined;
49
- const templates = getEntityRecords('postType', 'wp_template', {
50
- per_page: -1
51
- });
52
49
  const isPostsPage = +postId === siteSettings?.page_for_posts;
50
+ const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front;
53
51
  // If current page is set front page or posts page, we also need
54
52
  // to check if the current theme has a template for it. If not
55
- const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({
53
+ const templates = isFrontPage ? getEntityRecords('postType', 'wp_template', {
54
+ per_page: -1
55
+ }) : [];
56
+ const hasFrontPage = isFrontPage && !!templates?.some(({
56
57
  slug
57
58
  }) => slug === 'front-page');
58
- return !isPostsPage && !isFrontPage;
59
+ return !isPostsPage && !hasFrontPage;
59
60
  }, [postId, postType]);
60
61
  }
61
62
  function useTemplates(postType) {
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_coreData","_store","useEditedPostContext","useSelect","select","getCurrentPostId","getCurrentPostType","editorStore","postId","postType","useAllowSwitchingTemplates","canUser","getEntityRecord","getEntityRecords","coreStore","siteSettings","kind","name","undefined","templates","per_page","isPostsPage","page_for_posts","isFrontPage","page_on_front","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","useMemo","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' &&\n\t\t\t\t+postId === siteSettings?.page_on_front &&\n\t\t\t\ttemplates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! isFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates( postType ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates( postType ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates( postType );\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,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Ac,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOpB,SAAS,EAAEuB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACT,IAAI,KAAKa,cAAe,CAAC,EACvEb,IAAI;AACR","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_coreData","_store","useEditedPostContext","useSelect","select","getCurrentPostId","getCurrentPostType","editorStore","postId","postType","useAllowSwitchingTemplates","canUser","getEntityRecord","getEntityRecords","coreStore","siteSettings","kind","name","undefined","isPostsPage","page_for_posts","isFrontPage","page_on_front","templates","per_page","hasFrontPage","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","useMemo","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && +postId === siteSettings?.page_on_front;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst templates = isFrontPage\n\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t } )\n\t\t\t\t: [];\n\t\t\tconst hasFrontPage =\n\t\t\t\tisFrontPage &&\n\t\t\t\t!! templates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! hasFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates( postType ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates( postType ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates( postType );\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGO,SAASI,oBAAoBA,CAAA,EAAG;EACtC,OAAO,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC/B,MAAM;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAAGF,MAAM,CAAEG,YAAY,CAAC;IACtE,OAAO;MACNC,MAAM,EAAEH,gBAAgB,CAAC,CAAC;MAC1BI,QAAQ,EAAEH,kBAAkB,CAAC;IAC9B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR;AACO,SAASI,0BAA0BA,CAAA,EAAG;EAC5C,MAAM;IAAED,QAAQ;IAAED;EAAO,CAAC,GAAGN,oBAAoB,CAAC,CAAC;EACnD,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAM;IACb,MAAM;MAAEO,OAAO;MAAEC,eAAe;MAAEC;IAAiB,CAAC,GACnDT,MAAM,CAAEU,eAAU,CAAC;IACpB,MAAMC,YAAY,GAAGJ,OAAO,CAAE,MAAM,EAAE;MACrCK,IAAI,EAAE,MAAM;MACZC,IAAI,EAAE;IACP,CAAE,CAAC,GACAL,eAAe,CAAE,MAAM,EAAE,MAAO,CAAC,GACjCM,SAAS;IAEZ,MAAMC,WAAW,GAAG,CAACX,MAAM,KAAKO,YAAY,EAAEK,cAAc;IAC5D,MAAMC,WAAW,GAChBZ,QAAQ,KAAK,MAAM,IAAI,CAACD,MAAM,KAAKO,YAAY,EAAEO,aAAa;IAC/D;IACA;IACA,MAAMC,SAAS,GAAGF,WAAW,GAC1BR,gBAAgB,CAAE,UAAU,EAAE,aAAa,EAAE;MAC7CW,QAAQ,EAAE,CAAC;IACX,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,IAAM;IACb,MAAMqC,IAAI,GAAGrC,MAAM,CAAEU,eAAU,CAAC,CAAC4B,qBAAqB,CACrD,UAAU,EACVjC,QAAQ,EACRD,MACD,CAAC;IACD,OAAOiC,IAAI,EAAEL,QAAQ;EACtB,CAAC,EACD,CAAE3B,QAAQ,EAAED,MAAM,CACnB,CAAC;EAED,IAAK,CAAEgC,cAAc,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOjB,SAAS,EAAEoB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACT,IAAI,KAAKa,cAAe,CAAC,EACvEb,IAAI;AACR","ignoreList":[]}
@@ -34,9 +34,6 @@ function SwapTemplateButton({
34
34
  const {
35
35
  editEntityRecord
36
36
  } = (0, _data.useDispatch)(_coreData.store);
37
- if (!availableTemplates?.length) {
38
- return null;
39
- }
40
37
  const onTemplateSelect = async template => {
41
38
  editEntityRecord('postType', postType, postId, {
42
39
  template: template.name
@@ -48,6 +45,8 @@ function SwapTemplateButton({
48
45
  };
49
46
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
50
47
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
48
+ disabled: !availableTemplates?.length,
49
+ accessibleWhenDisabled: true,
51
50
  onClick: () => setShowModal(true),
52
51
  children: (0, _i18n.__)('Change template')
53
52
  }), showModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_htmlEntities","_blockEditor","_components","_i18n","_data","_coreData","_blocks","_hooks","_jsxRuntime","SwapTemplateButton","onClick","showModal","setShowModal","useState","postType","postId","useEditedPostContext","availableTemplates","useAvailableTemplates","editEntityRecord","useDispatch","coreStore","length","onTemplateSelect","template","name","undoIgnore","jsxs","Fragment","children","jsx","MenuItem","__","Modal","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","templatesAsPatterns","useMemo","map","slug","blocks","parse","content","raw","decodeEntities","rendered","id","__experimentalBlockPatternsList","label","blockPatterns","onClickPattern"],"sources":["@wordpress/editor/src/components/post-template/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tif ( ! availableTemplates?.length ) {\n\t\treturn null;\n\t}\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tsetShowModal( false ); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem onClick={ () => setShowModal( true ) }>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonSelect={ onTemplateSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { postType, onSelect } ) {\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tlabel={ __( 'Templates' ) }\n\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\tonClickPattern={ onSelect }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AAAsE,IAAAS,WAAA,GAAAT,OAAA;AAftE;AACA;AACA;;AAUA;AACA;AACA;;AAGe,SAASU,kBAAkBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACzD,MAAM,CAAEC,SAAS,EAAEC,YAAY,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACrD,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAG,IAAAC,2BAAoB,EAAC,CAAC;EACnD,MAAMC,kBAAkB,GAAG,IAAAC,4BAAqB,EAAEJ,QAAS,CAAC;EAC5D,MAAM;IAAEK;EAAiB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,eAAU,CAAC;EACrD,IA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AAM2B,mBAAmB,GAAG,IAAAC,gBAAO,EAClC,MACCzB,kBAAkB,CAAC0B,GAAG,CAAInB,QAAQ,KAAQ;IACzCC,IAAI,EAAED,QAAQ,CAACoB,IAAI;IACnBC,MAAM,EAAE,IAAAC,aAAK,EAAEtB,QAAQ,CAACuB,OAAO,CAACC,GAAI,CAAC;IACrCd,KAAK,EAAE,IAAAe,4BAAc,EAAEzB,QAAQ,CAACU,KAAK,CAACgB,QAAS,CAAC;IAChDC,EAAE,EAAE3B,QAAQ,CAAC2B;EACd,CAAC,CAAG,CAAC,EACN,CAAElC,kBAAkB,CACrB,CAAC;EACD,oBACC,IAAAT,WAAA,CAAAsB,GAAA,EAAC7B,YAAA,CAAAmD,+BAAiB;IACjBC,KAAK,EAAG,IAAArB,QAAE,EAAE,WAAY,CAAG;IAC3BsB,aAAa,EAAGb,mBAAqB;IACrCc,cAAc,EAAGf;EAAU,CAC3B,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_htmlEntities","_blockEditor","_components","_i18n","_data","_coreData","_blocks","_hooks","_jsxRuntime","SwapTemplateButton","onClick","showModal","setShowModal","useState","postType","postId","useEditedPostContext","availableTemplates","useAvailableTemplates","editEntityRecord","useDispatch","coreStore","onTemplateSelect","template","name","undoIgnore","jsxs","Fragment","children","jsx","MenuItem","disabled","length","accessibleWhenDisabled","__","Modal","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","templatesAsPatterns","useMemo","map","slug","blocks","parse","content","raw","decodeEntities","rendered","id","__experimentalBlockPatternsList","label","blockPatterns","onClickPattern"],"sources":["@wordpress/editor/src/components/post-template/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tsetShowModal( false ); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tdisabled={ ! availableTemplates?.length }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonSelect={ onTemplateSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { postType, onSelect } ) {\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tlabel={ __( 'Templates' ) }\n\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\tonClickPattern={ onSelect }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AAAsE,IAAAS,WAAA,GAAAT,OAAA;AAftE;AACA;AACA;;AAUA;AACA;AACA;;AAGe,SAASU,kBAAkBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACzD,MAAM,CAAEC,SAAS,EAAEC,YAAY,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACrD,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAG,IAAAC,2BAAoB,EAAC,CAAC;EACnD,MAAMC,kBAAkB,GAAG,IAAAC,4BAAqB,EAAEJ,QAAS,CAAC;EAC5D,MAAM;IAAEK;EAAiB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,eAAU,CAAC;EAErD,MAAMC,gBAAgB,GAAG,MAAQC,QAAQ,IAAM;IAC9CJ,gBAAgB,CACf,UAAU,EACVL,QAAQ,EACRC,MAAM,EACN;MAAEQ,QAAQ,EAAEA,QAAQ,CAACC;IAAK,CAAC,EAC3B;MAAEC,UAAU,EAAE;IAAK,CACpB,CAAC;IACDb,YAAY,CAAE,KAAM,CAAC,CAAC,CAAC;IACvBF,OAAO,CAAC,CAA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AAQ,CAACa,KAAK,CAACgB,QAAS,CAAC;IAChDC,EAAE,EAAE9B,QAAQ,CAAC8B;EACd,CAAC,CAAG,CAAC,EACN,CAAEpC,kBAAkB,CACrB,CAAC;EACD,oBACC,IAAAT,WAAA,CAAAqB,GAAA,EAAC5B,YAAA,CAAAqD,+BAAiB;IACjBC,KAAK,EAAG,IAAArB,QAAE,EAAE,WAAY,CAAG;IAC3BsB,aAAa,EAAGb,mBAAqB;IACrCc,cAAc,EAAGf;EAAU,CAC3B,CAAC;AAEJ","ignoreList":[]}
@@ -41,43 +41,30 @@ var _jsxRuntime = require("react/jsx-runtime");
41
41
  password: select(_store.store).getEditedPostAttribute('password')
42
42
  }));
43
43
  const {
44
- editPost,
45
- savePost
44
+ editPost
46
45
  } = (0, _data.useDispatch)(_store.store);
47
46
  const [hasPassword, setHasPassword] = (0, _element.useState)(!!password);
48
- const [showPrivateConfirmDialog, setShowPrivateConfirmDialog] = (0, _element.useState)(false);
49
- const setPublic = () => {
47
+ function updateVisibility(value) {
48
+ const nextValues = {
49
+ public: {
50
+ status: visibility === 'private' ? 'draft' : status,
51
+ password: ''
52
+ },
53
+ private: {
54
+ status: 'private',
55
+ password: ''
56
+ },
57
+ password: {
58
+ status: visibility === 'private' ? 'draft' : status,
59
+ password: password || ''
60
+ }
61
+ };
62
+ editPost(nextValues[value]);
63
+ setHasPassword(value === 'password');
64
+ }
65
+ const updatePassword = value => {
50
66
  editPost({
51
- status: visibility === 'private' ? 'draft' : status,
52
- password: ''
53
- });
54
- setHasPassword(false);
55
- };
56
- const setPrivate = () => {
57
- setShowPrivateConfirmDialog(true);
58
- };
59
- const confirmPrivate = () => {
60
- editPost({
61
- status: 'private',
62
- password: ''
63
- });
64
- setHasPassword(false);
65
- setShowPrivateConfirmDialog(false);
66
- savePost();
67
- };
68
- const handleDialogCancel = () => {
69
- setShowPrivateConfirmDialog(false);
70
- };
71
- const setPasswordProtected = () => {
72
- editPost({
73
- status: visibility === 'private' ? 'draft' : status,
74
- password: password || ''
75
- });
76
- setHasPassword(true);
77
- };
78
- const updatePassword = event => {
79
- editPost({
80
- password: event.target.value
67
+ password: value
81
68
  });
82
69
  };
83
70
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
@@ -86,82 +73,25 @@ var _jsxRuntime = require("react/jsx-runtime");
86
73
  title: (0, _i18n.__)('Visibility'),
87
74
  help: (0, _i18n.__)('Control how this post is viewed.'),
88
75
  onClose: onClose
89
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("fieldset", {
90
- className: "editor-post-visibility__fieldset",
91
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.VisuallyHidden, {
92
- as: "legend",
93
- children: (0, _i18n.__)('Visibility')
94
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(PostVisibilityChoice, {
95
- instanceId: instanceId,
96
- value: "public",
97
- label: _utils.visibilityOptions.public.label,
98
- info: _utils.visibilityOptions.public.info,
99
- checked: visibility === 'public' && !hasPassword,
100
- onChange: setPublic
101
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(PostVisibilityChoice, {
102
- instanceId: instanceId,
103
- value: "private",
104
- label: _utils.visibilityOptions.private.label,
105
- info: _utils.visibilityOptions.private.info,
106
- checked: visibility === 'private',
107
- onChange: setPrivate
108
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(PostVisibilityChoice, {
109
- instanceId: instanceId,
110
- value: "password",
111
- label: _utils.visibilityOptions.password.label,
112
- info: _utils.visibilityOptions.password.info,
113
- checked: hasPassword,
114
- onChange: setPasswordProtected
115
- }), hasPassword && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
116
- className: "editor-post-visibility__password",
117
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.VisuallyHidden, {
118
- as: "label",
119
- htmlFor: `editor-post-visibility__password-input-${instanceId}`,
120
- children: (0, _i18n.__)('Create password')
121
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
122
- className: "editor-post-visibility__password-input",
123
- id: `editor-post-visibility__password-input-${instanceId}`,
124
- type: "text",
125
- onChange: updatePassword,
126
- value: password,
127
- placeholder: (0, _i18n.__)('Use a secure password')
128
- })]
76
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
77
+ spacing: 4,
78
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.RadioControl, {
79
+ label: (0, _i18n.__)('Visibility'),
80
+ hideLabelFromVision: true,
81
+ options: _utils.VISIBILITY_OPTIONS,
82
+ selected: hasPassword ? 'password' : visibility,
83
+ onChange: updateVisibility
84
+ }), hasPassword && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextControl, {
85
+ label: (0, _i18n.__)('Password'),
86
+ onChange: updatePassword,
87
+ value: password,
88
+ placeholder: (0, _i18n.__)('Use a secure password'),
89
+ type: "text",
90
+ id: `editor-post-visibility__password-input-${instanceId}`,
91
+ __next40pxDefaultSize: true,
92
+ __nextHasNoMarginBottom: true,
93
+ maxLength: 255
129
94
  })]
130
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalConfirmDialog, {
131
- isOpen: showPrivateConfirmDialog,
132
- onConfirm: confirmPrivate,
133
- onCancel: handleDialogCancel,
134
- confirmButtonText: (0, _i18n.__)('Publish'),
135
- size: "medium",
136
- children: (0, _i18n.__)('Would you like to privately publish this post now?')
137
- })]
138
- });
139
- }
140
- function PostVisibilityChoice({
141
- instanceId,
142
- value,
143
- label,
144
- info,
145
- ...props
146
- }) {
147
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
148
- className: "editor-post-visibility__choice",
149
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
150
- type: "radio",
151
- name: `editor-post-visibility__setting-${instanceId}`,
152
- value: value,
153
- id: `editor-post-${value}-${instanceId}`,
154
- "aria-describedby": `editor-post-${value}-${instanceId}-description`,
155
- className: "editor-post-visibility__radio",
156
- ...props
157
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
158
- htmlFor: `editor-post-${value}-${instanceId}`,
159
- className: "editor-post-visibility__label",
160
- children: label
161
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
162
- id: `editor-post-${value}-${instanceId}-description`,
163
- className: "editor-post-visibility__info",
164
- children: info
165
95
  })]
166
96
  });
167
97
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_element","_components","_compose","_data","_blockEditor","_utils","_store","_jsxRuntime","PostVisibility","onClose","instanceId","useInstanceId","status","visibility","password","useSelect","select","editorStore","getEditedPostAttribute","getEditedPostVisibility","editPost","savePost","useDispatch","hasPassword","setHasPassword","useState","showPrivateConfirmDialog","setShowPrivateConfirmDialog","setPublic","setPrivate","confirmPrivate","handleDialogCancel","setPasswordProtected","updatePassword","event","target","value","jsxs","className","children","jsx","__experimentalInspectorPopoverHeader","title","__","help","VisuallyHidden","as","PostVisibilityChoice","label","visibilityOptions","public","info","checked","onChange","private","htmlFor","id","type","placeholder","__experimentalConfirmDialog","isOpen","onConfirm","onCancel","confirmButtonText","size","props","name"],"sources":["@wordpress/editor/src/components/post-visibility/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport {\n\tVisuallyHidden,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { visibilityOptions } from './utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * Allows users to set the visibility of a post.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose Function to call when the popover is closed.\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostVisibility( { onClose } ) {\n\tconst instanceId = useInstanceId( PostVisibility );\n\n\tconst { status, visibility, password } = useSelect( ( select ) => ( {\n\t\tstatus: select( editorStore ).getEditedPostAttribute( 'status' ),\n\t\tvisibility: select( editorStore ).getEditedPostVisibility(),\n\t\tpassword: select( editorStore ).getEditedPostAttribute( 'password' ),\n\t} ) );\n\n\tconst { editPost, savePost } = useDispatch( editorStore );\n\n\tconst [ hasPassword, setHasPassword ] = useState( !! password );\n\tconst [ showPrivateConfirmDialog, setShowPrivateConfirmDialog ] =\n\t\tuseState( false );\n\n\tconst setPublic = () => {\n\t\teditPost( {\n\t\t\tstatus: visibility === 'private' ? 'draft' : status,\n\t\t\tpassword: '',\n\t\t} );\n\t\tsetHasPassword( false );\n\t};\n\n\tconst setPrivate = () => {\n\t\tsetShowPrivateConfirmDialog( true );\n\t};\n\n\tconst confirmPrivate = () => {\n\t\teditPost( { status: 'private', password: '' } );\n\t\tsetHasPassword( false );\n\t\tsetShowPrivateConfirmDialog( false );\n\t\tsavePost();\n\t};\n\n\tconst handleDialogCancel = () => {\n\t\tsetShowPrivateConfirmDialog( false );\n\t};\n\n\tconst setPasswordProtected = () => {\n\t\teditPost( {\n\t\t\tstatus: visibility === 'private' ? 'draft' : status,\n\t\t\tpassword: password || '',\n\t\t} );\n\t\tsetHasPassword( true );\n\t};\n\n\tconst updatePassword = ( event ) => {\n\t\teditPost( { password: event.target.value } );\n\t};\n\n\treturn (\n\t\t<div className=\"editor-post-visibility\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Visibility' ) }\n\t\t\t\thelp={ __( 'Control how this post is viewed.' ) }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t<fieldset className=\"editor-post-visibility__fieldset\">\n\t\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t\t{ __( 'Visibility' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t<PostVisibilityChoice\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\tvalue=\"public\"\n\t\t\t\t\tlabel={ visibilityOptions.public.label }\n\t\t\t\t\tinfo={ visibilityOptions.public.info }\n\t\t\t\t\tchecked={ visibility === 'public' && ! hasPassword }\n\t\t\t\t\tonChange={ setPublic }\n\t\t\t\t/>\n\t\t\t\t<PostVisibilityChoice\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\tvalue=\"private\"\n\t\t\t\t\tlabel={ visibilityOptions.private.label }\n\t\t\t\t\tinfo={ visibilityOptions.private.info }\n\t\t\t\t\tchecked={ visibility === 'private' }\n\t\t\t\t\tonChange={ setPrivate }\n\t\t\t\t/>\n\t\t\t\t<PostVisibilityChoice\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\tvalue=\"password\"\n\t\t\t\t\tlabel={ visibilityOptions.password.label }\n\t\t\t\t\tinfo={ visibilityOptions.password.info }\n\t\t\t\t\tchecked={ hasPassword }\n\t\t\t\t\tonChange={ setPasswordProtected }\n\t\t\t\t/>\n\t\t\t\t{ hasPassword && (\n\t\t\t\t\t<div className=\"editor-post-visibility__password\">\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"label\"\n\t\t\t\t\t\t\thtmlFor={ `editor-post-visibility__password-input-${ instanceId }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create password' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tclassName=\"editor-post-visibility__password-input\"\n\t\t\t\t\t\t\tid={ `editor-post-visibility__password-input-${ instanceId }` }\n\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\tonChange={ updatePassword }\n\t\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\t\tplaceholder={ __( 'Use a secure password' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</fieldset>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showPrivateConfirmDialog }\n\t\t\t\tonConfirm={ confirmPrivate }\n\t\t\t\tonCancel={ handleDialogCancel }\n\t\t\t\tconfirmButtonText={ __( 'Publish' ) }\n\t\t\t\tsize=\"medium\"\n\t\t\t>\n\t\t\t\t{ __( 'Would you like to privately publish this post now?' ) }\n\t\t\t</ConfirmDialog>\n\t\t</div>\n\t);\n}\n\nfunction PostVisibilityChoice( { instanceId, value, label, info, ...props } ) {\n\treturn (\n\t\t<div className=\"editor-post-visibility__choice\">\n\t\t\t<input\n\t\t\t\ttype=\"radio\"\n\t\t\t\tname={ `editor-post-visibility__setting-${ instanceId }` }\n\t\t\t\tvalue={ value }\n\t\t\t\tid={ `editor-post-${ value }-${ instanceId }` }\n\t\t\t\taria-describedby={ `editor-post-${ value }-${ instanceId }-description` }\n\t\t\t\tclassName=\"editor-post-visibility__radio\"\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t\t<label\n\t\t\t\thtmlFor={ `editor-post-${ value }-${ instanceId }` }\n\t\t\t\tclassName=\"editor-post-visibility__label\"\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</label>\n\t\t\t<p\n\t\t\t\tid={ `editor-post-${ value }-${ instanceId }-description` }\n\t\t\t\tclassName=\"editor-post-visibility__info\"\n\t\t\t>\n\t\t\t\t{ info }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAIA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAmD,IAAAQ,WAAA,GAAAR,OAAA;AAjBnD;AACA;AACA;;AAWA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA,GACe,SAASS,cAAcA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACrD,MAAMC,UAAU,GAAG,IAAAC,sBAAa,EAAEH,cAAe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G/B,kBAAoB;MAC/BgC,iBAAiB,EAAG,IAAApB,QAAE,EAAE,SAAU,CAAG;MACrCqB,IAAI,EAAC,QAAQ;MAAAzB,QAAA,EAEX,IAAAI,QAAE,EAAE,oDAAqD;IAAC,CAC9C,CAAC;EAAA,CACZ,CAAC;AAER;AAEA,SAASI,oBAAoBA,CAAE;EAAErC,UAAU;EAAE0B,KAAK;EAAEY,KAAK;EAAEG,IAAI;EAAE,GAAGc;AAAM,CAAC,EAAG;EAC7E,oBACC,IAAA1D,WAAA,CAAA8B,IAAA;IAAKC,SAAS,EAAC,gCAAgC;IAAAC,QAAA,gBAC9C,IAAAhC,WAAA,CAAAiC,GAAA;MACCiB,IAAI,EAAC,OAAO;MACZS,IAAI,EAAG,mCAAoCxD,UAAU,EAAK;MAC1D0B,KAAK,EAAGA,KAAO;MACfoB,EAAE,EAAG,eAAgBpB,KAAK,IAAM1B,UAAU,EAAK;MAC/C,oBAAmB,eAAgB0B,KAAK,IAAM1B,UAAU,cAAiB;MACzE4B,SAAS,EAAC,+BAA+B;MAAA,GACpC2B;IAAK,CACV,CAAC,eACF,IAAA1D,WAAA,CAAAiC,GAAA;MACCe,OAAO,EAAG,eAAgBnB,KAAK,IAAM1B,UAAU,EAAK;MACpD4B,SAAS,EAAC,+BAA+B;MAAAC,QAAA,EAEvCS;IAAK,CACD,CAAC,eACR,IAAAzC,WAAA,CAAAiC,GAAA;MACCgB,EAAE,EAAG,eAAgBpB,KAAK,IAAM1B,UAAU,cAAiB;MAC3D4B,SAAS,EAAC,8BAA8B;MAAAC,QAAA,EAEtCY;IAAI,CACJ,CAAC;EAAA,CACA,CAAC;AAER","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_element","_components","_compose","_data","_blockEditor","_utils","_store","_jsxRuntime","PostVisibility","onClose","instanceId","useInstanceId","status","visibility","password","useSelect","select","editorStore","getEditedPostAttribute","getEditedPostVisibility","editPost","useDispatch","hasPassword","setHasPassword","useState","updateVisibility","value","nextValues","public","private","updatePassword","jsxs","className","children","jsx","__experimentalInspectorPopoverHeader","title","__","help","__experimentalVStack","spacing","RadioControl","label","hideLabelFromVision","options","VISIBILITY_OPTIONS","selected","onChange","TextControl","placeholder","type","id","__next40pxDefaultSize","__nextHasNoMarginBottom","maxLength"],"sources":["@wordpress/editor/src/components/post-visibility/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport {\n\tTextControl,\n\tRadioControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { VISIBILITY_OPTIONS } from './utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * Allows users to set the visibility of a post.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose Function to call when the popover is closed.\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostVisibility( { onClose } ) {\n\tconst instanceId = useInstanceId( PostVisibility );\n\n\tconst { status, visibility, password } = useSelect( ( select ) => ( {\n\t\tstatus: select( editorStore ).getEditedPostAttribute( 'status' ),\n\t\tvisibility: select( editorStore ).getEditedPostVisibility(),\n\t\tpassword: select( editorStore ).getEditedPostAttribute( 'password' ),\n\t} ) );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst [ hasPassword, setHasPassword ] = useState( !! password );\n\n\tfunction updateVisibility( value ) {\n\t\tconst nextValues = {\n\t\t\tpublic: {\n\t\t\t\tstatus: visibility === 'private' ? 'draft' : status,\n\t\t\t\tpassword: '',\n\t\t\t},\n\t\t\tprivate: { status: 'private', password: '' },\n\t\t\tpassword: {\n\t\t\t\tstatus: visibility === 'private' ? 'draft' : status,\n\t\t\t\tpassword: password || '',\n\t\t\t},\n\t\t};\n\n\t\teditPost( nextValues[ value ] );\n\t\tsetHasPassword( value === 'password' );\n\t}\n\n\tconst updatePassword = ( value ) => {\n\t\teditPost( { password: value } );\n\t};\n\n\treturn (\n\t\t<div className=\"editor-post-visibility\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Visibility' ) }\n\t\t\t\thelp={ __( 'Control how this post is viewed.' ) }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<RadioControl\n\t\t\t\t\tlabel={ __( 'Visibility' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\toptions={ VISIBILITY_OPTIONS }\n\t\t\t\t\tselected={ hasPassword ? 'password' : visibility }\n\t\t\t\t\tonChange={ updateVisibility }\n\t\t\t\t/>\n\t\t\t\t{ hasPassword && (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Password' ) }\n\t\t\t\t\t\tonChange={ updatePassword }\n\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\tplaceholder={ __( 'Use a secure password' ) }\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\tid={ `editor-post-visibility__password-input-${ instanceId }` }\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tmaxLength={ 255 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAmD,IAAAQ,WAAA,GAAAR,OAAA;AAlBnD;AACA;AACA;;AAYA;AACA;AACA;;AAIA;AACA;AACA;AACA;AAC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CAAC;EAChC,CAAC;EAED,oBACC,IAAAnB,WAAA,CAAAwB,IAAA;IAAKC,SAAS,EAAC,wBAAwB;IAAAC,QAAA,gBACtC,IAAA1B,WAAA,CAAA2B,GAAA,EAAC9B,YAAA,CAAA+B,oCAAsB;MACtBC,KAAK,EAAG,IAAAC,QAAE,EAAE,YAAa,CAAG;MAC5BC,IAAI,EAAG,IAAAD,QAAE,EAAE,kCAAmC,CAAG;MACjD5B,OAAO,EAAGA;IAAS,CACnB,CAAC,eACF,IAAAF,WAAA,CAAAwB,IAAA,EAAC9B,WAAA,CAAAsC,oBAAM;MAACC,OAAO,EAAG,CAAG;MAAAP,QAAA,gBACpB,IAAA1B,WAAA,CAAA2B,GAAA,EAACjC,WAAA,CAAAwC,YAAY;QACZC,KAAK,EAAG,IAAAL,QAAE,EAAE,YAAa,CAAG;QAC5BM,mBAAmB;QACnBC,OAAO,EAAGC,yBAAoB;QAC9BC,QAAQ,EAAGxB,WAAW,GAAG,UAAU,GAAGT,UAAY;QAClDkC,QAAQ,EAAGtB;MAAkB,CAC7B,CAAC,EACAH,WAAW,iBACZ,IAAAf,WAAA,CAAA2B,GAAA,EAACjC,WAAA,CAAA+C,WAAW;QACXN,KAAK,EAAG,IAAAL,QAAE,EAAE,UAAW,CAAG;QAC1BU,QAAQ,EAAGjB,cAAgB;QAC3BJ,KAAK,EAAGZ,QAAU;QAClBmC,WAAW,EAAG,IAAAZ,QAAE,EAAE,uBAAwB,CAAG;QAC7Ca,IAAI,EAAC,MAAM;QACXC,EAAE,EAAG,0CAA2CzC,UAAU,EAAK;QAC/D0C,qBAAqB;QACrBC,uBAAuB;QACvBC,SAAS,EAAG;MAAK,CACjB,CACD;IAAA,CACM,CAAC;EAAA,CACL,CAAC;AAER","ignoreList":[]}
@@ -31,7 +31,7 @@ function PostVisibilityLabel() {
31
31
  * @return {string} Post visibility label.
32
32
  */
33
33
  function usePostVisibilityLabel() {
34
- const visibility = (0, _data.useSelect)(select => select(_store.store).getEditedPostVisibility());
35
- return _utils.visibilityOptions[visibility]?.label;
34
+ const visibility = (0, _data.useSelect)(select => select(_store.store).getEditedPostVisibility(), []);
35
+ return _utils.VISIBILITY_OPTIONS.find(option => option.value === visibility)?.label;
36
36
  }
37
37
  //# sourceMappingURL=label.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_utils","_store","PostVisibilityLabel","usePostVisibilityLabel","visibility","useSelect","select","editorStore","getEditedPostVisibility","visibilityOptions","label"],"sources":["@wordpress/editor/src/components/post-visibility/label.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { visibilityOptions } from './utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * Returns the label for the current post visibility setting.\n *\n * @return {string} Post visibility label.\n */\nexport default function PostVisibilityLabel() {\n\treturn usePostVisibilityLabel();\n}\n\n/**\n * Get the label for the current post visibility setting.\n *\n * @return {string} Post visibility label.\n */\nexport function usePostVisibilityLabel() {\n\tconst visibility = useSelect( ( select ) =>\n\t\tselect( editorStore ).getEditedPostVisibility()\n\t);\n\treturn visibilityOptions[ visibility ]?.label;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACe,SAASG,mBAAmBA,CAAA,EAAG;EAC7C,OAAOC,sBAAsB,CAAC,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAsBA,CAAA,EAAG;EACxC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EAAIC,MAAM,IACrCA,MAAM,CAAEC,YAAY,CAAC,CAACC,uBAAuB,CAAC,CAC/C,CAAC;EACD,OAAOC,wBAAiB,CAAEL,UAAU,CAAE,EAAEM,KAAK;AAC9C","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_utils","_store","PostVisibilityLabel","usePostVisibilityLabel","visibility","useSelect","select","editorStore","getEditedPostVisibility","VISIBILITY_OPTIONS","find","option","value","label"],"sources":["@wordpress/editor/src/components/post-visibility/label.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { VISIBILITY_OPTIONS } from './utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * Returns the label for the current post visibility setting.\n *\n * @return {string} Post visibility label.\n */\nexport default function PostVisibilityLabel() {\n\treturn usePostVisibilityLabel();\n}\n\n/**\n * Get the label for the current post visibility setting.\n *\n * @return {string} Post visibility label.\n */\nexport function usePostVisibilityLabel() {\n\tconst visibility = useSelect(\n\t\t( select ) => select( editorStore ).getEditedPostVisibility(),\n\t\t[]\n\t);\n\n\treturn VISIBILITY_OPTIONS.find( ( option ) => option.value === visibility )\n\t\t?.label;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACe,SAASG,mBAAmBA,CAAA,EAAG;EAC7C,OAAOC,sBAAsB,CAAC,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAsBA,CAAA,EAAG;EACxC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EACzBC,MAAM,IAAMA,MAAM,CAAEC,YAAY,CAAC,CAACC,uBAAuB,CAAC,CAAC,EAC7D,EACD,CAAC;EAED,OAAOC,yBAAkB,CAACC,IAAI,CAAIC,MAAM,IAAMA,MAAM,CAACC,KAAK,KAAKR,UAAW,CAAC,EACxES,KAAK;AACT","ignoreList":[]}
@@ -3,24 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.visibilityOptions = void 0;
6
+ exports.VISIBILITY_OPTIONS = void 0;
7
7
  var _i18n = require("@wordpress/i18n");
8
8
  /**
9
9
  * WordPress dependencies
10
10
  */
11
11
 
12
- const visibilityOptions = exports.visibilityOptions = {
13
- public: {
14
- label: (0, _i18n.__)('Public'),
15
- info: (0, _i18n.__)('Visible to everyone.')
16
- },
17
- private: {
18
- label: (0, _i18n.__)('Private'),
19
- info: (0, _i18n.__)('Only visible to site admins and editors.')
20
- },
21
- password: {
22
- label: (0, _i18n.__)('Password protected'),
23
- info: (0, _i18n.__)('Only those with the password can view this post.')
24
- }
25
- };
12
+ const VISIBILITY_OPTIONS = exports.VISIBILITY_OPTIONS = [{
13
+ label: (0, _i18n.__)('Public'),
14
+ value: 'public',
15
+ description: (0, _i18n.__)('Visible to everyone.')
16
+ }, {
17
+ label: (0, _i18n.__)('Private'),
18
+ value: 'private',
19
+ description: (0, _i18n.__)('Only visible to site admins and editors.')
20
+ }, {
21
+ label: (0, _i18n.__)('Password protected'),
22
+ value: 'password',
23
+ description: (0, _i18n.__)('Only visible to those who know the password.')
24
+ }];
26
25
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","visibilityOptions","exports","public","label","__","info","private","password"],"sources":["@wordpress/editor/src/components/post-visibility/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const visibilityOptions = {\n\tpublic: {\n\t\tlabel: __( 'Public' ),\n\t\tinfo: __( 'Visible to everyone.' ),\n\t},\n\tprivate: {\n\t\tlabel: __( 'Private' ),\n\t\tinfo: __( 'Only visible to site admins and editors.' ),\n\t},\n\tpassword: {\n\t\tlabel: __( 'Password protected' ),\n\t\tinfo: __( 'Only those with the password can view this post.' ),\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EAChCE,MAAM,EAAE;IACPC,KAAK,EAAE,IAAAC,QAAE,EAAE,QAAS,CAAC;IACrBC,IAAI,EAAE,IAAAD,QAAE,EAAE,sBAAuB;EAClC,CAAC;EACDE,OAAO,EAAE;IACRH,KAAK,EAAE,IAAAC,QAAE,EAAE,SAAU,CAAC;IACtBC,IAAI,EAAE,IAAAD,QAAE,EAAE,0CAA2C;EACtD,CAAC;EACDG,QAAQ,EAAE;IACTJ,KAAK,EAAE,IAAAC,QAAE,EAAE,oBAAqB,CAAC;IACjCC,IAAI,EAAE,IAAAD,QAAE,EAAE,kDAAmD;EAC9D;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","VISIBILITY_OPTIONS","exports","label","__","value","description"],"sources":["@wordpress/editor/src/components/post-visibility/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const VISIBILITY_OPTIONS = [\n\t{\n\t\tlabel: __( 'Public' ),\n\t\tvalue: 'public',\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n\t{\n\t\tlabel: __( 'Private' ),\n\t\tvalue: 'private',\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tlabel: __( 'Password protected' ),\n\t\tvalue: 'password',\n\t\tdescription: __( 'Only visible to those who know the password.' ),\n\t},\n];\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,CACjC;EACCE,KAAK,EAAE,IAAAC,QAAE,EAAE,QAAS,CAAC;EACrBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE,IAAAF,QAAE,EAAE,sBAAuB;AACzC,CAAC,EACD;EACCD,KAAK,EAAE,IAAAC,QAAE,EAAE,SAAU,CAAC;EACtBC,KAAK,EAAE,SAAS;EAChBC,WAAW,EAAE,IAAAF,QAAE,EAAE,0CAA2C;AAC7D,CAAC,EACD;EACCD,KAAK,EAAE,IAAAC,QAAE,EAAE,oBAAqB,CAAC;EACjCC,KAAK,EAAE,UAAU;EACjBC,WAAW,EAAE,IAAAF,QAAE,EAAE,8CAA+C;AACjE,CAAC,CACD","ignoreList":[]}
@@ -48,11 +48,9 @@ function PreviewDropdown({
48
48
  const {
49
49
  getDeviceType,
50
50
  getCurrentPostType,
51
- getCurrentTemplateId
52
- } = select(_store.store);
53
- const {
51
+ getCurrentTemplateId,
54
52
  getRenderingMode
55
- } = (0, _lockUnlock.unlock)(select(_store.store));
53
+ } = select(_store.store);
56
54
  const {
57
55
  getEntityRecord,
58
56
  getPostType