@wordpress/edit-site 5.12.7 → 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/create-pattern-modal/index.js +7 -3
- package/build/components/create-pattern-modal/index.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 +83 -59
- 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 -118
- package/build/components/page-patterns/use-patterns.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-page/status-label.js +1 -34
- package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +2 -2
- 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/site-hub/index.js +1 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/template-actions/index.js +3 -1
- 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/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/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/create-pattern-modal/index.js +6 -3
- package/build-module/components/create-pattern-modal/index.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 +84 -65
- 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 -119
- package/build-module/components/page-patterns/use-patterns.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-page/status-label.js +1 -32
- package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +2 -2
- 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/site-hub/index.js +1 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/template-actions/index.js +2 -1
- 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/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/utils/use-activate-theme.js +1 -1
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-style/style-rtl.css +103 -45
- package/build-style/style.css +103 -45
- package/package.json +14 -14
- package/src/components/block-editor/editor-canvas.js +1 -1
- package/src/components/create-pattern-modal/index.js +5 -2
- package/src/components/header-edit-mode/document-actions/style.scss +4 -0
- package/src/components/page-patterns/duplicate-menu-item.js +196 -0
- package/src/components/page-patterns/grid-item.js +187 -137
- 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 +96 -167
- package/src/components/sidebar-navigation-screen/index.js +1 -1
- package/src/components/sidebar-navigation-screen-page/status-label.js +1 -35
- package/src/components/sidebar-navigation-screen-patterns/index.js +0 -6
- package/src/components/sidebar-navigation-screen-patterns/style.scss +0 -3
- package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
- package/src/components/site-hub/index.js +1 -1
- package/src/components/template-actions/index.js +2 -1
- package/src/components/template-actions/rename-menu-item.js +8 -6
- package/src/hooks/push-changes-to-global-styles/index.js +8 -1
- package/src/style.scss +10 -12
- package/src/utils/use-activate-theme.js +1 -1
|
@@ -11,6 +11,8 @@ var _element = require("@wordpress/element");
|
|
|
11
11
|
|
|
12
12
|
var _components = require("@wordpress/components");
|
|
13
13
|
|
|
14
|
+
var _i18n = require("@wordpress/i18n");
|
|
15
|
+
|
|
14
16
|
var _gridItem = _interopRequireDefault(require("./grid-item"));
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -20,30 +22,36 @@ var _gridItem = _interopRequireDefault(require("./grid-item"));
|
|
|
20
22
|
/**
|
|
21
23
|
* Internal dependencies
|
|
22
24
|
*/
|
|
25
|
+
const PAGE_SIZE = 100;
|
|
26
|
+
|
|
23
27
|
function Grid({
|
|
24
28
|
categoryId,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
items
|
|
29
|
+
items,
|
|
30
|
+
...props
|
|
28
31
|
}) {
|
|
29
|
-
const
|
|
30
|
-
orientation: 'vertical'
|
|
31
|
-
});
|
|
32
|
+
const gridRef = (0, _element.useRef)();
|
|
32
33
|
|
|
33
34
|
if (!items?.length) {
|
|
34
35
|
return null;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
const list = items.slice(0, PAGE_SIZE);
|
|
39
|
+
const restLength = items.length - PAGE_SIZE;
|
|
40
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("ul", {
|
|
38
41
|
role: "listbox",
|
|
39
42
|
className: "edit-site-patterns__grid",
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
...props,
|
|
44
|
+
ref: gridRef
|
|
45
|
+
}, list.map(item => (0, _element.createElement)(_gridItem.default, {
|
|
42
46
|
key: item.name,
|
|
43
|
-
icon: icon,
|
|
44
47
|
item: item,
|
|
45
|
-
categoryId: categoryId
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
categoryId: categoryId
|
|
49
|
+
}))), restLength > 0 && (0, _element.createElement)(_components.__experimentalText, {
|
|
50
|
+
variant: "muted",
|
|
51
|
+
as: "p",
|
|
52
|
+
align: "center"
|
|
53
|
+
}, (0, _i18n.sprintf)(
|
|
54
|
+
/* translators: %d: number of patterns */
|
|
55
|
+
(0, _i18n.__)('+ %d more patterns discoverable by searching'), restLength)));
|
|
48
56
|
}
|
|
49
57
|
//# sourceMappingURL=grid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/grid.js"],"names":["Grid","categoryId","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/grid.js"],"names":["PAGE_SIZE","Grid","categoryId","items","props","gridRef","length","list","slice","restLength","map","item","name"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,SAAS,GAAG,GAAlB;;AAEe,SAASC,IAAT,CAAe;AAAEC,EAAAA,UAAF;AAAcC,EAAAA,KAAd;AAAqB,KAAGC;AAAxB,CAAf,EAAiD;AAC/D,QAAMC,OAAO,GAAG,sBAAhB;;AAEA,MAAK,CAAEF,KAAK,EAAEG,MAAd,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,QAAMC,IAAI,GAAGJ,KAAK,CAACK,KAAN,CAAa,CAAb,EAAgBR,SAAhB,CAAb;AACA,QAAMS,UAAU,GAAGN,KAAK,CAACG,MAAN,GAAeN,SAAlC;AAEA,SACC,qDACC;AACC,IAAA,IAAI,EAAC,SADN;AAEC,IAAA,SAAS,EAAC,0BAFX;AAAA,OAGMI,KAHN;AAIC,IAAA,GAAG,EAAGC;AAJP,KAMGE,IAAI,CAACG,GAAL,CAAYC,IAAF,IACX,4BAAC,iBAAD;AACC,IAAA,GAAG,EAAGA,IAAI,CAACC,IADZ;AAEC,IAAA,IAAI,EAAGD,IAFR;AAGC,IAAA,UAAU,EAAGT;AAHd,IADC,CANH,CADD,EAeGO,UAAU,GAAG,CAAb,IACD,4BAAC,8BAAD;AAAM,IAAA,OAAO,EAAC,OAAd;AAAsB,IAAA,EAAE,EAAC,GAAzB;AAA6B,IAAA,KAAK,EAAC;AAAnC,KACG;AACD;AACA,gBAAI,8CAAJ,CAFC,EAGDA,UAHC,CADH,CAhBF,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalText as Text } from '@wordpress/components';\nimport { useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport GridItem from './grid-item';\n\nconst PAGE_SIZE = 100;\n\nexport default function Grid( { categoryId, items, ...props } ) {\n\tconst gridRef = useRef();\n\n\tif ( ! items?.length ) {\n\t\treturn null;\n\t}\n\n\tconst list = items.slice( 0, PAGE_SIZE );\n\tconst restLength = items.length - PAGE_SIZE;\n\n\treturn (\n\t\t<>\n\t\t\t<ul\n\t\t\t\trole=\"listbox\"\n\t\t\t\tclassName=\"edit-site-patterns__grid\"\n\t\t\t\t{ ...props }\n\t\t\t\tref={ gridRef }\n\t\t\t>\n\t\t\t\t{ list.map( ( item ) => (\n\t\t\t\t\t<GridItem\n\t\t\t\t\t\tkey={ item.name }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ restLength > 0 && (\n\t\t\t\t<Text variant=\"muted\" as=\"p\" align=\"center\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of patterns */\n\t\t\t\t\t\t__( '+ %d more patterns discoverable by searching' ),\n\t\t\t\t\t\trestLength\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = PatternsHeader;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _components = require("@wordpress/components");
|
|
13
|
+
|
|
14
|
+
var _i18n = require("@wordpress/i18n");
|
|
15
|
+
|
|
16
|
+
var _editor = require("@wordpress/editor");
|
|
17
|
+
|
|
18
|
+
var _data = require("@wordpress/data");
|
|
19
|
+
|
|
20
|
+
var _usePatternCategories = _interopRequireDefault(require("../sidebar-navigation-screen-patterns/use-pattern-categories"));
|
|
21
|
+
|
|
22
|
+
var _utils = require("./utils");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* WordPress dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
function PatternsHeader({
|
|
32
|
+
categoryId,
|
|
33
|
+
type,
|
|
34
|
+
titleId,
|
|
35
|
+
descriptionId
|
|
36
|
+
}) {
|
|
37
|
+
const {
|
|
38
|
+
patternCategories
|
|
39
|
+
} = (0, _usePatternCategories.default)();
|
|
40
|
+
const templatePartAreas = (0, _data.useSelect)(select => select(_editor.store).__experimentalGetDefaultTemplatePartAreas(), []);
|
|
41
|
+
let title, description;
|
|
42
|
+
|
|
43
|
+
if (categoryId === _utils.USER_PATTERN_CATEGORY && type === _utils.USER_PATTERNS) {
|
|
44
|
+
title = (0, _i18n.__)('My Patterns');
|
|
45
|
+
description = '';
|
|
46
|
+
} else if (type === _utils.TEMPLATE_PARTS) {
|
|
47
|
+
const templatePartArea = templatePartAreas.find(area => area.area === categoryId);
|
|
48
|
+
title = templatePartArea?.label;
|
|
49
|
+
description = templatePartArea?.description;
|
|
50
|
+
} else if (type === _utils.PATTERNS) {
|
|
51
|
+
const patternCategory = patternCategories.find(category => category.name === categoryId);
|
|
52
|
+
title = patternCategory?.label;
|
|
53
|
+
description = patternCategory?.description;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!title) return null;
|
|
57
|
+
return (0, _element.createElement)(_components.__experimentalVStack, {
|
|
58
|
+
className: "edit-site-patterns__section-header"
|
|
59
|
+
}, (0, _element.createElement)(_components.__experimentalHeading, {
|
|
60
|
+
as: "h2",
|
|
61
|
+
level: 4,
|
|
62
|
+
id: titleId
|
|
63
|
+
}, title), description ? (0, _element.createElement)(_components.__experimentalText, {
|
|
64
|
+
variant: "muted",
|
|
65
|
+
as: "p",
|
|
66
|
+
id: descriptionId
|
|
67
|
+
}, description) : null);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -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":";;;;;;;;;AAGA;;AACA;;AAUA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAiBA;AACA;AACA;AAUA,MAAM;AAAEA,EAAAA,WAAF;AAAeC,EAAAA;AAAf,IAA8B,wBAAQC,mBAAR,CAApC;AAEA,MAAMC,YAAY,GAAG;AACpBC,EAAAA,GAAG,EAAE,cAAI,KAAJ,CADe;AAEpB,GAAEC,kBAAWC,IAAb,GAAqB,cAAI,QAAJ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UAJT;AAKC,IAAA,OAAO,MALR;AAMC,IAAA,QAAQ,EAAKuB,KAAF,IAAatB,aAAa,CAAEsB,KAAF,CANtC;AAOC,IAAA,uBAAuB;AAPxB,KASGE,MAAM,CAACC,OAAP,CAAgB1C,YAAhB,EAA+B2C,GAA/B,CACD,CAAE,CAAEC,GAAF,EAAOC,KAAP,CAAF,KACC,4BAAC,kDAAD;AACC,IAAA,SAAS,EAAC,+CADX;AAEC,IAAA,GAAG,EAAGD,GAFP;AAGC,IAAA,KAAK,EAAGA,GAHT;AAIC,IAAA,KAAK,EAAGC;AAJT,IAFA,CATH,CA3BF,CARD,EAyDG7B,UAAU,KAAK,KAAf,IACD,4BAAC,gCAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,4BAAC,iCAAD;AAAS,IAAA,EAAE,EAAC,IAAZ;AAAiB,IAAA,KAAK,EAAG,CAAzB;AAA6B,IAAA,EAAE,EAAGS;AAAlC,KACGI,KADH,CADD,EAIGC,WAAW,GACZ,4BAAC,8BAAD;AAAM,IAAA,OAAO,EAAC,OAAd;AAAsB,IAAA,EAAE,EAAC,GAAzB;AAA6B,IAAA,EAAE,EAAGJ;AAAlC,KACGI,WADH,CADY,GAIT,IARL,CA1DF,EAqEGH,WAAW,IACZ,4BAAC,aAAD;AACC,IAAA,UAAU,EAAGpB,UADd;AAEC,IAAA,KAAK,EAAGwB,aAFT;AAGC,uBAAkBN,OAHnB;AAIC,wBAAmBC;AAJpB,IAtEF,EA6EG,CAAEN,WAAF,IAAiB,CAAEO,WAAnB,IAAkC,4BAAC,mBAAD,OA7ErC,CADD;AAiFA","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":";;;;;;;AAaA;;AAVA;;AAQA;;AACA;;AAEA;;AACA;;AAKA;;AApBA;AACA;AACA;;AAeA;AACA;AACA;AAGe,SAASA,cAAT,CAAyB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAAzB,EAA6C;AAC3D,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,MAAMH,IAAI,CAACE,KAArB,CAA5B;AACA,QAAM,CAAEE,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AAEA,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MACL,uBAAaC,eAAb,CADD;AAEA,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MACL,uBAAaC,cAAb,CADD;;AAGA,MAAKX,IAAI,CAACY,IAAL,KAAcC,qBAAd,IAAgC,CAAEb,IAAI,CAACc,QAA5C,EAAuD;AACtD,WAAO,IAAP;AACA;;AAED,iBAAeC,QAAf,CAAyBC,KAAzB,EAAiC;AAChCA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAI;AACH,YAAMX,gBAAgB,CAAE,UAAF,EAAcN,IAAI,CAACY,IAAnB,EAAyBZ,IAAI,CAACkB,EAA9B,EAAkC;AAAEhB,QAAAA;AAAF,OAAlC,CA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IAAA,KAAK,EAAGb,KAHT;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,QAAQ;AALT,IADD,EASC,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfE,MAAAA,cAAc,CAAE,KAAF,CAAd;AACAJ,MAAAA,OAAO;AACP;AALF,KAOG,cAAI,QAAJ,CAPH,CADD,EAWC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACG,cAAI,MAAJ,CADH,CAXD,CATD,CADD,CARD,CAVF,CADD;AAkDA","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"]}
|