@wordpress/fields 0.1.0 → 0.3.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 (135) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +12 -0
  3. package/build/actions/delete-post.js +9 -9
  4. package/build/actions/delete-post.js.map +1 -1
  5. package/build/actions/duplicate-post.js +3 -3
  6. package/build/actions/duplicate-post.js.map +1 -1
  7. package/build/actions/export-pattern.js.map +1 -1
  8. package/build/actions/permanently-delete-post.js +4 -3
  9. package/build/actions/permanently-delete-post.js.map +1 -1
  10. package/build/actions/reset-post.js +2 -2
  11. package/build/actions/reset-post.js.map +1 -1
  12. package/build/actions/restore-post.js +6 -5
  13. package/build/actions/restore-post.js.map +1 -1
  14. package/build/actions/trash-post.js +5 -4
  15. package/build/actions/trash-post.js.map +1 -1
  16. package/build/actions/view-post-revisions.js +1 -1
  17. package/build/actions/view-post-revisions.js.map +1 -1
  18. package/build/fields/featured-image/featured-image-edit.js +113 -0
  19. package/build/fields/featured-image/featured-image-edit.js.map +1 -0
  20. package/build/fields/featured-image/featured-image-view.js +41 -0
  21. package/build/fields/featured-image/featured-image-view.js.map +1 -0
  22. package/build/fields/featured-image/index.js +30 -0
  23. package/build/fields/featured-image/index.js.map +1 -0
  24. package/build/fields/index.js +21 -0
  25. package/build/fields/index.js.map +1 -1
  26. package/build/fields/parent/index.js +34 -0
  27. package/build/fields/parent/index.js.map +1 -0
  28. package/build/fields/parent/parent-edit.js +243 -0
  29. package/build/fields/parent/parent-edit.js.map +1 -0
  30. package/build/fields/parent/parent-view.js +39 -0
  31. package/build/fields/parent/parent-view.js.map +1 -0
  32. package/build/fields/parent/utils.js +20 -0
  33. package/build/fields/parent/utils.js.map +1 -0
  34. package/build/fields/slug/index.js +30 -0
  35. package/build/fields/slug/index.js.map +1 -0
  36. package/build/fields/slug/slug-edit.js +132 -0
  37. package/build/fields/slug/slug-edit.js.map +1 -0
  38. package/build/fields/slug/slug-view.js +30 -0
  39. package/build/fields/slug/slug-view.js.map +1 -0
  40. package/build/mutation/index.js +3 -2
  41. package/build/mutation/index.js.map +1 -1
  42. package/build/types.js.map +1 -1
  43. package/build-module/actions/delete-post.js +11 -12
  44. package/build-module/actions/delete-post.js.map +1 -1
  45. package/build-module/actions/duplicate-post.js +4 -5
  46. package/build-module/actions/duplicate-post.js.map +1 -1
  47. package/build-module/actions/export-pattern.js.map +1 -1
  48. package/build-module/actions/permanently-delete-post.js +4 -3
  49. package/build-module/actions/permanently-delete-post.js.map +1 -1
  50. package/build-module/actions/rename-post.js +1 -2
  51. package/build-module/actions/rename-post.js.map +1 -1
  52. package/build-module/actions/reorder-page.js +1 -2
  53. package/build-module/actions/reorder-page.js.map +1 -1
  54. package/build-module/actions/reset-post.js +3 -4
  55. package/build-module/actions/reset-post.js.map +1 -1
  56. package/build-module/actions/restore-post.js +6 -5
  57. package/build-module/actions/restore-post.js.map +1 -1
  58. package/build-module/actions/trash-post.js +6 -6
  59. package/build-module/actions/trash-post.js.map +1 -1
  60. package/build-module/actions/view-post-revisions.js +1 -1
  61. package/build-module/actions/view-post-revisions.js.map +1 -1
  62. package/build-module/fields/featured-image/featured-image-edit.js +105 -0
  63. package/build-module/fields/featured-image/featured-image-edit.js.map +1 -0
  64. package/build-module/fields/featured-image/featured-image-view.js +33 -0
  65. package/build-module/fields/featured-image/featured-image-view.js.map +1 -0
  66. package/build-module/fields/featured-image/index.js +24 -0
  67. package/build-module/fields/featured-image/index.js.map +1 -0
  68. package/build-module/fields/index.js +3 -0
  69. package/build-module/fields/index.js.map +1 -1
  70. package/build-module/fields/parent/index.js +28 -0
  71. package/build-module/fields/parent/index.js.map +1 -0
  72. package/build-module/fields/parent/parent-edit.js +230 -0
  73. package/build-module/fields/parent/parent-edit.js.map +1 -0
  74. package/build-module/fields/parent/parent-view.js +32 -0
  75. package/build-module/fields/parent/parent-view.js.map +1 -0
  76. package/build-module/fields/parent/utils.js +14 -0
  77. package/build-module/fields/parent/utils.js.map +1 -0
  78. package/build-module/fields/slug/index.js +23 -0
  79. package/build-module/fields/slug/index.js.map +1 -0
  80. package/build-module/fields/slug/slug-edit.js +125 -0
  81. package/build-module/fields/slug/slug-edit.js.map +1 -0
  82. package/build-module/fields/slug/slug-view.js +24 -0
  83. package/build-module/fields/slug/slug-view.js.map +1 -0
  84. package/build-module/mutation/index.js +3 -2
  85. package/build-module/mutation/index.js.map +1 -1
  86. package/build-module/types.js.map +1 -1
  87. package/build-style/styles-rtl.css +134 -0
  88. package/build-style/styles.css +134 -0
  89. package/build-types/actions/delete-post.d.ts.map +1 -1
  90. package/build-types/fields/featured-image/featured-image-edit.d.ts +7 -0
  91. package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -0
  92. package/build-types/fields/featured-image/featured-image-view.d.ts +7 -0
  93. package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -0
  94. package/build-types/fields/featured-image/index.d.ts +11 -0
  95. package/build-types/fields/featured-image/index.d.ts.map +1 -0
  96. package/build-types/fields/index.d.ts +3 -0
  97. package/build-types/fields/index.d.ts.map +1 -1
  98. package/build-types/fields/parent/index.d.ts +14 -0
  99. package/build-types/fields/parent/index.d.ts.map +1 -0
  100. package/build-types/fields/parent/parent-edit.d.ts +9 -0
  101. package/build-types/fields/parent/parent-edit.d.ts.map +1 -0
  102. package/build-types/fields/parent/parent-view.d.ts +7 -0
  103. package/build-types/fields/parent/parent-view.d.ts.map +1 -0
  104. package/build-types/fields/parent/utils.d.ts +6 -0
  105. package/build-types/fields/parent/utils.d.ts.map +1 -0
  106. package/build-types/fields/slug/index.d.ts +11 -0
  107. package/build-types/fields/slug/index.d.ts.map +1 -0
  108. package/build-types/fields/slug/slug-edit.d.ts +8 -0
  109. package/build-types/fields/slug/slug-edit.d.ts.map +1 -0
  110. package/build-types/fields/slug/slug-view.d.ts +9 -0
  111. package/build-types/fields/slug/slug-view.d.ts.map +1 -0
  112. package/build-types/types.d.ts +2 -0
  113. package/build-types/types.d.ts.map +1 -1
  114. package/package.json +27 -23
  115. package/src/actions/delete-post.tsx +8 -5
  116. package/src/actions/duplicate-post.tsx +2 -2
  117. package/src/actions/view-post-revisions.tsx +1 -1
  118. package/src/fields/featured-image/featured-image-edit.tsx +122 -0
  119. package/src/fields/featured-image/featured-image-view.tsx +38 -0
  120. package/src/fields/featured-image/index.ts +24 -0
  121. package/src/fields/featured-image/style.scss +95 -0
  122. package/src/fields/index.ts +3 -0
  123. package/src/fields/parent/index.ts +27 -0
  124. package/src/fields/parent/parent-edit.tsx +348 -0
  125. package/src/fields/parent/parent-view.tsx +33 -0
  126. package/src/fields/parent/utils.ts +18 -0
  127. package/src/fields/slug/index.ts +23 -0
  128. package/src/fields/slug/slug-edit.tsx +156 -0
  129. package/src/fields/slug/slug-view.tsx +26 -0
  130. package/src/fields/slug/style.scss +22 -0
  131. package/src/mutation/index.ts +3 -3
  132. package/src/styles.scss +1 -0
  133. package/src/types.ts +2 -0
  134. package/tsconfig.json +3 -1
  135. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/fields/parent/utils.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,wBAAwB,CAAE,IAAI,EAAE,QAAQ,UAMvD"}
