@wordpress/media-fields 0.19.2-next.v.202608281122.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 (37) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/build/alt_text/index.cjs +20 -28
  3. package/build/alt_text/index.cjs.map +3 -3
  4. package/build/author/index.cjs +0 -5
  5. package/build/author/index.cjs.map +2 -2
  6. package/build/caption/index.cjs +3 -12
  7. package/build/caption/index.cjs.map +3 -3
  8. package/build/description/index.cjs +3 -11
  9. package/build/description/index.cjs.map +3 -3
  10. package/build/media_thumbnail/view.cjs.map +1 -1
  11. package/build-module/alt_text/index.mjs +20 -28
  12. package/build-module/alt_text/index.mjs.map +2 -2
  13. package/build-module/author/index.mjs +0 -5
  14. package/build-module/author/index.mjs.map +2 -2
  15. package/build-module/caption/index.mjs +3 -12
  16. package/build-module/caption/index.mjs.map +2 -2
  17. package/build-module/description/index.mjs +3 -11
  18. package/build-module/description/index.mjs.map +2 -2
  19. package/build-module/media_thumbnail/view.mjs.map +1 -1
  20. package/build-style/style-rtl.css +2 -4
  21. package/build-style/style.css +2 -4
  22. package/build-types/alt_text/index.d.ts.map +1 -1
  23. package/build-types/author/index.d.ts.map +1 -1
  24. package/build-types/caption/index.d.ts.map +1 -1
  25. package/build-types/description/index.d.ts.map +1 -1
  26. package/package.json +16 -16
  27. package/src/alt_text/index.tsx +20 -27
  28. package/src/attached_to/test/{view.test.tsx → view.jsdom.test.tsx} +1 -0
  29. package/src/author/index.tsx +1 -9
  30. package/src/caption/index.tsx +3 -10
  31. package/src/description/index.tsx +3 -10
  32. package/src/filename/test/index.test.ts +1 -0
  33. package/src/filename/test/{view.test.tsx → view.jsdom.test.tsx} +1 -0
  34. package/src/filesize/test/index.test.tsx +1 -0
  35. package/src/media_dimensions/test/index.test.ts +1 -0
  36. package/src/media_thumbnail/test/{get-best-image-url.test.ts → get-best-image-url.jsdom.test.ts} +1 -0
  37. package/src/media_thumbnail/view.tsx +1 -1
