@wordpress/fields 0.34.0 → 0.35.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +8 -0
  3. package/build/fields/date/scheduled/index.cjs +4 -0
  4. package/build/fields/date/scheduled/index.cjs.map +2 -2
  5. package/build/fields/excerpt/index.cjs +61 -0
  6. package/build/fields/excerpt/index.cjs.map +7 -0
  7. package/build/fields/index.cjs +6 -0
  8. package/build/fields/index.cjs.map +2 -2
  9. package/build/fields/sticky/index.cjs +38 -0
  10. package/build/fields/sticky/index.cjs.map +7 -0
  11. package/build/types.cjs.map +1 -1
  12. package/build-module/fields/date/scheduled/index.mjs +4 -0
  13. package/build-module/fields/date/scheduled/index.mjs.map +2 -2
  14. package/build-module/fields/excerpt/index.mjs +43 -0
  15. package/build-module/fields/excerpt/index.mjs.map +7 -0
  16. package/build-module/fields/index.mjs +8 -4
  17. package/build-module/fields/index.mjs.map +2 -2
  18. package/build-module/fields/sticky/index.mjs +17 -0
  19. package/build-module/fields/sticky/index.mjs.map +7 -0
  20. package/build-types/fields/date/scheduled/index.d.ts.map +1 -1
  21. package/build-types/fields/excerpt/index.d.ts +14 -0
  22. package/build-types/fields/excerpt/index.d.ts.map +1 -0
  23. package/build-types/fields/index.d.ts +2 -0
  24. package/build-types/fields/index.d.ts.map +1 -1
  25. package/build-types/fields/sticky/index.d.ts +14 -0
  26. package/build-types/fields/sticky/index.d.ts.map +1 -0
  27. package/build-types/types.d.ts +2 -0
  28. package/build-types/types.d.ts.map +1 -1
  29. package/package.json +26 -26
  30. package/src/fields/date/scheduled/index.tsx +4 -0
  31. package/src/fields/excerpt/index.tsx +57 -0
  32. package/src/fields/index.ts +2 -0
  33. package/src/fields/sticky/index.tsx +26 -0
  34. package/src/types.ts +2 -0
  35. package/build/fields/template/utils.cjs +0 -91
  36. package/build/fields/template/utils.cjs.map +0 -7
  37. package/build-module/fields/template/utils.mjs +0 -65
  38. package/build-module/fields/template/utils.mjs.map +0 -7
  39. package/build-types/fields/template/utils.d.ts +0 -28
  40. package/build-types/fields/template/utils.d.ts.map +0 -1
  41. package/src/fields/template/utils.ts +0 -119
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.35.0 (2026-04-01)
6
+
5
7
  ## 0.34.0 (2026-03-18)
6
8
 
7
9
  ## 0.33.0 (2026-03-04)
package/README.md CHANGED
@@ -63,6 +63,10 @@ Duplicate action for BasePost.
63
63
 
64
64
  Duplicate action for TemplatePart.
65
65
 
66
+ ### excerptField
67
+
68
+ Excerpt field for BasePost.
69
+
66
70
  ### exportPattern
67
71
 
68
72
  Export action as JSON for Pattern.
@@ -188,6 +192,10 @@ Slug field for BasePost.
188
192
 
189
193
  Status field for BasePost.
190
194
 
195
+ ### stickyField
196
+
197
+ Sticky field for BasePost.
198
+
191
199
  ### templateField
192
200
 
193
201
  Template field for BasePost.
