@wordpress/media-fields 0.19.2-next.v.202609031004.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.
package/CHANGELOG.md CHANGED
@@ -2,10 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 0.19.1-next.0 (2026-09-03)
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< 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\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,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< 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\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 +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.202609031004.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,25 +48,24 @@
48
48
  "src/**/*.scss"
49
49
  ],
50
50
  "dependencies": {
51
- "@wordpress/base-styles": "^13.1.1-next.v.202609031004.0",
52
- "@wordpress/components": "^40.1.1-next.v.202609031004.0",
53
- "@wordpress/compose": "^8.7.2-next.v.202609031004.0",
54
- "@wordpress/core-data": "^8.0.1-next.v.202609031004.0",
55
- "@wordpress/data": "^10.54.2-next.v.202609031004.0",
56
- "@wordpress/dataviews": "^19.0.1-next.v.202609031004.0",
57
- "@wordpress/element": "^8.6.2-next.v.202609031004.0",
58
- "@wordpress/i18n": "^6.27.1-next.v.202609031004.0",
59
- "@wordpress/icons": "^16.0.1-next.v.202609031004.0",
60
- "@wordpress/ui": "^0.22.1-next.v.202609031004.0",
61
- "@wordpress/url": "^4.54.1-next.v.202609031004.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",
69
- "vitest": "^4.1.10"
66
+ "@testing-library/jest-dom": "^7.0.1",
67
+ "@testing-library/react": "^16.3.3",
68
+ "vitest": "^5.0.0"
70
69
  },
71
70
  "peerDependencies": {
72
71
  "@types/react": "^18 || ^19",
@@ -80,5 +79,5 @@
80
79
  "publishConfig": {
81
80
  "access": "public"
82
81
  },
83
- "gitHead": "7275d6c6d93b542fca3cd98cdb9c7344ddd11e19"
82
+ "gitHead": "485f42ae8a1c58ceea18371a507fd4acfa86fbd8"
84
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';
@@ -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 { 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 { getBestImageUrl } from '../view';
2
3
 
3
4
  type Media = Parameters< typeof getBestImageUrl >[ 0 ];