package/CHANGELOG.md CHANGED
@@ -2,10 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 0.19.1-next.0 (2026-08-28)
5
+ ## 0.20.0 (2026-09-10)
6
+
7
+ ### Bug Fixes
8
+
9
+ - `author`: Drop the custom `sort` callback, which read `_embedded.author` from the arguments although `Field.sort` receives the field values (the author ids), so every comparison returned `0` and in-memory sorting by author was a no-op. The field now sorts by author id through the `integer` type, matching the order the REST API returns for `orderby=author` ([#82559](https://github.com/WordPress/gutenberg/pull/82559)).
10
+ - `alt_text`, `caption`, `description`: Pass the field's disabled state to the textarea control, so disabling one of these fields stops it accepting input. ([#82516](https://github.com/WordPress/gutenberg/pull/82516))
6
11
 
7
12
  ### Internal
8
13
 
14
+ - `caption`: Replace the custom `Edit` component with the built-in `textarea` control ([#82539](https://github.com/WordPress/gutenberg/pull/82539)).
15
+ - `alt_text`: Replace the custom `Edit` component with the built-in `textarea` control, passing the help text as the field's `description` ([#82539](https://github.com/WordPress/gutenberg/pull/82539)).
16
+ - `description`: Replace the custom `Edit` component with the built-in `textarea` control ([#82539](https://github.com/WordPress/gutenberg/pull/82539)).
9
17
  - Remove unused dependencies `@wordpress/date` and `@wordpress/primitives` ([#82103](https://github.com/WordPress/gutenberg/pull/82103)).
10
18
  - Remove tsconfig project references to packages that are not dependencies ([#82106](https://github.com/WordPress/gutenberg/pull/82106)).
11
19
 
@@ -21,6 +29,7 @@
21
29
  ### Bug Fixes
22
30
 
23
31
  - `attached_to`: Reserve room for the suggestions so the field's DataForm panel dropdown is placed with space for them, instead of being sized to the row and then crushing them into a box too small to scroll comfortably. Also don't expand the suggestion list until the user searches, debounce the search so a request isn't fired per keystroke, allow re-attaching straight after detaching, and drop the detach link from the help text in favour of the field's own reset button ([#81122](https://github.com/WordPress/gutenberg/issues/81122)).
32
+
24
33
  ## 0.17.0 (2026-07-29)
25
34
 
26
35
  ## 0.16.0 (2026-07-14)
@@ -24,42 +24,34 @@ __export(alt_text_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(alt_text_exports);
26
26
  var import_i18n = require("@wordpress/i18n");
27
- var import_components = require("@wordpress/components");
28
27
  var import_ui = require("@wordpress/ui");
29
28
  var import_jsx_runtime = require("react/jsx-runtime");
30
29
  var altTextField = {
31
30
  id: "alt_text",
32
31
  type: "text",
33
32
  label: (0, import_i18n.__)("Alt text"),
34
- isVisible: (item) => item?.media_type === "image",
35
- render: ({ item }) => item?.alt_text || "-",
36
- Edit: ({ field, onChange, data }) => {
37
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
38
- import_components.TextareaControl,
33
+ description: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
34
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
35
+ import_ui.Link,
39
36
  {
40
- label: field.label,
41
- value: data.alt_text || "",
42
- onChange: (value) => onChange({ alt_text: value }),
43
- help: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
44
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
45
- import_ui.Link,
46
- {
47
- href: (
48
- // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
49
- (0, import_i18n.__)(
50
- "https://www.w3.org/WAI/tutorials/images/decision-tree/"
51
- )
52
- ),
53
- openInNewTab: true,
54
- children: (0, import_i18n.__)("Describe the purpose of the image.")
55
- }
56
- ),
57
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
58
- (0, import_i18n.__)("Leave empty if decorative.")
59
- ] }),
60
- rows: 2
37
+ href: (
38
+ // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
39
+ (0, import_i18n.__)(
40
+ "https://www.w3.org/WAI/tutorials/images/decision-tree/"
41
+ )
42
+ ),
43
+ openInNewTab: true,
44
+ children: (0, import_i18n.__)("Describe the purpose of the image.")
61
45
  }
62
- );
46
+ ),
47
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
48
+ (0, import_i18n.__)("Leave empty if decorative.")
49
+ ] }),
50
+ isVisible: (item) => item?.media_type === "image",
51
+ render: ({ item }) => item?.alt_text || "-",
52
+ Edit: {
53
+ control: "textarea",
54
+ rows: 2
63
55
  },
64
56
  enableSorting: false,
65
57
  filterBy: false
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/alt_text/index.tsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { TextareaControl as WCTextareaControl } from '@wordpress/components';\nimport { Link } from '@wordpress/ui';\nimport type { Field } from '@wordpress/dataviews';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\n\nconst altTextField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'alt_text',\n\ttype: 'text',\n\tlabel: __( 'Alt text' ),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<WCTextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ data.alt_text || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { alt_text: value } ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\thref={\n\t\t\t\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\topenInNewTab\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Describe the purpose of the image.' ) }\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t<br />\n\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\trows={ 2 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,wBAAqD;AACrD,gBAAqB;AAiBhB;AAbL,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,UAAW;AAAA,EACtB,WAAW,CAAE,SAAU,MAAM,eAAe;AAAA,EAC5C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,YAAY;AAAA,EAC1C,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC,kBAAAA;AAAA,MAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,OAAQ,KAAK,YAAY;AAAA,QACzB,UAAW,CAAE,UAAW,SAAU,EAAE,UAAU,MAAM,CAAE;AAAA,QACtD,MACC,4EACC;AAAA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA;AAAA,oBAEC;AAAA,kBACC;AAAA,gBACD;AAAA;AAAA,cAED,cAAY;AAAA,cAEV,8BAAI,oCAAqC;AAAA;AAAA,UAC5C;AAAA,UACA,4CAAC,QAAG;AAAA,cACF,gBAAI,4BAA6B;AAAA,WACpC;AAAA,QAED,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,mBAAQ;",
6
- "names": ["WCTextareaControl"]
4
+ "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { Link } from '@wordpress/ui';\nimport type { Field } from '@wordpress/dataviews';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\n\nconst altTextField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'alt_text',\n\ttype: 'text',\n\tlabel: __( 'Alt text' ),\n\tdescription: (\n\t\t<>\n\t\t\t<Link\n\t\t\t\thref={\n\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t__(\n\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\topenInNewTab\n\t\t\t>\n\t\t\t\t{ __( 'Describe the purpose of the image.' ) }\n\t\t\t</Link>\n\t\t\t<br />\n\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t</>\n\t),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,gBAAqB;AASnB;AALF,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,UAAW;AAAA,EACtB,aACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA;AAAA,cAEC;AAAA,YACC;AAAA,UACD;AAAA;AAAA,QAED,cAAY;AAAA,QAEV,8BAAI,oCAAqC;AAAA;AAAA,IAC5C;AAAA,IACA,4CAAC,QAAG;AAAA,QACF,gBAAI,4BAA6B;AAAA,KACpC;AAAA,EAED,WAAW,CAAE,SAAU,MAAM,eAAe;AAAA,EAC5C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,YAAY;AAAA,EAC1C,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,mBAAQ;",
6
+ "names": []
7
7
  }
@@ -58,11 +58,6 @@ var authorField = {
58
58
  }));
59
59
  },
60
60
  render: import_view.default,
61
- sort: (a, b, direction) => {
62
- const nameA = a._embedded?.author?.[0]?.name || "";
63
- const nameB = b._embedded?.author?.[0]?.name || "";
64
- return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
65
- },
66
61
  filterBy: {
67
62
  operators: ["isAny", "isNone"]
68
63
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/author/index.tsx"],
4
- "sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\tsort: ( a, b, direction ) => {\n\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\treturn direction === 'asc'\n\t\t\t? nameA.localeCompare( nameB )\n\t\t\t: nameB.localeCompare( nameA );\n\t},\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n\treadOnly: true,\n};\n\nexport default authorField;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAmB;AACnB,kBAA8B;AAC9B,uBAAuC;AAEvC,kBAAuB;AAOvB,IAAM,cAA6C;AAAA,EAClD,WAAO,gBAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,UAAM,2BAAe,iBAAAA,KAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ,YAAAC;AAAA,EACR,MAAM,CAAE,GAAG,GAAG,cAAe;AAC5B,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAClD,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAElD,WAAO,cAAc,QAClB,MAAM,cAAe,KAAM,IAC3B,MAAM,cAAe,KAAM;AAAA,EAC/B;AAAA,EACA,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,iBAAQ;",
4
+ "sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords< Author >(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n\treadOnly: true,\n};\n\nexport default authorField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAmB;AACnB,kBAA8B;AAC9B,uBAAuC;AAEvC,kBAAuB;AAOvB,IAAM,cAA6C;AAAA,EAClD,WAAO,gBAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,UAAM,2BAAe,iBAAAA,KAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ,YAAAC;AAAA,EACR,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,iBAAQ;",
6
6
  "names": ["coreDataStore", "AuthorView"]
7
7
  }
@@ -24,25 +24,16 @@ __export(caption_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(caption_exports);
26
26
  var import_i18n = require("@wordpress/i18n");
27
- var import_components = require("@wordpress/components");
28
27
  var import_get_raw_content = require("../utils/get-raw-content.cjs");
29
- var import_jsx_runtime = require("react/jsx-runtime");
30
28
  var captionField = {
31
29
  id: "caption",
32
30
  type: "text",
33
31
  label: (0, import_i18n.__)("Caption"),
34
32
  getValue: ({ item }) => (0, import_get_raw_content.getRawContent)(item?.caption),
35
33
  render: ({ item }) => (0, import_get_raw_content.getRawContent)(item?.caption) || "-",
36
- Edit: ({ field, onChange, data }) => {
37
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
38
- import_components.TextareaControl,
39
- {
40
- label: field.label,
41
- value: (0, import_get_raw_content.getRawContent)(data.caption) || "",
42
- onChange: (value) => onChange({ caption: value }),
43
- rows: 2
44
- }
45
- );
34
+ Edit: {
35
+ control: "textarea",
36
+ rows: 2
46
37
  },
47
38
  enableSorting: false,
48
39
  filterBy: false
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/caption/index.tsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { TextareaControl as WCTextareaControl } from '@wordpress/components';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst captionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'caption',\n\ttype: 'text',\n\tlabel: __( 'Caption' ),\n\tgetValue: ( { item } ) => getRawContent( item?.caption ),\n\trender: ( { item } ) => getRawContent( item?.caption ) || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<WCTextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ getRawContent( data.caption ) || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { caption: value } ) }\n\t\t\t\trows={ 2 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,wBAAqD;AAGrD,6BAA8B;AAU3B;AARH,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,SAAU;AAAA,EACrB,UAAU,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,OAAQ;AAAA,EACvD,QAAQ,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,OAAQ,KAAK;AAAA,EAC1D,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC,kBAAAA;AAAA,MAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,WAAQ,sCAAe,KAAK,OAAQ,KAAK;AAAA,QACzC,UAAW,CAAE,UAAW,SAAU,EAAE,SAAS,MAAM,CAAE;AAAA,QACrD,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,kBAAQ;",
6
- "names": ["WCTextareaControl"]
4
+ "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst captionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'caption',\n\ttype: 'text',\n\tlabel: __( 'Caption' ),\n\tgetValue: ( { item } ) => getRawContent( item?.caption ),\n\trender: ( { item } ) => getRawContent( item?.caption ) || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AAGnB,6BAA8B;AAE9B,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,SAAU;AAAA,EACrB,UAAU,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,OAAQ;AAAA,EACvD,QAAQ,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,OAAQ,KAAK;AAAA,EAC1D,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,kBAAQ;",
6
+ "names": []
7
7
  }
@@ -24,7 +24,6 @@ __export(description_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(description_exports);
26
26
  var import_i18n = require("@wordpress/i18n");
27
- var import_components = require("@wordpress/components");
28
27
  var import_get_raw_content = require("../utils/get-raw-content.cjs");
29
28
  var import_jsx_runtime = require("react/jsx-runtime");
30
29
  var descriptionField = {
@@ -33,16 +32,9 @@ var descriptionField = {
33
32
  label: (0, import_i18n.__)("Description"),
34
33
  getValue: ({ item }) => (0, import_get_raw_content.getRawContent)(item?.description),
35
34
  render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: (0, import_get_raw_content.getRawContent)(item?.description) || "-" }),
36
- Edit: ({ field, onChange, data }) => {
37
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
38
- import_components.TextareaControl,
39
- {
40
- label: field.label,
41
- value: (0, import_get_raw_content.getRawContent)(data.description) || "",
42
- onChange: (value) => onChange({ description: value }),
43
- rows: 5
44
- }
45
- );
35
+ Edit: {
36
+ control: "textarea",
37
+ rows: 5
46
38
  },
47
39
  enableSorting: false,
48
40
  filterBy: false
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/description/index.tsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { TextareaControl as WCTextareaControl } from '@wordpress/components';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst descriptionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue: ( { item } ) => getRawContent( item?.description ),\n\trender: ( { item } ) => (\n\t\t<div>{ getRawContent( item?.description ) || '-' }</div>\n\t),\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<WCTextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ getRawContent( data.description ) || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { description: value } ) }\n\t\t\t\trows={ 5 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,wBAAqD;AAGrD,6BAA8B;AAQ5B;AANF,IAAM,mBAAgE;AAAA,EACrE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,aAAc;AAAA,EACzB,UAAU,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,WAAY;AAAA,EAC3D,QAAQ,CAAE,EAAE,KAAK,MAChB,4CAAC,SAAM,oDAAe,MAAM,WAAY,KAAK,KAAK;AAAA,EAEnD,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC,kBAAAA;AAAA,MAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,WAAQ,sCAAe,KAAK,WAAY,KAAK;AAAA,QAC7C,UAAW,CAAE,UAAW,SAAU,EAAE,aAAa,MAAM,CAAE;AAAA,QACzD,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
6
- "names": ["WCTextareaControl"]
4
+ "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst descriptionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue: ( { item } ) => getRawContent( item?.description ),\n\trender: ( { item } ) => (\n\t\t<div>{ getRawContent( item?.description ) || '-' }</div>\n\t),\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 5,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AAGnB,6BAA8B;AAQ5B;AANF,IAAM,mBAAgE;AAAA,EACrE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,aAAc;AAAA,EACzB,UAAU,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,WAAY;AAAA,EAC3D,QAAQ,CAAE,EAAE,KAAK,MAChB,4CAAC,SAAM,oDAAe,MAAM,WAAY,KAAK,KAAK;AAAA,EAEnD,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
6
+ "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/media_thumbnail/view.tsx"],
4
- "sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport { useState, useRef, useLayoutEffect } from '@wordpress/element';\nimport type { Attachment } from '@wordpress/core-data';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { getMediaTypeFromMimeType } from '../utils/get-media-type-from-mime-type';\nimport type { MediaItem } from '../types';\n\n/**\n * Given the available image sizes and a target display width, returns the URL\n * of the smallest size whose width is >= the target. Falls back to the largest\n * available size, or the original source_url.\n *\n * @param featuredMedia The media item with size details.\n * @param configSizes The target display size string (e.g. '900px').\n */\nexport function getBestImageUrl(\n\tfeaturedMedia: Attachment | MediaItem,\n\tconfigSizes?: string\n): string {\n\tconst sizes = featuredMedia?.media_details?.sizes;\n\tif ( ! sizes ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\tconst sizeEntries = Object.values( sizes );\n\n\tif ( ! sizeEntries.length ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\t// Parse target width from config.sizes (e.g. '900px' → 900).\n\tconst targetWidth = configSizes ? parseInt( configSizes, 10 ) : NaN;\n\n\tif ( ! Number.isNaN( targetWidth ) ) {\n\t\t// Filter to entries that have a valid numeric width.\n\t\tconst validEntries = sizeEntries.filter(\n\t\t\t( s ) => typeof s.width === 'number' && ! Number.isNaN( s.width )\n\t\t);\n\n\t\tif ( ! validEntries.length ) {\n\t\t\treturn featuredMedia.source_url;\n\t\t}\n\n\t\t// Sort ascending by width.\n\t\tconst sorted = [ ...validEntries ].sort(\n\t\t\t( a, b ) => a.width - b.width\n\t\t);\n\t\t// Pick the smallest size that is >= target width.\n\t\tconst match = sorted.find( ( s ) => s.width >= targetWidth );\n\t\tif ( match ) {\n\t\t\treturn match.source_url;\n\t\t}\n\t\t// No size large enough — use the largest available.\n\t\treturn sorted[ sorted.length - 1 ].source_url;\n\t}\n\n\t// If we can't parse the target, fall back to source_url.\n\treturn featuredMedia.source_url;\n}\n\nfunction FallbackView( {\n\titem,\n\tfilename,\n}: {\n\titem: MediaItem;\n\tfilename: string;\n} ) {\n\treturn (\n\t\t<div className=\"dataviews-media-field__media-thumbnail\">\n\t\t\t<VStack\n\t\t\t\tjustify=\"center\"\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail__stack\"\n\t\t\t\tspacing={ 0 }\n\t\t\t>\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--icon\"\n\t\t\t\t\ticon={ getMediaTypeFromMimeType( item.mime_type ).icon }\n\t\t\t\t\tsize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ !! filename && (\n\t\t\t\t\t<div className=\"dataviews-media-field__media-thumbnail__filename\">\n\t\t\t\t\t\t<Truncate className=\"dataviews-media-field__media-thumbnail__filename__truncate\">\n\t\t\t\t\t\t\t{ filename }\n\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nfunction ImageView( {\n\titem,\n\tconfigSizes,\n\tonError,\n}: {\n\titem: Attachment | MediaItem;\n\tconfigSizes?: string;\n\tonError: () => void;\n} ) {\n\tconst imageUrl = getBestImageUrl( item, configSizes );\n\n\t/*\n\t * Use three states to avoid fade-in animation for cached images:\n\t * 'instant' = image already cached, 'loading' = waiting, 'loaded' = just finished.\n\t *\n\t * useLayoutEffect runs synchronously after DOM mutations but before paint,\n\t * so we can check img.complete to detect disk-cached images and skip the\n\t * fade-in animation entirely.\n\t */\n\tconst imgRef = useRef< HTMLImageElement >( null );\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'instant' | 'loading' | 'loaded'\n\t>( 'loading' );\n\n\tuseLayoutEffect( () => {\n\t\tif ( imgRef.current?.complete ) {\n\t\t\tsetLoadingState( 'instant' );\n\t\t} else {\n\t\t\tsetLoadingState( 'loading' );\n\t\t}\n\t}, [ imageUrl ] );\n\n\tconst handleLoad = () => {\n\t\tif ( loadingState === 'loading' ) {\n\t\t\tsetLoadingState( 'loaded' );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'dataviews-media-field__media-thumbnail', {\n\t\t\t\t'is-loading': loadingState === 'loading',\n\t\t\t\t'is-loaded': loadingState === 'loaded',\n\t\t\t} ) }\n\t\t>\n\t\t\t<img\n\t\t\t\tref={ imgRef }\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--image\"\n\t\t\t\tsrc={ imageUrl }\n\t\t\t\talt={ item.alt_text || item.title.raw }\n\t\t\t\tonLoad={ handleLoad }\n\t\t\t\tonError={ onError }\n\t\t\t\tloading=\"lazy\"\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default function MediaThumbnailView( {\n\titem,\n\tconfig,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst [ imageError, setImageError ] = useState( false );\n\n\tconst _featuredMedia = useSelect(\n\t\t( select ) => {\n\t\t\t// Avoid the network request if it's not needed. `featured_media` is\n\t\t\t// 0 for images and media without featured media.\n\t\t\tif ( ! item.featured_media ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn select( coreStore ).getEntityRecord< Attachment >(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\titem.featured_media\n\t\t\t);\n\t\t},\n\t\t[ item.featured_media ]\n\t);\n\tconst featuredMedia = item.featured_media ? _featuredMedia : item;\n\n\t// Fetching.\n\tif ( ! featuredMedia ) {\n\t\treturn null;\n\t}\n\n\tconst filename = getFilename( featuredMedia.source_url || '' );\n\n\t// Show fallback if image failed to load or if not an image type.\n\tif (\n\t\timageError ||\n\t\tgetMediaTypeFromMimeType( featuredMedia.mime_type ).type !== 'image'\n\t) {\n\t\treturn (\n\t\t\t<FallbackView item={ featuredMedia } filename={ filename || '' } />\n\t\t);\n\t}\n\n\treturn (\n\t\t<ImageView\n\t\t\titem={ featuredMedia }\n\t\t\tconfigSizes={ config?.sizes }\n\t\t\tonError={ () => setImageError( true ) }\n\t\t/>\n\t);\n}\n"],
4
+ "sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport { useState, useRef, useLayoutEffect } from '@wordpress/element';\nimport type { Attachment } from '@wordpress/core-data';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { getMediaTypeFromMimeType } from '../utils/get-media-type-from-mime-type';\nimport type { MediaItem } from '../types';\n\n/**\n * Given the available image sizes and a target display width, returns the URL\n * of the smallest size whose width is >= the target. Falls back to the largest\n * available size, or the original source_url.\n *\n * @param featuredMedia The media item with size details.\n * @param configSizes The target display size string (e.g. '900px').\n */\nexport function getBestImageUrl(\n\tfeaturedMedia: Attachment | MediaItem,\n\tconfigSizes?: string\n): string {\n\tconst sizes = featuredMedia?.media_details?.sizes;\n\tif ( ! sizes ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\tconst sizeEntries = Object.values( sizes );\n\n\tif ( ! sizeEntries.length ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\t// Parse target width from config.sizes (e.g. '900px' → 900).\n\tconst targetWidth = configSizes ? parseInt( configSizes, 10 ) : NaN;\n\n\tif ( ! Number.isNaN( targetWidth ) ) {\n\t\t// Filter to entries that have a valid numeric width.\n\t\tconst validEntries = sizeEntries.filter(\n\t\t\t( s ) => typeof s.width === 'number' && ! Number.isNaN( s.width )\n\t\t);\n\n\t\tif ( ! validEntries.length ) {\n\t\t\treturn featuredMedia.source_url;\n\t\t}\n\n\t\t// Sort ascending by width.\n\t\tconst sorted = [ ...validEntries ].sort(\n\t\t\t( a, b ) => a.width - b.width\n\t\t);\n\t\t// Pick the smallest size that is >= target width.\n\t\tconst match = sorted.find( ( s ) => s.width >= targetWidth );\n\t\tif ( match ) {\n\t\t\treturn match.source_url;\n\t\t}\n\t\t// No size large enough — use the largest available.\n\t\treturn sorted[ sorted.length - 1 ].source_url;\n\t}\n\n\t// If we can't parse the target, fall back to source_url.\n\treturn featuredMedia.source_url;\n}\n\nfunction FallbackView( {\n\titem,\n\tfilename,\n}: {\n\titem: MediaItem;\n\tfilename: string;\n} ) {\n\treturn (\n\t\t<div className=\"dataviews-media-field__media-thumbnail\">\n\t\t\t<VStack\n\t\t\t\tjustify=\"center\"\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail__stack\"\n\t\t\t\tspacing={ 0 }\n\t\t\t>\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--icon\"\n\t\t\t\t\ticon={ getMediaTypeFromMimeType( item.mime_type ).icon }\n\t\t\t\t\tsize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ !! filename && (\n\t\t\t\t\t<div className=\"dataviews-media-field__media-thumbnail__filename\">\n\t\t\t\t\t\t<Truncate className=\"dataviews-media-field__media-thumbnail__filename__truncate\">\n\t\t\t\t\t\t\t{ filename }\n\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nfunction ImageView( {\n\titem,\n\tconfigSizes,\n\tonError,\n}: {\n\titem: Attachment | MediaItem;\n\tconfigSizes?: string;\n\tonError: () => void;\n} ) {\n\tconst imageUrl = getBestImageUrl( item, configSizes );\n\n\t/*\n\t * Use three states to avoid fade-in animation for cached images:\n\t * 'instant' = image already cached, 'loading' = waiting, 'loaded' = just finished.\n\t *\n\t * useLayoutEffect runs synchronously after DOM mutations but before paint,\n\t * so we can check img.complete to detect disk-cached images and skip the\n\t * fade-in animation entirely.\n\t */\n\tconst imgRef = useRef< HTMLImageElement >( null );\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'instant' | 'loading' | 'loaded'\n\t>( 'loading' );\n\n\tuseLayoutEffect( () => {\n\t\tif ( imgRef.current?.complete ) {\n\t\t\tsetLoadingState( 'instant' );\n\t\t} else {\n\t\t\tsetLoadingState( 'loading' );\n\t\t}\n\t}, [ imageUrl ] );\n\n\tconst handleLoad = () => {\n\t\tif ( loadingState === 'loading' ) {\n\t\t\tsetLoadingState( 'loaded' );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'dataviews-media-field__media-thumbnail', {\n\t\t\t\t'is-loading': loadingState === 'loading',\n\t\t\t\t'is-loaded': loadingState === 'loaded',\n\t\t\t} ) }\n\t\t>\n\t\t\t<img\n\t\t\t\tref={ imgRef }\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--image\"\n\t\t\t\tsrc={ imageUrl }\n\t\t\t\talt={ item.alt_text || item.title.raw }\n\t\t\t\tonLoad={ handleLoad }\n\t\t\t\tonError={ onError }\n\t\t\t\tloading=\"lazy\"\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default function MediaThumbnailView( {\n\titem,\n\tconfig,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst [ imageError, setImageError ] = useState( false );\n\n\tconst _featuredMedia = useSelect(\n\t\t( select ) => {\n\t\t\t// Avoid the network request if it's not needed. `featured_media` is\n\t\t\t// 0 for images and media without featured media.\n\t\t\tif ( ! item.featured_media ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\titem.featured_media\n\t\t\t);\n\t\t},\n\t\t[ item.featured_media ]\n\t);\n\tconst featuredMedia = item.featured_media ? _featuredMedia : item;\n\n\t// Fetching.\n\tif ( ! featuredMedia ) {\n\t\treturn null;\n\t}\n\n\tconst filename = getFilename( featuredMedia.source_url || '' );\n\n\t// Show fallback if image failed to load or if not an image type.\n\tif (\n\t\timageError ||\n\t\tgetMediaTypeFromMimeType( featuredMedia.mime_type ).type !== 'image'\n\t) {\n\t\treturn (\n\t\t\t<FallbackView item={ featuredMedia } filename={ filename || '' } />\n\t\t);\n\t}\n\n\treturn (\n\t\t<ImageView\n\t\t\titem={ featuredMedia }\n\t\t\tconfigSizes={ config?.sizes }\n\t\t\tonError={ () => setImageError( true ) }\n\t\t/>\n\t);\n}\n"],
5
5
  "mappings": "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",
