@wordpress/fields 0.35.0 → 0.36.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 (36) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -1
  3. package/build/components/create-template-part-modal/index.cjs.map +2 -2
  4. package/build/components/media-edit/index.cjs +8 -1
  5. package/build/components/media-edit/index.cjs.map +2 -2
  6. package/build/fields/post-content-info/index.cjs.map +2 -2
  7. package/build/fields/post-content-info/post-content-info-view.cjs +9 -2
  8. package/build/fields/post-content-info/post-content-info-view.cjs.map +2 -2
  9. package/build/types.cjs.map +1 -1
  10. package/build-module/components/create-template-part-modal/index.mjs.map +2 -2
  11. package/build-module/components/media-edit/index.mjs +8 -1
  12. package/build-module/components/media-edit/index.mjs.map +2 -2
  13. package/build-module/fields/post-content-info/index.mjs.map +2 -2
  14. package/build-module/fields/post-content-info/post-content-info-view.mjs +9 -2
  15. package/build-module/fields/post-content-info/post-content-info-view.mjs.map +2 -2
  16. package/build-style/style-rtl.css +4 -0
  17. package/build-style/style.css +4 -0
  18. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
  19. package/build-types/components/media-edit/index.d.ts +1 -1
  20. package/build-types/components/media-edit/index.d.ts.map +1 -1
  21. package/build-types/fields/post-content-info/index.d.ts +2 -2
  22. package/build-types/fields/post-content-info/index.d.ts.map +1 -1
  23. package/build-types/fields/post-content-info/post-content-info-view.d.ts +3 -3
  24. package/build-types/fields/post-content-info/post-content-info-view.d.ts.map +1 -1
  25. package/build-types/fields/status/status-elements.d.ts +11 -11
  26. package/build-types/stories/index.story.d.ts.map +1 -1
  27. package/build-types/types.d.ts +4 -0
  28. package/build-types/types.d.ts.map +1 -1
  29. package/package.json +26 -26
  30. package/src/components/create-template-part-modal/index.tsx +0 -1
  31. package/src/components/media-edit/index.tsx +5 -2
  32. package/src/components/media-edit/style.scss +5 -0
  33. package/src/fields/post-content-info/index.ts +2 -2
  34. package/src/fields/post-content-info/post-content-info-view.tsx +12 -6
  35. package/src/stories/index.story.tsx +2 -9
  36. package/src/types.ts +7 -0
@@ -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),
@@ -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
@@ -183,12 +183,6 @@ export const DataViewsPreview = () => {
183
183
  totalPages: 1,
184
184
  };
185
185
 
186
- const defaultLayouts = {
187
- table: {},
188
- list: {},
189
- grid: {},
190
- };
191
-
192
186
  return (
193
187
  <div style={ { padding: '20px' } }>
194
188
  <h2>Fields Package DataViews Preview</h2>
@@ -203,7 +197,6 @@ export const DataViewsPreview = () => {
203
197
  view={ view }
204
198
  onChangeView={ ( nextView: View ) => setView( nextView ) }
205
199
  paginationInfo={ paginationInfo }
206
- defaultLayouts={ defaultLayouts }
207
200
  />
208
201
  </div>
209
202
  );
package/src/types.ts CHANGED
@@ -61,6 +61,12 @@ export interface BasePost extends CommonPost {
61
61
  author?: number;
62
62
  }
63
63
 
64
+ export interface BasePostWithEditedEntity extends Omit< BasePost, 'content' > {
65
+ content:
66
+ | BasePost[ 'content' ]
67
+ | ( ( record: BasePostWithEditedEntity ) => string );
68
+ }
69
+
64
70
  export interface BasePostWithEmbeddedAuthor extends BasePost {
65
71
  _embedded: EmbeddedAuthor;
66
72
  }
@@ -149,6 +155,7 @@ export interface MediaEditProps< Item >
149
155
  > {
150
156
  /**
151
157
  * Array of allowed media types (e.g., ['image', 'video']).
158
+ * Use ['*'] to allow all file types.
152
159
  *
153
160
  * @default ['image']
154
161
  */