@wordpress/edit-site 5.12.6 → 5.12.8
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/block-editor/editor-canvas.js +1 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +10 -5
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/create-pattern-modal/index.js +8 -4
- package/build/components/create-pattern-modal/index.js.map +1 -1
- package/build/components/global-styles/palette.js +1 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/header-edit-mode/index.js +6 -2
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/layout/index.js +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page/header.js +1 -1
- package/build/components/page/header.js.map +1 -1
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -5
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/page-patterns/duplicate-menu-item.js +163 -0
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build/components/page-patterns/grid-item.js +84 -60
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/grid.js +21 -13
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/header.js +69 -0
- package/build/components/page-patterns/header.js.map +1 -0
- package/build/components/page-patterns/index.js +3 -1
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +67 -27
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/rename-menu-item.js +109 -0
- package/build/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build/components/page-patterns/use-patterns.js +99 -126
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/index.js +1 -0
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/page-templates/index.js +1 -0
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-content.js +4 -3
- package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +1 -1
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +57 -17
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +4 -2
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js +45 -0
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -11
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +6 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/status-label.js +2 -35
- package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +68 -43
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +20 -9
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build/components/site-hub/index.js +2 -2
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/template-actions/index.js +25 -7
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/template-actions/rename-menu-item.js +9 -6
- package/build/components/template-actions/rename-menu-item.js.map +1 -1
- package/build/components/welcome-guide/page.js +2 -2
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +2 -2
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +1 -2
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +3 -1
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/private-actions.js +7 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/utils/use-activate-theme.js +1 -1
- package/build/utils/use-activate-theme.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +10 -5
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/create-pattern-modal/index.js +7 -4
- package/build-module/components/create-pattern-modal/index.js.map +1 -1
- package/build-module/components/global-styles/palette.js +1 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +6 -2
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/layout/index.js +1 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page/header.js +1 -1
- package/build-module/components/page/header.js.map +1 -1
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -3
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/page-patterns/duplicate-menu-item.js +147 -0
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/grid-item.js +85 -66
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +22 -15
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/header.js +54 -0
- package/build-module/components/page-patterns/header.js.map +1 -0
- package/build-module/components/page-patterns/index.js +3 -1
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +70 -31
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/rename-menu-item.js +97 -0
- package/build-module/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/use-patterns.js +100 -127
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/index.js +1 -0
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +1 -0
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +5 -2
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +57 -17
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +4 -3
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +33 -0
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -9
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +6 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/status-label.js +2 -33
- package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +71 -44
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +18 -9
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build-module/components/site-hub/index.js +2 -2
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/template-actions/index.js +26 -8
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/template-actions/rename-menu-item.js +8 -6
- package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +2 -2
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +2 -2
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +1 -2
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +4 -2
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/private-actions.js +7 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/utils/use-activate-theme.js +1 -1
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-style/style-rtl.css +149 -50
- package/build-style/style.css +149 -50
- package/package.json +19 -19
- package/src/components/block-editor/editor-canvas.js +1 -1
- package/src/components/block-editor/use-site-editor-settings.js +8 -4
- package/src/components/create-pattern-modal/index.js +6 -3
- package/src/components/global-styles/palette.js +10 -9
- package/src/components/header-edit-mode/document-actions/style.scss +12 -0
- package/src/components/header-edit-mode/index.js +17 -9
- package/src/components/layout/index.js +1 -1
- package/src/components/layout/style.scss +0 -11
- package/src/components/page/header.js +1 -1
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +12 -3
- package/src/components/page-patterns/duplicate-menu-item.js +196 -0
- package/src/components/page-patterns/grid-item.js +187 -132
- package/src/components/page-patterns/grid.js +35 -22
- package/src/components/page-patterns/header.js +69 -0
- package/src/components/page-patterns/index.js +6 -1
- package/src/components/page-patterns/patterns-list.js +89 -47
- package/src/components/page-patterns/rename-menu-item.js +115 -0
- package/src/components/page-patterns/style.scss +86 -26
- package/src/components/page-patterns/use-patterns.js +99 -176
- package/src/components/page-template-parts/index.js +1 -1
- package/src/components/page-templates/index.js +1 -1
- package/src/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
- package/src/components/sidebar-navigation-screen/index.js +1 -1
- package/src/components/sidebar-navigation-screen/style.scss +19 -1
- package/src/components/sidebar-navigation-screen-global-styles/index.js +56 -39
- package/src/components/sidebar-navigation-screen-main/index.js +44 -40
- package/src/components/sidebar-navigation-screen-main/template-part-hint.js +36 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js +8 -11
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +10 -6
- package/src/components/sidebar-navigation-screen-page/status-label.js +2 -36
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +3 -3
- package/src/components/sidebar-navigation-screen-patterns/index.js +79 -75
- package/src/components/sidebar-navigation-screen-patterns/style.scss +23 -1
- package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +31 -9
- package/src/components/site-hub/index.js +2 -2
- package/src/components/template-actions/index.js +40 -9
- package/src/components/template-actions/rename-menu-item.js +8 -6
- package/src/components/welcome-guide/page.js +2 -2
- package/src/components/welcome-guide/template.js +2 -2
- package/src/hooks/commands/use-edit-mode-commands.js +0 -1
- package/src/hooks/push-changes-to-global-styles/index.js +8 -1
- package/src/store/private-actions.js +5 -1
- package/src/style.scss +10 -12
- package/src/utils/use-activate-theme.js +1 -1
- package/build/components/page-content-focus-manager/constants.js +0 -9
- package/build/components/page-content-focus-manager/constants.js.map +0 -1
- package/build-module/components/page-content-focus-manager/constants.js +0 -2
- package/build-module/components/page-content-focus-manager/constants.js.map +0 -1
- package/src/components/page-content-focus-manager/constants.js +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/header.js"],"names":["PatternsHeader","categoryId","type","titleId","descriptionId","patternCategories","templatePartAreas","select","editorStore","__experimentalGetDefaultTemplatePartAreas","title","description","USER_PATTERN_CATEGORY","USER_PATTERNS","TEMPLATE_PARTS","templatePartArea","find","area","label","PATTERNS","patternCategory","category","name"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;AASe,SAASA,cAAT,CAAyB;AACvCC,EAAAA,UADuC;AAEvCC,EAAAA,IAFuC;AAGvCC,EAAAA,OAHuC;AAIvCC,EAAAA;AAJuC,CAAzB,EAKX;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAwB,oCAA9B;AACA,QAAMC,iBAAiB,GAAG,qBACvBC,MAAF,IACCA,MAAM,CAAEC,aAAF,CAAN,CAAsBC,yCAAtB,EAFwB,EAGzB,EAHyB,CAA1B;AAMA,MAAIC,KAAJ,EAAWC,WAAX;;AACA,MAAKV,UAAU,KAAKW,4BAAf,IAAwCV,IAAI,KAAKW,oBAAtD,EAAsE;AACrEH,IAAAA,KAAK,GAAG,cAAI,aAAJ,CAAR;AACAC,IAAAA,WAAW,GAAG,EAAd;AACA,GAHD,MAGO,IAAKT,IAAI,KAAKY,qBAAd,EAA+B;AACrC,UAAMC,gBAAgB,GAAGT,iBAAiB,CAACU,IAAlB,CACtBC,IAAF,IAAYA,IAAI,CAACA,IAAL,KAAchB,UADF,CAAzB;AAGAS,IAAAA,KAAK,GAAGK,gBAAgB,EAAEG,KAA1B;AACAP,IAAAA,WAAW,GAAGI,gBAAgB,EAAEJ,WAAhC;AACA,GANM,MAMA,IAAKT,IAAI,KAAKiB,eAAd,EAAyB;AAC/B,UAAMC,eAAe,GAAGf,iBAAiB,CAACW,IAAlB,CACrBK,QAAF,IAAgBA,QAAQ,CAACC,IAAT,KAAkBrB,UADX,CAAxB;AAGAS,IAAAA,KAAK,GAAGU,eAAe,EAAEF,KAAzB;AACAP,IAAAA,WAAW,GAAGS,eAAe,EAAET,WAA/B;AACA;;AAED,MAAK,CAAED,KAAP,EAAe,OAAO,IAAP;AAEf,SACC,4BAAC,gCAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,4BAAC,iCAAD;AAAS,IAAA,EAAE,EAAC,IAAZ;AAAiB,IAAA,KAAK,EAAG,CAAzB;AAA6B,IAAA,EAAE,EAAGP;AAAlC,KACGO,KADH,CADD,EAIGC,WAAW,GACZ,4BAAC,8BAAD;AAAM,IAAA,OAAO,EAAC,OAAd;AAAsB,IAAA,EAAE,EAAC,GAAzB;AAA6B,IAAA,EAAE,EAAGP;AAAlC,KACGO,WADH,CADY,GAIT,IARL,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport usePatternCategories from '../sidebar-navigation-screen-patterns/use-pattern-categories';\nimport {\n\tUSER_PATTERN_CATEGORY,\n\tUSER_PATTERNS,\n\tTEMPLATE_PARTS,\n\tPATTERNS,\n} from './utils';\n\nexport default function PatternsHeader( {\n\tcategoryId,\n\ttype,\n\ttitleId,\n\tdescriptionId,\n} ) {\n\tconst { patternCategories } = usePatternCategories();\n\tconst templatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplatePartAreas(),\n\t\t[]\n\t);\n\n\tlet title, description;\n\tif ( categoryId === USER_PATTERN_CATEGORY && type === USER_PATTERNS ) {\n\t\ttitle = __( 'My Patterns' );\n\t\tdescription = '';\n\t} else if ( type === TEMPLATE_PARTS ) {\n\t\tconst templatePartArea = templatePartAreas.find(\n\t\t\t( area ) => area.area === categoryId\n\t\t);\n\t\ttitle = templatePartArea?.label;\n\t\tdescription = templatePartArea?.description;\n\t} else if ( type === PATTERNS ) {\n\t\tconst patternCategory = patternCategories.find(\n\t\t\t( category ) => category.name === categoryId\n\t\t);\n\t\ttitle = patternCategory?.label;\n\t\tdescription = patternCategory?.description;\n\t}\n\n\tif ( ! title ) return null;\n\n\treturn (\n\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t<Heading as=\"h2\" level={ 4 } id={ titleId }>\n\t\t\t\t{ title }\n\t\t\t</Heading>\n\t\t\t{ description ? (\n\t\t\t\t<Text variant=\"muted\" as=\"p\" id={ descriptionId }>\n\t\t\t\t\t{ description }\n\t\t\t\t</Text>\n\t\t\t) : null }\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -53,7 +53,9 @@ function PagePatterns() {
|
|
|
53
53
|
className: "edit-site-patterns",
|
|
54
54
|
title: (0, _i18n.__)('Patterns content'),
|
|
55
55
|
hideTitleFromUI: true
|
|
56
|
-
}, (0, _element.createElement)(_patternsList.default
|
|
56
|
+
}, (0, _element.createElement)(_patternsList.default // Reset the states when switching between categories and types.
|
|
57
|
+
, {
|
|
58
|
+
key: `${type}-${category}`,
|
|
57
59
|
type: type,
|
|
58
60
|
categoryId: category
|
|
59
61
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/index.js"],"names":["ExperimentalBlockEditorProvider","blockEditorPrivateApis","PagePatterns","categoryType","categoryId","window","location","href","type","DEFAULT_TYPE","category","DEFAULT_CATEGORY","settings"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;;AAKA;AACA;AACA;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAsC,wBAAQC,wBAAR,CAA5C;;AAEe,SAASC,YAAT,GAAwB;AACtC,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAA+B,uBAAcC,MAAM,CAACC,QAAP,CAAgBC,IAA9B,CAArC;AACA,QAAMC,IAAI,GAAGL,YAAY,IAAIM,mBAA7B;AACA,QAAMC,QAAQ,GAAGN,UAAU,IAAIO,uBAA/B;AACA,QAAMC,QAAQ,GAAG,kCAAjB,CAJsC,CAMtC;AACA;AACA;;AACA,SACC,4BAAC,+BAAD;AAAiC,IAAA,QAAQ,EAAGA;AAA5C,KACC,4BAAC,aAAD;AACC,IAAA,SAAS,EAAC,oBADX;AAEC,IAAA,KAAK,EAAG,cAAI,kBAAJ,CAFT;AAGC,IAAA,eAAe;AAHhB,KAKC,4BAAC,qBAAD;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/index.js"],"names":["ExperimentalBlockEditorProvider","blockEditorPrivateApis","PagePatterns","categoryType","categoryId","window","location","href","type","DEFAULT_TYPE","category","DEFAULT_CATEGORY","settings"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;;AAKA;AACA;AACA;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAsC,wBAAQC,wBAAR,CAA5C;;AAEe,SAASC,YAAT,GAAwB;AACtC,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAA+B,uBAAcC,MAAM,CAACC,QAAP,CAAgBC,IAA9B,CAArC;AACA,QAAMC,IAAI,GAAGL,YAAY,IAAIM,mBAA7B;AACA,QAAMC,QAAQ,GAAGN,UAAU,IAAIO,uBAA/B;AACA,QAAMC,QAAQ,GAAG,kCAAjB,CAJsC,CAMtC;AACA;AACA;;AACA,SACC,4BAAC,+BAAD;AAAiC,IAAA,QAAQ,EAAGA;AAA5C,KACC,4BAAC,aAAD;AACC,IAAA,SAAS,EAAC,oBADX;AAEC,IAAA,KAAK,EAAG,cAAI,kBAAJ,CAFT;AAGC,IAAA,eAAe;AAHhB,KAKC,4BAAC,qBAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAI,GAAGJ,IAAM,IAAIE,QAAU,EAF/B;AAGC,IAAA,IAAI,EAAGF,IAHR;AAIC,IAAA,UAAU,EAAGE;AAJd,IALD,CADD,CADD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { getQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CATEGORY, DEFAULT_TYPE } from './utils';\nimport Page from '../page';\nimport PatternsList from './patterns-list';\nimport usePatternSettings from './use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\n\nexport default function PagePatterns() {\n\tconst { categoryType, categoryId } = getQueryArgs( window.location.href );\n\tconst type = categoryType || DEFAULT_TYPE;\n\tconst category = categoryId || DEFAULT_CATEGORY;\n\tconst settings = usePatternSettings();\n\n\t// Wrap everything in a block editor provider.\n\t// This ensures 'styles' that are needed for the previews are synced\n\t// from the site editor store to the block editor store.\n\treturn (\n\t\t<ExperimentalBlockEditorProvider settings={ settings }>\n\t\t\t<Page\n\t\t\t\tclassName=\"edit-site-patterns\"\n\t\t\t\ttitle={ __( 'Patterns content' ) }\n\t\t\t\thideTitleFromUI\n\t\t\t>\n\t\t\t\t<PatternsList\n\t\t\t\t\t// Reset the states when switching between categories and types.\n\t\t\t\t\tkey={ `${ type }-${ category }` }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcategoryId={ category }\n\t\t\t\t/>\n\t\t\t</Page>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n"]}
|
|
@@ -19,6 +19,8 @@ var _router = require("@wordpress/router");
|
|
|
19
19
|
|
|
20
20
|
var _compose = require("@wordpress/compose");
|
|
21
21
|
|
|
22
|
+
var _header = _interopRequireDefault(require("./header"));
|
|
23
|
+
|
|
22
24
|
var _grid = _interopRequireDefault(require("./grid"));
|
|
23
25
|
|
|
24
26
|
var _noPatterns = _interopRequireDefault(require("./no-patterns"));
|
|
@@ -31,6 +33,8 @@ var _useDebouncedInput = _interopRequireDefault(require("../../utils/use-debounc
|
|
|
31
33
|
|
|
32
34
|
var _lockUnlock = require("../../lock-unlock");
|
|
33
35
|
|
|
36
|
+
var _utils = require("./utils");
|
|
37
|
+
|
|
34
38
|
/**
|
|
35
39
|
* WordPress dependencies
|
|
36
40
|
*/
|
|
@@ -42,6 +46,16 @@ const {
|
|
|
42
46
|
useLocation,
|
|
43
47
|
useHistory
|
|
44
48
|
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
49
|
+
const SYNC_FILTERS = {
|
|
50
|
+
all: (0, _i18n.__)('All'),
|
|
51
|
+
[_utils.SYNC_TYPES.full]: (0, _i18n.__)('Synced'),
|
|
52
|
+
[_utils.SYNC_TYPES.unsynced]: (0, _i18n.__)('Standard')
|
|
53
|
+
};
|
|
54
|
+
const SYNC_DESCRIPTIONS = {
|
|
55
|
+
all: '',
|
|
56
|
+
[_utils.SYNC_TYPES.full]: (0, _i18n.__)('Patterns that are kept in sync across the site.'),
|
|
57
|
+
[_utils.SYNC_TYPES.unsynced]: (0, _i18n.__)('Patterns that can be changed freely without affecting the site.')
|
|
58
|
+
};
|
|
45
59
|
|
|
46
60
|
function PatternsList({
|
|
47
61
|
categoryId,
|
|
@@ -51,15 +65,34 @@ function PatternsList({
|
|
|
51
65
|
const history = useHistory();
|
|
52
66
|
const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
|
|
53
67
|
const [filterValue, setFilterValue, delayedFilterValue] = (0, _useDebouncedInput.default)('');
|
|
54
|
-
const
|
|
68
|
+
const deferredFilterValue = (0, _element.useDeferredValue)(delayedFilterValue);
|
|
69
|
+
const [syncFilter, setSyncFilter] = (0, _element.useState)('all');
|
|
70
|
+
const deferredSyncedFilter = (0, _element.useDeferredValue)(syncFilter);
|
|
55
71
|
const {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} =
|
|
59
|
-
|
|
72
|
+
patterns,
|
|
73
|
+
isResolving
|
|
74
|
+
} = (0, _usePatterns.default)(type, categoryId, {
|
|
75
|
+
search: deferredFilterValue,
|
|
76
|
+
syncStatus: deferredSyncedFilter === 'all' ? undefined : deferredSyncedFilter
|
|
77
|
+
});
|
|
78
|
+
const id = (0, _element.useId)();
|
|
79
|
+
const titleId = `${id}-title`;
|
|
80
|
+
const descriptionId = `${id}-description`;
|
|
81
|
+
const hasPatterns = patterns.length;
|
|
82
|
+
const title = SYNC_FILTERS[syncFilter];
|
|
83
|
+
const description = SYNC_DESCRIPTIONS[syncFilter];
|
|
84
|
+
const shownPatterns = (0, _compose.useAsyncList)(patterns);
|
|
60
85
|
return (0, _element.createElement)(_components.__experimentalVStack, {
|
|
61
86
|
spacing: 6
|
|
62
|
-
}, (0, _element.createElement)(
|
|
87
|
+
}, (0, _element.createElement)(_header.default, {
|
|
88
|
+
categoryId: categoryId,
|
|
89
|
+
type: type,
|
|
90
|
+
titleId: titleId,
|
|
91
|
+
descriptionId: descriptionId
|
|
92
|
+
}), (0, _element.createElement)(_components.Flex, {
|
|
93
|
+
alignment: "stretch",
|
|
94
|
+
wrap: true
|
|
95
|
+
}, isMobileViewport && (0, _element.createElement)(_sidebarButton.default, {
|
|
63
96
|
icon: (0, _i18n.isRTL)() ? _icons.chevronRight : _icons.chevronLeft,
|
|
64
97
|
label: (0, _i18n.__)('Back'),
|
|
65
98
|
onClick: () => {
|
|
@@ -73,36 +106,43 @@ function PatternsList({
|
|
|
73
106
|
});
|
|
74
107
|
}
|
|
75
108
|
}
|
|
76
|
-
}), (0, _element.createElement)(_components.FlexBlock,
|
|
109
|
+
}), (0, _element.createElement)(_components.FlexBlock, {
|
|
110
|
+
className: "edit-site-patterns__search-block"
|
|
111
|
+
}, (0, _element.createElement)(_components.SearchControl, {
|
|
77
112
|
className: "edit-site-patterns__search",
|
|
78
113
|
onChange: value => setFilterValue(value),
|
|
79
114
|
placeholder: (0, _i18n.__)('Search patterns'),
|
|
80
115
|
label: (0, _i18n.__)('Search patterns'),
|
|
81
116
|
value: filterValue,
|
|
82
117
|
__nextHasNoMarginBottom: true
|
|
83
|
-
}))
|
|
84
|
-
className: "edit-site-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
})), categoryId === _utils.USER_PATTERN_CATEGORY && (0, _element.createElement)(_components.__experimentalToggleGroupControl, {
|
|
119
|
+
className: "edit-site-patterns__sync-status-filter",
|
|
120
|
+
hideLabelFromVision: true,
|
|
121
|
+
label: (0, _i18n.__)('Filter by sync status'),
|
|
122
|
+
value: syncFilter,
|
|
123
|
+
isBlock: true,
|
|
124
|
+
onChange: value => setSyncFilter(value),
|
|
125
|
+
__nextHasNoMarginBottom: true
|
|
126
|
+
}, Object.entries(SYNC_FILTERS).map(([key, label]) => (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
127
|
+
className: "edit-site-patterns__sync-status-filter-option",
|
|
128
|
+
key: key,
|
|
129
|
+
value: key,
|
|
130
|
+
label: label
|
|
131
|
+
})))), syncFilter !== 'all' && (0, _element.createElement)(_components.__experimentalVStack, {
|
|
96
132
|
className: "edit-site-patterns__section-header"
|
|
97
133
|
}, (0, _element.createElement)(_components.__experimentalHeading, {
|
|
98
|
-
|
|
99
|
-
|
|
134
|
+
as: "h3",
|
|
135
|
+
level: 4,
|
|
136
|
+
id: titleId
|
|
137
|
+
}, title), description ? (0, _element.createElement)(_components.__experimentalText, {
|
|
100
138
|
variant: "muted",
|
|
101
|
-
as: "p"
|
|
102
|
-
|
|
139
|
+
as: "p",
|
|
140
|
+
id: descriptionId
|
|
141
|
+
}, description) : null), hasPatterns && (0, _element.createElement)(_grid.default, {
|
|
103
142
|
categoryId: categoryId,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
143
|
+
items: shownPatterns,
|
|
144
|
+
"aria-labelledby": titleId,
|
|
145
|
+
"aria-describedby": descriptionId
|
|
146
|
+
}), !isResolving && !hasPatterns && (0, _element.createElement)(_noPatterns.default, null));
|
|
107
147
|
}
|
|
108
148
|
//# sourceMappingURL=patterns-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/patterns-list.js"],"names":["useLocation","useHistory","routerPrivateApis","PatternsList","categoryId","type","location","history","isMobileViewport","filterValue","setFilterValue","delayedFilterValue","patterns","isResolving","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/patterns-list.js"],"names":["useLocation","useHistory","routerPrivateApis","SYNC_FILTERS","all","SYNC_TYPES","full","unsynced","SYNC_DESCRIPTIONS","PatternsList","categoryId","type","location","history","isMobileViewport","filterValue","setFilterValue","delayedFilterValue","deferredFilterValue","syncFilter","setSyncFilter","deferredSyncedFilter","patterns","isResolving","search","syncStatus","undefined","id","titleId","descriptionId","hasPatterns","length","title","description","shownPatterns","chevronRight","chevronLeft","state","backPath","back","push","path","value","USER_PATTERN_CATEGORY","Object","entries","map","key","label"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useDeferredValue, useId } from '@wordpress/element';\nimport {\n\tSearchControl,\n\t__experimentalVStack as VStack,\n\tFlex,\n\tFlexBlock,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useViewportMatch, useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PatternsHeader from './header';\nimport Grid from './grid';\nimport NoPatterns from './no-patterns';\nimport usePatterns from './use-patterns';\nimport SidebarButton from '../sidebar-button';\nimport useDebouncedInput from '../../utils/use-debounced-input';\nimport { unlock } from '../../lock-unlock';\nimport { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nconst SYNC_FILTERS = {\n\tall: __( 'All' ),\n\t[ SYNC_TYPES.full ]: __( 'Synced' ),\n\t[ SYNC_TYPES.unsynced ]: __( 'Standard' ),\n};\n\nconst SYNC_DESCRIPTIONS = {\n\tall: '',\n\t[ SYNC_TYPES.full ]: __(\n\t\t'Patterns that are kept in sync across the site.'\n\t),\n\t[ SYNC_TYPES.unsynced ]: __(\n\t\t'Patterns that can be changed freely without affecting the site.'\n\t),\n};\n\nexport default function PatternsList( { categoryId, type } ) {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( '' );\n\tconst deferredFilterValue = useDeferredValue( delayedFilterValue );\n\n\tconst [ syncFilter, setSyncFilter ] = useState( 'all' );\n\tconst deferredSyncedFilter = useDeferredValue( syncFilter );\n\tconst { patterns, isResolving } = usePatterns( type, categoryId, {\n\t\tsearch: deferredFilterValue,\n\t\tsyncStatus:\n\t\t\tdeferredSyncedFilter === 'all' ? undefined : deferredSyncedFilter,\n\t} );\n\n\tconst id = useId();\n\tconst titleId = `${ id }-title`;\n\tconst descriptionId = `${ id }-description`;\n\n\tconst hasPatterns = patterns.length;\n\tconst title = SYNC_FILTERS[ syncFilter ];\n\tconst description = SYNC_DESCRIPTIONS[ syncFilter ];\n\tconst shownPatterns = useAsyncList( patterns );\n\n\treturn (\n\t\t<VStack spacing={ 6 }>\n\t\t\t<PatternsHeader\n\t\t\t\tcategoryId={ categoryId }\n\t\t\t\ttype={ type }\n\t\t\t\ttitleId={ titleId }\n\t\t\t\tdescriptionId={ descriptionId }\n\t\t\t/>\n\n\t\t\t<Flex alignment=\"stretch\" wrap>\n\t\t\t\t{ isMobileViewport && (\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Go back in history if we came from the Patterns page.\n\t\t\t\t\t\t\t// Otherwise push a stack onto the history.\n\t\t\t\t\t\t\tif ( location.state?.backPath === '/patterns' ) {\n\t\t\t\t\t\t\t\thistory.back();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\thistory.push( { path: '/patterns' } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<FlexBlock className=\"edit-site-patterns__search-block\">\n\t\t\t\t\t<SearchControl\n\t\t\t\t\t\tclassName=\"edit-site-patterns__search\"\n\t\t\t\t\t\tonChange={ ( value ) => setFilterValue( value ) }\n\t\t\t\t\t\tplaceholder={ __( 'Search patterns' ) }\n\t\t\t\t\t\tlabel={ __( 'Search patterns' ) }\n\t\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</FlexBlock>\n\t\t\t\t{ categoryId === USER_PATTERN_CATEGORY && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\tclassName=\"edit-site-patterns__sync-status-filter\"\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tlabel={ __( 'Filter by sync status' ) }\n\t\t\t\t\t\tvalue={ syncFilter }\n\t\t\t\t\t\tisBlock\n\t\t\t\t\t\tonChange={ ( value ) => setSyncFilter( value ) }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t>\n\t\t\t\t\t\t{ Object.entries( SYNC_FILTERS ).map(\n\t\t\t\t\t\t\t( [ key, label ] ) => (\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-patterns__sync-status-filter-option\"\n\t\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\t\tvalue={ key }\n\t\t\t\t\t\t\t\t\tlabel={ label }\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</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t</Flex>\n\t\t\t{ syncFilter !== 'all' && (\n\t\t\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t\t\t<Heading as=\"h3\" level={ 4 } id={ titleId }>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Heading>\n\t\t\t\t\t{ description ? (\n\t\t\t\t\t\t<Text variant=\"muted\" as=\"p\" id={ descriptionId }>\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t) : null }\n\t\t\t\t</VStack>\n\t\t\t) }\n\t\t\t{ hasPatterns && (\n\t\t\t\t<Grid\n\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\titems={ shownPatterns }\n\t\t\t\t\taria-labelledby={ titleId }\n\t\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! isResolving && ! hasPatterns && <NoPatterns /> }\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = RenameMenuItem;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
|
|
12
|
+
var _coreData = require("@wordpress/core-data");
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _i18n = require("@wordpress/i18n");
|
|
17
|
+
|
|
18
|
+
var _notices = require("@wordpress/notices");
|
|
19
|
+
|
|
20
|
+
var _utils = require("./utils");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* WordPress dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
function RenameMenuItem({
|
|
30
|
+
item,
|
|
31
|
+
onClose
|
|
32
|
+
}) {
|
|
33
|
+
const [title, setTitle] = (0, _element.useState)(() => item.title);
|
|
34
|
+
const [isModalOpen, setIsModalOpen] = (0, _element.useState)(false);
|
|
35
|
+
const {
|
|
36
|
+
editEntityRecord,
|
|
37
|
+
saveEditedEntityRecord
|
|
38
|
+
} = (0, _data.useDispatch)(_coreData.store);
|
|
39
|
+
const {
|
|
40
|
+
createSuccessNotice,
|
|
41
|
+
createErrorNotice
|
|
42
|
+
} = (0, _data.useDispatch)(_notices.store);
|
|
43
|
+
|
|
44
|
+
if (item.type === _utils.TEMPLATE_PARTS && !item.isCustom) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function onRename(event) {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
await editEntityRecord('postType', item.type, item.id, {
|
|
53
|
+
title
|
|
54
|
+
}); // Update state before saving rerenders the list.
|
|
55
|
+
|
|
56
|
+
setTitle('');
|
|
57
|
+
setIsModalOpen(false);
|
|
58
|
+
onClose(); // Persist edited entity.
|
|
59
|
+
|
|
60
|
+
await saveEditedEntityRecord('postType', item.type, item.id, {
|
|
61
|
+
throwOnError: true
|
|
62
|
+
});
|
|
63
|
+
createSuccessNotice((0, _i18n.__)('Entity renamed.'), {
|
|
64
|
+
type: 'snackbar'
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while renaming the entity.');
|
|
68
|
+
createErrorNotice(errorMessage, {
|
|
69
|
+
type: 'snackbar'
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuItem, {
|
|
75
|
+
onClick: () => {
|
|
76
|
+
setIsModalOpen(true);
|
|
77
|
+
setTitle(item.title);
|
|
78
|
+
}
|
|
79
|
+
}, (0, _i18n.__)('Rename')), isModalOpen && (0, _element.createElement)(_components.Modal, {
|
|
80
|
+
title: (0, _i18n.__)('Rename'),
|
|
81
|
+
onRequestClose: () => {
|
|
82
|
+
setIsModalOpen(false);
|
|
83
|
+
onClose();
|
|
84
|
+
},
|
|
85
|
+
overlayClassName: "edit-site-list__rename_modal"
|
|
86
|
+
}, (0, _element.createElement)("form", {
|
|
87
|
+
onSubmit: onRename
|
|
88
|
+
}, (0, _element.createElement)(_components.__experimentalVStack, {
|
|
89
|
+
spacing: "5"
|
|
90
|
+
}, (0, _element.createElement)(_components.TextControl, {
|
|
91
|
+
__nextHasNoMarginBottom: true,
|
|
92
|
+
label: (0, _i18n.__)('Name'),
|
|
93
|
+
value: title,
|
|
94
|
+
onChange: setTitle,
|
|
95
|
+
required: true
|
|
96
|
+
}), (0, _element.createElement)(_components.__experimentalHStack, {
|
|
97
|
+
justify: "right"
|
|
98
|
+
}, (0, _element.createElement)(_components.Button, {
|
|
99
|
+
variant: "tertiary",
|
|
100
|
+
onClick: () => {
|
|
101
|
+
setIsModalOpen(false);
|
|
102
|
+
onClose();
|
|
103
|
+
}
|
|
104
|
+
}, (0, _i18n.__)('Cancel')), (0, _element.createElement)(_components.Button, {
|
|
105
|
+
variant: "primary",
|
|
106
|
+
type: "submit"
|
|
107
|
+
}, (0, _i18n.__)('Save')))))));
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=rename-menu-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/rename-menu-item.js"],"names":["RenameMenuItem","item","onClose","title","setTitle","isModalOpen","setIsModalOpen","editEntityRecord","saveEditedEntityRecord","coreStore","createSuccessNotice","createErrorNotice","noticesStore","type","TEMPLATE_PARTS","isCustom","onRename","event","preventDefault","id","throwOnError","error","errorMessage","message","code"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tMenuItem,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PARTS } from './utils';\n\nexport default function RenameMenuItem( { item, onClose } ) {\n\tconst [ title, setTitle ] = useState( () => item.title );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tif ( item.type === TEMPLATE_PARTS && ! item.isCustom ) {\n\t\treturn null;\n\t}\n\n\tasync function onRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', item.type, item.id, { title } );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice( __( 'Entity renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetTitle( item.title );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename_modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -11,7 +11,7 @@ var _data = require("@wordpress/data");
|
|
|
11
11
|
|
|
12
12
|
var _coreData = require("@wordpress/core-data");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
15
15
|
|
|
16
16
|
var _utils = require("./utils");
|
|
17
17
|
|
|
@@ -36,92 +36,68 @@ const templatePartToPattern = templatePart => ({
|
|
|
36
36
|
blocks: (0, _blocks.parse)(templatePart.content.raw),
|
|
37
37
|
categories: [templatePart.area],
|
|
38
38
|
description: templatePart.description || '',
|
|
39
|
+
isCustom: templatePart.source === 'custom',
|
|
39
40
|
keywords: templatePart.keywords || [],
|
|
41
|
+
id: createTemplatePartId(templatePart.theme, templatePart.slug),
|
|
40
42
|
name: createTemplatePartId(templatePart.theme, templatePart.slug),
|
|
41
|
-
title: templatePart.title.rendered,
|
|
43
|
+
title: (0, _htmlEntities.decodeEntities)(templatePart.title.rendered),
|
|
42
44
|
type: templatePart.type,
|
|
43
45
|
templatePart
|
|
44
46
|
});
|
|
45
47
|
|
|
46
|
-
const
|
|
48
|
+
const templatePartHasCategory = (item, category) => item.templatePart.area === category;
|
|
47
49
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return item.templatePart.area === category;
|
|
54
|
-
};
|
|
50
|
+
const selectTemplatePartsAsPatterns = (select, {
|
|
51
|
+
categoryId,
|
|
52
|
+
search = ''
|
|
53
|
+
} = {}) => {
|
|
54
|
+
var _getEntityRecords;
|
|
55
55
|
|
|
56
|
-
const useTemplatePartsAsPatterns = (categoryId, postType = _utils.TEMPLATE_PARTS, filterValue = '') => {
|
|
57
56
|
const {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
} = (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} = select(_coreData.store);
|
|
72
|
-
const query = {
|
|
73
|
-
per_page: -1
|
|
74
|
-
};
|
|
75
|
-
const rawTemplateParts = getEntityRecords('postType', postType, query);
|
|
76
|
-
const partsAsPatterns = rawTemplateParts?.map(templatePart => templatePartToPattern(templatePart));
|
|
77
|
-
return {
|
|
78
|
-
templateParts: partsAsPatterns,
|
|
79
|
-
isResolving: _isResolving('getEntityRecords', ['postType', 'wp_template_part', query])
|
|
80
|
-
};
|
|
81
|
-
}, [postType]);
|
|
82
|
-
const filteredTemplateParts = (0, _element.useMemo)(() => {
|
|
83
|
-
if (!templateParts) {
|
|
84
|
-
return EMPTY_PATTERN_LIST;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return (0, _searchItems.searchItems)(templateParts, filterValue, {
|
|
88
|
-
categoryId,
|
|
89
|
-
hasCategory: templatePartHasCategory
|
|
90
|
-
});
|
|
91
|
-
}, [templateParts, filterValue, categoryId]);
|
|
57
|
+
getEntityRecords,
|
|
58
|
+
getIsResolving
|
|
59
|
+
} = select(_coreData.store);
|
|
60
|
+
const query = {
|
|
61
|
+
per_page: -1
|
|
62
|
+
};
|
|
63
|
+
const rawTemplateParts = (_getEntityRecords = getEntityRecords('postType', _utils.TEMPLATE_PARTS, query)) !== null && _getEntityRecords !== void 0 ? _getEntityRecords : EMPTY_PATTERN_LIST;
|
|
64
|
+
const templateParts = rawTemplateParts.map(templatePart => templatePartToPattern(templatePart));
|
|
65
|
+
const isResolving = getIsResolving('getEntityRecords', ['postType', 'wp_template_part', query]);
|
|
66
|
+
const patterns = (0, _searchItems.searchItems)(templateParts, search, {
|
|
67
|
+
categoryId,
|
|
68
|
+
hasCategory: templatePartHasCategory
|
|
69
|
+
});
|
|
92
70
|
return {
|
|
93
|
-
|
|
71
|
+
patterns,
|
|
94
72
|
isResolving
|
|
95
73
|
};
|
|
96
74
|
};
|
|
97
75
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
76
|
+
const selectThemePatterns = (select, {
|
|
77
|
+
categoryId,
|
|
78
|
+
search = ''
|
|
79
|
+
} = {}) => {
|
|
80
|
+
var _settings$__experimen;
|
|
101
81
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const patterns = (0, _element.useMemo)(() => [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !_utils.CORE_PATTERN_SOURCES.includes(pattern.source)).filter(_utils.filterOutDuplicatesByName).map(pattern => ({ ...pattern,
|
|
82
|
+
const {
|
|
83
|
+
getSettings
|
|
84
|
+
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
85
|
+
const settings = getSettings();
|
|
86
|
+
const blockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns;
|
|
87
|
+
const restBlockPatterns = select(_coreData.store).getBlockPatterns();
|
|
88
|
+
let patterns = [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !_utils.CORE_PATTERN_SOURCES.includes(pattern.source)).filter(_utils.filterOutDuplicatesByName).map(pattern => ({ ...pattern,
|
|
110
89
|
keywords: pattern.keywords || [],
|
|
111
90
|
type: 'pattern',
|
|
112
91
|
blocks: (0, _blocks.parse)(pattern.content)
|
|
113
|
-
}))
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
});
|
|
123
|
-
}, [patterns, filterValue, categoryId, postType]);
|
|
124
|
-
return filteredPatterns;
|
|
92
|
+
}));
|
|
93
|
+
patterns = (0, _searchItems.searchItems)(patterns, search, {
|
|
94
|
+
categoryId,
|
|
95
|
+
hasCategory: (item, currentCategory) => item.categories?.includes(currentCategory)
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
patterns,
|
|
99
|
+
isResolving: false
|
|
100
|
+
};
|
|
125
101
|
};
|
|
126
102
|
|
|
127
103
|
const reusableBlockToPattern = reusableBlock => ({
|
|
@@ -129,73 +105,70 @@ const reusableBlockToPattern = reusableBlock => ({
|
|
|
129
105
|
categories: reusableBlock.wp_pattern,
|
|
130
106
|
id: reusableBlock.id,
|
|
131
107
|
name: reusableBlock.slug,
|
|
132
|
-
syncStatus: reusableBlock.
|
|
108
|
+
syncStatus: reusableBlock.wp_pattern_sync_status || _utils.SYNC_TYPES.full,
|
|
133
109
|
title: reusableBlock.title.raw,
|
|
134
110
|
type: reusableBlock.type,
|
|
135
111
|
reusableBlock
|
|
136
112
|
});
|
|
137
113
|
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (!records) {
|
|
153
|
-
return EMPTY_PATTERN_LIST;
|
|
154
|
-
}
|
|
114
|
+
const selectUserPatterns = (select, {
|
|
115
|
+
search = '',
|
|
116
|
+
syncStatus
|
|
117
|
+
} = {}) => {
|
|
118
|
+
const {
|
|
119
|
+
getEntityRecords,
|
|
120
|
+
getIsResolving
|
|
121
|
+
} = select(_coreData.store);
|
|
122
|
+
const query = {
|
|
123
|
+
per_page: -1
|
|
124
|
+
};
|
|
125
|
+
const records = getEntityRecords('postType', _utils.USER_PATTERNS, query);
|
|
126
|
+
let patterns = records ? records.map(record => reusableBlockToPattern(record)) : EMPTY_PATTERN_LIST;
|
|
127
|
+
const isResolving = getIsResolving('getEntityRecords', ['postType', _utils.USER_PATTERNS, query]);
|
|
155
128
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (!unfilteredPatterns.length) {
|
|
160
|
-
return EMPTY_PATTERN_LIST;
|
|
161
|
-
}
|
|
129
|
+
if (syncStatus) {
|
|
130
|
+
patterns = patterns.filter(pattern => pattern.syncStatus === syncStatus);
|
|
131
|
+
}
|
|
162
132
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
169
|
-
}, [unfilteredPatterns, filterValue]);
|
|
170
|
-
const patterns = {
|
|
171
|
-
syncedPatterns: [],
|
|
172
|
-
unsyncedPatterns: []
|
|
173
|
-
};
|
|
174
|
-
filteredPatterns.forEach(pattern => {
|
|
175
|
-
if (pattern.syncStatus === _utils.SYNC_TYPES.full) {
|
|
176
|
-
patterns.syncedPatterns.push(pattern);
|
|
177
|
-
} else {
|
|
178
|
-
patterns.unsyncedPatterns.push(pattern);
|
|
179
|
-
}
|
|
133
|
+
patterns = (0, _searchItems.searchItems)(patterns, search, {
|
|
134
|
+
// We exit user pattern retrieval early if we aren't in the
|
|
135
|
+
// catch-all category for user created patterns, so it has
|
|
136
|
+
// to be in the category.
|
|
137
|
+
hasCategory: () => true
|
|
180
138
|
});
|
|
181
|
-
return
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const usePatterns = (categoryType, categoryId, filterValue) => {
|
|
185
|
-
const blockPatterns = useThemePatterns(categoryId, categoryType, filterValue);
|
|
186
|
-
const {
|
|
187
|
-
syncedPatterns = [],
|
|
188
|
-
unsyncedPatterns = []
|
|
189
|
-
} = useUserPatterns(categoryId, categoryType, filterValue);
|
|
190
|
-
const {
|
|
191
|
-
templateParts,
|
|
139
|
+
return {
|
|
140
|
+
patterns,
|
|
192
141
|
isResolving
|
|
193
|
-
} = useTemplatePartsAsPatterns(categoryId, categoryType, filterValue);
|
|
194
|
-
const patterns = {
|
|
195
|
-
syncedPatterns: [...templateParts, ...syncedPatterns],
|
|
196
|
-
unsyncedPatterns: [...blockPatterns, ...unsyncedPatterns]
|
|
197
142
|
};
|
|
198
|
-
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const usePatterns = (categoryType, categoryId, {
|
|
146
|
+
search = '',
|
|
147
|
+
syncStatus
|
|
148
|
+
}) => {
|
|
149
|
+
return (0, _data.useSelect)(select => {
|
|
150
|
+
if (categoryType === _utils.TEMPLATE_PARTS) {
|
|
151
|
+
return selectTemplatePartsAsPatterns(select, {
|
|
152
|
+
categoryId,
|
|
153
|
+
search
|
|
154
|
+
});
|
|
155
|
+
} else if (categoryType === _utils.PATTERNS) {
|
|
156
|
+
return selectThemePatterns(select, {
|
|
157
|
+
categoryId,
|
|
158
|
+
search
|
|
159
|
+
});
|
|
160
|
+
} else if (categoryType === _utils.USER_PATTERNS) {
|
|
161
|
+
return selectUserPatterns(select, {
|
|
162
|
+
search,
|
|
163
|
+
syncStatus
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
patterns: EMPTY_PATTERN_LIST,
|
|
169
|
+
isResolving: false
|
|
170
|
+
};
|
|
171
|
+
}, [categoryId, categoryType, search, syncStatus]);
|
|
199
172
|
};
|
|
200
173
|
|
|
201
174
|
exports.usePatterns = usePatterns;
|