@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.
- package/CHANGELOG.md +12 -0
- package/build/alt_text/index.cjs.map +3 -3
- package/build/attached_to/edit.cjs +5 -24
- package/build/attached_to/edit.cjs.map +2 -2
- package/build/attached_to/index.cjs.map +2 -2
- package/build/attached_to/view.cjs.map +2 -2
- package/build/author/index.cjs.map +2 -2
- package/build/author/view.cjs.map +2 -2
- package/build/caption/index.cjs.map +3 -3
- package/build/date_added/index.cjs.map +2 -2
- package/build/date_modified/index.cjs.map +2 -2
- package/build/description/index.cjs.map +3 -3
- package/build/filename/index.cjs.map +2 -2
- package/build/filename/view.cjs.map +2 -2
- package/build/filesize/index.cjs.map +2 -2
- package/build/media_dimensions/index.cjs.map +2 -2
- package/build/media_thumbnail/index.cjs.map +2 -2
- package/build/media_thumbnail/view.cjs.map +2 -2
- package/build/mime_type/index.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build/utils/get-media-type-from-mime-type.cjs.map +2 -2
- package/build-module/alt_text/index.mjs +2 -2
- package/build-module/alt_text/index.mjs.map +2 -2
- package/build-module/attached_to/edit.mjs +8 -27
- package/build-module/attached_to/edit.mjs.map +2 -2
- package/build-module/attached_to/index.mjs.map +2 -2
- package/build-module/attached_to/view.mjs.map +2 -2
- package/build-module/author/index.mjs.map +2 -2
- package/build-module/author/view.mjs.map +2 -2
- package/build-module/caption/index.mjs +2 -2
- package/build-module/caption/index.mjs.map +2 -2
- package/build-module/date_added/index.mjs.map +2 -2
- package/build-module/date_modified/index.mjs.map +2 -2
- package/build-module/description/index.mjs +2 -2
- package/build-module/description/index.mjs.map +2 -2
- package/build-module/filename/index.mjs.map +2 -2
- package/build-module/filename/view.mjs.map +2 -2
- package/build-module/filesize/index.mjs.map +2 -2
- package/build-module/media_dimensions/index.mjs.map +2 -2
- package/build-module/media_thumbnail/index.mjs.map +2 -2
- package/build-module/media_thumbnail/view.mjs.map +2 -2
- package/build-module/mime_type/index.mjs.map +2 -2
- package/build-module/utils/get-media-type-from-mime-type.mjs.map +2 -2
- package/build-style/style-rtl.css +14 -3
- package/build-style/style.css +14 -3
- package/build-types/alt_text/index.d.ts.map +1 -1
- package/build-types/attached_to/edit.d.ts +0 -3
- package/build-types/attached_to/edit.d.ts.map +1 -1
- package/build-types/attached_to/index.d.ts +0 -3
- package/build-types/attached_to/index.d.ts.map +1 -1
- package/build-types/attached_to/view.d.ts +0 -3
- package/build-types/attached_to/view.d.ts.map +1 -1
- package/build-types/author/index.d.ts +0 -6
- package/build-types/author/index.d.ts.map +1 -1
- package/build-types/author/view.d.ts +0 -3
- package/build-types/author/view.d.ts.map +1 -1
- package/build-types/caption/index.d.ts.map +1 -1
- package/build-types/date_added/index.d.ts +0 -3
- package/build-types/date_added/index.d.ts.map +1 -1
- package/build-types/date_modified/index.d.ts +0 -3
- package/build-types/date_modified/index.d.ts.map +1 -1
- package/build-types/description/index.d.ts.map +1 -1
- package/build-types/filename/index.d.ts +0 -3
- package/build-types/filename/index.d.ts.map +1 -1
- package/build-types/filename/view.d.ts +0 -3
- package/build-types/filename/view.d.ts.map +1 -1
- package/build-types/filesize/index.d.ts +0 -3
- package/build-types/filesize/index.d.ts.map +1 -1
- package/build-types/media_dimensions/index.d.ts.map +1 -1
- package/build-types/media_thumbnail/index.d.ts +0 -3
- package/build-types/media_thumbnail/index.d.ts.map +1 -1
- package/build-types/media_thumbnail/view.d.ts.map +1 -1
- package/build-types/mime_type/index.d.ts.map +1 -1
- package/build-types/types.d.ts +0 -3
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/get-media-type-from-mime-type.d.ts +0 -3
- package/build-types/utils/get-media-type-from-mime-type.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/alt_text/index.tsx +2 -5
- package/src/attached_to/edit.tsx +17 -37
- package/src/attached_to/index.tsx +0 -7
- package/src/attached_to/style.scss +36 -0
- package/src/attached_to/test/view.test.tsx +0 -11
- package/src/attached_to/view.tsx +0 -6
- package/src/author/index.tsx +0 -7
- package/src/author/view.tsx +0 -11
- package/src/caption/index.tsx +2 -9
- package/src/date_added/index.tsx +0 -7
- package/src/date_modified/index.tsx +0 -7
- package/src/description/index.tsx +2 -9
- package/src/filename/index.ts +0 -7
- package/src/filename/test/index.test.ts +0 -3
- package/src/filename/test/view.test.tsx +0 -11
- package/src/filename/view.tsx +0 -7
- package/src/filesize/index.tsx +0 -7
- package/src/filesize/test/index.test.tsx +0 -3
- package/src/media_dimensions/index.ts +0 -3
- package/src/media_dimensions/test/index.test.ts +0 -7
- package/src/media_thumbnail/index.tsx +0 -7
- package/src/media_thumbnail/test/get-best-image-url.test.ts +0 -3
- package/src/media_thumbnail/view.tsx +0 -10
- package/src/mime_type/index.ts +0 -3
- package/src/stories/index.story.tsx +6 -7
- package/src/style.scss +1 -0
- package/src/types.ts +0 -3
- package/src/utils/get-media-type-from-mime-type.ts +0 -7
- package/build-types/attached_to/test/view.test.d.ts +0 -2
- package/build-types/attached_to/test/view.test.d.ts.map +0 -1
- package/build-types/filename/test/index.test.d.ts +0 -2
- package/build-types/filename/test/index.test.d.ts.map +0 -1
- package/build-types/filename/test/view.test.d.ts +0 -2
- package/build-types/filename/test/view.test.d.ts.map +0 -1
- package/build-types/filesize/test/index.test.d.ts +0 -2
- package/build-types/filesize/test/index.test.d.ts.map +0 -1
- package/build-types/media_dimensions/test/index.test.d.ts +0 -2
- package/build-types/media_dimensions/test/index.test.d.ts.map +0 -1
- package/build-types/media_thumbnail/test/get-best-image-url.test.d.ts +0 -2
- package/build-types/media_thumbnail/test/get-best-image-url.test.d.ts.map +0 -1
- package/build-types/stories/index.story.d.ts +0 -26
- package/build-types/stories/index.story.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filename/index.ts"],"names":[],"mappings":"
|
|
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":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filesize/index.tsx"],"names":[],"mappings":"
|
|
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":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media_thumbnail/index.tsx"],"names":[],"mappings":"
|
|
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":"
|
|
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":"
|
|
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"}
|
package/build-types/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
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 +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":"
|
|
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.
|
|
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": "^
|
|
52
|
-
"@wordpress/components": "^
|
|
53
|
-
"@wordpress/compose": "^8.
|
|
54
|
-
"@wordpress/core-data": "^7.
|
|
55
|
-
"@wordpress/data": "^10.
|
|
56
|
-
"@wordpress/dataviews": "^
|
|
57
|
-
"@wordpress/date": "^5.
|
|
58
|
-
"@wordpress/element": "^8.
|
|
59
|
-
"@wordpress/i18n": "^6.
|
|
60
|
-
"@wordpress/icons": "^15.
|
|
61
|
-
"@wordpress/primitives": "^4.
|
|
62
|
-
"@wordpress/ui": "^0.
|
|
63
|
-
"@wordpress/url": "^4.
|
|
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": "
|
|
84
|
+
"gitHead": "5ef24f60261976bb198ad035db24bf81c1fb92b4"
|
|
85
85
|
}
|
package/src/alt_text/index.tsx
CHANGED
|
@@ -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
|
-
<
|
|
15
|
+
<WCTextareaControl
|
|
19
16
|
label={ field.label }
|
|
20
17
|
value={ data.alt_text || '' }
|
|
21
18
|
onChange={ ( value ) => onChange( { alt_text: value } ) }
|
package/src/attached_to/edit.tsx
CHANGED
|
@@ -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 {
|
|
5
|
+
import { ComboboxControl } from '@wordpress/components';
|
|
9
6
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { useState
|
|
11
|
-
import {
|
|
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={
|
|
154
|
+
help={ __( 'Attach this file to a single post or page.' ) }
|
|
176
155
|
value={ value }
|
|
177
156
|
options={ options }
|
|
178
|
-
onFilterValueChange={
|
|
179
|
-
( filterValue
|
|
180
|
-
|
|
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
|
|
package/src/attached_to/view.tsx
CHANGED
|
@@ -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
|
|
package/src/author/index.tsx
CHANGED
|
@@ -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
|
|
package/src/author/view.tsx
CHANGED
|
@@ -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( {
|
package/src/caption/index.tsx
CHANGED
|
@@ -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
|
-
<
|
|
15
|
+
<WCTextareaControl
|
|
23
16
|
label={ field.label }
|
|
24
17
|
value={ getRawContent( data.caption ) || '' }
|
|
25
18
|
onChange={ ( value ) => onChange( { caption: value } ) }
|
package/src/date_added/index.tsx
CHANGED
|
@@ -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
|
-
<
|
|
17
|
+
<WCTextareaControl
|
|
25
18
|
label={ field.label }
|
|
26
19
|
value={ getRawContent( data.description ) || '' }
|
|
27
20
|
onChange={ ( value ) => onChange( { description: value } ) }
|
package/src/filename/index.ts
CHANGED
|
@@ -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,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';
|
package/src/filename/view.tsx
CHANGED
|
@@ -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" —
|
package/src/filesize/index.tsx
CHANGED
|
@@ -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,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,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
|
|
package/src/mime_type/index.ts
CHANGED
|
@@ -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
|
+
};
|