@wordpress/fields 0.33.0 → 0.33.1-next.v.202603161435.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 (89) hide show
  1. package/README.md +12 -0
  2. package/build/fields/author/author-view.cjs +4 -4
  3. package/build/fields/author/author-view.cjs.map +2 -2
  4. package/build/fields/date/scheduled/index.cjs +39 -0
  5. package/build/fields/date/scheduled/index.cjs.map +7 -0
  6. package/build/fields/featured-image/index.cjs +1 -0
  7. package/build/fields/featured-image/index.cjs.map +2 -2
  8. package/build/fields/format/index.cjs +69 -0
  9. package/build/fields/format/index.cjs.map +7 -0
  10. package/build/fields/index.cjs +9 -0
  11. package/build/fields/index.cjs.map +2 -2
  12. package/build/fields/parent/parent-edit.cjs +4 -10
  13. package/build/fields/parent/parent-edit.cjs.map +2 -2
  14. package/build/fields/post-content-info/index.cjs +49 -0
  15. package/build/fields/post-content-info/index.cjs.map +7 -0
  16. package/build/fields/post-content-info/post-content-info-view.cjs +76 -0
  17. package/build/fields/post-content-info/post-content-info-view.cjs.map +7 -0
  18. package/build/fields/status/status-view.cjs +1 -1
  19. package/build/fields/status/status-view.cjs.map +2 -2
  20. package/build/fields/template/hooks.cjs +35 -2
  21. package/build/fields/template/hooks.cjs.map +2 -2
  22. package/build/fields/template/template-edit.cjs +64 -12
  23. package/build/fields/template/template-edit.cjs.map +2 -2
  24. package/build/fields/template/template-view.cjs +23 -2
  25. package/build/fields/template/template-view.cjs.map +2 -2
  26. package/build/types.cjs.map +1 -1
  27. package/build-module/fields/author/author-view.mjs +4 -4
  28. package/build-module/fields/author/author-view.mjs.map +2 -2
  29. package/build-module/fields/date/scheduled/index.mjs +18 -0
  30. package/build-module/fields/date/scheduled/index.mjs.map +7 -0
  31. package/build-module/fields/featured-image/index.mjs +1 -0
  32. package/build-module/fields/featured-image/index.mjs.map +2 -2
  33. package/build-module/fields/format/index.mjs +48 -0
  34. package/build-module/fields/format/index.mjs.map +7 -0
  35. package/build-module/fields/index.mjs +10 -4
  36. package/build-module/fields/index.mjs.map +2 -2
  37. package/build-module/fields/parent/parent-edit.mjs +4 -10
  38. package/build-module/fields/parent/parent-edit.mjs.map +2 -2
  39. package/build-module/fields/post-content-info/index.mjs +18 -0
  40. package/build-module/fields/post-content-info/index.mjs.map +7 -0
  41. package/build-module/fields/post-content-info/post-content-info-view.mjs +58 -0
  42. package/build-module/fields/post-content-info/post-content-info-view.mjs.map +7 -0
  43. package/build-module/fields/status/status-view.mjs +1 -1
  44. package/build-module/fields/status/status-view.mjs.map +2 -2
  45. package/build-module/fields/template/hooks.mjs +33 -1
  46. package/build-module/fields/template/hooks.mjs.map +2 -2
  47. package/build-module/fields/template/template-edit.mjs +65 -13
  48. package/build-module/fields/template/template-edit.mjs.map +2 -2
  49. package/build-module/fields/template/template-view.mjs +24 -3
  50. package/build-module/fields/template/template-view.mjs.map +2 -2
  51. package/build-style/style-rtl.css +50 -0
  52. package/build-style/style.css +50 -0
  53. package/build-types/fields/date/scheduled/index.d.ts +14 -0
  54. package/build-types/fields/date/scheduled/index.d.ts.map +1 -0
  55. package/build-types/fields/featured-image/index.d.ts.map +1 -1
  56. package/build-types/fields/format/index.d.ts +14 -0
  57. package/build-types/fields/format/index.d.ts.map +1 -0
  58. package/build-types/fields/index.d.ts +3 -0
  59. package/build-types/fields/index.d.ts.map +1 -1
  60. package/build-types/fields/parent/parent-edit.d.ts.map +1 -1
  61. package/build-types/fields/post-content-info/index.d.ts +14 -0
  62. package/build-types/fields/post-content-info/index.d.ts.map +1 -0
  63. package/build-types/fields/post-content-info/post-content-info-view.d.ts +8 -0
  64. package/build-types/fields/post-content-info/post-content-info-view.d.ts.map +1 -0
  65. package/build-types/fields/template/hooks.d.ts +8 -0
  66. package/build-types/fields/template/hooks.d.ts.map +1 -1
  67. package/build-types/fields/template/template-edit.d.ts +1 -1
  68. package/build-types/fields/template/template-edit.d.ts.map +1 -1
  69. package/build-types/fields/template/template-view.d.ts +1 -1
  70. package/build-types/fields/template/template-view.d.ts.map +1 -1
  71. package/build-types/types.d.ts +1 -0
  72. package/build-types/types.d.ts.map +1 -1
  73. package/package.json +26 -26
  74. package/src/fields/author/author-view.tsx +7 -7
  75. package/src/fields/author/style.scss +46 -0
  76. package/src/fields/date/scheduled/index.tsx +27 -0
  77. package/src/fields/featured-image/index.tsx +1 -0
  78. package/src/fields/format/index.ts +62 -0
  79. package/src/fields/index.ts +3 -0
  80. package/src/fields/parent/parent-edit.tsx +4 -10
  81. package/src/fields/post-content-info/index.ts +27 -0
  82. package/src/fields/post-content-info/post-content-info-view.tsx +88 -0
  83. package/src/fields/status/status-view.tsx +1 -1
  84. package/src/fields/status/style.scss +10 -0
  85. package/src/fields/template/hooks.ts +48 -0
  86. package/src/fields/template/template-edit.tsx +80 -23
  87. package/src/fields/template/template-view.tsx +33 -3
  88. package/src/style.scss +2 -0
  89. package/src/types.ts +1 -0