6
6
  "names": ["VStack", "WCIcon", "Truncate", "clsx", "coreStore"]
7
7
  }
@@ -1,41 +1,33 @@
1
1
  // packages/media-fields/src/alt_text/index.tsx
2
2
  import { __ } from "@wordpress/i18n";
3
- import { TextareaControl as WCTextareaControl } from "@wordpress/components";
4
3
  import { Link } from "@wordpress/ui";
5
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
5
  var altTextField = {
7
6
  id: "alt_text",
8
7
  type: "text",
9
8
  label: __("Alt text"),
10
- isVisible: (item) => item?.media_type === "image",
11
- render: ({ item }) => item?.alt_text || "-",
12
- Edit: ({ field, onChange, data }) => {
13
- return /* @__PURE__ */ jsx(
14
- WCTextareaControl,
9
+ description: /* @__PURE__ */ jsxs(Fragment, { children: [
10
+ /* @__PURE__ */ jsx(
11
+ Link,
15
12
  {
16
- label: field.label,
17
- value: data.alt_text || "",
18
- onChange: (value) => onChange({ alt_text: value }),
19
- help: /* @__PURE__ */ jsxs(Fragment, { children: [
20
- /* @__PURE__ */ jsx(
21
- Link,
22
- {
23
- href: (
24
- // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
25
- __(
26
- "https://www.w3.org/WAI/tutorials/images/decision-tree/"
27
- )
28
- ),
29
- openInNewTab: true,
30
- children: __("Describe the purpose of the image.")
31
- }
32
- ),
33
- /* @__PURE__ */ jsx("br", {}),
34
- __("Leave empty if decorative.")
35
- ] }),
36
- rows: 2
13
+ href: (
14
+ // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
15
+ __(
16
+ "https://www.w3.org/WAI/tutorials/images/decision-tree/"
17
+ )
18
+ ),
19
+ openInNewTab: true,
20
+ children: __("Describe the purpose of the image.")
37
21
  }
38
- );
22
+ ),
23
+ /* @__PURE__ */ jsx("br", {}),
24
+ __("Leave empty if decorative.")
25
+ ] }),
26
+ isVisible: (item) => item?.media_type === "image",
27
+ render: ({ item }) => item?.alt_text || "-",
28
+ Edit: {
29
+ control: "textarea",
30
+ rows: 2
39
31
  },
40
32
  enableSorting: false,
41
33
  filterBy: false
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/alt_text/index.tsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { TextareaControl as WCTextareaControl } from '@wordpress/components';\nimport { Link } from '@wordpress/ui';\nimport type { Field } from '@wordpress/dataviews';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\n\nconst altTextField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'alt_text',\n\ttype: 'text',\n\tlabel: __( 'Alt text' ),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<WCTextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ data.alt_text || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { alt_text: value } ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\thref={\n\t\t\t\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\topenInNewTab\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Describe the purpose of the image.' ) }\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t<br />\n\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\trows={ 2 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
5
- "mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,mBAAmB,yBAAyB;AACrD,SAAS,YAAY;AAiBhB,mBACC,KADD;AAbL,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,UAAW;AAAA,EACtB,WAAW,CAAE,SAAU,MAAM,eAAe;AAAA,EAC5C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,YAAY;AAAA,EAC1C,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,OAAQ,KAAK,YAAY;AAAA,QACzB,UAAW,CAAE,UAAW,SAAU,EAAE,UAAU,MAAM,CAAE;AAAA,QACtD,MACC,iCACC;AAAA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA;AAAA,gBAEC;AAAA,kBACC;AAAA,gBACD;AAAA;AAAA,cAED,cAAY;AAAA,cAEV,aAAI,oCAAqC;AAAA;AAAA,UAC5C;AAAA,UACA,oBAAC,QAAG;AAAA,UACF,GAAI,4BAA6B;AAAA,WACpC;AAAA,QAED,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,mBAAQ;",
4
+ "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { Link } from '@wordpress/ui';\nimport type { Field } from '@wordpress/dataviews';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\n\nconst altTextField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'alt_text',\n\ttype: 'text',\n\tlabel: __( 'Alt text' ),\n\tdescription: (\n\t\t<>\n\t\t\t<Link\n\t\t\t\thref={\n\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t__(\n\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\topenInNewTab\n\t\t\t>\n\t\t\t\t{ __( 'Describe the purpose of the image.' ) }\n\t\t\t</Link>\n\t\t\t<br />\n\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t</>\n\t),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,YAAY;AASnB,mBACC,KADD;AALF,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,UAAW;AAAA,EACtB,aACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA;AAAA,UAEC;AAAA,YACC;AAAA,UACD;AAAA;AAAA,QAED,cAAY;AAAA,QAEV,aAAI,oCAAqC;AAAA;AAAA,IAC5C;AAAA,IACA,oBAAC,QAAG;AAAA,IACF,GAAI,4BAA6B;AAAA,KACpC;AAAA,EAED,WAAW,CAAE,SAAU,MAAM,eAAe;AAAA,EAC5C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,YAAY;AAAA,EAC1C,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,mBAAQ;",
6
6
  "names": []
7
7
  }
@@ -24,11 +24,6 @@ var authorField = {
24
24
  }));
