@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
package/build/filename/index.cjs
CHANGED
|
@@ -1,50 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
2
7
|
var __create = Object.create;
|
|
3
8
|
var __defProp = Object.defineProperty;
|
|
4
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
13
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
19
22
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
28
|
+
let _wordpress_url = require("@wordpress/url");
|
|
29
|
+
let __view_tsx = require("./view.cjs");
|
|
30
|
+
__view_tsx = __toESM(__view_tsx);
|
|
30
31
|
// packages/media-fields/src/filename/index.ts
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
id: "filename",
|
|
41
|
-
type: "text",
|
|
42
|
-
label: (0, import_i18n.__)("File name"),
|
|
43
|
-
getValue: ({ item }) => (0, import_url.getFilename)(item?.source_url || ""),
|
|
44
|
-
render: import_view.default,
|
|
45
|
-
enableSorting: false,
|
|
46
|
-
filterBy: false,
|
|
47
|
-
readOnly: true
|
|
32
|
+
const filenameField = {
|
|
33
|
+
id: "filename",
|
|
34
|
+
type: "text",
|
|
35
|
+
label: (0, _wordpress_i18n.__)("File name"),
|
|
36
|
+
getValue: ({ item }) => (0, _wordpress_url.getFilename)(item?.source_url || ""),
|
|
37
|
+
render: __view_tsx.default,
|
|
38
|
+
enableSorting: false,
|
|
39
|
+
filterBy: false,
|
|
40
|
+
readOnly: true
|
|
48
41
|
};
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
exports.default = filenameField;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=index.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,iBAA4B;AAG5B,kBAAyB;AAEzB,IAAM,gBAA+C;AAAA,EACpD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,WAAY;AAAA,EACvB,UAAU,CAAE,EAAE,KAAK,UAClB,wBAAa,MAAM,cAAc,EAAG;AAAA,EACrC,QAAQ,YAAAA;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AACX;AAEA,IAAO,mBAAQ;",
|
|
6
|
-
"names": ["FileNameView"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["__","getFilename","FileNameView"],"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,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,WAAY;CACvB,WAAY,EAAE,YAAA,GACbC,eAAAA,YAAAA,CAAa,MAAM,cAAc,EAAG;CACrC,QAAQC,WAAAA;CACR,eAAe;CACf,UAAU;CACV,UAAU;AACX"}
|
package/build/filename/view.cjs
CHANGED
|
@@ -1,54 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/media-fields/src/filename/view.tsx
|
|
21
|
-
var view_exports = {};
|
|
22
|
-
__export(view_exports, {
|
|
23
|
-
default: () => FileNameView
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
5
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function FileNameView({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dataviews-media-field__filename", children: fileName });
|
|
43
|
-
}
|
|
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
|
-
] });
|
|
6
|
+
let _wordpress_element = require("@wordpress/element");
|
|
7
|
+
let _wordpress_url = require("@wordpress/url");
|
|
8
|
+
let _wordpress_ui = require("@wordpress/ui");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
// packages/media-fields/src/filename/view.tsx
|
|
11
|
+
const TRUNCATE_LENGTH = 15;
|
|
12
|
+
function FileNameView({ item }) {
|
|
13
|
+
const fileName = (0, _wordpress_element.useMemo)(() => item?.source_url ? (0, _wordpress_url.getFilename)(item.source_url) : null, [item?.source_url]);
|
|
14
|
+
if (!fileName) return "";
|
|
15
|
+
if (fileName.length <= TRUNCATE_LENGTH) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
16
|
+
className: "dataviews-media-field__filename",
|
|
17
|
+
children: fileName
|
|
18
|
+
});
|
|
19
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Tooltip.Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tooltip.Trigger, { render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
20
|
+
className: "dataviews-media-field__filename",
|
|
21
|
+
children: fileName
|
|
22
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tooltip.Popup, { children: fileName })] });
|
|
53
23
|
}
|
|
54
|
-
|
|
24
|
+
exports.default = FileNameView;
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=view.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AACxB,iBAA4B;AAE5B,gBAAwB;AAsBrB;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
|
-
}
|
|
1
|
+
{"version":3,"file":"view.cjs","names":["useMemo","getFilename","Tooltip"],"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,YAAA,GAAWA,mBAAAA,QAAAA,OACR,MAAM,cAAA,GAAaC,eAAAA,YAAAA,CAAa,KAAK,UAAW,IAAI,MAC5D,CAAE,MAAM,UAAW,CACpB;CAEA,IAAK,CAAE,UACN,OAAO;CAGR,IAAK,SAAS,UAAU,iBACvB,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAM,WAAU;EACb,UAAA;CACG,CAAA;CAQR,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,cAAAA,QAAQ,MAAT,EAAA,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,QAAQ,SAAT,EACC,QACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAM,WAAU;EACb,UAAA;CACG,CAAA,EAEP,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,QAAQ,OAAT,EAAA,UAAiB,SAAyB,CAAA,CAC7B,EAAA,CAAA;AAEhB"}
|
package/build/filesize/index.cjs
CHANGED
|
@@ -1,90 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/media-fields/src/filesize/index.tsx
|
|
21
|
-
var filesize_exports = {};
|
|
22
|
-
__export(filesize_exports, {
|
|
23
|
-
default: () => filesize_default
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
5
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
7
|
+
// packages/media-fields/src/filesize/index.tsx
|
|
8
|
+
const KB_IN_BYTES = 1024;
|
|
9
|
+
const MB_IN_BYTES = 1024 * KB_IN_BYTES;
|
|
10
|
+
const GB_IN_BYTES = 1024 * MB_IN_BYTES;
|
|
11
|
+
const TB_IN_BYTES = 1024 * GB_IN_BYTES;
|
|
12
|
+
const PB_IN_BYTES = 1024 * TB_IN_BYTES;
|
|
13
|
+
const EB_IN_BYTES = 1024 * PB_IN_BYTES;
|
|
14
|
+
const ZB_IN_BYTES = 1024 * EB_IN_BYTES;
|
|
15
|
+
const YB_IN_BYTES = 1024 * ZB_IN_BYTES;
|
|
35
16
|
function getBytesString(bytes, unitSymbol, decimals = 2) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
minimumFractionDigits: 0,
|
|
41
|
-
maximumFractionDigits: decimals
|
|
42
|
-
}),
|
|
43
|
-
unitSymbol
|
|
44
|
-
);
|
|
17
|
+
return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._x)("%1$s %2$s", "file size"), bytes.toLocaleString(void 0, {
|
|
18
|
+
minimumFractionDigits: 0,
|
|
19
|
+
maximumFractionDigits: decimals
|
|
20
|
+
}), unitSymbol);
|
|
45
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Converts bytes to a human-readable file size string with a specified number of decimal places.
|
|
24
|
+
*
|
|
25
|
+
* This logic is comparable to core's `size_format()` function.
|
|
26
|
+
*
|
|
27
|
+
* @param bytes The size in bytes.
|
|
28
|
+
* @param decimals The number of decimal places to include in the result.
|
|
29
|
+
* @return The human-readable file size string.
|
|
30
|
+
*/
|
|
46
31
|
function formatFileSize(bytes, decimals = 2) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/* translators: Unit symbol for gigabyte. */
|
|
62
|
-
[(0, import_i18n._x)("GB", "unit symbol")]: GB_IN_BYTES,
|
|
63
|
-
/* translators: Unit symbol for megabyte. */
|
|
64
|
-
[(0, import_i18n._x)("MB", "unit symbol")]: MB_IN_BYTES,
|
|
65
|
-
/* translators: Unit symbol for kilobyte. */
|
|
66
|
-
[(0, import_i18n._x)("KB", "unit symbol")]: KB_IN_BYTES,
|
|
67
|
-
/* translators: Unit symbol for byte. */
|
|
68
|
-
[(0, import_i18n._x)("B", "unit symbol")]: 1
|
|
69
|
-
};
|
|
70
|
-
for (const [unit, mag] of Object.entries(quant)) {
|
|
71
|
-
if (bytes >= mag) {
|
|
72
|
-
return getBytesString(bytes / mag, unit, decimals);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return "";
|
|
32
|
+
if (bytes === 0) return getBytesString(0, (0, _wordpress_i18n._x)("B", "unit symbol"), decimals);
|
|
33
|
+
const quant = {
|
|
34
|
+
[(0, _wordpress_i18n._x)("YB", "unit symbol")]: YB_IN_BYTES,
|
|
35
|
+
[(0, _wordpress_i18n._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
|
|
36
|
+
[(0, _wordpress_i18n._x)("EB", "unit symbol")]: EB_IN_BYTES,
|
|
37
|
+
[(0, _wordpress_i18n._x)("PB", "unit symbol")]: PB_IN_BYTES,
|
|
38
|
+
[(0, _wordpress_i18n._x)("TB", "unit symbol")]: TB_IN_BYTES,
|
|
39
|
+
[(0, _wordpress_i18n._x)("GB", "unit symbol")]: GB_IN_BYTES,
|
|
40
|
+
[(0, _wordpress_i18n._x)("MB", "unit symbol")]: MB_IN_BYTES,
|
|
41
|
+
[(0, _wordpress_i18n._x)("KB", "unit symbol")]: KB_IN_BYTES,
|
|
42
|
+
[(0, _wordpress_i18n._x)("B", "unit symbol")]: 1
|
|
43
|
+
};
|
|
44
|
+
for (const [unit, mag] of Object.entries(quant)) if (bytes >= mag) return getBytesString(bytes / mag, unit, decimals);
|
|
45
|
+
return "";
|
|
76
46
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
47
|
+
const filesizeField = {
|
|
48
|
+
id: "filesize",
|
|
49
|
+
type: "text",
|
|
50
|
+
label: (0, _wordpress_i18n.__)("File size"),
|
|
51
|
+
getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
|
|
52
|
+
isVisible: (item) => {
|
|
53
|
+
return !!item?.media_details?.filesize;
|
|
54
|
+
},
|
|
55
|
+
enableSorting: false,
|
|
56
|
+
filterBy: false,
|
|
57
|
+
readOnly: true
|
|
88
58
|
};
|
|
89
|
-
|
|
90
|
-
|
|
59
|
+
exports.default = filesizeField;
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/filesize/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __, sprintf, _x } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nconst KB_IN_BYTES = 1024;\nconst MB_IN_BYTES = 1024 * KB_IN_BYTES;\nconst GB_IN_BYTES = 1024 * MB_IN_BYTES;\nconst TB_IN_BYTES = 1024 * GB_IN_BYTES;\nconst PB_IN_BYTES = 1024 * TB_IN_BYTES;\nconst EB_IN_BYTES = 1024 * PB_IN_BYTES;\nconst ZB_IN_BYTES = 1024 * EB_IN_BYTES;\nconst YB_IN_BYTES = 1024 * ZB_IN_BYTES;\n\nfunction getBytesString(\n\tbytes: number,\n\tunitSymbol: string,\n\tdecimals = 2\n): string {\n\treturn sprintf(\n\t\t// translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).\n\t\t_x( '%1$s %2$s', 'file size' ),\n\t\tbytes.toLocaleString( undefined, {\n\t\t\tminimumFractionDigits: 0,\n\t\t\tmaximumFractionDigits: decimals,\n\t\t} ),\n\t\tunitSymbol\n\t);\n}\n\n/**\n * Converts bytes to a human-readable file size string with a specified number of decimal places.\n *\n * This logic is comparable to core's `size_format()` function.\n *\n * @param bytes The size in bytes.\n * @param decimals The number of decimal places to include in the result.\n * @return The human-readable file size string.\n */\nfunction formatFileSize( bytes: number, decimals = 2 ): string {\n\tif ( bytes === 0 ) {\n\t\treturn getBytesString( 0, _x( 'B', 'unit symbol' ), decimals );\n\t}\n\tconst quant = {\n\t\t/* translators: Unit symbol for yottabyte. */\n\t\t[ _x( 'YB', 'unit symbol' ) ]: YB_IN_BYTES,\n\t\t/* translators: Unit symbol for zettabyte. */\n\t\t[ _x( 'ZB', 'unit symbol' ) ]: ZB_IN_BYTES,\n\t\t/* translators: Unit symbol for exabyte. */\n\t\t[ _x( 'EB', 'unit symbol' ) ]: EB_IN_BYTES,\n\t\t/* translators: Unit symbol for petabyte. */\n\t\t[ _x( 'PB', 'unit symbol' ) ]: PB_IN_BYTES,\n\t\t/* translators: Unit symbol for terabyte. */\n\t\t[ _x( 'TB', 'unit symbol' ) ]: TB_IN_BYTES,\n\t\t/* translators: Unit symbol for gigabyte. */\n\t\t[ _x( 'GB', 'unit symbol' ) ]: GB_IN_BYTES,\n\t\t/* translators: Unit symbol for megabyte. */\n\t\t[ _x( 'MB', 'unit symbol' ) ]: MB_IN_BYTES,\n\t\t/* translators: Unit symbol for kilobyte. */\n\t\t[ _x( 'KB', 'unit symbol' ) ]: KB_IN_BYTES,\n\t\t/* translators: Unit symbol for byte. */\n\t\t[ _x( 'B', 'unit symbol' ) ]: 1,\n\t};\n\n\tfor ( const [ unit, mag ] of Object.entries( quant ) ) {\n\t\tif ( bytes >= mag ) {\n\t\t\treturn getBytesString( bytes / mag, unit, decimals );\n\t\t}\n\t}\n\n\treturn ''; // Fallback in case no unit matches, though this should not happen.\n}\n\nconst filesizeField: Partial< Field< MediaItem > > = {\n\tid: 'filesize',\n\ttype: 'text',\n\tlabel: __( 'File size' ),\n\tgetValue: ( { item }: { item: MediaItem } ) =>\n\t\titem?.media_details?.filesize\n\t\t\t? formatFileSize( item?.media_details?.filesize )\n\t\t\t: '',\n\tisVisible: ( item: MediaItem ) => {\n\t\treturn !! item?.media_details?.filesize;\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n\treadOnly: true,\n};\n\nexport default filesizeField;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC;AAIhC,IAAM,cAAc;AACpB,IAAM,cAAc,OAAO;AAC3B,IAAM,cAAc,OAAO;AAC3B,IAAM,cAAc,OAAO;AAC3B,IAAM,cAAc,OAAO;AAC3B,IAAM,cAAc,OAAO;AAC3B,IAAM,cAAc,OAAO;AAC3B,IAAM,cAAc,OAAO;AAE3B,SAAS,eACR,OACA,YACA,WAAW,GACF;AACT,aAAO;AAAA;AAAA,QAEN,gBAAI,aAAa,WAAY;AAAA,IAC7B,MAAM,eAAgB,QAAW;AAAA,MAChC,uBAAuB;AAAA,MACvB,uBAAuB;AAAA,IACxB,CAAE;AAAA,IACF;AAAA,EACD;AACD;AAWA,SAAS,eAAgB,OAAe,WAAW,GAAY;AAC9D,MAAK,UAAU,GAAI;AAClB,WAAO,eAAgB,OAAG,gBAAI,KAAK,aAAc,GAAG,QAAS;AAAA,EAC9D;AACA,QAAM,QAAQ;AAAA;AAAA,IAEb,KAAE,gBAAI,MAAM,aAAc,CAAE,GAAG;AAAA;AAAA,IAE/B,KAAE,gBAAI,MAAM,aAAc,CAAE,GAAG;AAAA;AAAA,IAE/B,KAAE,gBAAI,MAAM,aAAc,CAAE,GAAG;AAAA;AAAA,IAE/B,KAAE,gBAAI,MAAM,aAAc,CAAE,GAAG;AAAA;AAAA,IAE/B,KAAE,gBAAI,MAAM,aAAc,CAAE,GAAG;AAAA;AAAA,IAE/B,KAAE,gBAAI,MAAM,aAAc,CAAE,GAAG;AAAA;AAAA,IAE/B,KAAE,gBAAI,MAAM,aAAc,CAAE,GAAG;AAAA;AAAA,IAE/B,KAAE,gBAAI,MAAM,aAAc,CAAE,GAAG;AAAA;AAAA,IAE/B,KAAE,gBAAI,KAAK,aAAc,CAAE,GAAG;AAAA,EAC/B;AAEA,aAAY,CAAE,MAAM,GAAI,KAAK,OAAO,QAAS,KAAM,GAAI;AACtD,QAAK,SAAS,KAAM;AACnB,aAAO,eAAgB,QAAQ,KAAK,MAAM,QAAS;AAAA,IACpD;AAAA,EACD;AAEA,SAAO;AACR;AAEA,IAAM,gBAA+C;AAAA,EACpD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,WAAY;AAAA,EACvB,UAAU,CAAE,EAAE,KAAK,MAClB,MAAM,eAAe,WAClB,eAAgB,MAAM,eAAe,QAAS,IAC9C;AAAA,EACJ,WAAW,CAAE,SAAqB;AACjC,WAAO,CAAC,CAAE,MAAM,eAAe;AAAA,EAChC;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AACX;AAEA,IAAO,mBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["sprintf","_x","__"],"sources":["../../src/filesize/index.tsx"],"sourcesContent":["import { __, sprintf, _x } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nconst KB_IN_BYTES = 1024;\nconst MB_IN_BYTES = 1024 * KB_IN_BYTES;\nconst GB_IN_BYTES = 1024 * MB_IN_BYTES;\nconst TB_IN_BYTES = 1024 * GB_IN_BYTES;\nconst PB_IN_BYTES = 1024 * TB_IN_BYTES;\nconst EB_IN_BYTES = 1024 * PB_IN_BYTES;\nconst ZB_IN_BYTES = 1024 * EB_IN_BYTES;\nconst YB_IN_BYTES = 1024 * ZB_IN_BYTES;\n\nfunction getBytesString(\n\tbytes: number,\n\tunitSymbol: string,\n\tdecimals = 2\n): string {\n\treturn sprintf(\n\t\t// translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).\n\t\t_x( '%1$s %2$s', 'file size' ),\n\t\tbytes.toLocaleString( undefined, {\n\t\t\tminimumFractionDigits: 0,\n\t\t\tmaximumFractionDigits: decimals,\n\t\t} ),\n\t\tunitSymbol\n\t);\n}\n\n/**\n * Converts bytes to a human-readable file size string with a specified number of decimal places.\n *\n * This logic is comparable to core's `size_format()` function.\n *\n * @param bytes The size in bytes.\n * @param decimals The number of decimal places to include in the result.\n * @return The human-readable file size string.\n */\nfunction formatFileSize( bytes: number, decimals = 2 ): string {\n\tif ( bytes === 0 ) {\n\t\treturn getBytesString( 0, _x( 'B', 'unit symbol' ), decimals );\n\t}\n\tconst quant = {\n\t\t/* translators: Unit symbol for yottabyte. */\n\t\t[ _x( 'YB', 'unit symbol' ) ]: YB_IN_BYTES,\n\t\t/* translators: Unit symbol for zettabyte. */\n\t\t[ _x( 'ZB', 'unit symbol' ) ]: ZB_IN_BYTES,\n\t\t/* translators: Unit symbol for exabyte. */\n\t\t[ _x( 'EB', 'unit symbol' ) ]: EB_IN_BYTES,\n\t\t/* translators: Unit symbol for petabyte. */\n\t\t[ _x( 'PB', 'unit symbol' ) ]: PB_IN_BYTES,\n\t\t/* translators: Unit symbol for terabyte. */\n\t\t[ _x( 'TB', 'unit symbol' ) ]: TB_IN_BYTES,\n\t\t/* translators: Unit symbol for gigabyte. */\n\t\t[ _x( 'GB', 'unit symbol' ) ]: GB_IN_BYTES,\n\t\t/* translators: Unit symbol for megabyte. */\n\t\t[ _x( 'MB', 'unit symbol' ) ]: MB_IN_BYTES,\n\t\t/* translators: Unit symbol for kilobyte. */\n\t\t[ _x( 'KB', 'unit symbol' ) ]: KB_IN_BYTES,\n\t\t/* translators: Unit symbol for byte. */\n\t\t[ _x( 'B', 'unit symbol' ) ]: 1,\n\t};\n\n\tfor ( const [ unit, mag ] of Object.entries( quant ) ) {\n\t\tif ( bytes >= mag ) {\n\t\t\treturn getBytesString( bytes / mag, unit, decimals );\n\t\t}\n\t}\n\n\treturn ''; // Fallback in case no unit matches, though this should not happen.\n}\n\nconst filesizeField: Partial< Field< MediaItem > > = {\n\tid: 'filesize',\n\ttype: 'text',\n\tlabel: __( 'File size' ),\n\tgetValue: ( { item }: { item: MediaItem } ) =>\n\t\titem?.media_details?.filesize\n\t\t\t? formatFileSize( item?.media_details?.filesize )\n\t\t\t: '',\n\tisVisible: ( item: MediaItem ) => {\n\t\treturn !! item?.media_details?.filesize;\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n\treadOnly: true,\n};\n\nexport default filesizeField;\n"],"mappings":";;;;;;;AAIA,MAAM,cAAc;AACpB,MAAM,cAAc,OAAO;AAC3B,MAAM,cAAc,OAAO;AAC3B,MAAM,cAAc,OAAO;AAC3B,MAAM,cAAc,OAAO;AAC3B,MAAM,cAAc,OAAO;AAC3B,MAAM,cAAc,OAAO;AAC3B,MAAM,cAAc,OAAO;AAE3B,SAAS,eACR,OACA,YACA,WAAW,GACF;CACT,QAAA,GAAOA,gBAAAA,QAAAA,EAAAA,GAENC,gBAAAA,GAAAA,CAAI,aAAa,WAAY,GAC7B,MAAM,eAAgB,KAAA,GAAW;EAChC,uBAAuB;EACvB,uBAAuB;CACxB,CAAE,GACF,UACD;AACD;;;;;;;;;;AAWA,SAAS,eAAgB,OAAe,WAAW,GAAY;CAC9D,IAAK,UAAU,GACd,OAAO,eAAgB,IAAA,GAAGA,gBAAAA,GAAAA,CAAI,KAAK,aAAc,GAAG,QAAS;CAE9D,MAAM,QAAQ;IAEXA,GAAAA,gBAAAA,GAAAA,CAAI,MAAM,aAAc,IAAK;IAE7BA,GAAAA,gBAAAA,GAAAA,CAAI,MAAM,aAAc,IAAK;IAE7BA,GAAAA,gBAAAA,GAAAA,CAAI,MAAM,aAAc,IAAK;IAE7BA,GAAAA,gBAAAA,GAAAA,CAAI,MAAM,aAAc,IAAK;IAE7BA,GAAAA,gBAAAA,GAAAA,CAAI,MAAM,aAAc,IAAK;IAE7BA,GAAAA,gBAAAA,GAAAA,CAAI,MAAM,aAAc,IAAK;IAE7BA,GAAAA,gBAAAA,GAAAA,CAAI,MAAM,aAAc,IAAK;IAE7BA,GAAAA,gBAAAA,GAAAA,CAAI,MAAM,aAAc,IAAK;IAE7BA,GAAAA,gBAAAA,GAAAA,CAAI,KAAK,aAAc,IAAK;CAC/B;CAEA,KAAM,MAAM,CAAE,MAAM,QAAS,OAAO,QAAS,KAAM,GAClD,IAAK,SAAS,KACb,OAAO,eAAgB,QAAQ,KAAK,MAAM,QAAS;CAIrD,OAAO;AACR;AAEA,MAAM,gBAA+C;CACpD,IAAI;CACJ,MAAM;CACN,QAAA,GAAOC,gBAAAA,GAAAA,CAAI,WAAY;CACvB,WAAY,EAAE,WACb,MAAM,eAAe,WAClB,eAAgB,MAAM,eAAe,QAAS,IAC9C;CACJ,YAAa,SAAqB;EACjC,OAAO,CAAC,CAAE,MAAM,eAAe;CAChC;CACA,eAAe;CACf,UAAU;CACV,UAAU;AACX"}
|
package/build/index.cjs
CHANGED
|
@@ -1,74 +1,122 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
2
7
|
var __create = Object.create;
|
|
3
8
|
var __defProp = Object.defineProperty;
|
|
4
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
13
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
19
22
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let __alt_text_index_tsx = require("./alt_text/index.cjs");
|
|
28
|
+
__alt_text_index_tsx = __toESM(__alt_text_index_tsx);
|
|
29
|
+
let __attached_to_index_tsx = require("./attached_to/index.cjs");
|
|
30
|
+
__attached_to_index_tsx = __toESM(__attached_to_index_tsx);
|
|
31
|
+
let __author_index_tsx = require("./author/index.cjs");
|
|
32
|
+
__author_index_tsx = __toESM(__author_index_tsx);
|
|
33
|
+
let __caption_index_tsx = require("./caption/index.cjs");
|
|
34
|
+
__caption_index_tsx = __toESM(__caption_index_tsx);
|
|
35
|
+
let __date_added_index_tsx = require("./date_added/index.cjs");
|
|
36
|
+
__date_added_index_tsx = __toESM(__date_added_index_tsx);
|
|
37
|
+
let __date_modified_index_tsx = require("./date_modified/index.cjs");
|
|
38
|
+
__date_modified_index_tsx = __toESM(__date_modified_index_tsx);
|
|
39
|
+
let __description_index_tsx = require("./description/index.cjs");
|
|
40
|
+
__description_index_tsx = __toESM(__description_index_tsx);
|
|
41
|
+
let __filename_index_ts = require("./filename/index.cjs");
|
|
42
|
+
__filename_index_ts = __toESM(__filename_index_ts);
|
|
43
|
+
let __filesize_index_tsx = require("./filesize/index.cjs");
|
|
44
|
+
__filesize_index_tsx = __toESM(__filesize_index_tsx);
|
|
45
|
+
let __media_dimensions_index_ts = require("./media_dimensions/index.cjs");
|
|
46
|
+
__media_dimensions_index_ts = __toESM(__media_dimensions_index_ts);
|
|
47
|
+
let __media_thumbnail_index_tsx = require("./media_thumbnail/index.cjs");
|
|
48
|
+
__media_thumbnail_index_tsx = __toESM(__media_thumbnail_index_tsx);
|
|
49
|
+
let __mime_type_index_ts = require("./mime_type/index.cjs");
|
|
50
|
+
__mime_type_index_ts = __toESM(__mime_type_index_ts);
|
|
51
|
+
Object.defineProperty(exports, "altTextField", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function() {
|
|
54
|
+
return __alt_text_index_tsx.default;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports, "attachedToField", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function() {
|
|
60
|
+
return __attached_to_index_tsx.default;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "authorField", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function() {
|
|
66
|
+
return __author_index_tsx.default;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "captionField", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function() {
|
|
72
|
+
return __caption_index_tsx.default;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, "dateAddedField", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function() {
|
|
78
|
+
return __date_added_index_tsx.default;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "dateModifiedField", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function() {
|
|
84
|
+
return __date_modified_index_tsx.default;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "descriptionField", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function() {
|
|
90
|
+
return __description_index_tsx.default;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "filenameField", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function() {
|
|
96
|
+
return __filename_index_ts.default;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, "filesizeField", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function() {
|
|
102
|
+
return __filesize_index_tsx.default;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, "mediaDimensionsField", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function() {
|
|
108
|
+
return __media_dimensions_index_ts.default;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(exports, "mediaThumbnailField", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get: function() {
|
|
114
|
+
return __media_thumbnail_index_tsx.default;
|
|
115
|
+
}
|
|
45
116
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var import_date_added = __toESM(require("./date_added/index.cjs"));
|
|
52
|
-
var import_date_modified = __toESM(require("./date_modified/index.cjs"));
|
|
53
|
-
var import_description = __toESM(require("./description/index.cjs"));
|
|
54
|
-
var import_filename = __toESM(require("./filename/index.cjs"));
|
|
55
|
-
var import_filesize = __toESM(require("./filesize/index.cjs"));
|
|
56
|
-
var import_media_dimensions = __toESM(require("./media_dimensions/index.cjs"));
|
|
57
|
-
var import_media_thumbnail = __toESM(require("./media_thumbnail/index.cjs"));
|
|
58
|
-
var import_mime_type = __toESM(require("./mime_type/index.cjs"));
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
altTextField,
|
|
62
|
-
attachedToField,
|
|
63
|
-
authorField,
|
|
64
|
-
captionField,
|
|
65
|
-
dateAddedField,
|
|
66
|
-
dateModifiedField,
|
|
67
|
-
descriptionField,
|
|
68
|
-
filenameField,
|
|
69
|
-
filesizeField,
|
|
70
|
-
mediaDimensionsField,
|
|
71
|
-
mediaThumbnailField,
|
|
72
|
-
mimeTypeField
|
|
117
|
+
Object.defineProperty(exports, "mimeTypeField", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function() {
|
|
120
|
+
return __mime_type_index_ts.default;
|
|
121
|
+
}
|
|
73
122
|
});
|
|
74
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,45 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/media-fields/src/media_dimensions/index.ts
|
|
21
|
-
var media_dimensions_exports = {};
|
|
22
|
-
__export(media_dimensions_exports, {
|
|
23
|
-
default: () => media_dimensions_default
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
5
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return !!(item?.media_details?.width && item?.media_details?.height);
|
|
39
|
-
},
|
|
40
|
-
enableSorting: false,
|
|
41
|
-
filterBy: false,
|
|
42
|
-
readOnly: true
|
|
6
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
7
|
+
// packages/media-fields/src/media_dimensions/index.ts
|
|
8
|
+
const mediaDimensionsField = {
|
|
9
|
+
id: "media_dimensions",
|
|
10
|
+
type: "text",
|
|
11
|
+
label: (0, _wordpress_i18n.__)("Dimensions"),
|
|
12
|
+
getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._x)("%1$s × %2$s", "image dimensions"), item?.media_details?.width?.toString(), item?.media_details?.height?.toString()) : "",
|
|
13
|
+
isVisible: (item) => {
|
|
14
|
+
return !!(item?.media_details?.width && item?.media_details?.height);
|
|
15
|
+
},
|
|
16
|
+
enableSorting: false,
|
|
17
|
+
filterBy: false,
|
|
18
|
+
readOnly: true
|
|
43
19
|
};
|
|
44
|
-
|
|
45
|
-
|
|
20
|
+
exports.default = mediaDimensionsField;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.cjs.map
|