@wordpress/fields 0.19.0 → 0.20.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 (31) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/fields/featured-image/featured-image-edit.js +1 -1
  3. package/build/fields/featured-image/featured-image-edit.js.map +1 -1
  4. package/build/fields/featured-image/featured-image-view.js +6 -3
  5. package/build/fields/featured-image/featured-image-view.js.map +1 -1
  6. package/build/fields/order/index.js +4 -1
  7. package/build/fields/order/index.js.map +1 -1
  8. package/build/fields/password/index.js +2 -0
  9. package/build/fields/password/index.js.map +1 -1
  10. package/build-module/fields/featured-image/featured-image-edit.js +1 -1
  11. package/build-module/fields/featured-image/featured-image-edit.js.map +1 -1
  12. package/build-module/fields/featured-image/featured-image-view.js +6 -3
  13. package/build-module/fields/featured-image/featured-image-view.js.map +1 -1
  14. package/build-module/fields/order/index.js +4 -1
  15. package/build-module/fields/order/index.js.map +1 -1
  16. package/build-module/fields/password/index.js +3 -0
  17. package/build-module/fields/password/index.js.map +1 -1
  18. package/build-style/style-rtl.css +20 -3
  19. package/build-style/style.css +20 -3
  20. package/build-types/fields/featured-image/featured-image-view.d.ts +1 -1
  21. package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -1
  22. package/build-types/fields/order/index.d.ts.map +1 -1
  23. package/build-types/fields/password/index.d.ts.map +1 -1
  24. package/build-types/fields/status/status-elements.d.ts +11 -11
  25. package/package.json +25 -25
  26. package/src/fields/featured-image/featured-image-edit.tsx +1 -1
  27. package/src/fields/featured-image/featured-image-view.tsx +15 -1
  28. package/src/fields/featured-image/style.scss +18 -2
  29. package/src/fields/order/index.ts +3 -0
  30. package/src/fields/password/index.tsx +2 -0
  31. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.20.0 (2025-08-07)
6
+
5
7
  ## 0.19.0 (2025-07-23)
6
8
 
7
9
  ## 0.18.0 (2025-06-25)
@@ -37,7 +37,7 @@ const FeaturedImageEdit = ({
37
37
  const {
38
38
  getEntityRecord
39
39
  } = select(_coreData.store);
40
- return getEntityRecord('root', 'media', value);
40
+ return getEntityRecord('postType', 'attachment', value);
41
41
  }, [value]);
