@wordpress/fields 0.5.1-next.cd6172eb0.0 → 0.6.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 +32 -36
- package/build/actions/delete-post.js +5 -0
- package/build/actions/delete-post.js.map +1 -1
- package/build/actions/duplicate-pattern.js +4 -0
- package/build/actions/duplicate-pattern.js.map +1 -1
- package/build/actions/duplicate-post.js +8 -3
- package/build/actions/duplicate-post.js.map +1 -1
- package/build/actions/duplicate-template-part.js +3 -0
- package/build/actions/duplicate-template-part.js.map +1 -1
- package/build/actions/export-pattern.js +5 -0
- package/build/actions/export-pattern.js.map +1 -1
- package/build/actions/index.js +0 -21
- package/build/actions/index.js.map +1 -1
- package/build/actions/permanently-delete-post.js +5 -0
- package/build/actions/permanently-delete-post.js.map +1 -1
- package/build/actions/rename-post.js +4 -0
- package/build/actions/rename-post.js.map +1 -1
- package/build/actions/reorder-page.js +4 -0
- package/build/actions/reorder-page.js.map +1 -1
- package/build/actions/reset-post.js +4 -0
- package/build/actions/reset-post.js.map +1 -1
- package/build/actions/restore-post.js +5 -0
- package/build/actions/restore-post.js.map +1 -1
- package/build/actions/trash-post.js +5 -0
- package/build/actions/trash-post.js.map +1 -1
- package/build/actions/view-post-revisions.js +4 -0
- package/build/actions/view-post-revisions.js.map +1 -1
- package/build/actions/view-post.js +4 -0
- package/build/actions/view-post.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +32 -41
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/create-template-part-modal/utils.js +1 -0
- package/build/components/create-template-part-modal/utils.js.map +1 -1
- package/build/fields/featured-image/index.js +4 -0
- package/build/fields/featured-image/index.js.map +1 -1
- package/build/fields/index.js +21 -0
- package/build/fields/index.js.map +1 -1
- package/build/fields/order/index.js +4 -0
- package/build/fields/order/index.js.map +1 -1
- package/build/fields/page-title/index.js +36 -0
- package/build/fields/page-title/index.js.map +1 -0
- package/build/fields/page-title/view.js +45 -0
- package/build/fields/page-title/view.js.map +1 -0
- package/build/fields/parent/index.js +1 -1
- package/build/fields/parent/index.js.map +1 -1
- package/build/fields/parent/parent-edit.js +1 -0
- package/build/fields/parent/parent-edit.js.map +1 -1
- package/build/fields/password/index.js +1 -1
- package/build/fields/password/index.js.map +1 -1
- package/build/fields/pattern-title/index.js +36 -0
- package/build/fields/pattern-title/index.js.map +1 -0
- package/build/fields/pattern-title/view.js +45 -0
- package/build/fields/pattern-title/view.js.map +1 -0
- package/build/fields/slug/index.js +4 -0
- package/build/fields/slug/index.js.map +1 -1
- package/build/fields/status/status-view.js +1 -0
- package/build/fields/status/status-view.js.map +1 -1
- package/build/fields/template/index.js +4 -3
- package/build/fields/template/index.js.map +1 -1
- package/build/fields/template/template-edit.js +1 -0
- package/build/fields/template/template-edit.js.map +1 -1
- package/build/fields/template-title/index.js +36 -0
- package/build/fields/template-title/index.js.map +1 -0
- package/build/fields/title/index.js +10 -3
- package/build/fields/title/index.js.map +1 -1
- package/build/fields/title/view.js +48 -0
- package/build/fields/title/view.js.map +1 -0
- package/build/index.native.js +0 -26
- package/build/index.native.js.map +1 -1
- package/build/mutation/index.js +1 -0
- package/build/mutation/index.js.map +1 -1
- package/build-module/actions/delete-post.js +5 -0
- package/build-module/actions/delete-post.js.map +1 -1
- package/build-module/actions/duplicate-pattern.js +4 -0
- package/build-module/actions/duplicate-pattern.js.map +1 -1
- package/build-module/actions/duplicate-post.js +8 -3
- package/build-module/actions/duplicate-post.js.map +1 -1
- package/build-module/actions/duplicate-template-part.js +3 -0
- package/build-module/actions/duplicate-template-part.js.map +1 -1
- package/build-module/actions/export-pattern.js +5 -0
- package/build-module/actions/export-pattern.js.map +1 -1
- package/build-module/actions/index.js +0 -3
- package/build-module/actions/index.js.map +1 -1
- package/build-module/actions/permanently-delete-post.js +5 -0
- package/build-module/actions/permanently-delete-post.js.map +1 -1
- package/build-module/actions/rename-post.js +4 -0
- package/build-module/actions/rename-post.js.map +1 -1
- package/build-module/actions/reorder-page.js +4 -0
- package/build-module/actions/reorder-page.js.map +1 -1
- package/build-module/actions/reset-post.js +4 -0
- package/build-module/actions/reset-post.js.map +1 -1
- package/build-module/actions/restore-post.js +5 -0
- package/build-module/actions/restore-post.js.map +1 -1
- package/build-module/actions/trash-post.js +5 -0
- package/build-module/actions/trash-post.js.map +1 -1
- package/build-module/actions/view-post-revisions.js +4 -0
- package/build-module/actions/view-post-revisions.js.map +1 -1
- package/build-module/actions/view-post.js +4 -0
- package/build-module/actions/view-post.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +32 -41
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/utils.js +1 -0
- package/build-module/components/create-template-part-modal/utils.js.map +1 -1
- package/build-module/fields/featured-image/index.js +4 -0
- package/build-module/fields/featured-image/index.js.map +1 -1
- package/build-module/fields/index.js +3 -0
- package/build-module/fields/index.js.map +1 -1
- package/build-module/fields/order/index.js +4 -0
- package/build-module/fields/order/index.js.map +1 -1
- package/build-module/fields/page-title/index.js +30 -0
- package/build-module/fields/page-title/index.js.map +1 -0
- package/build-module/fields/page-title/view.js +39 -0
- package/build-module/fields/page-title/view.js.map +1 -0
- package/build-module/fields/parent/index.js +1 -1
- package/build-module/fields/parent/index.js.map +1 -1
- package/build-module/fields/parent/parent-edit.js +1 -0
- package/build-module/fields/parent/parent-edit.js.map +1 -1
- package/build-module/fields/password/index.js +1 -1
- package/build-module/fields/password/index.js.map +1 -1
- package/build-module/fields/pattern-title/index.js +30 -0
- package/build-module/fields/pattern-title/index.js.map +1 -0
- package/build-module/fields/pattern-title/view.js +36 -0
- package/build-module/fields/pattern-title/view.js.map +1 -0
- package/build-module/fields/slug/index.js +4 -0
- package/build-module/fields/slug/index.js.map +1 -1
- package/build-module/fields/status/status-view.js +1 -0
- package/build-module/fields/status/status-view.js.map +1 -1
- package/build-module/fields/template/index.js +4 -3
- package/build-module/fields/template/index.js.map +1 -1
- package/build-module/fields/template/template-edit.js +1 -0
- package/build-module/fields/template/template-edit.js.map +1 -1
- package/build-module/fields/template-title/index.js +30 -0
- package/build-module/fields/template-title/index.js.map +1 -0
- package/build-module/fields/title/index.js +9 -2
- package/build-module/fields/title/index.js.map +1 -1
- package/build-module/fields/title/view.js +39 -0
- package/build-module/fields/title/view.js.map +1 -0
- package/build-module/index.native.js +1 -2
- package/build-module/index.native.js.map +1 -1
- package/build-module/mutation/index.js +1 -0
- package/build-module/mutation/index.js.map +1 -1
- package/build-style/style-rtl.css +24 -0
- package/build-style/style.css +24 -0
- package/build-types/actions/delete-post.d.ts +3 -0
- package/build-types/actions/delete-post.d.ts.map +1 -1
- package/build-types/actions/duplicate-pattern.d.ts +3 -0
- package/build-types/actions/duplicate-pattern.d.ts.map +1 -1
- package/build-types/actions/duplicate-post.d.ts +3 -0
- package/build-types/actions/duplicate-post.d.ts.map +1 -1
- package/build-types/actions/duplicate-template-part.d.ts +3 -0
- package/build-types/actions/duplicate-template-part.d.ts.map +1 -1
- package/build-types/actions/export-pattern.d.ts +3 -0
- package/build-types/actions/export-pattern.d.ts.map +1 -1
- package/build-types/actions/index.d.ts +0 -3
- package/build-types/actions/index.d.ts.map +1 -1
- package/build-types/actions/permanently-delete-post.d.ts +3 -0
- package/build-types/actions/permanently-delete-post.d.ts.map +1 -1
- package/build-types/actions/rename-post.d.ts +3 -0
- package/build-types/actions/rename-post.d.ts.map +1 -1
- package/build-types/actions/reorder-page.d.ts +3 -0
- package/build-types/actions/reorder-page.d.ts.map +1 -1
- package/build-types/actions/reset-post.d.ts +3 -0
- package/build-types/actions/reset-post.d.ts.map +1 -1
- package/build-types/actions/restore-post.d.ts +3 -0
- package/build-types/actions/restore-post.d.ts.map +1 -1
- package/build-types/actions/trash-post.d.ts +3 -0
- package/build-types/actions/trash-post.d.ts.map +1 -1
- package/build-types/actions/view-post-revisions.d.ts +3 -0
- package/build-types/actions/view-post-revisions.d.ts.map +1 -1
- package/build-types/actions/view-post.d.ts +3 -0
- package/build-types/actions/view-post.d.ts.map +1 -1
- package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
- package/build-types/fields/featured-image/index.d.ts +3 -0
- package/build-types/fields/featured-image/index.d.ts.map +1 -1
- package/build-types/fields/index.d.ts +3 -0
- package/build-types/fields/index.d.ts.map +1 -1
- package/build-types/fields/order/index.d.ts +3 -0
- package/build-types/fields/order/index.d.ts.map +1 -1
- package/build-types/fields/page-title/index.d.ts +14 -0
- package/build-types/fields/page-title/index.d.ts.map +1 -0
- package/build-types/fields/page-title/view.d.ts +8 -0
- package/build-types/fields/page-title/view.d.ts.map +1 -0
- package/build-types/fields/parent/index.d.ts +1 -1
- package/build-types/fields/password/index.d.ts +1 -1
- package/build-types/fields/pattern-title/index.d.ts +14 -0
- package/build-types/fields/pattern-title/index.d.ts.map +1 -0
- package/build-types/fields/pattern-title/view.d.ts +9 -0
- package/build-types/fields/pattern-title/view.d.ts.map +1 -0
- package/build-types/fields/slug/index.d.ts +3 -0
- package/build-types/fields/slug/index.d.ts.map +1 -1
- package/build-types/fields/template/index.d.ts +3 -0
- package/build-types/fields/template/index.d.ts.map +1 -1
- package/build-types/fields/template-title/index.d.ts +14 -0
- package/build-types/fields/template-title/index.d.ts.map +1 -0
- package/build-types/fields/title/index.d.ts +7 -2
- package/build-types/fields/title/index.d.ts.map +1 -1
- package/build-types/fields/title/view.d.ts +14 -0
- package/build-types/fields/title/view.d.ts.map +1 -0
- package/build-types/index.native.d.ts +0 -2
- package/build-types/index.native.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/actions/delete-post.tsx +3 -0
- package/src/actions/duplicate-pattern.tsx +3 -0
- package/src/actions/duplicate-post.tsx +6 -3
- package/src/actions/duplicate-template-part.tsx +3 -1
- package/src/actions/export-pattern.tsx +3 -0
- package/src/actions/index.ts +0 -3
- package/src/actions/permanently-delete-post.tsx +3 -0
- package/src/actions/rename-post.tsx +3 -0
- package/src/actions/reorder-page.tsx +3 -0
- package/src/actions/reset-post.tsx +3 -0
- package/src/actions/restore-post.tsx +3 -0
- package/src/actions/trash-post.tsx +3 -0
- package/src/actions/view-post-revisions.tsx +3 -0
- package/src/actions/view-post.tsx +3 -0
- package/src/components/create-template-part-modal/index.tsx +25 -26
- package/src/fields/featured-image/index.ts +3 -0
- package/src/fields/index.ts +3 -0
- package/src/fields/order/index.ts +3 -0
- package/src/fields/page-title/index.ts +28 -0
- package/src/fields/page-title/style.scss +10 -0
- package/src/fields/page-title/view.tsx +38 -0
- package/src/fields/parent/index.ts +1 -1
- package/src/fields/password/index.tsx +1 -1
- package/src/fields/pattern-title/index.ts +28 -0
- package/src/fields/pattern-title/style.scss +3 -0
- package/src/fields/pattern-title/view.tsx +32 -0
- package/src/fields/slug/index.ts +3 -0
- package/src/fields/template/index.ts +3 -1
- package/src/fields/template-title/index.ts +28 -0
- package/src/fields/title/index.ts +9 -3
- package/src/fields/title/style.scss +8 -0
- package/src/fields/title/view.tsx +43 -0
- package/src/index.native.ts +0 -2
- package/src/style.scss +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/actions/duplicate-post.native.js +0 -9
- package/build/actions/duplicate-post.native.js.map +0 -1
- package/build/actions/export-pattern.native.js +0 -9
- package/build/actions/export-pattern.native.js.map +0 -1
- package/build/actions/reorder-page.native.js +0 -9
- package/build/actions/reorder-page.native.js.map +0 -1
- package/build/fields/title/title-view.js +0 -61
- package/build/fields/title/title-view.js.map +0 -1
- package/build-module/actions/duplicate-post.native.js +0 -3
- package/build-module/actions/duplicate-post.native.js.map +0 -1
- package/build-module/actions/export-pattern.native.js +0 -3
- package/build-module/actions/export-pattern.native.js.map +0 -1
- package/build-module/actions/reorder-page.native.js +0 -3
- package/build-module/actions/reorder-page.native.js.map +0 -1
- package/build-module/fields/title/title-view.js +0 -55
- package/build-module/fields/title/title-view.js.map +0 -1
- package/build-types/actions/duplicate-post.native.d.ts +0 -3
- package/build-types/actions/duplicate-post.native.d.ts.map +0 -1
- package/build-types/actions/export-pattern.native.d.ts +0 -3
- package/build-types/actions/export-pattern.native.d.ts.map +0 -1
- package/build-types/actions/reorder-page.native.d.ts +0 -3
- package/build-types/actions/reorder-page.native.d.ts.map +0 -1
- package/build-types/fields/title/title-view.d.ts +0 -9
- package/build-types/fields/title/title-view.d.ts.map +0 -1
- package/src/actions/duplicate-post.native.tsx +0 -3
- package/src/actions/export-pattern.native.tsx +0 -3
- package/src/actions/reorder-page.native.tsx +0 -3
- package/src/fields/title/title-view.tsx +0 -61
package/build/fields/index.js
CHANGED
|
@@ -34,6 +34,12 @@ Object.defineProperty(exports, "orderField", {
|
|
|
34
34
|
return _order.default;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
+
Object.defineProperty(exports, "pageTitleField", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _pageTitle.default;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
37
43
|
Object.defineProperty(exports, "parentField", {
|
|
38
44
|
enumerable: true,
|
|
39
45
|
get: function () {
|
|
@@ -46,6 +52,12 @@ Object.defineProperty(exports, "passwordField", {
|
|
|
46
52
|
return _password.default;
|
|
47
53
|
}
|
|
48
54
|
});
|
|
55
|
+
Object.defineProperty(exports, "patternTitleField", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _patternTitle.default;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
49
61
|
Object.defineProperty(exports, "slugField", {
|
|
50
62
|
enumerable: true,
|
|
51
63
|
get: function () {
|
|
@@ -64,6 +76,12 @@ Object.defineProperty(exports, "templateField", {
|
|
|
64
76
|
return _template.default;
|
|
65
77
|
}
|
|
66
78
|
});
|
|
79
|
+
Object.defineProperty(exports, "templateTitleField", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return _templateTitle.default;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
67
85
|
Object.defineProperty(exports, "titleField", {
|
|
68
86
|
enumerable: true,
|
|
69
87
|
get: function () {
|
|
@@ -72,6 +90,9 @@ Object.defineProperty(exports, "titleField", {
|
|
|
72
90
|
});
|
|
73
91
|
var _slug = _interopRequireDefault(require("./slug"));
|
|
74
92
|
var _title = _interopRequireDefault(require("./title"));
|
|
93
|
+
var _pageTitle = _interopRequireDefault(require("./page-title"));
|
|
94
|
+
var _templateTitle = _interopRequireDefault(require("./template-title"));
|
|
95
|
+
var _patternTitle = _interopRequireDefault(require("./pattern-title"));
|
|
75
96
|
var _order = _interopRequireDefault(require("./order"));
|
|
76
97
|
var _featuredImage = _interopRequireDefault(require("./featured-image"));
|
|
77
98
|
var _template = _interopRequireDefault(require("./template"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_slug","_interopRequireDefault","require","_title","_order","_featuredImage","_template","_parent","_password","_status","_commentStatus","_date","_author"],"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 templateField } from './template';\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';\nexport { default as authorField } from './author';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_slug","_interopRequireDefault","require","_title","_pageTitle","_templateTitle","_patternTitle","_order","_featuredImage","_template","_parent","_password","_status","_commentStatus","_date","_author"],"sources":["@wordpress/fields/src/fields/index.ts"],"sourcesContent":["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as pageTitleField } from './page-title';\nexport { default as templateTitleField } from './template-title';\nexport { default as patternTitleField } from './pattern-title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as templateField } from './template';\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';\nexport { default as authorField } from './author';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,aAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,cAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,OAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,SAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,OAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,cAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,KAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,OAAA,GAAAd,sBAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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\n/**\n * Order field for BasePost.\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;;AAED;AACA;AACA;AAFA,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeR,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 _utils = require("../../actions/utils");
|
|
10
|
+
var _view = _interopRequireDefault(require("./view"));
|
|
11
|
+
/**
|
|
12
|
+
* WordPress dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const pageTitleField = {
|
|
20
|
+
type: 'text',
|
|
21
|
+
id: 'title',
|
|
22
|
+
label: (0, _i18n.__)('Title'),
|
|
23
|
+
placeholder: (0, _i18n.__)('No title'),
|
|
24
|
+
getValue: ({
|
|
25
|
+
item
|
|
26
|
+
}) => (0, _utils.getItemTitle)(item),
|
|
27
|
+
render: _view.default,
|
|
28
|
+
enableHiding: false,
|
|
29
|
+
enableGlobalSearch: true
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Title for the page entity.
|
|
34
|
+
*/
|
|
35
|
+
var _default = exports.default = pageTitleField;
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_utils","_view","_interopRequireDefault","pageTitleField","type","id","label","__","placeholder","getValue","item","getItemTitle","render","PageTitleView","enableHiding","enableGlobalSearch","_default","exports","default"],"sources":["@wordpress/fields/src/fields/page-title/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 { getItemTitle } from '../../actions/utils';\nimport PageTitleView from './view';\n\nconst pageTitleField: Field< BasePost > = {\n\ttype: 'text',\n\tid: 'title',\n\tlabel: __( 'Title' ),\n\tplaceholder: __( 'No title' ),\n\tgetValue: ( { item } ) => getItemTitle( item ),\n\trender: PageTitleView,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\n/**\n * Title for the page entity.\n */\nexport default pageTitleField;\n"],"mappings":";;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMI,cAAiC,GAAG;EACzCC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,OAAO;EACXC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,WAAW,EAAE,IAAAD,QAAE,EAAE,UAAW,CAAC;EAC7BE,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAM,IAAAC,mBAAY,EAAED,IAAK,CAAC;EAC9CE,MAAM,EAAEC,aAAa;EACrBC,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE;AACrB,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGef,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = PageTitleView;
|
|
7
|
+
var _i18n = require("@wordpress/i18n");
|
|
8
|
+
var _data = require("@wordpress/data");
|
|
9
|
+
var _coreData = require("@wordpress/core-data");
|
|
10
|
+
var _view = require("../title/view");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function PageTitleView({
|
|
21
|
+
item
|
|
22
|
+
}) {
|
|
23
|
+
const {
|
|
24
|
+
frontPageId,
|
|
25
|
+
postsPageId
|
|
26
|
+
} = (0, _data.useSelect)(select => {
|
|
27
|
+
const {
|
|
28
|
+
getEntityRecord
|
|
29
|
+
} = select(_coreData.store);
|
|
30
|
+
const siteSettings = getEntityRecord('root', 'site');
|
|
31
|
+
return {
|
|
32
|
+
frontPageId: siteSettings?.page_on_front,
|
|
33
|
+
postsPageId: siteSettings?.page_for_posts
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_view.BaseTitleView, {
|
|
37
|
+
item: item,
|
|
38
|
+
className: "fields-field__page-title",
|
|
39
|
+
children: [frontPageId, postsPageId].includes(item.id) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
40
|
+
className: "fields-field__page-title__badge",
|
|
41
|
+
children: item.id === frontPageId ? (0, _i18n.__)('Homepage') : (0, _i18n.__)('Posts Page')
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_coreData","_view","_jsxRuntime","PageTitleView","item","frontPageId","postsPageId","useSelect","select","getEntityRecord","coreStore","siteSettings","page_on_front","page_for_posts","jsx","BaseTitleView","className","children","includes","id","__"],"sources":["@wordpress/fields/src/fields/page-title/view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Settings } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { CommonPost } from '../../types';\nimport { BaseTitleView } from '../title/view';\n\nexport default function PageTitleView( { item }: { item: CommonPost } ) {\n\tconst { frontPageId, postsPageId } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t) as Partial< Settings >;\n\t\treturn {\n\t\t\tfrontPageId: siteSettings?.page_on_front,\n\t\t\tpostsPageId: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<BaseTitleView item={ item } className=\"fields-field__page-title\">\n\t\t\t{ [ frontPageId, postsPageId ].includes( item.id as number ) && (\n\t\t\t\t<span className=\"fields-field__page-title__badge\">\n\t\t\t\t\t{ item.id === frontPageId\n\t\t\t\t\t\t? __( 'Homepage' )\n\t\t\t\t\t\t: __( 'Posts Page' ) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</BaseTitleView>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAOA,IAAAG,KAAA,GAAAH,OAAA;AAA8C,IAAAI,WAAA,GAAAJ,OAAA;AAZ9C;AACA;AACA;;AAMA;AACA;AACA;;AAIe,SAASK,aAAaA,CAAE;EAAEC;AAA2B,CAAC,EAAG;EACvE,MAAM;IAAEC,WAAW;IAAEC;EAAY,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC7D,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IAC/C,MAAMC,YAAY,GAAGF,eAAe,CACnC,MAAM,EACN,MACD,CAAwB;IACxB,OAAO;MACNJ,WAAW,EAAEM,YAAY,EAAEC,aAAa;MACxCN,WAAW,EAAEK,YAAY,EAAEE;IAC5B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,oBACC,IAAAX,WAAA,CAAAY,GAAA,EAACb,KAAA,CAAAc,aAAa;IAACX,IAAI,EAAGA,IAAM;IAACY,SAAS,EAAC,0BAA0B;IAAAC,QAAA,EAC9D,CAAEZ,WAAW,EAAEC,WAAW,CAAE,CAACY,QAAQ,CAAEd,IAAI,CAACe,EAAa,CAAC,iBAC3D,IAAAjB,WAAA,CAAAY,GAAA;MAAME,SAAS,EAAC,iCAAiC;MAAAC,QAAA,EAC9Cb,IAAI,CAACe,EAAE,KAAKd,WAAW,GACtB,IAAAe,QAAE,EAAE,UAAW,CAAC,GAChB,IAAAA,QAAE,EAAE,YAAa;IAAC,CAChB;EACN,CACa,CAAC;AAElB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
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 *
|
|
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 * Parent field for BasePost.\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":[]}
|
|
@@ -1 +1 @@
|
|
|
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\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\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AA,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":[]}
|
|
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\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,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAOA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,IAAA,GAAAR,OAAA;AAMA,IAAAS,MAAA,GAAAT,OAAA;AAAmD,IAAAU,WAAA,GAAAV,OAAA;AA5BnD;AACA;AACA;;AAGA;AACA;AACA;;AASA;;AAQA;AACA;AACA;;AAoBA,SAASW,cAAcA,CAAEC,SAAiB,EAAG;EAC5C,MAAMC,8BAA8B,GAAGD,SAAS,CAACE,GAAG,CAAIC,IAAI,IAAM;IACjE,OAAO;MACNC,QAAQ,EAAE,EAAE;MACZ,GAAGD;IACJ,CAAC;EACF,CAAE,CAAC;;EAEH;EACA,IACCF,8BAA8B,CAACI,IAAI,CAClC,CAAE;IAAEC;EAAO,CAAC,KAAMA,MAAM,KAAK,IAAI,IAAIA,MA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AA,CAAAgH,IAAA;MAAA1G,QAAA,GACG,IAAA2G,iCAAwB,EACzB,IAAAC,aAAO,EACN;MACA,IAAAhB,QAAE,EACD,0LACD,CAAC,EACD,IAAAiB,wBAAmB,EAAER,OAAQ,CAAC,CAACS,OAAO,CACrC,SAAS,EACT,WACD,CACD,CAAC,EACD;QACCC,GAAG,eAAE,IAAArH,WAAA,CAAA8F,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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_edit","_interopRequireDefault","require","passwordField","id","type","Edit","PasswordEdit","enableSorting","enableHiding","isVisible","item","status","_default","exports","default"],"sources":["@wordpress/fields/src/fields/password/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport PasswordEdit from './edit';\n\nconst passwordField: Field< BasePost > = {\n\tid: 'password',\n\ttype: 'text',\n\tEdit: PasswordEdit,\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => item.status !== 'private',\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"names":["_edit","_interopRequireDefault","require","passwordField","id","type","Edit","PasswordEdit","enableSorting","enableHiding","isVisible","item","status","_default","exports","default"],"sources":["@wordpress/fields/src/fields/password/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport PasswordEdit from './edit';\n\nconst passwordField: Field< BasePost > = {\n\tid: 'password',\n\ttype: 'text',\n\tEdit: PasswordEdit,\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => item.status !== 'private',\n};\n\n/**\n * Password field for BasePost.\n */\nexport default passwordField;\n"],"mappings":";;;;;;;AASA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAEC,aAAY;EAClBC,aAAa,EAAE,KAAK;EACpBC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAIC,IAAI,IAAMA,IAAI,CAACC,MAAM,KAAK;AACxC,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeZ,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 _utils = require("../../actions/utils");
|
|
10
|
+
var _view = _interopRequireDefault(require("./view"));
|
|
11
|
+
/**
|
|
12
|
+
* WordPress dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const patternTitleField = {
|
|
20
|
+
type: 'text',
|
|
21
|
+
id: 'title',
|
|
22
|
+
label: (0, _i18n.__)('Title'),
|
|
23
|
+
placeholder: (0, _i18n.__)('No title'),
|
|
24
|
+
getValue: ({
|
|
25
|
+
item
|
|
26
|
+
}) => (0, _utils.getItemTitle)(item),
|
|
27
|
+
render: _view.default,
|
|
28
|
+
enableHiding: false,
|
|
29
|
+
enableGlobalSearch: true
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Title for the pattern entity.
|
|
34
|
+
*/
|
|
35
|
+
var _default = exports.default = patternTitleField;
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_utils","_view","_interopRequireDefault","patternTitleField","type","id","label","__","placeholder","getValue","item","getItemTitle","render","PatternTitleView","enableHiding","enableGlobalSearch","_default","exports","default"],"sources":["@wordpress/fields/src/fields/pattern-title/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 { Pattern } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\nimport PatternTitleView from './view';\n\nconst patternTitleField: Field< Pattern > = {\n\ttype: 'text',\n\tid: 'title',\n\tlabel: __( 'Title' ),\n\tplaceholder: __( 'No title' ),\n\tgetValue: ( { item } ) => getItemTitle( item ),\n\trender: PatternTitleView,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\n/**\n * Title for the pattern entity.\n */\nexport default patternTitleField;\n"],"mappings":";;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMI,iBAAmC,GAAG;EAC3CC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,OAAO;EACXC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,WAAW,EAAE,IAAAD,QAAE,EAAE,UAAW,CAAC;EAC7BE,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAM,IAAAC,mBAAY,EAAED,IAAK,CAAC;EAC9CE,MAAM,EAAEC,aAAgB;EACxBC,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE;AACrB,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGef,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PATTERN_TYPES = void 0;
|
|
7
|
+
exports.default = PatternTitleView;
|
|
8
|
+
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
var _icons = require("@wordpress/icons");
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
var _patterns = require("@wordpress/patterns");
|
|
12
|
+
var _view = require("../title/view");
|
|
13
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
/**
|
|
16
|
+
* WordPress dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
PATTERN_TYPES
|
|
27
|
+
} = (0, _lockUnlock.unlock)(_patterns.privateApis);
|
|
28
|
+
exports.PATTERN_TYPES = PATTERN_TYPES;
|
|
29
|
+
function PatternTitleView({
|
|
30
|
+
item
|
|
31
|
+
}) {
|
|
32
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_view.BaseTitleView, {
|
|
33
|
+
item: item,
|
|
34
|
+
className: "fields-field__pattern-title",
|
|
35
|
+
children: item.type === PATTERN_TYPES.theme && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
|
|
36
|
+
placement: "top",
|
|
37
|
+
text: (0, _i18n.__)('This pattern cannot be edited.'),
|
|
38
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
|
|
39
|
+
icon: _icons.lockSmall,
|
|
40
|
+
size: 24
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_icons","_components","_patterns","_view","_lockUnlock","_jsxRuntime","PATTERN_TYPES","unlock","patternPrivateApis","exports","PatternTitleView","item","jsx","BaseTitleView","className","children","type","theme","Tooltip","placement","text","__","Icon","icon","lockSmall","size"],"sources":["@wordpress/fields/src/fields/pattern-title/view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, lockSmall } from '@wordpress/icons';\nimport { Tooltip } from '@wordpress/components';\n// @ts-ignore\nimport { privateApis as patternPrivateApis } from '@wordpress/patterns';\n\n/**\n * Internal dependencies\n */\nimport type { CommonPost } from '../../types';\nimport { BaseTitleView } from '../title/view';\nimport { unlock } from '../../lock-unlock';\n\nexport const { PATTERN_TYPES } = unlock( patternPrivateApis );\n\nexport default function PatternTitleView( { item }: { item: CommonPost } ) {\n\treturn (\n\t\t<BaseTitleView item={ item } className=\"fields-field__pattern-title\">\n\t\t\t{ item.type === PATTERN_TYPES.theme && (\n\t\t\t\t<Tooltip\n\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\ttext={ __( 'This pattern cannot be edited.' ) }\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ lockSmall } size={ 24 } />\n\t\t\t\t</Tooltip>\n\t\t\t) }\n\t\t</BaseTitleView>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AAMA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAA2C,IAAAM,WAAA,GAAAN,OAAA;AAd3C;AACA;AACA;;AAIA;;AAGA;AACA;AACA;;AAKO,MAAM;EAAEO;AAAc,CAAC,GAAG,IAAAC,kBAAM,EAAEC,qBAAmB,CAAC;AAACC,OAAA,CAAAH,aAAA,GAAAA,aAAA;AAE/C,SAASI,gBAAgBA,CAAE;EAAEC;AAA2B,CAAC,EAAG;EAC1E,oBACC,IAAAN,WAAA,CAAAO,GAAA,EAACT,KAAA,CAAAU,aAAa;IAACF,IAAI,EAAGA,IAAM;IAACG,SAAS,EAAC,6BAA6B;IAAAC,QAAA,EACjEJ,IAAI,CAACK,IAAI,KAAKV,aAAa,CAACW,KAAK,iBAClC,IAAAZ,WAAA,CAAAO,GAAA,EAACX,WAAA,CAAAiB,OAAO;MACPC,SAAS,EAAC,KAAK;MACfC,IAAI,EAAG,IAAAC,QAAE,EAAE,gCAAiC,CAAG;MAAAN,QAAA,eAE/C,IAAAV,WAAA,CAAAO,GAAA,EAACZ,MAAA,CAAAsB,IAAI;QAACC,IAAI,EAAGC,gBAAW;QAACC,IAAI,EAAG;MAAI,CAAE;IAAC,CAC/B;EACT,CACa,CAAC;AAElB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_slugEdit","_interopRequireDefault","_slugView","slugField","id","type","label","__","Edit","SlugEdit","render","SlugView","_default","exports","default"],"sources":["@wordpress/fields/src/fields/slug/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 SlugEdit from './slug-edit';\nimport SlugView from './slug-view';\n\nconst slugField: Field< BasePost > = {\n\tid: 'slug',\n\ttype: 'text',\n\tlabel: __( 'Slug' ),\n\tEdit: SlugEdit,\n\trender: SlugView,\n};\n\nexport default slugField;\n"],"mappings":";;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAD,sBAAA,CAAAF,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMI,SAA4B,GAAG;EACpCC,EAAE,EAAE,MAAM;EACVC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO,CAAC;EACnBC,IAAI,EAAEC,iBAAQ;EACdC,MAAM,EAAEC;AACT,CAAC;
|
|
1
|
+
{"version":3,"names":["_i18n","require","_slugEdit","_interopRequireDefault","_slugView","slugField","id","type","label","__","Edit","SlugEdit","render","SlugView","_default","exports","default"],"sources":["@wordpress/fields/src/fields/slug/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 SlugEdit from './slug-edit';\nimport SlugView from './slug-view';\n\nconst slugField: Field< BasePost > = {\n\tid: 'slug',\n\ttype: 'text',\n\tlabel: __( 'Slug' ),\n\tEdit: SlugEdit,\n\trender: SlugView,\n};\n\n/**\n * Slug field for BasePost.\n */\nexport default slugField;\n"],"mappings":";;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAD,sBAAA,CAAAF,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMI,SAA4B,GAAG;EACpCC,EAAE,EAAE,MAAM;EACVC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO,CAAC;EACnBC,IAAI,EAAEC,iBAAQ;EACdC,MAAM,EAAEC;AACT,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeX,SAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_statusElements","_interopRequireDefault","_jsxRuntime","StatusView","item","status","STATUSES","find","value","label","icon","jsxs","__experimentalHStack","alignment","spacing","children","jsx","className","Icon","_default","exports","default"],"sources":["@wordpress/fields/src/fields/status/status-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport STATUSES from './status-elements';\n\nfunction StatusView( { item }: { item: BasePost } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default StatusView;\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_components","require","_statusElements","_interopRequireDefault","_jsxRuntime","StatusView","item","status","STATUSES","find","value","label","icon","jsxs","__experimentalHStack","alignment","spacing","children","jsx","className","Icon","_default","exports","default"],"sources":["@wordpress/fields/src/fields/status/status-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport STATUSES from './status-elements';\n\nfunction StatusView( { item }: { item: BasePost } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default StatusView;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAyC,IAAAG,WAAA,GAAAH,OAAA;AATzC;AACA;AACA;;AAGA;AACA;AACA;;AAIA,SAASI,UAAUA,CAAE;EAAEC;AAAyB,CAAC,EAAG;EACnD,MAAMC,MAAM,GAAGC,uBAAQ,CAACC,IAAI,CAAE,CAAE;IAAEC;EAAM,CAAC,KAAMA,KAAK,KAAKJ,IAAI,CAACC,MAAO,CAAC;EACtE,MAAMI,KAAK,GAAGJ,MAAM,EAAEI,KAAK,IAAIL,IAAI,CAACC,MAAM;EAC1C,MAAMK,IAAI,GAAGL,MAAM,EAAEK,IAAI;EACzB,oBACC,IAAAR,WAAA,CAAAS,IAAA,EAACb,WAAA,CAAAc,oBAAM;IAACC,SAAS,EAAC,MAAM;IAACC,OAAO,EAAG,CAAG;IAAAC,QAAA,GACnCL,IAAI,iBACL,IAAAR,WAAA,CAAAc,GAAA;MAAKC,SAAS,EAAC,kCAAkC;MAAAF,QAAA,eAChD,IAAAb,WAAA,CAAAc,GAAA,EAAClB,WAAA,CAAAoB,IAAI;QAACR,IAAI,EAAGA;MAAM,CAAE;IAAC,CAClB,CACL,eACD,IAAAR,WAAA,CAAAc,GAAA;MAAAD,QAAA,EAAQN;IAAK,CAAQ,CAAC;EAAA,CACf,CAAC;AAEX;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEclB,UAAU","ignoreList":[]}
|
|
@@ -18,11 +18,12 @@ const templateField = {
|
|
|
18
18
|
id: 'template',
|
|
19
19
|
type: 'text',
|
|
20
20
|
label: (0, _i18n.__)('Template'),
|
|
21
|
-
getValue: ({
|
|
22
|
-
item
|
|
23
|
-
}) => item.template,
|
|
24
21
|
Edit: _templateEdit.TemplateEdit,
|
|
25
22
|
enableSorting: false
|
|
26
23
|
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Template field for BasePost.
|
|
27
|
+
*/
|
|
27
28
|
var _default = exports.default = templateField;
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_templateEdit","templateField","id","type","label","__","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_templateEdit","templateField","id","type","label","__","Edit","TemplateEdit","enableSorting","_default","exports","default"],"sources":["@wordpress/fields/src/fields/template/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport type { BasePost } from '../../types';\nimport { TemplateEdit } from './template-edit';\n\nconst templateField: Field< BasePost > = {\n\tid: 'template',\n\ttype: 'text',\n\tlabel: __( 'Template' ),\n\tEdit: TemplateEdit,\n\tenableSorting: false,\n};\n\n/**\n * Template field for BasePost.\n */\nexport default templateField;\n"],"mappings":";;;;;;AAQA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA,MAAME,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,UAAW,CAAC;EACvBC,IAAI,EAAEC,0BAAY;EAClBC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeV,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_blocks","_coreData","_blockEditor","_components","_compose","_data","_htmlEntities","_i18n","_utils","_lockUnlock","_jsxRuntime","TemplateEdit","data","field","onChange","id","postType","type","postId","parseInt","slug","availableTemplates","templates","useSelect","select","_select$getEntityReco","allTemplates","coreStore","getEntityRecords","per_page","post_type","getHomePage","getPostsPageId","unlock","isPostsPage","isFrontPage","allowSwitchingTemplate","filter","template","is_custom","content","raw","templatesAsPatterns","useMemo","map","name","blocks","parse","title","decodeEntities","rendered","shownTemplates","useAsyncList","value","getValue","item","currentTemplate","foundTemplate","find","slugToCheck","templateId","getDefaultTemplateId","getEntityRecord","showModal","setShowModal","useState","onChangeControl","useCallback","newValue","jsxs","className","children","jsx","Dropdown","popoverProps","placement","renderToggle","onToggle","Button","__next40pxDefaultSize","variant","size","onClick","getItemTitle","renderContent","MenuGroup","MenuItem","__","Modal","onRequestClose","overlayClassName","isFullScreen","__experimentalBlockPatternsList","label","blockPatterns","shownPatterns","onClickPattern","exports"],"sources":["@wordpress/fields/src/fields/template/template-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo, useState } from '@wordpress/element';\n// @ts-ignore\nimport { parse } from '@wordpress/blocks';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\n// @ts-expect-error block-editor is not typed correctly.\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tDropdown,\n\tMenuGroup,\n\tMenuItem,\n\tModal,\n} from '@wordpress/components';\nimport { useAsyncList } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { getItemTitle } from '../../actions/utils';\nimport type { BasePost } from '../../types';\nimport { unlock } from '../../lock-unlock';\n\nexport const TemplateEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\tconst postType = data.type;\n\tconst postId =\n\t\ttypeof data.id === 'number' ? data.id : parseInt( data.id, 10 );\n\tconst slug = data.slug;\n\n\tconst { availableTemplates, templates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst allTemplates =\n\t\t\t\tselect( coreStore ).getEntityRecords< WpTemplate >(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\t{\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\tpost_type: postType,\n\t\t\t\t\t}\n\t\t\t\t) ?? [];\n\n\t\t\tconst { getHomePage, getPostsPageId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst isPostsPage = getPostsPageId() === +postId;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && getHomePage()?.postId === +postId;\n\n\t\t\tconst allowSwitchingTemplate = ! isPostsPage && ! isFrontPage;\n\n\t\t\treturn {\n\t\t\t\ttemplates: allTemplates,\n\t\t\t\tavailableTemplates: allowSwitchingTemplate\n\t\t\t\t\t? allTemplates.filter(\n\t\t\t\t\t\t\t( template ) =>\n\t\t\t\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\t\t\t\ttemplate.slug !== data.template &&\n\t\t\t\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t\t\t )\n\t\t\t\t\t: [],\n\t\t\t};\n\t\t},\n\t\t[ data.template, postId, postType ]\n\t);\n\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\n\tconst shownTemplates = useAsyncList( templatesAsPatterns );\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst currentTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst foundTemplate = templates?.find(\n\t\t\t\t( template ) => template.slug === value\n\t\t\t);\n\n\t\t\tif ( foundTemplate ) {\n\t\t\t\treturn foundTemplate;\n\t\t\t}\n\n\t\t\tlet slugToCheck;\n\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t// through template hierarchy.\n\t\t\tif ( slug ) {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page'\n\t\t\t\t\t\t? `${ postType }-${ slug }`\n\t\t\t\t\t\t: `single-${ postType }-${ slug }`;\n\t\t\t} else {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page' ? 'page' : `single-${ postType }`;\n\t\t\t}\n\n\t\t\tif ( postType ) {\n\t\t\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\n\t\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\ttemplateId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ postType, slug, templates, value ]\n\t);\n\n\tconst [ showModal, setShowModal ] = useState( false );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\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__template\">\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ currentTemplate\n\t\t\t\t\t\t\t? getItemTitle( currentTemplate )\n\t\t\t\t\t\t\t: '' }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onToggle } ) => (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowModal( true );\n\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Swap template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// The default template in a post is indicated by an empty string\n\t\t\t\t\t\t\tvalue !== '' && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonChangeControl( '' );\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Use default template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"fields-controls__template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"fields-controls__template-content\">\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tlabel={ __( 'Templates' ) }\n\t\t\t\t\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\t\t\t\t\tshownPatterns={ shownTemplates }\n\t\t\t\t\t\t\tonClickPattern={ (\n\t\t\t\t\t\t\t\ttemplate: ( typeof templatesAsPatterns )[ 0 ]\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tonChangeControl( template.name );\n\t\t\t\t\t\t\t\tsetShowModal( false );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</fieldset>\n\t);\n};\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAOA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAOA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAEA,IAAAU,WAAA,GAAAV,OAAA;AAA2C,IAAAW,WAAA,GAAAX,OAAA;AA5B3C;AACA;AACA;;AAEA;;AAMA;AACA;AACA;AACA;;AAiBO,MAAMY,YAAY,GAAGA,CAAE;EAC7BC,IAAI;EACJC,KAAK;EACLC;AACiC,CAAC,KAAM;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGF,KAAK;EACpB,MAAMG,QAAQ,GAAGJ,IAAI,CAACK,IAAI;EAC1B,MAAMC,MAAM,GACX,OAAON,IAAI,CAACG,EAAE,KAAK,QAAQ,GAAGH,IAAI,CAACG,EAAE,GAAGI,QAAQ,CAAEP,IAAI,CAACG,EAAE,EAAE,EAAG,CAAC;EAChE,MAAMK,IAAI,GAAGR,IAAI,CAACQ,IAAI;EAEtB,MAAM;IAAEC,kBAAkB;IAAEC;EAAU,CAAC,GAAG,IAAAC,eAAS,EAChDC,MAAM,IAAM;IAAA,IAAAC,qBAAA;IACb,MAAMC,YAAY,IAAAD,qB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CAAAqF,KAAK;MACLxC,KAAK,EAAG,IAAAuC,QAAE,EAAE,mBAAoB,CAAG;MACnCE,cAAc,EAAGA,CAAA,KAAMzB,YAAY,CAAE,KAAM,CAAG;MAC9C0B,gBAAgB,EAAC,iCAAiC;MAClDC,YAAY;MAAApB,QAAA,eAEZ,IAAA7D,WAAA,CAAA8D,GAAA;QAAKF,SAAS,EAAC,mCAAmC;QAAAC,QAAA,eACjD,IAAA7D,WAAA,CAAA8D,GAAA,EAACtE,YAAA,CAAA0F,+BAAiB;UACjBC,KAAK,EAAG,IAAAN,QAAE,EAAE,WAAY,CAAG;UAC3BO,aAAa,EAAGpD,mBAAqB;UACrCqD,aAAa,EAAG5C,cAAgB;UAChC6C,cAAc,EACb1D,QAA6C,IACzC;YACJ4B,eAAe,CAAE5B,QAAQ,CAACO,IAAK,CAAC;YAChCmB,YAAY,CAAE,KAAM,CAAC;UACtB;QAAG,CACH;MAAC,CACE;IAAC,CACA,CACP;EAAA,CACQ,CAAC;AAEb,CAAC;AAACiC,OAAA,CAAAtF,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_blocks","_coreData","_blockEditor","_components","_compose","_data","_htmlEntities","_i18n","_utils","_lockUnlock","_jsxRuntime","TemplateEdit","data","field","onChange","id","postType","type","postId","parseInt","slug","availableTemplates","templates","useSelect","select","_select$getEntityReco","allTemplates","coreStore","getEntityRecords","per_page","post_type","getHomePage","getPostsPageId","unlock","isPostsPage","isFrontPage","allowSwitchingTemplate","filter","template","is_custom","content","raw","templatesAsPatterns","useMemo","map","name","blocks","parse","title","decodeEntities","rendered","shownTemplates","useAsyncList","value","getValue","item","currentTemplate","foundTemplate","find","slugToCheck","templateId","getDefaultTemplateId","getEntityRecord","showModal","setShowModal","useState","onChangeControl","useCallback","newValue","jsxs","className","children","jsx","Dropdown","popoverProps","placement","renderToggle","onToggle","Button","__next40pxDefaultSize","variant","size","onClick","getItemTitle","renderContent","MenuGroup","MenuItem","__","Modal","onRequestClose","overlayClassName","isFullScreen","__experimentalBlockPatternsList","label","blockPatterns","shownPatterns","onClickPattern","exports"],"sources":["@wordpress/fields/src/fields/template/template-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo, useState } from '@wordpress/element';\n// @ts-ignore\nimport { parse } from '@wordpress/blocks';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\n// @ts-expect-error block-editor is not typed correctly.\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tDropdown,\n\tMenuGroup,\n\tMenuItem,\n\tModal,\n} from '@wordpress/components';\nimport { useAsyncList } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { getItemTitle } from '../../actions/utils';\nimport type { BasePost } from '../../types';\nimport { unlock } from '../../lock-unlock';\n\nexport const TemplateEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\tconst postType = data.type;\n\tconst postId =\n\t\ttypeof data.id === 'number' ? data.id : parseInt( data.id, 10 );\n\tconst slug = data.slug;\n\n\tconst { availableTemplates, templates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst allTemplates =\n\t\t\t\tselect( coreStore ).getEntityRecords< WpTemplate >(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\t{\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\tpost_type: postType,\n\t\t\t\t\t}\n\t\t\t\t) ?? [];\n\n\t\t\tconst { getHomePage, getPostsPageId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst isPostsPage = getPostsPageId() === +postId;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && getHomePage()?.postId === +postId;\n\n\t\t\tconst allowSwitchingTemplate = ! isPostsPage && ! isFrontPage;\n\n\t\t\treturn {\n\t\t\t\ttemplates: allTemplates,\n\t\t\t\tavailableTemplates: allowSwitchingTemplate\n\t\t\t\t\t? allTemplates.filter(\n\t\t\t\t\t\t\t( template ) =>\n\t\t\t\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\t\t\t\ttemplate.slug !== data.template &&\n\t\t\t\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t\t\t )\n\t\t\t\t\t: [],\n\t\t\t};\n\t\t},\n\t\t[ data.template, postId, postType ]\n\t);\n\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\n\tconst shownTemplates = useAsyncList( templatesAsPatterns );\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst currentTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst foundTemplate = templates?.find(\n\t\t\t\t( template ) => template.slug === value\n\t\t\t);\n\n\t\t\tif ( foundTemplate ) {\n\t\t\t\treturn foundTemplate;\n\t\t\t}\n\n\t\t\tlet slugToCheck;\n\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t// through template hierarchy.\n\t\t\tif ( slug ) {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page'\n\t\t\t\t\t\t? `${ postType }-${ slug }`\n\t\t\t\t\t\t: `single-${ postType }-${ slug }`;\n\t\t\t} else {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page' ? 'page' : `single-${ postType }`;\n\t\t\t}\n\n\t\t\tif ( postType ) {\n\t\t\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\n\t\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\ttemplateId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ postType, slug, templates, value ]\n\t);\n\n\tconst [ showModal, setShowModal ] = useState( false );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\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__template\">\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ currentTemplate\n\t\t\t\t\t\t\t? getItemTitle( currentTemplate )\n\t\t\t\t\t\t\t: '' }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onToggle } ) => (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowModal( true );\n\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Swap template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// The default template in a post is indicated by an empty string\n\t\t\t\t\t\t\tvalue !== '' && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonChangeControl( '' );\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Use default template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"fields-controls__template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"fields-controls__template-content\">\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tlabel={ __( 'Templates' ) }\n\t\t\t\t\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\t\t\t\t\tshownPatterns={ shownTemplates }\n\t\t\t\t\t\t\tonClickPattern={ (\n\t\t\t\t\t\t\t\ttemplate: ( typeof templatesAsPatterns )[ 0 ]\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tonChangeControl( template.name );\n\t\t\t\t\t\t\t\tsetShowModal( false );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</fieldset>\n\t);\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAOA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAOA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,KA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CACH;MAAC,CACE;IAAC,CACA,CACP;EAAA,CACQ,CAAC;AAEb,CAAC;AAACiC,OAAA,CAAAtF,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 _utils = require("../../actions/utils");
|
|
10
|
+
var _view = _interopRequireDefault(require("../title/view"));
|
|
11
|
+
/**
|
|
12
|
+
* WordPress dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const templateTitleField = {
|
|
20
|
+
type: 'text',
|
|
21
|
+
label: (0, _i18n.__)('Template'),
|
|
22
|
+
placeholder: (0, _i18n.__)('No title'),
|
|
23
|
+
id: 'title',
|
|
24
|
+
getValue: ({
|
|
25
|
+
item
|
|
26
|
+
}) => (0, _utils.getItemTitle)(item),
|
|
27
|
+
render: _view.default,
|
|
28
|
+
enableHiding: false,
|
|
29
|
+
enableGlobalSearch: true
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Title for the template entity.
|
|
34
|
+
*/
|
|
35
|
+
var _default = exports.default = templateTitleField;
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_utils","_view","_interopRequireDefault","templateTitleField","type","label","__","placeholder","id","getValue","item","getItemTitle","render","TitleView","enableHiding","enableGlobalSearch","_default","exports","default"],"sources":["@wordpress/fields/src/fields/template-title/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 { Template } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\nimport TitleView from '../title/view';\n\nconst templateTitleField: Field< Template > = {\n\ttype: 'text',\n\tlabel: __( 'Template' ),\n\tplaceholder: __( 'No title' ),\n\tid: 'title',\n\tgetValue: ( { item } ) => getItemTitle( item ),\n\trender: TitleView,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\n/**\n * Title for the template entity.\n */\nexport default templateTitleField;\n"],"mappings":";;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMI,kBAAqC,GAAG;EAC7CC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,UAAW,CAAC;EACvBC,WAAW,EAAE,IAAAD,QAAE,EAAE,UAAW,CAAC;EAC7BE,EAAE,EAAE,OAAO;EACXC,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAM,IAAAC,mBAAY,EAAED,IAAK,CAAC;EAC9CE,MAAM,EAAEC,aAAS;EACjBC,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE;AACrB,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGef,kBAAkB","ignoreList":[]}
|