@@ -0,0 +1,11 @@
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 slugField: Field<BasePost>;
10
+ export default slugField;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/slug/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,QAAA,MAAM,SAAS,EAAE,KAAK,CAAE,QAAQ,CAO/B,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { DataFormControlProps } from '@wordpress/dataviews';
2
+ /**
3
+ * Internal dependencies
4
+ */
5
+ import type { BasePost } from '../../types';
6
+ declare const SlugEdit: ({ field, onChange, data, }: DataFormControlProps<BasePost>) => import("react").JSX.Element;
7
+ export default SlugEdit;
8
+ //# sourceMappingURL=slug-edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slug-edit.d.ts","sourceRoot":"","sources":["../../../src/fields/slug/slug-edit.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGjE;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,QAAA,MAAM,QAAQ,+BAIX,oBAAoB,CAAE,QAAQ,CAAE,gCA6HlC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { BasePost } from '../../types';
5
+ declare const SlugView: ({ item }: {
6
+ item: BasePost;
7
+ }) => string;
8
+ export default SlugView;
9
+ //# sourceMappingURL=slug-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slug-view.d.ts","sourceRoot":"","sources":["../../../src/fields/slug/slug-view.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,QAAA,MAAM,QAAQ,aAAe;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,WAa9C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -43,6 +43,8 @@ export interface BasePost extends CommonPost {
43
43
  menu_order?: number;
