@wordpress/media-fields 0.13.0 → 0.13.1
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 +11 -0
- package/build/date_added/index.cjs +0 -4
- package/build/date_added/index.cjs.map +2 -2
- package/build/date_modified/index.cjs +0 -4
- package/build/date_modified/index.cjs.map +2 -2
- package/build/filename/view.cjs +10 -2
- package/build/filename/view.cjs.map +3 -3
- package/build-module/date_added/index.mjs +0 -4
- package/build-module/date_added/index.mjs.map +2 -2
- package/build-module/date_modified/index.mjs +0 -4
- package/build-module/date_modified/index.mjs.map +2 -2
- package/build-module/filename/view.mjs +11 -3
- package/build-module/filename/view.mjs.map +2 -2
- package/build-style/style-rtl.css +7 -3
- package/build-style/style.css +7 -3
- 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/filename/view.d.ts.map +1 -1
- package/package.json +19 -16
- package/src/date_added/index.tsx +0 -4
- package/src/date_modified/index.tsx +0 -4
- package/src/filename/style.scss +22 -13
- package/src/filename/test/view.test.tsx +1 -22
- package/src/filename/view.tsx +17 -11
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. -->
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 0.13.1 (2026-06-16)
|
|
6
|
+
|
|
7
|
+
## 0.13.0 (2026-06-10)
|
|
8
|
+
|
|
9
|
+
### Code Quality
|
|
10
|
+
|
|
11
|
+
- Add missing `@types/react` dependency. [#78882](https://github.com/WordPress/gutenberg/pull/78882).
|
|
@@ -24,7 +24,6 @@ __export(date_added_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(date_added_exports);
|
|
26
26
|
var import_i18n = require("@wordpress/i18n");
|
|
27
|
-
var import_date = require("@wordpress/date");
|
|
28
27
|
var dateAddedField = {
|
|
29
28
|
id: "date",
|
|
30
29
|
type: "datetime",
|
|
@@ -32,9 +31,6 @@ var dateAddedField = {
|
|
|
32
31
|
filterBy: {
|
|
33
32
|
operators: ["before", "after"]
|
|
34
33
|
},
|
|
35
|
-
format: {
|
|
36
|
-
datetime: (0, import_date.getSettings)().formats.datetimeAbbreviated
|
|
37
|
-
},
|
|
38
34
|
readOnly: true
|
|
39
35
|
};
|
|
40
36
|
var date_added_default = dateAddedField;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/date_added/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\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;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAQnB,IAAM,iBAAgD;AAAA,EACrD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,YAAa;AAAA,EACxB,UAAU;AAAA,IACT,WAAW,CAAE,UAAU,OAAQ;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,7 +24,6 @@ __export(date_modified_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(date_modified_exports);
|
|
26
26
|
var import_i18n = require("@wordpress/i18n");
|
|
27
|
-
var import_date = require("@wordpress/date");
|
|
28
27
|
var dateModifiedField = {
|
|
29
28
|
id: "modified",
|
|
30
29
|
type: "datetime",
|
|
@@ -32,9 +31,6 @@ var dateModifiedField = {
|
|
|
32
31
|
filterBy: {
|
|
33
32
|
operators: ["before", "after"]
|
|
34
33
|
},
|
|
35
|
-
format: {
|
|
36
|
-
datetime: (0, import_date.getSettings)().formats.datetimeAbbreviated
|
|
37
|
-
},
|
|
38
34
|
readOnly: true
|
|
39
35
|
};
|
|
40
36
|
var date_modified_default = dateModifiedField;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/date_modified/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\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;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAQnB,IAAM,oBAAmD;AAAA,EACxD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,eAAgB;AAAA,EAC3B,UAAU;AAAA,IACT,WAAW,CAAE,UAAU,OAAQ;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/filename/view.cjs
CHANGED
|
@@ -23,9 +23,9 @@ __export(view_exports, {
|
|
|
23
23
|
default: () => FileNameView
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(view_exports);
|
|
26
|
-
var import_components = require("@wordpress/components");
|
|
27
26
|
var import_element = require("@wordpress/element");
|
|
28
27
|
var import_url = require("@wordpress/url");
|
|
28
|
+
var import_ui = require("@wordpress/ui");
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
var TRUNCATE_LENGTH = 15;
|
|
31
31
|
function FileNameView({
|
|
@@ -41,6 +41,14 @@ function FileNameView({
|
|
|
41
41
|
if (fileName.length <= TRUNCATE_LENGTH) {
|
|
42
42
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dataviews-media-field__filename", children: fileName });
|
|
43
43
|
}
|
|
44
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Tooltip.Root, { children: [
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
46
|
+
import_ui.Tooltip.Trigger,
|
|
47
|
+
{
|
|
48
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dataviews-media-field__filename", children: fileName })
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tooltip.Popup, { children: fileName })
|
|
52
|
+
] });
|
|
45
53
|
}
|
|
46
54
|
//# sourceMappingURL=view.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/filename/view.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.\nimport { Tooltip } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\n\n// Proxy threshold for \"long enough that the cell will visually truncate\" \u2014\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;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,iBAA4B;AAG5B,gBAAwB;AA0BrB;AAhBH,IAAM,kBAAkB;AAET,SAAR,aAA+B;AAAA,EACrC;AACD,GAA2C;AAC1C,QAAM,eAAW;AAAA,IAChB,MAAQ,MAAM,iBAAa,wBAAa,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,4CAAC,UAAK,WAAU,mCACb,oBACH;AAAA,EAEF;AAMA,SACC,6CAAC,kBAAQ,MAAR,EACA;AAAA;AAAA,MAAC,kBAAQ;AAAA,MAAR;AAAA,QACA,QACC,4CAAC,UAAK,WAAU,mCACb,oBACH;AAAA;AAAA,IAEF;AAAA,IACA,4CAAC,kBAAQ,OAAR,EAAgB,oBAAU;AAAA,KAC5B;AAEF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// packages/media-fields/src/date_added/index.tsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { getSettings } from "@wordpress/date";
|
|
4
3
|
var dateAddedField = {
|
|
5
4
|
id: "date",
|
|
6
5
|
type: "datetime",
|
|
@@ -8,9 +7,6 @@ var dateAddedField = {
|
|
|
8
7
|
filterBy: {
|
|
9
8
|
operators: ["before", "after"]
|
|
10
9
|
},
|
|
11
|
-
format: {
|
|
12
|
-
datetime: getSettings().formats.datetimeAbbreviated
|
|
13
|
-
},
|
|
14
10
|
readOnly: true
|
|
15
11
|
};
|
|
16
12
|
var date_added_default = dateAddedField;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/date_added/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\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": ";AAGA,SAAS,UAAU;AAQnB,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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// packages/media-fields/src/date_modified/index.tsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { getSettings } from "@wordpress/date";
|
|
4
3
|
var dateModifiedField = {
|
|
5
4
|
id: "modified",
|
|
6
5
|
type: "datetime",
|
|
@@ -8,9 +7,6 @@ var dateModifiedField = {
|
|
|
8
7
|
filterBy: {
|
|
9
8
|
operators: ["before", "after"]
|
|
10
9
|
},
|
|
11
|
-
format: {
|
|
12
|
-
datetime: getSettings().formats.datetimeAbbreviated
|
|
13
|
-
},
|
|
14
10
|
readOnly: true
|
|
15
11
|
};
|
|
16
12
|
var date_modified_default = dateModifiedField;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/date_modified/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\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": ";AAGA,SAAS,UAAU;AAQnB,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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// packages/media-fields/src/filename/view.tsx
|
|
2
|
-
import { Tooltip as WCTooltip } from "@wordpress/components";
|
|
3
2
|
import { useMemo } from "@wordpress/element";
|
|
4
3
|
import { getFilename } from "@wordpress/url";
|
|
5
|
-
import {
|
|
4
|
+
import { Tooltip } from "@wordpress/ui";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
var TRUNCATE_LENGTH = 15;
|
|
7
7
|
function FileNameView({
|
|
8
8
|
item
|
|
@@ -17,7 +17,15 @@ function FileNameView({
|
|
|
17
17
|
if (fileName.length <= TRUNCATE_LENGTH) {
|
|
18
18
|
return /* @__PURE__ */ jsx("span", { className: "dataviews-media-field__filename", children: fileName });
|
|
19
19
|
}
|
|
20
|
-
return /* @__PURE__ */
|
|
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
|
+
] });
|
|
21
29
|
}
|
|
22
30
|
export {
|
|
23
31
|
FileNameView as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/filename/view.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.\nimport { Tooltip } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\n\n// Proxy threshold for \"long enough that the cell will visually truncate\" \u2014\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": ";AAGA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAG5B,SAAS,eAAe;AA0BrB,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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -99,7 +99,8 @@
|
|
|
99
99
|
.media-author-field__avatar img {
|
|
100
100
|
width: 16px;
|
|
101
101
|
height: 16px;
|
|
102
|
-
object-fit: cover;
|
|
102
|
+
-o-object-fit: cover;
|
|
103
|
+
object-fit: cover;
|
|
103
104
|
opacity: 1;
|
|
104
105
|
border-radius: 100%;
|
|
105
106
|
}
|
|
@@ -131,7 +132,9 @@
|
|
|
131
132
|
overflow: hidden;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
.dataviews-media-field__filename
|
|
135
|
+
.dataviews-view-table .dataviews-media-field__filename,
|
|
136
|
+
.dataviews-view-grid .dataviews-media-field__filename,
|
|
137
|
+
.dataviews-view-list .dataviews-media-field__filename {
|
|
135
138
|
display: inline-block;
|
|
136
139
|
max-inline-size: 15ch;
|
|
137
140
|
overflow: hidden;
|
|
@@ -162,7 +165,8 @@
|
|
|
162
165
|
display: block;
|
|
163
166
|
width: 100%;
|
|
164
167
|
height: 100%;
|
|
165
|
-
object-fit: cover;
|
|
168
|
+
-o-object-fit: cover;
|
|
169
|
+
object-fit: cover;
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
.dataviews-media-field__media-thumbnail__stack {
|
package/build-style/style.css
CHANGED
|
@@ -99,7 +99,8 @@
|
|
|
99
99
|
.media-author-field__avatar img {
|
|
100
100
|
width: 16px;
|
|
101
101
|
height: 16px;
|
|
102
|
-
object-fit: cover;
|
|
102
|
+
-o-object-fit: cover;
|
|
103
|
+
object-fit: cover;
|
|
103
104
|
opacity: 1;
|
|
104
105
|
border-radius: 100%;
|
|
105
106
|
}
|
|
@@ -131,7 +132,9 @@
|
|
|
131
132
|
overflow: hidden;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
.dataviews-media-field__filename
|
|
135
|
+
.dataviews-view-table .dataviews-media-field__filename,
|
|
136
|
+
.dataviews-view-grid .dataviews-media-field__filename,
|
|
137
|
+
.dataviews-view-list .dataviews-media-field__filename {
|
|
135
138
|
display: inline-block;
|
|
136
139
|
max-inline-size: 15ch;
|
|
137
140
|
overflow: hidden;
|
|
@@ -162,7 +165,8 @@
|
|
|
162
165
|
display: block;
|
|
163
166
|
width: 100%;
|
|
164
167
|
height: 100%;
|
|
165
|
-
object-fit: cover;
|
|
168
|
+
-o-object-fit: cover;
|
|
169
|
+
object-fit: cover;
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
.dataviews-media-field__media-thumbnail__stack {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_added/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_added/index.tsx"],"names":[],"mappings":"AAIA,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,CAQhD,CAAC;eAEa,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_modified/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_modified/index.tsx"],"names":[],"mappings":"AAIA,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,CAQnD,CAAC;eAEa,iBAAiB"}
|
|
@@ -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":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAIrE;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAO1C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,EACrC,IAAI,EACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,oCAkCvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/media-fields",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
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",
|
|
@@ -42,29 +42,32 @@
|
|
|
42
42
|
},
|
|
43
43
|
"./package.json": "./package.json"
|
|
44
44
|
},
|
|
45
|
-
"react-native": "src/index",
|
|
46
45
|
"types": "build-types",
|
|
47
46
|
"sideEffects": [
|
|
48
47
|
"build-style/**",
|
|
49
48
|
"src/**/*.scss"
|
|
50
49
|
],
|
|
51
50
|
"dependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"@wordpress/
|
|
54
|
-
"@wordpress/
|
|
55
|
-
"@wordpress/
|
|
56
|
-
"@wordpress/data": "^
|
|
57
|
-
"@wordpress/
|
|
58
|
-
"@wordpress/
|
|
59
|
-
"@wordpress/
|
|
60
|
-
"@wordpress/
|
|
61
|
-
"@wordpress/
|
|
62
|
-
"@wordpress/
|
|
63
|
-
"@wordpress/
|
|
64
|
-
"
|
|
51
|
+
"@types/react": "^18.3.27",
|
|
52
|
+
"@wordpress/base-styles": "^10.0.1",
|
|
53
|
+
"@wordpress/components": "^35.0.1",
|
|
54
|
+
"@wordpress/compose": "^8.1.1",
|
|
55
|
+
"@wordpress/core-data": "^7.48.1",
|
|
56
|
+
"@wordpress/data": "^10.48.1",
|
|
57
|
+
"@wordpress/dataviews": "^16.0.1",
|
|
58
|
+
"@wordpress/date": "^5.48.1",
|
|
59
|
+
"@wordpress/element": "^8.0.1",
|
|
60
|
+
"@wordpress/i18n": "^6.21.1",
|
|
61
|
+
"@wordpress/icons": "^14.0.1",
|
|
62
|
+
"@wordpress/primitives": "^4.48.1",
|
|
63
|
+
"@wordpress/ui": "^0.15.1",
|
|
64
|
+
"@wordpress/url": "^4.48.1",
|
|
65
|
+
"clsx": "^2.1.1"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
68
|
+
"@testing-library/dom": "^10.4.1",
|
|
67
69
|
"@testing-library/jest-dom": "^6.9.1",
|
|
70
|
+
"@testing-library/react": "^16.3.2",
|
|
68
71
|
"@types/jest": "^29.5.14"
|
|
69
72
|
},
|
|
70
73
|
"peerDependencies": {
|
|
@@ -73,5 +76,5 @@
|
|
|
73
76
|
"publishConfig": {
|
|
74
77
|
"access": "public"
|
|
75
78
|
},
|
|
76
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "99df7432c5c7cb83ba41146fd1f57f3c19004305"
|
|
77
80
|
}
|
package/src/date_added/index.tsx
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { getSettings } from '@wordpress/date';
|
|
6
5
|
import type { Field } from '@wordpress/dataviews';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -17,9 +16,6 @@ const dateAddedField: Partial< Field< MediaItem > > = {
|
|
|
17
16
|
filterBy: {
|
|
18
17
|
operators: [ 'before', 'after' ],
|
|
19
18
|
},
|
|
20
|
-
format: {
|
|
21
|
-
datetime: getSettings().formats.datetimeAbbreviated,
|
|
22
|
-
},
|
|
23
19
|
readOnly: true,
|
|
24
20
|
};
|
|
25
21
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { getSettings } from '@wordpress/date';
|
|
6
5
|
import type { Field } from '@wordpress/dataviews';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -17,9 +16,6 @@ const dateModifiedField: Partial< Field< MediaItem > > = {
|
|
|
17
16
|
filterBy: {
|
|
18
17
|
operators: [ 'before', 'after' ],
|
|
19
18
|
},
|
|
20
|
-
format: {
|
|
21
|
-
datetime: getSettings().formats.datetimeAbbreviated,
|
|
22
|
-
},
|
|
23
19
|
readOnly: true,
|
|
24
20
|
};
|
|
25
21
|
|
package/src/filename/style.scss
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
// Truncation is a DataViews layout concern, so it's scoped to the table/grid/
|
|
2
|
+
// list containers. The same `FileNameView` render is also used in a DataForm
|
|
3
|
+
// (e.g. the media editor modal Details panel) where there's room to show the
|
|
4
|
+
// full name — outside these containers the filename is left to wrap naturally.
|
|
5
|
+
//
|
|
6
|
+
// CSS-based truncation (rather than `__experimentalTruncate`) keeps the full
|
|
7
|
+
// filename in the DOM — available to assistive technology reading the row, and
|
|
8
|
+
// lets the cell respond to column width changes.
|
|
9
|
+
.dataviews-view-table,
|
|
10
|
+
.dataviews-view-grid,
|
|
11
|
+
.dataviews-view-list {
|
|
12
|
+
.dataviews-media-field__filename {
|
|
13
|
+
display: inline-block;
|
|
14
|
+
max-inline-size: 15ch;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
text-overflow: ellipsis;
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
// Snap to the top of the line box so the cell aligns correctly in the
|
|
19
|
+
// DataViews Grid layout — without this the inline-block sits on the
|
|
20
|
+
// baseline and pushes the row out of alignment.
|
|
21
|
+
vertical-align: top;
|
|
22
|
+
}
|
|
14
23
|
}
|
|
@@ -17,7 +17,7 @@ import type { MediaItem } from '../../types';
|
|
|
17
17
|
|
|
18
18
|
describe( 'FileNameView', () => {
|
|
19
19
|
describe( 'filename rendering', () => {
|
|
20
|
-
it( 'renders short filename without a tooltip anchor
|
|
20
|
+
it( 'renders short filename without a tooltip anchor', () => {
|
|
21
21
|
const item: Partial< MediaItem > = {
|
|
22
22
|
source_url: 'https://example.com/uploads/12345678901.jpg', // exactly 15 chars
|
|
23
23
|
};
|
|
@@ -31,7 +31,6 @@ describe( 'FileNameView', () => {
|
|
|
31
31
|
|
|
32
32
|
const rendered = screen.getByText( '12345678901.jpg' );
|
|
33
33
|
expect( rendered ).toHaveClass( 'dataviews-media-field__filename' );
|
|
34
|
-
expect( rendered ).not.toHaveAttribute( 'tabindex' );
|
|
35
34
|
} );
|
|
36
35
|
|
|
37
36
|
it( 'renders long filename inside a Tooltip and exposes the full name in the DOM', () => {
|
|
@@ -54,26 +53,6 @@ describe( 'FileNameView', () => {
|
|
|
54
53
|
const rendered = screen.getByText( longFilename );
|
|
55
54
|
expect( rendered ).toHaveClass( 'dataviews-media-field__filename' );
|
|
56
55
|
} );
|
|
57
|
-
|
|
58
|
-
it( 'does not add a tab stop for truncated filenames', () => {
|
|
59
|
-
const longFilename =
|
|
60
|
-
'very-long-filename-that-exceeds-fifteen-characters.jpg';
|
|
61
|
-
const item: Partial< MediaItem > = {
|
|
62
|
-
source_url: `https://example.com/uploads/${ longFilename }`,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
render(
|
|
66
|
-
<FileNameView
|
|
67
|
-
item={ item as MediaItem }
|
|
68
|
-
field={ filenameField as NormalizedField< MediaItem > }
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
expect( screen.getByText( longFilename ) ).toHaveAttribute(
|
|
73
|
-
'tabindex',
|
|
74
|
-
'-1'
|
|
75
|
-
);
|
|
76
|
-
} );
|
|
77
56
|
} );
|
|
78
57
|
|
|
79
58
|
describe( 'edge cases', () => {
|
package/src/filename/view.tsx
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { Tooltip as WCTooltip } from '@wordpress/components';
|
|
5
4
|
import { useMemo } from '@wordpress/element';
|
|
6
5
|
import { getFilename } from '@wordpress/url';
|
|
7
6
|
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
7
|
+
// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.
|
|
8
|
+
import { Tooltip } from '@wordpress/ui';
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Internal dependencies
|
|
10
12
|
*/
|
|
@@ -35,16 +37,20 @@ export default function FileNameView( {
|
|
|
35
37
|
);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
// already in the DOM for assistive technology reading the row.
|
|
40
|
+
// The full filename is always in the DOM, so assistive tech gets it
|
|
41
|
+
// regardless. The Tooltip aids mouse users where the cell visually clips
|
|
42
|
+
// (DataViews layouts); in a non-truncating context like the DataForm the
|
|
43
|
+
// name wraps in full, making it redundant but harmless.
|
|
43
44
|
return (
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
<Tooltip.Root>
|
|
46
|
+
<Tooltip.Trigger
|
|
47
|
+
render={
|
|
48
|
+
<span className="dataviews-media-field__filename">
|
|
49
|
+
{ fileName }
|
|
50
|
+
</span>
|
|
51
|
+
}
|
|
52
|
+
/>
|
|
53
|
+
<Tooltip.Popup>{ fileName }</Tooltip.Popup>
|
|
54
|
+
</Tooltip.Root>
|
|
49
55
|
);
|
|
50
56
|
}
|