25
25
  },
26
26
  render: AuthorView,
27
- sort: (a, b, direction) => {
28
- const nameA = a._embedded?.author?.[0]?.name || "";
29
- const nameB = b._embedded?.author?.[0]?.name || "";
30
- return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
31
- },
32
27
  filterBy: {
33
28
  operators: ["isAny", "isNone"]
34
29
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/author/index.tsx"],
4
- "sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\tsort: ( a, b, direction ) => {\n\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\treturn direction === 'asc'\n\t\t\t? nameA.localeCompare( nameB )\n\t\t\t: nameB.localeCompare( nameA );\n\t},\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n\treadOnly: true,\n};\n\nexport default authorField;\n"],
5
- "mappings": ";AACA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AAEvC,OAAO,gBAAgB;AAOvB,IAAM,cAA6C;AAAA,EAClD,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,MAAM,cAAe,aAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ;AAAA,EACR,MAAM,CAAE,GAAG,GAAG,cAAe;AAC5B,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAClD,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAElD,WAAO,cAAc,QAClB,MAAM,cAAe,KAAM,IAC3B,MAAM,cAAe,KAAM;AAAA,EAC/B;AAAA,EACA,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,iBAAQ;",
4
+ "sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords< Author >(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n\treadOnly: true,\n};\n\nexport default authorField;\n"],
5
+ "mappings": ";AACA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AAEvC,OAAO,gBAAgB;AAOvB,IAAM,cAA6C;AAAA,EAClD,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,MAAM,cAAe,aAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,iBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,24 +1,15 @@
1
1
  // packages/media-fields/src/caption/index.tsx
