@wordpress/fields 0.34.0 → 0.35.1-next.v.202604091042.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 (66) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +9 -1
  3. package/build/components/media-edit/index.cjs +8 -1
  4. package/build/components/media-edit/index.cjs.map +2 -2
  5. package/build/fields/date/scheduled/index.cjs +4 -0
  6. package/build/fields/date/scheduled/index.cjs.map +2 -2
  7. package/build/fields/excerpt/index.cjs +61 -0
  8. package/build/fields/excerpt/index.cjs.map +7 -0
  9. package/build/fields/index.cjs +6 -0
  10. package/build/fields/index.cjs.map +2 -2
  11. package/build/fields/post-content-info/index.cjs.map +2 -2
  12. package/build/fields/post-content-info/post-content-info-view.cjs +9 -2
  13. package/build/fields/post-content-info/post-content-info-view.cjs.map +2 -2
  14. package/build/fields/sticky/index.cjs +38 -0
  15. package/build/fields/sticky/index.cjs.map +7 -0
  16. package/build/types.cjs.map +1 -1
  17. package/build-module/components/media-edit/index.mjs +8 -1
  18. package/build-module/components/media-edit/index.mjs.map +2 -2
  19. package/build-module/fields/date/scheduled/index.mjs +4 -0
  20. package/build-module/fields/date/scheduled/index.mjs.map +2 -2
  21. package/build-module/fields/excerpt/index.mjs +43 -0
  22. package/build-module/fields/excerpt/index.mjs.map +7 -0
  23. package/build-module/fields/index.mjs +8 -4
  24. package/build-module/fields/index.mjs.map +2 -2
  25. package/build-module/fields/post-content-info/index.mjs.map +2 -2
  26. package/build-module/fields/post-content-info/post-content-info-view.mjs +9 -2
  27. package/build-module/fields/post-content-info/post-content-info-view.mjs.map +2 -2
  28. package/build-module/fields/sticky/index.mjs +17 -0
  29. package/build-module/fields/sticky/index.mjs.map +7 -0
  30. package/build-style/style-rtl.css +4 -0
  31. package/build-style/style.css +4 -0
  32. package/build-types/components/media-edit/index.d.ts +1 -1
  33. package/build-types/components/media-edit/index.d.ts.map +1 -1
  34. package/build-types/fields/date/scheduled/index.d.ts.map +1 -1
  35. package/build-types/fields/excerpt/index.d.ts +14 -0
  36. package/build-types/fields/excerpt/index.d.ts.map +1 -0
  37. package/build-types/fields/index.d.ts +2 -0
  38. package/build-types/fields/index.d.ts.map +1 -1
  39. package/build-types/fields/post-content-info/index.d.ts +2 -2
  40. package/build-types/fields/post-content-info/index.d.ts.map +1 -1
  41. package/build-types/fields/post-content-info/post-content-info-view.d.ts +3 -3
  42. package/build-types/fields/post-content-info/post-content-info-view.d.ts.map +1 -1
  43. package/build-types/fields/status/status-elements.d.ts +11 -11
  44. package/build-types/fields/sticky/index.d.ts +14 -0
  45. package/build-types/fields/sticky/index.d.ts.map +1 -0
  46. package/build-types/stories/index.story.d.ts.map +1 -1
  47. package/build-types/types.d.ts +6 -0
  48. package/build-types/types.d.ts.map +1 -1
  49. package/package.json +26 -26
  50. package/src/components/media-edit/index.tsx +5 -2
  51. package/src/components/media-edit/style.scss +5 -0
  52. package/src/fields/date/scheduled/index.tsx +4 -0
  53. package/src/fields/excerpt/index.tsx +57 -0
  54. package/src/fields/index.ts +2 -0
  55. package/src/fields/post-content-info/index.ts +2 -2
  56. package/src/fields/post-content-info/post-content-info-view.tsx +12 -6
  57. package/src/fields/sticky/index.tsx +26 -0
  58. package/src/stories/index.story.tsx +2 -2
  59. package/src/types.ts +9 -0
  60. package/build/fields/template/utils.cjs +0 -91
  61. package/build/fields/template/utils.cjs.map +0 -7
  62. package/build-module/fields/template/utils.mjs +0 -65
  63. package/build-module/fields/template/utils.mjs.map +0 -7
  64. package/build-types/fields/template/utils.d.ts +0 -28
  65. package/build-types/fields/template/utils.d.ts.map +0 -1
  66. package/src/fields/template/utils.ts +0 -119
