@wordpress/media-fields 0.10.0 → 0.10.1-next.v.202605131032.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/build/attached_to/view.cjs +1 -1
- package/build/attached_to/view.cjs.map +2 -2
- package/build-module/attached_to/view.mjs +1 -1
- package/build-module/attached_to/view.mjs.map +2 -2
- package/build-types/alt_text/index.d.ts.map +1 -1
- package/build-types/attached_to/edit.d.ts +1 -1
- package/build-types/attached_to/edit.d.ts.map +1 -1
- package/build-types/attached_to/index.d.ts.map +1 -1
- package/build-types/attached_to/test/view.test.d.ts +2 -0
- package/build-types/attached_to/test/view.test.d.ts.map +1 -0
- package/build-types/attached_to/view.d.ts +1 -1
- package/build-types/attached_to/view.d.ts.map +1 -1
- package/build-types/author/index.d.ts.map +1 -1
- package/build-types/author/view.d.ts +1 -1
- 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.map +1 -1
- 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.map +1 -1
- package/build-types/filename/view.d.ts +1 -1
- package/build-types/filename/view.d.ts.map +1 -1
- 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.map +1 -1
- package/build-types/media_thumbnail/view.d.ts +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/stories/index.story.d.ts +1 -1
- package/build-types/stories/index.story.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/attached_to/test/view.test.tsx +97 -0
- package/src/attached_to/view.tsx +1 -3
|
@@ -37,7 +37,7 @@ function MediaAttachedToView({
|
|
|
37
37
|
(0, import_element.useEffect)(() => {
|
|
38
38
|
if (!!parentId && parentId === embeddedPostId) {
|
|
39
39
|
setAttachedPostTitle(
|
|
40
|
-
(0, import_get_rendered_content.getRenderedContent)(embeddedPostTitle) ||
|
|
40
|
+
(0, import_get_rendered_content.getRenderedContent)(embeddedPostTitle) || (0, import_i18n.__)("(no title)")
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
if (!parentId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/attached_to/view.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport default function MediaAttachedToView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\t// Store the displayed title in state, as the embedded post may be loaded\n\t// asynchronously. This ensures that the title remains stable after it\n\t// is updated by the user, and while it is re-fetched from the server.\n\tconst [ attachedPostTitle, setAttachedPostTitle ] = useState<\n\t\tstring | null\n\t>( null );\n\n\tconst parentId = item.post;\n\tconst embeddedPostId = item._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.id;\n\tconst embeddedPostTitle =\n\t\titem._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title;\n\n\tuseEffect( () => {\n\t\tif ( !! parentId && parentId === embeddedPostId ) {\n\t\t\tsetAttachedPostTitle(\n\t\t\t\tgetRenderedContent( embeddedPostTitle )
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoC;AACpC,kBAAmB;AAMnB,kCAAmC;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport default function MediaAttachedToView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\t// Store the displayed title in state, as the embedded post may be loaded\n\t// asynchronously. This ensures that the title remains stable after it\n\t// is updated by the user, and while it is re-fetched from the server.\n\tconst [ attachedPostTitle, setAttachedPostTitle ] = useState<\n\t\tstring | null\n\t>( null );\n\n\tconst parentId = item.post;\n\tconst embeddedPostId = item._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.id;\n\tconst embeddedPostTitle =\n\t\titem._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title;\n\n\tuseEffect( () => {\n\t\tif ( !! parentId && parentId === embeddedPostId ) {\n\t\t\tsetAttachedPostTitle(\n\t\t\t\tgetRenderedContent( embeddedPostTitle ) || __( '(no title)' )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! parentId ) {\n\t\t\tsetAttachedPostTitle( __( '(Unattached)' ) );\n\t\t}\n\t}, [ parentId, embeddedPostId, embeddedPostTitle ] );\n\n\treturn <>{ attachedPostTitle }</>;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoC;AACpC,kBAAmB;AAMnB,kCAAmC;AA6B3B;AA3BO,SAAR,oBAAsC;AAAA,EAC5C;AACD,GAA2C;AAI1C,QAAM,CAAE,mBAAmB,oBAAqB,QAAI,yBAEjD,IAAK;AAER,QAAM,WAAW,KAAK;AACtB,QAAM,iBAAiB,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AACpE,QAAM,oBACL,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AAE9C,gCAAW,MAAM;AAChB,QAAK,CAAC,CAAE,YAAY,aAAa,gBAAiB;AACjD;AAAA,YACC,gDAAoB,iBAAkB,SAAK,gBAAI,YAAa;AAAA,MAC7D;AAAA,IACD;AAEA,QAAK,CAAE,UAAW;AACjB,+BAAsB,gBAAI,cAAe,CAAE;AAAA,IAC5C;AAAA,EACD,GAAG,CAAE,UAAU,gBAAgB,iBAAkB,CAAE;AAEnD,SAAO,2EAAI,6BAAmB;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -13,7 +13,7 @@ function MediaAttachedToView({
|
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (!!parentId && parentId === embeddedPostId) {
|
|
15
15
|
setAttachedPostTitle(
|
|
16
|
-
getRenderedContent(embeddedPostTitle) ||
|
|
16
|
+
getRenderedContent(embeddedPostTitle) || __("(no title)")
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
if (!parentId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/attached_to/view.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport default function MediaAttachedToView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\t// Store the displayed title in state, as the embedded post may be loaded\n\t// asynchronously. This ensures that the title remains stable after it\n\t// is updated by the user, and while it is re-fetched from the server.\n\tconst [ attachedPostTitle, setAttachedPostTitle ] = useState<\n\t\tstring | null\n\t>( null );\n\n\tconst parentId = item.post;\n\tconst embeddedPostId = item._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.id;\n\tconst embeddedPostTitle =\n\t\titem._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title;\n\n\tuseEffect( () => {\n\t\tif ( !! parentId && parentId === embeddedPostId ) {\n\t\t\tsetAttachedPostTitle(\n\t\t\t\tgetRenderedContent( embeddedPostTitle )
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU,iBAAiB;AACpC,SAAS,UAAU;AAMnB,SAAS,0BAA0B;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport default function MediaAttachedToView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\t// Store the displayed title in state, as the embedded post may be loaded\n\t// asynchronously. This ensures that the title remains stable after it\n\t// is updated by the user, and while it is re-fetched from the server.\n\tconst [ attachedPostTitle, setAttachedPostTitle ] = useState<\n\t\tstring | null\n\t>( null );\n\n\tconst parentId = item.post;\n\tconst embeddedPostId = item._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.id;\n\tconst embeddedPostTitle =\n\t\titem._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title;\n\n\tuseEffect( () => {\n\t\tif ( !! parentId && parentId === embeddedPostId ) {\n\t\t\tsetAttachedPostTitle(\n\t\t\t\tgetRenderedContent( embeddedPostTitle ) || __( '(no title)' )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! parentId ) {\n\t\t\tsetAttachedPostTitle( __( '(Unattached)' ) );\n\t\t}\n\t}, [ parentId, embeddedPostId, embeddedPostTitle ] );\n\n\treturn <>{ attachedPostTitle }</>;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU,iBAAiB;AACpC,SAAS,UAAU;AAMnB,SAAS,0BAA0B;AA6B3B;AA3BO,SAAR,oBAAsC;AAAA,EAC5C;AACD,GAA2C;AAI1C,QAAM,CAAE,mBAAmB,oBAAqB,IAAI,SAEjD,IAAK;AAER,QAAM,WAAW,KAAK;AACtB,QAAM,iBAAiB,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AACpE,QAAM,oBACL,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AAE9C,YAAW,MAAM;AAChB,QAAK,CAAC,CAAE,YAAY,aAAa,gBAAiB;AACjD;AAAA,QACC,mBAAoB,iBAAkB,KAAK,GAAI,YAAa;AAAA,MAC7D;AAAA,IACD;AAEA,QAAK,CAAE,UAAW;AACjB,2BAAsB,GAAI,cAAe,CAAE;AAAA,IAC5C;AAAA,EACD,GAAG,CAAE,UAAU,gBAAgB,iBAAkB,CAAE;AAEnD,SAAO,gCAAI,6BAAmB;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/alt_text/index.tsx"],"names":[],"mappings":"AAKA,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,CAkB5D,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/alt_text/index.tsx"],"names":[],"mappings":"AAKA,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,CAkB5D,CAAC;eAEa,YAAY"}
|
|
@@ -25,5 +25,5 @@ export type SearchResult = {
|
|
|
25
25
|
*/
|
|
26
26
|
kind?: string;
|
|
27
27
|
};
|
|
28
|
-
export default function MediaAttachedToEdit({ data, onChange
|
|
28
|
+
export default function MediaAttachedToEdit({ data, onChange }: DataFormControlProps<MediaItem>): import("react").JSX.Element;
|
|
29
29
|
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/attached_to/edit.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,MAAM,YAAY,GAAG;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,EACJ,QAAQ,
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/attached_to/edit.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,MAAM,YAAY,GAAG;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,EACJ,QAAQ,EACR,EAAE,oBAAoB,CAAE,SAAS,CAAE,+BA0InC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/attached_to/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C,QAAA,MAAM,eAAe,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAQjD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/attached_to/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C,QAAA,MAAM,eAAe,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAQjD,CAAC;eAEa,eAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.test.d.ts","sourceRoot":"","sources":["../../../src/attached_to/test/view.test.tsx"],"names":[],"mappings":""}
|
|
@@ -3,5 +3,5 @@ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
|
3
3
|
* Internal dependencies
|
|
4
4
|
*/
|
|
5
5
|
import type { MediaItem } from '../types';
|
|
6
|
-
export default function MediaAttachedToView({ item
|
|
6
|
+
export default function MediaAttachedToView({ item }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element;
|
|
7
7
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/attached_to/view.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/attached_to/view.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,EACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,+BA0BvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/author/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAKlD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQ1C,QAAA,MAAM,WAAW,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAkC7C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/author/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAKlD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQ1C,QAAA,MAAM,WAAW,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAkC7C,CAAC;eAEa,WAAW"}
|
|
@@ -3,5 +3,5 @@ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
|
3
3
|
* Internal dependencies
|
|
4
4
|
*/
|
|
5
5
|
import type { MediaItem } from '../types';
|
|
6
|
-
export default function AuthorView({ item
|
|
6
|
+
export default function AuthorView({ item }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element;
|
|
7
7
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/author/view.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAE,EACnC,IAAI,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/author/view.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAE,EACnC,IAAI,EACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,+BAsDvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caption/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAOlD,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAkB5D,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caption/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAOlD,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAkB5D,CAAC;eAEa,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_added/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,QAAA,MAAM,cAAc,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAWhD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_added/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,QAAA,MAAM,cAAc,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAWhD,CAAC;eAEa,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_modified/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,QAAA,MAAM,iBAAiB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAWnD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_modified/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,QAAA,MAAM,iBAAiB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAWnD,CAAC;eAEa,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/description/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAOlD,QAAA,MAAM,gBAAgB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAoBhE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/description/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAOlD,QAAA,MAAM,gBAAgB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAoBhE,CAAC;eAEa,gBAAgB"}
|
|
@@ -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;
|
|
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"}
|
|
@@ -3,5 +3,5 @@ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
|
3
3
|
* Internal dependencies
|
|
4
4
|
*/
|
|
5
5
|
import type { MediaItem } from '../types';
|
|
6
|
-
export default function FileNameView({ item
|
|
6
|
+
export default function FileNameView({ item }: DataViewRenderFieldProps<MediaItem>): "" | import("react").JSX.Element;
|
|
7
7
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/filename/view.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAM1C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,EACrC,IAAI,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/filename/view.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAM1C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,EACrC,IAAI,EACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,oCAmBvC"}
|
|
@@ -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;
|
|
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 +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;
|
|
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 +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;
|
|
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"}
|
|
@@ -10,5 +10,5 @@ import type { MediaItem } from '../types';
|
|
|
10
10
|
* @param configSizes The target display size string (e.g. '900px').
|
|
11
11
|
*/
|
|
12
12
|
export declare function getBestImageUrl(featuredMedia: Attachment | MediaItem, configSizes?: string): string;
|
|
13
|
-
export default function MediaThumbnailView({ item, config
|
|
13
|
+
export default function MediaThumbnailView({ item, config }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element | null;
|
|
14
14
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -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,
|
|
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,EACN,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;
|
|
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 +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
|
|
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;;;AAqUV,eAAO,MAAM,gBAAgB;IAC5B,MAAM,aA/CgC;QAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;KAAE;IAgDnE,QAAQ;QACP,IAAI;YACH,OAAO;gBAAI,IAAI;;YACf,WAAW;YACX,OAAO;;;IAGT,IAAI;QACH,IAAI;;CAEL,CAAC;AAEF,eAAO,MAAM,gBAAgB,mCAsC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/media-fields",
|
|
3
|
-
"version": "0.10.0",
|
|
3
|
+
"version": "0.10.1-next.v.202605131032.0+f6d6e7149",
|
|
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",
|
|
@@ -49,18 +49,18 @@
|
|
|
49
49
|
"src/**/*.scss"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@wordpress/base-styles": "^
|
|
53
|
-
"@wordpress/components": "^33.
|
|
54
|
-
"@wordpress/compose": "^7.45.0",
|
|
55
|
-
"@wordpress/core-data": "^7.45.0",
|
|
56
|
-
"@wordpress/data": "^10.45.0",
|
|
57
|
-
"@wordpress/dataviews": "^14.2.0",
|
|
58
|
-
"@wordpress/date": "^5.45.0",
|
|
59
|
-
"@wordpress/element": "^6.45.0",
|
|
60
|
-
"@wordpress/i18n": "^6.18.0",
|
|
61
|
-
"@wordpress/icons": "^13.0.0",
|
|
62
|
-
"@wordpress/primitives": "^4.45.0",
|
|
63
|
-
"@wordpress/url": "^4.45.0",
|
|
52
|
+
"@wordpress/base-styles": "^8.0.1-next.v.202605131032.0+f6d6e7149",
|
|
53
|
+
"@wordpress/components": "^33.1.1-next.v.202605131032.0+f6d6e7149",
|
|
54
|
+
"@wordpress/compose": "^7.45.1-next.v.202605131032.0+f6d6e7149",
|
|
55
|
+
"@wordpress/core-data": "^7.45.1-next.v.202605131032.0+f6d6e7149",
|
|
56
|
+
"@wordpress/data": "^10.45.1-next.v.202605131032.0+f6d6e7149",
|
|
57
|
+
"@wordpress/dataviews": "^14.2.1-next.v.202605131032.0+f6d6e7149",
|
|
58
|
+
"@wordpress/date": "^5.45.1-next.v.202605131032.0+f6d6e7149",
|
|
59
|
+
"@wordpress/element": "^6.45.1-next.v.202605131032.0+f6d6e7149",
|
|
60
|
+
"@wordpress/i18n": "^6.18.1-next.v.202605131032.0+f6d6e7149",
|
|
61
|
+
"@wordpress/icons": "^13.0.1-next.v.202605131032.0+f6d6e7149",
|
|
62
|
+
"@wordpress/primitives": "^4.45.1-next.v.202605131032.0+f6d6e7149",
|
|
63
|
+
"@wordpress/url": "^4.45.1-next.v.202605131032.0+f6d6e7149",
|
|
64
64
|
"clsx": "2.1.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "0e198c7ac7ca634e73ded9220ce048c0302174dd"
|
|
77
77
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { NormalizedField } from '@wordpress/dataviews';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import MediaAttachedToView from '../view';
|
|
15
|
+
import type { MediaItem } from '../../types';
|
|
16
|
+
|
|
17
|
+
// The view component only reads `item`; a stub is enough to satisfy the
|
|
18
|
+
// `DataViewRenderFieldProps` signature without dragging in the edit
|
|
19
|
+
// component's `@wordpress/core-data` import chain.
|
|
20
|
+
const field = {} as NormalizedField< MediaItem >;
|
|
21
|
+
|
|
22
|
+
describe( 'MediaAttachedToView', () => {
|
|
23
|
+
it( 'renders the rendered post title when the embedded post matches the parent', () => {
|
|
24
|
+
const item: Partial< MediaItem > = {
|
|
25
|
+
post: 42,
|
|
26
|
+
_embedded: {
|
|
27
|
+
'wp:attached-to': [
|
|
28
|
+
{
|
|
29
|
+
id: 42,
|
|
30
|
+
title: { raw: 'Hello world', rendered: 'Hello world' },
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
render(
|
|
37
|
+
<MediaAttachedToView item={ item as MediaItem } field={ field } />
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect( screen.getByText( 'Hello world' ) ).toBeInTheDocument();
|
|
41
|
+
} );
|
|
42
|
+
|
|
43
|
+
it( 'falls back to "(no title)" when the embedded post is loaded but has an empty title', () => {
|
|
44
|
+
const item: Partial< MediaItem > = {
|
|
45
|
+
post: 42,
|
|
46
|
+
_embedded: {
|
|
47
|
+
'wp:attached-to': [
|
|
48
|
+
{
|
|
49
|
+
id: 42,
|
|
50
|
+
title: { raw: '', rendered: '' },
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
render(
|
|
57
|
+
<MediaAttachedToView item={ item as MediaItem } field={ field } />
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
expect( screen.getByText( '(no title)' ) ).toBeInTheDocument();
|
|
61
|
+
expect( screen.queryByText( '42' ) ).not.toBeInTheDocument();
|
|
62
|
+
} );
|
|
63
|
+
|
|
64
|
+
it( 'renders "(Unattached)" when there is no parent post', () => {
|
|
65
|
+
const item: Partial< MediaItem > = {
|
|
66
|
+
post: 0,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
render(
|
|
70
|
+
<MediaAttachedToView item={ item as MediaItem } field={ field } />
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect( screen.getByText( '(Unattached)' ) ).toBeInTheDocument();
|
|
74
|
+
} );
|
|
75
|
+
|
|
76
|
+
it( 'does not render the title yet when the embedded post id does not match the parent', () => {
|
|
77
|
+
// Stale embedded data from a prior attachment shouldn't be shown
|
|
78
|
+
// for the new parent until the matching record loads.
|
|
79
|
+
const item: Partial< MediaItem > = {
|
|
80
|
+
post: 42,
|
|
81
|
+
_embedded: {
|
|
82
|
+
'wp:attached-to': [
|
|
83
|
+
{
|
|
84
|
+
id: 7,
|
|
85
|
+
title: { raw: 'Old title', rendered: 'Old title' },
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const { container } = render(
|
|
92
|
+
<MediaAttachedToView item={ item as MediaItem } field={ field } />
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
expect( container ).toBeEmptyDOMElement();
|
|
96
|
+
} );
|
|
97
|
+
} );
|
package/src/attached_to/view.tsx
CHANGED
|
@@ -28,9 +28,7 @@ export default function MediaAttachedToView( {
|
|
|
28
28
|
useEffect( () => {
|
|
29
29
|
if ( !! parentId && parentId === embeddedPostId ) {
|
|
30
30
|
setAttachedPostTitle(
|
|
31
|
-
getRenderedContent( embeddedPostTitle ) ||
|
|
32
|
-
embeddedPostId?.toString() ||
|
|
33
|
-
''
|
|
31
|
+
getRenderedContent( embeddedPostTitle ) || __( '(no title)' )
|
|
34
32
|
);
|
|
35
33
|
}
|
|
36
34
|
|