2
2
  import { __ } from "@wordpress/i18n";
3
- import { TextareaControl as WCTextareaControl } from "@wordpress/components";
4
3
  import { getRawContent } from "../utils/get-raw-content.mjs";
5
- import { jsx } from "react/jsx-runtime";
6
4
  var captionField = {
7
5
  id: "caption",
8
6
  type: "text",
9
7
  label: __("Caption"),
10
8
  getValue: ({ item }) => getRawContent(item?.caption),
11
9
  render: ({ item }) => getRawContent(item?.caption) || "-",
12
- Edit: ({ field, onChange, data }) => {
13
- return /* @__PURE__ */ jsx(
14
- WCTextareaControl,
15
- {
16
- label: field.label,
17
- value: getRawContent(data.caption) || "",
18
- onChange: (value) => onChange({ caption: value }),
19
- rows: 2
20
- }
21
- );
10
+ Edit: {
11
+ control: "textarea",
12
+ rows: 2
22
13
  },
23
14
  enableSorting: false,
24
15
  filterBy: false
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/caption/index.tsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { TextareaControl as WCTextareaControl } from '@wordpress/components';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst captionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'caption',\n\ttype: 'text',\n\tlabel: __( 'Caption' ),\n\tgetValue: ( { item } ) => getRawContent( item?.caption ),\n\trender: ( { item } ) => getRawContent( item?.caption ) || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<WCTextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ getRawContent( data.caption ) || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { caption: value } ) }\n\t\t\t\trows={ 2 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],
5
- "mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,mBAAmB,yBAAyB;AAGrD,SAAS,qBAAqB;AAU3B;AARH,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,SAAU;AAAA,EACrB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ;AAAA,EACvD,QAAQ,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ,KAAK;AAAA,EAC1D,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,OAAQ,cAAe,KAAK,OAAQ,KAAK;AAAA,QACzC,UAAW,CAAE,UAAW,SAAU,EAAE,SAAS,MAAM,CAAE;AAAA,QACrD,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,kBAAQ;",
4
+ "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst captionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'caption',\n\ttype: 'text',\n\tlabel: __( 'Caption' ),\n\tgetValue: ( { item } ) => getRawContent( item?.caption ),\n\trender: ( { item } ) => getRawContent( item?.caption ) || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU;AAGnB,SAAS,qBAAqB;AAE9B,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,SAAU;AAAA,EACrB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ;AAAA,EACvD,QAAQ,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ,KAAK;AAAA,EAC1D,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,kBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,5 @@
1
1
  // packages/media-fields/src/description/index.tsx
2
2
  import { __ } from "@wordpress/i18n";
3
- import { TextareaControl as WCTextareaControl } from "@wordpress/components";
4
3
  import { getRawContent } from "../utils/get-raw-content.mjs";
5
4
  import { jsx } from "react/jsx-runtime";
