@wordpress/media-fields 0.17.0 → 0.19.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 (120) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/alt_text/index.cjs.map +3 -3
  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 +3 -3
  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 +3 -3
  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 +2 -2
  23. package/build-module/alt_text/index.mjs.map +2 -2
  24. package/build-module/attached_to/edit.mjs +8 -27
  25. package/build-module/attached_to/edit.mjs.map +2 -2
  26. package/build-module/attached_to/index.mjs.map +2 -2
  27. package/build-module/attached_to/view.mjs.map +2 -2
  28. package/build-module/author/index.mjs.map +2 -2
  29. package/build-module/author/view.mjs.map +2 -2
  30. package/build-module/caption/index.mjs +2 -2
  31. package/build-module/caption/index.mjs.map +2 -2
  32. package/build-module/date_added/index.mjs.map +2 -2
  33. package/build-module/date_modified/index.mjs.map +2 -2
  34. package/build-module/description/index.mjs +2 -2
  35. package/build-module/description/index.mjs.map +2 -2
  36. package/build-module/filename/index.mjs.map +2 -2
  37. package/build-module/filename/view.mjs.map +2 -2
  38. package/build-module/filesize/index.mjs.map +2 -2
  39. package/build-module/media_dimensions/index.mjs.map +2 -2
  40. package/build-module/media_thumbnail/index.mjs.map +2 -2
  41. package/build-module/media_thumbnail/view.mjs.map +2 -2
  42. package/build-module/mime_type/index.mjs.map +2 -2
  43. package/build-module/utils/get-media-type-from-mime-type.mjs.map +2 -2
  44. package/build-style/style-rtl.css +14 -3
  45. package/build-style/style.css +14 -3
  46. package/build-types/alt_text/index.d.ts.map +1 -1
  47. package/build-types/attached_to/edit.d.ts +0 -3
  48. package/build-types/attached_to/edit.d.ts.map +1 -1
  49. package/build-types/attached_to/index.d.ts +0 -3
  50. package/build-types/attached_to/index.d.ts.map +1 -1
  51. package/build-types/attached_to/view.d.ts +0 -3
  52. package/build-types/attached_to/view.d.ts.map +1 -1
  53. package/build-types/author/index.d.ts +0 -6
  54. package/build-types/author/index.d.ts.map +1 -1
  55. package/build-types/author/view.d.ts +0 -3
  56. package/build-types/author/view.d.ts.map +1 -1
  57. package/build-types/caption/index.d.ts.map +1 -1
  58. package/build-types/date_added/index.d.ts +0 -3
  59. package/build-types/date_added/index.d.ts.map +1 -1
  60. package/build-types/date_modified/index.d.ts +0 -3
  61. package/build-types/date_modified/index.d.ts.map +1 -1
  62. package/build-types/description/index.d.ts.map +1 -1
  63. package/build-types/filename/index.d.ts +0 -3
  64. package/build-types/filename/index.d.ts.map +1 -1
  65. package/build-types/filename/view.d.ts +0 -3
  66. package/build-types/filename/view.d.ts.map +1 -1
  67. package/build-types/filesize/index.d.ts +0 -3
  68. package/build-types/filesize/index.d.ts.map +1 -1
  69. package/build-types/media_dimensions/index.d.ts.map +1 -1
  70. package/build-types/media_thumbnail/index.d.ts +0 -3
  71. package/build-types/media_thumbnail/index.d.ts.map +1 -1
  72. package/build-types/media_thumbnail/view.d.ts.map +1 -1
  73. package/build-types/mime_type/index.d.ts.map +1 -1
  74. package/build-types/types.d.ts +0 -3
  75. package/build-types/types.d.ts.map +1 -1
  76. package/build-types/utils/get-media-type-from-mime-type.d.ts +0 -3
  77. package/build-types/utils/get-media-type-from-mime-type.d.ts.map +1 -1
  78. package/package.json +15 -15
  79. package/src/alt_text/index.tsx +2 -5
  80. package/src/attached_to/edit.tsx +17 -37
  81. package/src/attached_to/index.tsx +0 -7
  82. package/src/attached_to/style.scss +36 -0
  83. package/src/attached_to/test/view.test.tsx +0 -11
  84. package/src/attached_to/view.tsx +0 -6
  85. package/src/author/index.tsx +0 -7
  86. package/src/author/view.tsx +0 -11
  87. package/src/caption/index.tsx +2 -9
  88. package/src/date_added/index.tsx +0 -7
  89. package/src/date_modified/index.tsx +0 -7
  90. package/src/description/index.tsx +2 -9
  91. package/src/filename/index.ts +0 -7
  92. package/src/filename/test/index.test.ts +0 -3
  93. package/src/filename/test/view.test.tsx +0 -11
  94. package/src/filename/view.tsx +0 -7
  95. package/src/filesize/index.tsx +0 -7
  96. package/src/filesize/test/index.test.tsx +0 -3
  97. package/src/media_dimensions/index.ts +0 -3
  98. package/src/media_dimensions/test/index.test.ts +0 -7
  99. package/src/media_thumbnail/index.tsx +0 -7
  100. package/src/media_thumbnail/test/get-best-image-url.test.ts +0 -3
  101. package/src/media_thumbnail/view.tsx +0 -10
  102. package/src/mime_type/index.ts +0 -3
  103. package/src/stories/index.story.tsx +6 -7
  104. package/src/style.scss +1 -0
  105. package/src/types.ts +0 -3
  106. package/src/utils/get-media-type-from-mime-type.ts +0 -7
  107. package/build-types/attached_to/test/view.test.d.ts +0 -2
  108. package/build-types/attached_to/test/view.test.d.ts.map +0 -1
  109. package/build-types/filename/test/index.test.d.ts +0 -2
  110. package/build-types/filename/test/index.test.d.ts.map +0 -1
  111. package/build-types/filename/test/view.test.d.ts +0 -2
  112. package/build-types/filename/test/view.test.d.ts.map +0 -1
  113. package/build-types/filesize/test/index.test.d.ts +0 -2
  114. package/build-types/filesize/test/index.test.d.ts.map +0 -1
  115. package/build-types/media_dimensions/test/index.test.d.ts +0 -2
  116. package/build-types/media_dimensions/test/index.test.d.ts.map +0 -1
  117. package/build-types/media_thumbnail/test/get-best-image-url.test.d.ts +0 -2
  118. package/build-types/media_thumbnail/test/get-best-image-url.test.d.ts.map +0 -1
  119. package/build-types/stories/index.story.d.ts +0 -26
  120. package/build-types/stories/index.story.d.ts.map +0 -1
