@wordpress/edit-site 3.0.15 → 3.0.16
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.
- package/build/components/add-new-template/new-template-part.js +29 -18
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +30 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js +51 -0
- package/build/components/app/index.js.map +1 -0
- package/build/components/block-editor/back-button.js +8 -20
- package/build/components/block-editor/back-button.js.map +1 -1
- package/build/components/block-editor/index.js +2 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +0 -2
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/edit-template-part-menu-button/index.js +20 -8
- package/build/components/edit-template-part-menu-button/index.js.map +1 -1
- package/build/components/editor/index.js +11 -30
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +10 -10
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/header/document-actions/index.js +3 -6
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/list/index.js +17 -15
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +4 -4
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-sidebar/index.js +12 -13
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +26 -24
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/routes/index.js +60 -0
- package/build/components/routes/index.js.map +1 -0
- package/build/components/routes/link.js +65 -0
- package/build/components/routes/link.js.map +1 -0
- package/build/components/routes/use-title.js +57 -0
- package/build/components/routes/use-title.js.map +1 -0
- package/build/components/sidebar/global-styles-sidebar.js +10 -0
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar/template-card/template-areas.js +7 -4
- package/build/components/sidebar/template-card/template-areas.js.map +1 -1
- package/build/components/template-details/index.js +12 -10
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +27 -10
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +7 -12
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/url-query-controller/index.js +41 -50
- package/build/components/url-query-controller/index.js.map +1 -1
- package/build/components/welcome-guide/editor.js +6 -0
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/components/welcome-guide/index.js +1 -28
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/styles.js +18 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/index.js +29 -35
- package/build/index.js.map +1 -1
- package/build/plugins/index.js +3 -23
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/site-export.js +61 -0
- package/build/plugins/site-export.js.map +1 -0
- package/build/plugins/welcome-guide-menu-item.js +1 -7
- package/build/plugins/welcome-guide-menu-item.js.map +1 -1
- package/build/store/actions.js +0 -27
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +1 -14
- package/build/store/constants.js.map +1 -1
- package/build/store/reducer.js +7 -16
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -31
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-is-list-page.js +23 -0
- package/build/utils/get-is-list-page.js.map +1 -0
- package/build/utils/history.js +35 -0
- package/build/utils/history.js.map +1 -0
- package/build-module/components/add-new-template/new-template-part.js +27 -16
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +28 -18
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js +35 -0
- package/build-module/components/app/index.js.map +1 -0
- package/build-module/components/block-editor/back-button.js +8 -19
- package/build-module/components/block-editor/back-button.js.map +1 -1
- package/build-module/components/block-editor/index.js +2 -1
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +0 -2
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/edit-template-part-menu-button/index.js +17 -9
- package/build-module/components/edit-template-part-menu-button/index.js.map +1 -1
- package/build-module/components/editor/index.js +13 -33
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +10 -10
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +3 -6
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/list/index.js +15 -15
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +4 -4
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-sidebar/index.js +13 -13
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +24 -24
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/routes/index.js +47 -0
- package/build-module/components/routes/index.js.map +1 -0
- package/build-module/components/routes/link.js +51 -0
- package/build-module/components/routes/link.js.map +1 -0
- package/build-module/components/routes/use-title.js +44 -0
- package/build-module/components/routes/use-title.js.map +1 -0
- package/build-module/components/sidebar/global-styles-sidebar.js +8 -0
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar/template-card/template-areas.js +8 -4
- package/build-module/components/sidebar/template-card/template-areas.js.map +1 -1
- package/build-module/components/template-details/index.js +10 -9
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +24 -9
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +7 -12
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/url-query-controller/index.js +40 -49
- package/build-module/components/url-query-controller/index.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +7 -1
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +2 -26
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +18 -2
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/index.js +28 -33
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/index.js +2 -18
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/site-export.js +45 -0
- package/build-module/plugins/site-export.js.map +1 -0
- package/build-module/plugins/welcome-guide-menu-item.js +2 -7
- package/build-module/plugins/welcome-guide-menu-item.js.map +1 -1
- package/build-module/store/actions.js +0 -23
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +0 -11
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/reducer.js +7 -16
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +1 -27
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +16 -0
- package/build-module/utils/get-is-list-page.js.map +1 -0
- package/build-module/utils/history.js +25 -0
- package/build-module/utils/history.js.map +1 -0
- package/build-style/style-rtl.css +1 -6
- package/build-style/style.css +1 -6
- package/package.json +9 -8
- package/src/components/add-new-template/new-template-part.js +29 -11
- package/src/components/add-new-template/new-template.js +26 -12
- package/src/components/app/index.js +47 -0
- package/src/components/block-editor/back-button.js +6 -14
- package/src/components/block-editor/index.js +1 -0
- package/src/components/create-template-part-modal/index.js +0 -2
- package/src/components/edit-template-part-menu-button/index.js +16 -5
- package/src/components/editor/index.js +105 -131
- package/src/components/global-styles/gradients-palette-panel.js +12 -12
- package/src/components/global-styles/use-global-styles-output.js +0 -1
- package/src/components/header/document-actions/index.js +3 -9
- package/src/components/list/index.js +11 -12
- package/src/components/list/style.scss +6 -11
- package/src/components/list/table.js +5 -5
- package/src/components/navigation-sidebar/index.js +18 -17
- package/src/components/navigation-sidebar/navigation-panel/index.js +16 -22
- package/src/components/routes/index.js +53 -0
- package/src/components/routes/link.js +44 -0
- package/src/components/routes/use-title.js +56 -0
- package/src/components/sidebar/global-styles-sidebar.js +8 -0
- package/src/components/sidebar/template-card/template-areas.js +16 -4
- package/src/components/template-details/index.js +8 -6
- package/src/components/template-details/template-areas.js +31 -8
- package/src/components/template-part-converter/convert-to-template-part.js +4 -2
- package/src/components/url-query-controller/index.js +34 -45
- package/src/components/welcome-guide/editor.js +10 -1
- package/src/components/welcome-guide/index.js +6 -25
- package/src/components/welcome-guide/styles.js +20 -2
- package/src/index.js +33 -36
- package/src/plugins/index.js +2 -32
- package/src/plugins/site-export.js +48 -0
- package/src/plugins/welcome-guide-menu-item.js +2 -16
- package/src/store/actions.js +0 -23
- package/src/store/constants.js +0 -12
- package/src/store/reducer.js +12 -26
- package/src/store/selectors.js +1 -27
- package/src/store/test/reducer.js +22 -39
- package/src/store/test/selectors.js +3 -34
- package/src/utils/get-is-list-page.js +11 -0
- package/src/utils/history.js +35 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["classnames","store","coreStore","useSelect","InterfaceSkeleton","__","sprintf","keyboardShortcutsStore","EditorSnackbars","useRegisterShortcuts","Header","NavigationSidebar","Table","editSiteStore","List","templateType","previousShortcut","nextShortcut","isNavigationOpen","select","getAllShortcutKeyCombinations","isNavigationOpened","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["classnames","store","coreStore","useSelect","InterfaceSkeleton","__","sprintf","keyboardShortcutsStore","EditorSnackbars","useRegisterShortcuts","Header","NavigationSidebar","Table","editSiteStore","useLocation","useTitle","List","params","postType","templateType","previousShortcut","nextShortcut","isNavigationOpen","select","getAllShortcutKeyCombinations","isNavigationOpened","getPostType","labels","name","itemsListLabel","items_list","detailedRegionLabels","header","body","undefined","drawer","previous","next"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASL,KAAK,IAAIM,sBAAlB,QAAgD,+BAAhD;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,SAASX,KAAK,IAAIY,aAAlB,QAAuC,aAAvC;AACA,SAASC,WAAT,QAA4B,WAA5B;AACA,OAAOC,QAAP,MAAqB,qBAArB;AAEA,eAAe,SAASC,IAAT,GAAgB;AAAA;;AAC9B,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,QAAQ,EAAEC;AAAZ;AADH,MAEFL,WAAW,EAFf;AAIAL,EAAAA,oBAAoB;AAEpB,QAAM;AAAEW,IAAAA,gBAAF;AAAoBC,IAAAA,YAApB;AAAkCC,IAAAA;AAAlC,MAAuDnB,SAAS,CACnEoB,MAAF,IAAc;AACb,WAAO;AACNH,MAAAA,gBAAgB,EAAEG,MAAM,CACvBhB,sBADuB,CAAN,CAEhBiB,6BAFgB,CAGjB,gCAHiB,CADZ;AAMNH,MAAAA,YAAY,EAAEE,MAAM,CACnBhB,sBADmB,CAAN,CAEZiB,6BAFY,CAEmB,4BAFnB,CANR;AASNF,MAAAA,gBAAgB,EAAEC,MAAM,CAAEV,aAAF,CAAN,CAAwBY,kBAAxB;AATZ,KAAP;AAWA,GAboE,EAcrE,EAdqE,CAAtE;AAiBA,QAAMP,QAAQ,GAAGf,SAAS,CACvBoB,MAAF,IAAcA,MAAM,CAAErB,SAAF,CAAN,CAAoBwB,WAApB,CAAiCP,YAAjC,CADW,EAEzB,CAAEA,YAAF,CAFyB,CAA1B;AAKAJ,EAAAA,QAAQ,CAAEG,QAAF,aAAEA,QAAF,2CAAEA,QAAQ,CAAES,MAAZ,qDAAE,iBAAkBC,IAApB,CAAR,CA7B8B,CA+B9B;AACA;;AACA,QAAMC,cAAc,GAAGX,QAAH,aAAGA,QAAH,4CAAGA,QAAQ,CAAES,MAAb,sDAAG,kBAAkBG,UAAzC;AACA,QAAMC,oBAAoB,GAAGb,QAAQ,GAClC;AACAc,IAAAA,MAAM,EAAE1B,OAAO,EACd;AACAD,IAAAA,EAAE,CAAE,aAAF,CAFY,EAGdwB,cAHc,CADf;AAMAI,IAAAA,IAAI,EAAE3B,OAAO,EACZ;AACAD,IAAAA,EAAE,CAAE,cAAF,CAFU,EAGZwB,cAHY;AANb,GADkC,GAalCK,SAbH;AAeA,SACC,cAAC,iBAAD;AACC,IAAA,SAAS,EAAGlC,UAAU,CAAE,gBAAF,EAAoB;AACzC,4BAAsBsB;AADmB,KAApB,CADvB;AAIC,IAAA,MAAM,EAAG;AACRa,MAAAA,MAAM,EAAE9B,EAAE,CAAE,oBAAF,CADF;AAER,SAAG0B;AAFK,KAJV;AAQC,IAAA,MAAM,EAAG,cAAC,MAAD;AAAQ,MAAA,YAAY,EAAGZ;AAAvB,MARV;AASC,IAAA,MAAM,EAAG,cAAC,iBAAD,CAAmB,IAAnB,OATV;AAUC,IAAA,OAAO,EAAG,cAAC,eAAD,OAVX;AAWC,IAAA,OAAO,EAAG,cAAC,KAAD;AAAO,MAAA,YAAY,EAAGA;AAAtB,MAXX;AAYC,IAAA,SAAS,EAAG;AACXiB,MAAAA,QAAQ,EAAEhB,gBADC;AAEXiB,MAAAA,IAAI,EAAEhB;AAFK;AAZb,IADD;AAmBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { InterfaceSkeleton } from '@wordpress/interface';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useRegisterShortcuts from './use-register-shortcuts';\nimport Header from './header';\nimport NavigationSidebar from '../navigation-sidebar';\nimport Table from './table';\nimport { store as editSiteStore } from '../../store';\nimport { useLocation } from '../routes';\nimport useTitle from '../routes/use-title';\n\nexport default function List() {\n\tconst {\n\t\tparams: { postType: templateType },\n\t} = useLocation();\n\n\tuseRegisterShortcuts();\n\n\tconst { previousShortcut, nextShortcut, isNavigationOpen } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tpreviousShortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getAllShortcutKeyCombinations(\n\t\t\t\t\t'core/edit-site/previous-region'\n\t\t\t\t),\n\t\t\t\tnextShortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t\t\tisNavigationOpen: select( editSiteStore ).isNavigationOpened(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tuseTitle( postType?.labels?.name );\n\n\t// `postType` could load in asynchronously. Only provide the detailed region labels if\n\t// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.\n\tconst itemsListLabel = postType?.labels?.items_list;\n\tconst detailedRegionLabels = postType\n\t\t? {\n\t\t\t\theader: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Header' as in the header area of that page.\n\t\t\t\t\t__( '%s - Header' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t\t\tbody: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Content' as in the content area of that page.\n\t\t\t\t\t__( '%s - Content' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t }\n\t\t: undefined;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tclassName={ classnames( 'edit-site-list', {\n\t\t\t\t'is-navigation-open': isNavigationOpen,\n\t\t\t} ) }\n\t\t\tlabels={ {\n\t\t\t\tdrawer: __( 'Navigation Sidebar' ),\n\t\t\t\t...detailedRegionLabels,\n\t\t\t} }\n\t\t\theader={ <Header templateType={ templateType } /> }\n\t\t\tdrawer={ <NavigationSidebar.Slot /> }\n\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\tcontent={ <Table templateType={ templateType } /> }\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -7,11 +7,11 @@ import { useSelect } from '@wordpress/data';
|
|
|
7
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
8
8
|
import { __, sprintf } from '@wordpress/i18n';
|
|
9
9
|
import { VisuallyHidden, __experimentalHeading as Heading } from '@wordpress/components';
|
|
10
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
11
10
|
/**
|
|
12
11
|
* Internal dependencies
|
|
13
12
|
*/
|
|
14
13
|
|
|
14
|
+
import Link from '../routes/link';
|
|
15
15
|
import Actions from './actions';
|
|
16
16
|
import AddedBy from './added-by';
|
|
17
17
|
export default function Table(_ref) {
|
|
@@ -79,11 +79,11 @@ export default function Table(_ref) {
|
|
|
79
79
|
role: "cell"
|
|
80
80
|
}, createElement(Heading, {
|
|
81
81
|
level: 4
|
|
82
|
-
}, createElement(
|
|
83
|
-
|
|
82
|
+
}, createElement(Link, {
|
|
83
|
+
params: {
|
|
84
84
|
postId: template.id,
|
|
85
85
|
postType: template.type
|
|
86
|
-
}
|
|
86
|
+
}
|
|
87
87
|
}, ((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug)), template.description), createElement("td", {
|
|
88
88
|
className: "edit-site-list-table-column",
|
|
89
89
|
role: "cell"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["useSelect","store","coreStore","__","sprintf","VisuallyHidden","__experimentalHeading","Heading","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["useSelect","store","coreStore","__","sprintf","VisuallyHidden","__experimentalHeading","Heading","Link","Actions","AddedBy","Table","templateType","templates","isLoading","postType","select","getEntityRecords","hasFinishedResolution","getPostType","per_page","length","labels","name","toLowerCase","map","template","id","postId","type","title","rendered","slug","description"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tVisuallyHidden,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport Link from '../routes/link';\nimport Actions from './actions';\nimport AddedBy from './added-by';\n\nexport default function Table( { templateType } ) {\n\tconst { templates, isLoading, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEntityRecords,\n\t\t\t\thasFinishedResolution,\n\t\t\t\tgetPostType,\n\t\t\t} = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\ttemplates: getEntityRecords( 'postType', templateType, {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} ),\n\t\t\t\tisLoading: ! hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\t{ per_page: -1 },\n\t\t\t\t] ),\n\t\t\t\tpostType: getPostType( templateType ),\n\t\t\t};\n\t\t},\n\t\t[ templateType ]\n\t);\n\n\tif ( ! templates || isLoading ) {\n\t\treturn null;\n\t}\n\n\tif ( ! templates.length ) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: The template type name, should be either \"templates\" or \"template parts\".\n\t\t\t\t\t__( 'No %s found.' ),\n\t\t\t\t\tpostType?.labels?.name?.toLowerCase()\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t// These explicit aria roles are needed for Safari.\n\t\t// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables\n\t\t<table className=\"edit-site-list-table\" role=\"table\">\n\t\t\t<thead>\n\t\t\t\t<tr className=\"edit-site-list-table-head\" role=\"row\">\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Added by' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>\n\t\t\t\t\t</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\n\t\t\t<tbody>\n\t\t\t\t{ templates.map( ( template ) => (\n\t\t\t\t\t<tr\n\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\tclassName=\"edit-site-list-table-row\"\n\t\t\t\t\t\trole=\"row\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Heading level={ 4 }>\n\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: template.type,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ template.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\ttemplate.slug }\n\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t{ template.description }\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<AddedBy\n\t\t\t\t\t\t\t\ttemplateType={ templateType }\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Actions template={ template } />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t) ) }\n\t\t\t</tbody>\n\t\t</table>\n\t);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElement
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
@@ -18,7 +18,12 @@ export const {
|
|
|
18
18
|
Fill: NavigationPanelPreviewFill,
|
|
19
19
|
Slot: NavigationPanelPreviewSlot
|
|
20
20
|
} = createSlotFill('EditSiteNavigationPanelPreview');
|
|
21
|
-
|
|
21
|
+
const {
|
|
22
|
+
Fill: NavigationSidebarFill,
|
|
23
|
+
Slot: NavigationSidebarSlot
|
|
24
|
+
} = createSlotFill('EditSiteNavigationSidebar');
|
|
25
|
+
|
|
26
|
+
function NavigationSidebar(_ref) {
|
|
22
27
|
let {
|
|
23
28
|
isDefaultOpen = false,
|
|
24
29
|
activeTemplateType
|
|
@@ -27,19 +32,14 @@ export default function NavigationSidebar(_ref) {
|
|
|
27
32
|
const {
|
|
28
33
|
setIsNavigationPanelOpened
|
|
29
34
|
} = useDispatch(editSiteStore);
|
|
30
|
-
useEffect(()
|
|
31
|
-
|
|
32
|
-
if (isDefaultOpen && isDesktopViewport) {
|
|
33
|
-
setIsNavigationPanelOpened(true);
|
|
34
|
-
} // When transitioning to mobile/tablet, close the navigation.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!isDesktopViewport) {
|
|
38
|
-
setIsNavigationPanelOpened(false);
|
|
39
|
-
}
|
|
35
|
+
useEffect(function autoOpenNavigationPanelOnViewportChange() {
|
|
36
|
+
setIsNavigationPanelOpened(isDefaultOpen && isDesktopViewport);
|
|
40
37
|
}, [isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened]);
|
|
41
|
-
return createElement(
|
|
38
|
+
return createElement(NavigationSidebarFill, null, createElement(NavigationToggle, null), createElement(NavigationPanel, {
|
|
42
39
|
activeItem: activeTemplateType
|
|
43
40
|
}), createElement(NavigationPanelPreviewSlot, null));
|
|
44
41
|
}
|
|
42
|
+
|
|
43
|
+
NavigationSidebar.Slot = NavigationSidebarSlot;
|
|
44
|
+
export default NavigationSidebar;
|
|
45
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/index.js"],"names":["useEffect","createSlotFill","useViewportMatch","useDispatch","store","editSiteStore","NavigationPanel","NavigationToggle","Fill","NavigationPanelPreviewFill","Slot","NavigationPanelPreviewSlot","NavigationSidebar","isDefaultOpen","activeTemplateType","isDesktopViewport","setIsNavigationPanelOpened"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,cAAT,QAA+B,uBAA/B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AAEA,OAAO,MAAM;AACZC,EAAAA,IAAI,EAAEC,0BADM;AAEZC,EAAAA,IAAI,EAAEC;AAFM,IAGTV,cAAc,CAAE,gCAAF,CAHX;AAKP,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/index.js"],"names":["useEffect","createSlotFill","useViewportMatch","useDispatch","store","editSiteStore","NavigationPanel","NavigationToggle","Fill","NavigationPanelPreviewFill","Slot","NavigationPanelPreviewSlot","NavigationSidebarFill","NavigationSidebarSlot","NavigationSidebar","isDefaultOpen","activeTemplateType","isDesktopViewport","setIsNavigationPanelOpened","autoOpenNavigationPanelOnViewportChange"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,cAAT,QAA+B,uBAA/B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AAEA,OAAO,MAAM;AACZC,EAAAA,IAAI,EAAEC,0BADM;AAEZC,EAAAA,IAAI,EAAEC;AAFM,IAGTV,cAAc,CAAE,gCAAF,CAHX;AAKP,MAAM;AACLO,EAAAA,IAAI,EAAEI,qBADD;AAELF,EAAAA,IAAI,EAAEG;AAFD,IAGFZ,cAAc,CAAE,2BAAF,CAHlB;;AAKA,SAASa,iBAAT,OAA4E;AAAA,MAAhD;AAAEC,IAAAA,aAAa,GAAG,KAAlB;AAAyBC,IAAAA;AAAzB,GAAgD;AAC3E,QAAMC,iBAAiB,GAAGf,gBAAgB,CAAE,QAAF,CAA1C;AACA,QAAM;AAAEgB,IAAAA;AAAF,MAAiCf,WAAW,CAAEE,aAAF,CAAlD;AAEAL,EAAAA,SAAS,CACR,SAASmB,uCAAT,GAAmD;AAClDD,IAAAA,0BAA0B,CAAEH,aAAa,IAAIE,iBAAnB,CAA1B;AACA,GAHO,EAIR,CAAEF,aAAF,EAAiBE,iBAAjB,EAAoCC,0BAApC,CAJQ,CAAT;AAOA,SACC,cAAC,qBAAD,QACC,cAAC,gBAAD,OADD,EAEC,cAAC,eAAD;AAAiB,IAAA,UAAU,EAAGF;AAA9B,IAFD,EAGC,cAAC,0BAAD,OAHD,CADD;AAOA;;AAEDF,iBAAiB,CAACJ,IAAlB,GAAyBG,qBAAzB;AAEA,eAAeC,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { createSlotFill } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport NavigationPanel from './navigation-panel';\nimport NavigationToggle from './navigation-toggle';\n\nexport const {\n\tFill: NavigationPanelPreviewFill,\n\tSlot: NavigationPanelPreviewSlot,\n} = createSlotFill( 'EditSiteNavigationPanelPreview' );\n\nconst {\n\tFill: NavigationSidebarFill,\n\tSlot: NavigationSidebarSlot,\n} = createSlotFill( 'EditSiteNavigationSidebar' );\n\nfunction NavigationSidebar( { isDefaultOpen = false, activeTemplateType } ) {\n\tconst isDesktopViewport = useViewportMatch( 'medium' );\n\tconst { setIsNavigationPanelOpened } = useDispatch( editSiteStore );\n\n\tuseEffect(\n\t\tfunction autoOpenNavigationPanelOnViewportChange() {\n\t\t\tsetIsNavigationPanelOpened( isDefaultOpen && isDesktopViewport );\n\t\t},\n\t\t[ isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened ]\n\t);\n\n\treturn (\n\t\t<NavigationSidebarFill>\n\t\t\t<NavigationToggle />\n\t\t\t<NavigationPanel activeItem={ activeTemplateType } />\n\t\t\t<NavigationPanelPreviewSlot />\n\t\t</NavigationSidebarFill>\n\t);\n}\n\nNavigationSidebar.Slot = NavigationSidebarSlot;\n\nexport default NavigationSidebar;\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import { createElement } from "@wordpress/element";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -11,24 +12,33 @@ import classnames from 'classnames';
|
|
|
11
12
|
import { __experimentalNavigation as Navigation, __experimentalNavigationBackButton as NavigationBackButton, __experimentalNavigationGroup as NavigationGroup, __experimentalNavigationItem as NavigationItem, __experimentalNavigationMenu as NavigationMenu } from '@wordpress/components';
|
|
12
13
|
import { store as coreDataStore } from '@wordpress/core-data';
|
|
13
14
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
|
-
import { useEffect, useRef } from '@wordpress/element';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
17
17
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
18
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
19
18
|
import { home as siteIcon, layout as templateIcon, symbolFilled as templatePartIcon } from '@wordpress/icons';
|
|
20
19
|
/**
|
|
21
20
|
* Internal dependencies
|
|
22
21
|
*/
|
|
23
22
|
|
|
23
|
+
import { useLink } from '../../routes/link';
|
|
24
24
|
import MainDashboardButton from '../../main-dashboard-button';
|
|
25
25
|
import { store as editSiteStore } from '../../../store';
|
|
26
26
|
const SITE_EDITOR_KEY = 'site-editor';
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
function NavLink(_ref) {
|
|
29
29
|
let {
|
|
30
|
-
|
|
30
|
+
params,
|
|
31
|
+
replace,
|
|
32
|
+
...props
|
|
31
33
|
} = _ref;
|
|
34
|
+
const linkProps = useLink(params, replace);
|
|
35
|
+
return createElement(NavigationItem, _extends({}, linkProps, props));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const NavigationPanel = _ref2 => {
|
|
39
|
+
let {
|
|
40
|
+
activeItem = SITE_EDITOR_KEY
|
|
41
|
+
} = _ref2;
|
|
32
42
|
const {
|
|
33
43
|
isNavigationOpen,
|
|
34
44
|
siteTitle
|
|
@@ -44,15 +54,7 @@ const NavigationPanel = _ref => {
|
|
|
44
54
|
}, []);
|
|
45
55
|
const {
|
|
46
56
|
setIsNavigationPanelOpened
|
|
47
|
-
} = useDispatch(editSiteStore);
|
|
48
|
-
// from a separate component (such as document actions in the header).
|
|
49
|
-
|
|
50
|
-
const panelRef = useRef();
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
if (isNavigationOpen) {
|
|
53
|
-
panelRef.current.focus();
|
|
54
|
-
}
|
|
55
|
-
}, [activeItem, isNavigationOpen]);
|
|
57
|
+
} = useDispatch(editSiteStore);
|
|
56
58
|
|
|
57
59
|
const closeOnEscape = event => {
|
|
58
60
|
if (event.keyCode === ESCAPE && !event.defaultPrevented) {
|
|
@@ -66,8 +68,6 @@ const NavigationPanel = _ref => {
|
|
|
66
68
|
className: classnames(`edit-site-navigation-panel`, {
|
|
67
69
|
'is-open': isNavigationOpen
|
|
68
70
|
}),
|
|
69
|
-
ref: panelRef,
|
|
70
|
-
tabIndex: "-1",
|
|
71
71
|
onKeyDown: closeOnEscape
|
|
72
72
|
}, createElement("div", {
|
|
73
73
|
className: "edit-site-navigation-panel__inner"
|
|
@@ -85,30 +85,30 @@ const NavigationPanel = _ref => {
|
|
|
85
85
|
href: "index.php"
|
|
86
86
|
})), createElement(NavigationMenu, null, createElement(NavigationGroup, {
|
|
87
87
|
title: __('Editor')
|
|
88
|
-
}, createElement(
|
|
88
|
+
}, createElement(NavLink, {
|
|
89
89
|
icon: siteIcon,
|
|
90
90
|
title: __('Site'),
|
|
91
91
|
item: SITE_EDITOR_KEY,
|
|
92
|
-
|
|
92
|
+
params: {
|
|
93
93
|
postId: undefined,
|
|
94
94
|
postType: undefined
|
|
95
|
-
}
|
|
96
|
-
}), createElement(
|
|
95
|
+
}
|
|
96
|
+
}), createElement(NavLink, {
|
|
97
97
|
icon: templateIcon,
|
|
98
98
|
title: __('Templates'),
|
|
99
99
|
item: "wp_template",
|
|
100
|
-
|
|
100
|
+
params: {
|
|
101
101
|
postId: undefined,
|
|
102
102
|
postType: 'wp_template'
|
|
103
|
-
}
|
|
104
|
-
}), createElement(
|
|
103
|
+
}
|
|
104
|
+
}), createElement(NavLink, {
|
|
105
105
|
icon: templatePartIcon,
|
|
106
106
|
title: __('Template Parts'),
|
|
107
107
|
item: "wp_template_part",
|
|
108
|
-
|
|
108
|
+
params: {
|
|
109
109
|
postId: undefined,
|
|
110
110
|
postType: 'wp_template_part'
|
|
111
|
-
}
|
|
111
|
+
}
|
|
112
112
|
})))))))
|
|
113
113
|
);
|
|
114
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/index.js"],"names":["classnames","__experimentalNavigation","Navigation","__experimentalNavigationBackButton","NavigationBackButton","__experimentalNavigationGroup","NavigationGroup","__experimentalNavigationItem","NavigationItem","__experimentalNavigationMenu","NavigationMenu","store","coreDataStore","useSelect","useDispatch","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/index.js"],"names":["classnames","__experimentalNavigation","Navigation","__experimentalNavigationBackButton","NavigationBackButton","__experimentalNavigationGroup","NavigationGroup","__experimentalNavigationItem","NavigationItem","__experimentalNavigationMenu","NavigationMenu","store","coreDataStore","useSelect","useDispatch","__","ESCAPE","decodeEntities","home","siteIcon","layout","templateIcon","symbolFilled","templatePartIcon","useLink","MainDashboardButton","editSiteStore","SITE_EDITOR_KEY","NavLink","params","replace","props","linkProps","NavigationPanel","activeItem","isNavigationOpen","siteTitle","select","getEntityRecord","siteData","undefined","name","isNavigationOpened","setIsNavigationPanelOpened","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","postId","postType"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNavigation as Navigation,\n\t__experimentalNavigationBackButton as NavigationBackButton,\n\t__experimentalNavigationGroup as NavigationGroup,\n\t__experimentalNavigationItem as NavigationItem,\n\t__experimentalNavigationMenu as NavigationMenu,\n} from '@wordpress/components';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport {\n\thome as siteIcon,\n\tlayout as templateIcon,\n\tsymbolFilled as templatePartIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useLink } from '../../routes/link';\nimport MainDashboardButton from '../../main-dashboard-button';\nimport { store as editSiteStore } from '../../../store';\n\nconst SITE_EDITOR_KEY = 'site-editor';\n\nfunction NavLink( { params, replace, ...props } ) {\n\tconst linkProps = useLink( params, replace );\n\n\treturn <NavigationItem { ...linkProps } { ...props } />;\n}\n\nconst NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {\n\tconst { isNavigationOpen, siteTitle } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreDataStore );\n\n\t\tconst siteData =\n\t\t\tgetEntityRecord( 'root', '__unstableBase', undefined ) || {};\n\n\t\treturn {\n\t\t\tsiteTitle: siteData.name,\n\t\t\tisNavigationOpen: select( editSiteStore ).isNavigationOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsNavigationPanelOpened } = useDispatch( editSiteStore );\n\n\tconst closeOnEscape = ( event ) => {\n\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\tevent.preventDefault();\n\t\t\tsetIsNavigationPanelOpened( false );\n\t\t}\n\t};\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName={ classnames( `edit-site-navigation-panel`, {\n\t\t\t\t'is-open': isNavigationOpen,\n\t\t\t} ) }\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t>\n\t\t\t<div className=\"edit-site-navigation-panel__inner\">\n\t\t\t\t<div className=\"edit-site-navigation-panel__site-title-container\">\n\t\t\t\t\t<div className=\"edit-site-navigation-panel__site-title\">\n\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-site-navigation-panel__scroll-container\">\n\t\t\t\t\t<Navigation activeItem={ activeItem }>\n\t\t\t\t\t\t<MainDashboardButton.Slot>\n\t\t\t\t\t\t\t<NavigationBackButton\n\t\t\t\t\t\t\t\tbackButtonLabel={ __( 'Dashboard' ) }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-navigation-panel__back-to-dashboard\"\n\t\t\t\t\t\t\t\thref=\"index.php\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MainDashboardButton.Slot>\n\n\t\t\t\t\t\t<NavigationMenu>\n\t\t\t\t\t\t\t<NavigationGroup title={ __( 'Editor' ) }>\n\t\t\t\t\t\t\t\t<NavLink\n\t\t\t\t\t\t\t\t\ticon={ siteIcon }\n\t\t\t\t\t\t\t\t\ttitle={ __( 'Site' ) }\n\t\t\t\t\t\t\t\t\titem={ SITE_EDITOR_KEY }\n\t\t\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\t\t\tpostId: undefined,\n\t\t\t\t\t\t\t\t\t\tpostType: undefined,\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<NavLink\n\t\t\t\t\t\t\t\t\ticon={ templateIcon }\n\t\t\t\t\t\t\t\t\ttitle={ __( 'Templates' ) }\n\t\t\t\t\t\t\t\t\titem=\"wp_template\"\n\t\t\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\t\t\tpostId: undefined,\n\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\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<NavLink\n\t\t\t\t\t\t\t\t\ticon={ templatePartIcon }\n\t\t\t\t\t\t\t\t\ttitle={ __( 'Template Parts' ) }\n\t\t\t\t\t\t\t\t\titem=\"wp_template_part\"\n\t\t\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\t\t\tpostId: undefined,\n\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template_part',\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</NavigationGroup>\n\t\t\t\t\t\t</NavigationMenu>\n\t\t\t\t\t</Navigation>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default NavigationPanel;\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { createContext, useState, useEffect, useContext } from '@wordpress/element';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import history from '../../utils/history';
|
|
12
|
+
const RoutesContext = createContext();
|
|
13
|
+
const HistoryContext = createContext();
|
|
14
|
+
export function useLocation() {
|
|
15
|
+
return useContext(RoutesContext);
|
|
16
|
+
}
|
|
17
|
+
export function useHistory() {
|
|
18
|
+
return useContext(HistoryContext);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getLocationWithParams(location) {
|
|
22
|
+
const searchParams = new URLSearchParams(location.search);
|
|
23
|
+
return { ...location,
|
|
24
|
+
params: Object.fromEntries(searchParams.entries())
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function Routes(_ref) {
|
|
29
|
+
let {
|
|
30
|
+
children
|
|
31
|
+
} = _ref;
|
|
32
|
+
const [location, setLocation] = useState(() => getLocationWithParams(history.location));
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
return history.listen(_ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
location: updatedLocation
|
|
37
|
+
} = _ref2;
|
|
38
|
+
setLocation(getLocationWithParams(updatedLocation));
|
|
39
|
+
});
|
|
40
|
+
}, []);
|
|
41
|
+
return createElement(HistoryContext.Provider, {
|
|
42
|
+
value: history
|
|
43
|
+
}, createElement(RoutesContext.Provider, {
|
|
44
|
+
value: location
|
|
45
|
+
}, children(location)));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/index.js"],"names":["createContext","useState","useEffect","useContext","history","RoutesContext","HistoryContext","useLocation","useHistory","getLocationWithParams","location","searchParams","URLSearchParams","search","params","Object","fromEntries","entries","Routes","children","setLocation","listen","updatedLocation"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,aADD,EAECC,QAFD,EAGCC,SAHD,EAICC,UAJD,QAKO,oBALP;AAOA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,qBAApB;AAEA,MAAMC,aAAa,GAAGL,aAAa,EAAnC;AACA,MAAMM,cAAc,GAAGN,aAAa,EAApC;AAEA,OAAO,SAASO,WAAT,GAAuB;AAC7B,SAAOJ,UAAU,CAAEE,aAAF,CAAjB;AACA;AAED,OAAO,SAASG,UAAT,GAAsB;AAC5B,SAAOL,UAAU,CAAEG,cAAF,CAAjB;AACA;;AAED,SAASG,qBAAT,CAAgCC,QAAhC,EAA2C;AAC1C,QAAMC,YAAY,GAAG,IAAIC,eAAJ,CAAqBF,QAAQ,CAACG,MAA9B,CAArB;AACA,SAAO,EACN,GAAGH,QADG;AAENI,IAAAA,MAAM,EAAEC,MAAM,CAACC,WAAP,CAAoBL,YAAY,CAACM,OAAb,EAApB;AAFF,GAAP;AAIA;;AAED,OAAO,SAASC,MAAT,OAAgC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACtC,QAAM,CAAET,QAAF,EAAYU,WAAZ,IAA4BnB,QAAQ,CAAE,MAC3CQ,qBAAqB,CAAEL,OAAO,CAACM,QAAV,CADoB,CAA1C;AAIAR,EAAAA,SAAS,CAAE,MAAM;AAChB,WAAOE,OAAO,CAACiB,MAAR,CAAgB,SAAqC;AAAA,UAAnC;AAAEX,QAAAA,QAAQ,EAAEY;AAAZ,OAAmC;AAC3DF,MAAAA,WAAW,CAAEX,qBAAqB,CAAEa,eAAF,CAAvB,CAAX;AACA,KAFM,CAAP;AAGA,GAJQ,EAIN,EAJM,CAAT;AAMA,SACC,cAAC,cAAD,CAAgB,QAAhB;AAAyB,IAAA,KAAK,EAAGlB;AAAjC,KACC,cAAC,aAAD,CAAe,QAAf;AAAwB,IAAA,KAAK,EAAGM;AAAhC,KACGS,QAAQ,CAAET,QAAF,CADX,CADD,CADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseState,\n\tuseEffect,\n\tuseContext,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport history from '../../utils/history';\n\nconst RoutesContext = createContext();\nconst HistoryContext = createContext();\n\nexport function useLocation() {\n\treturn useContext( RoutesContext );\n}\n\nexport function useHistory() {\n\treturn useContext( HistoryContext );\n}\n\nfunction getLocationWithParams( location ) {\n\tconst searchParams = new URLSearchParams( location.search );\n\treturn {\n\t\t...location,\n\t\tparams: Object.fromEntries( searchParams.entries() ),\n\t};\n}\n\nexport function Routes( { children } ) {\n\tconst [ location, setLocation ] = useState( () =>\n\t\tgetLocationWithParams( history.location )\n\t);\n\n\tuseEffect( () => {\n\t\treturn history.listen( ( { location: updatedLocation } ) => {\n\t\t\tsetLocation( getLocationWithParams( updatedLocation ) );\n\t\t} );\n\t}, [] );\n\n\treturn (\n\t\t<HistoryContext.Provider value={ history }>\n\t\t\t<RoutesContext.Provider value={ location }>\n\t\t\t\t{ children( location ) }\n\t\t\t</RoutesContext.Provider>\n\t\t</HistoryContext.Provider>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* WordPress dependencies
|
|
6
|
+
*/
|
|
7
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { useHistory } from './index';
|
|
13
|
+
export function useLink() {
|
|
14
|
+
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
15
|
+
let state = arguments.length > 1 ? arguments[1] : undefined;
|
|
16
|
+
let shouldReplace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
17
|
+
const history = useHistory();
|
|
18
|
+
|
|
19
|
+
function onClick(event) {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
|
|
22
|
+
if (shouldReplace) {
|
|
23
|
+
history.replace(params, state);
|
|
24
|
+
} else {
|
|
25
|
+
history.push(params, state);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
href: addQueryArgs(window.location.href, params),
|
|
31
|
+
onClick
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export default function Link(_ref) {
|
|
35
|
+
let {
|
|
36
|
+
params = {},
|
|
37
|
+
state,
|
|
38
|
+
replace: shouldReplace = false,
|
|
39
|
+
children,
|
|
40
|
+
...props
|
|
41
|
+
} = _ref;
|
|
42
|
+
const {
|
|
43
|
+
href,
|
|
44
|
+
onClick
|
|
45
|
+
} = useLink(params, state, shouldReplace);
|
|
46
|
+
return createElement("a", _extends({
|
|
47
|
+
href: href,
|
|
48
|
+
onClick: onClick
|
|
49
|
+
}, props), children);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["addQueryArgs","useHistory","useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","href","window","location","Link","children","props"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,SAA3B;AAEA,OAAO,SAASC,OAAT,GAA8D;AAAA,MAA5CC,MAA4C,uEAAnC,EAAmC;AAAA,MAA/BC,KAA+B;AAAA,MAAxBC,aAAwB,uEAAR,KAAQ;AACpE,QAAMC,OAAO,GAAGL,UAAU,EAA1B;;AAEA,WAASM,OAAT,CAAkBC,KAAlB,EAA0B;AACzBA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAKJ,aAAL,EAAqB;AACpBC,MAAAA,OAAO,CAACI,OAAR,CAAiBP,MAAjB,EAAyBC,KAAzB;AACA,KAFD,MAEO;AACNE,MAAAA,OAAO,CAACK,IAAR,CAAcR,MAAd,EAAsBC,KAAtB;AACA;AACD;;AAED,SAAO;AACNQ,IAAAA,IAAI,EAAEZ,YAAY,CAAEa,MAAM,CAACC,QAAP,CAAgBF,IAAlB,EAAwBT,MAAxB,CADZ;AAENI,IAAAA;AAFM,GAAP;AAIA;AAED,eAAe,SAASQ,IAAT,OAMX;AAAA,MAN0B;AAC7BZ,IAAAA,MAAM,GAAG,EADoB;AAE7BC,IAAAA,KAF6B;AAG7BM,IAAAA,OAAO,EAAEL,aAAa,GAAG,KAHI;AAI7BW,IAAAA,QAJ6B;AAK7B,OAAGC;AAL0B,GAM1B;AACH,QAAM;AAAEL,IAAAA,IAAF;AAAQL,IAAAA;AAAR,MAAoBL,OAAO,CAAEC,MAAF,EAAUC,KAAV,EAAiBC,aAAjB,CAAjC;AAEA,SACC;AAAG,IAAA,IAAI,EAAGO,IAAV;AAAiB,IAAA,OAAO,EAAGL;AAA3B,KAA0CU,KAA1C,GACGD,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from './index';\n\nexport function useLink( params = {}, state, shouldReplace = false ) {\n\tconst history = useHistory();\n\n\tfunction onClick( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( shouldReplace ) {\n\t\t\thistory.replace( params, state );\n\t\t} else {\n\t\t\thistory.push( params, state );\n\t\t}\n\t}\n\n\treturn {\n\t\thref: addQueryArgs( window.location.href, params ),\n\t\tonClick,\n\t};\n}\n\nexport default function Link( {\n\tparams = {},\n\tstate,\n\treplace: shouldReplace = false,\n\tchildren,\n\t...props\n} ) {\n\tconst { href, onClick } = useLink( params, state, shouldReplace );\n\n\treturn (\n\t\t<a href={ href } onClick={ onClick } { ...props }>\n\t\t\t{ children }\n\t\t</a>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import { speak } from '@wordpress/a11y';
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { useLocation } from './index';
|
|
14
|
+
export default function useTitle(title) {
|
|
15
|
+
const location = useLocation();
|
|
16
|
+
const siteTitle = useSelect(select => {
|
|
17
|
+
var _select$getEntityReco;
|
|
18
|
+
|
|
19
|
+
return (_select$getEntityReco = select(coreStore).getEntityRecord('root', 'site')) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco.title;
|
|
20
|
+
}, []);
|
|
21
|
+
const isInitialLocationRef = useRef(true);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
isInitialLocationRef.current = false;
|
|
24
|
+
}, [location]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
// Don't update or announce the title for initial page load.
|
|
27
|
+
if (isInitialLocationRef.current) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (title && siteTitle) {
|
|
32
|
+
// @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68
|
|
33
|
+
const formattedTitle = sprintf(
|
|
34
|
+
/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
|
|
35
|
+
__('%1$s ‹ %2$s — WordPress'), title, siteTitle);
|
|
36
|
+
document.title = formattedTitle; // Announce title on route change for screen readers.
|
|
37
|
+
|
|
38
|
+
speak(sprintf(
|
|
39
|
+
/* translators: The page title that is currently displaying. */
|
|
40
|
+
__('Now displaying: %s'), document.title), 'assertive');
|
|
41
|
+
}
|
|
42
|
+
}, [title, siteTitle, location]);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=use-title.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/use-title.js"],"names":["useEffect","useRef","useSelect","store","coreStore","__","sprintf","speak","useLocation","useTitle","title","location","siteTitle","select","getEntityRecord","isInitialLocationRef","current","formattedTitle","document"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,SAA5B;AAEA,eAAe,SAASC,QAAT,CAAmBC,KAAnB,EAA2B;AACzC,QAAMC,QAAQ,GAAGH,WAAW,EAA5B;AACA,QAAMI,SAAS,GAAGV,SAAS,CACxBW,MAAF;AAAA;;AAAA,oCACCA,MAAM,CAAET,SAAF,CAAN,CAAoBU,eAApB,CAAqC,MAArC,EAA6C,MAA7C,CADD,0DACC,sBAAuDJ,KADxD;AAAA,GAD0B,EAG1B,EAH0B,CAA3B;AAKA,QAAMK,oBAAoB,GAAGd,MAAM,CAAE,IAAF,CAAnC;AAEAD,EAAAA,SAAS,CAAE,MAAM;AAChBe,IAAAA,oBAAoB,CAACC,OAArB,GAA+B,KAA/B;AACA,GAFQ,EAEN,CAAEL,QAAF,CAFM,CAAT;AAIAX,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA,QAAKe,oBAAoB,CAACC,OAA1B,EAAoC;AACnC;AACA;;AAED,QAAKN,KAAK,IAAIE,SAAd,EAA0B;AACzB;AACA,YAAMK,cAAc,GAAGX,OAAO;AAC7B;AACAD,MAAAA,EAAE,CAAE,yBAAF,CAF2B,EAG7BK,KAH6B,EAI7BE,SAJ6B,CAA9B;AAOAM,MAAAA,QAAQ,CAACR,KAAT,GAAiBO,cAAjB,CATyB,CAWzB;;AACAV,MAAAA,KAAK,CACJD,OAAO;AACN;AACAD,MAAAA,EAAE,CAAE,oBAAF,CAFI,EAGNa,QAAQ,CAACR,KAHH,CADH,EAMJ,WANI,CAAL;AAQA;AACD,GA3BQ,EA2BN,CAAEA,KAAF,EAASE,SAAT,EAAoBD,QAApB,CA3BM,CAAT;AA4BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from './index';\n\nexport default function useTitle( title ) {\n\tconst location = useLocation();\n\tconst siteTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'root', 'site' )?.title,\n\t\t[]\n\t);\n\tconst isInitialLocationRef = useRef( true );\n\n\tuseEffect( () => {\n\t\tisInitialLocationRef.current = false;\n\t}, [ location ] );\n\n\tuseEffect( () => {\n\t\t// Don't update or announce the title for initial page load.\n\t\tif ( isInitialLocationRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( title && siteTitle ) {\n\t\t\t// @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68\n\t\t\tconst formattedTitle = sprintf(\n\t\t\t\t/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */\n\t\t\t\t__( '%1$s ‹ %2$s — WordPress' ),\n\t\t\t\ttitle,\n\t\t\t\tsiteTitle\n\t\t\t);\n\n\t\t\tdocument.title = formattedTitle;\n\n\t\t\t// Announce title on route change for screen readers.\n\t\t\tspeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The page title that is currently displaying. */\n\t\t\t\t\t__( 'Now displaying: %s' ),\n\t\t\t\t\tdocument.title\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t}\n\t}, [ title, siteTitle, location ] );\n}\n"]}
|
|
@@ -6,14 +6,19 @@ import { createElement } from "@wordpress/element";
|
|
|
6
6
|
import { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { styles, moreVertical } from '@wordpress/icons';
|
|
9
|
+
import { useDispatch } from '@wordpress/data';
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
import DefaultSidebar from './default-sidebar';
|
|
14
15
|
import { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';
|
|
16
|
+
import { store as editSiteStore } from '../../store';
|
|
15
17
|
export default function GlobalStylesSidebar() {
|
|
16
18
|
const [canReset, onReset] = useGlobalStylesReset();
|
|
19
|
+
const {
|
|
20
|
+
toggleFeature
|
|
21
|
+
} = useDispatch(editSiteStore);
|
|
17
22
|
return createElement(DefaultSidebar, {
|
|
18
23
|
className: "edit-site-global-styles-sidebar",
|
|
19
24
|
identifier: "edit-site/global-styles",
|
|
@@ -31,6 +36,9 @@ export default function GlobalStylesSidebar() {
|
|
|
31
36
|
controls: [{
|
|
32
37
|
title: __('Reset to defaults'),
|
|
33
38
|
onClick: onReset
|
|
39
|
+
}, {
|
|
40
|
+
title: __('Welcome Guide'),
|
|
41
|
+
onClick: () => toggleFeature('welcomeGuideStyles')
|
|
34
42
|
}]
|
|
35
43
|
})))
|
|
36
44
|
}, createElement(GlobalStylesUI, null));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/global-styles-sidebar.js"],"names":["DropdownMenu","FlexItem","FlexBlock","Flex","__","styles","moreVertical","DefaultSidebar","GlobalStylesUI","useGlobalStylesReset","GlobalStylesSidebar","canReset","onReset","disabled","title","onClick"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,QAAvB,EAAiCC,SAAjC,EAA4CC,IAA5C,QAAwD,uBAAxD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,YAAjB,QAAqC,kBAArC;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,SAASC,cAAT,EAAyBC,oBAAzB,QAAqD,kBAArD;AAEA,eAAe,SAASC,mBAAT,GAA+B;AAC7C,QAAM,CAAEC,QAAF,EAAYC,OAAZ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/global-styles-sidebar.js"],"names":["DropdownMenu","FlexItem","FlexBlock","Flex","__","styles","moreVertical","useDispatch","DefaultSidebar","GlobalStylesUI","useGlobalStylesReset","store","editSiteStore","GlobalStylesSidebar","canReset","onReset","toggleFeature","disabled","title","onClick"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,QAAvB,EAAiCC,SAAjC,EAA4CC,IAA5C,QAAwD,uBAAxD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,YAAjB,QAAqC,kBAArC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,SAASC,cAAT,EAAyBC,oBAAzB,QAAqD,kBAArD;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,mBAAT,GAA+B;AAC7C,QAAM,CAAEC,QAAF,EAAYC,OAAZ,IAAwBL,oBAAoB,EAAlD;AACA,QAAM;AAAEM,IAAAA;AAAF,MAAoBT,WAAW,CAAEK,aAAF,CAArC;AAEA,SACC,cAAC,cAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,UAAU,EAAC,yBAFZ;AAGC,IAAA,KAAK,EAAGR,EAAE,CAAE,QAAF,CAHX;AAIC,IAAA,IAAI,EAAGC,MAJR;AAKC,IAAA,UAAU,EAAGD,EAAE,CAAE,6BAAF,CALhB;AAMC,IAAA,MAAM,EACL,cAAC,IAAD,QACC,cAAC,SAAD,QACC,8BAAUA,EAAE,CAAE,QAAF,CAAZ,CADD,EAEC;AAAM,MAAA,SAAS,EAAC;AAAhB,OACGA,EAAE,CAAE,MAAF,CADL,CAFD,CADD,EAOC,cAAC,QAAD,QACC,cAAC,YAAD;AACC,MAAA,IAAI,EAAGE,YADR;AAEC,MAAA,KAAK,EAAGF,EAAE,CAAE,4BAAF,CAFX;AAGC,MAAA,WAAW,EAAG;AAAEa,QAAAA,QAAQ,EAAE,CAAEH;AAAd,OAHf;AAIC,MAAA,QAAQ,EAAG,CACV;AACCI,QAAAA,KAAK,EAAEd,EAAE,CAAE,mBAAF,CADV;AAECe,QAAAA,OAAO,EAAEJ;AAFV,OADU,EAKV;AACCG,QAAAA,KAAK,EAAEd,EAAE,CAAE,eAAF,CADV;AAECe,QAAAA,OAAO,EAAE,MACRH,aAAa,CAAE,oBAAF;AAHf,OALU;AAJZ,MADD,CAPD;AAPF,KAmCC,cAAC,cAAD,OAnCD,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { styles, moreVertical } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';\nimport { store as editSiteStore } from '../../store';\n\nexport default function GlobalStylesSidebar() {\n\tconst [ canReset, onReset ] = useGlobalStylesReset();\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\n\treturn (\n\t\t<DefaultSidebar\n\t\t\tclassName=\"edit-site-global-styles-sidebar\"\n\t\t\tidentifier=\"edit-site/global-styles\"\n\t\t\ttitle={ __( 'Styles' ) }\n\t\t\ticon={ styles }\n\t\t\tcloseLabel={ __( 'Close global styles sidebar' ) }\n\t\t\theader={\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<strong>{ __( 'Styles' ) }</strong>\n\t\t\t\t\t\t<span className=\"edit-site-global-styles-sidebar__beta\">\n\t\t\t\t\t\t\t{ __( 'Beta' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'More Global Styles Actions' ) }\n\t\t\t\t\t\t\ttoggleProps={ { disabled: ! canReset } }\n\t\t\t\t\t\t\tcontrols={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: __( 'Reset to defaults' ),\n\t\t\t\t\t\t\t\t\tonClick: onReset,\n\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\ttitle: __( 'Welcome Guide' ),\n\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\ttoggleFeature( 'welcomeGuideStyles' ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t}\n\t\t>\n\t\t\t<GlobalStylesUI />\n\t\t</DefaultSidebar>\n\t);\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import { createElement } from "@wordpress/element";
|
|
|
5
5
|
*/
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { Button, __experimentalHeading as Heading } from '@wordpress/components';
|
|
8
|
-
import {
|
|
8
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
9
9
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
11
|
/**
|
|
@@ -13,7 +13,6 @@ import { __ } from '@wordpress/i18n';
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { store as editSiteStore } from '../../../store';
|
|
16
|
-
import { TEMPLATE_PART_AREA_TO_NAME } from '../../../store/constants';
|
|
17
16
|
|
|
18
17
|
function TemplateAreaItem(_ref) {
|
|
19
18
|
let {
|
|
@@ -24,6 +23,11 @@ function TemplateAreaItem(_ref) {
|
|
|
24
23
|
selectBlock,
|
|
25
24
|
toggleBlockHighlight
|
|
26
25
|
} = useDispatch(blockEditorStore);
|
|
26
|
+
const templatePartArea = useSelect(select => {
|
|
27
|
+
const defaultAreas = select(editorStore).__experimentalGetDefaultTemplatePartAreas();
|
|
28
|
+
|
|
29
|
+
return defaultAreas.find(defaultArea => defaultArea.area === area);
|
|
30
|
+
}, [area]);
|
|
27
31
|
|
|
28
32
|
const highlightBlock = () => toggleBlockHighlight(clientId, true);
|
|
29
33
|
|
|
@@ -31,7 +35,7 @@ function TemplateAreaItem(_ref) {
|
|
|
31
35
|
|
|
32
36
|
return createElement(Button, {
|
|
33
37
|
className: "edit-site-template-card__template-areas-item",
|
|
34
|
-
icon:
|
|
38
|
+
icon: templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.icon,
|
|
35
39
|
onMouseOver: highlightBlock,
|
|
36
40
|
onMouseLeave: cancelHighlightBlock,
|
|
37
41
|
onFocus: highlightBlock,
|
|
@@ -39,7 +43,7 @@ function TemplateAreaItem(_ref) {
|
|
|
39
43
|
onClick: () => {
|
|
40
44
|
selectBlock(clientId);
|
|
41
45
|
}
|
|
42
|
-
},
|
|
46
|
+
}, templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.label);
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
export default function TemplateAreas() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/template-card/template-areas.js"],"names":["useSelect","useDispatch","Button","__experimentalHeading","Heading","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/template-card/template-areas.js"],"names":["useSelect","useDispatch","Button","__experimentalHeading","Heading","store","editorStore","blockEditorStore","__","editSiteStore","TemplateAreaItem","area","clientId","selectBlock","toggleBlockHighlight","templatePartArea","select","defaultAreas","__experimentalGetDefaultTemplatePartAreas","find","defaultArea","highlightBlock","cancelHighlightBlock","icon","label","TemplateAreas","templateParts","getCurrentTemplateTemplateParts","length","map","templatePart","block","slug"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,MADD,EAECC,qBAAqB,IAAIC,OAF1B,QAGO,uBAHP;AAIA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,gBAAvC;;AAEA,SAASC,gBAAT,OAAgD;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AAC/C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAwCb,WAAW,CACxDM,gBADwD,CAAzD;AAGA,QAAMQ,gBAAgB,GAAGf,SAAS,CAC/BgB,MAAF,IAAc;AACb,UAAMC,YAAY,GAAGD,MAAM,CAC1BV,WAD0B,CAAN,CAEnBY,yCAFmB,EAArB;;AAIA,WAAOD,YAAY,CAACE,IAAb,CACJC,WAAF,IAAmBA,WAAW,CAACT,IAAZ,KAAqBA,IADlC,CAAP;AAGA,GATgC,EAUjC,CAAEA,IAAF,CAViC,CAAlC;;AAaA,QAAMU,cAAc,GAAG,MAAMP,oBAAoB,CAAEF,QAAF,EAAY,IAAZ,CAAjD;;AACA,QAAMU,oBAAoB,GAAG,MAAMR,oBAAoB,CAAEF,QAAF,EAAY,KAAZ,CAAvD;;AAEA,SACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,8CADX;AAEC,IAAA,IAAI,EAAGG,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAEQ,IAF1B;AAGC,IAAA,WAAW,EAAGF,cAHf;AAIC,IAAA,YAAY,EAAGC,oBAJhB;AAKC,IAAA,OAAO,EAAGD,cALX;AAMC,IAAA,MAAM,EAAGC,oBANV;AAOC,IAAA,OAAO,EAAG,MAAM;AACfT,MAAAA,WAAW,CAAED,QAAF,CAAX;AACA;AATF,KAWGG,gBAXH,aAWGA,gBAXH,uBAWGA,gBAAgB,CAAES,KAXrB,CADD;AAeA;;AAED,eAAe,SAASC,aAAT,GAAyB;AACvC,QAAMC,aAAa,GAAG1B,SAAS,CAC5BgB,MAAF,IAAcA,MAAM,CAAEP,aAAF,CAAN,CAAwBkB,+BAAxB,EADgB,EAE9B,EAF8B,CAA/B;;AAKA,MAAK,CAAED,aAAa,CAACE,MAArB,EAA8B;AAC7B,WAAO,IAAP;AACA;;AAED,SACC;AAAS,IAAA,SAAS,EAAC;AAAnB,KACC,cAAC,OAAD;AACC,IAAA,KAAK,EAAG,CADT;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGpB,EAAE,CAAE,OAAF,CAJL,CADD,EAQC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGkB,aAAa,CAACG,GAAd,CAAmB;AAAA,QAAE;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,KAAF;AAAA,WACpB;AAAI,MAAA,GAAG,EAAGD,YAAY,CAACE;AAAvB,OACC,cAAC,gBAAD;AACC,MAAA,IAAI,EAAGF,YAAY,CAACnB,IADrB;AAEC,MAAA,QAAQ,EAAGoB,KAAK,CAACnB;AAFlB,MADD,CADoB;AAAA,GAAnB,CADH,CARD,CADD;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\n\nfunction TemplateAreaItem( { area, clientId } ) {\n\tconst { selectBlock, toggleBlockHighlight } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst templatePartArea = useSelect(\n\t\t( select ) => {\n\t\t\tconst defaultAreas = select(\n\t\t\t\teditorStore\n\t\t\t).__experimentalGetDefaultTemplatePartAreas();\n\n\t\t\treturn defaultAreas.find(\n\t\t\t\t( defaultArea ) => defaultArea.area === area\n\t\t\t);\n\t\t},\n\t\t[ area ]\n\t);\n\n\tconst highlightBlock = () => toggleBlockHighlight( clientId, true );\n\tconst cancelHighlightBlock = () => toggleBlockHighlight( clientId, false );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-site-template-card__template-areas-item\"\n\t\t\ticon={ templatePartArea?.icon }\n\t\t\tonMouseOver={ highlightBlock }\n\t\t\tonMouseLeave={ cancelHighlightBlock }\n\t\t\tonFocus={ highlightBlock }\n\t\t\tonBlur={ cancelHighlightBlock }\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t>\n\t\t\t{ templatePartArea?.label }\n\t\t</Button>\n\t);\n}\n\nexport default function TemplateAreas() {\n\tconst templateParts = useSelect(\n\t\t( select ) => select( editSiteStore ).getCurrentTemplateTemplateParts(),\n\t\t[]\n\t);\n\n\tif ( ! templateParts.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<section className=\"edit-site-template-card__template-areas\">\n\t\t\t<Heading\n\t\t\t\tlevel={ 3 }\n\t\t\t\tclassName=\"edit-site-template-card__template-areas-title\"\n\t\t\t>\n\t\t\t\t{ __( 'Areas' ) }\n\t\t\t</Heading>\n\n\t\t\t<ul className=\"edit-site-template-card__template-areas-list\">\n\t\t\t\t{ templateParts.map( ( { templatePart, block } ) => (\n\t\t\t\t\t<li key={ templatePart.slug }>\n\t\t\t\t\t\t<TemplateAreaItem\n\t\t\t\t\t\t\tarea={ templatePart.area }\n\t\t\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t</section>\n\t);\n}\n"]}
|