42
42
  const onChangeControl = (0, _element.useCallback)(newValue => onChange({
43
43
  [id]: newValue
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_data","_element","_mediaUtils","_icons","_coreData","_i18n","_jsxRuntime","FeaturedImageEdit","data","field","onChange","id","value","getValue","item","media","useSelect","select","getEntityRecord","coreStore","onChangeControl","useCallback","newValue","url","source_url","title","rendered","ref","useRef","jsx","className","children","MediaUpload","onSelect","selectedMedia","allowedTypes","render","open","role","tabIndex","onClick","onKeyDown","jsxs","__experimentalGrid","rowGap","columnGap","templateColumns","Fragment","alt","width","height","src","style","__","Button","size","icon","lineSolid","event","stopPropagation","exports"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\n// @ts-ignore\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'root', 'media', value );\n\t\t},\n\t\t[ value ]\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\tconst url = media?.source_url;\n\tconst title = media?.title?.rendered;\n\tconst ref = useRef( null );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__featured-image\">\n\t\t\t<div className=\"fields-controls__featured-image-container\">\n\t\t\t\t<MediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: { id: number } ) => {\n\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t} }\n\t\t\t\t\tallowedTypes={ [ 'image' ] }\n\t\t\t\t\trender={ ( { open }: { open: () => void } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonKeyDown={ open }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr 24px\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\theight={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose an image…' ) }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-remove-button\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChangeControl( 0 );\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\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WAAA,CAAAoC,IAAA,EAAApC,WAAA,CAAAyC,QAAA;gBAAAhB,QAAA,gBACC,IAAAzB,WAAA,CAAAuB,GAAA;kBACCC,SAAS,EAAC,6CAA6C;kBACvDsB,KAAK,EAAG;oBACPH,KAAK,EAAE,MAAM;oBACbC,MAAM,EAAE;kBACT;gBAAG,CACH,CAAC,eACF,IAAA5C,WAAA,CAAAuB,GAAA;kBAAMC,SAAS,EAAC,uCAAuC;kBAAAC,QAAA,EACpD,IAAAsB,QAAE,EAAE,kBAAmB;gBAAC,CACrB,CAAC;cAAA,CACN,CACF,EACC9B,GAAG,iBACJ,IAAAjB,WAAA,CAAAuB,GAAA,EAAAvB,WAAA,CAAAyC,QAAA;gBAAAhB,QAAA,eACC,IAAAzB,WAAA,CAAAuB,GAAA,EAAC/B,WAAA,CAAAwD,MAAM;kBACNC,IAAI,EAAC,OAAO;kBACZzB,SAAS,EAAC,+CAA+C;kBACzD0B,IAAI,EAAGC,gBAAW;kBAClBjB,OAAO,EACNkB,KAA4C,IACxC;oBACJA,KAAK,CAACC,eAAe,CAAC,CAAC;oBACvBvC,eAAe,CAAE,CAAE,CAAC;kBACrB;gBAAG,CACH;cAAC,CACD,CACF;YAAA,CACI;UAAC,CACH,CAAC;QAER;MAAG,CACH;IAAC,CACE;EAAC,CACG,CAAC;AAEb,CAAC;AAACwC,OAAA,CAAArD,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_data","_element","_mediaUtils","_icons","_coreData","_i18n","_jsxRuntime","FeaturedImageEdit","data","field","onChange","id","value","getValue","item","media","useSelect","select","getEntityRecord","coreStore","onChangeControl","useCallback","newValue","url","source_url","title","rendered","ref","useRef","jsx","className","children","MediaUpload","onSelect","selectedMedia","allowedTypes","render","open","role","tabIndex","onClick","onKeyDown","jsxs","__experimentalGrid","rowGap","columnGap","templateColumns","Fragment","alt","width","height","src","style","__","Button","size","icon","lineSolid","event","stopPropagation","exports"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\n// @ts-ignore\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'postType', 'attachment', value );\n\t\t},\n\t\t[ value ]\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\tconst url = media?.source_url;\n\tconst title = media?.title?.rendered;\n\tconst ref = useRef( null );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__featured-image\">\n\t\t\t<div className=\"fields-controls__featured-image-container\">\n\t\t\t\t<MediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: { id: number } ) => {\n\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t} }\n\t\t\t\t\tallowedTypes={ [ 'image' ] }\n\t\t\t\t\trender={ ( { open }: { open: () => void } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonKeyDown={ open }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr 24px\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\theight={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose an image…' ) }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-remove-button\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChangeControl( 0 );\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,KAAA,GAAAN,OAAA;AAAqC,IAAAO,WAAA,GAAAP,OAAA;AAXrC;AACA;AACA;;AAIA;;AAOA;AACA;AACA;;AAGO,MAAMQ,iBAAiB,GAAGA,CAAE;EAClCC,IAAI;EACJC,KAAK;EACLC;AACiC,CAAC,KAAM;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGF,KAAK;EAE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,OAAO,EACNkB,KAA4C,IACxC;oBACJA,KAAK,CAACC,eAAe,CAAC,CAAC;oBACvBvC,eAAe,CAAE,CAAE,CAAC;kBACrB;gBAAG,CACH;cAAC,CACD,CACF;YAAA,CACI;UAAC,CACH,CAAC;QAER;MAAG,CACH;IAAC,CACE;EAAC,CACG,CAAC;AAEb,CAAC;AAACwC,OAAA,CAAArD,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -16,21 +16,24 @@ var _jsxRuntime = require("react/jsx-runtime");
16
16
  */
17
17
 
18
18
  const FeaturedImageView = ({
19
- item
19
+ item,
20
+ config
20
21
  }) => {
21
22
  const mediaId = item.featured_media;
22
23
  const media = (0, _data.useSelect)(select => {
23
24
  const {
24
25
  getEntityRecord
25
26
  } = select(_coreData.store);
26
- return mediaId ? getEntityRecord('root', 'media', mediaId) : null;
27
+ return mediaId ? getEntityRecord('postType', 'attachment', mediaId) : null;
27
28
  }, [mediaId]);
28
29
  const url = media?.source_url;
29
30
  if (url) {
30
31
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
31
32
  className: "fields-controls__featured-image-image",
32
33
  src: url,
33
- alt: ""
34
+ alt: "",
35
+ srcSet: media?.media_details?.sizes ? Object.values(media.media_details.sizes).map(size => `${size.source_url} ${size.width}w`).join(', ') : undefined,
36
+ sizes: config?.sizes || '100vw'
34
37
  });
35
38
  }
36
39
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_coreData","_jsxRuntime","FeaturedImageView","item","mediaId","featured_media","media","useSelect","select","getEntityRecord","coreStore","url","source_url","jsx","className","src","alt","exports"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageView = ( {\n\titem,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst mediaId = item.featured_media;\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn mediaId ? getEntityRecord( 'root', 'media', mediaId ) : null;\n\t\t},\n\t\t[ mediaId ]\n\t);\n\tconst url = media?.source_url;\n\n\tif ( url ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\tsrc={ url }\n\t\t\t\talt=\"\"\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <span className=\"fields-controls__featured-image-placeholder\" />;\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAA0D,IAAAE,WAAA,GAAAF,OAAA;AAJ1D;AACA;AACA;;AAKA;AACA;AACA;;AAGO,MAAMG,iBAAiB,GAAGA,CAAE;EAClCC;AACqC,CAAC,KAAM;EAC5C,MAAMC,OAAO,GAAGD,IAAI,CAACE,cAAc;EAEnC,MAAMC,KAAK,GAAG,IAAAC,eAAS,EACpBC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IAC/C,OAAON,OAAO,GAAGK,eAAe,CAAE,MAAM,EAAE,OAAO,EAAEL,OAAQ,CAAC,GAAG,IAAI;EACpE,CAAC,EACD,CAAEA,OAAO,CACV,CAAC;EACD,MAAMO,GAAG,GAAGL,KAAK,EAAEM,UAAU;EAE7B,IAAKD,GAAG,EAAG;IACV,oBACC,IAAAV,WAAA,CAAAY,GAAA;MACCC,SAAS,EAAC,uCAAuC;MACjDC,GAAG,EAAGJ,GAAK;MACXK,GAAG,EAAC;IAAE,CACN,CAAC;EAEJ;EAEA,oBAAO,IAAAf,WAAA,CAAAY,GAAA;IAAMC,SAAS,EAAC;EAA6C,CAAE,CAAC;AACxE,CAAC;AAACG,OAAA,CAAAf,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_coreData","_jsxRuntime","FeaturedImageView","item","config","mediaId","featured_media","media","useSelect","select","getEntityRecord","coreStore","url","source_url","jsx","className","src","alt","srcSet","media_details","sizes","Object","values","map","size","width","join","undefined","exports"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageView = ( {\n\titem,\n\tconfig,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst mediaId = item.featured_media;\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn mediaId\n\t\t\t\t? getEntityRecord( 'postType', 'attachment', mediaId )\n\t\t\t\t: null;\n\t\t},\n\t\t[ mediaId ]\n\t);\n\tconst url = media?.source_url;\n\n\tif ( url ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\tsrc={ url }\n\t\t\t\talt=\"\"\n\t\t\t\tsrcSet={\n\t\t\t\t\tmedia?.media_details?.sizes\n\t\t\t\t\t\t? Object.values( media.media_details.sizes )\n\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t( size: any ) =>\n\t\t\t\t\t\t\t\t\t\t`${ size.source_url } ${ size.width }w`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.join( ', ' )\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tsizes={ config?.sizes || '100vw' }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <span className=\"fields-controls__featured-image-placeholder\" />;\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAA0D,IAAAE,WAAA,GAAAF,OAAA;AAJ1D;AACA;AACA;;AAKA;AACA;AACA;;AAGO,MAAMG,iBAAiB,GAAGA,CAAE;EAClCC,IAAI;EACJC;AACqC,CAAC,KAAM;EAC5C,MAAMC,OAAO,GAAGF,IAAI,CAACG,cAAc;EAEnC,MAAMC,KAAK,GAAG,IAAAC,eAAS,EACpBC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IAC/C,OAAON,OAAO,GACXK,eAAe,CAAE,UAAU,EAAE,YAAY,EAAEL,OAAQ,CAAC,GACpD,IAAI;EACR,CAAC,EACD,CAAEA,OAAO,CACV,CAAC;EACD,MAAMO,GAAG,GAAGL,KAAK,EAAEM,UAAU;EAE7B,IAAKD,GAAG,EAAG;IACV,oBACC,IAAAX,WAAA,CAAAa,GAAA;MACCC,SAAS,EAAC,uCAAuC;MACjDC,GAAG,EAAGJ,GAAK;MACXK,GAAG,EAAC,EAAE;MACNC,MAAM,EACLX,KAAK,EAAEY,aAAa,EAAEC,KAAK,GACxBC,MAAM,CAACC,MAAM,CAAEf,KAAK,CAACY,aAAa,CAACC,KAAM,CAAC,CACzCG,GAAG,CACDC,IAAS,IACV,GAAIA,IAAI,CAACX,UAAU,IAAMW,IAAI,CAACC,KAAK,GACrC,CAAC,CACAC,IAAI,CAAE,IAAK,CAAC,GACbC,SACH;MACDP,KAAK,EAAGhB,MAAM,EAAEgB,KAAK,IAAI;IAAS,CAClC,CAAC;EAEJ;EAEA,oBAAO,IAAAnB,WAAA,CAAAa,GAAA;IAAMC,SAAS,EAAC;EAA6C,CAAE,CAAC;AACxE,CAAC;AAACa,OAAA,CAAA1B,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -18,7 +18,10 @@ const orderField = {
18
18
  type: 'integer',
19
19
  label: (0, _i18n.__)('Order'),
20
20
  description: (0, _i18n.__)('Determines the order of pages.'),
21
- filterBy: false
21
+ filterBy: false,
22
+ isValid: {
23
+ required: true
24
+ }
22
25
  };
23
26
 
24
27
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","orderField","id","type","label","__","description","filterBy","_default","exports","default"],"sources":["@wordpress/fields/src/fields/order/index.ts"],"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 orderField: Field< BasePost > = {\n\tid: 'menu_order',\n\ttype: 'integer',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n\tfilterBy: false,\n};\n\n/**\n * Order field for BasePost.\n */\nexport default orderField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,WAAW,EAAE,IAAAD,QAAE,EAAE,gCAAiC,CAAC;EACnDE,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeT,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","orderField","id","type","label","__","description","filterBy","isValid","required","_default","exports","default"],"sources":["@wordpress/fields/src/fields/order/index.ts"],"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 orderField: Field< BasePost > = {\n\tid: 'menu_order',\n\ttype: 'integer',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n\tfilterBy: false,\n\tisValid: {\n\t\trequired: true,\n\t},\n};\n\n/**\n * Order field for BasePost.\n */\nexport default orderField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,WAAW,EAAE,IAAAD,QAAE,EAAE,gCAAiC,CAAC;EACnDE,QAAQ,EAAE,KAAK;EACfC,OAAO,EAAE;IACRC,QAAQ,EAAE;EACX;AACD,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeX,UAAU","ignoreList":[]}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _i18n = require("@wordpress/i18n");
8
9
  var _edit = _interopRequireDefault(require("./edit"));
9
10
  /**
10
11
  * WordPress dependencies
@@ -17,6 +18,7 @@ var _edit = _interopRequireDefault(require("./edit"));
17
18
  const passwordField = {
18
19
  id: 'password',
19
20
  type: 'text',
21
+ label: (0, _i18n.__)('Password'),
20
22
  Edit: _edit.default,
21
23
  enableSorting: false,
22
24
  enableHiding: false,
@@ -1 +1 @@
1
- {"version":3,"names":["_edit","_interopRequireDefault","require","passwordField","id","type","Edit","PasswordEdit","enableSorting","enableHiding","isVisible","item","status","filterBy","_default","exports","default"],"sources":["@wordpress/fields/src/fields/password/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport PasswordEdit from './edit';\n\nconst passwordField: Field< BasePost > = {\n\tid: 'password',\n\ttype: 'text',\n\tEdit: PasswordEdit,\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => item.status !== 'private',\n\tfilterBy: false,\n};\n\n/**\n * Password field for BasePost.\n */\nexport default passwordField;\n"],"mappings":";;;;;;;AASA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAEC,aAAY;EAClBC,aAAa,EAAE,KAAK;EACpBC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAIC,IAAI,IAAMA,IAAI,CAACC,MAAM,KAAK,SAAS;EAChDC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeb,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_edit","_interopRequireDefault","passwordField","id","type","label","__","Edit","PasswordEdit","enableSorting","enableHiding","isVisible","item","status","filterBy","_default","exports","default"],"sources":["@wordpress/fields/src/fields/password/index.tsx"],"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 PasswordEdit from './edit';\n\nconst passwordField: Field< BasePost > = {\n\tid: 'password',\n\ttype: 'text',\n\tlabel: __( 'Password' ),\n\tEdit: PasswordEdit,\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => item.status !== 'private',\n\tfilterBy: false,\n};\n\n/**\n * Password field for BasePost.\n */\nexport default passwordField;\n"],"mappings":";;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA,MAAMG,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,UAAW,CAAC;EACvBC,IAAI,EAAEC,aAAY;EAClBC,aAAa,EAAE,KAAK;EACpBC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAIC,IAAI,IAAMA,IAAI,CAACC,MAAM,KAAK,SAAS;EAChDC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGef,aAAa","ignoreList":[]}
@@ -29,7 +29,7 @@ export const FeaturedImageEdit = ({
29
29
  const {
30
30
  getEntityRecord
31
31
  } = select(coreStore);
32
- return getEntityRecord('root', 'media', value);
32
+ return getEntityRecord('postType', 'attachment', value);
33
33
  }, [value]);
34
34
  const onChangeControl = useCallback(newValue => onChange({
35
35
  [id]: newValue
@@ -1 +1 @@
1
- {"version":3,"names":["Button","__experimentalGrid","Grid","useSelect","useCallback","useRef","MediaUpload","lineSolid","store","coreStore","__","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","FeaturedImageEdit","data","field","onChange","id","value","getValue","item","media","select","getEntityRecord","onChangeControl","newValue","url","source_url","title","rendered","ref","className","children","onSelect","selectedMedia","allowedTypes","render","open","role","tabIndex","onClick","onKeyDown","rowGap","columnGap","templateColumns","alt","width","height","src","style","size","icon","event","stopPropagation"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\n// @ts-ignore\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'root', 'media', value );\n\t\t},\n\t\t[ value ]\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\tconst url = media?.source_url;\n\tconst title = media?.title?.rendered;\n\tconst ref = useRef( null );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__featured-image\">\n\t\t\t<div className=\"fields-controls__featured-image-container\">\n\t\t\t\t<MediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: { id: number } ) => {\n\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t} }\n\t\t\t\t\tallowedTypes={ [ 'image' ] }\n\t\t\t\t\trender={ ( { open }: { open: () => void } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonKeyDown={ open }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr 24px\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\theight={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose an image…' ) }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-remove-button\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t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;gBAAK,CACF,CAAC;cAAA,CACN,CACF,EACC,CAAEF,GAAG,iBACNd,KAAA,CAAAF,SAAA;gBAAAsB,QAAA,gBACCxB,IAAA;kBACCuB,SAAS,EAAC,6CAA6C;kBACvDkB,KAAK,EAAG;oBACPH,KAAK,EAAE,MAAM;oBACbC,MAAM,EAAE;kBACT;gBAAG,CACH,CAAC,eACFvC,IAAA;kBAAMuB,SAAS,EAAC,uCAAuC;kBAAAC,QAAA,EACpD1B,EAAE,CAAE,kBAAmB;gBAAC,CACrB,CAAC;cAAA,CACN,CACF,EACCoB,GAAG,iBACJlB,IAAA,CAAAE,SAAA;gBAAAsB,QAAA,eACCxB,IAAA,CAACZ,MAAM;kBACNsD,IAAI,EAAC,OAAO;kBACZnB,SAAS,EAAC,+CAA+C;kBACzDoB,IAAI,EAAGhD,SAAW;kBAClBqC,OAAO,EACNY,KAA4C,IACxC;oBACJA,KAAK,CAACC,eAAe,CAAC,CAAC;oBACvB7B,eAAe,CAAE,CAAE,CAAC;kBACrB;gBAAG,CACH;cAAC,CACD,CACF;YAAA,CACI;UAAC,CACH,CAAC;QAER;MAAG,CACH;IAAC,CACE;EAAC,CACG,CAAC;AAEb,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Button","__experimentalGrid","Grid","useSelect","useCallback","useRef","MediaUpload","lineSolid","store","coreStore","__","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","FeaturedImageEdit","data","field","onChange","id","value","getValue","item","media","select","getEntityRecord","onChangeControl","newValue","url","source_url","title","rendered","ref","className","children","onSelect","selectedMedia","allowedTypes","render","open","role","tabIndex","onClick","onKeyDown","rowGap","columnGap","templateColumns","alt","width","height","src","style","size","icon","event","stopPropagation"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\n// @ts-ignore\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'postType', 'attachment', value );\n\t\t},\n\t\t[ value ]\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\tconst url = media?.source_url;\n\tconst title = media?.title?.rendered;\n\tconst ref = useRef( null );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__featured-image\">\n\t\t\t<div className=\"fields-controls__featured-image-container\">\n\t\t\t\t<MediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: { id: number } ) => {\n\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t} }\n\t\t\t\t\tallowedTypes={ [ 'image' ] }\n\t\t\t\t\trender={ ( { open }: { open: () => void } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonKeyDown={ open }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr 24px\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\theight={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose an image…' ) }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-remove-button\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChangeControl( 0 );\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,kBAAkB,IAAIC,IAAI,QAAQ,uBAAuB;AAC1E,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD;AACA,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAEzD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAKA,OAAO,MAAMC,iBAAiB,GAAGA,CAAE;EAClCC,IAAI;EACJC,KAAK;EACLC;AACiC,CAAC,KAAM;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGF,KAAK;EAEpB,MAAMG,KAAK,GAAGH,KAAK,CAACI,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e;cAAAZ,QAAA,GAE7BN,GAAG,iBACJd,KAAA,CAAAF,SAAA;gBAAAsB,QAAA,gBACCxB,IAAA;kBACCuB,SAAS,EAAC,uCAAuC;kBACjDc,GAAG,EAAC,EAAE;kBACNC,KAAK,EAAG,EAAI;kBACZC,MAAM,EAAG,EAAI;kBACbC,GAAG,EAAGtB;gBAAK,CACX,CAAC,eACFlB,IAAA;kBAAMuB,SAAS,EAAC,uCAAuC;kBAAAC,QAAA,EACpDJ;gBAAK,CACF,CAAC;cAAA,CACN,CACF,EACC,CAAEF,GAAG,iBACNd,KAAA,CAAAF,SAAA;gBAAAsB,QAAA,gBACCxB,IAAA;kBACCuB,SAAS,EAAC,6CAA6C;kBACvDkB,KAAK,EAAG;oBACPH,KAAK,EAAE,MAAM;oBACbC,MAAM,EAAE;kBACT;gBAAG,CACH,CAAC,eACFvC,IAAA;kBAAMuB,SAAS,EAAC,uCAAuC;kBAAAC,QAAA,EACpD1B,EAAE,CAAE,kBAAmB;gBAAC,CACrB,CAAC;cAAA,CACN,CACF,EACCoB,GAAG,iBACJlB,IAAA,CAAAE,SAAA;gBAAAsB,QAAA,eACCxB,IAAA,CAACZ,MAAM;kBACNsD,IAAI,EAAC,OAAO;kBACZnB,SAAS,EAAC,+CAA+C;kBACzDoB,IAAI,EAAGhD,SAAW;kBAClBqC,OAAO,EACNY,KAA4C,IACxC;oBACJA,KAAK,CAACC,eAAe,CAAC,CAAC;oBACvB7B,eAAe,CAAE,CAAE,CAAC;kBACrB;gBAAG,CACH;cAAC,CACD,CACF;YAAA,CACI;UAAC,CACH,CAAC;QAER;MAAG,CACH;IAAC,CACE;EAAC,CACG,CAAC;AAEb,CAAC","ignoreList":[]}
@@ -9,21 +9,24 @@ import { store as coreStore } from '@wordpress/core-data';
9
9
  */
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  export const FeaturedImageView = ({
12
- item
12
+ item,
13
+ config
13
14
  }) => {
14
15
  const mediaId = item.featured_media;
15
16
  const media = useSelect(select => {
16
17
  const {
17
18
  getEntityRecord
18
19
  } = select(coreStore);
19
- return mediaId ? getEntityRecord('root', 'media', mediaId) : null;
20
+ return mediaId ? getEntityRecord('postType', 'attachment', mediaId) : null;
20
21
  }, [mediaId]);
21
22
  const url = media?.source_url;
22
23
  if (url) {
23
24
  return /*#__PURE__*/_jsx("img", {
24
25
  className: "fields-controls__featured-image-image",
25
26
  src: url,
26
- alt: ""
27
+ alt: "",
28
+ srcSet: media?.media_details?.sizes ? Object.values(media.media_details.sizes).map(size => `${size.source_url} ${size.width}w`).join(', ') : undefined,
29
+ sizes: config?.sizes || '100vw'
27
30
  });
28
31
  }
29
32
  return /*#__PURE__*/_jsx("span", {
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","jsx","_jsx","FeaturedImageView","item","mediaId","featured_media","media","select","getEntityRecord","url","source_url","className","src","alt"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageView = ( {\n\titem,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst mediaId = item.featured_media;\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn mediaId ? getEntityRecord( 'root', 'media', mediaId ) : null;\n\t\t},\n\t\t[ mediaId ]\n\t);\n\tconst url = media?.source_url;\n\n\tif ( url ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\tsrc={ url }\n\t\t\t\talt=\"\"\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <span className=\"fields-controls__featured-image-placeholder\" />;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAGzD;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAKA,OAAO,MAAMC,iBAAiB,GAAGA,CAAE;EAClCC;AACqC,CAAC,KAAM;EAC5C,MAAMC,OAAO,GAAGD,IAAI,CAACE,cAAc;EAEnC,MAAMC,KAAK,GAAGT,SAAS,CACpBU,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAER,SAAU,CAAC;IAC/C,OAAOK,OAAO,GAAGI,eAAe,CAAE,MAAM,EAAE,OAAO,EAAEJ,OAAQ,CAAC,GAAG,IAAI;EACpE,CAAC,EACD,CAAEA,OAAO,CACV,CAAC;EACD,MAAMK,GAAG,GAAGH,KAAK,EAAEI,UAAU;EAE7B,IAAKD,GAAG,EAAG;IACV,oBACCR,IAAA;MACCU,SAAS,EAAC,uCAAuC;MACjDC,GAAG,EAAGH,GAAK;MACXI,GAAG,EAAC;IAAE,CACN,CAAC;EAEJ;EAEA,oBAAOZ,IAAA;IAAMU,SAAS,EAAC;EAA6C,CAAE,CAAC;AACxE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","store","coreStore","jsx","_jsx","FeaturedImageView","item","config","mediaId","featured_media","media","select","getEntityRecord","url","source_url","className","src","alt","srcSet","media_details","sizes","Object","values","map","size","width","join","undefined"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageView = ( {\n\titem,\n\tconfig,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst mediaId = item.featured_media;\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn mediaId\n\t\t\t\t? getEntityRecord( 'postType', 'attachment', mediaId )\n\t\t\t\t: null;\n\t\t},\n\t\t[ mediaId ]\n\t);\n\tconst url = media?.source_url;\n\n\tif ( url ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\tsrc={ url }\n\t\t\t\talt=\"\"\n\t\t\t\tsrcSet={\n\t\t\t\t\tmedia?.media_details?.sizes\n\t\t\t\t\t\t? Object.values( media.media_details.sizes )\n\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t( size: any ) =>\n\t\t\t\t\t\t\t\t\t\t`${ size.source_url } ${ size.width }w`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.join( ', ' )\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tsizes={ config?.sizes || '100vw' }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <span className=\"fields-controls__featured-image-placeholder\" />;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAGzD;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAKA,OAAO,MAAMC,iBAAiB,GAAGA,CAAE;EAClCC,IAAI;EACJC;AACqC,CAAC,KAAM;EAC5C,MAAMC,OAAO,GAAGF,IAAI,CAACG,cAAc;EAEnC,MAAMC,KAAK,GAAGV,SAAS,CACpBW,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAET,SAAU,CAAC;IAC/C,OAAOM,OAAO,GACXI,eAAe,CAAE,UAAU,EAAE,YAAY,EAAEJ,OAAQ,CAAC,GACpD,IAAI;EACR,CAAC,EACD,CAAEA,OAAO,CACV,CAAC;EACD,MAAMK,GAAG,GAAGH,KAAK,EAAEI,UAAU;EAE7B,IAAKD,GAAG,EAAG;IACV,oBACCT,IAAA;MACCW,SAAS,EAAC,uCAAuC;MACjDC,GAAG,EAAGH,GAAK;MACXI,GAAG,EAAC,EAAE;MACNC,MAAM,EACLR,KAAK,EAAES,aAAa,EAAEC,KAAK,GACxBC,MAAM,CAACC,MAAM,CAAEZ,KAAK,CAACS,aAAa,CAACC,KAAM,CAAC,CACzCG,GAAG,CACDC,IAAS,IACV,GAAIA,IAAI,CAACV,UAAU,IAAMU,IAAI,CAACC,KAAK,GACrC,CAAC,CACAC,IAAI,CAAE,IAAK,CAAC,GACbC,SACH;MACDP,KAAK,EAAGb,MAAM,EAAEa,KAAK,IAAI;IAAS,CAClC,CAAC;EAEJ;EAEA,oBAAOhB,IAAA;IAAMW,SAAS,EAAC;EAA6C,CAAE,CAAC;AACxE,CAAC","ignoreList":[]}
@@ -13,7 +13,10 @@ const orderField = {
13
13
  type: 'integer',
14
14
  label: __('Order'),
15
15
  description: __('Determines the order of pages.'),
16
- filterBy: false
16
+ filterBy: false,
17
+ isValid: {
18
+ required: true
19
+ }
17
20
  };
18
21
 
19
22
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["__","orderField","id","type","label","description","filterBy"],"sources":["@wordpress/fields/src/fields/order/index.ts"],"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 orderField: Field< BasePost > = {\n\tid: 'menu_order',\n\ttype: 'integer',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n\tfilterBy: false,\n};\n\n/**\n * Order field for BasePost.\n */\nexport default orderField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAEJ,EAAE,CAAE,OAAQ,CAAC;EACpBK,WAAW,EAAEL,EAAE,CAAE,gCAAiC,CAAC;EACnDM,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA,eAAeL,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["__","orderField","id","type","label","description","filterBy","isValid","required"],"sources":["@wordpress/fields/src/fields/order/index.ts"],"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 orderField: Field< BasePost > = {\n\tid: 'menu_order',\n\ttype: 'integer',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n\tfilterBy: false,\n\tisValid: {\n\t\trequired: true,\n\t},\n};\n\n/**\n * Order field for BasePost.\n */\nexport default orderField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAEJ,EAAE,CAAE,OAAQ,CAAC;EACpBK,WAAW,EAAEL,EAAE,CAAE,gCAAiC,CAAC;EACnDM,QAAQ,EAAE,KAAK;EACfC,OAAO,EAAE;IACRC,QAAQ,EAAE;EACX;AACD,CAAC;;AAED;AACA;AACA;AACA,eAAeP,UAAU","ignoreList":[]}
@@ -2,6 +2,8 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
 
5
+ import { __ } from '@wordpress/i18n';
6
+
5
7
  /**
6
8
  * Internal dependencies
7
9
  */
@@ -10,6 +12,7 @@ import PasswordEdit from './edit';
10
12
  const passwordField = {
11
13
  id: 'password',
12
14
  type: 'text',
15
+ label: __('Password'),
13
16
  Edit: PasswordEdit,
14
17
  enableSorting: false,
15
18
  enableHiding: false,
@@ -1 +1 @@
1
- {"version":3,"names":["PasswordEdit","passwordField","id","type","Edit","enableSorting","enableHiding","isVisible","item","status","filterBy"],"sources":["@wordpress/fields/src/fields/password/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport PasswordEdit from './edit';\n\nconst passwordField: Field< BasePost > = {\n\tid: 'password',\n\ttype: 'text',\n\tEdit: PasswordEdit,\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => item.status !== 'private',\n\tfilterBy: false,\n};\n\n/**\n * Password field for BasePost.\n */\nexport default passwordField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,OAAOA,YAAY,MAAM,QAAQ;AAEjC,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAEJ,YAAY;EAClBK,aAAa,EAAE,KAAK;EACpBC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAIC,IAAI,IAAMA,IAAI,CAACC,MAAM,KAAK,SAAS;EAChDC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA,eAAeT,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["__","PasswordEdit","passwordField","id","type","label","Edit","enableSorting","enableHiding","isVisible","item","status","filterBy"],"sources":["@wordpress/fields/src/fields/password/index.tsx"],"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 PasswordEdit from './edit';\n\nconst passwordField: Field< BasePost > = {\n\tid: 'password',\n\ttype: 'text',\n\tlabel: __( 'Password' ),\n\tEdit: PasswordEdit,\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => item.status !== 'private',\n\tfilterBy: false,\n};\n\n/**\n * Password field for BasePost.\n */\nexport default passwordField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,OAAOC,YAAY,MAAM,QAAQ;AAEjC,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEL,EAAE,CAAE,UAAW,CAAC;EACvBM,IAAI,EAAEL,YAAY;EAClBM,aAAa,EAAE,KAAK;EACpBC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAIC,IAAI,IAAMA,IAAI,CAACC,MAAM,KAAK,SAAS;EAChDC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA,eAAeV,aAAa","ignoreList":[]}
@@ -392,11 +392,28 @@ fieldset.fields-controls__featured-image .fields-controls__featured-image-remove
392
392
  height: 16px;
393
393
  }
394
394
 
395
- .dataviews-view-table__cell-content-wrapper .fields-controls__featured-image-image,
396
- .dataviews-view-table__cell-content-wrapper .fields-controls__featured-image-placeholder {
395
+ .dataviews-view-grid__media .fields-controls__featured-image-image,
396
+ .dataviews-view-grid__media .fields-controls__featured-image-placeholder,
397
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-image,
398
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder,
399
+ .dataviews-view-list__media-wrapper .fields-controls__featured-image-image,
400
+ .dataviews-view-list__media-wrapper .fields-controls__featured-image-placeholder {
401
+ width: 100%;
402
+ height: 100%;
403
+ display: block;
404
+ border-radius: 4px;
405
+ }
406
+ .dataviews-view-grid__media .fields-controls__featured-image-placeholder,
407
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder,
408
+ .dataviews-view-list__media-wrapper .fields-controls__featured-image-placeholder {
409
+ box-shadow: none;
410
+ background: #f0f0f0;
411
+ }
412
+
413
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-image,
414
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder {
397
415
  width: 32px;
398
416
  height: 32px;
399
- display: block;
400
417
  }
401
418
 
402
419
  .fields-controls__template-modal {
@@ -392,11 +392,28 @@ fieldset.fields-controls__featured-image .fields-controls__featured-image-remove
392
392
  height: 16px;
393
393
  }
394
394
 
395
- .dataviews-view-table__cell-content-wrapper .fields-controls__featured-image-image,
396
- .dataviews-view-table__cell-content-wrapper .fields-controls__featured-image-placeholder {
395
+ .dataviews-view-grid__media .fields-controls__featured-image-image,
396
+ .dataviews-view-grid__media .fields-controls__featured-image-placeholder,
397
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-image,
398
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder,
399
+ .dataviews-view-list__media-wrapper .fields-controls__featured-image-image,
400
+ .dataviews-view-list__media-wrapper .fields-controls__featured-image-placeholder {
401
+ width: 100%;
402
+ height: 100%;
403
+ display: block;
404
+ border-radius: 4px;
405
+ }
406
+ .dataviews-view-grid__media .fields-controls__featured-image-placeholder,
407
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder,
408
+ .dataviews-view-list__media-wrapper .fields-controls__featured-image-placeholder {
409
+ box-shadow: none;
410
+ background: #f0f0f0;
411
+ }
412
+
413
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-image,
414
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder {
397
415
  width: 32px;
398
416
  height: 32px;
399
- display: block;
400
417
  }
401
418
 
402
419
  .fields-controls__template-modal {
@@ -3,5 +3,5 @@ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
3
3
  * Internal dependencies
4
4
  */
5
5
  import type { BasePost } from '../../types';
6
- export declare const FeaturedImageView: ({ item, }: DataViewRenderFieldProps<BasePost>) => import("react").JSX.Element;
6
+ export declare const FeaturedImageView: ({ item, config, }: DataViewRenderFieldProps<BasePost>) => import("react").JSX.Element;
7
7
  //# sourceMappingURL=featured-image-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"featured-image-view.d.ts","sourceRoot":"","sources":["../../../src/fields/featured-image/featured-image-view.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,iBAAiB,cAE3B,wBAAwB,CAAE,QAAQ,CAAE,gCAuBtC,CAAC"}
1
+ {"version":3,"file":"featured-image-view.d.ts","sourceRoot":"","sources":["../../../src/fields/featured-image/featured-image-view.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,iBAAiB,sBAG3B,wBAAwB,CAAE,QAAQ,CAAE,gCAoCtC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/order/index.ts"],"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,UAAU,EAAE,KAAK,CAAE,QAAQ,CAMhC,CAAC;AAEF;;GAEG;AACH,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/order/index.ts"],"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,UAAU,EAAE,KAAK,CAAE,QAAQ,CAShC,CAAC;AAEF;;GAEG;AACH,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/password/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,QAAA,MAAM,aAAa,EAAE,KAAK,CAAE,QAAQ,CAQnC,CAAC;AAEF;;GAEG;AACH,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/password/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;AAG5C,QAAA,MAAM,aAAa,EAAE,KAAK,CAAE,QAAQ,CASnC,CAAC;AAEF;;GAEG;AACH,eAAe,aAAa,CAAC"}
@@ -1,31 +1,31 @@
1
1
  declare const STATUSES: ({
2
2
  value: string;
3
- label: import("@wordpress/i18n/build-types/types").TranslatableText<"Draft">;
3
+ label: import("@wordpress/i18n").TranslatableText<"Draft">;
4
4
  icon: import("react").JSX.Element;
5
- description: import("@wordpress/i18n/build-types/types").TranslatableText<"Not ready to publish.">;
5
+ description: import("@wordpress/i18n").TranslatableText<"Not ready to publish.">;
6
6
  } | {
7
7
  value: string;
8
- label: import("@wordpress/i18n/build-types/types").TranslatableText<"Scheduled">;
8
+ label: import("@wordpress/i18n").TranslatableText<"Scheduled">;
9
9
  icon: import("react").JSX.Element;
10
- description: import("@wordpress/i18n/build-types/types").TranslatableText<"Publish automatically on a chosen date.">;
10
+ description: import("@wordpress/i18n").TranslatableText<"Publish automatically on a chosen date.">;
11
11
  } | {
12
12
  value: string;
13
- label: import("@wordpress/i18n/build-types/types").TranslatableText<"Pending Review">;
13
+ label: import("@wordpress/i18n").TranslatableText<"Pending Review">;
14
14
  icon: import("react").JSX.Element;
15
- description: import("@wordpress/i18n/build-types/types").TranslatableText<"Waiting for review before publishing.">;
15
+ description: import("@wordpress/i18n").TranslatableText<"Waiting for review before publishing.">;
16
16
  } | {
17
17
  value: string;
18
- label: import("@wordpress/i18n/build-types/types").TranslatableText<"Private">;
18
+ label: import("@wordpress/i18n").TranslatableText<"Private">;
19
19
  icon: import("react").JSX.Element;
20
- description: import("@wordpress/i18n/build-types/types").TranslatableText<"Only visible to site admins and editors.">;
20
+ description: import("@wordpress/i18n").TranslatableText<"Only visible to site admins and editors.">;
21
21
  } | {
22
22
  value: string;
23
- label: import("@wordpress/i18n/build-types/types").TranslatableText<"Published">;
23
+ label: import("@wordpress/i18n").TranslatableText<"Published">;
24
24
  icon: import("react").JSX.Element;
25
- description: import("@wordpress/i18n/build-types/types").TranslatableText<"Visible to everyone.">;
25
+ description: import("@wordpress/i18n").TranslatableText<"Visible to everyone.">;
26
26
  } | {
27
27
  value: string;
28
- label: import("@wordpress/i18n/build-types/types").TranslatableText<"Trash">;
28
+ label: import("@wordpress/i18n").TranslatableText<"Trash">;
29
29
  icon: import("react").JSX.Element;
30
30
  description?: undefined;
31
31
  })[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/fields",
3
- "version": "0.19.0",
3
+ "version": "0.20.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",
@@ -33,29 +33,29 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@babel/runtime": "7.25.7",
36
- "@wordpress/api-fetch": "^7.27.0",
37
- "@wordpress/blob": "^4.27.0",
38
- "@wordpress/block-editor": "^15.0.0",
39
- "@wordpress/blocks": "^15.0.0",
40
- "@wordpress/components": "^30.0.0",
41
- "@wordpress/compose": "^7.27.0",
42
- "@wordpress/core-data": "^7.27.0",
43
- "@wordpress/data": "^10.27.0",
44
- "@wordpress/dataviews": "^5.0.0",
45
- "@wordpress/date": "^5.27.0",
46
- "@wordpress/element": "^6.27.0",
47
- "@wordpress/hooks": "^4.27.0",
48
- "@wordpress/html-entities": "^4.27.0",
49
- "@wordpress/i18n": "^6.0.0",
50
- "@wordpress/icons": "^10.27.0",
51
- "@wordpress/media-utils": "^5.27.0",
52
- "@wordpress/notices": "^5.27.0",
53
- "@wordpress/patterns": "^2.27.0",
54
- "@wordpress/primitives": "^4.27.0",
55
- "@wordpress/private-apis": "^1.27.0",
56
- "@wordpress/router": "^1.27.0",
57
- "@wordpress/url": "^4.27.0",
58
- "@wordpress/warning": "^3.27.0",
36
+ "@wordpress/api-fetch": "^7.28.0",
37
+ "@wordpress/blob": "^4.28.0",
38
+ "@wordpress/block-editor": "^15.1.0",
39
+ "@wordpress/blocks": "^15.1.0",
40
+ "@wordpress/components": "^30.1.0",
41
+ "@wordpress/compose": "^7.28.0",
42
+ "@wordpress/core-data": "^7.28.0",
43
+ "@wordpress/data": "^10.28.0",
44
+ "@wordpress/dataviews": "^6.0.0",
45
+ "@wordpress/date": "^5.28.0",
46
+ "@wordpress/element": "^6.28.0",
47
+ "@wordpress/hooks": "^4.28.0",
48
+ "@wordpress/html-entities": "^4.28.0",
49
+ "@wordpress/i18n": "^6.1.0",
50
+ "@wordpress/icons": "^10.28.0",
51
+ "@wordpress/media-utils": "^5.28.0",
52
+ "@wordpress/notices": "^5.28.0",
53
+ "@wordpress/patterns": "^2.28.0",
54
+ "@wordpress/primitives": "^4.28.0",
55
+ "@wordpress/private-apis": "^1.28.0",
56
+ "@wordpress/router": "^1.28.0",
57
+ "@wordpress/url": "^4.28.0",
58
+ "@wordpress/warning": "^3.28.0",
59
59
  "change-case": "4.1.2",
60
60
  "client-zip": "^2.4.5",
61
61
  "clsx": "2.1.1",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "abe06a6f2aef8d03c30ea9d5b3e133f041e523b1"
70
+ "gitHead": "28cc2098f5ee28f89096b638533796538f495f72"
71
71
  }
@@ -28,7 +28,7 @@ export const FeaturedImageEdit = ( {
28
28
  const media = useSelect(
29
29
  ( select ) => {
30
30
  const { getEntityRecord } = select( coreStore );
31
- return getEntityRecord( 'root', 'media', value );
31
+ return getEntityRecord( 'postType', 'attachment', value );
32
32
  },
33
33
  [ value ]
34
34
  );
@@ -12,13 +12,16 @@ import type { BasePost } from '../../types';
12
12
 
13
13
  export const FeaturedImageView = ( {
14
14
  item,
15
+ config,
15
16
  }: DataViewRenderFieldProps< BasePost > ) => {
16
17
  const mediaId = item.featured_media;
17
18
 
18
19
  const media = useSelect(
19
20
  ( select ) => {
20
21
  const { getEntityRecord } = select( coreStore );
21
- return mediaId ? getEntityRecord( 'root', 'media', mediaId ) : null;
22
+ return mediaId
23
+ ? getEntityRecord( 'postType', 'attachment', mediaId )
24
+ : null;
22
25
  },
23
26
  [ mediaId ]
24
27
  );
@@ -30,6 +33,17 @@ export const FeaturedImageView = ( {
30
33
  className="fields-controls__featured-image-image"
31
34
  src={ url }
32
35
  alt=""
36
+ srcSet={
37
+ media?.media_details?.sizes
38
+ ? Object.values( media.media_details.sizes )
39
+ .map(
40
+ ( size: any ) =>
41
+ `${ size.source_url } ${ size.width }w`
42
+ )
43
+ .join( ', ' )
44
+ : undefined
45
+ }
46
+ sizes={ config?.sizes || '100vw' }
33
47
  />
34
48
  );
35
49
  }
@@ -82,11 +82,27 @@ fieldset.fields-controls__featured-image {
82
82
  }
83
83
  }
84
84
 
85
- .dataviews-view-table__cell-content-wrapper {
85
+ .dataviews-view-grid__media,
86
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media,
87
+ .dataviews-view-list__media-wrapper {
88
+ .fields-controls__featured-image-image,
89
+ .fields-controls__featured-image-placeholder {
90
+ width: 100%;
91
+ height: 100%;
92
+ display: block;
93
+ border-radius: $radius-medium;
94
+ }
95
+
96
+ .fields-controls__featured-image-placeholder {
97
+ box-shadow: none;
98
+ background: $gray-100;
99
+ }
100
+ }
101
+
102
+ .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media {
86
103
  .fields-controls__featured-image-image,
87
104
  .fields-controls__featured-image-placeholder {
88
105
  width: 32px;
89
106
  height: 32px;
90
- display: block;
91
107
  }
92
108
  }
@@ -15,6 +15,9 @@ const orderField: Field< BasePost > = {
15
15
  label: __( 'Order' ),
16
16
  description: __( 'Determines the order of pages.' ),
17
17
  filterBy: false,
18
+ isValid: {
19
+ required: true,
20
+ },
18
21
  };
19
22
 
20
23
  /**
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import type { Field } from '@wordpress/dataviews';
5
+ import { __ } from '@wordpress/i18n';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -12,6 +13,7 @@ import PasswordEdit from './edit';
12
13
  const passwordField: Field< BasePost > = {
13
14
  id: 'password',
14
15
  type: 'text',
16
+ label: __( 'Password' ),
15
17
  Edit: PasswordEdit,
16
18
  enableSorting: false,
17
19
  enableHiding: false,