@wordpress/media-fields 0.17.0 → 0.18.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 (104) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/alt_text/index.cjs.map +2 -2
  3. package/build/attached_to/edit.cjs +5 -24
  4. package/build/attached_to/edit.cjs.map +2 -2
  5. package/build/attached_to/index.cjs.map +2 -2
  6. package/build/attached_to/view.cjs.map +2 -2
  7. package/build/author/index.cjs.map +2 -2
  8. package/build/author/view.cjs.map +2 -2
  9. package/build/caption/index.cjs.map +2 -2
  10. package/build/date_added/index.cjs.map +2 -2
  11. package/build/date_modified/index.cjs.map +2 -2
  12. package/build/description/index.cjs.map +2 -2
  13. package/build/filename/index.cjs.map +2 -2
  14. package/build/filename/view.cjs.map +2 -2
  15. package/build/filesize/index.cjs.map +2 -2
  16. package/build/media_dimensions/index.cjs.map +2 -2
  17. package/build/media_thumbnail/index.cjs.map +2 -2
  18. package/build/media_thumbnail/view.cjs.map +2 -2
  19. package/build/mime_type/index.cjs.map +2 -2
  20. package/build/types.cjs.map +1 -1
  21. package/build/utils/get-media-type-from-mime-type.cjs.map +2 -2
  22. package/build-module/alt_text/index.mjs.map +2 -2
  23. package/build-module/attached_to/edit.mjs +8 -27
  24. package/build-module/attached_to/edit.mjs.map +2 -2
  25. package/build-module/attached_to/index.mjs.map +2 -2
  26. package/build-module/attached_to/view.mjs.map +2 -2
  27. package/build-module/author/index.mjs.map +2 -2
  28. package/build-module/author/view.mjs.map +2 -2
  29. package/build-module/caption/index.mjs.map +2 -2
  30. package/build-module/date_added/index.mjs.map +2 -2
  31. package/build-module/date_modified/index.mjs.map +2 -2
  32. package/build-module/description/index.mjs.map +2 -2
  33. package/build-module/filename/index.mjs.map +2 -2
  34. package/build-module/filename/view.mjs.map +2 -2
  35. package/build-module/filesize/index.mjs.map +2 -2
  36. package/build-module/media_dimensions/index.mjs.map +2 -2
  37. package/build-module/media_thumbnail/index.mjs.map +2 -2
  38. package/build-module/media_thumbnail/view.mjs.map +2 -2
  39. package/build-module/mime_type/index.mjs.map +2 -2
  40. package/build-module/utils/get-media-type-from-mime-type.mjs.map +2 -2
  41. package/build-style/style-rtl.css +14 -3
  42. package/build-style/style.css +14 -3
  43. package/build-types/alt_text/index.d.ts.map +1 -1
  44. package/build-types/attached_to/edit.d.ts +0 -3
  45. package/build-types/attached_to/edit.d.ts.map +1 -1
  46. package/build-types/attached_to/index.d.ts +0 -3
  47. package/build-types/attached_to/index.d.ts.map +1 -1
  48. package/build-types/attached_to/view.d.ts +0 -3
  49. package/build-types/attached_to/view.d.ts.map +1 -1
  50. package/build-types/author/index.d.ts +0 -6
  51. package/build-types/author/index.d.ts.map +1 -1
  52. package/build-types/author/view.d.ts +0 -3
  53. package/build-types/author/view.d.ts.map +1 -1
  54. package/build-types/caption/index.d.ts.map +1 -1
  55. package/build-types/date_added/index.d.ts +0 -3
  56. package/build-types/date_added/index.d.ts.map +1 -1
  57. package/build-types/date_modified/index.d.ts +0 -3
  58. package/build-types/date_modified/index.d.ts.map +1 -1
  59. package/build-types/description/index.d.ts.map +1 -1
  60. package/build-types/filename/index.d.ts +0 -3
  61. package/build-types/filename/index.d.ts.map +1 -1
  62. package/build-types/filename/view.d.ts +0 -3
  63. package/build-types/filename/view.d.ts.map +1 -1
  64. package/build-types/filesize/index.d.ts +0 -3
  65. package/build-types/filesize/index.d.ts.map +1 -1
  66. package/build-types/media_dimensions/index.d.ts.map +1 -1
  67. package/build-types/media_thumbnail/index.d.ts +0 -3
  68. package/build-types/media_thumbnail/index.d.ts.map +1 -1
  69. package/build-types/media_thumbnail/view.d.ts.map +1 -1
  70. package/build-types/mime_type/index.d.ts.map +1 -1
  71. package/build-types/stories/index.story.d.ts.map +1 -1
  72. package/build-types/types.d.ts +0 -3
  73. package/build-types/types.d.ts.map +1 -1
  74. package/build-types/utils/get-media-type-from-mime-type.d.ts +0 -3
  75. package/build-types/utils/get-media-type-from-mime-type.d.ts.map +1 -1
  76. package/package.json +15 -15
  77. package/src/alt_text/index.tsx +0 -3
  78. package/src/attached_to/edit.tsx +16 -34
  79. package/src/attached_to/index.tsx +0 -7
  80. package/src/attached_to/style.scss +36 -0
  81. package/src/attached_to/test/view.test.tsx +0 -11
  82. package/src/attached_to/view.tsx +0 -6
  83. package/src/author/index.tsx +0 -7
  84. package/src/author/view.tsx +0 -11
  85. package/src/caption/index.tsx +0 -7
  86. package/src/date_added/index.tsx +0 -7
  87. package/src/date_modified/index.tsx +0 -7
  88. package/src/description/index.tsx +0 -7
  89. package/src/filename/index.ts +0 -7
  90. package/src/filename/test/index.test.ts +0 -3
  91. package/src/filename/test/view.test.tsx +0 -11
  92. package/src/filename/view.tsx +0 -7
  93. package/src/filesize/index.tsx +0 -7
  94. package/src/filesize/test/index.test.tsx +0 -3
  95. package/src/media_dimensions/index.ts +0 -3
  96. package/src/media_dimensions/test/index.test.ts +0 -7
  97. package/src/media_thumbnail/index.tsx +0 -7
  98. package/src/media_thumbnail/test/get-best-image-url.test.ts +0 -3
  99. package/src/media_thumbnail/view.tsx +0 -10
  100. package/src/mime_type/index.ts +0 -3
  101. package/src/stories/index.story.tsx +0 -7
  102. package/src/style.scss +1 -0
  103. package/src/types.ts +0 -3
  104. package/src/utils/get-media-type-from-mime-type.ts +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filesize/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAsE1C,QAAA,MAAM,aAAa,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAc/C,CAAC;eAEa,aAAa"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filesize/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAsE1C,QAAA,MAAM,aAAa,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAc/C,CAAC;eAEa,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media_dimensions/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,QAAA,MAAM,oBAAoB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAmBpE,CAAC;eAEa,oBAAoB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media_dimensions/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,QAAA,MAAM,oBAAoB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAmBpE,CAAC;eAEa,oBAAoB"}
