@wordpress/fields 0.24.0 → 0.24.1-next.ff1cebbba.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/actions/delete-post.js +168 -117
- package/build/actions/delete-post.js.map +7 -1
- package/build/actions/duplicate-pattern.js +42 -43
- package/build/actions/duplicate-pattern.js.map +7 -1
- package/build/actions/duplicate-post.js +104 -93
- package/build/actions/duplicate-post.js.map +7 -1
- package/build/actions/duplicate-template-part.js +71 -63
- package/build/actions/duplicate-template-part.js.map +7 -1
- package/build/actions/export-pattern.js +60 -45
- package/build/actions/export-pattern.js.map +7 -1
- package/build/actions/index.js +71 -94
- package/build/actions/index.js.map +7 -1
- package/build/actions/permanently-delete-post.js +161 -132
- package/build/actions/permanently-delete-post.js.map +7 -1
- package/build/actions/rename-post.js +77 -83
- package/build/actions/rename-post.js.map +7 -1
- package/build/actions/reorder-page.js +76 -73
- package/build/actions/reorder-page.js.map +7 -1
- package/build/actions/reset-post.js +214 -165
- package/build/actions/reset-post.js.map +7 -1
- package/build/actions/restore-post.js +91 -75
- package/build/actions/restore-post.js.map +7 -1
- package/build/actions/trash-post.js +167 -127
- package/build/actions/trash-post.js.map +7 -1
- package/build/actions/utils.js +48 -41
- package/build/actions/utils.js.map +7 -1
- package/build/actions/view-post-revisions.js +39 -35
- package/build/actions/view-post-revisions.js.map +7 -1
- package/build/actions/view-post.js +31 -28
- package/build/actions/view-post.js.map +7 -1
- package/build/components/create-template-part-modal/index.js +213 -169
- package/build/components/create-template-part-modal/index.js.map +7 -1
- package/build/components/create-template-part-modal/utils.js +48 -48
- package/build/components/create-template-part-modal/utils.js.map +7 -1
- package/build/fields/author/author-view.js +63 -69
- package/build/fields/author/author-view.js.map +7 -1
- package/build/fields/author/index.js +43 -29
- package/build/fields/author/index.js.map +7 -1
- package/build/fields/comment-status/index.js +42 -32
- package/build/fields/comment-status/index.js.map +7 -1
- package/build/fields/date/date-view.js +84 -58
- package/build/fields/date/date-view.js.map +7 -1
- package/build/fields/date/index.js +39 -25
- package/build/fields/date/index.js.map +7 -1
- package/build/fields/discussion/index.js +36 -32
- package/build/fields/discussion/index.js.map +7 -1
- package/build/fields/featured-image/featured-image-edit.js +115 -97
- package/build/fields/featured-image/featured-image-edit.js.map +7 -1
- package/build/fields/featured-image/featured-image-view.js +41 -34
- package/build/fields/featured-image/featured-image-view.js.map +7 -1
- package/build/fields/featured-image/index.js +31 -26
- package/build/fields/featured-image/index.js.map +7 -1
- package/build/fields/index.js +83 -118
- package/build/fields/index.js.map +7 -1
- package/build/fields/order/index.js +28 -23
- package/build/fields/order/index.js.map +7 -1
- package/build/fields/page-title/index.js +42 -30
- package/build/fields/page-title/index.js.map +7 -1
- package/build/fields/page-title/view.js +38 -41
- package/build/fields/page-title/view.js.map +7 -1
- package/build/fields/parent/index.js +31 -26
- package/build/fields/parent/index.js.map +7 -1
- package/build/fields/parent/parent-edit.js +200 -168
- package/build/fields/parent/parent-edit.js.map +7 -1
- package/build/fields/parent/parent-view.js +40 -31
- package/build/fields/parent/parent-view.js.map +7 -1
- package/build/fields/parent/utils.js +29 -16
- package/build/fields/parent/utils.js.map +7 -1
- package/build/fields/password/edit.js +67 -53
- package/build/fields/password/edit.js.map +7 -1
- package/build/fields/password/index.js +40 -26
- package/build/fields/password/index.js.map +7 -1
- package/build/fields/pattern-title/index.js +42 -30
- package/build/fields/pattern-title/index.js.map +7 -1
- package/build/fields/pattern-title/view.js +43 -41
- package/build/fields/pattern-title/view.js.map +7 -1
- package/build/fields/ping-status/index.js +66 -47
- package/build/fields/ping-status/index.js.map +7 -1
- package/build/fields/slug/index.js +41 -27
- package/build/fields/slug/index.js.map +7 -1
- package/build/fields/slug/slug-edit.js +116 -107
- package/build/fields/slug/slug-edit.js.map +7 -1
- package/build/fields/slug/slug-view.js +30 -23
- package/build/fields/slug/slug-view.js.map +7 -1
- package/build/fields/slug/utils.js +32 -20
- package/build/fields/slug/utils.js.map +7 -1
- package/build/fields/status/index.js +43 -29
- package/build/fields/status/index.js.map +7 -1
- package/build/fields/status/status-elements.js +58 -44
- package/build/fields/status/status-elements.js.map +7 -1
- package/build/fields/status/status-view.js +42 -36
- package/build/fields/status/status-view.js.map +7 -1
- package/build/fields/template/index.js +29 -24
- package/build/fields/template/index.js.map +7 -1
- package/build/fields/template/template-edit.js +167 -142
- package/build/fields/template/template-edit.js.map +7 -1
- package/build/fields/template-title/index.js +42 -30
- package/build/fields/template-title/index.js.map +7 -1
- package/build/fields/title/index.js +42 -32
- package/build/fields/title/index.js.map +7 -1
- package/build/fields/title/view.js +57 -39
- package/build/fields/title/view.js.map +7 -1
- package/build/index.js +39 -36
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -14
- package/build/lock-unlock.js.map +7 -1
- package/build/mutation/index.js +91 -76
- package/build/mutation/index.js.map +7 -1
- package/build/types.js +16 -5
- package/build/types.js.map +7 -1
- package/build-module/actions/delete-post.js +155 -107
- package/build-module/actions/delete-post.js.map +7 -1
- package/build-module/actions/duplicate-pattern.js +24 -36
- package/build-module/actions/duplicate-pattern.js.map +7 -1
- package/build-module/actions/duplicate-post.js +87 -84
- package/build-module/actions/duplicate-post.js.map +7 -1
- package/build-module/actions/duplicate-template-part.js +51 -58
- package/build-module/actions/duplicate-template-part.js.map +7 -1
- package/build-module/actions/export-pattern.js +40 -39
- package/build-module/actions/export-pattern.js.map +7 -1
- package/build-module/actions/index.js +29 -14
- package/build-module/actions/index.js.map +7 -1
- package/build-module/actions/permanently-delete-post.js +146 -125
- package/build-module/actions/permanently-delete-post.js.map +7 -1
- package/build-module/actions/rename-post.js +63 -77
- package/build-module/actions/rename-post.js.map +7 -1
- package/build-module/actions/reorder-page.js +58 -65
- package/build-module/actions/reorder-page.js.map +7 -1
- package/build-module/actions/reset-post.js +185 -152
- package/build-module/actions/reset-post.js.map +7 -1
- package/build-module/actions/restore-post.js +72 -68
- package/build-module/actions/restore-post.js.map +7 -1
- package/build-module/actions/trash-post.js +152 -119
- package/build-module/actions/trash-post.js.map +7 -1
- package/build-module/actions/utils.js +23 -34
- package/build-module/actions/utils.js.map +7 -1
- package/build-module/actions/view-post-revisions.js +21 -31
- package/build-module/actions/view-post-revisions.js.map +7 -1
- package/build-module/actions/view-post.js +12 -23
- package/build-module/actions/view-post.js.map +7 -1
- package/build-module/components/create-template-part-modal/index.js +201 -154
- package/build-module/components/create-template-part-modal/index.js.map +7 -1
- package/build-module/components/create-template-part-modal/utils.js +26 -43
- package/build-module/components/create-template-part-modal/utils.js.map +7 -1
- package/build-module/fields/author/author-view.js +34 -62
- package/build-module/fields/author/author-view.js.map +7 -1
- package/build-module/fields/author/index.js +14 -24
- package/build-module/fields/author/index.js.map +7 -1
- package/build-module/fields/comment-status/index.js +24 -29
- package/build-module/fields/comment-status/index.js.map +7 -1
- package/build-module/fields/date/date-view.js +66 -53
- package/build-module/fields/date/date-view.js.map +7 -1
- package/build-module/fields/date/index.js +10 -20
- package/build-module/fields/date/index.js.map +7 -1
- package/build-module/fields/discussion/index.js +18 -29
- package/build-module/fields/discussion/index.js.map +7 -1
- package/build-module/fields/featured-image/featured-image-edit.js +93 -90
- package/build-module/fields/featured-image/featured-image-edit.js.map +7 -1
- package/build-module/fields/featured-image/featured-image-view.js +20 -29
- package/build-module/fields/featured-image/featured-image-view.js.map +7 -1
- package/build-module/fields/featured-image/index.js +11 -21
- package/build-module/fields/featured-image/index.js.map +7 -1
- package/build-module/fields/index.js +35 -17
- package/build-module/fields/index.js.map +7 -1
- package/build-module/fields/order/index.js +10 -20
- package/build-module/fields/order/index.js.map +7 -1
- package/build-module/fields/page-title/index.js +13 -25
- package/build-module/fields/page-title/index.js.map +7 -1
- package/build-module/fields/page-title/view.js +20 -37
- package/build-module/fields/page-title/view.js.map +7 -1
- package/build-module/fields/parent/index.js +11 -21
- package/build-module/fields/parent/index.js.map +7 -1
- package/build-module/fields/parent/parent-edit.js +172 -160
- package/build-module/fields/parent/parent-edit.js.map +7 -1
- package/build-module/fields/parent/parent-view.js +19 -27
- package/build-module/fields/parent/parent-view.js.map +7 -1
- package/build-module/fields/parent/utils.js +8 -13
- package/build-module/fields/parent/utils.js.map +7 -1
- package/build-module/fields/password/edit.js +53 -48
- package/build-module/fields/password/edit.js.map +7 -1
- package/build-module/fields/password/index.js +11 -21
- package/build-module/fields/password/index.js.map +7 -1
- package/build-module/fields/pattern-title/index.js +13 -25
- package/build-module/fields/pattern-title/index.js.map +7 -1
- package/build-module/fields/pattern-title/view.js +21 -34
- package/build-module/fields/pattern-title/view.js.map +7 -1
- package/build-module/fields/ping-status/index.js +48 -43
- package/build-module/fields/ping-status/index.js.map +7 -1
- package/build-module/fields/slug/index.js +11 -21
- package/build-module/fields/slug/index.js.map +7 -1
- package/build-module/fields/slug/slug-edit.js +101 -100
- package/build-module/fields/slug/slug-edit.js.map +7 -1
- package/build-module/fields/slug/slug-view.js +9 -16
- package/build-module/fields/slug/slug-view.js.map +7 -1
- package/build-module/fields/slug/utils.js +9 -13
- package/build-module/fields/slug/utils.js.map +7 -1
- package/build-module/fields/status/index.js +13 -23
- package/build-module/fields/status/index.js.map +7 -1
- package/build-module/fields/status/status-elements.js +47 -40
- package/build-module/fields/status/status-elements.js.map +7 -1
- package/build-module/fields/status/status-view.js +14 -31
- package/build-module/fields/status/status-view.js.map +7 -1
- package/build-module/fields/template/index.js +10 -18
- package/build-module/fields/template/index.js.map +7 -1
- package/build-module/fields/template/template-edit.js +147 -130
- package/build-module/fields/template/template-edit.js.map +7 -1
- package/build-module/fields/template-title/index.js +13 -25
- package/build-module/fields/template-title/index.js.map +7 -1
- package/build-module/fields/title/index.js +13 -27
- package/build-module/fields/title/index.js.map +7 -1
- package/build-module/fields/title/view.js +25 -32
- package/build-module/fields/title/view.js.map +7 -1
- package/build-module/index.js +7 -4
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/mutation/index.js +70 -72
- package/build-module/mutation/index.js.map +7 -1
- package/build-module/types.js +1 -2
- package/build-module/types.js.map +7 -1
- package/build-style/style-rtl.css +4 -139
- package/build-style/style.css +4 -139
- package/build-types/fields/author/author-view.d.ts.map +1 -1
- package/build-types/fields/discussion/index.d.ts.map +1 -1
- package/build-types/fields/featured-image/featured-image-edit.d.ts +2 -2
- package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -1
- package/build-types/fields/featured-image/featured-image-view.d.ts +5 -2
- package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -1
- package/build-types/fields/featured-image/index.d.ts +3 -3
- package/build-types/fields/featured-image/index.d.ts.map +1 -1
- package/build-types/types.d.ts +18 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +34 -27
- package/src/components/create-template-part-modal/style.scss +4 -0
- package/src/fields/author/author-view.tsx +3 -17
- package/src/fields/discussion/index.tsx +1 -0
- package/src/fields/featured-image/featured-image-edit.tsx +2 -2
- package/src/fields/featured-image/featured-image-view.tsx +3 -15
- package/src/fields/featured-image/index.ts +3 -3
- package/src/fields/featured-image/style.scss +3 -0
- package/src/fields/template/style.scss +4 -0
- package/src/fields/title/style.scss +1 -1
- package/src/style.scss +9 -8
- package/src/types.ts +18 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/index.native.js +0 -2
- package/build/index.native.js.map +0 -1
- package/build-module/index.native.js +0 -2
- package/build-module/index.native.js.map +0 -1
package/build/actions/utils.js
CHANGED
|
@@ -1,57 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
getItemTitle: () => getItemTitle,
|
|
22
|
+
isTemplate: () => isTemplate,
|
|
23
|
+
isTemplateOrTemplatePart: () => isTemplateOrTemplatePart,
|
|
24
|
+
isTemplatePart: () => isTemplatePart,
|
|
25
|
+
isTemplateRemovable: () => isTemplateRemovable
|
|
5
26
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.isTemplatePart = isTemplatePart;
|
|
10
|
-
exports.isTemplateRemovable = isTemplateRemovable;
|
|
11
|
-
var _htmlEntities = require("@wordpress/html-entities");
|
|
12
|
-
var _i18n = require("@wordpress/i18n");
|
|
13
|
-
/**
|
|
14
|
-
* WordPress dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Internal dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
27
|
+
module.exports = __toCommonJS(utils_exports);
|
|
28
|
+
var import_html_entities = require("@wordpress/html-entities");
|
|
29
|
+
var import_i18n = require("@wordpress/i18n");
|
|
21
30
|
function isTemplate(post) {
|
|
22
|
-
return post.type ===
|
|
31
|
+
return post.type === "wp_template";
|
|
23
32
|
}
|
|
24
33
|
function isTemplatePart(post) {
|
|
25
|
-
return post.type ===
|
|
34
|
+
return post.type === "wp_template_part";
|
|
26
35
|
}
|
|
27
36
|
function isTemplateOrTemplatePart(p) {
|
|
28
|
-
return p.type ===
|
|
37
|
+
return p.type === "wp_template" || p.type === "wp_template_part";
|
|
29
38
|
}
|
|
30
|
-
function getItemTitle(item, fallback = (0,
|
|
31
|
-
let title =
|
|
32
|
-
if (typeof item.title ===
|
|
33
|
-
title = (0,
|
|
34
|
-
} else if (item.title &&
|
|
35
|
-
title = (0,
|
|
36
|
-
} else if (item.title &&
|
|
37
|
-
title = (0,
|
|
39
|
+
function getItemTitle(item, fallback = (0, import_i18n.__)("(no title)")) {
|
|
40
|
+
let title = "";
|
|
41
|
+
if (typeof item.title === "string") {
|
|
42
|
+
title = (0, import_html_entities.decodeEntities)(item.title);
|
|
43
|
+
} else if (item.title && "rendered" in item.title) {
|
|
44
|
+
title = (0, import_html_entities.decodeEntities)(item.title.rendered);
|
|
45
|
+
} else if (item.title && "raw" in item.title) {
|
|
46
|
+
title = (0, import_html_entities.decodeEntities)(item.title.raw);
|
|
38
47
|
}
|
|
39
48
|
return title || fallback;
|
|
40
49
|
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Check if a template is removable.
|
|
44
|
-
*
|
|
45
|
-
* @param template The template entity to check.
|
|
46
|
-
* @return Whether the template is removable.
|
|
47
|
-
*/
|
|
48
50
|
function isTemplateRemovable(template) {
|
|
49
51
|
if (!template) {
|
|
50
52
|
return false;
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
// than the one returned from the endpoint. This is why we need to check for
|
|
54
|
-
// two props whether is custom or has a theme file.
|
|
55
|
-
return [template.source, template.source].includes('custom') && !Boolean(template.type === 'wp_template' && template?.plugin) && !template.has_theme_file;
|
|
54
|
+
return [template.source, template.source].includes("custom") && !Boolean(template.type === "wp_template" && template?.plugin) && !template.has_theme_file;
|
|
56
55
|
}
|
|
57
|
-
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
getItemTitle,
|
|
59
|
+
isTemplate,
|
|
60
|
+
isTemplateOrTemplatePart,
|
|
61
|
+
isTemplatePart,
|
|
62
|
+
isTemplateRemovable
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/actions/utils.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { Post, TemplatePart, Template } from '../types';\n\nexport function isTemplate( post: Post ): post is Template {\n\treturn post.type === 'wp_template';\n}\n\nexport function isTemplatePart( post: Post ): post is TemplatePart {\n\treturn post.type === 'wp_template_part';\n}\n\nexport function isTemplateOrTemplatePart(\n\tp: Post\n): p is Template | TemplatePart {\n\treturn p.type === 'wp_template' || p.type === 'wp_template_part';\n}\n\nexport function getItemTitle(\n\titem: {\n\t\ttitle: string | { rendered: string } | { raw: string };\n\t},\n\tfallback: string = __( '(no title)' )\n) {\n\tlet title = '';\n\tif ( typeof item.title === 'string' ) {\n\t\ttitle = decodeEntities( item.title );\n\t} else if ( item.title && 'rendered' in item.title ) {\n\t\ttitle = decodeEntities( item.title.rendered );\n\t} else if ( item.title && 'raw' in item.title ) {\n\t\ttitle = decodeEntities( item.title.raw );\n\t}\n\treturn title || fallback;\n}\n\n/**\n * Check if a template is removable.\n *\n * @param template The template entity to check.\n * @return Whether the template is removable.\n */\nexport function isTemplateRemovable( template: Template | TemplatePart ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\t// In patterns list page we map the templates parts to a different object\n\t// than the one returned from the endpoint. This is why we need to check for\n\t// two props whether is custom or has a theme file.\n\treturn (\n\t\t[ template.source, template.source ].includes( 'custom' ) &&\n\t\t! Boolean( template.type === 'wp_template' && template?.plugin ) &&\n\t\t! template.has_theme_file\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,2BAA+B;AAC/B,kBAAmB;AAOZ,SAAS,WAAY,MAA+B;AAC1D,SAAO,KAAK,SAAS;AACtB;AAEO,SAAS,eAAgB,MAAmC;AAClE,SAAO,KAAK,SAAS;AACtB;AAEO,SAAS,yBACf,GAC+B;AAC/B,SAAO,EAAE,SAAS,iBAAiB,EAAE,SAAS;AAC/C;AAEO,SAAS,aACf,MAGA,eAAmB,gBAAI,YAAa,GACnC;AACD,MAAI,QAAQ;AACZ,MAAK,OAAO,KAAK,UAAU,UAAW;AACrC,gBAAQ,qCAAgB,KAAK,KAAM;AAAA,EACpC,WAAY,KAAK,SAAS,cAAc,KAAK,OAAQ;AACpD,gBAAQ,qCAAgB,KAAK,MAAM,QAAS;AAAA,EAC7C,WAAY,KAAK,SAAS,SAAS,KAAK,OAAQ;AAC/C,gBAAQ,qCAAgB,KAAK,MAAM,GAAI;AAAA,EACxC;AACA,SAAO,SAAS;AACjB;AAQO,SAAS,oBAAqB,UAAoC;AACxE,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AAIA,SACC,CAAE,SAAS,QAAQ,SAAS,MAAO,EAAE,SAAU,QAAS,KACxD,CAAE,QAAS,SAAS,SAAS,iBAAiB,UAAU,MAAO,KAC/D,CAAE,SAAS;AAEb;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,43 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var view_post_revisions_exports = {};
|
|
20
|
+
__export(view_post_revisions_exports, {
|
|
21
|
+
default: () => view_post_revisions_default
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
/**
|
|
10
|
-
* WordPress dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
23
|
+
module.exports = __toCommonJS(view_post_revisions_exports);
|
|
24
|
+
var import_url = require("@wordpress/url");
|
|
25
|
+
var import_i18n = require("@wordpress/i18n");
|
|
17
26
|
const viewPostRevisions = {
|
|
18
|
-
id:
|
|
19
|
-
context:
|
|
27
|
+
id: "view-post-revisions",
|
|
28
|
+
context: "list",
|
|
20
29
|
label(items) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
const revisionsCount = items[0]._links?.["version-history"]?.[0]?.count ?? 0;
|
|
31
|
+
return (0, import_i18n.sprintf)(
|
|
32
|
+
/* translators: %d: number of revisions. */
|
|
33
|
+
(0, import_i18n.__)("View revisions (%d)"),
|
|
34
|
+
revisionsCount
|
|
35
|
+
);
|
|
25
36
|
},
|
|
26
37
|
isEligible(post) {
|
|
27
|
-
|
|
28
|
-
if (post.status === 'trash') {
|
|
38
|
+
if (post.status === "trash") {
|
|
29
39
|
return false;
|
|
30
40
|
}
|
|
31
|
-
const lastRevisionId =
|
|
32
|
-
const revisionsCount =
|
|
41
|
+
const lastRevisionId = post?._links?.["predecessor-version"]?.[0]?.id ?? null;
|
|
42
|
+
const revisionsCount = post?._links?.["version-history"]?.[0]?.count ?? 0;
|
|
33
43
|
return !!lastRevisionId && revisionsCount > 1;
|
|
34
44
|
},
|
|
35
|
-
callback(posts, {
|
|
36
|
-
onActionPerformed
|
|
37
|
-
}) {
|
|
45
|
+
callback(posts, { onActionPerformed }) {
|
|
38
46
|
const post = posts[0];
|
|
39
|
-
const href = (0,
|
|
40
|
-
revision: post?._links?.[
|
|
47
|
+
const href = (0, import_url.addQueryArgs)("revision.php", {
|
|
48
|
+
revision: post?._links?.["predecessor-version"]?.[0]?.id
|
|
41
49
|
});
|
|
42
50
|
document.location.href = href;
|
|
43
51
|
if (onActionPerformed) {
|
|
@@ -45,9 +53,5 @@ const viewPostRevisions = {
|
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* View post revisions action for Post.
|
|
51
|
-
*/
|
|
52
|
-
var _default = exports.default = viewPostRevisions;
|
|
53
|
-
//# sourceMappingURL=view-post-revisions.js.map
|
|
56
|
+
var view_post_revisions_default = viewPostRevisions;
|
|
57
|
+
//# sourceMappingURL=view-post-revisions.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/actions/view-post-revisions.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Post } from '../types';\n\nconst viewPostRevisions: Action< Post > = {\n\tid: 'view-post-revisions',\n\tcontext: 'list',\n\tlabel( items ) {\n\t\tconst revisionsCount =\n\t\t\titems[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn sprintf(\n\t\t\t/* translators: %d: number of revisions. */\n\t\t\t__( 'View revisions (%d)' ),\n\t\t\trevisionsCount\n\t\t);\n\t},\n\tisEligible( post ) {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn !! lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( posts, { onActionPerformed } ) {\n\t\tconst post = posts[ 0 ];\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\n/**\n * View post revisions action for Post.\n */\nexport default viewPostRevisions;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA6B;AAC7B,kBAA4B;AAQ5B,MAAM,oBAAoC;AAAA,EACzC,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,MAAO,OAAQ;AACd,UAAM,iBACL,MAAO,CAAE,EAAE,SAAU,iBAAkB,IAAK,CAAE,GAAG,SAAS;AAC3D,eAAO;AAAA;AAAA,UAEN,gBAAI,qBAAsB;AAAA,MAC1B;AAAA,IACD;AAAA,EACD;AAAA,EACA,WAAY,MAAO;AAClB,QAAK,KAAK,WAAW,SAAU;AAC9B,aAAO;AAAA,IACR;AACA,UAAM,iBACL,MAAM,SAAU,qBAAsB,IAAK,CAAE,GAAG,MAAM;AACvD,UAAM,iBACL,MAAM,SAAU,iBAAkB,IAAK,CAAE,GAAG,SAAS;AACtD,WAAO,CAAC,CAAE,kBAAkB,iBAAiB;AAAA,EAC9C;AAAA,EACA,SAAU,OAAO,EAAE,kBAAkB,GAAI;AACxC,UAAM,OAAO,MAAO,CAAE;AACtB,UAAM,WAAO,yBAAc,gBAAgB;AAAA,MAC1C,UAAU,MAAM,SAAU,qBAAsB,IAAK,CAAE,GAAG;AAAA,IAC3D,CAAE;AACF,aAAS,SAAS,OAAO;AACzB,QAAK,mBAAoB;AACxB,wBAAmB,KAAM;AAAA,IAC1B;AAAA,EACD;AACD;AAKA,IAAO,8BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,40 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var view_post_exports = {};
|
|
20
|
+
__export(view_post_exports, {
|
|
21
|
+
default: () => view_post_default
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
/**
|
|
10
|
-
* WordPress dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
23
|
+
module.exports = __toCommonJS(view_post_exports);
|
|
24
|
+
var import_icons = require("@wordpress/icons");
|
|
25
|
+
var import_i18n = require("@wordpress/i18n");
|
|
17
26
|
const viewPost = {
|
|
18
|
-
id:
|
|
19
|
-
label: (0,
|
|
27
|
+
id: "view-post",
|
|
28
|
+
label: (0, import_i18n._x)("View", "verb"),
|
|
20
29
|
isPrimary: true,
|
|
21
|
-
icon:
|
|
30
|
+
icon: import_icons.external,
|
|
22
31
|
isEligible(post) {
|
|
23
|
-
return post.status !==
|
|
32
|
+
return post.status !== "trash";
|
|
24
33
|
},
|
|
25
|
-
callback(posts, {
|
|
26
|
-
onActionPerformed
|
|
27
|
-
}) {
|
|
34
|
+
callback(posts, { onActionPerformed }) {
|
|
28
35
|
const post = posts[0];
|
|
29
|
-
window.open(post?.link,
|
|
36
|
+
window.open(post?.link, "_blank");
|
|
30
37
|
if (onActionPerformed) {
|
|
31
38
|
onActionPerformed(posts);
|
|
32
39
|
}
|
|
33
40
|
}
|
|
34
41
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* View post action for BasePost.
|
|
38
|
-
*/
|
|
39
|
-
var _default = exports.default = viewPost;
|
|
40
|
-
//# sourceMappingURL=view-post.js.map
|
|
42
|
+
var view_post_default = viewPost;
|
|
43
|
+
//# sourceMappingURL=view-post.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/actions/view-post.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { external } from '@wordpress/icons';\nimport { _x } from '@wordpress/i18n';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../types';\n\nconst viewPost: Action< BasePost > = {\n\tid: 'view-post',\n\tlabel: _x( 'View', 'verb' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( posts, { onActionPerformed } ) {\n\t\tconst post = posts[ 0 ];\n\t\twindow.open( post?.link, '_blank' );\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\n/**\n * View post action for BasePost.\n */\nexport default viewPost;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAyB;AACzB,kBAAmB;AAQnB,MAAM,WAA+B;AAAA,EACpC,IAAI;AAAA,EACJ,WAAO,gBAAI,QAAQ,MAAO;AAAA,EAC1B,WAAW;AAAA,EACX,MAAM;AAAA,EACN,WAAY,MAAO;AAClB,WAAO,KAAK,WAAW;AAAA,EACxB;AAAA,EACA,SAAU,OAAO,EAAE,kBAAkB,GAAI;AACxC,UAAM,OAAO,MAAO,CAAE;AACtB,WAAO,KAAM,MAAM,MAAM,QAAS;AAClC,QAAK,mBAAoB;AACxB,wBAAmB,KAAM;AAAA,IAC1B;AAAA,EACD;AACD;AAKA,IAAO,oBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|