package/README.md CHANGED
@@ -71,6 +71,10 @@ Export action as JSON for Pattern.
71
71
 
72
72
  Featured Image field for BasePostWithEmbeddedFeaturedMedia.
73
73
 
74
+ ### formatField
75
+
76
+ Format field for BasePost.
77
+
74
78
  ### MediaEdit
75
79
 
76
80
  A media edit control component that provides a media picker UI with upload functionality for selecting WordPress media attachments. Supports both the traditional WordPress media library and the experimental DataViews media modal.
@@ -148,6 +152,10 @@ Delete action for PostWithPermissions.
148
152
 
149
153
  Ping status field for BasePost.
150
154
 
155
+ ### postContentInfoField
156
+
157
+ Post content information field for BasePost.
158
+
151
159
  ### PostType
152
160
 
153
161
  Undocumented declaration.
@@ -168,6 +176,10 @@ Reset action for Template and TemplatePart.
168
176
 
169
177
  Restore action for PostWithPermissions.
170
178
 
179
+ ### scheduledDateField
180
+
181
+ ScheduledDate Field.
182
+
171
183
  ### slugField
172
184
 
173
185
  Slug field for BasePost.
@@ -45,7 +45,7 @@ function AuthorView({ item }) {
45
45
  const authorId = item?.author;
46
46
  const embeddedAuthorId = item?._embedded?.author?.[0]?.id;
47
47
  const shouldFetch = Boolean(
48
- authorId && embeddedAuthorId && authorId !== embeddedAuthorId
48
+ authorId && (!embeddedAuthorId || authorId !== embeddedAuthorId)
49
49
  );
50
50
  const author = (0, import_data.useSelect)(
51
51
  (select) => {
@@ -64,7 +64,7 @@ function AuthorView({ item }) {
64
64
  !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
65
  "div",
66
66
  {
67
- className: (0, import_clsx.default)("page-templates-author-field__avatar", {
67
+ className: (0, import_clsx.default)("fields-controls__author-avatar", {
68
68
  "is-loaded": isImageLoaded
69
69
  }),
70
70
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -77,8 +77,8 @@ function AuthorView({ item }) {
77
77
  )
78
78
  }
79
79
  ),
80
- !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "page-templates-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon: import_icons.commentAuthorAvatar }) }),
81
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "page-templates-author-field__name", children: text })
80
+ !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "fields-controls__author-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon: import_icons.commentAuthorAvatar }) }),
81
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "fields-controls__author-name", children: text })
82
82
  ] });
83
83
  }