@@ -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 filenameField: Partial<Field<MediaItem>>;
7
4
  export default filenameField;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filename/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,QAAA,MAAM,aAAa,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAU/C,CAAC;eAEa,aAAa"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filename/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,QAAA,MAAM,aAAa,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAU/C,CAAC;eAEa,aAAa"}
@@ -1,7 +1,4 @@
1
1
  import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
2
- /**
3
- * Internal dependencies
4
- */
5
2
  import type { MediaItem } from '../types';
6
3
  export default function FileNameView({ item, }: DataViewRenderFieldProps<MediaItem>): "" | import("react").JSX.Element;
7
4
  //# sourceMappingURL=view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/filename/view.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAO1C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,EACrC,IAAI,GACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,oCAkCvC"}
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/filename/view.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAO1C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,EACrC,IAAI,GACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,oCAkCvC"}
@@ -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 filesizeField: Partial<Field<MediaItem>>;
7
4
  export default filesizeField;
@@ -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,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.19.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": "^13.0.0",
52
+ "@wordpress/components": "^40.0.0",
53
+ "@wordpress/compose": "^8.7.0",
54
+ "@wordpress/core-data": "^7.54.0",
55
+ "@wordpress/data": "^10.54.0",
56
+ "@wordpress/dataviews": "^18.1.0",
57
+ "@wordpress/date": "^5.54.0",
58
+ "@wordpress/element": "^8.6.0",
59
+ "@wordpress/i18n": "^6.27.0",
60
+ "@wordpress/icons": "^15.5.0",
61
+ "@wordpress/primitives": "^4.54.0",
62
+ "@wordpress/ui": "^0.21.0",
63
+ "@wordpress/url": "^4.54.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": "5ef24f60261976bb198ad035db24bf81c1fb92b4"
85
85
  }