@@ -1,31 +1,31 @@
1
1
  declare const STATUSES: ({
2
2
  value: string;
3
- label: import("@wordpress/i18n").TranslatableText<"Draft">;
3
+ label: import("@wordpress/i18n").TransformedText<"Draft">;
4
4
  icon: import("react").JSX.Element;
5
- description: import("@wordpress/i18n").TranslatableText<"Not ready to publish.">;
5
+ description: import("@wordpress/i18n").TransformedText<"Not ready to publish.">;
6
6
  } | {
7
7
  value: string;
8
- label: import("@wordpress/i18n").TranslatableText<"Scheduled">;
8
+ label: import("@wordpress/i18n").TransformedText<"Scheduled">;
9
9
  icon: import("react").JSX.Element;
10
- description: import("@wordpress/i18n").TranslatableText<"Publish automatically on a chosen date.">;
10
+ description: import("@wordpress/i18n").TransformedText<"Publish automatically on a chosen date.">;
11
11
  } | {
12
12
  value: string;
13
- label: import("@wordpress/i18n").TranslatableText<"Pending Review">;
13
+ label: import("@wordpress/i18n").TransformedText<"Pending Review">;
14
14
  icon: import("react").JSX.Element;
15
- description: import("@wordpress/i18n").TranslatableText<"Waiting for review before publishing.">;
15
+ description: import("@wordpress/i18n").TransformedText<"Waiting for review before publishing.">;
16
16
  } | {
17
17
  value: string;
18
- label: import("@wordpress/i18n").TranslatableText<"Private">;
18
+ label: import("@wordpress/i18n").TransformedText<"Private">;
19
19
  icon: import("react").JSX.Element;
20
- description: import("@wordpress/i18n").TranslatableText<"Only visible to site admins and editors.">;
20
+ description: import("@wordpress/i18n").TransformedText<"Only visible to site admins and editors.">;
21
21
  } | {
22
22
  value: string;
23
- label: import("@wordpress/i18n").TranslatableText<"Published">;
23
+ label: import("@wordpress/i18n").TransformedText<"Published">;
24
24
  icon: import("react").JSX.Element;
25
- description: import("@wordpress/i18n").TranslatableText<"Visible to everyone.">;
25
+ description: import("@wordpress/i18n").TransformedText<"Visible to everyone.">;
26
26
  } | {
27
27
  value: string;
28
- label: import("@wordpress/i18n").TranslatableText<"Trash">;
28
+ label: import("@wordpress/i18n").TransformedText<"Trash">;
29
29
  icon: import("react").JSX.Element;
30
30
  description?: undefined;
31
31
  })[];
@@ -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"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAwB,MAAM,sBAAsB,CAAC;;;;;AA4DtE,wBAGE;AAyFF,eAAO,MAAM,gBAAgB;uBA1CU;QAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;KAAE;;;;;;;;;;;;;CAsDnE,CAAC;AAEF,eAAO,MAAM,gBAAgB,mCAuC5B,CAAC"}
1
+ {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;;;;;AA2D3D,wBAGE;AAyFF,eAAO,MAAM,gBAAgB;uBA1CU;QAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;KAAE;;;;;;;;;;;;;CAsDnE,CAAC;AAEF,eAAO,MAAM,gBAAgB,mCAuC5B,CAAC"}
@@ -59,11 +59,15 @@ 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;
65
66
  author?: number;
66
67
  }
68
+ export interface BasePostWithEditedEntity extends Omit<BasePost, 'content'> {
69
+ content: BasePost['content'] | ((record: BasePostWithEditedEntity) => string);
70
+ }
67
71
  export interface BasePostWithEmbeddedAuthor extends BasePost {
68
72
  _embedded: EmbeddedAuthor;
69
73
  }