84
84
  var author_view_default = AuthorView;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/author/author-view.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { commentAuthorAvatar as authorIcon } from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePostWithEmbeddedAuthor } from '../../types';\n\nfunction AuthorView( { item }: { item: BasePostWithEmbeddedAuthor } ) {\n\t// When editing, item.author may differ from _embedded.author (which preserves\n\t// the saved record). Fetch the updated author only when they differ, so the\n\t// view reflects edits while lists preserve original data.\n\tconst authorId = item?.author;\n\tconst embeddedAuthorId = item?._embedded?.author?.[ 0 ]?.id;\n\tconst shouldFetch = Boolean(\n\t\tauthorId && embeddedAuthorId && authorId !== embeddedAuthorId\n\t);\n\tconst author = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! shouldFetch ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\t// This doesn't make extra REST requests because the records are\n\t\t\t// already in the store from the field's getElements function.\n\t\t\treturn authorId\n\t\t\t\t? getEntityRecord( 'root', 'user', authorId )\n\t\t\t\t: null;\n\t\t},\n\t\t[ authorId, shouldFetch ]\n\t);\n\t// Use fetched author if available, otherwise use _embedded.\n\tconst text = author?.name || item?._embedded?.author?.[ 0 ]?.name;\n\tconst imageUrl =\n\t\tauthor?.avatar_urls?.[ 48 ] ||\n\t\titem?._embedded?.author?.[ 0 ]?.avatar_urls?.[ 48 ];\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default AuthorView;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,qBAAyB;AACzB,mBAAkD;AAClD,wBAAqD;AACrD,kBAA0B;AAC1B,uBAAmC;AAqCjC;AA9BF,SAAS,WAAY,EAAE,KAAK,GAA0C;AAIrE,QAAM,WAAW,MAAM;AACvB,QAAM,mBAAmB,MAAM,WAAW,SAAU,CAAE,GAAG;AACzD,QAAM,cAAc;AAAA,IACnB,YAAY,oBAAoB,aAAa;AAAA,EAC9C;AACA,QAAM,aAAS;AAAA,IACd,CAAE,WAAY;AACb,UAAK,CAAE,aAAc;AACpB,eAAO;AAAA,MACR;AACA,YAAM,EAAE,gBAAgB,IAAI,OAAQ,iBAAAA,KAAU;AAG9C,aAAO,WACJ,gBAAiB,QAAQ,QAAQ,QAAS,IAC1C;AAAA,IACJ;AAAA,IACA,CAAE,UAAU,WAAY;AAAA,EACzB;AAEA,QAAM,OAAO,QAAQ,QAAQ,MAAM,WAAW,SAAU,CAAE,GAAG;AAC7D,QAAM,WACL,QAAQ,cAAe,EAAG,KAC1B,MAAM,WAAW,SAAU,CAAE,GAAG,cAAe,EAAG;AACnD,QAAM,CAAE,eAAe,gBAAiB,QAAI,yBAAU,KAAM;AAC5D,SACC,6CAAC,kBAAAC,sBAAA,EAAO,WAAU,QAAO,SAAU,GAChC;AAAA,KAAC,CAAE,YACJ;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAC,SAAM,uCAAuC;AAAA,UACxD,aAAa;AAAA,QACd,CAAE;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACA,QAAS,MAAM,iBAAkB,IAAK;AAAA,YACtC,SAAM,gBAAI,eAAgB;AAAA,YAC1B,KAAM;AAAA;AAAA,QACP;AAAA;AAAA,IACD;AAAA,IAEC,CAAE,YACH,4CAAC,SAAI,WAAU,qCACd,sDAAC,0BAAK,MAAO,aAAAC,qBAAa,GAC3B;AAAA,IAED,4CAAC,UAAK,WAAU,qCAAsC,gBAAM;AAAA,KAC7D;AAEF;AAEA,IAAO,sBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { commentAuthorAvatar as authorIcon } from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePostWithEmbeddedAuthor } from '../../types';\n\nfunction AuthorView( { item }: { item: BasePostWithEmbeddedAuthor } ) {\n\t// Fetch the author record from the store when _embedded data is unavailable\n\t// (e.g. in the post editor inspector) or when the author has been changed\n\t// during editing (item.author differs from _embedded.author).\n\tconst authorId = item?.author;\n\tconst embeddedAuthorId = item?._embedded?.author?.[ 0 ]?.id;\n\tconst shouldFetch = Boolean(\n\t\tauthorId && ( ! embeddedAuthorId || authorId !== embeddedAuthorId )\n\t);\n\tconst author = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! shouldFetch ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\t// This doesn't make extra REST requests because the records are\n\t\t\t// already in the store from the field's getElements function.\n\t\t\treturn authorId\n\t\t\t\t? getEntityRecord( 'root', 'user', authorId )\n\t\t\t\t: null;\n\t\t},\n\t\t[ authorId, shouldFetch ]\n\t);\n\t// Use fetched author if available, otherwise use _embedded.\n\tconst text = author?.name || item?._embedded?.author?.[ 0 ]?.name;\n\tconst imageUrl =\n\t\tauthor?.avatar_urls?.[ 48 ] ||\n\t\titem?._embedded?.author?.[ 0 ]?.avatar_urls?.[ 48 ];\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'fields-controls__author-avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"fields-controls__author-icon\">\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"fields-controls__author-name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default AuthorView;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,qBAAyB;AACzB,mBAAkD;AAClD,wBAAqD;AACrD,kBAA0B;AAC1B,uBAAmC;AAqCjC;AA9BF,SAAS,WAAY,EAAE,KAAK,GAA0C;AAIrE,QAAM,WAAW,MAAM;AACvB,QAAM,mBAAmB,MAAM,WAAW,SAAU,CAAE,GAAG;AACzD,QAAM,cAAc;AAAA,IACnB,aAAc,CAAE,oBAAoB,aAAa;AAAA,EAClD;AACA,QAAM,aAAS;AAAA,IACd,CAAE,WAAY;AACb,UAAK,CAAE,aAAc;AACpB,eAAO;AAAA,MACR;AACA,YAAM,EAAE,gBAAgB,IAAI,OAAQ,iBAAAA,KAAU;AAG9C,aAAO,WACJ,gBAAiB,QAAQ,QAAQ,QAAS,IAC1C;AAAA,IACJ;AAAA,IACA,CAAE,UAAU,WAAY;AAAA,EACzB;AAEA,QAAM,OAAO,QAAQ,QAAQ,MAAM,WAAW,SAAU,CAAE,GAAG;AAC7D,QAAM,WACL,QAAQ,cAAe,EAAG,KAC1B,MAAM,WAAW,SAAU,CAAE,GAAG,cAAe,EAAG;AACnD,QAAM,CAAE,eAAe,gBAAiB,QAAI,yBAAU,KAAM;AAC5D,SACC,6CAAC,kBAAAC,sBAAA,EAAO,WAAU,QAAO,SAAU,GAChC;AAAA,KAAC,CAAE,YACJ;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAC,SAAM,kCAAkC;AAAA,UACnD,aAAa;AAAA,QACd,CAAE;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACA,QAAS,MAAM,iBAAkB,IAAK;AAAA,YACtC,SAAM,gBAAI,eAAgB;AAAA,YAC1B,KAAM;AAAA;AAAA,QACP;AAAA;AAAA,IACD;AAAA,IAEC,CAAE,YACH,4CAAC,SAAI,WAAU,gCACd,sDAAC,0BAAK,MAAO,aAAAC,qBAAa,GAC3B;AAAA,IAED,4CAAC,UAAK,WAAU,gCAAiC,gBAAM;AAAA,KACxD;AAEF;AAEA,IAAO,sBAAQ;",
6
6
  "names": ["coreStore", "HStack", "clsx", "authorIcon"]
7
7
  }
@@ -0,0 +1,39 @@
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/date/scheduled/index.tsx
21
+ var scheduled_exports = {};
22
+ __export(scheduled_exports, {
23
+ default: () => scheduled_default
24
+ });
25
+ module.exports = __toCommonJS(scheduled_exports);
26
+ var import_i18n = require("@wordpress/i18n");
27
+ var scheduledDateField = {
28
+ id: "scheduled_date",
29
+ type: "datetime",
30
+ label: (0, import_i18n.__)("Scheduled Date"),
31
+ getValue: ({ item }) => item.date,
32
+ setValue: ({ value }) => ({ date: value }),
33
+ isVisible: (item) => item.status === "future",
34
+ enableHiding: false,
35
+ enableSorting: false,
36
+ filterBy: false
37
+ };
38
+ var scheduled_default = scheduledDateField;
39
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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;",
6
+ "names": []
7
+ }
@@ -41,6 +41,7 @@ var featuredImageField = {
41
41
  id: "featured_media",
42
42
  type: "media",
43
43
  label: (0, import_i18n.__)("Featured Image"),
44
+ placeholder: (0, import_i18n.__)("Set featured image"),
44
45
  Edit: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_edit.default, { ...props, isExpanded: true }),