@@ -1,8 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { __ } from '@wordpress/i18n';
5
- import { TextareaControl } from '@wordpress/components';
2
+ import { TextareaControl as WCTextareaControl } from '@wordpress/components';
6
3
  import { Link } from '@wordpress/ui';
7
4
  import type { Field } from '@wordpress/dataviews';
8
5
  import type { Attachment, Updatable } from '@wordpress/core-data';
@@ -15,7 +12,7 @@ const altTextField: Partial< Field< Updatable< Attachment > > > = {
15
12
  render: ( { item } ) => item?.alt_text || '-',
16
13
  Edit: ( { field, onChange, data } ) => {
17
14
  return (
18
- <TextareaControl
15
+ <WCTextareaControl
19
16
  label={ field.label }
20
17
  value={ data.alt_text || '' }
21
18
  onChange={ ( value ) => onChange( { alt_text: value } ) }
@@ -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,14 +96,18 @@ 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
  *
110
108
  * @param {Object} selectedPostId The selected post id.
111
109
  */
112
- const handleSelectOption = (
113
- selectedPostId: string | null | undefined
114
- ) => {
110
+ const handleSelectOption = ( selectedPostId: string | null ) => {
115
111
  if ( ! selectedPostId ) {
116
112
  handleDetach();
117
113
  return;
@@ -150,38 +146,22 @@ export default function MediaAttachedToEdit( {
150
146
  }
151
147
  };
152
148
 
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
149
  return (
171
150
  <ComboboxControl
172
151
  className="dataviews-media-field__attached-to"
173
152
  isLoading={ isLoading }
174
153
  label={ __( 'Attached to' ) }
175
- help={ help }
154
+ help={ __( 'Attach this file to a single post or page.' ) }
176
155
  value={ value }
177
156
  options={ options }
178
- onFilterValueChange={ debounce(
179
- ( filterValue: unknown ) =>
180
- onValueChange( filterValue as string ),
181
- 300
182
- ) }
157
+ onFilterValueChange={ ( filterValue: unknown ) =>
158
+ debouncedValueChange( filterValue as string )
159
+ }
183
160
  onChange={ handleSelectOption }
184
161
  hideLabelFromVision
162
+ // Opening the panel shouldn't imply the user has decided to change
163
+ // the attachment, so wait for them to search before showing the list.
164
+ expandOnFocus={ false }
185
165
  />
186
166
  );
187
167
  }
@@ -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
- import { TextareaControl } from '@wordpress/components';
2
+ import { TextareaControl as WCTextareaControl } 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 > > > = {
@@ -19,7 +12,7 @@ const captionField: Partial< Field< Updatable< Attachment > > > = {
19
12
  render: ( { item } ) => getRawContent( item?.caption ) || '-',
20
13
  Edit: ( { field, onChange, data } ) => {
21
14
  return (
22
- <TextareaControl
15
+ <WCTextareaControl
23
16
  label={ field.label }
24
17
  value={ getRawContent( data.caption ) || '' }
25
18
  onChange={ ( value ) => onChange( { caption: value } ) }
@@ -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
- import { TextareaControl } from '@wordpress/components';
2
+ import { TextareaControl as WCTextareaControl } 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 > > > = {
@@ -21,7 +14,7 @@ const descriptionField: Partial< Field< Updatable< Attachment > > > = {
21
14
  ),
22
15
  Edit: ( { field, onChange, data } ) => {
23
16
  return (
24
- <TextareaControl
17
+ <WCTextareaControl
25
18
  label={ field.label }
26
19
  value={ getRawContent( data.description ) || '' }
27
20
  onChange={ ( value ) => onChange( { description: value } ) }
@@ -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,
@@ -404,3 +397,9 @@ export const DataViewsPreview = () => {
404
397
  </div>
405
398
  );
406
399
  };
400
+
401
+ DataViewsPreview.parameters = {
402
+ // FIXME: Preview table has an empty column header (empty-table-header).
403
+ // See: https://github.com/WordPress/gutenberg/issues/81596
404
+ a11y: { test: 'todo' },
405
+ };