@@ -31,6 +31,10 @@ var scheduledDateField = {
31
31
  getValue: ({ item }) => item.date,
32
32
  setValue: ({ value }) => ({ date: value }),
33
33
  isVisible: (item) => item.status === "future",
34
+ Edit: {
35
+ control: "datetime",
36
+ compact: true
37
+ },
34
38
  enableHiding: false,
35
39
  enableSorting: false,
36
40
  filterBy: false
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/fields/date/scheduled/index.tsx"],
4
- "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 scheduledDateField: Field< BasePost > = {\n\tid: 'scheduled_date',\n\ttype: 'datetime',\n\tlabel: __( 'Scheduled Date' ),\n\tgetValue: ( { item } ) => item.date,\n\tsetValue: ( { value } ) => ( { date: value } ),\n\tisVisible: ( item ) => item.status === 'future',\n\tenableHiding: false,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * ScheduledDate Field.\n */\nexport default scheduledDateField;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AAOnB,IAAM,qBAAwC;AAAA,EAC7C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,gBAAiB;AAAA,EAC5B,UAAU,CAAE,EAAE,KAAK,MAAO,KAAK;AAAA,EAC/B,UAAU,CAAE,EAAE,MAAM,OAAS,EAAE,MAAM,MAAM;AAAA,EAC3C,WAAW,CAAE,SAAU,KAAK,WAAW;AAAA,EACvC,cAAc;AAAA,EACd,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,oBAAQ;",
4
+ "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 scheduledDateField: Field< BasePost > = {\n\tid: 'scheduled_date',\n\ttype: 'datetime',\n\tlabel: __( 'Scheduled Date' ),\n\tgetValue: ( { item } ) => item.date,\n\tsetValue: ( { value } ) => ( { date: value } ),\n\tisVisible: ( item ) => item.status === 'future',\n\tEdit: {\n\t\tcontrol: 'datetime',\n\t\tcompact: true,\n\t},\n\tenableHiding: false,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * ScheduledDate Field.\n */\nexport default scheduledDateField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AAOnB,IAAM,qBAAwC;AAAA,EAC7C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,gBAAiB;AAAA,EAC5B,UAAU,CAAE,EAAE,KAAK,MAAO,KAAK;AAAA,EAC/B,UAAU,CAAE,EAAE,MAAM,OAAS,EAAE,MAAM,MAAM;AAAA,EAC3C,WAAW,CAAE,SAAU,KAAK,WAAW;AAAA,EACvC,MAAM;AAAA,IACL,SAAS;AAAA,IACT,SAAS;AAAA,EACV;AAAA,EACA,cAAc;AAAA,EACd,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,oBAAQ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/fields/src/fields/excerpt/index.tsx
21
+ var excerpt_exports = {};
22
+ __export(excerpt_exports, {
23
+ default: () => excerpt_default
24
+ });
25
+ module.exports = __toCommonJS(excerpt_exports);
26
+ var import_html_entities = require("@wordpress/html-entities");
27
+ var import_i18n = require("@wordpress/i18n");
28
+ var import_components = require("@wordpress/components");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var excerptField = {
31
+ id: "excerpt",
32
+ type: "text",
33
+ label: (0, import_i18n.__)("Excerpt"),
34
+ placeholder: (0, import_i18n.__)("Add an excerpt"),
35
+ description: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
36
+ import_components.ExternalLink,
37
+ {
38
+ href: (0, import_i18n.__)(
39
+ "https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt"
40
+ ),
41
+ children: (0, import_i18n.__)("Learn more about manual excerpts")
42
+ }
43
+ ),
44
+ render: ({ item }) => {
45
+ let excerpt;
46
+ if (typeof item.excerpt === "string") {
47
+ excerpt = !!item.excerpt ? (0, import_html_entities.decodeEntities)(item.excerpt) : (0, import_i18n.__)("Add an excerpt");
48
+ } else {
49
+ excerpt = (0, import_html_entities.decodeEntities)(item.excerpt?.raw || "");
50
+ }
51
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { align: "left", numberOfLines: 3, truncate: true, children: excerpt });
52
+ },
53
+ Edit: {
54
+ control: "textarea",
55
+ rows: 4
56
+ },
57
+ enableSorting: false,
58
+ filterBy: false
59
+ };
60
+ var excerpt_default = excerptField;
61
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/excerpt/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tExternalLink,\n\t__experimentalText as Text,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nconst excerptField: Field< BasePost > = {\n\tid: 'excerpt',\n\ttype: 'text',\n\tlabel: __( 'Excerpt' ),\n\tplaceholder: __( 'Add an excerpt' ),\n\tdescription: (\n\t\t<ExternalLink\n\t\t\thref={ __(\n\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'\n\t\t\t) }\n\t\t>\n\t\t\t{ __( 'Learn more about manual excerpts' ) }\n\t\t</ExternalLink>\n\t),\n\trender: ( { item } ) => {\n\t\tlet excerpt;\n\t\tif ( typeof item.excerpt === 'string' ) {\n\t\t\texcerpt = !! item.excerpt\n\t\t\t\t? decodeEntities( item.excerpt )\n\t\t\t\t: __( 'Add an excerpt' );\n\t\t} else {\n\t\t\texcerpt = decodeEntities( item.excerpt?.raw || '' );\n\t\t}\n\t\treturn (\n\t\t\t<Text align=\"left\" numberOfLines={ 3 } truncate>\n\t\t\t\t{ excerpt }\n\t\t\t</Text>\n\t\t);\n\t},\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 4,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * Excerpt field for BasePost.\n */\nexport default excerptField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,2BAA+B;AAC/B,kBAAmB;AACnB,wBAGO;AAaL;AANF,IAAM,eAAkC;AAAA,EACvC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,SAAU;AAAA,EACrB,iBAAa,gBAAI,gBAAiB;AAAA,EAClC,aACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAO;AAAA,QACN;AAAA,MACD;AAAA,MAEE,8BAAI,kCAAmC;AAAA;AAAA,EAC1C;AAAA,EAED,QAAQ,CAAE,EAAE,KAAK,MAAO;AACvB,QAAI;AACJ,QAAK,OAAO,KAAK,YAAY,UAAW;AACvC,gBAAU,CAAC,CAAE,KAAK,cACf,qCAAgB,KAAK,OAAQ,QAC7B,gBAAI,gBAAiB;AAAA,IACzB,OAAO;AACN,oBAAU,qCAAgB,KAAK,SAAS,OAAO,EAAG;AAAA,IACnD;AACA,WACC,4CAAC,kBAAAA,oBAAA,EAAK,OAAM,QAAO,eAAgB,GAAI,UAAQ,MAC5C,mBACH;AAAA,EAEF;AAAA,EACA,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,kBAAQ;",
6
+ "names": ["Text"]
7
+ }
@@ -34,6 +34,7 @@ __export(fields_exports, {
34
34
  commentStatusField: () => import_comment_status.default,
35
35
  dateField: () => import_date.default,
36
36
  discussionField: () => import_discussion.default,
37
+ excerptField: () => import_excerpt.default,
37
38
  featuredImageField: () => import_featured_image.default,
38
39
  formatField: () => import_format.default,
39
40
  notesField: () => import_notes.default,
@@ -47,6 +48,7 @@ __export(fields_exports, {
47
48
  scheduledDateField: () => import_scheduled.default,
48
49
  slugField: () => import_slug.default,
49
50
  statusField: () => import_status.default,
51
+ stickyField: () => import_sticky.default,
50
52
  templateField: () => import_template.default,
51
53
  templateTitleField: () => import_template_title.default,
52
54
  titleField: () => import_title.default
@@ -70,14 +72,17 @@ var import_date = __toESM(require("./date/index.cjs"));
70
72
  var import_scheduled = __toESM(require("./date/scheduled/index.cjs"));
71
73
  var import_author = __toESM(require("./author/index.cjs"));
72
74
  var import_notes = __toESM(require("./notes/index.cjs"));
75
+ var import_excerpt = __toESM(require("./excerpt/index.cjs"));
73
76
  var import_format = __toESM(require("./format/index.cjs"));
74
77
  var import_post_content_info = __toESM(require("./post-content-info/index.cjs"));
78
+ var import_sticky = __toESM(require("./sticky/index.cjs"));
75
79
  // Annotate the CommonJS export names for ESM import in node:
76
80
  0 && (module.exports = {
77
81
  authorField,
78
82
  commentStatusField,
79
83
  dateField,
80
84
  discussionField,
85
+ excerptField,
81
86
  featuredImageField,
82
87
  formatField,
83
88
  notesField,
@@ -91,6 +96,7 @@ var import_post_content_info = __toESM(require("./post-content-info/index.cjs"))
91
96
  scheduledDateField,
92
97
  slugField,
93
98
  statusField,
99
+ stickyField,
94
100
  templateField,
95
101
  templateTitleField,
96
102
  titleField
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/fields/index.ts"],
4
- "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 pingStatusField } from './ping-status';\nexport { default as discussionField } from './discussion';\nexport { default as dateField } from './date';\nexport { default as scheduledDateField } from './date/scheduled';\nexport { default as authorField } from './author';\nexport { default as notesField } from './notes';\nexport { default as formatField } from './format';\nexport { default as postContentInfoField } from './post-content-info';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqC;AACrC,mBAAsC;AACtC,wBAA0C;AAC1C,4BAA8C;AAC9C,2BAA6C;AAC7C,mBAAsC;AACtC,4BAA8C;AAC9C,sBAAyC;AACzC,oBAAuC;AACvC,sBAAyC;AACzC,oBAAuC;AACvC,4BAA8C;AAC9C,yBAA2C;AAC3C,wBAA2C;AAC3C,kBAAqC;AACrC,uBAA8C;AAC9C,oBAAuC;AACvC,mBAAsC;AACtC,oBAAuC;AACvC,+BAAgD;",
4
+ "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 pingStatusField } from './ping-status';\nexport { default as discussionField } from './discussion';\nexport { default as dateField } from './date';\nexport { default as scheduledDateField } from './date/scheduled';\nexport { default as authorField } from './author';\nexport { default as notesField } from './notes';\nexport { default as excerptField } from './excerpt';\nexport { default as formatField } from './format';\nexport { default as postContentInfoField } from './post-content-info';\nexport { default as stickyField } from './sticky';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqC;AACrC,mBAAsC;AACtC,wBAA0C;AAC1C,4BAA8C;AAC9C,2BAA6C;AAC7C,mBAAsC;AACtC,4BAA8C;AAC9C,sBAAyC;AACzC,oBAAuC;AACvC,sBAAyC;AACzC,oBAAuC;AACvC,4BAA8C;AAC9C,yBAA2C;AAC3C,wBAA2C;AAC3C,kBAAqC;AACrC,uBAA8C;AAC9C,oBAAuC;AACvC,mBAAsC;AACtC,qBAAwC;AACxC,oBAAuC;AACvC,+BAAgD;AAChD,oBAAuC;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/fields/src/fields/sticky/index.tsx
21
+ var sticky_exports = {};
22
+ __export(sticky_exports, {
23
+ default: () => sticky_default
24
+ });
25
+ module.exports = __toCommonJS(sticky_exports);
26
+ var import_i18n = require("@wordpress/i18n");
27
+ var stickyField = {
28
+ id: "sticky",
29
+ type: "boolean",
30
+ label: (0, import_i18n.__)("Sticky"),
31
+ description: (0, import_i18n.__)("Pin this post to the top of the blog."),
32
+ enableSorting: false,
33
+ enableHiding: false,
34
+ isVisible: (item) => !!item._links?.["wp:action-sticky"],
35
+ filterBy: false
36
+ };
37
+ var sticky_default = stickyField;
38
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/sticky/index.tsx"],
4
+ "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 stickyField: Field< BasePost > = {\n\tid: 'sticky',\n\ttype: 'boolean',\n\tlabel: __( 'Sticky' ),\n\tdescription: __( 'Pin this post to the top of the blog.' ),\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => !! item._links?.[ 'wp:action-sticky' ],\n\tfilterBy: false,\n};\n\n/**\n * Sticky field for BasePost.\n */\nexport default stickyField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AAOnB,IAAM,cAAiC;AAAA,EACtC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,QAAS;AAAA,EACpB,iBAAa,gBAAI,uCAAwC;AAAA,EACzD,eAAe;AAAA,EACf,cAAc;AAAA,EACd,WAAW,CAAE,SAAU,CAAC,CAAE,KAAK,SAAU,kBAAmB;AAAA,EAC5D,UAAU;AACX;AAKA,IAAO,iBAAQ;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/types.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\ntype PostStatus =\n\t| 'publish'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface CommonPost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\tcontent: string | { raw: string; rendered: string };\n\ttype: string;\n\tid: string | number;\n\tblocks?: Object[];\n\t_links?: Links;\n}\n\ninterface Links {\n\t'predecessor-version'?: { href: string; id: number }[];\n\t'version-history'?: { href: string; count: number }[];\n\t[ key: string ]: { href: string }[] | undefined;\n}\n\ninterface Author {\n\tid: number;\n\tname: string;\n\tavatar_urls: Record< string, string >;\n}\n\ninterface EmbeddedAuthor {\n\tauthor: Author[];\n}\n\n/**\n * BasePost interface used for all post types.\n */\nexport interface BasePost extends CommonPost {\n\tcomment_status?: 'open' | 'closed';\n\texcerpt?: string | { raw: string; rendered: string };\n\tmeta?: Record< string, any >;\n\tparent?: number;\n\tpassword?: string;\n\ttemplate?: string;\n\tformat?: string;\n\tfeatured_media?: number;\n\tmenu_order?: number;\n\tping_status?: 'open' | 'closed';\n\tlink?: string;\n\tslug?: string;\n\tpermalink_template?: string;\n\tdate?: string;\n\tmodified?: string;\n\tauthor?: number;\n}\n\nexport interface BasePostWithEmbeddedAuthor extends BasePost {\n\t_embedded: EmbeddedAuthor;\n}\n\ninterface FeaturedMedia {\n\ttitle: {\n\t\trendered: string;\n\t};\n\tsource_url: string;\n\tmedia_details: {\n\t\tsizes: Record< string, { width: number; source_url: string } >;\n\t};\n}\n\ninterface EmbeddedFeaturedMedia {\n\t'wp:featuredmedia': FeaturedMedia[];\n}\n\nexport interface BasePostWithEmbeddedFeaturedMedia extends BasePost {\n\t_embedded: EmbeddedFeaturedMedia;\n}\n\nexport interface Template extends CommonPost {\n\ttype: 'wp_template';\n\tis_custom: boolean;\n\tsource: string;\n\torigin: string;\n\tplugin?: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface TemplatePart extends CommonPost {\n\ttype: 'wp_template_part';\n\tsource: string;\n\torigin: string;\n\thas_theme_file: boolean;\n\tid: string;\n\tarea: string;\n\tplugin?: string;\n}\n\nexport interface Pattern extends CommonPost {\n\tslug: string;\n\ttitle: { raw: string };\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = Template | TemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\ninterface EditorSupport {\n\tnotes?: boolean;\n}\n\nexport interface PostType {\n\tslug: string;\n\tviewable: boolean;\n\tsupports?: {\n\t\t'page-attributes'?: boolean;\n\t\ttitle?: boolean;\n\t\trevisions?: boolean;\n\t\tauthor?: string;\n\t\tthumbnail?: string;\n\t\tcomments?: string;\n\t\teditor?: boolean | [ EditorSupport ];\n\t\ttrackbacks?: boolean;\n\t\t'post-formats'?: boolean;\n\t};\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n\nexport interface MediaEditProps< Item >\n\textends Pick<\n\t\tDataFormControlProps< Item >,\n\t\t'data' | 'field' | 'onChange' | 'hideLabelFromVision' | 'validity'\n\t> {\n\t/**\n\t * Array of allowed media types (e.g., ['image', 'video']).\n\t *\n\t * @default ['image']\n\t */\n\tallowedTypes?: string[];\n\t/**\n\t * Whether to allow multiple media selections.\n\t *\n\t * @default false\n\t */\n\tmultiple?: boolean;\n\t/**\n\t * Whether to render in an expanded form.\n\t *\n\t * @default false\n\t */\n\tisExpanded?: boolean;\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\ntype PostStatus =\n\t| 'publish'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface CommonPost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\tcontent: string | { raw: string; rendered: string };\n\ttype: string;\n\tid: string | number;\n\tblocks?: Object[];\n\t_links?: Links;\n}\n\ninterface Links {\n\t'predecessor-version'?: { href: string; id: number }[];\n\t'version-history'?: { href: string; count: number }[];\n\t[ key: string ]: { href: string }[] | undefined;\n}\n\ninterface Author {\n\tid: number;\n\tname: string;\n\tavatar_urls: Record< string, string >;\n}\n\ninterface EmbeddedAuthor {\n\tauthor: Author[];\n}\n\n/**\n * BasePost interface used for all post types.\n */\nexport interface BasePost extends CommonPost {\n\tcomment_status?: 'open' | 'closed';\n\texcerpt?: string | { raw: string; rendered: string };\n\tmeta?: Record< string, any >;\n\tparent?: number;\n\tpassword?: string;\n\ttemplate?: string;\n\tformat?: string;\n\tfeatured_media?: number;\n\tmenu_order?: number;\n\tping_status?: 'open' | 'closed';\n\tlink?: string;\n\tslug?: string;\n\tsticky?: boolean;\n\tpermalink_template?: string;\n\tdate?: string;\n\tmodified?: string;\n\tauthor?: number;\n}\n\nexport interface BasePostWithEmbeddedAuthor extends BasePost {\n\t_embedded: EmbeddedAuthor;\n}\n\ninterface FeaturedMedia {\n\ttitle: {\n\t\trendered: string;\n\t};\n\tsource_url: string;\n\tmedia_details: {\n\t\tsizes: Record< string, { width: number; source_url: string } >;\n\t};\n}\n\ninterface EmbeddedFeaturedMedia {\n\t'wp:featuredmedia': FeaturedMedia[];\n}\n\nexport interface BasePostWithEmbeddedFeaturedMedia extends BasePost {\n\t_embedded: EmbeddedFeaturedMedia;\n}\n\nexport interface Template extends CommonPost {\n\ttype: 'wp_template';\n\tis_custom: boolean;\n\tsource: string;\n\torigin: string;\n\tplugin?: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface TemplatePart extends CommonPost {\n\ttype: 'wp_template_part';\n\tsource: string;\n\torigin: string;\n\thas_theme_file: boolean;\n\tid: string;\n\tarea: string;\n\tplugin?: string;\n}\n\nexport interface Pattern extends CommonPost {\n\tslug: string;\n\ttitle: { raw: string };\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = Template | TemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\ninterface EditorSupport {\n\tnotes?: boolean;\n}\n\nexport interface PostType {\n\tslug: string;\n\tviewable: boolean;\n\tsupports?: {\n\t\t'page-attributes'?: boolean;\n\t\ttitle?: boolean;\n\t\texcerpt?: boolean;\n\t\trevisions?: boolean;\n\t\tauthor?: string;\n\t\tthumbnail?: string;\n\t\tcomments?: string;\n\t\teditor?: boolean | [ EditorSupport ];\n\t\ttrackbacks?: boolean;\n\t\t'post-formats'?: boolean;\n\t};\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n\nexport interface MediaEditProps< Item >\n\textends Pick<\n\t\tDataFormControlProps< Item >,\n\t\t'data' | 'field' | 'onChange' | 'hideLabelFromVision' | 'validity'\n\t> {\n\t/**\n\t * Array of allowed media types (e.g., ['image', 'video']).\n\t *\n\t * @default ['image']\n\t */\n\tallowedTypes?: string[];\n\t/**\n\t * Whether to allow multiple media selections.\n\t *\n\t * @default false\n\t */\n\tmultiple?: boolean;\n\t/**\n\t * Whether to render in an expanded form.\n\t *\n\t * @default false\n\t */\n\tisExpanded?: boolean;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -7,6 +7,10 @@ var scheduledDateField = {
7
7
  getValue: ({ item }) => item.date,
8
8
  setValue: ({ value }) => ({ date: value }),
9
9
  isVisible: (item) => item.status === "future",
10
+ Edit: {
11
+ control: "datetime",
12
+ compact: true
13
+ },
10
14
  enableHiding: false,
11
15
  enableSorting: false,
12
16
  filterBy: false
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/fields/date/scheduled/index.tsx"],
4
- "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 scheduledDateField: Field< BasePost > = {\n\tid: 'scheduled_date',\n\ttype: 'datetime',\n\tlabel: __( 'Scheduled Date' ),\n\tgetValue: ( { item } ) => item.date,\n\tsetValue: ( { value } ) => ( { date: value } ),\n\tisVisible: ( item ) => item.status === 'future',\n\tenableHiding: false,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * ScheduledDate Field.\n */\nexport default scheduledDateField;\n"],
5
- "mappings": ";AAIA,SAAS,UAAU;AAOnB,IAAM,qBAAwC;AAAA,EAC7C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,gBAAiB;AAAA,EAC5B,UAAU,CAAE,EAAE,KAAK,MAAO,KAAK;AAAA,EAC/B,UAAU,CAAE,EAAE,MAAM,OAAS,EAAE,MAAM,MAAM;AAAA,EAC3C,WAAW,CAAE,SAAU,KAAK,WAAW;AAAA,EACvC,cAAc;AAAA,EACd,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,oBAAQ;",
4
+ "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 scheduledDateField: Field< BasePost > = {\n\tid: 'scheduled_date',\n\ttype: 'datetime',\n\tlabel: __( 'Scheduled Date' ),\n\tgetValue: ( { item } ) => item.date,\n\tsetValue: ( { value } ) => ( { date: value } ),\n\tisVisible: ( item ) => item.status === 'future',\n\tEdit: {\n\t\tcontrol: 'datetime',\n\t\tcompact: true,\n\t},\n\tenableHiding: false,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * ScheduledDate Field.\n */\nexport default scheduledDateField;\n"],
5
+ "mappings": ";AAIA,SAAS,UAAU;AAOnB,IAAM,qBAAwC;AAAA,EAC7C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,gBAAiB;AAAA,EAC5B,UAAU,CAAE,EAAE,KAAK,MAAO,KAAK;AAAA,EAC/B,UAAU,CAAE,EAAE,MAAM,OAAS,EAAE,MAAM,MAAM;AAAA,EAC3C,WAAW,CAAE,SAAU,KAAK,WAAW;AAAA,EACvC,MAAM;AAAA,IACL,SAAS;AAAA,IACT,SAAS;AAAA,EACV;AAAA,EACA,cAAc;AAAA,EACd,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,oBAAQ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,43 @@
1
+ // packages/fields/src/fields/excerpt/index.tsx
2
+ import { decodeEntities } from "@wordpress/html-entities";
3
+ import { __ } from "@wordpress/i18n";
4
+ import {
5
+ ExternalLink,
6
+ __experimentalText as Text
7
+ } from "@wordpress/components";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var excerptField = {
10
+ id: "excerpt",
11
+ type: "text",
12
+ label: __("Excerpt"),
13
+ placeholder: __("Add an excerpt"),
14
+ description: /* @__PURE__ */ jsx(
15
+ ExternalLink,
16
+ {
17
+ href: __(
18
+ "https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt"
19
+ ),
20
+ children: __("Learn more about manual excerpts")
21
+ }
22
+ ),
23
+ render: ({ item }) => {
24
+ let excerpt;
25
+ if (typeof item.excerpt === "string") {
26
+ excerpt = !!item.excerpt ? decodeEntities(item.excerpt) : __("Add an excerpt");
27
+ } else {
28
+ excerpt = decodeEntities(item.excerpt?.raw || "");
29
+ }
30
+ return /* @__PURE__ */ jsx(Text, { align: "left", numberOfLines: 3, truncate: true, children: excerpt });
31
+ },
32
+ Edit: {
33
+ control: "textarea",
34
+ rows: 4
35
+ },
36
+ enableSorting: false,
37
+ filterBy: false
38
+ };
39
+ var excerpt_default = excerptField;
40
+ export {
41
+ excerpt_default as default
42
+ };
43
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/excerpt/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tExternalLink,\n\t__experimentalText as Text,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nconst excerptField: Field< BasePost > = {\n\tid: 'excerpt',\n\ttype: 'text',\n\tlabel: __( 'Excerpt' ),\n\tplaceholder: __( 'Add an excerpt' ),\n\tdescription: (\n\t\t<ExternalLink\n\t\t\thref={ __(\n\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'\n\t\t\t) }\n\t\t>\n\t\t\t{ __( 'Learn more about manual excerpts' ) }\n\t\t</ExternalLink>\n\t),\n\trender: ( { item } ) => {\n\t\tlet excerpt;\n\t\tif ( typeof item.excerpt === 'string' ) {\n\t\t\texcerpt = !! item.excerpt\n\t\t\t\t? decodeEntities( item.excerpt )\n\t\t\t\t: __( 'Add an excerpt' );\n\t\t} else {\n\t\t\texcerpt = decodeEntities( item.excerpt?.raw || '' );\n\t\t}\n\t\treturn (\n\t\t\t<Text align=\"left\" numberOfLines={ 3 } truncate>\n\t\t\t\t{ excerpt }\n\t\t\t</Text>\n\t\t);\n\t},\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 4,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * Excerpt field for BasePost.\n */\nexport default excerptField;\n"],
5
+ "mappings": ";AAIA,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,sBAAsB;AAAA,OAChB;AAaL;AANF,IAAM,eAAkC;AAAA,EACvC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,SAAU;AAAA,EACrB,aAAa,GAAI,gBAAiB;AAAA,EAClC,aACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,QACN;AAAA,MACD;AAAA,MAEE,aAAI,kCAAmC;AAAA;AAAA,EAC1C;AAAA,EAED,QAAQ,CAAE,EAAE,KAAK,MAAO;AACvB,QAAI;AACJ,QAAK,OAAO,KAAK,YAAY,UAAW;AACvC,gBAAU,CAAC,CAAE,KAAK,UACf,eAAgB,KAAK,OAAQ,IAC7B,GAAI,gBAAiB;AAAA,IACzB,OAAO;AACN,gBAAU,eAAgB,KAAK,SAAS,OAAO,EAAG;AAAA,IACnD;AACA,WACC,oBAAC,QAAK,OAAM,QAAO,eAAgB,GAAI,UAAQ,MAC5C,mBACH;AAAA,EAEF;AAAA,EACA,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,kBAAQ;",
6
+ "names": []
7
+ }
@@ -17,15 +17,18 @@ import { default as default16 } from "./date/index.mjs";
17
17
  import { default as default17 } from "./date/scheduled/index.mjs";
18
18
  import { default as default18 } from "./author/index.mjs";
19
19
  import { default as default19 } from "./notes/index.mjs";
20
- import { default as default20 } from "./format/index.mjs";
21
- import { default as default21 } from "./post-content-info/index.mjs";
20
+ import { default as default20 } from "./excerpt/index.mjs";
21
+ import { default as default21 } from "./format/index.mjs";
22
+ import { default as default22 } from "./post-content-info/index.mjs";
23
+ import { default as default23 } from "./sticky/index.mjs";
22
24
  export {
23
25
  default18 as authorField,
24
26
  default13 as commentStatusField,
25
27
  default16 as dateField,
26
28
  default15 as discussionField,
29
+ default20 as excerptField,
27
30
  default8 as featuredImageField,
28
- default20 as formatField,
31
+ default21 as formatField,
29
32
  default19 as notesField,
30
33
  default7 as orderField,
31
34
  default4 as pageTitleField,
@@ -33,10 +36,11 @@ export {
33
36
  default11 as passwordField,
34
37
  default6 as patternTitleField,
35
38
  default14 as pingStatusField,
36
- default21 as postContentInfoField,
39
+ default22 as postContentInfoField,
37
40
  default17 as scheduledDateField,
38
41
  default2 as slugField,
39
42
  default12 as statusField,
43
+ default23 as stickyField,
40
44
  default9 as templateField,
41
45
  default5 as templateTitleField,
42
46
  default3 as titleField
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/fields/index.ts"],
4
- "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 pingStatusField } from './ping-status';\nexport { default as discussionField } from './discussion';\nexport { default as dateField } from './date';\nexport { default as scheduledDateField } from './date/scheduled';\nexport { default as authorField } from './author';\nexport { default as notesField } from './notes';\nexport { default as formatField } from './format';\nexport { default as postContentInfoField } from './post-content-info';\n"],
5
- "mappings": ";AAAA,SAAoB,WAAXA,gBAA4B;AACrC,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAoC;AAC7C,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAA4B;AACrC,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA6B;AACtC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAuC;",
4
+ "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 pingStatusField } from './ping-status';\nexport { default as discussionField } from './discussion';\nexport { default as dateField } from './date';\nexport { default as scheduledDateField } from './date/scheduled';\nexport { default as authorField } from './author';\nexport { default as notesField } from './notes';\nexport { default as excerptField } from './excerpt';\nexport { default as formatField } from './format';\nexport { default as postContentInfoField } from './post-content-info';\nexport { default as stickyField } from './sticky';\n"],
5
+ "mappings": ";AAAA,SAAoB,WAAXA,gBAA4B;AACrC,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAoC;AAC7C,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAA4B;AACrC,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA6B;AACtC,SAAoB,WAAXA,iBAA+B;AACxC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAuC;AAChD,SAAoB,WAAXA,iBAA8B;",
6
6
  "names": ["default"]
7
7
  }
@@ -0,0 +1,17 @@
1
+ // packages/fields/src/fields/sticky/index.tsx
2
+ import { __ } from "@wordpress/i18n";
3
+ var stickyField = {
4
+ id: "sticky",
5
+ type: "boolean",
6
+ label: __("Sticky"),
7
+ description: __("Pin this post to the top of the blog."),
8
+ enableSorting: false,
9
+ enableHiding: false,
10
+ isVisible: (item) => !!item._links?.["wp:action-sticky"],
11
+ filterBy: false
12
+ };
13
+ var sticky_default = stickyField;
14
+ export {
15
+ sticky_default as default
16
+ };
17
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/sticky/index.tsx"],
4
+ "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 stickyField: Field< BasePost > = {\n\tid: 'sticky',\n\ttype: 'boolean',\n\tlabel: __( 'Sticky' ),\n\tdescription: __( 'Pin this post to the top of the blog.' ),\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => !! item._links?.[ 'wp:action-sticky' ],\n\tfilterBy: false,\n};\n\n/**\n * Sticky field for BasePost.\n */\nexport default stickyField;\n"],
5
+ "mappings": ";AAIA,SAAS,UAAU;AAOnB,IAAM,cAAiC;AAAA,EACtC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,QAAS;AAAA,EACpB,aAAa,GAAI,uCAAwC;AAAA,EACzD,eAAe;AAAA,EACf,cAAc;AAAA,EACd,WAAW,CAAE,SAAU,CAAC,CAAE,KAAK,SAAU,kBAAmB;AAAA,EAC5D,UAAU;AACX;AAKA,IAAO,iBAAQ;",
6
+ "names": []
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/date/scheduled/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAE,QAAQ,CAUxC,CAAC;AAEF;;GAEG;AACH,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/date/scheduled/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAE,QAAQ,CAcxC,CAAC;AAEF;;GAEG;AACH,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { Field } from '@wordpress/dataviews';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import type { BasePost } from '../../types';
9
+ declare const excerptField: Field<BasePost>;
10
+ /**
11
+ * Excerpt field for BasePost.
12
+ */
13
+ export default excerptField;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/excerpt/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAQlD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,QAAA,MAAM,YAAY,EAAE,KAAK,CAAE,QAAQ,CAmClC,CAAC;AAEF;;GAEG;AACH,eAAe,YAAY,CAAC"}
@@ -16,6 +16,8 @@ export { default as dateField } from './date';
16
16
  export { default as scheduledDateField } from './date/scheduled';
17
17
  export { default as authorField } from './author';
18
18
  export { default as notesField } from './notes';
19
+ export { default as excerptField } from './excerpt';
19
20
  export { default as formatField } from './format';
20
21
  export { default as postContentInfoField } from './post-content-info';
22
+ export { default as stickyField } from './sticky';
21
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],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,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { Field } from '@wordpress/dataviews';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import type { BasePost } from '../../types';
9
+ declare const stickyField: Field<BasePost>;
10
+ /**
11
+ * Sticky field for BasePost.
12
+ */
13
+ export default stickyField;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/sticky/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,QAAA,MAAM,WAAW,EAAE,KAAK,CAAE,QAAQ,CASjC,CAAC;AAEF;;GAEG;AACH,eAAe,WAAW,CAAC"}
@@ -59,6 +59,7 @@ export interface BasePost extends CommonPost {
59
59
  ping_status?: 'open' | 'closed';
60
60
  link?: string;
61
61
  slug?: string;
62
+ sticky?: boolean;
62
63
  permalink_template?: string;
63
64
  date?: string;
64
65
  modified?: string;
@@ -126,6 +127,7 @@ export interface PostType {
126
127
  supports?: {
127
128
  'page-attributes'?: boolean;
128
129
  title?: boolean;
130
+ excerpt?: boolean;
129
131
  revisions?: boolean;
130
132
  author?: string;
131
133
  thumbnail?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MA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package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/fields",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -48,30 +48,30 @@
48
48
  ],
49
49
  "dependencies": {
50
50
  "@react-spring/web": "^9.4.5",
51
- "@wordpress/api-fetch": "^7.42.0",
52
- "@wordpress/base-styles": "^6.18.0",
53
- "@wordpress/blob": "^4.42.0",
54
- "@wordpress/blocks": "^15.15.0",
55
- "@wordpress/components": "^32.4.0",
56
- "@wordpress/compose": "^7.42.0",
57
- "@wordpress/core-data": "^7.42.0",
58
- "@wordpress/data": "^10.42.0",
59
- "@wordpress/dataviews": "^13.1.0",
60
- "@wordpress/date": "^5.42.0",
61
- "@wordpress/element": "^6.42.0",
62
- "@wordpress/hooks": "^4.42.0",
63
- "@wordpress/html-entities": "^4.42.0",
64
- "@wordpress/i18n": "^6.15.0",
65
- "@wordpress/icons": "^12.0.0",
66
- "@wordpress/media-utils": "^5.42.0",
67
- "@wordpress/notices": "^5.42.0",
68
- "@wordpress/patterns": "^2.42.0",
69
- "@wordpress/primitives": "^4.42.0",
70
- "@wordpress/private-apis": "^1.42.0",
71
- "@wordpress/router": "^1.42.0",
72
- "@wordpress/url": "^4.42.0",
73
- "@wordpress/warning": "^3.42.0",
74
- "@wordpress/wordcount": "^4.42.0",
51
+ "@wordpress/api-fetch": "^7.43.0",
52
+ "@wordpress/base-styles": "^6.19.0",
53
+ "@wordpress/blob": "^4.43.0",
54
+ "@wordpress/blocks": "^15.16.0",
55
+ "@wordpress/components": "^32.5.0",
56
+ "@wordpress/compose": "^7.43.0",
57
+ "@wordpress/core-data": "^7.43.0",
58
+ "@wordpress/data": "^10.43.0",
59
+ "@wordpress/dataviews": "^14.0.0",
60
+ "@wordpress/date": "^5.43.0",
61
+ "@wordpress/element": "^6.43.0",
62
+ "@wordpress/hooks": "^4.43.0",
63
+ "@wordpress/html-entities": "^4.43.0",
64
+ "@wordpress/i18n": "^6.16.0",
65
+ "@wordpress/icons": "^12.1.0",
66
+ "@wordpress/media-utils": "^5.43.0",
67
+ "@wordpress/notices": "^5.43.0",
68
+ "@wordpress/patterns": "^2.43.0",
69
+ "@wordpress/primitives": "^4.43.0",
70
+ "@wordpress/private-apis": "^1.43.0",
71
+ "@wordpress/router": "^1.43.0",
72
+ "@wordpress/url": "^4.43.0",
73
+ "@wordpress/warning": "^3.43.0",
74
+ "@wordpress/wordcount": "^4.43.0",
75
75
  "change-case": "4.1.2",
76
76
  "client-zip": "^2.4.5",
77
77
  "clsx": "2.1.1",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "c20787b1778ae64c2db65643b1c236309d68e6ba"
86
+ "gitHead": "2cea90674d11aa521ec3f71652fb3a6a4c383969"
87
87
  }
@@ -16,6 +16,10 @@ const scheduledDateField: Field< BasePost > = {
16
16
  getValue: ( { item } ) => item.date,
17
17
  setValue: ( { value } ) => ( { date: value } ),
18
18
  isVisible: ( item ) => item.status === 'future',
19
+ Edit: {
20
+ control: 'datetime',
21
+ compact: true,
22
+ },
19
23
  enableHiding: false,
20
24
  enableSorting: false,
21
25
  filterBy: false,
@@ -0,0 +1,57 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { Field } from '@wordpress/dataviews';
5
+ import { decodeEntities } from '@wordpress/html-entities';
6
+ import { __ } from '@wordpress/i18n';
7
+ import {
8
+ ExternalLink,
9
+ __experimentalText as Text,
10
+ } from '@wordpress/components';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import type { BasePost } from '../../types';
16
+
17
+ const excerptField: Field< BasePost > = {
18
+ id: 'excerpt',
19
+ type: 'text',
20
+ label: __( 'Excerpt' ),
21
+ placeholder: __( 'Add an excerpt' ),
22
+ description: (
23
+ <ExternalLink
24
+ href={ __(
25
+ 'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'
26
+ ) }
27
+ >
28
+ { __( 'Learn more about manual excerpts' ) }
29
+ </ExternalLink>
30
+ ),
31
+ render: ( { item } ) => {
32
+ let excerpt;
33
+ if ( typeof item.excerpt === 'string' ) {
34
+ excerpt = !! item.excerpt
35
+ ? decodeEntities( item.excerpt )
36
+ : __( 'Add an excerpt' );
37
+ } else {
38
+ excerpt = decodeEntities( item.excerpt?.raw || '' );
39
+ }
40
+ return (
41
+ <Text align="left" numberOfLines={ 3 } truncate>
42
+ { excerpt }
43
+ </Text>
44
+ );
45
+ },
46
+ Edit: {
47
+ control: 'textarea',
48
+ rows: 4,
49
+ },
50
+ enableSorting: false,
51
+ filterBy: false,
52
+ };
53
+
54
+ /**
55
+ * Excerpt field for BasePost.
56
+ */
57
+ export default excerptField;
@@ -16,5 +16,7 @@ export { default as dateField } from './date';
16
16
  export { default as scheduledDateField } from './date/scheduled';
17
17
  export { default as authorField } from './author';
18
18
  export { default as notesField } from './notes';
19
+ export { default as excerptField } from './excerpt';
19
20
  export { default as formatField } from './format';
20
21
  export { default as postContentInfoField } from './post-content-info';
22
+ export { default as stickyField } from './sticky';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { Field } from '@wordpress/dataviews';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import type { BasePost } from '../../types';
11
+
12
+ const stickyField: Field< BasePost > = {
13
+ id: 'sticky',
14
+ type: 'boolean',
15
+ label: __( 'Sticky' ),
16
+ description: __( 'Pin this post to the top of the blog.' ),
17
+ enableSorting: false,
18
+ enableHiding: false,
19
+ isVisible: ( item ) => !! item._links?.[ 'wp:action-sticky' ],
20
+ filterBy: false,
21
+ };
22
+
23
+ /**
24
+ * Sticky field for BasePost.
25
+ */
26
+ export default stickyField;
package/src/types.ts CHANGED
@@ -54,6 +54,7 @@ export interface BasePost extends CommonPost {
54
54
  ping_status?: 'open' | 'closed';
55
55
  link?: string;
56
56
  slug?: string;
57
+ sticky?: boolean;
57
58
  permalink_template?: string;
58
59
  date?: string;
59
60
  modified?: string;
@@ -127,6 +128,7 @@ export interface PostType {
127
128
  supports?: {
128
129
  'page-attributes'?: boolean;
129
130
  title?: boolean;
131
+ excerpt?: boolean;
130
132
  revisions?: boolean;
131
133
  author?: string;
132
134
  thumbnail?: string;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/fields/src/fields/template/utils.ts
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- getDefaultTemplateLabel: () => getDefaultTemplateLabel,
24
- getTemplateSlugToCheck: () => getTemplateSlugToCheck
25
- });
26
- module.exports = __toCommonJS(utils_exports);
27
- var import_core_data = require("@wordpress/core-data");
28
- var import_i18n = require("@wordpress/i18n");
29
- var import_utils = require("../../actions/utils.cjs");
30
- var import_lock_unlock = require("../../lock-unlock.cjs");
31
- function getTemplateSlugToCheck(postType, slug) {
32
- if (slug) {
33
- return postType === "page" ? `${postType}-${slug}` : `single-${postType}-${slug}`;
34
- }
35
- return postType === "page" ? "page" : `single-${postType}`;
36
- }
37
- function getDefaultTemplateLabel(select, postType, postId, slug) {
38
- if (!postType || !postId) {
39
- return (0, import_i18n.__)("Default template");
40
- }
41
- const homePage = (0, import_lock_unlock.unlock)(select(import_core_data.store)).getHomePage();
42
- if (postType === "page" && homePage?.postType === "page" && homePage?.postId === String(postId)) {
43
- const templates = select(import_core_data.store).getEntityRecords(
44
- "postType",
45
- "wp_template",
46
- { per_page: -1 }
47
- );
48
- const frontPage = templates?.find(
49
- (t) => t.slug === "front-page"
50
- );
51
- if (frontPage) {
52
- return (0, import_utils.getItemTitle)(frontPage);
53
- }
54
- }
55
- const postsPageId = (0, import_lock_unlock.unlock)(select(import_core_data.store)).getPostsPageId();
56
- if (postType === "page" && postsPageId === String(postId)) {
57
- const templateId2 = select(import_core_data.store).getDefaultTemplateId({
58
- slug: "home"
59
- });
60
- if (templateId2) {
61
- const template2 = select(import_core_data.store).getEntityRecord(
62
- "postType",
63
- "wp_template",
64
- templateId2
65
- );
66
- if (template2) {
67
- return (0, import_utils.getItemTitle)(template2);
68
- }
69
- }
70
- return (0, import_i18n.__)("Default template");
71
- }
72
- const slugToCheck = getTemplateSlugToCheck(postType, slug);
73
- const templateId = select(import_core_data.store).getDefaultTemplateId({
74
- slug: slugToCheck
75
- });
76
- if (!templateId) {
77
- return (0, import_i18n.__)("Default template");
78
- }
79
- const template = select(import_core_data.store).getEntityRecord(
80
- "postType",
81
- "wp_template",
82
- templateId
83
- );
84
- return template ? (0, import_utils.getItemTitle)(template) : (0, import_i18n.__)("Default template");
85
- }
86
- // Annotate the CommonJS export names for ESM import in node:
87
- 0 && (module.exports = {
88
- getDefaultTemplateLabel,
89
- getTemplateSlugToCheck
90
- });
91
- //# sourceMappingURL=utils.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/fields/template/utils.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../actions/utils';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Compute the template slug to look up in the template hierarchy.\n *\n * In `draft` status we might not have a slug available, so we use the\n * `single` post type template slug (e.g. page, single-post,\n * single-product, etc.). Pages do not need the `single` prefix to be\n * prioritised through template hierarchy.\n *\n * @param postType The post type.\n * @param slug The post slug.\n */\nexport function getTemplateSlugToCheck(\n\tpostType: string,\n\tslug: string | undefined\n): string {\n\tif ( slug ) {\n\t\treturn postType === 'page'\n\t\t\t? `${ postType }-${ slug }`\n\t\t\t: `single-${ postType }-${ slug }`;\n\t}\n\treturn postType === 'page' ? 'page' : `single-${ postType }`;\n}\n\n/**\n * Resolve the human-readable label for the default template that would\n * apply to a post, given its type, ID and slug. Meant to be called inside a\n * `useSelect` callback (receives `select` as its first argument).\n *\n * @param select The `select` function from a `useSelect` callback.\n * @param postType The post type.\n * @param postId The post ID.\n * @param slug The post slug.\n */\nexport function getDefaultTemplateLabel(\n\tselect: ( store: typeof coreStore ) => any,\n\tpostType: string | undefined,\n\tpostId: string | number | undefined,\n\tslug: string | undefined\n): string {\n\tif ( ! postType || ! postId ) {\n\t\treturn __( 'Default template' );\n\t}\n\n\t// For the front page, we always use the front page template if existing.\n\tconst homePage = unlock( select( coreStore ) ).getHomePage();\n\tif (\n\t\tpostType === 'page' &&\n\t\thomePage?.postType === 'page' &&\n\t\thomePage?.postId === String( postId )\n\t) {\n\t\t// The /lookup endpoint cannot currently handle a lookup\n\t\t// when a page is set as the front page, so specifically in\n\t\t// that case, we want to check if there is a front page\n\t\t// template, and instead of falling back to the home\n\t\t// template, we want to fall back to the page template.\n\t\tconst templates = select( coreStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\t{ per_page: -1 }\n\t\t);\n\t\tconst frontPage = templates?.find(\n\t\t\t( t: WpTemplate ) => t.slug === 'front-page'\n\t\t);\n\t\tif ( frontPage ) {\n\t\t\treturn getItemTitle( frontPage );\n\t\t}\n\t\t// If no front page template is found, continue with the\n\t\t// logic below (fetching the page template).\n\t}\n\n\tconst postsPageId = unlock( select( coreStore ) ).getPostsPageId();\n\t// Check if the current page is the posts page.\n\tif ( postType === 'page' && postsPageId === String( postId ) ) {\n\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\tslug: 'home',\n\t\t} );\n\t\tif ( templateId ) {\n\t\t\tconst template = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\ttemplateId\n\t\t\t);\n\t\t\tif ( template ) {\n\t\t\t\treturn getItemTitle( template );\n\t\t\t}\n\t\t}\n\t\treturn __( 'Default template' );\n\t}\n\n\tconst slugToCheck = getTemplateSlugToCheck( postType, slug );\n\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\tslug: slugToCheck,\n\t} );\n\n\tif ( ! templateId ) {\n\t\treturn __( 'Default template' );\n\t}\n\n\tconst template = select( coreStore ).getEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplateId\n\t);\n\n\treturn template ? getItemTitle( template ) : __( 'Default template' );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAmC;AAEnC,kBAAmB;AAKnB,mBAA6B;AAC7B,yBAAuB;AAahB,SAAS,uBACf,UACA,MACS;AACT,MAAK,MAAO;AACX,WAAO,aAAa,SACjB,GAAI,QAAS,IAAK,IAAK,KACvB,UAAW,QAAS,IAAK,IAAK;AAAA,EAClC;AACA,SAAO,aAAa,SAAS,SAAS,UAAW,QAAS;AAC3D;AAYO,SAAS,wBACf,QACA,UACA,QACA,MACS;AACT,MAAK,CAAE,YAAY,CAAE,QAAS;AAC7B,eAAO,gBAAI,kBAAmB;AAAA,EAC/B;AAGA,QAAM,eAAW,2BAAQ,OAAQ,iBAAAA,KAAU,CAAE,EAAE,YAAY;AAC3D,MACC,aAAa,UACb,UAAU,aAAa,UACvB,UAAU,WAAW,OAAQ,MAAO,GACnC;AAMD,UAAM,YAAY,OAAQ,iBAAAA,KAAU,EAAE;AAAA,MACrC;AAAA,MACA;AAAA,MACA,EAAE,UAAU,GAAG;AAAA,IAChB;AACA,UAAM,YAAY,WAAW;AAAA,MAC5B,CAAE,MAAmB,EAAE,SAAS;AAAA,IACjC;AACA,QAAK,WAAY;AAChB,iBAAO,2BAAc,SAAU;AAAA,IAChC;AAAA,EAGD;AAEA,QAAM,kBAAc,2BAAQ,OAAQ,iBAAAA,KAAU,CAAE,EAAE,eAAe;AAEjE,MAAK,aAAa,UAAU,gBAAgB,OAAQ,MAAO,GAAI;AAC9D,UAAMC,cAAa,OAAQ,iBAAAD,KAAU,EAAE,qBAAsB;AAAA,MAC5D,MAAM;AAAA,IACP,CAAE;AACF,QAAKC,aAAa;AACjB,YAAMC,YAAW,OAAQ,iBAAAF,KAAU,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACAC;AAAA,MACD;AACA,UAAKC,WAAW;AACf,mBAAO,2BAAcA,SAAS;AAAA,MAC/B;AAAA,IACD;AACA,eAAO,gBAAI,kBAAmB;AAAA,EAC/B;AAEA,QAAM,cAAc,uBAAwB,UAAU,IAAK;AAC3D,QAAM,aAAa,OAAQ,iBAAAF,KAAU,EAAE,qBAAsB;AAAA,IAC5D,MAAM;AAAA,EACP,CAAE;AAEF,MAAK,CAAE,YAAa;AACnB,eAAO,gBAAI,kBAAmB;AAAA,EAC/B;AAEA,QAAM,WAAW,OAAQ,iBAAAA,KAAU,EAAE;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,SAAO,eAAW,2BAAc,QAAS,QAAI,gBAAI,kBAAmB;AACrE;",
6
- "names": ["coreStore", "templateId", "template"]
7
- }
@@ -1,65 +0,0 @@
1
- // packages/fields/src/fields/template/utils.ts
2
- import { store as coreStore } from "@wordpress/core-data";
3
- import { __ } from "@wordpress/i18n";
4
- import { getItemTitle } from "../../actions/utils.mjs";
5
- import { unlock } from "../../lock-unlock.mjs";
6
- function getTemplateSlugToCheck(postType, slug) {
7
- if (slug) {
8
- return postType === "page" ? `${postType}-${slug}` : `single-${postType}-${slug}`;
9
- }
10
- return postType === "page" ? "page" : `single-${postType}`;
11
- }
12
- function getDefaultTemplateLabel(select, postType, postId, slug) {
13
- if (!postType || !postId) {
14
- return __("Default template");
15
- }
16
- const homePage = unlock(select(coreStore)).getHomePage();
17
- if (postType === "page" && homePage?.postType === "page" && homePage?.postId === String(postId)) {
18
- const templates = select(coreStore).getEntityRecords(
19
- "postType",
20
- "wp_template",
21
- { per_page: -1 }
22
- );
23
- const frontPage = templates?.find(
24
- (t) => t.slug === "front-page"
25
- );
26
- if (frontPage) {
27
- return getItemTitle(frontPage);
28
- }
29
- }
30
- const postsPageId = unlock(select(coreStore)).getPostsPageId();
31
- if (postType === "page" && postsPageId === String(postId)) {
32
- const templateId2 = select(coreStore).getDefaultTemplateId({
33
- slug: "home"
34
- });
35
- if (templateId2) {
36
- const template2 = select(coreStore).getEntityRecord(
37
- "postType",
38
- "wp_template",
39
- templateId2
40
- );
41
- if (template2) {
42
- return getItemTitle(template2);
43
- }
44
- }
45
- return __("Default template");
46
- }
47
- const slugToCheck = getTemplateSlugToCheck(postType, slug);
48
- const templateId = select(coreStore).getDefaultTemplateId({
49
- slug: slugToCheck
50
- });
51
- if (!templateId) {
52
- return __("Default template");
53
- }
54
- const template = select(coreStore).getEntityRecord(
55
- "postType",
56
- "wp_template",
57
- templateId
58
- );
59
- return template ? getItemTitle(template) : __("Default template");
60
- }
61
- export {
62
- getDefaultTemplateLabel,
63
- getTemplateSlugToCheck
64
- };
65
- //# sourceMappingURL=utils.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/fields/template/utils.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../actions/utils';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Compute the template slug to look up in the template hierarchy.\n *\n * In `draft` status we might not have a slug available, so we use the\n * `single` post type template slug (e.g. page, single-post,\n * single-product, etc.). Pages do not need the `single` prefix to be\n * prioritised through template hierarchy.\n *\n * @param postType The post type.\n * @param slug The post slug.\n */\nexport function getTemplateSlugToCheck(\n\tpostType: string,\n\tslug: string | undefined\n): string {\n\tif ( slug ) {\n\t\treturn postType === 'page'\n\t\t\t? `${ postType }-${ slug }`\n\t\t\t: `single-${ postType }-${ slug }`;\n\t}\n\treturn postType === 'page' ? 'page' : `single-${ postType }`;\n}\n\n/**\n * Resolve the human-readable label for the default template that would\n * apply to a post, given its type, ID and slug. Meant to be called inside a\n * `useSelect` callback (receives `select` as its first argument).\n *\n * @param select The `select` function from a `useSelect` callback.\n * @param postType The post type.\n * @param postId The post ID.\n * @param slug The post slug.\n */\nexport function getDefaultTemplateLabel(\n\tselect: ( store: typeof coreStore ) => any,\n\tpostType: string | undefined,\n\tpostId: string | number | undefined,\n\tslug: string | undefined\n): string {\n\tif ( ! postType || ! postId ) {\n\t\treturn __( 'Default template' );\n\t}\n\n\t// For the front page, we always use the front page template if existing.\n\tconst homePage = unlock( select( coreStore ) ).getHomePage();\n\tif (\n\t\tpostType === 'page' &&\n\t\thomePage?.postType === 'page' &&\n\t\thomePage?.postId === String( postId )\n\t) {\n\t\t// The /lookup endpoint cannot currently handle a lookup\n\t\t// when a page is set as the front page, so specifically in\n\t\t// that case, we want to check if there is a front page\n\t\t// template, and instead of falling back to the home\n\t\t// template, we want to fall back to the page template.\n\t\tconst templates = select( coreStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\t{ per_page: -1 }\n\t\t);\n\t\tconst frontPage = templates?.find(\n\t\t\t( t: WpTemplate ) => t.slug === 'front-page'\n\t\t);\n\t\tif ( frontPage ) {\n\t\t\treturn getItemTitle( frontPage );\n\t\t}\n\t\t// If no front page template is found, continue with the\n\t\t// logic below (fetching the page template).\n\t}\n\n\tconst postsPageId = unlock( select( coreStore ) ).getPostsPageId();\n\t// Check if the current page is the posts page.\n\tif ( postType === 'page' && postsPageId === String( postId ) ) {\n\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\tslug: 'home',\n\t\t} );\n\t\tif ( templateId ) {\n\t\t\tconst template = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\ttemplateId\n\t\t\t);\n\t\t\tif ( template ) {\n\t\t\t\treturn getItemTitle( template );\n\t\t\t}\n\t\t}\n\t\treturn __( 'Default template' );\n\t}\n\n\tconst slugToCheck = getTemplateSlugToCheck( postType, slug );\n\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\tslug: slugToCheck,\n\t} );\n\n\tif ( ! templateId ) {\n\t\treturn __( 'Default template' );\n\t}\n\n\tconst template = select( coreStore ).getEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplateId\n\t);\n\n\treturn template ? getItemTitle( template ) : __( 'Default template' );\n}\n"],
5
- "mappings": ";AAGA,SAAS,SAAS,iBAAiB;AAEnC,SAAS,UAAU;AAKnB,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AAahB,SAAS,uBACf,UACA,MACS;AACT,MAAK,MAAO;AACX,WAAO,aAAa,SACjB,GAAI,QAAS,IAAK,IAAK,KACvB,UAAW,QAAS,IAAK,IAAK;AAAA,EAClC;AACA,SAAO,aAAa,SAAS,SAAS,UAAW,QAAS;AAC3D;AAYO,SAAS,wBACf,QACA,UACA,QACA,MACS;AACT,MAAK,CAAE,YAAY,CAAE,QAAS;AAC7B,WAAO,GAAI,kBAAmB;AAAA,EAC/B;AAGA,QAAM,WAAW,OAAQ,OAAQ,SAAU,CAAE,EAAE,YAAY;AAC3D,MACC,aAAa,UACb,UAAU,aAAa,UACvB,UAAU,WAAW,OAAQ,MAAO,GACnC;AAMD,UAAM,YAAY,OAAQ,SAAU,EAAE;AAAA,MACrC;AAAA,MACA;AAAA,MACA,EAAE,UAAU,GAAG;AAAA,IAChB;AACA,UAAM,YAAY,WAAW;AAAA,MAC5B,CAAE,MAAmB,EAAE,SAAS;AAAA,IACjC;AACA,QAAK,WAAY;AAChB,aAAO,aAAc,SAAU;AAAA,IAChC;AAAA,EAGD;AAEA,QAAM,cAAc,OAAQ,OAAQ,SAAU,CAAE,EAAE,eAAe;AAEjE,MAAK,aAAa,UAAU,gBAAgB,OAAQ,MAAO,GAAI;AAC9D,UAAMA,cAAa,OAAQ,SAAU,EAAE,qBAAsB;AAAA,MAC5D,MAAM;AAAA,IACP,CAAE;AACF,QAAKA,aAAa;AACjB,YAAMC,YAAW,OAAQ,SAAU,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACAD;AAAA,MACD;AACA,UAAKC,WAAW;AACf,eAAO,aAAcA,SAAS;AAAA,MAC/B;AAAA,IACD;AACA,WAAO,GAAI,kBAAmB;AAAA,EAC/B;AAEA,QAAM,cAAc,uBAAwB,UAAU,IAAK;AAC3D,QAAM,aAAa,OAAQ,SAAU,EAAE,qBAAsB;AAAA,IAC5D,MAAM;AAAA,EACP,CAAE;AAEF,MAAK,CAAE,YAAa;AACnB,WAAO,GAAI,kBAAmB;AAAA,EAC/B;AAEA,QAAM,WAAW,OAAQ,SAAU,EAAE;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,SAAO,WAAW,aAAc,QAAS,IAAI,GAAI,kBAAmB;AACrE;",
6
- "names": ["templateId", "template"]
7
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store as coreStore } from '@wordpress/core-data';
5
- /**
6
- * Compute the template slug to look up in the template hierarchy.
7
- *
8
- * In `draft` status we might not have a slug available, so we use the
9
- * `single` post type template slug (e.g. page, single-post,
10
- * single-product, etc.). Pages do not need the `single` prefix to be
11
- * prioritised through template hierarchy.
12
- *
13
- * @param postType The post type.
14
- * @param slug The post slug.
15
- */
16
- export declare function getTemplateSlugToCheck(postType: string, slug: string | undefined): string;
17
- /**
18
- * Resolve the human-readable label for the default template that would
19
- * apply to a post, given its type, ID and slug. Meant to be called inside a
20
- * `useSelect` callback (receives `select` as its first argument).
21
- *
22
- * @param select The `select` function from a `useSelect` callback.
23
- * @param postType The post type.
24
- * @param postId The post ID.
25
- * @param slug The post slug.
26
- */
27
- export declare function getDefaultTemplateLabel(select: (store: typeof coreStore) => any, postType: string | undefined, postId: string | number | undefined, slug: string | undefined): string;
28
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/fields/template/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAU1D;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GAAG,SAAS,GACtB,MAAM,CAOR;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,CAAE,KAAK,EAAE,OAAO,SAAS,KAAM,GAAG,EAC1C,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACnC,IAAI,EAAE,MAAM,GAAG,SAAS,GACtB,MAAM,CAmER"}
@@ -1,119 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store as coreStore } from '@wordpress/core-data';
5
- import type { WpTemplate } from '@wordpress/core-data';
6
- import { __ } from '@wordpress/i18n';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import { getItemTitle } from '../../actions/utils';
12
- import { unlock } from '../../lock-unlock';
13
-
14
- /**
15
- * Compute the template slug to look up in the template hierarchy.
16
- *
17
- * In `draft` status we might not have a slug available, so we use the
18
- * `single` post type template slug (e.g. page, single-post,
19
- * single-product, etc.). Pages do not need the `single` prefix to be
20
- * prioritised through template hierarchy.
21
- *
22
- * @param postType The post type.
23
- * @param slug The post slug.
24
- */
25
- export function getTemplateSlugToCheck(
26
- postType: string,
27
- slug: string | undefined
28
- ): string {
29
- if ( slug ) {
30
- return postType === 'page'
31
- ? `${ postType }-${ slug }`
32
- : `single-${ postType }-${ slug }`;
33
- }
34
- return postType === 'page' ? 'page' : `single-${ postType }`;
35
- }
36
-
37
- /**
38
- * Resolve the human-readable label for the default template that would
39
- * apply to a post, given its type, ID and slug. Meant to be called inside a
40
- * `useSelect` callback (receives `select` as its first argument).
41
- *
42
- * @param select The `select` function from a `useSelect` callback.
43
- * @param postType The post type.
44
- * @param postId The post ID.
45
- * @param slug The post slug.
46
- */
47
- export function getDefaultTemplateLabel(
48
- select: ( store: typeof coreStore ) => any,
49
- postType: string | undefined,
50
- postId: string | number | undefined,
51
- slug: string | undefined
52
- ): string {
53
- if ( ! postType || ! postId ) {
54
- return __( 'Default template' );
55
- }
56
-
57
- // For the front page, we always use the front page template if existing.
58
- const homePage = unlock( select( coreStore ) ).getHomePage();
59
- if (
60
- postType === 'page' &&
61
- homePage?.postType === 'page' &&
62
- homePage?.postId === String( postId )
63
- ) {
64
- // The /lookup endpoint cannot currently handle a lookup
65
- // when a page is set as the front page, so specifically in
66
- // that case, we want to check if there is a front page
67
- // template, and instead of falling back to the home
68
- // template, we want to fall back to the page template.
69
- const templates = select( coreStore ).getEntityRecords(
70
- 'postType',
71
- 'wp_template',
72
- { per_page: -1 }
73
- );
74
- const frontPage = templates?.find(
75
- ( t: WpTemplate ) => t.slug === 'front-page'
76
- );
77
- if ( frontPage ) {
78
- return getItemTitle( frontPage );
79
- }
80
- // If no front page template is found, continue with the
81
- // logic below (fetching the page template).
82
- }
83
-
84
- const postsPageId = unlock( select( coreStore ) ).getPostsPageId();
85
- // Check if the current page is the posts page.
86
- if ( postType === 'page' && postsPageId === String( postId ) ) {
87
- const templateId = select( coreStore ).getDefaultTemplateId( {
88
- slug: 'home',
89
- } );
90
- if ( templateId ) {
91
- const template = select( coreStore ).getEntityRecord(
92
- 'postType',
93
- 'wp_template',
94
- templateId
95
- );
96
- if ( template ) {
97
- return getItemTitle( template );
98
- }
99
- }
100
- return __( 'Default template' );
101
- }
102
-
103
- const slugToCheck = getTemplateSlugToCheck( postType, slug );
104
- const templateId = select( coreStore ).getDefaultTemplateId( {
105
- slug: slugToCheck,
106
- } );
107
-
108
- if ( ! templateId ) {
109
- return __( 'Default template' );
110
- }
111
-
112
- const template = select( coreStore ).getEntityRecord(
113
- 'postType',
114
- 'wp_template',
115
- templateId
116
- );
117
-
118
- return template ? getItemTitle( template ) : __( 'Default template' );
119
- }