44
44
  ping_status?: 'open' | 'closed';
45
45
  link?: string;
46
+ slug?: string;
47
+ permalink_template?: string;
46
48
  }
47
49
  export interface Template extends CommonPost {
48
50
  type: 'wp_template';
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GACZ,WAAW,GACX,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,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvD,iBAAiB,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,CAAE,GAAG,EAAE,MAAM,GAAI;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,QAAS,SAAQ,UAAU;IAC3C,cAAc,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,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AAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,OAAQ,SAAQ,UAAU;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEhE,MAAM,MAAM,mBAAmB,GAAG,IAAI,GAAG;IACxC,WAAW,EAAE;QACZ,MAAM,EAAE,OAAO,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;KAChB,CAAC;CACF,CAAC;AAEF,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE;QACV,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,SAAS,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACF;AAGD,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/fields",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,28 +31,31 @@
31
31
  "src/**/*.scss"
32
32
  ],
33
33
  "dependencies": {
34
- "@babel/runtime": "^7.16.0",
35
- "@wordpress/api-fetch": "^7.9.0",
36
- "@wordpress/blob": "^4.9.0",
37
- "@wordpress/blocks": "^13.9.0",
38
- "@wordpress/components": "^28.9.0",
39
- "@wordpress/compose": "^7.9.0",
40
- "@wordpress/core-data": "^7.9.0",
41
- "@wordpress/data": "^10.9.0",
42
- "@wordpress/dataviews": "^4.5.0",
43
- "@wordpress/element": "^6.9.0",
44
- "@wordpress/hooks": "^4.9.0",
45
- "@wordpress/html-entities": "^4.9.0",
46
- "@wordpress/i18n": "^5.9.0",
47
- "@wordpress/icons": "^10.9.0",
48
- "@wordpress/notices": "^5.9.0",
49
- "@wordpress/patterns": "^2.9.0",
50
- "@wordpress/primitives": "^4.9.0",
51
- "@wordpress/private-apis": "^1.9.0",
52
- "@wordpress/url": "^4.9.0",
53
- "@wordpress/warning": "^3.9.0",
34
+ "@babel/runtime": "7.25.7",
35
+ "@wordpress/api-fetch": "*",
36
+ "@wordpress/blob": "*",
37
+ "@wordpress/blocks": "*",
38
+ "@wordpress/components": "*",
39
+ "@wordpress/compose": "*",
40
+ "@wordpress/core-data": "*",
41
+ "@wordpress/data": "*",
42
+ "@wordpress/dataviews": "*",
43
+ "@wordpress/element": "*",
44
+ "@wordpress/hooks": "*",
45
+ "@wordpress/html-entities": "*",
46
+ "@wordpress/i18n": "*",
47
+ "@wordpress/icons": "*",
48
+ "@wordpress/media-utils": "*",
49
+ "@wordpress/notices": "*",
50
+ "@wordpress/patterns": "*",
51
+ "@wordpress/primitives": "*",
52
+ "@wordpress/private-apis": "*",
53
+ "@wordpress/router": "*",
54
+ "@wordpress/url": "*",
55
+ "@wordpress/warning": "*",
54
56
  "change-case": "4.1.2",
55
- "client-zip": "^2.4.5"
57
+ "client-zip": "^2.4.5",
58
+ "remove-accents": "^0.5.0"
56
59
  },