@@ -1,7 +1,4 @@
1
1
  import type { Field } from '@wordpress/dataviews';
2
- /**
3
- * Internal dependencies
4
- */
5
2
  import type { MediaItem } from '../types';
6
3
  declare const mediaThumbnailField: Partial<Field<MediaItem>>;
7
4
  export default mediaThumbnailField;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media_thumbnail/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,QAAA,MAAM,mBAAmB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAOrD,CAAC;eAEa,mBAAmB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media_thumbnail/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,QAAA,MAAM,mBAAmB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAOrD,CAAC;eAEa,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/media_thumbnail/view.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAKrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,aAAa,EAAE,UAAU,GAAG,SAAS,EACrC,WAAW,CAAC,EAAE,MAAM,GAClB,MAAM,CAwCR;AA4FD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAE,EAC3C,IAAI,EACJ,MAAM,GACN,EAAE,wBAAwB,CAAE,SAAS,CAAE,sCA4CvC"}
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/media_thumbnail/view.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,aAAa,EAAE,UAAU,GAAG,SAAS,EACrC,WAAW,CAAC,EAAE,MAAM,GAClB,MAAM,CAwCR;AA4FD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAE,EAC3C,IAAI,EACJ,MAAM,GACN,EAAE,wBAAwB,CAAE,SAAS,CAAE,sCA4CvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mime_type/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,QAAA,MAAM,aAAa,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAW7D,CAAC;eAEa,aAAa"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mime_type/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,QAAA,MAAM,aAAa,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAW7D,CAAC;eAEa,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;;IAsB1D,KAAK;IACL,SAAS;;;AAuRV,QAAA,MAAM,kBAAkB,aAAe;IAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;CAAE,gCA4CnE,CAAC;AAEF,eAAO,MAAM,gBAAgB;IAC5B,MAAM;IACN,QAAQ;QACP,IAAI;YACH,OAAO;gBAAI,IAAI;;YACf,WAAW;YACX,OAAO;;;IAGT,IAAI;QACH,IAAI;;CAEL,CAAC;AAEF,eAAO,MAAM,gBAAgB,mCAsC5B,CAAC"}
1
+ {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;;IAkB1D,KAAK;IACL,SAAS;;;AAuRV,QAAA,MAAM,kBAAkB,aAAe;IAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;CAAE,gCA4CnE,CAAC;AAEF,eAAO,MAAM,gBAAgB;IAC5B,MAAM;IACN,QAAQ;QACP,IAAI;YACH,OAAO;gBAAI,IAAI;;YACf,WAAW;YACX,OAAO;;;IAGT,IAAI;QACH,IAAI;;CAEL,CAAC;AAEF,eAAO,MAAM,gBAAgB,mCAsC5B,CAAC"}
@@ -1,6 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import type { Attachment, Updatable, Post, User } from '@wordpress/core-data';
5
2
  export type MediaKind = 'image' | 'video' | 'audio' | 'application';
6
3
  export interface MediaType {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE9E,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;AAEpE,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;CACxB;AAGD,MAAM,WAAW,SAAU,SAAQ,UAAU,CAAE,MAAM,CAAE;IAEtD,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE;QAEX,gBAAgB,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAE,IAAI,CAAE,EAAE,CAAC;QAC9C,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAE,IAAI,CAAE,EAAE,CAAC;KACpC,CAAC;CACF;AAED,MAAM,MAAM,kBAAkB,GAAG,SAAS,CAAE,UAAU,CAAE,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE9E,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;AAEpE,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;CACxB;AAGD,MAAM,WAAW,SAAU,SAAQ,UAAU,CAAE,MAAM,CAAE;IAEtD,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE;QAEX,gBAAgB,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAE,IAAI,CAAE,EAAE,CAAC;QAC9C,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAE,IAAI,CAAE,EAAE,CAAC;KACpC,CAAC;CACF;AAED,MAAM,MAAM,kBAAkB,GAAG,SAAS,CAAE,UAAU,CAAE,CAAC"}
@@ -1,6 +1,3 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  import type { MediaType } from '../types';
5
2
  /**
6
3
  * Get the media type from a mime type, including an icon.
@@ -1 +1 @@
1
- {"version":3,"file":"get-media-type-from-mime-type.d.ts","sourceRoot":"","sources":["../../src/utils/get-media-type-from-mime-type.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAE,QAAQ,EAAE,MAAM,GAAI,SAAS,CA8BtE"}
1
+ {"version":3,"file":"get-media-type-from-mime-type.d.ts","sourceRoot":"","sources":["../../src/utils/get-media-type-from-mime-type.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAE,QAAQ,EAAE,MAAM,GAAI,SAAS,CA8BtE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/media-fields",
3
- "version": "0.17.0",
3
+ "version": "0.18.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,19 +48,19 @@
48
48
  "src/**/*.scss"
49
49
  ],
50
50
  "dependencies": {
51
- "@wordpress/base-styles": "^12.0.0",
52
- "@wordpress/components": "^38.0.0",
53
- "@wordpress/compose": "^8.5.0",
54
- "@wordpress/core-data": "^7.52.0",
55
- "@wordpress/data": "^10.52.0",
56
- "@wordpress/dataviews": "^17.3.0",
57
- "@wordpress/date": "^5.52.0",
58
- "@wordpress/element": "^8.4.0",
59
- "@wordpress/i18n": "^6.25.0",
60
- "@wordpress/icons": "^15.3.0",
61
- "@wordpress/primitives": "^4.52.0",
62
- "@wordpress/ui": "^0.19.0",
63
- "@wordpress/url": "^4.52.0",
51
+ "@wordpress/base-styles": "^12.1.0",
52
+ "@wordpress/components": "^39.0.0",
53
+ "@wordpress/compose": "^8.6.0",
54
+ "@wordpress/core-data": "^7.53.0",
55
+ "@wordpress/data": "^10.53.0",
56
+ "@wordpress/dataviews": "^18.0.0",
57
+ "@wordpress/date": "^5.53.0",
58
+ "@wordpress/element": "^8.5.0",
59
+ "@wordpress/i18n": "^6.26.0",
60
+ "@wordpress/icons": "^15.4.0",
61
+ "@wordpress/primitives": "^4.53.0",
62
+ "@wordpress/ui": "^0.20.0",
63
+ "@wordpress/url": "^4.53.0",
64
64
  "clsx": "^2.1.1"
65
65
  },
66
66
  "devDependencies": {
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "7e8b17a983f9391d3ebc7717af2a1c9ed7efc7ab"
84
+ "gitHead": "989764d42ff93e33684aaf0b96a5b7f3d9bbff52"
85
85
  }
@@ -1,6 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import { TextareaControl } from '@wordpress/components';
6
3
  import { Link } from '@wordpress/ui';
@@ -1,20 +1,13 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import {
5
2
  __experimentalFetchLinkSuggestions as fetchLinkSuggestions,
6
3
  store as coreStore,
7
4
  } from '@wordpress/core-data';
8
- import { Button, ComboboxControl } from '@wordpress/components';
5
+ import { ComboboxControl } from '@wordpress/components';
9
6
  import { __ } from '@wordpress/i18n';
10
- import { useState, createInterpolateElement } from '@wordpress/element';
11
- import { debounce } from '@wordpress/compose';
7
+ import { useState } from '@wordpress/element';
8
+ import { useDebounce, useEvent } from '@wordpress/compose';
12
9
  import { useSelect } from '@wordpress/data';
13
10
  import type { DataFormControlProps } from '@wordpress/dataviews';
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
11
  import type { MediaItem } from '../types';
19
12
  import { getRenderedContent } from '../utils/get-rendered-content';
20
13
 
@@ -76,7 +69,6 @@ export default function MediaAttachedToEdit( {
76
69
  _embedded: { ...data?._embedded, 'wp:attached-to': undefined },
77
70
  } );
78
71
  setValue( null );
79
- setOptions( [] );
80
72
  };
