@wordpress/media-fields 0.1.1-next.6deb34194.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.
Files changed (117) hide show
  1. package/LICENSE.md +788 -0
  2. package/README.md +52 -0
  3. package/build/alt_text/index.js +51 -0
  4. package/build/alt_text/index.js.map +7 -0
  5. package/build/caption/index.js +52 -0
  6. package/build/caption/index.js.map +7 -0
  7. package/build/description/index.js +52 -0
  8. package/build/description/index.js.map +7 -0
  9. package/build/filename/index.js +50 -0
  10. package/build/filename/index.js.map +7 -0
  11. package/build/filename/view.js +43 -0
  12. package/build/filename/view.js.map +7 -0
  13. package/build/filesize/index.js +90 -0
  14. package/build/filesize/index.js.map +7 -0
  15. package/build/index.js +62 -0
  16. package/build/index.js.map +7 -0
  17. package/build/media_dimensions/index.js +45 -0
  18. package/build/media_dimensions/index.js.map +7 -0
  19. package/build/media_thumbnail/index.js +47 -0
  20. package/build/media_thumbnail/index.js.map +7 -0
  21. package/build/media_thumbnail/view.js +94 -0
  22. package/build/media_thumbnail/view.js.map +7 -0
  23. package/build/mime_type/index.js +38 -0
  24. package/build/mime_type/index.js.map +7 -0
  25. package/build/types.js +19 -0
  26. package/build/types.js.map +7 -0
  27. package/build/utils/get-media-type-from-mime-type.js +60 -0
  28. package/build/utils/get-media-type-from-mime-type.js.map +7 -0
  29. package/build/utils/get-raw-content.js +42 -0
  30. package/build/utils/get-raw-content.js.map +7 -0
  31. package/build/utils/get-rendered-content.js +42 -0
  32. package/build/utils/get-rendered-content.js.map +7 -0
  33. package/build-module/alt_text/index.js +30 -0
  34. package/build-module/alt_text/index.js.map +7 -0
  35. package/build-module/caption/index.js +31 -0
  36. package/build-module/caption/index.js.map +7 -0
  37. package/build-module/description/index.js +31 -0
  38. package/build-module/description/index.js.map +7 -0
  39. package/build-module/filename/index.js +19 -0
  40. package/build-module/filename/index.js.map +7 -0
  41. package/build-module/filename/view.js +25 -0
  42. package/build-module/filename/view.js.map +7 -0
  43. package/build-module/filesize/index.js +69 -0
  44. package/build-module/filesize/index.js.map +7 -0
  45. package/build-module/index.js +20 -0
  46. package/build-module/index.js.map +7 -0
  47. package/build-module/media_dimensions/index.js +24 -0
  48. package/build-module/media_dimensions/index.js.map +7 -0
  49. package/build-module/media_thumbnail/index.js +16 -0
  50. package/build-module/media_thumbnail/index.js.map +7 -0
  51. package/build-module/media_thumbnail/view.js +77 -0
  52. package/build-module/media_thumbnail/view.js.map +7 -0
  53. package/build-module/mime_type/index.js +17 -0
  54. package/build-module/mime_type/index.js.map +7 -0
  55. package/build-module/types.js +1 -0
  56. package/build-module/types.js.map +7 -0
  57. package/build-module/utils/get-media-type-from-mime-type.js +35 -0
  58. package/build-module/utils/get-media-type-from-mime-type.js.map +7 -0
  59. package/build-module/utils/get-raw-content.js +17 -0
  60. package/build-module/utils/get-raw-content.js.map +7 -0
  61. package/build-module/utils/get-rendered-content.js +17 -0
  62. package/build-module/utils/get-rendered-content.js.map +7 -0
  63. package/build-style/style-rtl.css +130 -0
  64. package/build-style/style.css +130 -0
  65. package/build-types/alt_text/index.d.ts +5 -0
  66. package/build-types/alt_text/index.d.ts.map +1 -0
  67. package/build-types/caption/index.d.ts +5 -0
  68. package/build-types/caption/index.d.ts.map +1 -0
  69. package/build-types/description/index.d.ts +5 -0
  70. package/build-types/description/index.d.ts.map +1 -0
  71. package/build-types/filename/index.d.ts +8 -0
  72. package/build-types/filename/index.d.ts.map +1 -0
  73. package/build-types/filename/view.d.ts +7 -0
  74. package/build-types/filename/view.d.ts.map +1 -0
  75. package/build-types/filesize/index.d.ts +8 -0
  76. package/build-types/filesize/index.d.ts.map +1 -0
  77. package/build-types/index.d.ts +10 -0
  78. package/build-types/index.d.ts.map +1 -0
  79. package/build-types/media_dimensions/index.d.ts +5 -0
  80. package/build-types/media_dimensions/index.d.ts.map +1 -0
  81. package/build-types/media_thumbnail/index.d.ts +8 -0
  82. package/build-types/media_thumbnail/index.d.ts.map +1 -0
  83. package/build-types/media_thumbnail/view.d.ts +4 -0
  84. package/build-types/media_thumbnail/view.d.ts.map +1 -0
  85. package/build-types/mime_type/index.d.ts +5 -0
  86. package/build-types/mime_type/index.d.ts.map +1 -0
  87. package/build-types/stories/index.story.d.ts +25 -0
  88. package/build-types/stories/index.story.d.ts.map +1 -0
  89. package/build-types/types.d.ts +18 -0
  90. package/build-types/types.d.ts.map +1 -0
  91. package/build-types/utils/get-media-type-from-mime-type.d.ts +18 -0
  92. package/build-types/utils/get-media-type-from-mime-type.d.ts.map +1 -0
  93. package/build-types/utils/get-raw-content.d.ts +17 -0
  94. package/build-types/utils/get-raw-content.d.ts.map +1 -0
  95. package/build-types/utils/get-rendered-content.d.ts +17 -0
  96. package/build-types/utils/get-rendered-content.d.ts.map +1 -0
  97. package/package.json +61 -0
  98. package/src/alt_text/index.tsx +30 -0
  99. package/src/caption/index.tsx +35 -0
  100. package/src/description/index.tsx +37 -0
  101. package/src/filename/index.ts +26 -0
  102. package/src/filename/view.tsx +39 -0
  103. package/src/filesize/index.tsx +96 -0
  104. package/src/index.ts +15 -0
  105. package/src/media_dimensions/index.ts +29 -0
  106. package/src/media_thumbnail/index.tsx +22 -0
  107. package/src/media_thumbnail/style.scss +49 -0
  108. package/src/media_thumbnail/view.tsx +104 -0
  109. package/src/mime_type/index.ts +19 -0
  110. package/src/stories/index.story.tsx +290 -0
  111. package/src/style.scss +1 -0
  112. package/src/types.ts +24 -0
  113. package/src/utils/get-media-type-from-mime-type.ts +54 -0
  114. package/src/utils/get-raw-content.ts +32 -0
  115. package/src/utils/get-rendered-content.ts +32 -0
  116. package/tsconfig.json +31 -0
  117. package/tsconfig.tsbuildinfo +1 -0
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Media Fields
2
+
3
+ This package provides reusable field definitions for displaying and editing media attachment properties in WordPress DataViews. It's primarily intended for internal use within Gutenberg and may change significantly between releases.
4
+
5
+ ## Usage
6
+
7
+ ### Available Fields
8
+
9
+ This package exports field definitions for common media attachment properties:
10
+
11
+ - `altTextField` - Alternative text for images
12
+ - `captionField` - Media caption text
13
+ - `descriptionField` - Detailed description
14
+ - `filenameField` - File name (read-only)
15
+ - `filesizeField` - File size with human-readable formatting
16
+ - `mediaDimensionsField` - Image dimensions (width × height)
17
+ - `mediaThumbnailField` - Thumbnail preview
18
+ - `mimeTypeField` - MIME type display
19
+
20
+ ### Using Media Fields in DataViews
21
+
22
+ ```jsx
23
+ import {
24
+ altTextField,
25
+ captionField,
26
+ filesizeField,
27
+ } from '@wordpress/media-fields';
28
+ import { DataViews } from '@wordpress/dataviews';
29
+
30
+ const fields = [
31
+ altTextField,
32
+ captionField,
33
+ filesizeField,
34
+ ];
35
+
36
+ export function MyMediaLibrary( { items } ) {
37
+ return (
38
+ <DataViews
39
+ data={ items }
40
+ fields={ fields }
41
+ view={ view }
42
+ onChangeView={ setView }
43
+ />
44
+ );
45
+ }
46
+ ```
47
+
48
+ ## Contributing to this package
49
+
50
+ This package is part of the Gutenberg project. To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
51
+
52
+ <br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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/alt_text/index.tsx
21
+ var alt_text_exports = {};
22
+ __export(alt_text_exports, {
23
+ default: () => alt_text_default
24
+ });
25
+ module.exports = __toCommonJS(alt_text_exports);
26
+ var import_i18n = require("@wordpress/i18n");
27
+ var import_components = require("@wordpress/components");
28
+ var import_jsx_runtime = require("react/jsx-runtime");
29
+ var altTextField = {
30
+ id: "alt_text",
31
+ type: "text",
32
+ label: (0, import_i18n.__)("Alt text"),
33
+ isVisible: (item) => item?.media_type === "image",
34
+ render: ({ item }) => item?.alt_text || "-",
35
+ Edit: ({ field, onChange, data }) => {
36
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
37
+ import_components.TextareaControl,
38
+ {
39
+ label: field.label,
40
+ value: data.alt_text || "",
41
+ onChange: (value) => onChange({ alt_text: value }),
42
+ rows: 2,
43
+ __nextHasNoMarginBottom: true
44
+ }
45
+ );
46
+ },
47
+ enableSorting: false,
48
+ filterBy: false
49
+ };
50
+ var alt_text_default = altTextField;
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/alt_text/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextareaControl } from '@wordpress/components';\nimport type { Field } from '@wordpress/dataviews';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\n\nconst altTextField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'alt_text',\n\ttype: 'text',\n\tlabel: __( 'Alt text' ),\n\tisVisible: ( item ) => item?.media_type === 'image',\n\trender: ( { item } ) => item?.alt_text || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<TextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ data.alt_text || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { alt_text: value } ) }\n\t\t\t\trows={ 2 }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default altTextField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,wBAAgC;AAY7B;AARH,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,UAAW;AAAA,EACtB,WAAW,CAAE,SAAU,MAAM,eAAe;AAAA,EAC5C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,YAAY;AAAA,EAC1C,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,OAAQ,KAAK,YAAY;AAAA,QACzB,UAAW,CAAE,UAAW,SAAU,EAAE,UAAU,MAAM,CAAE;AAAA,QACtD,MAAO;AAAA,QACP,yBAAuB;AAAA;AAAA,IACxB;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,mBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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/caption/index.tsx
21
+ var caption_exports = {};
22
+ __export(caption_exports, {
23
+ default: () => caption_default
24
+ });
25
+ module.exports = __toCommonJS(caption_exports);
26
+ var import_i18n = require("@wordpress/i18n");
27
+ var import_components = require("@wordpress/components");
28
+ var import_get_raw_content = require("../utils/get-raw-content");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var captionField = {
31
+ id: "caption",
32
+ type: "text",
33
+ label: (0, import_i18n.__)("Caption"),
34
+ getValue: ({ item }) => (0, import_get_raw_content.getRawContent)(item?.caption),
35
+ render: ({ item }) => (0, import_get_raw_content.getRawContent)(item?.caption) || "-",
36
+ Edit: ({ field, onChange, data }) => {
37
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
38
+ import_components.TextareaControl,
39
+ {
40
+ label: field.label,
41
+ value: (0, import_get_raw_content.getRawContent)(data.caption) || "",
42
+ onChange: (value) => onChange({ caption: value }),
43
+ rows: 2,
44
+ __nextHasNoMarginBottom: true
45
+ }
46
+ );
47
+ },
48
+ enableSorting: false,
49
+ filterBy: false
50
+ };
51
+ var caption_default = captionField;
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/caption/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextareaControl } from '@wordpress/components';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\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: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<TextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ getRawContent( data.caption ) || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { caption: value } ) }\n\t\t\t\trows={ 2 }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,wBAAgC;AAOhC,6BAA8B;AAU3B;AARH,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,SAAU;AAAA,EACrB,UAAU,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,OAAQ;AAAA,EACvD,QAAQ,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,OAAQ,KAAK;AAAA,EAC1D,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,WAAQ,sCAAe,KAAK,OAAQ,KAAK;AAAA,QACzC,UAAW,CAAE,UAAW,SAAU,EAAE,SAAS,MAAM,CAAE;AAAA,QACrD,MAAO;AAAA,QACP,yBAAuB;AAAA;AAAA,IACxB;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,kBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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/description/index.tsx
21
+ var description_exports = {};
22
+ __export(description_exports, {
23
+ default: () => description_default
24
+ });
25
+ module.exports = __toCommonJS(description_exports);
26
+ var import_i18n = require("@wordpress/i18n");
27
+ var import_components = require("@wordpress/components");
28
+ var import_get_raw_content = require("../utils/get-raw-content");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var descriptionField = {
31
+ id: "description",
32
+ type: "text",
33
+ label: (0, import_i18n.__)("Description"),
34
+ getValue: ({ item }) => (0, import_get_raw_content.getRawContent)(item?.description),
35
+ render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: (0, import_get_raw_content.getRawContent)(item?.description) || "-" }),
36
+ Edit: ({ field, onChange, data }) => {
37
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
38
+ import_components.TextareaControl,
39
+ {
40
+ label: field.label,
41
+ value: (0, import_get_raw_content.getRawContent)(data.description) || "",
42
+ onChange: (value) => onChange({ description: value }),
43
+ rows: 5,
44
+ __nextHasNoMarginBottom: true
45
+ }
46
+ );
47
+ },
48
+ enableSorting: false,
49
+ filterBy: false
50
+ };
51
+ var description_default = descriptionField;
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/description/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextareaControl } from '@wordpress/components';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\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: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<TextareaControl\n\t\t\t\tlabel={ field.label }\n\t\t\t\tvalue={ getRawContent( data.description ) || '' }\n\t\t\t\tonChange={ ( value ) => onChange( { description: value } ) }\n\t\t\t\trows={ 5 }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,wBAAgC;AAOhC,6BAA8B;AAQ5B;AANF,IAAM,mBAAgE;AAAA,EACrE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,aAAc;AAAA,EACzB,UAAU,CAAE,EAAE,KAAK,UAAO,sCAAe,MAAM,WAAY;AAAA,EAC3D,QAAQ,CAAE,EAAE,KAAK,MAChB,4CAAC,SAAM,oDAAe,MAAM,WAAY,KAAK,KAAK;AAAA,EAEnD,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,WAAQ,sCAAe,KAAK,WAAY,KAAK;AAAA,QAC7C,UAAW,CAAE,UAAW,SAAU,EAAE,aAAa,MAAM,CAAE;AAAA,QACzD,MAAO;AAAA,QACP,yBAAuB;AAAA;AAAA,IACxB;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ 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
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/media-fields/src/filename/index.ts
31
+ var filename_exports = {};
32
+ __export(filename_exports, {
33
+ default: () => filename_default
34
+ });
35
+ module.exports = __toCommonJS(filename_exports);
36
+ var import_i18n = require("@wordpress/i18n");
37
+ var import_url = require("@wordpress/url");
38
+ var import_view = __toESM(require("./view"));
39
+ var filenameField = {
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
48
+ };
49
+ var filename_default = filenameField;
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/filename/index.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\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;AAGA,kBAAmB;AACnB,iBAA4B;AAO5B,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
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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
24
+ });
25
+ module.exports = __toCommonJS(view_exports);
26
+ var import_components = require("@wordpress/components");
27
+ var import_element = require("@wordpress/element");
28
+ var import_url = require("@wordpress/url");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var TRUNCATE_LENGTH = 15;
31
+ function FileNameView({
32
+ item
33
+ }) {
34
+ const fileName = (0, import_element.useMemo)(
35
+ () => item?.source_url ? (0, import_url.getFilename)(item.source_url) : null,
36
+ [item?.source_url]
37
+ );
38
+ if (!fileName) {
39
+ return "";
40
+ }
41
+ return fileName.length > TRUNCATE_LENGTH ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Tooltip, { text: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalTruncate, { children: fileName }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: fileName });
42
+ }
43
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/filename/view.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tTooltip,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\n\n// Hard-coded truncate length to match the available area in the media sidebar.\n// Longer file names will be truncated and wrapped in a tooltip showing the full name.\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\treturn fileName.length > TRUNCATE_LENGTH ? (\n\t\t<Tooltip text={ fileName }>\n\t\t\t<Truncate>{ fileName }</Truncate>\n\t\t</Tooltip>\n\t) : (\n\t\t<>{ fileName }</>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AACP,qBAAwB;AACxB,iBAA4B;AAyBzB;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,SAAO,SAAS,SAAS,kBACxB,4CAAC,6BAAQ,MAAO,UACf,sDAAC,kBAAAA,wBAAA,EAAW,oBAAU,GACvB,IAEA,2EAAI,oBAAU;AAEhB;",
6
+ "names": ["Truncate"]
7
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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
24
+ });
25
+ module.exports = __toCommonJS(filesize_exports);
26
+ var import_i18n = require("@wordpress/i18n");
27
+ var KB_IN_BYTES = 1024;
28
+ var MB_IN_BYTES = 1024 * KB_IN_BYTES;
29
+ var GB_IN_BYTES = 1024 * MB_IN_BYTES;
30
+ var TB_IN_BYTES = 1024 * GB_IN_BYTES;
31
+ var PB_IN_BYTES = 1024 * TB_IN_BYTES;
32
+ var EB_IN_BYTES = 1024 * PB_IN_BYTES;
33
+ var ZB_IN_BYTES = 1024 * EB_IN_BYTES;
34
+ var YB_IN_BYTES = 1024 * ZB_IN_BYTES;
35
+ function getBytesString(bytes, unitSymbol, decimals = 2) {
36
+ return (0, import_i18n.sprintf)(
37
+ // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).
38
+ (0, import_i18n._x)("%1$s %2$s", "file size"),
39
+ bytes.toLocaleString(void 0, {
40
+ minimumFractionDigits: 0,
41
+ maximumFractionDigits: decimals
42
+ }),
43
+ unitSymbol
44
+ );
45
+ }
46
+ function formatFileSize(bytes, decimals = 2) {
47
+ if (bytes === 0) {
48
+ return getBytesString(0, (0, import_i18n._x)("B", "unit symbol"), decimals);
49
+ }
50
+ const quant = {
51
+ /* translators: Unit symbol for yottabyte. */
52
+ [(0, import_i18n._x)("YB", "unit symbol")]: YB_IN_BYTES,
53
+ /* translators: Unit symbol for zettabyte. */
54
+ [(0, import_i18n._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
55
+ /* translators: Unit symbol for exabyte. */
56
+ [(0, import_i18n._x)("EB", "unit symbol")]: EB_IN_BYTES,
57
+ /* translators: Unit symbol for petabyte. */
58
+ [(0, import_i18n._x)("PB", "unit symbol")]: PB_IN_BYTES,
59
+ /* translators: Unit symbol for terabyte. */
60
+ [(0, import_i18n._x)("TB", "unit symbol")]: TB_IN_BYTES,
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 "";
76
+ }
77
+ var filesizeField = {
78
+ id: "filesize",
79
+ type: "text",
80
+ label: (0, import_i18n.__)("File size"),
81
+ getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
82
+ isVisible: (item) => {
83
+ return !!item?.media_details?.filesize;
84
+ },
85
+ enableSorting: false,
86
+ filterBy: false,
87
+ readOnly: true
88
+ };
89
+ var filesize_default = filesizeField;
90
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/filesize/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\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;AAGA,kBAAgC;AAQhC,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
+ }
package/build/index.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ 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
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/media-fields/src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ altTextField: () => import_alt_text.default,
34
+ captionField: () => import_caption.default,
35
+ descriptionField: () => import_description.default,
36
+ filenameField: () => import_filename.default,
37
+ filesizeField: () => import_filesize.default,
38
+ mediaDimensionsField: () => import_media_dimensions.default,
39
+ mediaThumbnailField: () => import_media_thumbnail.default,
40
+ mimeTypeField: () => import_mime_type.default
41
+ });
42
+ module.exports = __toCommonJS(index_exports);
43
+ var import_alt_text = __toESM(require("./alt_text"));
44
+ var import_caption = __toESM(require("./caption"));
45
+ var import_description = __toESM(require("./description"));
46
+ var import_filename = __toESM(require("./filename"));
47
+ var import_filesize = __toESM(require("./filesize"));
48
+ var import_media_dimensions = __toESM(require("./media_dimensions"));
49
+ var import_media_thumbnail = __toESM(require("./media_thumbnail"));
50
+ var import_mime_type = __toESM(require("./mime_type"));
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ altTextField,
54
+ captionField,
55
+ descriptionField,
56
+ filenameField,
57
+ filesizeField,
58
+ mediaDimensionsField,
59
+ mediaThumbnailField,
60
+ mimeTypeField
61
+ });
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["export { default as altTextField } from './alt_text';\nexport { default as captionField } from './caption';\nexport { default as descriptionField } from './description';\nexport { default as filenameField } from './filename';\nexport { default as filesizeField } from './filesize';\nexport { default as mediaDimensionsField } from './media_dimensions';\nexport { default as mediaThumbnailField } from './media_thumbnail';\nexport { default as mimeTypeField } from './mime_type';\n\nexport type {\n\tMediaItem,\n\tMediaKind,\n\tMediaType,\n\tMediaItemUpdatable,\n} from './types';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAwC;AACxC,qBAAwC;AACxC,yBAA4C;AAC5C,sBAAyC;AACzC,sBAAyC;AACzC,8BAAgD;AAChD,6BAA+C;AAC/C,uBAAyC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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
24
+ });
25
+ module.exports = __toCommonJS(media_dimensions_exports);
26
+ var import_i18n = require("@wordpress/i18n");
27
+ var mediaDimensionsField = {
28
+ id: "media_dimensions",
29
+ type: "text",
30
+ label: (0, import_i18n.__)("Dimensions"),
31
+ getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n.sprintf)(
32
+ // translators: 1: Width. 2: Height.
33
+ (0, import_i18n._x)("%1$s \xD7 %2$s", "image dimensions"),
34
+ item?.media_details?.width?.toString(),
35
+ item?.media_details?.height?.toString()
36
+ ) : "",
37
+ isVisible: (item) => {
38
+ return !!(item?.media_details?.width && item?.media_details?.height);
39
+ },
40
+ enableSorting: false,
41
+ filterBy: false,
42
+ readOnly: true
43
+ };
44
+ var media_dimensions_default = mediaDimensionsField;
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/media_dimensions/index.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\n\nconst mediaDimensionsField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'media_dimensions',\n\ttype: 'text',\n\tlabel: __( 'Dimensions' ),\n\tgetValue: ( { item } ) =>\n\t\titem?.media_details?.width && item?.media_details?.height\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: 1: Width. 2: Height.\n\t\t\t\t\t_x( '%1$s \u00D7 %2$s', 'image dimensions' ),\n\t\t\t\t\titem?.media_details?.width?.toString(),\n\t\t\t\t\titem?.media_details?.height?.toString()\n\t\t\t )\n\t\t\t: '',\n\tisVisible: ( item ) => {\n\t\treturn !! ( item?.media_details?.width && item?.media_details?.height );\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n\treadOnly: true,\n};\n\nexport default mediaDimensionsField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAIhC,IAAM,uBAAoE;AAAA,EACzE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,YAAa;AAAA,EACxB,UAAU,CAAE,EAAE,KAAK,MAClB,MAAM,eAAe,SAAS,MAAM,eAAe,aAChD;AAAA;AAAA,QAEA,gBAAI,kBAAe,kBAAmB;AAAA,IACtC,MAAM,eAAe,OAAO,SAAS;AAAA,IACrC,MAAM,eAAe,QAAQ,SAAS;AAAA,EACtC,IACA;AAAA,EACJ,WAAW,CAAE,SAAU;AACtB,WAAO,CAAC,EAAI,MAAM,eAAe,SAAS,MAAM,eAAe;AAAA,EAChE;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AACX;AAEA,IAAO,2BAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ 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
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/media-fields/src/media_thumbnail/index.tsx
31
+ var media_thumbnail_exports = {};
32
+ __export(media_thumbnail_exports, {
33
+ default: () => media_thumbnail_default
34
+ });
35
+ module.exports = __toCommonJS(media_thumbnail_exports);
36
+ var import_i18n = require("@wordpress/i18n");
37
+ var import_view = __toESM(require("./view"));
38
+ var mediaThumbnailField = {
39
+ id: "media_thumbnail",
40
+ type: "media",
41
+ label: (0, import_i18n.__)("Thumbnail"),
42
+ render: import_view.default,
43
+ enableSorting: false,
44
+ filterBy: false
45
+ };
46
+ var media_thumbnail_default = mediaThumbnailField;
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/media_thumbnail/index.tsx"],
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';\nimport MediaThumbnailView from './view';\n\nconst mediaThumbnailField: Partial< Field< MediaItem > > = {\n\tid: 'media_thumbnail',\n\ttype: 'media',\n\tlabel: __( 'Thumbnail' ),\n\trender: MediaThumbnailView,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default mediaThumbnailField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAOnB,kBAA+B;AAE/B,IAAM,sBAAqD;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,WAAY;AAAA,EACvB,QAAQ,YAAAA;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,0BAAQ;",
6
+ "names": ["MediaThumbnailView"]
7
+ }