@wordpress/fields 0.3.0 → 0.4.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/CHANGELOG.md +2 -0
- package/README.md +16 -0
- package/build/actions/utils.js +2 -2
- package/build/actions/utils.js.map +1 -1
- package/build/fields/comment-status/index.js +40 -0
- package/build/fields/comment-status/index.js.map +1 -0
- package/build/fields/date/date-view.js +69 -0
- package/build/fields/date/date-view.js.map +1 -0
- package/build/fields/date/index.js +29 -0
- package/build/fields/date/index.js.map +1 -0
- package/build/fields/featured-image/featured-image-edit.js.map +1 -1
- package/build/fields/featured-image/featured-image-view.js.map +1 -1
- package/build/fields/featured-image/index.js +0 -3
- package/build/fields/featured-image/index.js.map +1 -1
- package/build/fields/index.js +28 -0
- package/build/fields/index.js.map +1 -1
- package/build/fields/order/index.js +1 -1
- package/build/fields/order/index.js.map +1 -1
- package/build/fields/parent/index.js +0 -3
- package/build/fields/parent/index.js.map +1 -1
- package/build/fields/parent/parent-edit.js +6 -6
- package/build/fields/parent/parent-edit.js.map +1 -1
- package/build/fields/parent/parent-view.js +1 -1
- package/build/fields/parent/parent-view.js.map +1 -1
- package/build/fields/password/edit.js +65 -0
- package/build/fields/password/edit.js.map +1 -0
- package/build/fields/password/index.js +30 -0
- package/build/fields/password/index.js.map +1 -0
- package/build/fields/slug/index.js +0 -3
- package/build/fields/slug/index.js.map +1 -1
- package/build/fields/slug/slug-edit.js +23 -26
- package/build/fields/slug/slug-edit.js.map +1 -1
- package/build/fields/slug/slug-view.js +3 -2
- package/build/fields/slug/slug-view.js.map +1 -1
- package/build/fields/slug/utils.js +21 -0
- package/build/fields/slug/utils.js.map +1 -0
- package/build/fields/status/index.js +37 -0
- package/build/fields/status/index.js.map +1 -0
- package/build/fields/status/status-elements.js +46 -0
- package/build/fields/status/status-elements.js.map +1 -0
- package/build/fields/status/status-view.js +41 -0
- package/build/fields/status/status-view.js.map +1 -0
- package/build/fields/title/index.js +5 -1
- package/build/fields/title/index.js.map +1 -1
- package/build/fields/title/title-view.js +61 -0
- package/build/fields/title/title-view.js.map +1 -0
- package/build/types.js.map +1 -1
- package/build-module/actions/utils.js +2 -2
- package/build-module/actions/utils.js.map +1 -1
- package/build-module/fields/comment-status/index.js +35 -0
- package/build-module/fields/comment-status/index.js.map +1 -0
- package/build-module/fields/date/date-view.js +62 -0
- package/build-module/fields/date/date-view.js.map +1 -0
- package/build-module/fields/date/index.js +23 -0
- package/build-module/fields/date/index.js.map +1 -0
- package/build-module/fields/featured-image/featured-image-edit.js +1 -2
- package/build-module/fields/featured-image/featured-image-edit.js.map +1 -1
- package/build-module/fields/featured-image/featured-image-view.js.map +1 -1
- package/build-module/fields/featured-image/index.js +2 -4
- package/build-module/fields/featured-image/index.js.map +1 -1
- package/build-module/fields/index.js +4 -0
- package/build-module/fields/index.js.map +1 -1
- package/build-module/fields/order/index.js +2 -1
- package/build-module/fields/order/index.js.map +1 -1
- package/build-module/fields/parent/index.js +2 -4
- package/build-module/fields/parent/index.js.map +1 -1
- package/build-module/fields/parent/parent-edit.js +10 -8
- package/build-module/fields/parent/parent-edit.js.map +1 -1
- package/build-module/fields/parent/parent-view.js +1 -1
- package/build-module/fields/parent/parent-view.js.map +1 -1
- package/build-module/fields/password/edit.js +58 -0
- package/build-module/fields/password/edit.js.map +1 -0
- package/build-module/fields/password/index.js +23 -0
- package/build-module/fields/password/index.js.map +1 -0
- package/build-module/fields/slug/index.js +2 -4
- package/build-module/fields/slug/index.js.map +1 -1
- package/build-module/fields/slug/slug-edit.js +25 -27
- package/build-module/fields/slug/slug-edit.js.map +1 -1
- package/build-module/fields/slug/slug-view.js +3 -2
- package/build-module/fields/slug/slug-view.js.map +1 -1
- package/build-module/fields/slug/utils.js +13 -0
- package/build-module/fields/slug/utils.js.map +1 -0
- package/build-module/fields/status/index.js +31 -0
- package/build-module/fields/status/index.js.map +1 -0
- package/build-module/fields/status/status-elements.js +40 -0
- package/build-module/fields/status/status-elements.js.map +1 -0
- package/build-module/fields/status/status-view.js +34 -0
- package/build-module/fields/status/status-view.js.map +1 -0
- package/build-module/fields/title/index.js +4 -1
- package/build-module/fields/title/index.js.map +1 -1
- package/build-module/fields/title/title-view.js +55 -0
- package/build-module/fields/title/title-view.js.map +1 -0
- package/build-module/types.js.map +1 -1
- package/build-style/{styles-rtl.css → style-rtl.css} +79 -0
- package/build-style/{styles.css → style.css} +79 -0
- package/build-types/fields/comment-status/index.d.ts +14 -0
- package/build-types/fields/comment-status/index.d.ts.map +1 -0
- package/build-types/fields/date/date-view.d.ts +9 -0
- package/build-types/fields/date/date-view.d.ts.map +1 -0
- package/build-types/fields/date/index.d.ts +14 -0
- package/build-types/fields/date/index.d.ts.map +1 -0
- 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 +1 -1
- package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -1
- package/build-types/fields/featured-image/index.d.ts.map +1 -1
- package/build-types/fields/index.d.ts +4 -0
- package/build-types/fields/index.d.ts.map +1 -1
- package/build-types/fields/order/index.d.ts.map +1 -1
- package/build-types/fields/parent/index.d.ts.map +1 -1
- package/build-types/fields/parent/parent-edit.d.ts +3 -0
- package/build-types/fields/parent/parent-edit.d.ts.map +1 -1
- package/build-types/fields/parent/parent-view.d.ts +1 -1
- package/build-types/fields/parent/parent-view.d.ts.map +1 -1
- package/build-types/fields/password/edit.d.ts +8 -0
- package/build-types/fields/password/edit.d.ts.map +1 -0
- package/build-types/fields/password/index.d.ts +14 -0
- package/build-types/fields/password/index.d.ts.map +1 -0
- package/build-types/fields/slug/index.d.ts.map +1 -1
- package/build-types/fields/slug/slug-edit.d.ts.map +1 -1
- package/build-types/fields/slug/slug-view.d.ts.map +1 -1
- package/build-types/fields/slug/utils.d.ts +6 -0
- package/build-types/fields/slug/utils.d.ts.map +1 -0
- package/build-types/fields/status/index.d.ts +14 -0
- package/build-types/fields/status/index.d.ts.map +1 -0
- package/build-types/fields/status/status-elements.d.ts +13 -0
- package/build-types/fields/status/status-elements.d.ts.map +1 -0
- package/build-types/fields/status/status-view.d.ts +9 -0
- package/build-types/fields/status/status-view.d.ts.map +1 -0
- package/build-types/fields/title/index.d.ts.map +1 -1
- package/build-types/fields/title/title-view.d.ts +9 -0
- package/build-types/fields/title/title-view.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/types.d.ts +3 -1
- package/build-types/types.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/actions/utils.ts +2 -2
- package/src/fields/comment-status/index.tsx +40 -0
- package/src/fields/date/date-view.tsx +92 -0
- package/src/fields/date/index.tsx +23 -0
- package/src/fields/featured-image/featured-image-edit.tsx +2 -1
- package/src/fields/featured-image/featured-image-view.tsx +1 -1
- package/src/fields/featured-image/index.ts +1 -2
- package/src/fields/index.ts +4 -0
- package/src/fields/order/index.ts +2 -1
- package/src/fields/parent/index.ts +1 -2
- package/src/fields/parent/parent-edit.tsx +9 -9
- package/src/fields/parent/parent-view.tsx +2 -2
- package/src/fields/password/edit.tsx +68 -0
- package/src/fields/password/index.tsx +24 -0
- package/src/fields/slug/index.ts +1 -2
- package/src/fields/slug/slug-edit.tsx +21 -24
- package/src/fields/slug/slug-view.tsx +3 -2
- package/src/fields/slug/utils.ts +15 -0
- package/src/fields/status/index.tsx +32 -0
- package/src/fields/status/status-elements.tsx +50 -0
- package/src/fields/status/status-view.tsx +28 -0
- package/src/fields/title/index.ts +3 -0
- package/src/fields/title/title-view.tsx +62 -0
- package/src/style.scss +2 -0
- package/src/types.ts +3 -1
- package/tsconfig.json +10 -9
- package/tsconfig.tsbuildinfo +1 -1
- package/src/styles.scss +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -14,6 +14,14 @@ npm install @wordpress/fields --save
|
|
|
14
14
|
|
|
15
15
|
<!-- START TOKEN(Autogenerated API docs) -->
|
|
16
16
|
|
|
17
|
+
### commentStatusField
|
|
18
|
+
|
|
19
|
+
Comment status field for BasePost.
|
|
20
|
+
|
|
21
|
+
### dateField
|
|
22
|
+
|
|
23
|
+
Date field for BasePost.
|
|
24
|
+
|
|
17
25
|
### deletePost
|
|
18
26
|
|
|
19
27
|
Undocumented declaration.
|
|
@@ -50,6 +58,10 @@ Undocumented declaration.
|
|
|
50
58
|
|
|
51
59
|
This field is used to display the post parent.
|
|
52
60
|
|
|
61
|
+
### passwordField
|
|
62
|
+
|
|
63
|
+
This field is used to display the post password.
|
|
64
|
+
|
|
53
65
|
### permanentlyDeletePost
|
|
54
66
|
|
|
55
67
|
Undocumented declaration.
|
|
@@ -78,6 +90,10 @@ Undocumented declaration.
|
|
|
78
90
|
|
|
79
91
|
Undocumented declaration.
|
|
80
92
|
|
|
93
|
+
### statusField
|
|
94
|
+
|
|
95
|
+
Status field for BasePost.
|
|
96
|
+
|
|
81
97
|
### titleField
|
|
82
98
|
|
|
83
99
|
Undocumented declaration.
|
package/build/actions/utils.js
CHANGED
|
@@ -38,10 +38,10 @@ function getItemTitle(item) {
|
|
|
38
38
|
if (typeof item.title === 'string') {
|
|
39
39
|
return (0, _htmlEntities.decodeEntities)(item.title);
|
|
40
40
|
}
|
|
41
|
-
if ('rendered' in item.title) {
|
|
41
|
+
if (item.title && 'rendered' in item.title) {
|
|
42
42
|
return (0, _htmlEntities.decodeEntities)(item.title.rendered);
|
|
43
43
|
}
|
|
44
|
-
if ('raw' in item.title) {
|
|
44
|
+
if (item.title && 'raw' in item.title) {
|
|
45
45
|
return (0, _htmlEntities.decodeEntities)(item.title.raw);
|
|
46
46
|
}
|
|
47
47
|
return '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_htmlEntities","require","TEMPLATE_POST_TYPE","exports","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","isTemplate","post","type","isTemplatePart","isTemplateOrTemplatePart","p","getItemTitle","item","title","decodeEntities","rendered","raw","isTemplateRemovable","template","source","includes","Boolean","has_theme_file"],"sources":["@wordpress/fields/src/actions/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport type { Post, TemplatePart, Template } from '../types';\n\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\n\nexport function isTemplate( post: Post ): post is Template {\n\treturn post.type === TEMPLATE_POST_TYPE;\n}\n\nexport function isTemplatePart( post: Post ): post is TemplatePart {\n\treturn post.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function isTemplateOrTemplatePart(\n\tp: Post\n): p is Template | TemplatePart {\n\treturn p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function getItemTitle( item: Post ) {\n\tif ( typeof item.title === 'string' ) {\n\t\treturn decodeEntities( item.title );\n\t}\n\tif ( 'rendered' in item.title ) {\n\t\treturn decodeEntities( item.title.rendered );\n\t}\n\tif ( 'raw' in item.title ) {\n\t\treturn decodeEntities( item.title.raw );\n\t}\n\treturn '';\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(\n\t\t\tTEMPLATE_ORIGINS.custom\n\t\t) &&\n\t\t! Boolean( template.type === 'wp_template' && template?.plugin ) &&\n\t\t! template.has_theme_file\n\t);\n}\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,aAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAGO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,aAAa;AACxC,MAAME,uBAAuB,GAAAD,OAAA,CAAAC,uBAAA,GAAG,kBAAkB;AAClD,MAAMC,gBAAgB,GAAAF,OAAA,CAAAE,gBAAA,GAAG;EAC/BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AAEM,SAASC,UAAUA,CAAEC,IAAU,EAAqB;EAC1D,OAAOA,IAAI,CAACC,IAAI,KAAKT,kBAAkB;AACxC;AAEO,SAASU,cAAcA,CAAEF,IAAU,EAAyB;EAClE,OAAOA,IAAI,CAACC,IAAI,KAAKP,uBAAuB;AAC7C;AAEO,SAASS,wBAAwBA,CACvCC,CAAO,EACwB;EAC/B,OAAOA,CAAC,CAACH,IAAI,KAAKT,kBAAkB,IAAIY,CAAC,CAACH,IAAI,KAAKP,uBAAuB;AAC3E;AAEO,SAASW,YAAYA,CAAEC,IAAU,EAAG;EAC1C,IAAK,OAAOA,IAAI,CAACC,KAAK,KAAK,QAAQ,EAAG;IACrC,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAM,CAAC;EACpC;EACA,
|
|
1
|
+
{"version":3,"names":["_htmlEntities","require","TEMPLATE_POST_TYPE","exports","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","isTemplate","post","type","isTemplatePart","isTemplateOrTemplatePart","p","getItemTitle","item","title","decodeEntities","rendered","raw","isTemplateRemovable","template","source","includes","Boolean","has_theme_file"],"sources":["@wordpress/fields/src/actions/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport type { Post, TemplatePart, Template } from '../types';\n\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\n\nexport function isTemplate( post: Post ): post is Template {\n\treturn post.type === TEMPLATE_POST_TYPE;\n}\n\nexport function isTemplatePart( post: Post ): post is TemplatePart {\n\treturn post.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function isTemplateOrTemplatePart(\n\tp: Post\n): p is Template | TemplatePart {\n\treturn p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function getItemTitle( item: Post ) {\n\tif ( typeof item.title === 'string' ) {\n\t\treturn decodeEntities( item.title );\n\t}\n\tif ( item.title && 'rendered' in item.title ) {\n\t\treturn decodeEntities( item.title.rendered );\n\t}\n\tif ( item.title && 'raw' in item.title ) {\n\t\treturn decodeEntities( item.title.raw );\n\t}\n\treturn '';\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(\n\t\t\tTEMPLATE_ORIGINS.custom\n\t\t) &&\n\t\t! Boolean( template.type === 'wp_template' && template?.plugin ) &&\n\t\t! template.has_theme_file\n\t);\n}\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,aAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAGO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,aAAa;AACxC,MAAME,uBAAuB,GAAAD,OAAA,CAAAC,uBAAA,GAAG,kBAAkB;AAClD,MAAMC,gBAAgB,GAAAF,OAAA,CAAAE,gBAAA,GAAG;EAC/BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AAEM,SAASC,UAAUA,CAAEC,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
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _i18n = require("@wordpress/i18n");
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const commentStatusField = {
|
|
17
|
+
id: 'comment_status',
|
|
18
|
+
label: (0, _i18n.__)('Discussion'),
|
|
19
|
+
type: 'text',
|
|
20
|
+
Edit: 'radio',
|
|
21
|
+
enableSorting: false,
|
|
22
|
+
filterBy: {
|
|
23
|
+
operators: []
|
|
24
|
+
},
|
|
25
|
+
elements: [{
|
|
26
|
+
value: 'open',
|
|
27
|
+
label: (0, _i18n.__)('Open'),
|
|
28
|
+
description: (0, _i18n.__)('Visitors can add new comments and replies.')
|
|
29
|
+
}, {
|
|
30
|
+
value: 'closed',
|
|
31
|
+
label: (0, _i18n.__)('Closed'),
|
|
32
|
+
description: (0, _i18n.__)('Visitors cannot add new comments or replies. Existing comments remain visible.')
|
|
33
|
+
}]
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Comment status field for BasePost.
|
|
38
|
+
*/
|
|
39
|
+
var _default = exports.default = commentStatusField;
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","commentStatusField","id","label","__","type","Edit","enableSorting","filterBy","operators","elements","value","description","_default","exports","default"],"sources":["@wordpress/fields/src/fields/comment-status/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nconst commentStatusField: Field< BasePost > = {\n\tid: 'comment_status',\n\tlabel: __( 'Discussion' ),\n\ttype: 'text',\n\tEdit: 'radio',\n\tenableSorting: false,\n\tfilterBy: {\n\t\toperators: [],\n\t},\n\telements: [\n\t\t{\n\t\t\tvalue: 'open',\n\t\t\tlabel: __( 'Open' ),\n\t\t\tdescription: __( 'Visitors can add new comments and replies.' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'closed',\n\t\t\tlabel: __( 'Closed' ),\n\t\t\tdescription: __(\n\t\t\t\t'Visitors cannot add new comments or replies. Existing comments remain visible.'\n\t\t\t),\n\t\t},\n\t],\n};\n\n/**\n * Comment status field for BasePost.\n */\nexport default commentStatusField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMC,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,KAAK,EAAE,IAAAC,QAAE,EAAE,YAAa,CAAC;EACzBC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,OAAO;EACbC,aAAa,EAAE,KAAK;EACpBC,QAAQ,EAAE;IACTC,SAAS,EAAE;EACZ,CAAC;EACDC,QAAQ,EAAE,CACT;IACCC,KAAK,EAAE,MAAM;IACbR,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO,CAAC;IACnBQ,WAAW,EAAE,IAAAR,QAAE,EAAE,4CAA6C;EAC/D,CAAC,EACD;IACCO,KAAK,EAAE,QAAQ;IACfR,KAAK,EAAE,IAAAC,QAAE,EAAE,QAAS,CAAC;IACrBQ,WAAW,EAAE,IAAAR,QAAE,EACd,gFACD;EACD,CAAC;AAEH,CAAC;;AAED;AACA;AACA;AAFA,IAAAS,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGed,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _i18n = require("@wordpress/i18n");
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
var _date = require("@wordpress/date");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
/**
|
|
12
|
+
* WordPress dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const getFormattedDate = dateToDisplay => (0, _date.dateI18n)((0, _date.getSettings)().formats.datetimeAbbreviated, (0, _date.getDate)(dateToDisplay));
|
|
20
|
+
const DateView = ({
|
|
21
|
+
item
|
|
22
|
+
}) => {
|
|
23
|
+
var _item$status, _item$modified, _item$date4, _item$date5;
|
|
24
|
+
const isDraftOrPrivate = ['draft', 'private'].includes((_item$status = item.status) !== null && _item$status !== void 0 ? _item$status : '');
|
|
25
|
+
if (isDraftOrPrivate) {
|
|
26
|
+
var _item$date;
|
|
27
|
+
return (0, _element.createInterpolateElement)((0, _i18n.sprintf)(/* translators: %s: page creation or modification date. */
|
|
28
|
+
(0, _i18n.__)('<span>Modified: <time>%s</time></span>'), getFormattedDate((_item$date = item.date) !== null && _item$date !== void 0 ? _item$date : null)), {
|
|
29
|
+
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}),
|
|
30
|
+
time: /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const isScheduled = item.status === 'future';
|
|
34
|
+
if (isScheduled) {
|
|
35
|
+
var _item$date2;
|
|
36
|
+
return (0, _element.createInterpolateElement)((0, _i18n.sprintf)(/* translators: %s: page creation date */
|
|
37
|
+
(0, _i18n.__)('<span>Scheduled: <time>%s</time></span>'), getFormattedDate((_item$date2 = item.date) !== null && _item$date2 !== void 0 ? _item$date2 : null)), {
|
|
38
|
+
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}),
|
|
39
|
+
time: /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const isPublished = item.status === 'publish';
|
|
43
|
+
if (isPublished) {
|
|
44
|
+
var _item$date3;
|
|
45
|
+
return (0, _element.createInterpolateElement)((0, _i18n.sprintf)(/* translators: %s: page creation time */
|
|
46
|
+
(0, _i18n.__)('<span>Published: <time>%s</time></span>'), getFormattedDate((_item$date3 = item.date) !== null && _item$date3 !== void 0 ? _item$date3 : null)), {
|
|
47
|
+
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}),
|
|
48
|
+
time: /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Pending posts show the modified date if it's newer.
|
|
53
|
+
const dateToDisplay = (0, _date.getDate)((_item$modified = item.modified) !== null && _item$modified !== void 0 ? _item$modified : null) > (0, _date.getDate)((_item$date4 = item.date) !== null && _item$date4 !== void 0 ? _item$date4 : null) ? item.modified : item.date;
|
|
54
|
+
const isPending = item.status === 'pending';
|
|
55
|
+
if (isPending) {
|
|
56
|
+
return (0, _element.createInterpolateElement)((0, _i18n.sprintf)(/* translators: %s: page creation or modification date. */
|
|
57
|
+
(0, _i18n.__)('<span>Modified: <time>%s</time></span>'), getFormattedDate(dateToDisplay !== null && dateToDisplay !== void 0 ? dateToDisplay : null)), {
|
|
58
|
+
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}),
|
|
59
|
+
time: /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Unknow status.
|
|
64
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {
|
|
65
|
+
children: getFormattedDate((_item$date5 = item.date) !== null && _item$date5 !== void 0 ? _item$date5 : null)
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
var _default = exports.default = DateView;
|
|
69
|
+
//# sourceMappingURL=date-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_element","_date","_jsxRuntime","getFormattedDate","dateToDisplay","dateI18n","getSettings","formats","datetimeAbbreviated","getDate","DateView","item","_item$status","_item$modified","_item$date4","_item$date5","isDraftOrPrivate","includes","status","_item$date","createInterpolateElement","sprintf","__","date","span","jsx","time","isScheduled","_item$date2","isPublished","_item$date3","modified","isPending","children","_default","exports","default"],"sources":["@wordpress/fields/src/fields/date/date-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { dateI18n, getDate, getSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nconst getFormattedDate = ( dateToDisplay: string | null ) =>\n\tdateI18n(\n\t\tgetSettings().formats.datetimeAbbreviated,\n\t\tgetDate( dateToDisplay )\n\t);\n\nconst DateView = ( { item }: { item: BasePost } ) => {\n\tconst isDraftOrPrivate = [ 'draft', 'private' ].includes(\n\t\titem.status ?? ''\n\t);\n\tif ( isDraftOrPrivate ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: page creation or modification date. */\n\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\tgetFormattedDate( item.date ?? null )\n\t\t\t),\n\t\t\t{\n\t\t\t\tspan: <span />,\n\t\t\t\ttime: <time />,\n\t\t\t}\n\t\t);\n\t}\n\n\tconst isScheduled = item.status === 'future';\n\tif ( isScheduled ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: page creation date */\n\t\t\t\t__( '<span>Scheduled: <time>%s</time></span>' ),\n\t\t\t\tgetFormattedDate( item.date ?? null )\n\t\t\t),\n\t\t\t{\n\t\t\t\tspan: <span />,\n\t\t\t\ttime: <time />,\n\t\t\t}\n\t\t);\n\t}\n\n\tconst isPublished = item.status === 'publish';\n\tif ( isPublished ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: page creation time */\n\t\t\t\t__( '<span>Published: <time>%s</time></span>' ),\n\t\t\t\tgetFormattedDate( item.date ?? null )\n\t\t\t),\n\t\t\t{\n\t\t\t\tspan: <span />,\n\t\t\t\ttime: <time />,\n\t\t\t}\n\t\t);\n\t}\n\n\t// Pending posts show the modified date if it's newer.\n\tconst dateToDisplay =\n\t\tgetDate( item.modified ?? null ) > getDate( item.date ?? null )\n\t\t\t? item.modified\n\t\t\t: item.date;\n\n\tconst isPending = item.status === 'pending';\n\tif ( isPending ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: page creation or modification date. */\n\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\tgetFormattedDate( dateToDisplay ?? null )\n\t\t\t),\n\t\t\t{\n\t\t\t\tspan: <span />,\n\t\t\t\ttime: <time />,\n\t\t\t}\n\t\t);\n\t}\n\n\t// Unknow status.\n\treturn <time>{ getFormattedDate( item.date ?? null ) }</time>;\n};\n\nexport default DateView;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAAiE,IAAAG,WAAA,GAAAH,OAAA;AALjE;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAMI,gBAAgB,GAAKC,aAA4B,IACtD,IAAAC,cAAQ,EACP,IAAAC,iBAAW,EAAC,CAAC,CAACC,OAAO,CAACC,mBAAmB,EACzC,IAAAC,aAAO,EAAEL,aAAc,CACxB,CAAC;AAEF,MAAMM,QAAQ,GAAGA,CAAE;EAAEC;AAAyB,CAAC,KAAM;EAAA,IAAAC,YAAA,EAAAC,cAAA,EAAAC,WAAA,EAAAC,WAAA;EACpD,MAAMC,gBAAgB,GAAG,CAAE,OAAO,EAAE,SAAS,CAAE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MACCN,IAAI,eAAE,IAAAtB,WAAA,CAAAuB,GAAA,YAAO,CAAC;MACdC,IAAI,eAAE,IAAAxB,WAAA,CAAAuB,GAAA,YAAO;IACd,CACD,CAAC;EACF;;EAEA;EACA,MAAMrB,aAAa,GAClB,IAAAK,aAAO,GAAAI,cAAA,GAAEF,IAAI,CAACoB,QAAQ,cAAAlB,cAAA,cAAAA,cAAA,GAAI,IAAK,CAAC,GAAG,IAAAJ,aAAO,GAAAK,WAAA,GAAEH,IAAI,CAACY,IAAI,cAAAT,WAAA,cAAAA,WAAA,GAAI,IAAK,CAAC,GAC5DH,IAAI,CAACoB,QAAQ,GACbpB,IAAI,CAACY,IAAI;EAEb,MAAMS,SAAS,GAAGrB,IAAI,CAACO,MAAM,KAAK,SAAS;EAC3C,IAAKc,SAAS,EAAG;IAChB,OAAO,IAAAZ,iCAAwB,EAC9B,IAAAC,aAAO,EACN;IACA,IAAAC,QAAE,EAAE,wCAAyC,CAAC,EAC9CnB,gBAAgB,CAAEC,aAAa,aAAbA,aAAa,cAAbA,aAAa,GAAI,IAAK,CACzC,CAAC,EACD;MACCoB,IAAI,eAAE,IAAAtB,WAAA,CAAAuB,GAAA,YAAO,CAAC;MACdC,IAAI,eAAE,IAAAxB,WAAA,CAAAuB,GAAA,YAAO;IACd,CACD,CAAC;EACF;;EAEA;EACA,oBAAO,IAAAvB,WAAA,CAAAuB,GAAA;IAAAQ,QAAA,EAAQ9B,gBAAgB,EAAAY,WAAA,GAAEJ,IAAI,CAACY,IAAI,cAAAR,WAAA,cAAAA,WAAA,GAAI,IAAK;EAAC,CAAQ,CAAC;AAC9D,CAAC;AAAC,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa1B,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
var _dateView = _interopRequireDefault(require("./date-view"));
|
|
10
|
+
/**
|
|
11
|
+
* WordPress dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const dateField = {
|
|
19
|
+
id: 'date',
|
|
20
|
+
type: 'datetime',
|
|
21
|
+
label: (0, _i18n.__)('Date'),
|
|
22
|
+
render: _dateView.default
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Date field for BasePost.
|
|
27
|
+
*/
|
|
28
|
+
var _default = exports.default = dateField;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_dateView","_interopRequireDefault","dateField","id","type","label","__","render","DateView","_default","exports","default"],"sources":["@wordpress/fields/src/fields/date/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport DateView from './date-view';\n\nconst dateField: Field< BasePost > = {\n\tid: 'date',\n\ttype: 'datetime',\n\tlabel: __( 'Date' ),\n\trender: DateView,\n};\n\n/**\n * Date field for BasePost.\n */\nexport default dateField;\n"],"mappings":";;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA,MAAMG,SAA4B,GAAG;EACpCC,EAAE,EAAE,MAAM;EACVC,IAAI,EAAE,UAAU;EAChBC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO,CAAC;EACnBC,MAAM,EAAEC;AACT,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeT,SAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_data","_element","_mediaUtils","_icons","_coreData","_i18n","_jsxRuntime","FeaturedImageEdit","data","field","onChange","id","value","getValue","item","media","useSelect","select","getEntityRecord","coreStore","onChangeControl","useCallback","newValue","url","source_url","title","rendered","ref","useRef","jsx","className","children","MediaUpload","onSelect","selectedMedia","allowedTypes","render","open","role","tabIndex","onClick","onKeyDown","jsxs","__experimentalGrid","rowGap","columnGap","templateColumns","Fragment","alt","width","height","src","style","__","Button","size","icon","lineSolid","event","stopPropagation","exports"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\n// @ts-ignore\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\
|
|
1
|
+
{"version":3,"names":["_components","require","_data","_element","_mediaUtils","_icons","_coreData","_i18n","_jsxRuntime","FeaturedImageEdit","data","field","onChange","id","value","getValue","item","media","useSelect","select","getEntityRecord","coreStore","onChangeControl","useCallback","newValue","url","source_url","title","rendered","ref","useRef","jsx","className","children","MediaUpload","onSelect","selectedMedia","allowedTypes","render","open","role","tabIndex","onClick","onKeyDown","jsxs","__experimentalGrid","rowGap","columnGap","templateColumns","Fragment","alt","width","height","src","style","__","Button","size","icon","lineSolid","event","stopPropagation","exports"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\n// @ts-ignore\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'root', 'media', value );\n\t\t},\n\t\t[ value ]\n\t);\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\tconst url = media?.source_url;\n\tconst title = media?.title?.rendered;\n\tconst ref = useRef( null );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__featured-image\">\n\t\t\t<div className=\"fields-controls__featured-image-container\">\n\t\t\t\t<MediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: { id: number } ) => {\n\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t} }\n\t\t\t\t\tallowedTypes={ [ 'image' ] }\n\t\t\t\t\trender={ ( { open }: { open: () => void } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonKeyDown={ open }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr 24px\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\theight={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose an image…' ) }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-remove-button\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChangeControl( 0 );\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,KAAA,GAAAN,OAAA;AAAqC,IAAAO,WAAA,GAAAP,OAAA;AAXrC;AACA;AACA;;AAIA;;AAOA;AACA;AACA;;AAGO,MAAMQ,iBAAiB,GAAGA,CAAE;EAClCC,IAAI;EACJC,KAAK;EACLC;AACiC,CAAC,KAAM;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGF,KAAK;EAEpB,MAAMG,KAAK,GAAGH,KAAK,CAACI,QAAQ,CAAE;IAAEC,IAAI,EAAEN;EAAK,CAAE,CAAC;EAE9C,MAAMO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rB;gBAAG,CACH;cAAC,CACD,CACF;YAAA,CACI;UAAC,CACH,CAAC;QAER;MAAG,CACH;IAAC,CACE;EAAC,CACG,CAAC;AAEb,CAAC;AAACwC,OAAA,CAAArD,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_coreData","_jsxRuntime","FeaturedImageView","item","mediaId","featured_media","media","useSelect","select","getEntityRecord","coreStore","url","source_url","jsx","className","src","alt","exports"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\
|
|
1
|
+
{"version":3,"names":["_data","require","_coreData","_jsxRuntime","FeaturedImageView","item","mediaId","featured_media","media","useSelect","select","getEntityRecord","coreStore","url","source_url","jsx","className","src","alt","exports"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageView = ( {\n\titem,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst mediaId = item.featured_media;\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn mediaId ? getEntityRecord( 'root', 'media', mediaId ) : null;\n\t\t},\n\t\t[ mediaId ]\n\t);\n\tconst url = media?.source_url;\n\n\tif ( url ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\tsrc={ url }\n\t\t\t\talt=\"\"\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <span className=\"fields-controls__featured-image-placeholder\" />;\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAA0D,IAAAE,WAAA,GAAAF,OAAA;AAJ1D;AACA;AACA;;AAKA;AACA;AACA;;AAGO,MAAMG,iBAAiB,GAAGA,CAAE;EAClCC;AACqC,CAAC,KAAM;EAC5C,MAAMC,OAAO,GAAGD,IAAI,CAACE,cAAc;EAEnC,MAAMC,KAAK,GAAG,IAAAC,eAAS,EACpBC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IAC/C,OAAON,OAAO,GAAGK,eAAe,CAAE,MAAM,EAAE,OAAO,EAAEL,OAAQ,CAAC,GAAG,IAAI;EACpE,CAAC,EACD,CAAEA,OAAO,CACV,CAAC;EACD,MAAMO,GAAG,GAAGL,KAAK,EAAEM,UAAU;EAE7B,IAAKD,GAAG,EAAG;IACV,oBACC,IAAAV,WAAA,CAAAY,GAAA;MACCC,SAAS,EAAC,uCAAuC;MACjDC,GAAG,EAAGJ,GAAK;MACXK,GAAG,EAAC;IAAE,CACN,CAAC;EAEJ;EAEA,oBAAO,IAAAf,WAAA,CAAAY,GAAA;IAAMC,SAAS,EAAC;EAA6C,CAAE,CAAC;AACxE,CAAC;AAACG,OAAA,CAAAf,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -19,9 +19,6 @@ const featuredImageField = {
|
|
|
19
19
|
id: 'featured_media',
|
|
20
20
|
type: 'text',
|
|
21
21
|
label: (0, _i18n.__)('Featured Image'),
|
|
22
|
-
getValue: ({
|
|
23
|
-
item
|
|
24
|
-
}) => item.featured_media,
|
|
25
22
|
Edit: _featuredImageEdit.FeaturedImageEdit,
|
|
26
23
|
render: _featuredImageView.FeaturedImageView,
|
|
27
24
|
enableSorting: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_featuredImageEdit","_featuredImageView","featuredImageField","id","type","label","__","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_featuredImageEdit","_featuredImageView","featuredImageField","id","type","label","__","Edit","FeaturedImageEdit","render","FeaturedImageView","enableSorting","_default","exports","default"],"sources":["@wordpress/fields/src/fields/featured-image/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { FeaturedImageEdit } from './featured-image-edit';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePost > = {\n\tid: 'featured_media',\n\ttype: 'text',\n\tlabel: __( 'Featured Image' ),\n\tEdit: FeaturedImageEdit,\n\trender: FeaturedImageView,\n\tenableSorting: false,\n};\n\nexport default featuredImageField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMG,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,gBAAiB,CAAC;EAC7BC,IAAI,EAAEC,oCAAiB;EACvBC,MAAM,EAAEC,oCAAiB;EACzBC,aAAa,EAAE;AAChB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaZ,kBAAkB","ignoreList":[]}
|
package/build/fields/index.js
CHANGED
|
@@ -4,6 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "commentStatusField", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _commentStatus.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "dateField", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _date.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
7
19
|
Object.defineProperty(exports, "featuredImageField", {
|
|
8
20
|
enumerable: true,
|
|
9
21
|
get: function () {
|
|
@@ -22,12 +34,24 @@ Object.defineProperty(exports, "parentField", {
|
|
|
22
34
|
return _parent.default;
|
|
23
35
|
}
|
|
24
36
|
});
|
|
37
|
+
Object.defineProperty(exports, "passwordField", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _password.default;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
25
43
|
Object.defineProperty(exports, "slugField", {
|
|
26
44
|
enumerable: true,
|
|
27
45
|
get: function () {
|
|
28
46
|
return _slug.default;
|
|
29
47
|
}
|
|
30
48
|
});
|
|
49
|
+
Object.defineProperty(exports, "statusField", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return _status.default;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
31
55
|
Object.defineProperty(exports, "titleField", {
|
|
32
56
|
enumerable: true,
|
|
33
57
|
get: function () {
|
|
@@ -39,4 +63,8 @@ var _title = _interopRequireDefault(require("./title"));
|
|
|
39
63
|
var _order = _interopRequireDefault(require("./order"));
|
|
40
64
|
var _featuredImage = _interopRequireDefault(require("./featured-image"));
|
|
41
65
|
var _parent = _interopRequireDefault(require("./parent"));
|
|
66
|
+
var _password = _interopRequireDefault(require("./password"));
|
|
67
|
+
var _status = _interopRequireDefault(require("./status"));
|
|
68
|
+
var _commentStatus = _interopRequireDefault(require("./comment-status"));
|
|
69
|
+
var _date = _interopRequireDefault(require("./date"));
|
|
42
70
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_slug","_interopRequireDefault","require","_title","_order","_featuredImage","_parent"],"sources":["@wordpress/fields/src/fields/index.ts"],"sourcesContent":["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as parentField } from './parent';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_slug","_interopRequireDefault","require","_title","_order","_featuredImage","_parent","_password","_status","_commentStatus","_date"],"sources":["@wordpress/fields/src/fields/index.ts"],"sourcesContent":["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as parentField } from './parent';\nexport { default as passwordField } from './password';\nexport { default as statusField } from './status';\nexport { default as commentStatusField } from './comment-status';\nexport { default as dateField } from './date';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,cAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,KAAA,GAAAT,sBAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","orderField","
|
|
1
|
+
{"version":3,"names":["_i18n","require","orderField","id","type","label","__","description","_default","exports","default"],"sources":["@wordpress/fields/src/fields/order/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nconst orderField: Field< BasePost > = {\n\tid: 'menu_order',\n\ttype: 'integer',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n};\n\nexport default orderField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,WAAW,EAAE,IAAAD,QAAE,EAAE,gCAAiC;AACnD,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaR,UAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_parentEdit","_parentView","parentField","id","type","label","__","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_parentEdit","_parentView","parentField","id","type","label","__","Edit","ParentEdit","render","ParentView","enableSorting","_default","exports","default"],"sources":["@wordpress/fields/src/fields/parent/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { ParentEdit } from './parent-edit';\nimport { ParentView } from './parent-view';\n\nconst parentField: Field< BasePost > = {\n\tid: 'parent',\n\ttype: 'text',\n\tlabel: __( 'Parent' ),\n\tEdit: ParentEdit,\n\trender: ParentView,\n\tenableSorting: true,\n};\n\n/**\n * This field is used to display the post parent.\n */\nexport default parentField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMG,WAA8B,GAAG;EACtCC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,QAAS,CAAC;EACrBC,IAAI,EAAEC,sBAAU;EAChBC,MAAM,EAAEC,sBAAU;EAClBC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeZ,WAAW","ignoreList":[]}
|
|
@@ -6,27 +6,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.PageAttributesParent = PageAttributesParent;
|
|
8
8
|
exports.getItemPriority = exports.ParentEdit = void 0;
|
|
9
|
+
var _removeAccents = _interopRequireDefault(require("remove-accents"));
|
|
9
10
|
var _components = require("@wordpress/components");
|
|
10
11
|
var _data = require("@wordpress/data");
|
|
11
12
|
var _element = require("@wordpress/element");
|
|
12
13
|
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
var _removeAccents = _interopRequireDefault(require("remove-accents"));
|
|
14
14
|
var _compose = require("@wordpress/compose");
|
|
15
15
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
16
16
|
var _i18n = require("@wordpress/i18n");
|
|
17
|
-
var _utils = require("./utils");
|
|
18
17
|
var _url = require("@wordpress/url");
|
|
18
|
+
var _utils = require("./utils");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* External dependencies
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
25
|
+
* WordPress dependencies
|
|
28
26
|
*/
|
|
29
27
|
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
|
|
30
30
|
/**
|
|
31
31
|
* Internal dependencies
|
|
32
32
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_data","_element","_coreData","_removeAccents","_interopRequireDefault","_compose","_htmlEntities","_i18n","_utils","_url","_jsxRuntime","buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","some","parent","undefined","termsByParent","reduce","acc","push","fillWithChildren","terms","id","length","getItemPriority","name","searchValue","normalizedName","removeAccents","toLowerCase","normalizedSearch","startsWith","Infinity","exports","PageAttributesParent","data","onChangeControl","fieldValue","setFieldValue","useState","pageId","postId","postTypeSlug","type","parentPostTitle","pageItems","isHierarchical","useSelect","select","getEntityRecord","getEntityRecords","getPostType","coreStore","postTypeInfo","postIsHierarchical","hierarchical","viewable","parentPost","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","getTitleWithFallbackName","parentOptions","useMemo","getOptionsFromTree","tree","level","mappedNodes","treeNode","value","label","repeat","decodeEntities","rawName","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","_item$parent","opts","optsHasParent","find","unshift","option","toString","handleKeydown","inputValue","handleChange","selectedPostId","_parseInt","parseInt","jsx","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","__","help","options","onFilterValueChange","debounce","onChange","hideLabelFromVision","ParentEdit","field","homeUrl","home","useCallback","newValue","className","jsxs","createInterpolateElement","sprintf","filterURLForDisplay","replace","wbr","ExternalLink","href"],"sources":["@wordpress/fields/src/fields/parent/parent-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ComboboxControl, ExternalLink } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateInterpolateElement,\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n// @ts-ignore\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Internal dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\nimport { filterURLForDisplay } from '@wordpress/url';\n\ntype TreeBase = {\n\tid: number;\n\tname: string;\n\t[ key: string ]: any;\n};\n\ntype TreeWithParent = TreeBase & {\n\tparent: number;\n};\n\ntype TreeWithoutParent = TreeBase & {\n\tparent: null;\n};\n\ntype Tree = TreeWithParent | TreeWithoutParent;\n\nfunction buildTermsTree( flatTerms: Tree[] ) {\n\tconst flatTermsWithParentAndChildren = flatTerms.map( ( term ) => {\n\t\treturn {\n\t\t\tchildren: [],\n\t\t\t...term,\n\t\t};\n\t} );\n\n\t// All terms should have a `parent` because we're about to index them by it.\n\tif (\n\t\tflatTermsWithParentAndChildren.some(\n\t\t\t( { parent } ) => parent === null || parent === undefined\n\t\t)\n\t) {\n\t\treturn flatTermsWithParentAndChildren as TreeWithParent[];\n\t}\n\n\tconst termsByParent = (\n\t\tflatTermsWithParentAndChildren as TreeWithParent[]\n\t ).reduce(\n\t\t( acc, term ) => {\n\t\t\tconst { parent } = term;\n\t\t\tif ( ! acc[ parent ] ) {\n\t\t\t\tacc[ parent ] = [];\n\t\t\t}\n\t\t\tacc[ parent ].push( term );\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record< string, Array< TreeWithParent > >\n\t);\n\n\tconst fillWithChildren = (\n\t\tterms: Array< TreeWithParent >\n\t): Array< TreeWithParent > => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n\nexport const getItemPriority = ( name: string, searchValue: string ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent( {\n\tdata,\n\tonChangeControl,\n}: {\n\tdata: BasePost;\n\tonChangeControl: ( newValue: number ) => void;\n} ) {\n\tconst [ fieldValue, setFieldValue ] = useState< null | string >( null );\n\n\tconst pageId = data.parent;\n\tconst postId = data.id;\n\tconst postTypeSlug = data.type;\n\n\tconst { parentPostTitle, pageItems, isHierarchical } = useSelect(\n\t\t( select ) => {\n\t\t\t// @ts-expect-error getPostType is not typed\n\t\t\tconst { getEntityRecord, getEntityRecords, getPostType } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postTypeInfo = getPostType( postTypeSlug );\n\n\t\t\tconst postIsHierarchical =\n\t\t\t\tpostTypeInfo?.hierarchical && postTypeInfo.viewable;\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord< BasePost >(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\tpageId\n\t\t\t\t )\n\t\t\t\t: null;\n\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t...( fieldValue !== null && {\n\t\t\t\t\tsearch: fieldValue,\n\t\t\t\t} ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostTitle: parentPost\n\t\t\t\t\t? getTitleWithFallbackName( parentPost )\n\t\t\t\t\t: '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords< BasePost >(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue, pageId, postId, postTypeSlug ]\n\t);\n\n\t/**\n\t * This logic has been copied from https://github.com/WordPress/gutenberg/blob/0249771b519d5646171fb9fae422006c8ab773f2/packages/editor/src/components/page-attributes/parent.js#L106.\n\t */\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = (\n\t\t\ttree: Array< Tree >,\n\t\t\tlevel = 0\n\t\t): Array< {\n\t\t\tvalue: number;\n\t\t\tlabel: string;\n\t\t\trawName: string;\n\t\t} > => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority(\n\t\t\t\t\ta.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\tconst priorityB = getItemPriority(\n\t\t\t\t\tb.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id as number,\n\t\t\tparent: item.parent ?? null,\n\t\t\tname: getTitleWithFallbackName( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find( ( item ) => item.value === pageId );\n\t\tif ( pageId && parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: pageId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t\trawName: '',\n\t\t\t} );\n\t\t}\n\t\treturn opts.map( ( option ) => ( {\n\t\t\t...option,\n\t\t\tvalue: option.value.toString(),\n\t\t} ) );\n\t}, [ pageItems, fieldValue, parentPostTitle, pageId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue: string ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId: string | null | undefined ) => {\n\t\tif ( selectedPostId ) {\n\t\t\treturn onChangeControl( parseInt( selectedPostId, 10 ) ?? 0 );\n\t\t}\n\n\t\tonChangeControl( 0 );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ pageId?.toString() }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce(\n\t\t\t\t( value: unknown ) => handleKeydown( value as string ),\n\t\t\t\t300\n\t\t\t) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n\nexport const ParentEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.\n\t\treturn select( coreStore ).getEntityRecord< {\n\t\t\thome: string;\n\t\t} >( 'root', '__unstableBase' )?.home as string;\n\t}, [] );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue?: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__parent\">\n\t\t\t<div>\n\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %1$s The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %1$s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t<p>\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tchildren={ undefined }\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) }\n\t\t\t\t</p>\n\t\t\t\t<PageAttributesParent\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tonChangeControl={ onChangeControl }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAA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ACC,CAAC,eACJ,IAAAT,WAAA,CAAA8F,GAAA,EAAClE,oBAAoB;QACpBC,IAAI,EAAGA,IAAM;QACbC,eAAe,EAAGA;MAAiB,CACnC,CAAC;IAAA,CACE;EAAC,CACG,CAAC;AAEb,CAAC;AAACH,OAAA,CAAA8E,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_removeAccents","_interopRequireDefault","require","_components","_data","_element","_coreData","_compose","_htmlEntities","_i18n","_url","_utils","_jsxRuntime","buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","some","parent","undefined","termsByParent","reduce","acc","push","fillWithChildren","terms","id","length","getItemPriority","name","searchValue","normalizedName","removeAccents","toLowerCase","normalizedSearch","startsWith","Infinity","exports","PageAttributesParent","data","onChangeControl","fieldValue","setFieldValue","useState","pageId","postId","postTypeSlug","type","parentPostTitle","pageItems","isHierarchical","useSelect","select","getEntityRecord","getEntityRecords","getPostType","coreStore","postTypeInfo","postIsHierarchical","hierarchical","viewable","parentPost","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","getTitleWithFallbackName","parentOptions","useMemo","getOptionsFromTree","tree","level","mappedNodes","treeNode","value","label","repeat","decodeEntities","rawName","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","_item$parent","opts","optsHasParent","find","unshift","option","toString","handleKeydown","inputValue","handleChange","selectedPostId","_parseInt","parseInt","jsx","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","__","help","options","onFilterValueChange","debounce","onChange","hideLabelFromVision","ParentEdit","field","homeUrl","home","useCallback","newValue","className","jsxs","createInterpolateElement","sprintf","filterURLForDisplay","replace","wbr","ExternalLink","href"],"sources":["@wordpress/fields/src/fields/parent/parent-edit.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { ComboboxControl, ExternalLink } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateInterpolateElement,\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n// @ts-ignore\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { debounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\n\ntype TreeBase = {\n\tid: number;\n\tname: string;\n\t[ key: string ]: any;\n};\n\ntype TreeWithParent = TreeBase & {\n\tparent: number;\n};\n\ntype TreeWithoutParent = TreeBase & {\n\tparent: null;\n};\n\ntype Tree = TreeWithParent | TreeWithoutParent;\n\nfunction buildTermsTree( flatTerms: Tree[] ) {\n\tconst flatTermsWithParentAndChildren = flatTerms.map( ( term ) => {\n\t\treturn {\n\t\t\tchildren: [],\n\t\t\t...term,\n\t\t};\n\t} );\n\n\t// All terms should have a `parent` because we're about to index them by it.\n\tif (\n\t\tflatTermsWithParentAndChildren.some(\n\t\t\t( { parent } ) => parent === null || parent === undefined\n\t\t)\n\t) {\n\t\treturn flatTermsWithParentAndChildren as TreeWithParent[];\n\t}\n\n\tconst termsByParent = (\n\t\tflatTermsWithParentAndChildren as TreeWithParent[]\n\t ).reduce(\n\t\t( acc, term ) => {\n\t\t\tconst { parent } = term;\n\t\t\tif ( ! acc[ parent ] ) {\n\t\t\t\tacc[ parent ] = [];\n\t\t\t}\n\t\t\tacc[ parent ].push( term );\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record< string, Array< TreeWithParent > >\n\t);\n\n\tconst fillWithChildren = (\n\t\tterms: Array< TreeWithParent >\n\t): Array< TreeWithParent > => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n\nexport const getItemPriority = ( name: string, searchValue: string ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent( {\n\tdata,\n\tonChangeControl,\n}: {\n\tdata: BasePost;\n\tonChangeControl: ( newValue: number ) => void;\n} ) {\n\tconst [ fieldValue, setFieldValue ] = useState< null | string >( null );\n\n\tconst pageId = data.parent;\n\tconst postId = data.id;\n\tconst postTypeSlug = data.type;\n\n\tconst { parentPostTitle, pageItems, isHierarchical } = useSelect(\n\t\t( select ) => {\n\t\t\t// @ts-expect-error getPostType is not typed\n\t\t\tconst { getEntityRecord, getEntityRecords, getPostType } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postTypeInfo = getPostType( postTypeSlug );\n\n\t\t\tconst postIsHierarchical =\n\t\t\t\tpostTypeInfo?.hierarchical && postTypeInfo.viewable;\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord< BasePost >(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\tpageId\n\t\t\t\t )\n\t\t\t\t: null;\n\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t...( fieldValue !== null && {\n\t\t\t\t\tsearch: fieldValue,\n\t\t\t\t} ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostTitle: parentPost\n\t\t\t\t\t? getTitleWithFallbackName( parentPost )\n\t\t\t\t\t: '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords< BasePost >(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue, pageId, postId, postTypeSlug ]\n\t);\n\n\t/**\n\t * This logic has been copied from https://github.com/WordPress/gutenberg/blob/0249771b519d5646171fb9fae422006c8ab773f2/packages/editor/src/components/page-attributes/parent.js#L106.\n\t */\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = (\n\t\t\ttree: Array< Tree >,\n\t\t\tlevel = 0\n\t\t): Array< {\n\t\t\tvalue: number;\n\t\t\tlabel: string;\n\t\t\trawName: string;\n\t\t} > => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority(\n\t\t\t\t\ta.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\tconst priorityB = getItemPriority(\n\t\t\t\t\tb.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id as number,\n\t\t\tparent: item.parent ?? null,\n\t\t\tname: getTitleWithFallbackName( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find( ( item ) => item.value === pageId );\n\t\tif ( pageId && parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: pageId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t\trawName: '',\n\t\t\t} );\n\t\t}\n\t\treturn opts.map( ( option ) => ( {\n\t\t\t...option,\n\t\t\tvalue: option.value.toString(),\n\t\t} ) );\n\t}, [ pageItems, fieldValue, parentPostTitle, pageId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue: string ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId: string | null | undefined ) => {\n\t\tif ( selectedPostId ) {\n\t\t\treturn onChangeControl( parseInt( selectedPostId, 10 ) ?? 0 );\n\t\t}\n\n\t\tonChangeControl( 0 );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ pageId?.toString() }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce(\n\t\t\t\t( value: unknown ) => handleKeydown( value as string ),\n\t\t\t\t300\n\t\t\t) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n\nexport const ParentEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.\n\t\treturn select( coreStore ).getEntityRecord< {\n\t\t\thome: string;\n\t\t} >( 'root', '__unstableBase' )?.home as string;\n\t}, [] );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue?: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__parent\">\n\t\t\t<div>\n\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %1$s The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %1$s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t<p>\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t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F,GAAA,WAAM;MACZ,CACD,CAAC,eACD,IAAA9F,WAAA,CAAA8F,GAAA;QAAAxF,QAAA,EACG,IAAA2G,iCAAwB,EACzB,IAAAf,QAAE,EACD,mFACD,CAAC,EACD;UACCvB,CAAC,eACA,IAAA3E,WAAA,CAAA8F,GAAA,EAACvG,WAAA,CAAA+H,YAAY;YACZC,IAAI,EAAG,IAAArB,QAAE,EACR,yFACD,CAAG;YACH5F,QAAQ,EAAGG;UAAW,CACtB;QAEH,CACD;MAAC,CACC,CAAC,eACJ,IAAAT,WAAA,CAAA8F,GAAA,EAAClE,oBAAoB;QACpBC,IAAI,EAAGA,IAAM;QACbC,eAAe,EAAGA;MAAiB,CACnC,CAAC;IAAA,CACE;EAAC,CACG,CAAC;AAEb,CAAC;AAACH,OAAA,CAAA8E,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.ParentView = void 0;
|
|
7
7
|
var _data = require("@wordpress/data");
|
|
8
8
|
var _coreData = require("@wordpress/core-data");
|
|
9
|
-
var _utils = require("./utils");
|
|
10
9
|
var _i18n = require("@wordpress/i18n");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
/**
|
|
13
13
|
* WordPress dependencies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_coreData","
|
|
1
|
+
{"version":3,"names":["_data","require","_coreData","_i18n","_utils","_jsxRuntime","ParentView","item","parent","useSelect","select","getEntityRecord","coreStore","type","jsx","Fragment","children","getTitleWithFallbackName","__","exports"],"sources":["@wordpress/fields/src/fields/parent/parent-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\n\nexport const ParentView = ( {\n\titem,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst parent = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn item?.parent\n\t\t\t\t? getEntityRecord( 'postType', item.type, item.parent )\n\t\t\t\t: null;\n\t\t},\n\t\t[ item.parent, item.type ]\n\t);\n\n\tif ( parent ) {\n\t\treturn <>{ getTitleWithFallbackName( parent ) }</>;\n\t}\n\n\treturn <>{ __( 'None' ) }</>;\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAMA,IAAAG,MAAA,GAAAH,OAAA;AAAmD,IAAAI,WAAA,GAAAJ,OAAA;AAZnD;AACA;AACA;;AAMA;AACA;AACA;;AAIO,MAAMK,UAAU,GAAGA,CAAE;EAC3BC;AACqC,CAAC,KAAM;EAC5C,MAAMC,MAAM,GAAG,IAAAC,eAAS,EACrBC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IAC/C,OAAOL,IAAI,EAAEC,MAAM,GAChBG,eAAe,CAAE,UAAU,EAAEJ,IAAI,CAACM,IAAI,EAAEN,IAAI,CAACC,MAAO,CAAC,GACrD,IAAI;EACR,CAAC,EACD,CAAED,IAAI,CAACC,MAAM,EAAED,IAAI,CAACM,IAAI,CACzB,CAAC;EAED,IAAKL,MAAM,EAAG;IACb,oBAAO,IAAAH,WAAA,CAAAS,GAAA,EAAAT,WAAA,CAAAU,QAAA;MAAAC,QAAA,EAAI,IAAAC,+BAAwB,EAAET,MAAO;IAAC,CAAI,CAAC;EACnD;EAEA,oBAAO,IAAAH,WAAA,CAAAS,GAAA,EAAAT,WAAA,CAAAU,QAAA;IAAAC,QAAA,EAAI,IAAAE,QAAE,EAAE,MAAO;EAAC,CAAI,CAAC;AAC7B,CAAC;AAACC,OAAA,CAAAb,UAAA,GAAAA,UAAA","ignoreList":[]}
|