57
60
  "peerDependencies": {
58
61
  "react": "^18.0.0"
@@ -60,5 +63,6 @@
60
63
  "publishConfig": {
61
64
  "access": "public"
62
65
  },
63
- "gitHead": "2e5495c635910cb34bfaca3c6258d2e989f66214"
66
+ "wpScript": true,
67
+ "gitHead": "dcf4613b33b0eda14e203ac30f700ed0db70347f"
64
68
  }
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { trash } from '@wordpress/icons';
5
- import { __, _n, sprintf } from '@wordpress/i18n';
5
+ import { __, _x, _n, sprintf } from '@wordpress/i18n';
6
6
  import { useState } from '@wordpress/element';
7
7
  import {
8
8
  Button,
@@ -66,8 +66,8 @@ const deletePostAction: Action< Template | TemplatePart | Pattern > = {
66
66
  items.length
67
67
  )
68
68
  : sprintf(
69
- // translators: %s: The template or template part's titles
70
- __( 'Delete "%s"?' ),
69
+ // translators: %s: The template or template part's title
70
+ _x( 'Delete "%s"?', 'template part' ),
71
71
  getItemTitle( items[ 0 ] )
72
72
  ) }
73
73
  </Text>
@@ -100,8 +100,11 @@ const deletePostAction: Action< Template | TemplatePart | Pattern > = {
100
100
  )
101
101
  )
102
102
  : sprintf(
103
- /* translators: The template/part's name. */
104
- __( '"%s" deleted.' ),
103
+ /* translators: %s: The template/part's name. */
104
+ _x(
105
+ '"%s" deleted.',
106
+ 'template part'
107
+ ),
105
108
  decodeEntities(
106
109
  getItemTitle( item )
107
110
  )
@@ -38,7 +38,7 @@ const duplicatePost: Action< BasePost > = {
38
38
  ...items[ 0 ],
39
39
  title: sprintf(
40
40
  /* translators: %s: Existing template title */
41
- __( '%s (Copy)' ),
41
+ _x( '%s (Copy)', 'template' ),
42
42
  getItemTitle( items[ 0 ] )
43
43
  ),
44
44
  } );
