@wordpress/media-fields 0.22.0 → 0.24.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/alt_text/index.cjs +31 -57
- package/build/alt_text/index.cjs.map +1 -7
- package/build/attached_to/edit.cjs +98 -133
- package/build/attached_to/edit.cjs.map +1 -7
- package/build/attached_to/index.cjs +33 -38
- package/build/attached_to/index.cjs.map +1 -7
- package/build/attached_to/view.cjs +25 -46
- package/build/attached_to/view.cjs.map +1 -7
- package/build/author/index.cjs +43 -56
- package/build/author/index.cjs.map +1 -7
- package/build/author/view.cjs +67 -74
- package/build/author/view.cjs.map +1 -7
- package/build/caption/index.cjs +21 -39
- package/build/caption/index.cjs.map +1 -7
- package/build/date_added/index.cjs +13 -34
- package/build/date_added/index.cjs.map +1 -7
- package/build/date_modified/index.cjs +13 -34
- package/build/date_modified/index.cjs.map +1 -7
- package/build/description/index.cjs +22 -40
- package/build/description/index.cjs.map +1 -7
- package/build/filename/index.cjs +33 -39
- package/build/filename/index.cjs.map +1 -7
- package/build/filename/view.cjs +23 -51
- package/build/filename/view.cjs.map +1 -7
- package/build/filesize/index.cjs +54 -83
- package/build/filesize/index.cjs.map +1 -7
- package/build/index.cjs +111 -63
- package/build/media_dimensions/index.cjs +19 -42
- package/build/media_dimensions/index.cjs.map +1 -7
- package/build/media_thumbnail/index.cjs +30 -36
- package/build/media_thumbnail/index.cjs.map +1 -7
- package/build/media_thumbnail/view.cjs +117 -164
- package/build/media_thumbnail/view.cjs.map +1 -7
- package/build/mime_type/index.cjs +16 -37
- package/build/mime_type/index.cjs.map +1 -7
- package/build/types.cjs +4 -18
- package/build/utils/get-media-type-from-mime-type.cjs +41 -56
- package/build/utils/get-media-type-from-mime-type.cjs.map +1 -7
- package/build/utils/get-raw-content.cjs +23 -38
- package/build/utils/get-raw-content.cjs.map +1 -7
- package/build/utils/get-rendered-content.cjs +23 -38
- package/build/utils/get-rendered-content.cjs.map +1 -7
- package/build-module/alt_text/index.mjs +25 -35
- package/build-module/alt_text/index.mjs.map +1 -7
- package/build-module/attached_to/edit.mjs +88 -110
- package/build-module/attached_to/edit.mjs.map +1 -7
- package/build-module/attached_to/index.mjs +12 -14
- package/build-module/attached_to/index.mjs.map +1 -7
- package/build-module/attached_to/view.mjs +19 -24
- package/build-module/attached_to/view.mjs.map +1 -7
- package/build-module/author/index.mjs +23 -32
- package/build-module/author/index.mjs.map +1 -7
- package/build-module/author/view.mjs +47 -53
- package/build-module/author/view.mjs.map +1 -7
- package/build-module/caption/index.mjs +16 -18
- package/build-module/caption/index.mjs.map +1 -7
- package/build-module/date_added/index.mjs +10 -14
- package/build-module/date_added/index.mjs.map +1 -7
- package/build-module/date_modified/index.mjs +10 -14
- package/build-module/date_modified/index.mjs.map +1 -7
- package/build-module/description/index.mjs +16 -18
- package/build-module/description/index.mjs.map +1 -7
- package/build-module/filename/index.mjs +13 -15
- package/build-module/filename/index.mjs.map +1 -7
- package/build-module/filename/view.mjs +16 -28
- package/build-module/filename/view.mjs.map +1 -7
- package/build-module/filesize/index.mjs +50 -63
- package/build-module/filesize/index.mjs.map +1 -7
- package/build-module/index.mjs +13 -28
- package/build-module/media_dimensions/index.mjs +15 -22
- package/build-module/media_dimensions/index.mjs.map +1 -7
- package/build-module/media_thumbnail/index.mjs +11 -13
- package/build-module/media_thumbnail/index.mjs.map +1 -7
- package/build-module/media_thumbnail/view.mjs +94 -138
- package/build-module/media_thumbnail/view.mjs.map +1 -7
- package/build-module/mime_type/index.mjs +13 -17
- package/build-module/mime_type/index.mjs.map +1 -7
- package/build-module/types.mjs +0 -1
- package/build-module/utils/get-media-type-from-mime-type.mjs +37 -32
- package/build-module/utils/get-media-type-from-mime-type.mjs.map +1 -7
- package/build-module/utils/get-raw-content.mjs +19 -14
- package/build-module/utils/get-raw-content.mjs.map +1 -7
- package/build-module/utils/get-rendered-content.mjs +19 -14
- package/build-module/utils/get-rendered-content.mjs.map +1 -7
- package/build-types/media_thumbnail/view.d.ts.map +1 -1
- package/package.json +16 -17
- package/src/media_thumbnail/view.tsx +1 -3
- package/CHANGELOG.md +0 -59
- package/build/index.cjs.map +0 -7
- package/build/types.cjs.map +0 -7
- package/build-module/index.mjs.map +0 -7
- package/build-module/types.mjs.map +0 -7
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
// packages/media-fields/src/attached_to/index.tsx
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
2
|
import MediaAttachedToView from "./view.mjs";
|
|
4
3
|
import MediaAttachedToEdit from "./edit.mjs";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var attached_to_default = attachedToField;
|
|
15
|
-
export {
|
|
16
|
-
attached_to_default as default
|
|
4
|
+
// packages/media-fields/src/attached_to/index.tsx
|
|
5
|
+
const attachedToField = {
|
|
6
|
+
id: "attached_to",
|
|
7
|
+
type: "text",
|
|
8
|
+
label: __("Attached to"),
|
|
9
|
+
Edit: MediaAttachedToEdit,
|
|
10
|
+
render: MediaAttachedToView,
|
|
11
|
+
enableSorting: false,
|
|
12
|
+
filterBy: false
|
|
17
13
|
};
|
|
18
|
-
|
|
14
|
+
export { attachedToField as default };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/attached_to/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\nimport MediaAttachedToView from './view';\nimport MediaAttachedToEdit from './edit';\n\nconst attachedToField: Partial< Field< MediaItem > > = {\n\tid: 'attached_to',\n\ttype: 'text',\n\tlabel: __( 'Attached to' ),\n\tEdit: MediaAttachedToEdit,\n\trender: MediaAttachedToView,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default attachedToField;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AAGnB,OAAO,yBAAyB;AAChC,OAAO,yBAAyB;AAEhC,IAAM,kBAAiD;AAAA,EACtD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,aAAc;AAAA,EACzB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/attached_to/index.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\nimport MediaAttachedToView from './view';\nimport MediaAttachedToEdit from './edit';\n\nconst attachedToField: Partial< Field< MediaItem > > = {\n\tid: 'attached_to',\n\ttype: 'text',\n\tlabel: __( 'Attached to' ),\n\tEdit: MediaAttachedToEdit,\n\trender: MediaAttachedToView,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default attachedToField;\n"],"mappings":";;;;AAMA,MAAM,kBAAiD;CACtD,IAAI;CACJ,MAAM;CACN,OAAO,GAAI,aAAc;CACzB,MAAM;CACN,QAAQ;CACR,eAAe;CACf,UAAU;AACX"}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import { useState, useEffect } from "@wordpress/element";
|
|
1
|
+
import { useEffect, useState } from "@wordpress/element";
|
|
3
2
|
import { __ } from "@wordpress/i18n";
|
|
4
3
|
import { getRenderedContent } from "../utils/get-rendered-content.mjs";
|
|
5
4
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
}, [parentId, embeddedPostId, embeddedPostTitle]);
|
|
23
|
-
return /* @__PURE__ */ jsx(Fragment, { children: attachedPostTitle });
|
|
5
|
+
// packages/media-fields/src/attached_to/view.tsx
|
|
6
|
+
function MediaAttachedToView({ item }) {
|
|
7
|
+
const [attachedPostTitle, setAttachedPostTitle] = useState(null);
|
|
8
|
+
const parentId = item.post;
|
|
9
|
+
const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id;
|
|
10
|
+
const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!!parentId && parentId === embeddedPostId) setAttachedPostTitle(getRenderedContent(embeddedPostTitle) || __("(no title)"));
|
|
13
|
+
if (!parentId) setAttachedPostTitle(__("(Unattached)"));
|
|
14
|
+
}, [
|
|
15
|
+
parentId,
|
|
16
|
+
embeddedPostId,
|
|
17
|
+
embeddedPostTitle
|
|
18
|
+
]);
|
|
19
|
+
return /* @__PURE__ */ jsx(Fragment, { children: attachedPostTitle });
|
|
24
20
|
}
|
|
25
|
-
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=view.mjs.map
|
|
21
|
+
export { MediaAttachedToView as default };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=view.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/attached_to/view.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\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,SAAS,UAAU,iBAAiB;AACpC,SAAS,UAAU;AAGnB,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
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"view.mjs","names":[],"sources":["../../src/attached_to/view.tsx"],"sourcesContent":["import { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\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"],"mappings":";;;;;AAMA,SAAwB,oBAAqB,EAC5C,QAC0C;CAI1C,MAAM,CAAE,mBAAmB,wBAAyB,SAEjD,IAAK;CAER,MAAM,WAAW,KAAK;CACtB,MAAM,iBAAiB,KAAK,YAAa,iBAAkB,GAAI,EAAG,EAAE;CACpE,MAAM,oBACL,KAAK,YAAa,iBAAkB,GAAI,EAAG,EAAE;CAE9C,gBAAiB;EAChB,IAAK,CAAC,CAAE,YAAY,aAAa,gBAChC,qBACC,mBAAoB,iBAAkB,KAAK,GAAI,YAAa,CAC7D;EAGD,IAAK,CAAE,UACN,qBAAsB,GAAI,cAAe,CAAE;CAE7C,GAAG;EAAE;EAAU;EAAgB;CAAkB,CAAE;CAEnD,OAAO,oBAAA,UAAA,EAAA,UAAI,kBAAqB,CAAA;AACjC"}
|
|
@@ -1,36 +1,27 @@
|
|
|
1
|
-
// packages/media-fields/src/author/index.tsx
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
2
|
import { resolveSelect } from "@wordpress/data";
|
|
4
|
-
import { store
|
|
3
|
+
import { store } from "@wordpress/core-data";
|
|
5
4
|
import AuthorView from "./view.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
render: AuthorView,
|
|
27
|
-
filterBy: {
|
|
28
|
-
operators: ["isAny", "isNone"]
|
|
29
|
-
},
|
|
30
|
-
readOnly: true
|
|
31
|
-
};
|
|
32
|
-
var author_default = authorField;
|
|
33
|
-
export {
|
|
34
|
-
author_default as default
|
|
5
|
+
// packages/media-fields/src/author/index.tsx
|
|
6
|
+
const authorField = {
|
|
7
|
+
label: __("Author"),
|
|
8
|
+
id: "author",
|
|
9
|
+
type: "integer",
|
|
10
|
+
getElements: async () => {
|
|
11
|
+
return (await resolveSelect(store).getEntityRecords("root", "user", {
|
|
12
|
+
per_page: -1,
|
|
13
|
+
who: "authors",
|
|
14
|
+
_fields: "id,name",
|
|
15
|
+
context: "view"
|
|
16
|
+
}) ?? []).map(({ id, name }) => ({
|
|
17
|
+
value: id,
|
|
18
|
+
label: name
|
|
19
|
+
}));
|
|
20
|
+
},
|
|
21
|
+
render: AuthorView,
|
|
22
|
+
filterBy: { operators: ["isAny", "isNone"] },
|
|
23
|
+
readOnly: true
|
|
35
24
|
};
|
|
36
|
-
|
|
25
|
+
export { authorField as default };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/author/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords< Author >(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n\treadOnly: true,\n};\n\nexport default authorField;\n"],
|
|
5
|
-
"mappings": ";AACA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AAEvC,OAAO,gBAAgB;AAOvB,IAAM,cAA6C;AAAA,EAClD,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,MAAM,cAAe,aAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,iBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["coreDataStore"],"sources":["../../src/author/index.tsx"],"sourcesContent":["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords< Author >(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n\treadOnly: true,\n};\n\nexport default authorField;\n"],"mappings":";;;;;AAYA,MAAM,cAA6C;CAClD,OAAO,GAAI,QAAS;CACpB,IAAI;CACJ,MAAM;CACN,aAAa,YAAY;EAYxB,QAVG,MAAM,cAAeA,KAAc,CAAC,CAAC,iBACtC,QACA,QACA;GACC,UAAU;GACV,KAAK;GACL,SAAS;GACT,SAAS;EACV,CACD,KAAO,CAAC,EAAA,CACM,KAAO,EAAE,IAAI,YAAc;GACzC,OAAO;GACP,OAAO;EACR,EAAI;CACL;CACA,QAAQ;CACR,UAAU,EACT,WAAW,CAAE,SAAS,QAAS,EAChC;CACA,UAAU;AACX"}
|
|
@@ -1,57 +1,51 @@
|
|
|
1
|
-
// packages/media-fields/src/author/view.tsx
|
|
2
1
|
import clsx from "clsx";
|
|
3
2
|
import { __ } from "@wordpress/i18n";
|
|
4
|
-
import {
|
|
5
|
-
import { commentAuthorAvatar
|
|
6
|
-
import {
|
|
7
|
-
__experimentalHStack as HStack,
|
|
8
|
-
Icon as WCIcon
|
|
9
|
-
} from "@wordpress/components";
|
|
3
|
+
import { useCallback, useEffect, useState } from "@wordpress/element";
|
|
4
|
+
import { commentAuthorAvatar } from "@wordpress/icons";
|
|
5
|
+
import { Icon, __experimentalHStack } from "@wordpress/components";
|
|
10
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
] });
|
|
7
|
+
// packages/media-fields/src/author/view.tsx
|
|
8
|
+
function AuthorView({ item }) {
|
|
9
|
+
const author = item?._embedded?.author?.[0];
|
|
10
|
+
const text = author?.name;
|
|
11
|
+
const imageUrl = author?.avatar_urls?.[48];
|
|
12
|
+
const [loadingState, setLoadingState] = useState("loading");
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
setLoadingState("loading");
|
|
15
|
+
}, [imageUrl]);
|
|
16
|
+
const imgRef = useCallback((img) => {
|
|
17
|
+
if (img?.complete) setLoadingState("instant");
|
|
18
|
+
}, []);
|
|
19
|
+
const handleLoad = () => {
|
|
20
|
+
if (loadingState === "loading") setLoadingState("loaded");
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ jsxs(__experimentalHStack, {
|
|
23
|
+
alignment: "left",
|
|
24
|
+
spacing: 0,
|
|
25
|
+
children: [
|
|
26
|
+
!!imageUrl && /* @__PURE__ */ jsx("div", {
|
|
27
|
+
className: clsx("media-author-field__avatar", {
|
|
28
|
+
"is-loading": loadingState === "loading",
|
|
29
|
+
"is-loaded": loadingState === "loaded"
|
|
30
|
+
}),
|
|
31
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
32
|
+
ref: imgRef,
|
|
33
|
+
onLoad: handleLoad,
|
|
34
|
+
alt: __("Author avatar"),
|
|
35
|
+
src: imageUrl
|
|
36
|
+
})
|
|
37
|
+
}),
|
|
38
|
+
!imageUrl && /* @__PURE__ */ jsx("div", {
|
|
39
|
+
className: "media-author-field__icon",
|
|
40
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: commentAuthorAvatar })
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ jsx("span", {
|
|
43
|
+
className: "media-author-field__name",
|
|
44
|
+
children: text
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
});
|
|
53
48
|
}
|
|
54
|
-
export {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=view.mjs.map
|
|
49
|
+
export { AuthorView as default };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=view.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/author/view.tsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useCallback, useEffect } from '@wordpress/element';\nimport { commentAuthorAvatar as authorIcon } from '@wordpress/icons';\nimport {\n\t__experimentalHStack as HStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nexport default function AuthorView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst author = item?._embedded?.author?.[ 0 ];\n\tconst text = author?.name;\n\tconst imageUrl = author?.avatar_urls?.[ 48 ];\n\n\t/*\n\t * Use three states to avoid fade-in animation for cached images:\n\t * 'instant' = image already cached, 'loading' = waiting, 'loaded' = just finished.\n\t */\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'instant' | 'loading' | 'loaded'\n\t>( 'loading' );\n\n\tuseEffect( () => {\n\t\tsetLoadingState( 'loading' );\n\t}, [ imageUrl ] );\n\n\tconst imgRef = useCallback( ( img: HTMLImageElement | null ) => {\n\t\tif ( img?.complete ) {\n\t\t\tsetLoadingState( 'instant' );\n\t\t}\n\t}, [] );\n\n\tconst handleLoad = () => {\n\t\tif ( loadingState === 'loading' ) {\n\t\t\tsetLoadingState( 'loaded' );\n\t\t}\n\t};\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'media-author-field__avatar', {\n\t\t\t\t\t\t'is-loading': loadingState === 'loading',\n\t\t\t\t\t\t'is-loaded': loadingState === 'loaded',\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tref={ imgRef }\n\t\t\t\t\t\tonLoad={ handleLoad }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"media-author-field__icon\">\n\t\t\t\t\t<WCIcon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"media-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,UAAU;AACnB,SAAS,UAAU,aAAa,iBAAiB;AACjD,SAAS,uBAAuB,kBAAkB;AAClD;AAAA,EACC,wBAAwB;AAAA,EACxB,QAAQ;AAAA,OACF;AAoCL,SAQG,KARH;AAhCa,SAAR,WAA6B;AAAA,EACnC;AACD,GAA2C;AAC1C,QAAM,SAAS,MAAM,WAAW,SAAU,CAAE;AAC5C,QAAM,OAAO,QAAQ;AACrB,QAAM,WAAW,QAAQ,cAAe,EAAG;AAM3C,QAAM,CAAE,cAAc,eAAgB,IAAI,SAEvC,SAAU;AAEb,YAAW,MAAM;AAChB,oBAAiB,SAAU;AAAA,EAC5B,GAAG,CAAE,QAAS,CAAE;AAEhB,QAAM,SAAS,YAAa,CAAE,QAAkC;AAC/D,QAAK,KAAK,UAAW;AACpB,sBAAiB,SAAU;AAAA,IAC5B;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,aAAa,MAAM;AACxB,QAAK,iBAAiB,WAAY;AACjC,sBAAiB,QAAS;AAAA,IAC3B;AAAA,EACD;AAEA,SACC,qBAAC,UAAO,WAAU,QAAO,SAAU,GAChC;AAAA,KAAC,CAAE,YACJ;AAAA,MAAC;AAAA;AAAA,QACA,WAAY,KAAM,8BAA8B;AAAA,UAC/C,cAAc,iBAAiB;AAAA,UAC/B,aAAa,iBAAiB;AAAA,QAC/B,CAAE;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN,QAAS;AAAA,YACT,KAAM,GAAI,eAAgB;AAAA,YAC1B,KAAM;AAAA;AAAA,QACP;AAAA;AAAA,IACD;AAAA,IAEC,CAAE,YACH,oBAAC,SAAI,WAAU,4BACd,8BAAC,UAAO,MAAO,YAAa,GAC7B;AAAA,IAED,oBAAC,UAAK,WAAU,4BAA6B,gBAAM;AAAA,KACpD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"view.mjs","names":["HStack","WCIcon","authorIcon"],"sources":["../../src/author/view.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useCallback, useEffect } from '@wordpress/element';\nimport { commentAuthorAvatar as authorIcon } from '@wordpress/icons';\nimport {\n\t__experimentalHStack as HStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nexport default function AuthorView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst author = item?._embedded?.author?.[ 0 ];\n\tconst text = author?.name;\n\tconst imageUrl = author?.avatar_urls?.[ 48 ];\n\n\t/*\n\t * Use three states to avoid fade-in animation for cached images:\n\t * 'instant' = image already cached, 'loading' = waiting, 'loaded' = just finished.\n\t */\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'instant' | 'loading' | 'loaded'\n\t>( 'loading' );\n\n\tuseEffect( () => {\n\t\tsetLoadingState( 'loading' );\n\t}, [ imageUrl ] );\n\n\tconst imgRef = useCallback( ( img: HTMLImageElement | null ) => {\n\t\tif ( img?.complete ) {\n\t\t\tsetLoadingState( 'instant' );\n\t\t}\n\t}, [] );\n\n\tconst handleLoad = () => {\n\t\tif ( loadingState === 'loading' ) {\n\t\t\tsetLoadingState( 'loaded' );\n\t\t}\n\t};\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'media-author-field__avatar', {\n\t\t\t\t\t\t'is-loading': loadingState === 'loading',\n\t\t\t\t\t\t'is-loaded': loadingState === 'loaded',\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tref={ imgRef }\n\t\t\t\t\t\tonLoad={ handleLoad }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"media-author-field__icon\">\n\t\t\t\t\t<WCIcon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"media-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n"],"mappings":";;;;;;;AAWA,SAAwB,WAAY,EACnC,QAC0C;CAC1C,MAAM,SAAS,MAAM,WAAW,SAAU;CAC1C,MAAM,OAAO,QAAQ;CACrB,MAAM,WAAW,QAAQ,cAAe;CAMxC,MAAM,CAAE,cAAc,mBAAoB,SAEvC,SAAU;CAEb,gBAAiB;EAChB,gBAAiB,SAAU;CAC5B,GAAG,CAAE,QAAS,CAAE;CAEhB,MAAM,SAAS,aAAe,QAAkC;EAC/D,IAAK,KAAK,UACT,gBAAiB,SAAU;CAE7B,GAAG,CAAC,CAAE;CAEN,MAAM,mBAAmB;EACxB,IAAK,iBAAiB,WACrB,gBAAiB,QAAS;CAE5B;CAEA,OACC,qBAACA,sBAAD;EAAQ,WAAU;EAAO,SAAU;EAAnC,UAAA;GACG,CAAC,CAAE,YACJ,oBAAC,OAAD;IACC,WAAY,KAAM,8BAA8B;KAC/C,cAAc,iBAAiB;KAC/B,aAAa,iBAAiB;IAC/B,CAAE;IAEF,UAAA,oBAAC,OAAD;KACC,KAAM;KACN,QAAS;KACT,KAAM,GAAI,eAAgB;KAC1B,KAAM;IACN,CAAA;GACG,CAAA;GAEJ,CAAE,YACH,oBAAC,OAAD;IAAK,WAAU;IACd,UAAA,oBAACC,MAAD,EAAQ,MAAOC,oBAAc,CAAA;GACzB,CAAA;GAEN,oBAAC,QAAD;IAAM,WAAU;IAA6B,UAAA;GAAY,CAAA;EAClD;;AAEV"}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
// packages/media-fields/src/caption/index.tsx
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
2
|
import { getRawContent } from "../utils/get-raw-content.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var caption_default = captionField;
|
|
18
|
-
export {
|
|
19
|
-
caption_default as default
|
|
3
|
+
// packages/media-fields/src/caption/index.tsx
|
|
4
|
+
const captionField = {
|
|
5
|
+
id: "caption",
|
|
6
|
+
type: "text",
|
|
7
|
+
label: __("Caption"),
|
|
8
|
+
getValue: ({ item }) => getRawContent(item?.caption),
|
|
9
|
+
render: ({ item }) => getRawContent(item?.caption) || "-",
|
|
10
|
+
Edit: {
|
|
11
|
+
control: "textarea",
|
|
12
|
+
rows: 2
|
|
13
|
+
},
|
|
14
|
+
enableSorting: false,
|
|
15
|
+
filterBy: false
|
|
20
16
|
};
|
|
21
|
-
|
|
17
|
+
export { captionField as default };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/caption/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst captionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'caption',\n\ttype: 'text',\n\tlabel: __( 'Caption' ),\n\tgetValue: ( { item } ) => getRawContent( item?.caption ),\n\trender: ( { item } ) => getRawContent( item?.caption ) || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AAGnB,SAAS,qBAAqB;AAE9B,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,SAAU;AAAA,EACrB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ;AAAA,EACvD,QAAQ,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ,KAAK;AAAA,EAC1D,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,kBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/caption/index.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst captionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'caption',\n\ttype: 'text',\n\tlabel: __( 'Caption' ),\n\tgetValue: ( { item } ) => getRawContent( item?.caption ),\n\trender: ( { item } ) => getRawContent( item?.caption ) || '-',\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 2,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],"mappings":";;;AAKA,MAAM,eAA4D;CACjE,IAAI;CACJ,MAAM;CACN,OAAO,GAAI,SAAU;CACrB,WAAY,EAAE,WAAY,cAAe,MAAM,OAAQ;CACvD,SAAU,EAAE,WAAY,cAAe,MAAM,OAAQ,KAAK;CAC1D,MAAM;EACL,SAAS;EACT,MAAM;CACP;CACA,eAAe;CACf,UAAU;AACX"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
// packages/media-fields/src/date_added/index.tsx
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readOnly: true
|
|
11
|
-
};
|
|
12
|
-
var date_added_default = dateAddedField;
|
|
13
|
-
export {
|
|
14
|
-
date_added_default as default
|
|
2
|
+
// packages/media-fields/src/date_added/index.tsx
|
|
3
|
+
const dateAddedField = {
|
|
4
|
+
id: "date",
|
|
5
|
+
type: "datetime",
|
|
6
|
+
label: __("Date added"),
|
|
7
|
+
filterBy: { operators: ["before", "after"] },
|
|
8
|
+
readOnly: true
|
|
15
9
|
};
|
|
16
|
-
|
|
10
|
+
export { dateAddedField as default };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/date_added/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nconst dateAddedField: Partial< Field< MediaItem > > = {\n\tid: 'date',\n\ttype: 'datetime',\n\tlabel: __( 'Date added' ),\n\tfilterBy: {\n\t\toperators: [ 'before', 'after' ],\n\t},\n\treadOnly: true,\n};\n\nexport default dateAddedField;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AAInB,IAAM,iBAAgD;AAAA,EACrD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,YAAa;AAAA,EACxB,UAAU;AAAA,IACT,WAAW,CAAE,UAAU,OAAQ;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,qBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/date_added/index.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nconst dateAddedField: Partial< Field< MediaItem > > = {\n\tid: 'date',\n\ttype: 'datetime',\n\tlabel: __( 'Date added' ),\n\tfilterBy: {\n\t\toperators: [ 'before', 'after' ],\n\t},\n\treadOnly: true,\n};\n\nexport default dateAddedField;\n"],"mappings":";;AAIA,MAAM,iBAAgD;CACrD,IAAI;CACJ,MAAM;CACN,OAAO,GAAI,YAAa;CACxB,UAAU,EACT,WAAW,CAAE,UAAU,OAAQ,EAChC;CACA,UAAU;AACX"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
// packages/media-fields/src/date_modified/index.tsx
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readOnly: true
|
|
11
|
-
};
|
|
12
|
-
var date_modified_default = dateModifiedField;
|
|
13
|
-
export {
|
|
14
|
-
date_modified_default as default
|
|
2
|
+
// packages/media-fields/src/date_modified/index.tsx
|
|
3
|
+
const dateModifiedField = {
|
|
4
|
+
id: "modified",
|
|
5
|
+
type: "datetime",
|
|
6
|
+
label: __("Date modified"),
|
|
7
|
+
filterBy: { operators: ["before", "after"] },
|
|
8
|
+
readOnly: true
|
|
15
9
|
};
|
|
16
|
-
|
|
10
|
+
export { dateModifiedField as default };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/date_modified/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nconst dateModifiedField: Partial< Field< MediaItem > > = {\n\tid: 'modified',\n\ttype: 'datetime',\n\tlabel: __( 'Date modified' ),\n\tfilterBy: {\n\t\toperators: [ 'before', 'after' ],\n\t},\n\treadOnly: true,\n};\n\nexport default dateModifiedField;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AAInB,IAAM,oBAAmD;AAAA,EACxD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,eAAgB;AAAA,EAC3B,UAAU;AAAA,IACT,WAAW,CAAE,UAAU,OAAQ;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,wBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/date_modified/index.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nconst dateModifiedField: Partial< Field< MediaItem > > = {\n\tid: 'modified',\n\ttype: 'datetime',\n\tlabel: __( 'Date modified' ),\n\tfilterBy: {\n\t\toperators: [ 'before', 'after' ],\n\t},\n\treadOnly: true,\n};\n\nexport default dateModifiedField;\n"],"mappings":";;AAIA,MAAM,oBAAmD;CACxD,IAAI;CACJ,MAAM;CACN,OAAO,GAAI,eAAgB;CAC3B,UAAU,EACT,WAAW,CAAE,UAAU,OAAQ,EAChC;CACA,UAAU;AACX"}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
// packages/media-fields/src/description/index.tsx
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
2
|
import { getRawContent } from "../utils/get-raw-content.mjs";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var description_default = descriptionField;
|
|
19
|
-
export {
|
|
20
|
-
description_default as default
|
|
4
|
+
// packages/media-fields/src/description/index.tsx
|
|
5
|
+
const descriptionField = {
|
|
6
|
+
id: "description",
|
|
7
|
+
type: "text",
|
|
8
|
+
label: __("Description"),
|
|
9
|
+
getValue: ({ item }) => getRawContent(item?.description),
|
|
10
|
+
render: ({ item }) => /* @__PURE__ */ jsx("div", { children: getRawContent(item?.description) || "-" }),
|
|
11
|
+
Edit: {
|
|
12
|
+
control: "textarea",
|
|
13
|
+
rows: 5
|
|
14
|
+
},
|
|
15
|
+
enableSorting: false,
|
|
16
|
+
filterBy: false
|
|
21
17
|
};
|
|
22
|
-
|
|
18
|
+
export { descriptionField as default };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/description/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst descriptionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue: ( { item } ) => getRawContent( item?.description ),\n\trender: ( { item } ) => (\n\t\t<div>{ getRawContent( item?.description ) || '-' }</div>\n\t),\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 5,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AAGnB,SAAS,qBAAqB;AAQ5B;AANF,IAAM,mBAAgE;AAAA,EACrE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,aAAc;AAAA,EACzB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,WAAY;AAAA,EAC3D,QAAQ,CAAE,EAAE,KAAK,MAChB,oBAAC,SAAM,wBAAe,MAAM,WAAY,KAAK,KAAK;AAAA,EAEnD,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/description/index.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst descriptionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue: ( { item } ) => getRawContent( item?.description ),\n\trender: ( { item } ) => (\n\t\t<div>{ getRawContent( item?.description ) || '-' }</div>\n\t),\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 5,\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],"mappings":";;;;AAKA,MAAM,mBAAgE;CACrE,IAAI;CACJ,MAAM;CACN,OAAO,GAAI,aAAc;CACzB,WAAY,EAAE,WAAY,cAAe,MAAM,WAAY;CAC3D,SAAU,EAAE,WACX,oBAAC,OAAD,EAAA,UAAO,cAAe,MAAM,WAAY,KAAK,IAAU,CAAA;CAExD,MAAM;EACL,SAAS;EACT,MAAM;CACP;CACA,eAAe;CACf,UAAU;AACX"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
// packages/media-fields/src/filename/index.ts
|
|
2
1
|
import { __ } from "@wordpress/i18n";
|
|
3
2
|
import { getFilename } from "@wordpress/url";
|
|
4
3
|
import FileNameView from "./view.mjs";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var filename_default = filenameField;
|
|
16
|
-
export {
|
|
17
|
-
filename_default as default
|
|
4
|
+
// packages/media-fields/src/filename/index.ts
|
|
5
|
+
const filenameField = {
|
|
6
|
+
id: "filename",
|
|
7
|
+
type: "text",
|
|
8
|
+
label: __("File name"),
|
|
9
|
+
getValue: ({ item }) => getFilename(item?.source_url || ""),
|
|
10
|
+
render: FileNameView,
|
|
11
|
+
enableSorting: false,
|
|
12
|
+
filterBy: false,
|
|
13
|
+
readOnly: true
|
|
18
14
|
};
|
|
19
|
-
|
|
15
|
+
export { filenameField as default };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/filename/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\nimport FileNameView from './view';\n\nconst filenameField: Partial< Field< MediaItem > > = {\n\tid: 'filename',\n\ttype: 'text',\n\tlabel: __( 'File name' ),\n\tgetValue: ( { item }: { item: MediaItem } ) =>\n\t\tgetFilename( item?.source_url || '' ),\n\trender: FileNameView,\n\tenableSorting: false,\n\tfilterBy: false,\n\treadOnly: true,\n};\n\nexport default filenameField;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAG5B,OAAO,kBAAkB;AAEzB,IAAM,gBAA+C;AAAA,EACpD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,WAAY;AAAA,EACvB,UAAU,CAAE,EAAE,KAAK,MAClB,YAAa,MAAM,cAAc,EAAG;AAAA,EACrC,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AACX;AAEA,IAAO,mBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/filename/index.ts"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\nimport FileNameView from './view';\n\nconst filenameField: Partial< Field< MediaItem > > = {\n\tid: 'filename',\n\ttype: 'text',\n\tlabel: __( 'File name' ),\n\tgetValue: ( { item }: { item: MediaItem } ) =>\n\t\tgetFilename( item?.source_url || '' ),\n\trender: FileNameView,\n\tenableSorting: false,\n\tfilterBy: false,\n\treadOnly: true,\n};\n\nexport default filenameField;\n"],"mappings":";;;;AAMA,MAAM,gBAA+C;CACpD,IAAI;CACJ,MAAM;CACN,OAAO,GAAI,WAAY;CACvB,WAAY,EAAE,WACb,YAAa,MAAM,cAAc,EAAG;CACrC,QAAQ;CACR,eAAe;CACf,UAAU;CACV,UAAU;AACX"}
|
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
// packages/media-fields/src/filename/view.tsx
|
|
2
1
|
import { useMemo } from "@wordpress/element";
|
|
3
2
|
import { getFilename } from "@wordpress/url";
|
|
4
3
|
import { Tooltip } from "@wordpress/ui";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return /* @__PURE__ */ jsxs(Tooltip.Root, { children: [
|
|
21
|
-
/* @__PURE__ */ jsx(
|
|
22
|
-
Tooltip.Trigger,
|
|
23
|
-
{
|
|
24
|
-
render: /* @__PURE__ */ jsx("span", { className: "dataviews-media-field__filename", children: fileName })
|
|
25
|
-
}
|
|
26
|
-
),
|
|
27
|
-
/* @__PURE__ */ jsx(Tooltip.Popup, { children: fileName })
|
|
28
|
-
] });
|
|
5
|
+
// packages/media-fields/src/filename/view.tsx
|
|
6
|
+
const TRUNCATE_LENGTH = 15;
|
|
7
|
+
function FileNameView({ item }) {
|
|
8
|
+
const fileName = useMemo(() => item?.source_url ? getFilename(item.source_url) : null, [item?.source_url]);
|
|
9
|
+
if (!fileName) return "";
|
|
10
|
+
if (fileName.length <= TRUNCATE_LENGTH) return /* @__PURE__ */ jsx("span", {
|
|
11
|
+
className: "dataviews-media-field__filename",
|
|
12
|
+
children: fileName
|
|
13
|
+
});
|
|
14
|
+
return /* @__PURE__ */ jsxs(Tooltip.Root, { children: [/* @__PURE__ */ jsx(Tooltip.Trigger, { render: /* @__PURE__ */ jsx("span", {
|
|
15
|
+
className: "dataviews-media-field__filename",
|
|
16
|
+
children: fileName
|
|
17
|
+
}) }), /* @__PURE__ */ jsx(Tooltip.Popup, { children: fileName })] });
|
|
29
18
|
}
|
|
30
|
-
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=view.mjs.map
|
|
19
|
+
export { FileNameView as default };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=view.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/filename/view.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useMemo } from '@wordpress/element';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { Tooltip } from '@wordpress/ui';\nimport type { MediaItem } from '../types';\n\n// Proxy threshold for \"long enough that the cell will visually truncate\" —\n// used to decide whether to wrap the filename in a Tooltip showing the full\n// name on hover. Visual truncation itself is handled in CSS.\nconst TRUNCATE_LENGTH = 15;\n\nexport default function FileNameView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst fileName = useMemo(\n\t\t() => ( item?.source_url ? getFilename( item.source_url ) : null ),\n\t\t[ item?.source_url ]\n\t);\n\n\tif ( ! fileName ) {\n\t\treturn '';\n\t}\n\n\tif ( fileName.length <= TRUNCATE_LENGTH ) {\n\t\treturn (\n\t\t\t<span className=\"dataviews-media-field__filename\">\n\t\t\t\t{ fileName }\n\t\t\t</span>\n\t\t);\n\t}\n\n\t// The full filename is always in the DOM, so assistive tech gets it\n\t// regardless. The Tooltip aids mouse users where the cell visually clips\n\t// (DataViews layouts); in a non-truncating context like the DataForm the\n\t// name wraps in full, making it redundant but harmless.\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<span className=\"dataviews-media-field__filename\">\n\t\t\t\t\t\t{ fileName }\n\t\t\t\t\t</span>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ fileName }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAE5B,SAAS,eAAe;AAsBrB,cAWD,YAXC;AAhBH,IAAM,kBAAkB;AAET,SAAR,aAA+B;AAAA,EACrC;AACD,GAA2C;AAC1C,QAAM,WAAW;AAAA,IAChB,MAAQ,MAAM,aAAa,YAAa,KAAK,UAAW,IAAI;AAAA,IAC5D,CAAE,MAAM,UAAW;AAAA,EACpB;AAEA,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AAEA,MAAK,SAAS,UAAU,iBAAkB;AACzC,WACC,oBAAC,UAAK,WAAU,mCACb,oBACH;AAAA,EAEF;AAMA,SACC,qBAAC,QAAQ,MAAR,EACA;AAAA;AAAA,MAAC,QAAQ;AAAA,MAAR;AAAA,QACA,QACC,oBAAC,UAAK,WAAU,mCACb,oBACH;AAAA;AAAA,IAEF;AAAA,IACA,oBAAC,QAAQ,OAAR,EAAgB,oBAAU;AAAA,KAC5B;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"view.mjs","names":[],"sources":["../../src/filename/view.tsx"],"sourcesContent":["import { useMemo } from '@wordpress/element';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { Tooltip } from '@wordpress/ui';\nimport type { MediaItem } from '../types';\n\n// Proxy threshold for \"long enough that the cell will visually truncate\" —\n// used to decide whether to wrap the filename in a Tooltip showing the full\n// name on hover. Visual truncation itself is handled in CSS.\nconst TRUNCATE_LENGTH = 15;\n\nexport default function FileNameView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst fileName = useMemo(\n\t\t() => ( item?.source_url ? getFilename( item.source_url ) : null ),\n\t\t[ item?.source_url ]\n\t);\n\n\tif ( ! fileName ) {\n\t\treturn '';\n\t}\n\n\tif ( fileName.length <= TRUNCATE_LENGTH ) {\n\t\treturn (\n\t\t\t<span className=\"dataviews-media-field__filename\">\n\t\t\t\t{ fileName }\n\t\t\t</span>\n\t\t);\n\t}\n\n\t// The full filename is always in the DOM, so assistive tech gets it\n\t// regardless. The Tooltip aids mouse users where the cell visually clips\n\t// (DataViews layouts); in a non-truncating context like the DataForm the\n\t// name wraps in full, making it redundant but harmless.\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<span className=\"dataviews-media-field__filename\">\n\t\t\t\t\t\t{ fileName }\n\t\t\t\t\t</span>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ fileName }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n"],"mappings":";;;;;AASA,MAAM,kBAAkB;AAExB,SAAwB,aAAc,EACrC,QAC0C;CAC1C,MAAM,WAAW,cACR,MAAM,aAAa,YAAa,KAAK,UAAW,IAAI,MAC5D,CAAE,MAAM,UAAW,CACpB;CAEA,IAAK,CAAE,UACN,OAAO;CAGR,IAAK,SAAS,UAAU,iBACvB,OACC,oBAAC,QAAD;EAAM,WAAU;EACb,UAAA;CACG,CAAA;CAQR,OACC,qBAAC,QAAQ,MAAT,EAAA,UAAA,CACC,oBAAC,QAAQ,SAAT,EACC,QACC,oBAAC,QAAD;EAAM,WAAU;EACb,UAAA;CACG,CAAA,EAEP,CAAA,GACD,oBAAC,QAAQ,OAAT,EAAA,UAAiB,SAAyB,CAAA,CAC7B,EAAA,CAAA;AAEhB"}
|