6
5
  var descriptionField = {
@@ -9,16 +8,9 @@ var descriptionField = {
9
8
  label: __("Description"),
10
9
  getValue: ({ item }) => getRawContent(item?.description),
11
10
  render: ({ item }) => /* @__PURE__ */ jsx("div", { children: getRawContent(item?.description) || "-" }),
12
- Edit: ({ field, onChange, data }) => {
13
- return /* @__PURE__ */ jsx(
14
- WCTextareaControl,
15
- {
16
- label: field.label,
17
- value: getRawContent(data.description) || "",
18
- onChange: (value) => onChange({ description: value }),
19
- rows: 5
20
- }
21
- );
11
+ Edit: {
12
+ control: "textarea",
13
+ rows: 5
22
14
  },
23
15
  enableSorting: false,
24
16
  filterBy: false
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/description/index.tsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { TextareaControl as WCTextareaControl } from '@wordpress/components';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst descriptionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue: ( { item } ) => getRawContent( item?.description ),\n\trender: ( { item } ) => (\n\t\t<div>{ getRawContent( item?.description ) || '-' }</div>\n\t),\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<WCTextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ getRawContent( data.description ) || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { description: value } ) }\n\t\t\t\trows={ 5 }\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],
5
- "mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,mBAAmB,yBAAyB;AAGrD,SAAS,qBAAqB;AAQ5B;AANF,IAAM,mBAAgE;AAAA,EACrE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,aAAc;AAAA,EACzB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,WAAY;AAAA,EAC3D,QAAQ,CAAE,EAAE,KAAK,MAChB,oBAAC,SAAM,wBAAe,MAAM,WAAY,KAAK,KAAK;AAAA,EAEnD,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,OAAQ,cAAe,KAAK,WAAY,KAAK;AAAA,QAC7C,UAAW,CAAE,UAAW,SAAU,EAAE,aAAa,MAAM,CAAE;AAAA,QACzD,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
4
+ "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst descriptionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue: ( { item } ) => getRawContent( item?.description ),\n\trender: ( { item } ) => (\n\t\t<div>{ getRawContent( item?.description ) || '-' }</div>\n\t),\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 5,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU;AAGnB,SAAS,qBAAqB;AAQ5B;AANF,IAAM,mBAAgE;AAAA,EACrE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,aAAc;AAAA,EACzB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,WAAY;AAAA,EAC3D,QAAQ,CAAE,EAAE,KAAK,MAChB,oBAAC,SAAM,wBAAe,MAAM,WAAY,KAAK,KAAK;AAAA,EAEnD,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/media_thumbnail/view.tsx"],
4
- "sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport { useState, useRef, useLayoutEffect } from '@wordpress/element';\nimport type { Attachment } from '@wordpress/core-data';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { getMediaTypeFromMimeType } from '../utils/get-media-type-from-mime-type';\nimport type { MediaItem } from '../types';\n\n/**\n * Given the available image sizes and a target display width, returns the URL\n * of the smallest size whose width is >= the target. Falls back to the largest\n * available size, or the original source_url.\n *\n * @param featuredMedia The media item with size details.\n * @param configSizes The target display size string (e.g. '900px').\n */\nexport function getBestImageUrl(\n\tfeaturedMedia: Attachment | MediaItem,\n\tconfigSizes?: string\n): string {\n\tconst sizes = featuredMedia?.media_details?.sizes;\n\tif ( ! sizes ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\tconst sizeEntries = Object.values( sizes );\n\n\tif ( ! sizeEntries.length ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\t// Parse target width from config.sizes (e.g. '900px' → 900).\n\tconst targetWidth = configSizes ? parseInt( configSizes, 10 ) : NaN;\n\n\tif ( ! Number.isNaN( targetWidth ) ) {\n\t\t// Filter to entries that have a valid numeric width.\n\t\tconst validEntries = sizeEntries.filter(\n\t\t\t( s ) => typeof s.width === 'number' && ! Number.isNaN( s.width )\n\t\t);\n\n\t\tif ( ! validEntries.length ) {\n\t\t\treturn featuredMedia.source_url;\n\t\t}\n\n\t\t// Sort ascending by width.\n\t\tconst sorted = [ ...validEntries ].sort(\n\t\t\t( a, b ) => a.width - b.width\n\t\t);\n\t\t// Pick the smallest size that is >= target width.\n\t\tconst match = sorted.find( ( s ) => s.width >= targetWidth );\n\t\tif ( match ) {\n\t\t\treturn match.source_url;\n\t\t}\n\t\t// No size large enough — use the largest available.\n\t\treturn sorted[ sorted.length - 1 ].source_url;\n\t}\n\n\t// If we can't parse the target, fall back to source_url.\n\treturn featuredMedia.source_url;\n}\n\nfunction FallbackView( {\n\titem,\n\tfilename,\n}: {\n\titem: MediaItem;\n\tfilename: string;\n} ) {\n\treturn (\n\t\t<div className=\"dataviews-media-field__media-thumbnail\">\n\t\t\t<VStack\n\t\t\t\tjustify=\"center\"\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail__stack\"\n\t\t\t\tspacing={ 0 }\n\t\t\t>\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--icon\"\n\t\t\t\t\ticon={ getMediaTypeFromMimeType( item.mime_type ).icon }\n\t\t\t\t\tsize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ !! filename && (\n\t\t\t\t\t<div className=\"dataviews-media-field__media-thumbnail__filename\">\n\t\t\t\t\t\t<Truncate className=\"dataviews-media-field__media-thumbnail__filename__truncate\">\n\t\t\t\t\t\t\t{ filename }\n\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nfunction ImageView( {\n\titem,\n\tconfigSizes,\n\tonError,\n}: {\n\titem: Attachment | MediaItem;\n\tconfigSizes?: string;\n\tonError: () => void;\n} ) {\n\tconst imageUrl = getBestImageUrl( item, configSizes );\n\n\t/*\n\t * Use three states to avoid fade-in animation for cached images:\n\t * 'instant' = image already cached, 'loading' = waiting, 'loaded' = just finished.\n\t *\n\t * useLayoutEffect runs synchronously after DOM mutations but before paint,\n\t * so we can check img.complete to detect disk-cached images and skip the\n\t * fade-in animation entirely.\n\t */\n\tconst imgRef = useRef< HTMLImageElement >( null );\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'instant' | 'loading' | 'loaded'\n\t>( 'loading' );\n\n\tuseLayoutEffect( () => {\n\t\tif ( imgRef.current?.complete ) {\n\t\t\tsetLoadingState( 'instant' );\n\t\t} else {\n\t\t\tsetLoadingState( 'loading' );\n\t\t}\n\t}, [ imageUrl ] );\n\n\tconst handleLoad = () => {\n\t\tif ( loadingState === 'loading' ) {\n\t\t\tsetLoadingState( 'loaded' );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'dataviews-media-field__media-thumbnail', {\n\t\t\t\t'is-loading': loadingState === 'loading',\n\t\t\t\t'is-loaded': loadingState === 'loaded',\n\t\t\t} ) }\n\t\t>\n\t\t\t<img\n\t\t\t\tref={ imgRef }\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--image\"\n\t\t\t\tsrc={ imageUrl }\n\t\t\t\talt={ item.alt_text || item.title.raw }\n\t\t\t\tonLoad={ handleLoad }\n\t\t\t\tonError={ onError }\n\t\t\t\tloading=\"lazy\"\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default function MediaThumbnailView( {\n\titem,\n\tconfig,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst [ imageError, setImageError ] = useState( false );\n\n\tconst _featuredMedia = useSelect(\n\t\t( select ) => {\n\t\t\t// Avoid the network request if it's not needed. `featured_media` is\n\t\t\t// 0 for images and media without featured media.\n\t\t\tif ( ! item.featured_media ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn select( coreStore ).getEntityRecord< Attachment >(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\titem.featured_media\n\t\t\t);\n\t\t},\n\t\t[ item.featured_media ]\n\t);\n\tconst featuredMedia = item.featured_media ? _featuredMedia : item;\n\n\t// Fetching.\n\tif ( ! featuredMedia ) {\n\t\treturn null;\n\t}\n\n\tconst filename = getFilename( featuredMedia.source_url || '' );\n\n\t// Show fallback if image failed to load or if not an image type.\n\tif (\n\t\timageError ||\n\t\tgetMediaTypeFromMimeType( featuredMedia.mime_type ).type !== 'image'\n\t) {\n\t\treturn (\n\t\t\t<FallbackView item={ featuredMedia } filename={ filename || '' } />\n\t\t);\n\t}\n\n\treturn (\n\t\t<ImageView\n\t\t\titem={ featuredMedia }\n\t\t\tconfigSizes={ config?.sizes }\n\t\t\tonError={ () => setImageError( true ) }\n\t\t/>\n\t);\n}\n"],
4
+ "sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport { useState, useRef, useLayoutEffect } from '@wordpress/element';\nimport type { Attachment } from '@wordpress/core-data';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { getMediaTypeFromMimeType } from '../utils/get-media-type-from-mime-type';\nimport type { MediaItem } from '../types';\n\n/**\n * Given the available image sizes and a target display width, returns the URL\n * of the smallest size whose width is >= the target. Falls back to the largest\n * available size, or the original source_url.\n *\n * @param featuredMedia The media item with size details.\n * @param configSizes The target display size string (e.g. '900px').\n */\nexport function getBestImageUrl(\n\tfeaturedMedia: Attachment | MediaItem,\n\tconfigSizes?: string\n): string {\n\tconst sizes = featuredMedia?.media_details?.sizes;\n\tif ( ! sizes ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\tconst sizeEntries = Object.values( sizes );\n\n\tif ( ! sizeEntries.length ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\t// Parse target width from config.sizes (e.g. '900px' → 900).\n\tconst targetWidth = configSizes ? parseInt( configSizes, 10 ) : NaN;\n\n\tif ( ! Number.isNaN( targetWidth ) ) {\n\t\t// Filter to entries that have a valid numeric width.\n\t\tconst validEntries = sizeEntries.filter(\n\t\t\t( s ) => typeof s.width === 'number' && ! Number.isNaN( s.width )\n\t\t);\n\n\t\tif ( ! validEntries.length ) {\n\t\t\treturn featuredMedia.source_url;\n\t\t}\n\n\t\t// Sort ascending by width.\n\t\tconst sorted = [ ...validEntries ].sort(\n\t\t\t( a, b ) => a.width - b.width\n\t\t);\n\t\t// Pick the smallest size that is >= target width.\n\t\tconst match = sorted.find( ( s ) => s.width >= targetWidth );\n\t\tif ( match ) {\n\t\t\treturn match.source_url;\n\t\t}\n\t\t// No size large enough — use the largest available.\n\t\treturn sorted[ sorted.length - 1 ].source_url;\n\t}\n\n\t// If we can't parse the target, fall back to source_url.\n\treturn featuredMedia.source_url;\n}\n\nfunction FallbackView( {\n\titem,\n\tfilename,\n}: {\n\titem: MediaItem;\n\tfilename: string;\n} ) {\n\treturn (\n\t\t<div className=\"dataviews-media-field__media-thumbnail\">\n\t\t\t<VStack\n\t\t\t\tjustify=\"center\"\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail__stack\"\n\t\t\t\tspacing={ 0 }\n\t\t\t>\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--icon\"\n\t\t\t\t\ticon={ getMediaTypeFromMimeType( item.mime_type ).icon }\n\t\t\t\t\tsize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ !! filename && (\n\t\t\t\t\t<div className=\"dataviews-media-field__media-thumbnail__filename\">\n\t\t\t\t\t\t<Truncate className=\"dataviews-media-field__media-thumbnail__filename__truncate\">\n\t\t\t\t\t\t\t{ filename }\n\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nfunction ImageView( {\n\titem,\n\tconfigSizes,\n\tonError,\n}: {\n\titem: Attachment | MediaItem;\n\tconfigSizes?: string;\n\tonError: () => void;\n} ) {\n\tconst imageUrl = getBestImageUrl( item, configSizes );\n\n\t/*\n\t * Use three states to avoid fade-in animation for cached images:\n\t * 'instant' = image already cached, 'loading' = waiting, 'loaded' = just finished.\n\t *\n\t * useLayoutEffect runs synchronously after DOM mutations but before paint,\n\t * so we can check img.complete to detect disk-cached images and skip the\n\t * fade-in animation entirely.\n\t */\n\tconst imgRef = useRef< HTMLImageElement >( null );\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'instant' | 'loading' | 'loaded'\n\t>( 'loading' );\n\n\tuseLayoutEffect( () => {\n\t\tif ( imgRef.current?.complete ) {\n\t\t\tsetLoadingState( 'instant' );\n\t\t} else {\n\t\t\tsetLoadingState( 'loading' );\n\t\t}\n\t}, [ imageUrl ] );\n\n\tconst handleLoad = () => {\n\t\tif ( loadingState === 'loading' ) {\n\t\t\tsetLoadingState( 'loaded' );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'dataviews-media-field__media-thumbnail', {\n\t\t\t\t'is-loading': loadingState === 'loading',\n\t\t\t\t'is-loaded': loadingState === 'loaded',\n\t\t\t} ) }\n\t\t>\n\t\t\t<img\n\t\t\t\tref={ imgRef }\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--image\"\n\t\t\t\tsrc={ imageUrl }\n\t\t\t\talt={ item.alt_text || item.title.raw }\n\t\t\t\tonLoad={ handleLoad }\n\t\t\t\tonError={ onError }\n\t\t\t\tloading=\"lazy\"\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default function MediaThumbnailView( {\n\titem,\n\tconfig,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst [ imageError, setImageError ] = useState( false );\n\n\tconst _featuredMedia = useSelect(\n\t\t( select ) => {\n\t\t\t// Avoid the network request if it's not needed. `featured_media` is\n\t\t\t// 0 for images and media without featured media.\n\t\t\tif ( ! item.featured_media ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\titem.featured_media\n\t\t\t);\n\t\t},\n\t\t[ item.featured_media ]\n\t);\n\tconst featuredMedia = item.featured_media ? _featuredMedia : item;\n\n\t// Fetching.\n\tif ( ! featuredMedia ) {\n\t\treturn null;\n\t}\n\n\tconst filename = getFilename( featuredMedia.source_url || '' );\n\n\t// Show fallback if image failed to load or if not an image type.\n\tif (\n\t\timageError ||\n\t\tgetMediaTypeFromMimeType( featuredMedia.mime_type ).type !== 'image'\n\t) {\n\t\treturn (\n\t\t\t<FallbackView item={ featuredMedia } filename={ filename || '' } />\n\t\t);\n\t}\n\n\treturn (\n\t\t<ImageView\n\t\t\titem={ featuredMedia }\n\t\t\tconfigSizes={ config?.sizes }\n\t\t\tonError={ () => setImageError( true ) }\n\t\t/>\n\t);\n}\n"],
5
5
  "mappings": "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",