@@ -104,7 +104,7 @@ const duplicatePost: Action< BasePost > = {
104
104
 
105
105
  createSuccessNotice(
106
106
  sprintf(
107
- // translators: %s: Title of the created template e.g: "Category".
107
+ // translators: %s: Title of the created post or template, e.g: "Hello world".
108
108
  __( '"%s" successfully created.' ),
109
109
  decodeEntities( newItem.title?.rendered || item.title )
110
110
  ),
@@ -17,7 +17,7 @@ const viewPostRevisions: Action< Post > = {
17
17
  const revisionsCount =
18
18
  items[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
19
19
  return sprintf(
20
- /* translators: %s: number of revisions */
20
+ /* translators: %s: number of revisions. */
21
21
  __( 'View revisions (%s)' ),
22
22
  revisionsCount
23
23
  );
@@ -0,0 +1,122 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Button, __experimentalGrid as Grid } from '@wordpress/components';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { useCallback, useRef } from '@wordpress/element';
7
+ // @ts-ignore
8
+ import { MediaUpload } from '@wordpress/media-utils';
9
+ import { lineSolid } from '@wordpress/icons';
10
+ import { store as coreStore } from '@wordpress/core-data';
11
+ import type { DataFormControlProps } from '@wordpress/dataviews';
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import type { BasePost } from '../../types';
16
+ import { __ } from '@wordpress/i18n';
17
+
18
+ export const FeaturedImageEdit = ( {
19
+ data,
20
+ field,
21
+ onChange,
22
+ }: DataFormControlProps< BasePost > ) => {
23
+ const { id } = field;
24
+
25
+ const value = field.getValue( { item: data } );
26
+
27
+ const media = useSelect(
28
+ ( select ) => {
29
+ const { getEntityRecord } = select( coreStore );
30
+ return getEntityRecord( 'root', 'media', value );
31
+ },
32
+ [ value ]
33
+ );
34
+
35
+ const onChangeControl = useCallback(
36
+ ( newValue: number ) =>
37
+ onChange( {
38
+ [ id ]: newValue,
39
+ } ),
40
+ [ id, onChange ]
41
+ );
42
+
43
+ const url = media?.source_url;
44
+ const title = media?.title?.rendered;
45
+ const ref = useRef( null );
46
+
47
+ return (
48
+ <fieldset className="fields-controls__featured-image">
49
+ <div className="fields-controls__featured-image-container">
50
+ <MediaUpload
51
+ onSelect={ ( selectedMedia: { id: number } ) => {
52
+ onChangeControl( selectedMedia.id );
53
+ } }
54
+ allowedTypes={ [ 'image' ] }
55
+ render={ ( { open }: { open: () => void } ) => {
56
+ return (
57
+ <div
58
+ ref={ ref }
59
+ role="button"
60
+ tabIndex={ -1 }
61
+ onClick={ () => {
62
+ open();
63
+ } }
64
+ onKeyDown={ open }
65
+ >
66
+ <Grid
67
+ rowGap={ 0 }
68
+ columnGap={ 8 }
69
+ templateColumns="24px 1fr 24px"
70
+ >
71
+ { url && (
72
+ <>
73
+ <img
74
+ className="fields-controls__featured-image-image"
75
+ alt=""
76
+ width={ 24 }
77
+ height={ 24 }
78
+ src={ url }
79
+ />
80
+ <span className="fields-controls__featured-image-title">
81
+ { title }
82
+ </span>
83
+ </>
84
+ ) }
85
+ { ! url && (
86
+ <>
87
+ <span
88
+ className="fields-controls__featured-image-placeholder"
89
+ style={ {
90
+ width: '24px',
91
+ height: '24px',
92
+ } }
93
+ />
94
+ <span className="fields-controls__featured-image-title">
95
+ { __( 'Choose an image…' ) }
96
+ </span>
97
+ </>
98
+ ) }
99
+ { url && (
100
+ <>
101
+ <Button
102
+ size="small"
103
+ className="fields-controls__featured-image-remove-button"
104
+ icon={ lineSolid }
105
+ onClick={ (
106
+ event: React.MouseEvent< HTMLButtonElement >
107
+ ) => {
108
+ event.stopPropagation();
109
+ onChangeControl( 0 );
110
+ } }
111
+ />
112
+ </>
113
+ ) }
114
+ </Grid>
115
+ </div>
116
+ );
117
+ } }
118
+ />
119
+ </div>
120
+ </fieldset>
121
+ );
122
+ };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { store as coreStore } from '@wordpress/core-data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import type { BasePost } from '../../types';
11
+ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
12
+
13
+ export const FeaturedImageView = ( {
14
+ item,
15
+ }: DataViewRenderFieldProps< BasePost > ) => {
16
+ const mediaId = item.featured_media;
17
+
18
+ const media = useSelect(
19
+ ( select ) => {
20
+ const { getEntityRecord } = select( coreStore );
21
+ return mediaId ? getEntityRecord( 'root', 'media', mediaId ) : null;
22
+ },
23
+ [ mediaId ]
24
+ );
25
+ const url = media?.source_url;
26
+
27
+ if ( url ) {
28
+ return (
29
+ <img
30
+ className="fields-controls__featured-image-image"
31
+ src={ url }
32
+ alt=""
33
+ />
34
+ );
35
+ }
36
+
37
+ return <span className="fields-controls__featured-image-placeholder" />;
38
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { Field } from '@wordpress/dataviews';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import type { BasePost } from '../../types';
10
+ import { __ } from '@wordpress/i18n';
11
+ import { FeaturedImageEdit } from './featured-image-edit';
12
+ import { FeaturedImageView } from './featured-image-view';
13
+
14
+ const featuredImageField: Field< BasePost > = {
15
+ id: 'featured_media',
16
+ type: 'text',
17
+ label: __( 'Featured Image' ),
18
+ getValue: ( { item } ) => item.featured_media,
19
+ Edit: FeaturedImageEdit,
20
+ render: FeaturedImageView,
21
+ enableSorting: false,
22
+ };
23
+
24
+ export default featuredImageField;
@@ -0,0 +1,95 @@
1
+ .fields-controls__featured-image-placeholder {
2
+ border-radius: $radius-small;
3
+ box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
4
+ display: inline-block;
5
+ padding: 0;
6
+ background:
7
+ $white
8
+ linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
9
+ }
10
+
11
+ .fields-controls__featured-image-title {
12
+ width: 100%;
13
+ color: $gray-900;
14
+ white-space: nowrap;
15
+ text-overflow: ellipsis;
16
+ overflow: hidden;
17
+ }
18
+
19
+ .fields-controls__featured-image-image {
20
+ width: 100%;
21
+ height: 100%;
22
+ border-radius: $radius-small;
23
+ align-self: center;
24
+ }
25
+
26
+ .fields-controls__featured-image-container {
27
+ .fields-controls__featured-image-placeholder {
28
+ margin: 0;
29
+ }
30
+
31
+ span {
32
+ margin-right: auto;
33
+ }
34
+ }
35
+
36
+ fieldset.fields-controls__featured-image {
37
+ .fields-controls__featured-image-container {
38
+ border: $border-width solid $gray-300;
39
+ border-radius: $radius-small;
40
+ padding: 8px 12px;
41
+ cursor: pointer;
42
+ &:hover {
43
+ background-color: $gray-100;
44
+ }
45
+ }
46
+
47
+ .fields-controls__featured-image-placeholder {
48
+ width: 24px;
49
+ height: 24px;
50
+ }
51
+
52
+ span {
53
+ align-self: center;
54
+ text-align: start;
55
+ white-space: nowrap;
56
+ }
57
+
58
+ .fields-controls__featured-image-upload-button {
59
+ padding: 0;
60
+ height: fit-content;
61
+ &:hover,
62
+ &:focus {
63
+ border: 0;
64
+ color: unset;
65
+ }
66
+ }
67
+
68
+ .fields-controls__featured-image-remove-button {
69
+ place-self: end;
70
+ }
71
+ }
72
+
73
+ .dataforms-layouts-panel__field-control {
74
+ .fields-controls__featured-image-image {
75
+ width: 16px;
76
+ height: 16px;
77
+ }
78
+
79
+ .fields-controls__featured-image-placeholder {
80
+ width: 16px;
81
+ height: 16px;
82
+ }
83
+ }
84
+
85
+ .dataviews-view-table__cell-content-wrapper {
86
+ .fields-controls__featured-image-image {
87
+ width: 32px;
88
+ height: 32px;
89
+ }
90
+
91
+ .fields-controls__featured-image-placeholder {
92
+ width: 32px;
93
+ height: 32px;
94
+ }
95
+ }
@@ -1,2 +1,5 @@
1
+ export { default as slugField } from './slug';
1
2
  export { default as titleField } from './title';
2
3
  export { default as orderField } from './order';
4
+ export { default as featuredImageField } from './featured-image';
5
+ export { default as parentField } from './parent';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { Field } from '@wordpress/dataviews';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import type { BasePost } from '../../types';
10
+ import { __ } from '@wordpress/i18n';
11
+ import { ParentEdit } from './parent-edit';
12
+ import { ParentView } from './parent-view';
13
+
14
+ const parentField: Field< BasePost > = {
15
+ id: 'parent',
16
+ type: 'text',
17
+ label: __( 'Parent' ),
18
+ getValue: ( { item } ) => item.parent,
19
+ Edit: ParentEdit,
20
+ render: ParentView,
21
+ enableSorting: true,
22
+ };
23
+
24
+ /**
25
+ * This field is used to display the post parent.
26
+ */
27
+ export default parentField;