@@ -126,6 +130,7 @@ export interface PostType {
126
130
  supports?: {
127
131
  'page-attributes'?: boolean;
128
132
  title?: boolean;
133
+ excerpt?: boolean;
129
134
  revisions?: boolean;
130
135
  author?: string;
131
136
  thumbnail?: string;
@@ -142,6 +147,7 @@ export type CoreDataError = {
142
147
  export interface MediaEditProps<Item> extends Pick<DataFormControlProps<Item>, 'data' | 'field' | 'onChange' | 'hideLabelFromVision' | 'validity'> {
143
148
  /**
144
149
  * Array of allowed media types (e.g., ['image', 'video']).
150
+ * Use ['*'] to allow all file types.
145
151
  *
146
152
  * @default ['image']
147
153
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,KAAK,UAAU,GACZ,SAAS,GACT,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,OAAO,CAAC;AAEX,MAAM,WAAW,UAAU;IAC1B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,OAAO,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,CAAC;CACf;AAED,UAAU,KAAK;IACd,qBAAqB,CA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,EAAE,OAAO,CAAC;QAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,OAAO,GAAG,CAAE,aAAa,CAAE,CAAC;QACrC,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,cAAc,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;CACF;AAGD,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,MAAM,WAAW,cAAc,CAAE,IAAI,CACpC,SAAQ,IAAI,CACX,oBAAoB,CAAE,IAAI,CAAE,EAC5B,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,qBAAqB,GAAG,UAAU,CAClE;IACD;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/fields",
3
- "version": "0.34.0",
3
+ "version": "0.35.1-next.v.202604091042.0+668146787",
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.1-next.v.202604091042.0+668146787",
52
+ "@wordpress/base-styles": "^6.19.1-next.v.202604091042.0+668146787",
53
+ "@wordpress/blob": "^4.43.1-next.v.202604091042.0+668146787",
54
+ "@wordpress/blocks": "^15.16.1-next.v.202604091042.0+668146787",
55
+ "@wordpress/components": "^32.5.2-next.v.202604091042.0+668146787",
56
+ "@wordpress/compose": "^7.43.1-next.v.202604091042.0+668146787",
57
+ "@wordpress/core-data": "^7.43.2-next.v.202604091042.0+668146787",
58
+ "@wordpress/data": "^10.43.1-next.v.202604091042.0+668146787",
59
+ "@wordpress/dataviews": "^14.1.1-next.v.202604091042.0+668146787",
60
+ "@wordpress/date": "^5.43.1-next.v.202604091042.0+668146787",
61
+ "@wordpress/element": "^6.44.1-next.v.202604091042.0+668146787",
62
+ "@wordpress/hooks": "^4.43.1-next.v.202604091042.0+668146787",
63
+ "@wordpress/html-entities": "^4.43.1-next.v.202604091042.0+668146787",
64
+ "@wordpress/i18n": "^6.17.1-next.v.202604091042.0+668146787",
65
+ "@wordpress/icons": "^12.1.1-next.v.202604091042.0+668146787",
66
+ "@wordpress/media-utils": "^5.43.1-next.v.202604091042.0+668146787",
67
+ "@wordpress/notices": "^5.43.1-next.v.202604091042.0+668146787",
68
+ "@wordpress/patterns": "^2.43.1-next.v.202604091042.0+668146787",
69
+ "@wordpress/primitives": "^4.43.1-next.v.202604091042.0+668146787",
70
+ "@wordpress/private-apis": "^1.43.1-next.v.202604091042.0+668146787",
71
+ "@wordpress/router": "^1.43.1-next.v.202604091042.0+668146787",
72
+ "@wordpress/url": "^4.43.1-next.v.202604091042.0+668146787",
73
+ "@wordpress/warning": "^3.43.1-next.v.202604091042.0+668146787",
74
+ "@wordpress/wordcount": "^4.43.1-next.v.202604091042.0+668146787",
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": "73606df74f1c38a084bfa5db97205259ef817593"
87
87
  }
@@ -567,7 +567,7 @@ function CompactMediaEditAttachments( {
567
567
  * @param {Item} props.data - The item being edited.
568
568
  * @param {Object} props.field - The field configuration with getValue and setValue methods.
569
569
  * @param {Function} props.onChange - Callback function when the media selection changes.
570
- * @param {string[]} [props.allowedTypes] - Array of allowed media types. Default `['image']`.
570
+ * @param {string[]} [props.allowedTypes] - Array of allowed media types. Use `['*']` to allow all file types. Default `['image']`.
571
571
  * @param {boolean} [props.multiple] - Whether to allow multiple media selections. Default `false`.
572
572
  * @param {boolean} [props.hideLabelFromVision] - Whether the label should be hidden from vision.
573
573
  * @param {boolean} [props.isExpanded] - Whether to render in an expanded form. Default `false`.
@@ -937,7 +937,10 @@ export default function MediaEdit< Item >( {
937
937
  setTargetItemId={ setTargetItemId }
938
938
  />
939
939
  { field.description && (
940
- <Text variant="muted">
940
+ <Text
941
+ variant="muted"
942
+ className="fields__media-edit-description"
943
+ >
941
944
  { field.description }
942
945
  </Text>
943
946
  ) }
@@ -30,6 +30,11 @@ fieldset.fields__media-edit {
30
30
  color: $gray-900;
31
31
  }
32
32
 
33
+ .fields__media-edit-description {
34
+ font-size: $helptext-font-size;
35
+ line-height: 1.5;
36
+ }
37
+
33
38
  /* stylelint-disable-next-line property-no-unknown -- '@container' not globally permitted */
34
39
  container-type: inline-size;
35
40
 
@@ -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';
@@ -7,10 +7,10 @@ import { __ } from '@wordpress/i18n';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import type { BasePost } from '../../types';
10
+ import type { BasePostWithEditedEntity } from '../../types';
11
11
  import PostContentInfoView from './post-content-info-view';
12
12
 
13
- const postContentInfoField: Field< BasePost > = {
13
+ const postContentInfoField: Field< BasePostWithEditedEntity > = {
14
14
  label: __( 'Post content information' ),
15
15
  id: 'post-content-info',
16
16
  type: 'text',
@@ -14,16 +14,22 @@ import { useMemo } from '@wordpress/element';
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
- import type { BasePost } from '../../types';
17
+ import type { BasePostWithEditedEntity } from '../../types';
18
18
 
19
19
  // Taken from packages/editor/src/components/time-to-read/index.js.
20
20
  const AVERAGE_READING_RATE = 189;
21
21
 
22
- export default function PostContentInfoView( { item }: { item: BasePost } ) {
23
- const content =
24
- typeof item.content === 'string'
25
- ? item.content
26
- : item.content?.raw || '';
22
+ export default function PostContentInfoView( {
23
+ item,
24
+ }: {
25
+ item: BasePostWithEditedEntity;
26
+ } ) {
27
+ let content = '';
28
+ if ( typeof item.content === 'string' ) {
29
+ content = item.content;
30
+ } else if ( typeof item.content === 'function' ) {
31
+ content = item.content( item );
32
+ }
27
33
 
28
34
  /*
29
35
  * translators: If your word count is based on single characters (e.g. East Asian characters),
@@ -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;
@@ -2,8 +2,8 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useState } from '@wordpress/element';
5
- import { DataForm, DataViews, type Form } from '@wordpress/dataviews';
6
- import type { Field, View } from '@wordpress/dataviews';
5
+ import type { Field, View, Form } from '@wordpress/dataviews';
6
+ import { DataForm, DataViews } from '@wordpress/dataviews';
7
7
 
8
8
  /**
9
9
  * Internal dependencies
package/src/types.ts CHANGED
@@ -54,12 +54,19 @@ 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;
60
61
  author?: number;
61
62
  }
62
63
 
64
+ export interface BasePostWithEditedEntity extends Omit< BasePost, 'content' > {
65
+ content:
66
+ | BasePost[ 'content' ]
67
+ | ( ( record: BasePostWithEditedEntity ) => string );
68
+ }
69
+
63
70
  export interface BasePostWithEmbeddedAuthor extends BasePost {
64
71
  _embedded: EmbeddedAuthor;
65
72
  }
@@ -127,6 +134,7 @@ export interface PostType {
127
134
  supports?: {
128
135
  'page-attributes'?: boolean;
129
136
  title?: boolean;
137
+ excerpt?: boolean;
130
138
  revisions?: boolean;
131
139
  author?: string;
132
140
  thumbnail?: string;
@@ -147,6 +155,7 @@ export interface MediaEditProps< Item >
147
155
  > {
148
156
  /**
149
157
  * Array of allowed media types (e.g., ['image', 'video']).
158
+ * Use ['*'] to allow all file types.
150
159
  *
151
160
  * @default ['image']
152
161
  */
@@ -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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