45
46
  render: import_featured_image_view.FeaturedImageView,
46
47
  setValue: ({ value }) => ({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/featured-image/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 MediaEdit from '../../components/media-edit';\nimport type { BasePostWithEmbeddedFeaturedMedia } from '../../types';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePostWithEmbeddedFeaturedMedia > = {\n\tid: 'featured_media',\n\ttype: 'media',\n\tlabel: __( 'Featured Image' ),\n\tEdit: ( props ) => <MediaEdit { ...props } isExpanded />,\n\trender: FeaturedImageView,\n\tsetValue: ( { value } ) => ( {\n\t\tfeatured_media: value ?? 0,\n\t} ),\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * Featured Image field for BasePostWithEmbeddedFeaturedMedia.\n */\nexport default featuredImageField;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AAKnB,wBAAsB;AAEtB,iCAAkC;AAMd;AAJpB,IAAM,qBAAiE;AAAA,EACtE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,gBAAiB;AAAA,EAC5B,MAAM,CAAE,UAAW,4CAAC,kBAAAA,SAAA,EAAY,GAAG,OAAQ,YAAU,MAAC;AAAA,EACtD,QAAQ;AAAA,EACR,UAAU,CAAE,EAAE,MAAM,OAAS;AAAA,IAC5B,gBAAgB,SAAS;AAAA,EAC1B;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,yBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport MediaEdit from '../../components/media-edit';\nimport type { BasePostWithEmbeddedFeaturedMedia } from '../../types';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePostWithEmbeddedFeaturedMedia > = {\n\tid: 'featured_media',\n\ttype: 'media',\n\tlabel: __( 'Featured Image' ),\n\tplaceholder: __( 'Set featured image' ),\n\tEdit: ( props ) => <MediaEdit { ...props } isExpanded />,\n\trender: FeaturedImageView,\n\tsetValue: ( { value } ) => ( {\n\t\tfeatured_media: value ?? 0,\n\t} ),\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * Featured Image field for BasePostWithEmbeddedFeaturedMedia.\n */\nexport default featuredImageField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AAKnB,wBAAsB;AAEtB,iCAAkC;AAOd;AALpB,IAAM,qBAAiE;AAAA,EACtE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,gBAAiB;AAAA,EAC5B,iBAAa,gBAAI,oBAAqB;AAAA,EACtC,MAAM,CAAE,UAAW,4CAAC,kBAAAA,SAAA,EAAY,GAAG,OAAQ,YAAU,MAAC;AAAA,EACtD,QAAQ;AAAA,EACR,UAAU,CAAE,EAAE,MAAM,OAAS;AAAA,IAC5B,gBAAgB,SAAS;AAAA,EAC1B;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,yBAAQ;",
6
6
  "names": ["MediaEdit"]
7
7
  }
@@ -0,0 +1,69 @@
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/format/index.ts
21
+ var format_exports = {};
22
+ __export(format_exports, {
23
+ default: () => format_default
24
+ });
25
+ module.exports = __toCommonJS(format_exports);
26
+ var import_i18n = require("@wordpress/i18n");
27
+ var import_data = require("@wordpress/data");
28
+ var import_core_data = require("@wordpress/core-data");
29
+ var POST_FORMATS = [
30
+ { id: "aside", caption: (0, import_i18n.__)("Aside") },
31
+ { id: "audio", caption: (0, import_i18n.__)("Audio") },
32
+ { id: "chat", caption: (0, import_i18n.__)("Chat") },
33
+ { id: "gallery", caption: (0, import_i18n.__)("Gallery") },
34
+ { id: "image", caption: (0, import_i18n.__)("Image") },
35
+ { id: "link", caption: (0, import_i18n.__)("Link") },
36
+ { id: "quote", caption: (0, import_i18n.__)("Quote") },
37
+ { id: "standard", caption: (0, import_i18n.__)("Standard") },
38
+ { id: "status", caption: (0, import_i18n.__)("Status") },
39
+ { id: "video", caption: (0, import_i18n.__)("Video") }
40
+ ].sort((a, b) => {
41
+ const normalizedA = a.caption.toUpperCase();
42
+ const normalizedB = b.caption.toUpperCase();
43
+ if (normalizedA < normalizedB) {
44
+ return -1;
45
+ }
46
+ if (normalizedA > normalizedB) {
47
+ return 1;
48
+ }
49
+ return 0;
50
+ });
51
+ var formatField = {
52
+ id: "format",
53
+ label: (0, import_i18n.__)("Format"),
54
+ type: "text",
55
+ Edit: "radio",
56
+ enableSorting: false,
57
+ enableHiding: false,
58
+ filterBy: false,
59
+ getElements: async () => {
60
+ const themeSupports = await (0, import_data.resolveSelect)(import_core_data.store).getThemeSupports();
61
+ return POST_FORMATS.filter(
62
+ (f) => themeSupports?.formats?.includes(
63
+ f.id
64
+ )
65
+ ).map((f) => ({ value: f.id, label: f.caption }));
66
+ }
67
+ };
68
+ var format_default = formatField;
69
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/format/index.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\n// All WP post formats, sorted alphabetically by translated name.\nconst POST_FORMATS = [\n\t{ id: 'aside', caption: __( 'Aside' ) },\n\t{ id: 'audio', caption: __( 'Audio' ) },\n\t{ id: 'chat', caption: __( 'Chat' ) },\n\t{ id: 'gallery', caption: __( 'Gallery' ) },\n\t{ id: 'image', caption: __( 'Image' ) },\n\t{ id: 'link', caption: __( 'Link' ) },\n\t{ id: 'quote', caption: __( 'Quote' ) },\n\t{ id: 'standard', caption: __( 'Standard' ) },\n\t{ id: 'status', caption: __( 'Status' ) },\n\t{ id: 'video', caption: __( 'Video' ) },\n].sort( ( a, b ) => {\n\tconst normalizedA = a.caption.toUpperCase();\n\tconst normalizedB = b.caption.toUpperCase();\n\n\tif ( normalizedA < normalizedB ) {\n\t\treturn -1;\n\t}\n\tif ( normalizedA > normalizedB ) {\n\t\treturn 1;\n\t}\n\treturn 0;\n} );\n\nconst formatField: Field< BasePost > = {\n\tid: 'format',\n\tlabel: __( 'Format' ),\n\ttype: 'text',\n\tEdit: 'radio',\n\tenableSorting: false,\n\tenableHiding: false,\n\tfilterBy: false,\n\tgetElements: async () => {\n\t\tconst themeSupports =\n\t\t\tawait resolveSelect( coreStore ).getThemeSupports();\n\t\treturn POST_FORMATS.filter(\n\t\t\t( f ) =>\n\t\t\t\t( themeSupports?.formats as string[] | undefined )?.includes(\n\t\t\t\t\tf.id\n\t\t\t\t)\n\t\t).map( ( f ) => ( { value: f.id, label: f.caption } ) );\n\t},\n};\n\n/**\n * Format field for BasePost.\n */\nexport default formatField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AACnB,kBAA8B;AAC9B,uBAAmC;AAQnC,IAAM,eAAe;AAAA,EACpB,EAAE,IAAI,SAAS,aAAS,gBAAI,OAAQ,EAAE;AAAA,EACtC,EAAE,IAAI,SAAS,aAAS,gBAAI,OAAQ,EAAE;AAAA,EACtC,EAAE,IAAI,QAAQ,aAAS,gBAAI,MAAO,EAAE;AAAA,EACpC,EAAE,IAAI,WAAW,aAAS,gBAAI,SAAU,EAAE;AAAA,EAC1C,EAAE,IAAI,SAAS,aAAS,gBAAI,OAAQ,EAAE;AAAA,EACtC,EAAE,IAAI,QAAQ,aAAS,gBAAI,MAAO,EAAE;AAAA,EACpC,EAAE,IAAI,SAAS,aAAS,gBAAI,OAAQ,EAAE;AAAA,EACtC,EAAE,IAAI,YAAY,aAAS,gBAAI,UAAW,EAAE;AAAA,EAC5C,EAAE,IAAI,UAAU,aAAS,gBAAI,QAAS,EAAE;AAAA,EACxC,EAAE,IAAI,SAAS,aAAS,gBAAI,OAAQ,EAAE;AACvC,EAAE,KAAM,CAAE,GAAG,MAAO;AACnB,QAAM,cAAc,EAAE,QAAQ,YAAY;AAC1C,QAAM,cAAc,EAAE,QAAQ,YAAY;AAE1C,MAAK,cAAc,aAAc;AAChC,WAAO;AAAA,EACR;AACA,MAAK,cAAc,aAAc;AAChC,WAAO;AAAA,EACR;AACA,SAAO;AACR,CAAE;AAEF,IAAM,cAAiC;AAAA,EACtC,IAAI;AAAA,EACJ,WAAO,gBAAI,QAAS;AAAA,EACpB,MAAM;AAAA,EACN,MAAM;AAAA,EACN,eAAe;AAAA,EACf,cAAc;AAAA,EACd,UAAU;AAAA,EACV,aAAa,YAAY;AACxB,UAAM,gBACL,UAAM,2BAAe,iBAAAA,KAAU,EAAE,iBAAiB;AACnD,WAAO,aAAa;AAAA,MACnB,CAAE,MACC,eAAe,SAAmC;AAAA,QACnD,EAAE;AAAA,MACH;AAAA,IACF,EAAE,IAAK,CAAE,OAAS,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,QAAQ,EAAI;AAAA,EACvD;AACD;AAKA,IAAO,iBAAQ;",
6
+ "names": ["coreStore"]
7
+ }
@@ -35,6 +35,7 @@ __export(fields_exports, {
35
35
  dateField: () => import_date.default,
36
36
  discussionField: () => import_discussion.default,
37
37
  featuredImageField: () => import_featured_image.default,
38
+ formatField: () => import_format.default,
38
39
  notesField: () => import_notes.default,
39
40
  orderField: () => import_order.default,
40
41
  pageTitleField: () => import_page_title.default,
@@ -42,6 +43,8 @@ __export(fields_exports, {
42
43
  passwordField: () => import_password.default,
43
44
  patternTitleField: () => import_pattern_title.default,
44
45
  pingStatusField: () => import_ping_status.default,
46
+ postContentInfoField: () => import_post_content_info.default,
47
+ scheduledDateField: () => import_scheduled.default,
45
48
  slugField: () => import_slug.default,
46
49
  statusField: () => import_status.default,
47
50
  templateField: () => import_template.default,
@@ -64,8 +67,11 @@ var import_comment_status = __toESM(require("./comment-status/index.cjs"));
64
67
  var import_ping_status = __toESM(require("./ping-status/index.cjs"));
65
68
  var import_discussion = __toESM(require("./discussion/index.cjs"));
66
69
  var import_date = __toESM(require("./date/index.cjs"));
70
+ var import_scheduled = __toESM(require("./date/scheduled/index.cjs"));
67
71
  var import_author = __toESM(require("./author/index.cjs"));
68
72
  var import_notes = __toESM(require("./notes/index.cjs"));
73
+ var import_format = __toESM(require("./format/index.cjs"));
74
+ var import_post_content_info = __toESM(require("./post-content-info/index.cjs"));
69
75
  // Annotate the CommonJS export names for ESM import in node:
70
76
  0 && (module.exports = {
71
77
  authorField,
@@ -73,6 +79,7 @@ var import_notes = __toESM(require("./notes/index.cjs"));
73
79
  dateField,
74
80
  discussionField,
75
81
  featuredImageField,
82
+ formatField,
76
83
  notesField,
77
84
  orderField,
78
85
  pageTitleField,
@@ -80,6 +87,8 @@ var import_notes = __toESM(require("./notes/index.cjs"));
80
87
  passwordField,
81
88
  patternTitleField,
82
89
  pingStatusField,
90
+ postContentInfoField,
91
+ scheduledDateField,
83
92
  slugField,
84
93
  statusField,
85
94
  templateField,
@@ -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 authorField } from './author';\nexport { default as notesField } from './notes';\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,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,oBAAuC;AACvC,mBAAsC;",
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;",
6
6
  "names": []
7
7
  }
@@ -95,7 +95,7 @@ function PageAttributesParent({
95
95
  data,
96
96
  onChangeControl
97
97
  }) {
98
- const [fieldValue, setFieldValue] = (0, import_element.useState)(null);
98
+ const [fieldValue, setFieldValue] = (0, import_element.useState)("");
99
99
  const pageId = data.parent;
100
100
  const postId = data.id;
101
101
  const postTypeSlug = data.type;
@@ -116,7 +116,7 @@ function PageAttributesParent({
116
116
  orderby: "menu_order",
117
117
  order: "asc",
118
118
  _fields: "id,title,parent",
119
- ...fieldValue !== null && {
119
+ ...!!fieldValue && {
120
120
  // Perform a search by relevance when the field is changed.
121
121
  search: fieldValue,
122
122
  orderby: "relevance"
@@ -145,14 +145,8 @@ function PageAttributesParent({
145
145
  ...getOptionsFromTree(treeNode.children || [], level + 1)
146
146
  ]);
147
147
  const sortedNodes = mappedNodes.sort(([a], [b]) => {
148
- const priorityA = getItemPriority(
149
- a.rawName,
150
- fieldValue ?? ""
151
- );
152
- const priorityB = getItemPriority(
153
- b.rawName,
154
- fieldValue ?? ""
155
- );
148
+ const priorityA = getItemPriority(a.rawName, fieldValue);
149
+ const priorityB = getItemPriority(b.rawName, fieldValue);
156
150
  return priorityA >= priorityB ? 1 : -1;
157
151
  });
158
152
  return sortedNodes.flat();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/parent/parent-edit.tsx"],
4
- "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\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\t// Perform a search by relevance when the field is changed.\n\t\t\t\t\tsearch: fieldValue,\n\t\t\t\t\torderby: 'relevance',\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'\u2014 '.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__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\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"],
5
-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D,GACD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;",
4
+ "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< string >( '' );\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\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 && {\n\t\t\t\t\t// Perform a search by relevance when the field is changed.\n\t\t\t\t\tsearch: fieldValue,\n\t\t\t\t\torderby: 'relevance',\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'\u2014 '.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( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\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__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\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA0B;AAK1B,wBAA8C;AAC9C,kBAA0B;AAC1B,qBAKO;AAEP,uBAAmC;AAEnC,qBAAyB;AACzB,2BAA+B;AAC/B,kBAA4B;AAC5B,iBAAoC;AAMpC,mBAAyC;AAyOvC;AAvNF,SAAS,eAAgB,WAAoB;AAC5C,QAAM,iCAAiC,UAAU,IAAK,CAAE,SAAU;AACjE,WAAO;AAAA,MACN,UAAU,CAAC;AAAA,MACX,GAAG;AAAA,IACJ;AAAA,EACD,CAAE;AAGF,MACC,+BAA+B;AAAA,IAC9B,CAAE,EAAE,OAAO,MAAO,WAAW,QAAQ,WAAW;AAAA,EACjD,GACC;AACD,WAAO;AAAA,EACR;AAEA,QAAM,gBACL,+BACE;AAAA,IACF,CAAE,KAAK,SAAU;AAChB,YAAM,EAAE,OAAO,IAAI;AACnB,UAAK,CAAE,IAAK,MAAO,GAAI;AACtB,YAAK,MAAO,IAAI,CAAC;AAAA,MAClB;AACA,UAAK,MAAO,EAAE,KAAM,IAAK;AACzB,aAAO;AAAA,IACR;AAAA,IACA,CAAC;AAAA,EACF;AAEA,QAAM,mBAAmB,CACxB,UAC6B;AAC7B,WAAO,MAAM,IAAK,CAAE,SAAU;AAC7B,YAAM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AAAA,UACC;AAAA,QACD;AAAA,YACA,gCAAqB,OAAQ,EAAE;AAAA,UAC9B;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,MACA;AAAA,QACC,KAAK,4CAAC,SAAI;AAAA,MACX;AAAA,IACD;AAAA,IACA,4CAAC,OACE;AAAA,UACD;AAAA,QACC;AAAA,MACD;AAAA,MACA;AAAA,QACC,GACC;AAAA,UAAC;AAAA;AAAA,YACA,UAAO;AAAA,cACN;AAAA,YACD;AAAA,YACA,UAAW;AAAA;AAAA,QACZ;AAAA,MAEF;AAAA,IACD,GACD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;",
6
6
  "names": ["removeAccents", "coreStore", "tree"]
7
7
  }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/fields/src/fields/post-content-info/index.ts
31
+ var post_content_info_exports = {};
32
+ __export(post_content_info_exports, {
33
+ default: () => post_content_info_default
34
+ });
35
+ module.exports = __toCommonJS(post_content_info_exports);
36
+ var import_i18n = require("@wordpress/i18n");
37
+ var import_post_content_info_view = __toESM(require("./post-content-info-view.cjs"));
38
+ var postContentInfoField = {
39
+ label: (0, import_i18n.__)("Post content information"),
40
+ id: "post-content-info",
41
+ type: "text",
42
+ readOnly: true,
43
+ render: import_post_content_info_view.default,
44
+ enableSorting: false,
45
+ enableHiding: false,
46
+ filterBy: false
47
+ };
48
+ var post_content_info_default = postContentInfoField;
49
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/post-content-info/index.ts"],
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';\nimport PostContentInfoView from './post-content-info-view';\n\nconst postContentInfoField: Field< BasePost > = {\n\tlabel: __( 'Post content information' ),\n\tid: 'post-content-info',\n\ttype: 'text',\n\treadOnly: true,\n\trender: PostContentInfoView,\n\tenableSorting: false,\n\tenableHiding: false,\n\tfilterBy: false,\n};\n\n/**\n * Post content information field for BasePost.\n */\nexport default postContentInfoField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AAMnB,oCAAgC;AAEhC,IAAM,uBAA0C;AAAA,EAC/C,WAAO,gBAAI,0BAA2B;AAAA,EACtC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ,8BAAAA;AAAA,EACR,eAAe;AAAA,EACf,cAAc;AAAA,EACd,UAAU;AACX;AAKA,IAAO,4BAAQ;",
6
+ "names": ["PostContentInfoView"]
7
+ }
@@ -0,0 +1,76 @@
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/post-content-info/post-content-info-view.tsx
21
+ var post_content_info_view_exports = {};
22
+ __export(post_content_info_view_exports, {
23
+ default: () => PostContentInfoView
24
+ });
25
+ module.exports = __toCommonJS(post_content_info_view_exports);
26
+ var import_components = require("@wordpress/components");
27
+ var import_i18n = require("@wordpress/i18n");
28
+ var import_wordcount = require("@wordpress/wordcount");
29
+ var import_date = require("@wordpress/date");
30
+ var import_element = require("@wordpress/element");
31
+ var import_jsx_runtime = require("react/jsx-runtime");
32
+ var AVERAGE_READING_RATE = 189;
33
+ function PostContentInfoView({ item }) {
34
+ const content = typeof item.content === "string" ? item.content : item.content?.raw || "";
35
+ const wordCountType = (0, import_i18n._x)(
36
+ "words",
37
+ "Word count type. Do not translate!"
38
+ );
39
+ const wordsCounted = (0, import_element.useMemo)(
40
+ () => content ? (0, import_wordcount.count)(content, wordCountType) : 0,
41
+ [content, wordCountType]
42
+ );
43
+ const modified = item.modified;
44
+ if (!wordsCounted && !modified) {
45
+ return null;
46
+ }
47
+ let contentInfoText;
48
+ if (wordsCounted) {
49
+ const readingTime = Math.round(wordsCounted / AVERAGE_READING_RATE);
50
+ const wordsCountText = (0, import_i18n.sprintf)(
51
+ // translators: %s: the number of words in the post.
52
+ (0, import_i18n._n)("%s word", "%s words", wordsCounted),
53
+ wordsCounted.toLocaleString()
54
+ );
55
+ const minutesText = readingTime <= 1 ? (0, import_i18n.__)("1 minute") : (0, import_i18n.sprintf)(
56
+ /* translators: %s: the number of minutes to read the post. */
57
+ (0, import_i18n._n)("%s minute", "%s minutes", readingTime),
58
+ readingTime.toLocaleString()
59
+ );
60
+ contentInfoText = (0, import_i18n.sprintf)(
61
+ /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
62
+ (0, import_i18n.__)("%1$s, %2$s read time."),
63
+ wordsCountText,
64
+ minutesText
65
+ );
66
+ }
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: 1, children: [
68
+ contentInfoText && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { variant: "muted", children: contentInfoText }),
69
+ modified && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { variant: "muted", children: (0, import_i18n.sprintf)(
70
+ // translators: %s: Human-readable time difference, e.g. "2 days ago".
71
+ (0, import_i18n.__)("Last edited %s."),
72
+ (0, import_date.humanTimeDiff)(modified)
73
+ ) })
74
+ ] });
75
+ }
76
+ //# sourceMappingURL=post-content-info-view.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/post-content-info/post-content-info-view.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport type { Strategy } from '@wordpress/wordcount';\nimport { humanTimeDiff } from '@wordpress/date';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\n// Taken from packages/editor/src/components/time-to-read/index.js.\nconst AVERAGE_READING_RATE = 189;\n\nexport default function PostContentInfoView( { item }: { item: BasePost } ) {\n\tconst content =\n\t\ttypeof item.content === 'string'\n\t\t\t? item.content\n\t\t\t: item.content?.raw || '';\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x(\n\t\t'words',\n\t\t'Word count type. Do not translate!'\n\t) as Strategy;\n\tconst wordsCounted = useMemo(\n\t\t() => ( content ? wordCount( content, wordCountType ) : 0 ),\n\t\t[ content, wordCountType ]\n\t);\n\n\tconst modified = item.modified;\n\n\tif ( ! wordsCounted && ! modified ) {\n\t\treturn null;\n\t}\n\n\tlet contentInfoText: string | undefined;\n\tif ( wordsCounted ) {\n\t\tconst readingTime = Math.round( wordsCounted / AVERAGE_READING_RATE );\n\t\tconst wordsCountText = sprintf(\n\t\t\t// translators: %s: the number of words in the post.\n\t\t\t_n( '%s word', '%s words', wordsCounted ),\n\t\t\twordsCounted.toLocaleString()\n\t\t);\n\t\tconst minutesText =\n\t\t\treadingTime <= 1\n\t\t\t\t? __( '1 minute' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: the number of minutes to read the post. */\n\t\t\t\t\t\t_n( '%s minute', '%s minutes', readingTime ),\n\t\t\t\t\t\treadingTime.toLocaleString()\n\t\t\t\t );\n\t\tcontentInfoText = sprintf(\n\t\t\t/* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */\n\t\t\t__( '%1$s, %2$s read time.' ),\n\t\t\twordsCountText,\n\t\t\tminutesText\n\t\t);\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 1 }>\n\t\t\t{ contentInfoText && (\n\t\t\t\t<Text variant=\"muted\">{ contentInfoText }</Text>\n\t\t\t) }\n\t\t\t{ modified && (\n\t\t\t\t<Text variant=\"muted\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %s: Human-readable time difference, e.g. \"2 days ago\".\n\t\t\t\t\t\t__( 'Last edited %s.' ),\n\t\t\t\t\t\thumanTimeDiff( modified )\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AACP,kBAAoC;AACpC,uBAAmC;AAEnC,kBAA8B;AAC9B,qBAAwB;AA6DtB;AArDF,IAAM,uBAAuB;AAEd,SAAR,oBAAsC,EAAE,KAAK,GAAwB;AAC3E,QAAM,UACL,OAAO,KAAK,YAAY,WACrB,KAAK,UACL,KAAK,SAAS,OAAO;AAOzB,QAAM,oBAAgB;AAAA,IACrB;AAAA,IACA;AAAA,EACD;AACA,QAAM,mBAAe;AAAA,IACpB,MAAQ,cAAU,iBAAAA,OAAW,SAAS,aAAc,IAAI;AAAA,IACxD,CAAE,SAAS,aAAc;AAAA,EAC1B;AAEA,QAAM,WAAW,KAAK;AAEtB,MAAK,CAAE,gBAAgB,CAAE,UAAW;AACnC,WAAO;AAAA,EACR;AAEA,MAAI;AACJ,MAAK,cAAe;AACnB,UAAM,cAAc,KAAK,MAAO,eAAe,oBAAqB;AACpE,UAAM,qBAAiB;AAAA;AAAA,UAEtB,gBAAI,WAAW,YAAY,YAAa;AAAA,MACxC,aAAa,eAAe;AAAA,IAC7B;AACA,UAAM,cACL,eAAe,QACZ,gBAAI,UAAW,QACf;AAAA;AAAA,UAEA,gBAAI,aAAa,cAAc,WAAY;AAAA,MAC3C,YAAY,eAAe;AAAA,IAC3B;AACJ,0BAAkB;AAAA;AAAA,UAEjB,gBAAI,uBAAwB;AAAA,MAC5B;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SACC,6CAAC,kBAAAC,sBAAA,EAAO,SAAU,GACf;AAAA,uBACD,4CAAC,kBAAAC,oBAAA,EAAK,SAAQ,SAAU,2BAAiB;AAAA,IAExC,YACD,4CAAC,kBAAAA,oBAAA,EAAK,SAAQ,SACX;AAAA;AAAA,UAED,gBAAI,iBAAkB;AAAA,UACtB,2BAAe,QAAS;AAAA,IACzB,GACD;AAAA,KAEF;AAEF;",
6
+ "names": ["wordCount", "VStack", "Text"]
7
+ }
@@ -41,7 +41,7 @@ function StatusView({ item }) {
41
41
  const label = status?.label || item.status;
42
42
  const icon = status?.icon;
43
43
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { alignment: "left", spacing: 0, children: [
44
- icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "edit-site-post-list__status-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon }) }),
44
+ icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "fields-controls__status-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon }) }),
45
45
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label })
46
46
  ] });
47
47
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/status/status-view.tsx"],
4
- "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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAqD;AAMrD,6BAAqB;AAOnB;AALF,SAAS,WAAY,EAAE,KAAK,GAAwB;AACnD,QAAM,SAAS,uBAAAA,QAAS,KAAM,CAAE,EAAE,MAAM,MAAO,UAAU,KAAK,MAAO;AACrE,QAAM,QAAQ,QAAQ,SAAS,KAAK;AACpC,QAAM,OAAO,QAAQ;AACrB,SACC,6CAAC,kBAAAC,sBAAA,EAAO,WAAU,QAAO,SAAU,GAChC;AAAA,YACD,4CAAC,SAAI,WAAU,oCACd,sDAAC,0BAAK,MAAc,GACrB;AAAA,IAED,4CAAC,UAAO,iBAAO;AAAA,KAChB;AAEF;AAEA,IAAO,sBAAQ;",
4
+ "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=\"fields-controls__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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAqD;AAMrD,6BAAqB;AAOnB;AALF,SAAS,WAAY,EAAE,KAAK,GAAwB;AACnD,QAAM,SAAS,uBAAAA,QAAS,KAAM,CAAE,EAAE,MAAM,MAAO,UAAU,KAAK,MAAO;AACrE,QAAM,QAAQ,QAAQ,SAAS,KAAK;AACpC,QAAM,OAAO,QAAQ;AACrB,SACC,6CAAC,kBAAAC,sBAAA,EAAO,WAAU,QAAO,SAAU,GAChC;AAAA,YACD,4CAAC,SAAI,WAAU,gCACd,sDAAC,0BAAK,MAAc,GACrB;AAAA,IAED,4CAAC,UAAO,iBAAO;AAAA,KAChB;AAEF;AAEA,IAAO,sBAAQ;",
6
6
  "names": ["STATUSES", "HStack"]
7
7
  }