6
6
  "names": []
7
7
  }
@@ -116,8 +116,7 @@
116
116
  .media-author-field__avatar img {
117
117
  width: 16px;
118
118
  height: 16px;
119
- -o-object-fit: cover;
120
- object-fit: cover;
119
+ object-fit: cover;
121
120
  opacity: 1;
122
121
  border-radius: 100%;
123
122
  }
@@ -182,8 +181,7 @@
182
181
  display: block;
183
182
  width: 100%;
184
183
  height: 100%;
185
- -o-object-fit: cover;
186
- object-fit: cover;
184
+ object-fit: cover;
187
185
  }
188
186
 
189
187
  .dataviews-media-field__media-thumbnail__stack {
@@ -116,8 +116,7 @@
116
116
  .media-author-field__avatar img {
117
117
  width: 16px;
118
118
  height: 16px;
119
- -o-object-fit: cover;
120
- object-fit: cover;
119
+ object-fit: cover;
121
120
  opacity: 1;
122
121
  border-radius: 100%;
123
122
  }
@@ -182,8 +181,7 @@
182
181
  display: block;
183
182
  width: 100%;
184
183
  height: 100%;
185
- -o-object-fit: cover;
186
- object-fit: cover;
184
+ object-fit: cover;
187
185
  }
188
186
 
189
187
  .dataviews-media-field__media-thumbnail__stack {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/alt_text/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAElE,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAmC5D,CAAC;eAEa,YAAY"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/alt_text/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAElE,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CA6B5D,CAAC;eAEa,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/author/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQ1C,QAAA,MAAM,WAAW,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAkC7C,CAAC;eAEa,WAAW"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/author/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQ1C,QAAA,MAAM,WAAW,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CA0B7C,CAAC;eAEa,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caption/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAkB5D,CAAC;eAEa,YAAY"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caption/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAY5D,CAAC;eAEa,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/description/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,QAAA,MAAM,gBAAgB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAoBhE,CAAC;eAEa,gBAAgB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/description/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,QAAA,MAAM,gBAAgB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAchE,CAAC;eAEa,gBAAgB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/media-fields",
3
- "version": "0.19.2-next.v.202608281122.0",
3
+ "version": "0.20.0",
4
4
  "description": "Reusable field definitions for displaying and editing media attachment properties in WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -48,24 +48,24 @@
48
48
  "src/**/*.scss"
49
49
  ],