81
73
 
82
74
  const onValueChange = async ( filterValue: string ) => {
@@ -104,6 +96,12 @@ export default function MediaAttachedToEdit( {
104
96
  setIsLoading( false );
105
97
  };
106
98
 
99
+ // `onValueChange` closes over state, so it's wrapped in `useEvent` to give
100
+ // `useDebounce` a stable function. Debouncing an inline function instead
101
+ // rebuilds the timer on every render, so nothing is debounced and each
102
+ // keystroke fires its own request.
103
+ const debouncedValueChange = useDebounce( useEvent( onValueChange ), 300 );
104
+
107
105
  /**
108
106
  * Handle selection.
109
107
  *
@@ -150,38 +148,22 @@ export default function MediaAttachedToEdit( {
150
148
  }
151
149
  };
152
150
 
153
- const help = createInterpolateElement(
154
- __(
155
- 'Search for a post or page to attach this media to or <button>detach current</button>.'
156
- ),
157
- {
158
- button: (
159
- <Button
160
- __next40pxDefaultSize
161
- onClick={ handleDetach }
162
- variant="link"
163
- accessibleWhenDisabled
164
- disabled={ ! value }
165
- />
166
- ),
167
- }
168
- );
169
-
170
151
  return (
171
152
  <ComboboxControl
172
153
  className="dataviews-media-field__attached-to"
173
154
  isLoading={ isLoading }
174
155
  label={ __( 'Attached to' ) }
175
- help={ help }
156
+ help={ __( 'Attach this file to a single post or page.' ) }
176
157
  value={ value }
177
158
  options={ options }
178
- onFilterValueChange={ debounce(
179
- ( filterValue: unknown ) =>
180
- onValueChange( filterValue as string ),
181
- 300
182
- ) }
159
+ onFilterValueChange={ ( filterValue: unknown ) =>
160
+ debouncedValueChange( filterValue as string )
161
+ }
183
162
  onChange={ handleSelectOption }
184
163
  hideLabelFromVision
164
+ // Opening the panel shouldn't imply the user has decided to change
165
+ // the attachment, so wait for them to search before showing the list.
166
+ expandOnFocus={ false }
185
167
  />
186
168
  );
187
169
  }
@@ -1,12 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import type { Field } from '@wordpress/dataviews';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
3
  import type { MediaItem } from '../types';
11
4
  import MediaAttachedToView from './view';
12
5
  import MediaAttachedToEdit from './edit';
@@ -0,0 +1,36 @@
1
+ @use "@wordpress/base-styles/variables" as *;
2
+
3
+ // Height of the suggestion list: three rows, the most `fetchLinkSuggestions`
4
+ // returns while it is called with `isInitialSuggestions` (see the @TODO in
5
+ // edit.tsx).
6
+ $suggestions-height: $button-size-compact * 3;
7
+
8
+ // When this field is edited from a DataForm panel it renders inside a popover
9
+ // that floating-ui measures and places when it opens. `ComboboxControl` renders
10
+ // its suggestions inline, so they arrive after that measurement: the popover
11
+ // can't grow, and the list ends up scrolling inside a box too small to scroll
12
+ // comfortably — worst low on screen, where the space is smallest.
13
+ //
14
+ // See https://github.com/WordPress/gutenberg/issues/81122.
15
+ .components-popover__content:has(.dataviews-media-field__attached-to) {
16
+ // Reserve the space the suggestions will need before they exist. The popover
17
+ // is absolutely positioned, so it contains this margin rather than collapsing
18
+ // it, and floating-ui measures the reserved height when it decides which way
19
+ // to open — and caps the popover's height against it too, so the cap already
20
+ // allows for the suggestions. The margin is transparent, so nothing is
21
+ // visibly reserved.
22
+ margin-bottom: $suggestions-height;
23
+
24
+ // Once the suggestions are there they occupy that space instead, so the
25
+ // popover's total height is unchanged and it has no reason to move.
26
+ &:has(.components-form-token-field__suggestions-list) {
27
+ margin-bottom: 0;
28
+ }
29
+
30
+ // Hold the list at the reserved height rather than letting it grow and shrink
31
+ // with the number of matches, which would resize the popover as you type.
32
+ .components-form-token-field__suggestions-list {
33
+ height: $suggestions-height;
34
+ max-height: none;
35
+ }
36
+ }
@@ -1,16 +1,5 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import { render, screen } from '@testing-library/react';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
2
  import type { NormalizedField } from '@wordpress/dataviews';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
3
  import MediaAttachedToView from '../view';
15
4
  import type { MediaItem } from '../../types';
16
5
 
@@ -1,12 +1,6 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { useState, useEffect } from '@wordpress/element';
5
2
  import { __ } from '@wordpress/i18n';
6
3
  import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
7
- /**
8
- * Internal dependencies
9
- */
10
4
  import type { MediaItem } from '../types';
11
5
  import { getRenderedContent } from '../utils/get-rendered-content';
12
6
 
@@ -1,14 +1,7 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import type { Field } from '@wordpress/dataviews';
5
2
  import { __ } from '@wordpress/i18n';
6
3
  import { resolveSelect } from '@wordpress/data';
7
4
  import { store as coreDataStore } from '@wordpress/core-data';
8
-
9
- /**
10
- * Internal dependencies
11
- */
12
5
  import type { MediaItem } from '../types';
13
6
  import AuthorView from './view';
14
7
 
@@ -1,11 +1,4 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import clsx from 'clsx';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
2
  import { __ } from '@wordpress/i18n';
10
3
  import { useState, useCallback, useEffect } from '@wordpress/element';
11
4
  import { commentAuthorAvatar as authorIcon } from '@wordpress/icons';
@@ -14,10 +7,6 @@ import {
14
7
  Icon as WCIcon,
15
8
  } from '@wordpress/components';
16
9
  import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
17
-
18
- /**
19
- * Internal dependencies
20
- */
21
10
  import type { MediaItem } from '../types';
22
11
 
23
12
  export default function AuthorView( {
@@ -1,14 +1,7 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import { TextareaControl } from '@wordpress/components';
6
3
  import type { Attachment, Updatable } from '@wordpress/core-data';
7
4
  import type { Field } from '@wordpress/dataviews';
8
-
9
- /**
10
- * Internal dependencies
11
- */
12
5
  import { getRawContent } from '../utils/get-raw-content';
13
6
 
14
7
  const captionField: Partial< Field< Updatable< Attachment > > > = {
@@ -1,12 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import type { Field } from '@wordpress/dataviews';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
3
  import type { MediaItem } from '../types';
11
4
 
12
5
  const dateAddedField: Partial< Field< MediaItem > > = {
@@ -1,12 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import type { Field } from '@wordpress/dataviews';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
3
  import type { MediaItem } from '../types';
11
4
 
12
5
  const dateModifiedField: Partial< Field< MediaItem > > = {
@@ -1,14 +1,7 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import { TextareaControl } from '@wordpress/components';
6
3
  import type { Attachment, Updatable } from '@wordpress/core-data';
7
4
  import type { Field } from '@wordpress/dataviews';
8
-
9
- /**
10
- * Internal dependencies
11
- */
12
5
  import { getRawContent } from '../utils/get-raw-content';
13
6
 
14
7
  const descriptionField: Partial< Field< Updatable< Attachment > > > = {
@@ -1,13 +1,6 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import { getFilename } from '@wordpress/url';
6
3
  import type { Field } from '@wordpress/dataviews';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
4
  import type { MediaItem } from '../types';
12
5
  import FileNameView from './view';
13
6
 
@@ -1,6 +1,3 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  import filenameField from '../index';
5
2
  import type { MediaItem } from '../../types';
6
3
 
@@ -1,16 +1,5 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import { render, screen } from '@testing-library/react';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
2
  import type { NormalizedField } from '@wordpress/dataviews';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
3
  import FileNameView from '../view';
15
4
  import filenameField from '../index';
16
5
  import type { MediaItem } from '../../types';
@@ -1,14 +1,7 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { useMemo } from '@wordpress/element';
5
2
  import { getFilename } from '@wordpress/url';
6
3
  import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
7
4
  import { Tooltip } from '@wordpress/ui';
8
-
9
- /**
10
- * Internal dependencies
11
- */
12
5
  import type { MediaItem } from '../types';
13
6
 
14
7
  // Proxy threshold for "long enough that the cell will visually truncate" —
@@ -1,12 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __, sprintf, _x } from '@wordpress/i18n';
5
2
  import type { Field } from '@wordpress/dataviews';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
3
  import type { MediaItem } from '../types';
11
4
 
12
5
  const KB_IN_BYTES = 1024;
@@ -1,6 +1,3 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  import filesizeField from '../index';
5
2
  import type { MediaItem } from '../../types';
6
3
 
@@ -1,6 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __, _x, sprintf } from '@wordpress/i18n';
5
2
  import type { Attachment, Updatable } from '@wordpress/core-data';
6
3
  import type { Field } from '@wordpress/dataviews';
@@ -1,11 +1,4 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import type { Attachment, Updatable } from '@wordpress/core-data';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
2
  import mediaDimensionsField from '../index';
10
3
 
11
4
  describe( 'mediaDimensionsField', () => {
@@ -1,12 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import type { Field } from '@wordpress/dataviews';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
3
  import type { MediaItem } from '../types';
11
4
  import MediaThumbnailView from './view';
12
5
 
@@ -1,6 +1,3 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  import { getBestImageUrl } from '../view';
5
2
 
6
3
  type Media = Parameters< typeof getBestImageUrl >[ 0 ];
@@ -1,11 +1,4 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import clsx from 'clsx';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
2
  import { useSelect } from '@wordpress/data';
10
3
  import { store as coreStore } from '@wordpress/core-data';
11
4
  import {
@@ -17,9 +10,6 @@ import { useState, useRef, useLayoutEffect } from '@wordpress/element';
17
10
  import type { Attachment } from '@wordpress/core-data';
18
11
  import { getFilename } from '@wordpress/url';
19
12
  import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
20
- /**
21
- * Internal dependencies
22
- */
23
13
  import { getMediaTypeFromMimeType } from '../utils/get-media-type-from-mime-type';
24
14
  import type { MediaItem } from '../types';
25
15
 
@@ -1,6 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import type { Attachment, Updatable } from '@wordpress/core-data';
6
3
  import type { Field } from '@wordpress/dataviews';
@@ -1,13 +1,6 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { useState } from '@wordpress/element';
5
2
  import type { Field, View, Form } from '@wordpress/dataviews';
6
3
  import { DataForm, DataViews } from '@wordpress/dataviews';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
4
  import {
12
5
  altTextField,
13
6
  attachedToField,
package/src/style.scss CHANGED
@@ -1,3 +1,4 @@
1
+ @use "./attached_to/style.scss" as *;
1
2
  @use "./author/style.scss" as *;
2
3
  @use "./filename/style.scss" as *;
3
4
  @use "./media_thumbnail/style.scss" as *;
package/src/types.ts CHANGED
@@ -1,6 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import type { Attachment, Updatable, Post, User } from '@wordpress/core-data';
5
2
 
6
3
  export type MediaKind = 'image' | 'video' | 'audio' | 'application';
@@ -1,12 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
2
  import { audio, video, image, file } from '@wordpress/icons';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
3
  import type { MediaType } from '../types';
11
4
 
12
5
  /**