50
50
  "dependencies": {
51
- "@wordpress/base-styles": "^13.0.1-next.v.202608281122.0",
52
- "@wordpress/components": "^40.1.1-next.v.202608281122.0",
53
- "@wordpress/compose": "^8.7.2-next.v.202608281122.0",
54
- "@wordpress/core-data": "^7.54.2-next.v.202608281122.0",
55
- "@wordpress/data": "^10.54.2-next.v.202608281122.0",
56
- "@wordpress/dataviews": "^18.1.2-next.v.202608281122.0",
57
- "@wordpress/element": "^8.6.2-next.v.202608281122.0",
58
- "@wordpress/i18n": "^6.27.1-next.v.202608281122.0",
59
- "@wordpress/icons": "^15.5.1-next.v.202608281122.0",
60
- "@wordpress/ui": "^0.22.1-next.v.202608281122.0",
61
- "@wordpress/url": "^4.54.1-next.v.202608281122.0",
51
+ "@wordpress/base-styles": "^13.1.0",
52
+ "@wordpress/components": "^40.1.0",
53
+ "@wordpress/compose": "^8.8.0",
54
+ "@wordpress/core-data": "^8.0.0",
55
+ "@wordpress/data": "^10.55.0",
56
+ "@wordpress/dataviews": "^19.0.0",
57
+ "@wordpress/element": "^8.7.0",
58
+ "@wordpress/i18n": "^6.28.0",
59
+ "@wordpress/icons": "^16.0.0",
60
+ "@wordpress/ui": "^0.22.0",
61
+ "@wordpress/url": "^4.55.0",
62
62
  "clsx": "^2.1.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@testing-library/dom": "^10.4.1",
66
- "@testing-library/jest-dom": "^6.9.1",
67
- "@testing-library/react": "^16.3.2",
68
- "@types/jest": "^30.0.0"
66
+ "@testing-library/jest-dom": "^7.0.1",
67
+ "@testing-library/react": "^16.3.3",
68
+ "vitest": "^5.0.0"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@types/react": "^18 || ^19",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "de479d415171765f7b573c81aeec5334ff506a12"
82
+ "gitHead": "485f42ae8a1c58ceea18371a507fd4acfa86fbd8"
83
83
  }
@@ -1,5 +1,4 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- import { TextareaControl as WCTextareaControl } from '@wordpress/components';
3
2
  import { Link } from '@wordpress/ui';
4
3
  import type { Field } from '@wordpress/dataviews';
5
4
  import type { Attachment, Updatable } from '@wordpress/core-data';
@@ -8,34 +7,28 @@ const altTextField: Partial< Field< Updatable< Attachment > > > = {
8
7
  id: 'alt_text',
9
8
  type: 'text',
10
9
  label: __( 'Alt text' ),
10
+ description: (
11
+ <>
12
+ <Link
13
+ href={
14
+ // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
15
+ __(
16
+ 'https://www.w3.org/WAI/tutorials/images/decision-tree/'
17
+ )
18
+ }
19
+ openInNewTab
20
+ >
21
+ { __( 'Describe the purpose of the image.' ) }
22
+ </Link>
23
+ <br />
24
+ { __( 'Leave empty if decorative.' ) }
25
+ </>
26
+ ),
11
27
  isVisible: ( item ) => item?.media_type === 'image',
12
28
  render: ( { item } ) => item?.alt_text || '-',
13
- Edit: ( { field, onChange, data } ) => {
14
- return (
15
- <WCTextareaControl
16
- label={ field.label }
17
- value={ data.alt_text || '' }
18
- onChange={ ( value ) => onChange( { alt_text: value } ) }
19
- help={
20
- <>
21
- <Link
22
- href={
23
- // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
24
- __(
25
- 'https://www.w3.org/WAI/tutorials/images/decision-tree/'
26
- )
27
- }
28
- openInNewTab
29
- >
30
- { __( 'Describe the purpose of the image.' ) }
31
- </Link>
32
- <br />
33
- { __( 'Leave empty if decorative.' ) }
34
- </>
35
- }
36
- rows={ 2 }
37
- />
38
- );
29
+ Edit: {
30
+ control: 'textarea',
31
+ rows: 2,
39
32
  },
40
33
  enableSorting: false,
41
34
  filterBy: false,
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import { render, screen } from '@testing-library/react';
2
3
  import type { NormalizedField } from '@wordpress/dataviews';
3
4
  import MediaAttachedToView from '../view';
@@ -16,7 +16,7 @@ const authorField: Partial< Field< MediaItem > > = {
16
16
  type: 'integer',
17
17
  getElements: async () => {
18
18
  const authors: Author[] =
19
- ( await resolveSelect( coreDataStore ).getEntityRecords(
19
+ ( await resolveSelect( coreDataStore ).getEntityRecords< Author >(
20
20
  'root',
21
21
  'user',
22
22
  {
@@ -32,14 +32,6 @@ const authorField: Partial< Field< MediaItem > > = {
32
32
  } ) );
33
33
  },
34
34
  render: AuthorView,
35
- sort: ( a, b, direction ) => {
36
- const nameA = a._embedded?.author?.[ 0 ]?.name || '';
37
- const nameB = b._embedded?.author?.[ 0 ]?.name || '';
38
-
39
- return direction === 'asc'
40
- ? nameA.localeCompare( nameB )
41
- : nameB.localeCompare( nameA );
42
- },
43
35
  filterBy: {
44
36
  operators: [ 'isAny', 'isNone' ],
45
37
  },
@@ -1,5 +1,4 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- import { TextareaControl as WCTextareaControl } from '@wordpress/components';
3
2
  import type { Attachment, Updatable } from '@wordpress/core-data';
4
3
  import type { Field } from '@wordpress/dataviews';
5
4
  import { getRawContent } from '../utils/get-raw-content';
@@ -10,15 +9,9 @@ const captionField: Partial< Field< Updatable< Attachment > > > = {
10
9
  label: __( 'Caption' ),
11
10
  getValue: ( { item } ) => getRawContent( item?.caption ),
12
11
  render: ( { item } ) => getRawContent( item?.caption ) || '-',
13
- Edit: ( { field, onChange, data } ) => {
14
- return (
15
- <WCTextareaControl
16
- label={ field.label }
17
- value={ getRawContent( data.caption ) || '' }
18
- onChange={ ( value ) => onChange( { caption: value } ) }
19
- rows={ 2 }
20
- />
21
- );
12
+ Edit: {
13
+ control: 'textarea',
14
+ rows: 2,
22
15
  },
23
16
  enableSorting: false,
24
17
  filterBy: false,
@@ -1,5 +1,4 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- import { TextareaControl as WCTextareaControl } from '@wordpress/components';
3
2
  import type { Attachment, Updatable } from '@wordpress/core-data';
4
3
  import type { Field } from '@wordpress/dataviews';
5
4
  import { getRawContent } from '../utils/get-raw-content';
@@ -12,15 +11,9 @@ const descriptionField: Partial< Field< Updatable< Attachment > > > = {
12
11
  render: ( { item } ) => (
13
12
  <div>{ getRawContent( item?.description ) || '-' }</div>
14
13
  ),
15
- Edit: ( { field, onChange, data } ) => {
16
- return (
17
- <WCTextareaControl
18
- label={ field.label }
19
- value={ getRawContent( data.description ) || '' }
20
- onChange={ ( value ) => onChange( { description: value } ) }
21
- rows={ 5 }
22
- />
23
- );
14
+ Edit: {
15
+ control: 'textarea',
16
+ rows: 5,
24
17
  },
25
18
  enableSorting: false,
26
19
  filterBy: false,
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import filenameField from '../index';
2
3
  import type { MediaItem } from '../../types';
3
4
 
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import { render, screen } from '@testing-library/react';
2
3
  import type { NormalizedField } from '@wordpress/dataviews';
3
4
  import FileNameView from '../view';
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import filesizeField from '../index';
2
3
  import type { MediaItem } from '../../types';
3
4
 
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import type { Attachment, Updatable } from '@wordpress/core-data';
2
3
  import mediaDimensionsField from '../index';
3
4
 
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import { getBestImageUrl } from '../view';
2
3
 
3
4
  type Media = Parameters< typeof getBestImageUrl >[ 0 ];
@@ -169,7 +169,7 @@ export default function MediaThumbnailView( {
169
169
  if ( ! item.featured_media ) {
170
170
  return;
171
171
  }
172
- return select( coreStore ).getEntityRecord< Attachment >(
172
+ return select( coreStore ).getEntityRecord(
173
173
  'postType',
174
174
  'attachment',
175
175
  item.featured_media