@wordpress/media-fields 0.17.0 → 0.19.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/CHANGELOG.md +12 -0
- package/build/alt_text/index.cjs.map +3 -3
- package/build/attached_to/edit.cjs +5 -24
- package/build/attached_to/edit.cjs.map +2 -2
- package/build/attached_to/index.cjs.map +2 -2
- package/build/attached_to/view.cjs.map +2 -2
- package/build/author/index.cjs.map +2 -2
- package/build/author/view.cjs.map +2 -2
- package/build/caption/index.cjs.map +3 -3
- package/build/date_added/index.cjs.map +2 -2
- package/build/date_modified/index.cjs.map +2 -2
- package/build/description/index.cjs.map +3 -3
- package/build/filename/index.cjs.map +2 -2
- package/build/filename/view.cjs.map +2 -2
- package/build/filesize/index.cjs.map +2 -2
- package/build/media_dimensions/index.cjs.map +2 -2
- package/build/media_thumbnail/index.cjs.map +2 -2
- package/build/media_thumbnail/view.cjs.map +2 -2
- package/build/mime_type/index.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build/utils/get-media-type-from-mime-type.cjs.map +2 -2
- package/build-module/alt_text/index.mjs +2 -2
- package/build-module/alt_text/index.mjs.map +2 -2
- package/build-module/attached_to/edit.mjs +8 -27
- package/build-module/attached_to/edit.mjs.map +2 -2
- package/build-module/attached_to/index.mjs.map +2 -2
- package/build-module/attached_to/view.mjs.map +2 -2
- package/build-module/author/index.mjs.map +2 -2
- package/build-module/author/view.mjs.map +2 -2
- package/build-module/caption/index.mjs +2 -2
- package/build-module/caption/index.mjs.map +2 -2
- package/build-module/date_added/index.mjs.map +2 -2
- package/build-module/date_modified/index.mjs.map +2 -2
- package/build-module/description/index.mjs +2 -2
- package/build-module/description/index.mjs.map +2 -2
- package/build-module/filename/index.mjs.map +2 -2
- package/build-module/filename/view.mjs.map +2 -2
- package/build-module/filesize/index.mjs.map +2 -2
- package/build-module/media_dimensions/index.mjs.map +2 -2
- package/build-module/media_thumbnail/index.mjs.map +2 -2
- package/build-module/media_thumbnail/view.mjs.map +2 -2
- package/build-module/mime_type/index.mjs.map +2 -2
- package/build-module/utils/get-media-type-from-mime-type.mjs.map +2 -2
- package/build-style/style-rtl.css +14 -3
- package/build-style/style.css +14 -3
- package/build-types/alt_text/index.d.ts.map +1 -1
- package/build-types/attached_to/edit.d.ts +0 -3
- package/build-types/attached_to/edit.d.ts.map +1 -1
- package/build-types/attached_to/index.d.ts +0 -3
- package/build-types/attached_to/index.d.ts.map +1 -1
- package/build-types/attached_to/view.d.ts +0 -3
- package/build-types/attached_to/view.d.ts.map +1 -1
- package/build-types/author/index.d.ts +0 -6
- package/build-types/author/index.d.ts.map +1 -1
- package/build-types/author/view.d.ts +0 -3
- package/build-types/author/view.d.ts.map +1 -1
- package/build-types/caption/index.d.ts.map +1 -1
- package/build-types/date_added/index.d.ts +0 -3
- package/build-types/date_added/index.d.ts.map +1 -1
- package/build-types/date_modified/index.d.ts +0 -3
- package/build-types/date_modified/index.d.ts.map +1 -1
- package/build-types/description/index.d.ts.map +1 -1
- package/build-types/filename/index.d.ts +0 -3
- package/build-types/filename/index.d.ts.map +1 -1
- package/build-types/filename/view.d.ts +0 -3
- package/build-types/filename/view.d.ts.map +1 -1
- package/build-types/filesize/index.d.ts +0 -3
- package/build-types/filesize/index.d.ts.map +1 -1
- package/build-types/media_dimensions/index.d.ts.map +1 -1
- package/build-types/media_thumbnail/index.d.ts +0 -3
- package/build-types/media_thumbnail/index.d.ts.map +1 -1
- package/build-types/media_thumbnail/view.d.ts.map +1 -1
- package/build-types/mime_type/index.d.ts.map +1 -1
- package/build-types/types.d.ts +0 -3
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/get-media-type-from-mime-type.d.ts +0 -3
- package/build-types/utils/get-media-type-from-mime-type.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/alt_text/index.tsx +2 -5
- package/src/attached_to/edit.tsx +17 -37
- package/src/attached_to/index.tsx +0 -7
- package/src/attached_to/style.scss +36 -0
- package/src/attached_to/test/view.test.tsx +0 -11
- package/src/attached_to/view.tsx +0 -6
- package/src/author/index.tsx +0 -7
- package/src/author/view.tsx +0 -11
- package/src/caption/index.tsx +2 -9
- package/src/date_added/index.tsx +0 -7
- package/src/date_modified/index.tsx +0 -7
- package/src/description/index.tsx +2 -9
- package/src/filename/index.ts +0 -7
- package/src/filename/test/index.test.ts +0 -3
- package/src/filename/test/view.test.tsx +0 -11
- package/src/filename/view.tsx +0 -7
- package/src/filesize/index.tsx +0 -7
- package/src/filesize/test/index.test.tsx +0 -3
- package/src/media_dimensions/index.ts +0 -3
- package/src/media_dimensions/test/index.test.ts +0 -7
- package/src/media_thumbnail/index.tsx +0 -7
- package/src/media_thumbnail/test/get-best-image-url.test.ts +0 -3
- package/src/media_thumbnail/view.tsx +0 -10
- package/src/mime_type/index.ts +0 -3
- package/src/stories/index.story.tsx +6 -7
- package/src/style.scss +1 -0
- package/src/types.ts +0 -3
- package/src/utils/get-media-type-from-mime-type.ts +0 -7
- package/build-types/attached_to/test/view.test.d.ts +0 -2
- package/build-types/attached_to/test/view.test.d.ts.map +0 -1
- package/build-types/filename/test/index.test.d.ts +0 -2
- package/build-types/filename/test/index.test.d.ts.map +0 -1
- package/build-types/filename/test/view.test.d.ts +0 -2
- package/build-types/filename/test/view.test.d.ts.map +0 -1
- package/build-types/filesize/test/index.test.d.ts +0 -2
- package/build-types/filesize/test/index.test.d.ts.map +0 -1
- package/build-types/media_dimensions/test/index.test.d.ts +0 -2
- package/build-types/media_dimensions/test/index.test.d.ts.map +0 -1
- package/build-types/media_thumbnail/test/get-best-image-url.test.d.ts +0 -2
- package/build-types/media_thumbnail/test/get-best-image-url.test.d.ts.map +0 -1
- package/build-types/stories/index.story.d.ts +0 -26
- package/build-types/stories/index.story.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/attached_to/edit.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { ComboboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDebounce, useEvent } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\nexport default function MediaAttachedToEdit( {\n\tdata,\n\tonChange,\n}: DataFormControlProps< MediaItem > ) {\n\tconst defaultPost =\n\t\t!! data.post && !! data?._embedded?.[ 'wp:attached-to' ]?.[ 0 ]\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: getRenderedContent(\n\t\t\t\t\t\t\tdata._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue: data.post.toString(),\n\t\t\t\t\t},\n\t\t\t ]\n\t\t\t: [];\n\tconst [ options, setOptions ] =\n\t\tuseState< { label: string; value: string }[] >( defaultPost );\n\tconst [ searchResults, setSearchResults ] = useState< SearchResult[] >(\n\t\t[]\n\t);\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ value, setValue ] = useState< string | null >(\n\t\tdata?.post?.toString() ?? null\n\t);\n\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes(),\n\t\t[]\n\t);\n\tconst handleDetach = () => {\n\t\tonChange( {\n\t\t\tpost: 0,\n\t\t\t_embedded: { ...data?._embedded, 'wp:attached-to': undefined },\n\t\t} );\n\t\tsetValue( null );\n\t};\n\n\tconst onValueChange = async ( filterValue: string ) => {\n\t\tsetIsLoading( true );\n\t\tconst results = await fetchLinkSuggestions(\n\t\t\tfilterValue,\n\t\t\t/*\n\t\t\t * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.\n\t\t\t * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.\n\t\t\t */\n\t\t\t{ type: 'post', isInitialSuggestions: true },\n\t\t\t{}\n\t\t);\n\t\tsetSearchResults( results );\n\t\tconst suggestions = results.map( ( result ) => {\n\t\t\treturn {\n\t\t\t\tlabel: result.title,\n\t\t\t\tvalue: result.id.toString(),\n\t\t\t};\n\t\t} );\n\t\tconst includeCurrent =\n\t\t\t! filterValue &&\n\t\t\tsuggestions.findIndex( ( s ) => s.value === value ) === -1;\n\t\tsetOptions( suggestions.concat( includeCurrent ? defaultPost : [] ) );\n\t\tsetIsLoading( false );\n\t};\n\n\t// `onValueChange` closes over state, so it's wrapped in `useEvent` to give\n\t// `useDebounce` a stable function. Debouncing an inline function instead\n\t// rebuilds the timer on every render, so nothing is debounced and each\n\t// keystroke fires its own request.\n\tconst debouncedValueChange = useDebounce( useEvent( onValueChange ), 300 );\n\n\t/**\n\t * Handle selection.\n\t *\n\t * @param {Object} selectedPostId The selected post id.\n\t */\n\tconst handleSelectOption = ( selectedPostId: string | null ) => {\n\t\tif ( ! selectedPostId ) {\n\t\t\thandleDetach();\n\t\t\treturn;\n\t\t}\n\t\tsetValue( selectedPostId );\n\t\tif ( selectedPostId ) {\n\t\t\tconst selectedPost = searchResults.find(\n\t\t\t\t( result ) => result.id === Number( selectedPostId )\n\t\t\t);\n\t\t\t// Although unlikely, it's technically possible for selectedPost to not be found.\n\t\t\t// E.g. if the user selects an option just as new search results are loaded.\n\t\t\t// TODO: Add error handling for when selectedPost is not found.\n\t\t\tif ( selectedPost && postTypes ) {\n\t\t\t\tconst postType = postTypes.find(\n\t\t\t\t\t( _postType: { slug: string } ) =>\n\t\t\t\t\t\t_postType.slug === selectedPost?.type\n\t\t\t\t);\n\n\t\t\t\tconst attachedTo = {\n\t\t\t\t\t...( postType && { type: postType.slug } ),\n\t\t\t\t\tid: Number( selectedPostId ),\n\t\t\t\t\ttitle: {\n\t\t\t\t\t\traw: selectedPost.title,\n\t\t\t\t\t\trendered: selectedPost.title,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tonChange( {\n\t\t\t\t\tpost: Number( selectedPostId ),\n\t\t\t\t\t_embedded: {\n\t\t\t\t\t\t...data?._embedded,\n\t\t\t\t\t\t'wp:attached-to': [ attachedTo ],\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\tclassName=\"dataviews-media-field__attached-to\"\n\t\t\tisLoading={ isLoading }\n\t\t\tlabel={ __( 'Attached to' ) }\n\t\t\thelp={ __( 'Attach this file to a single post or page.' ) }\n\t\t\tvalue={ value }\n\t\t\toptions={ options }\n\t\t\tonFilterValueChange={ ( filterValue: unknown ) =>\n\t\t\t\tdebouncedValueChange( filterValue as string )\n\t\t\t}\n\t\t\tonChange={ handleSelectOption }\n\t\t\thideLabelFromVision\n\t\t\t// Opening the panel shouldn't imply the user has decided to change\n\t\t\t// the attachment, so wait for them to search before showing the list.\n\t\t\texpandOnFocus={ false }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACC,sCAAsC;AAAA,EACtC,SAAS;AAAA,OACH;AACP,SAAS,uBAAuB;AAChC,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,aAAa,gBAAgB;AACtC,SAAS,iBAAiB;AAG1B,SAAS,0BAA0B;AA0IjC;AAjHa,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AACD,GAAuC;AACtC,QAAM,cACL,CAAC,CAAE,KAAK,QAAQ,CAAC,CAAE,MA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QAAM,uBAAuB,YAAa,SAAU,aAAc,GAAG,GAAI;AAOzE,QAAM,qBAAqB,CAAE,mBAAmC;AAC/D,QAAK,CAAE,gBAAiB;AACvB,mBAAa;AACb;AAAA,IACD;AACA,aAAU,cAAe;AACzB,QAAK,gBAAiB;AACrB,YAAM,eAAe,cAAc;AAAA,QAClC,CAAE,WAAY,OAAO,OAAO,OAAQ,cAAe;AAAA,MACpD;AAIA,UAAK,gBAAgB,WAAY;AAChC,cAAM,WAAW,UAAU;AAAA,UAC1B,CAAE,cACD,UAAU,SAAS,cAAc;AAAA,QACnC;AAEA,cAAM,aAAa;AAAA,UAClB,GAAK,YAAY,EAAE,MAAM,SAAS,KAAK;AAAA,UACvC,IAAI,OAAQ,cAAe;AAAA,UAC3B,OAAO;AAAA,YACN,KAAK,aAAa;AAAA,YAClB,UAAU,aAAa;AAAA,UACxB;AAAA,QACD;AAEA,iBAAU;AAAA,UACT,MAAM,OAAQ,cAAe;AAAA,UAC7B,WAAW;AAAA,YACV,GAAG,MAAM;AAAA,YACT,kBAAkB,CAAE,UAAW;AAAA,UAChC;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV;AAAA,MACA,OAAQ,GAAI,aAAc;AAAA,MAC1B,MAAO,GAAI,4CAA6C;AAAA,MACxD;AAAA,MACA;AAAA,MACA,qBAAsB,CAAE,gBACvB,qBAAsB,WAAsB;AAAA,MAE7C,UAAW;AAAA,MACX,qBAAmB;AAAA,MAGnB,eAAgB;AAAA;AAAA,EACjB;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/attached_to/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\nimport MediaAttachedToView from './view';\nimport MediaAttachedToEdit from './edit';\n\nconst attachedToField: Partial< Field< MediaItem > > = {\n\tid: 'attached_to',\n\ttype: 'text',\n\tlabel: __( 'Attached to' ),\n\tEdit: MediaAttachedToEdit,\n\trender: MediaAttachedToView,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default attachedToField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AAGnB,OAAO,yBAAyB;AAChC,OAAO,yBAAyB;AAEhC,IAAM,kBAAiD;AAAA,EACtD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,aAAc;AAAA,EACzB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/attached_to/view.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport default function MediaAttachedToView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\t// Store the displayed title in state, as the embedded post may be loaded\n\t// asynchronously. This ensures that the title remains stable after it\n\t// is updated by the user, and while it is re-fetched from the server.\n\tconst [ attachedPostTitle, setAttachedPostTitle ] = useState<\n\t\tstring | null\n\t>( null );\n\n\tconst parentId = item.post;\n\tconst embeddedPostId = item._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.id;\n\tconst embeddedPostTitle =\n\t\titem._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title;\n\n\tuseEffect( () => {\n\t\tif ( !! parentId && parentId === embeddedPostId ) {\n\t\t\tsetAttachedPostTitle(\n\t\t\t\tgetRenderedContent( embeddedPostTitle ) || __( '(no title)' )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! parentId ) {\n\t\t\tsetAttachedPostTitle( __( '(Unattached)' ) );\n\t\t}\n\t}, [ parentId, embeddedPostId, embeddedPostTitle ] );\n\n\treturn <>{ attachedPostTitle }</>;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU,iBAAiB;AACpC,SAAS,UAAU;AAGnB,SAAS,0BAA0B;AA6B3B;AA3BO,SAAR,oBAAsC;AAAA,EAC5C;AACD,GAA2C;AAI1C,QAAM,CAAE,mBAAmB,oBAAqB,IAAI,SAEjD,IAAK;AAER,QAAM,WAAW,KAAK;AACtB,QAAM,iBAAiB,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AACpE,QAAM,oBACL,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AAE9C,YAAW,MAAM;AAChB,QAAK,CAAC,CAAE,YAAY,aAAa,gBAAiB;AACjD;AAAA,QACC,mBAAoB,iBAAkB,KAAK,GAAI,YAAa;AAAA,MAC7D;AAAA,IACD;AAEA,QAAK,CAAE,UAAW;AACjB,2BAAsB,GAAI,cAAe,CAAE;AAAA,IAC5C;AAAA,EACD,GAAG,CAAE,UAAU,gBAAgB,iBAAkB,CAAE;AAEnD,SAAO,gCAAI,6BAAmB;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/author/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type { MediaItem } from '../types';\nimport AuthorView from './view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Partial< Field< MediaItem > > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\twho: 'authors',\n\t\t\t\t\t_fields: 'id,name',\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\trender: AuthorView,\n\tsort: ( a, b, direction ) => {\n\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\treturn direction === 'asc'\n\t\t\t? nameA.localeCompare( nameB )\n\t\t\t: nameB.localeCompare( nameA );\n\t},\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n\treadOnly: true,\n};\n\nexport default authorField;\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AAEvC,OAAO,gBAAgB;AAOvB,IAAM,cAA6C;AAAA,EAClD,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,MAAM,cAAe,aAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,QAAQ;AAAA,EACR,MAAM,CAAE,GAAG,GAAG,cAAe;AAC5B,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAClD,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAElD,WAAO,cAAc,QAClB,MAAM,cAAe,KAAM,IAC3B,MAAM,cAAe,KAAM;AAAA,EAC/B;AAAA,EACA,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/author/view.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useCallback, useEffect } from '@wordpress/element';\nimport { commentAuthorAvatar as authorIcon } from '@wordpress/icons';\nimport {\n\t__experimentalHStack as HStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nexport default function AuthorView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst author = item?._embedded?.author?.[ 0 ];\n\tconst text = author?.name;\n\tconst imageUrl = author?.avatar_urls?.[ 48 ];\n\n\t/*\n\t * Use three states to avoid fade-in animation for cached images:\n\t * 'instant' = image already cached, 'loading' = waiting, 'loaded' = just finished.\n\t */\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'instant' | 'loading' | 'loaded'\n\t>( 'loading' );\n\n\tuseEffect( () => {\n\t\tsetLoadingState( 'loading' );\n\t}, [ imageUrl ] );\n\n\tconst imgRef = useCallback( ( img: HTMLImageElement | null ) => {\n\t\tif ( img?.complete ) {\n\t\t\tsetLoadingState( 'instant' );\n\t\t}\n\t}, [] );\n\n\tconst handleLoad = () => {\n\t\tif ( loadingState === 'loading' ) {\n\t\t\tsetLoadingState( 'loaded' );\n\t\t}\n\t};\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'media-author-field__avatar', {\n\t\t\t\t\t\t'is-loading': loadingState === 'loading',\n\t\t\t\t\t\t'is-loaded': loadingState === 'loaded',\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tref={ imgRef }\n\t\t\t\t\t\tonLoad={ handleLoad }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"media-author-field__icon\">\n\t\t\t\t\t<WCIcon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"media-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,UAAU;AACnB,SAAS,UAAU,aAAa,iBAAiB;AACjD,SAAS,uBAAuB,kBAAkB;AAClD;AAAA,EACC,wBAAwB;AAAA,EACxB,QAAQ;AAAA,OACF;AAoCL,SAQG,KARH;AAhCa,SAAR,WAA6B;AAAA,EACnC;AACD,GAA2C;AAC1C,QAAM,SAAS,MAAM,WAAW,SAAU,CAAE;AAC5C,QAAM,OAAO,QAAQ;AACrB,QAAM,WAAW,QAAQ,cAAe,EAAG;AAM3C,QAAM,CAAE,cAAc,eAAgB,IAAI,SAEvC,SAAU;AAEb,YAAW,MAAM;AAChB,oBAAiB,SAAU;AAAA,EAC5B,GAAG,CAAE,QAAS,CAAE;AAEhB,QAAM,SAAS,YAAa,CAAE,QAAkC;AAC/D,QAAK,KAAK,UAAW;AACpB,sBAAiB,SAAU;AAAA,IAC5B;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,aAAa,MAAM;AACxB,QAAK,iBAAiB,WAAY;AACjC,sBAAiB,QAAS;AAAA,IAC3B;AAAA,EACD;AAEA,SACC,qBAAC,UAAO,WAAU,QAAO,SAAU,GAChC;AAAA,KAAC,CAAE,YACJ;AAAA,MAAC;AAAA;AAAA,QACA,WAAY,KAAM,8BAA8B;AAAA,UAC/C,cAAc,iBAAiB;AAAA,UAC/B,aAAa,iBAAiB;AAAA,QAC/B,CAAE;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN,QAAS;AAAA,YACT,KAAM,GAAI,eAAgB;AAAA,YAC1B,KAAM;AAAA;AAAA,QACP;AAAA;AAAA,IACD;AAAA,IAEC,CAAE,YACH,oBAAC,SAAI,WAAU,4BACd,8BAAC,UAAO,MAAO,YAAa,GAC7B;AAAA,IAED,oBAAC,UAAK,WAAU,4BAA6B,gBAAM;AAAA,KACpD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/media-fields/src/caption/index.tsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { TextareaControl } from "@wordpress/components";
|
|
3
|
+
import { TextareaControl as WCTextareaControl } from "@wordpress/components";
|
|
4
4
|
import { getRawContent } from "../utils/get-raw-content.mjs";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
var captionField = {
|
|
@@ -11,7 +11,7 @@ var captionField = {
|
|
|
11
11
|
render: ({ item }) => getRawContent(item?.caption) || "-",
|
|
12
12
|
Edit: ({ field, onChange, data }) => {
|
|
13
13
|
return /* @__PURE__ */ jsx(
|
|
14
|
-
|
|
14
|
+
WCTextareaControl,
|
|
15
15
|
{
|
|
16
16
|
label: field.label,
|
|
17
17
|
value: getRawContent(data.caption) || "",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/caption/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { TextareaControl as WCTextareaControl } from '@wordpress/components';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst captionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'caption',\n\ttype: 'text',\n\tlabel: __( 'Caption' ),\n\tgetValue: ( { item } ) => getRawContent( item?.caption ),\n\trender: ( { item } ) => getRawContent( item?.caption ) || '-',\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<WCTextareaControl\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/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default captionField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,mBAAmB,yBAAyB;AAGrD,SAAS,qBAAqB;AAU3B;AARH,IAAM,eAA4D;AAAA,EACjE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,SAAU;AAAA,EACrB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ;AAAA,EACvD,QAAQ,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,OAAQ,KAAK;AAAA,EAC1D,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,OAAQ,cAAe,KAAK,OAAQ,KAAK;AAAA,QACzC,UAAW,CAAE,UAAW,SAAU,EAAE,SAAS,MAAM,CAAE;AAAA,QACrD,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,kBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/date_added/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nconst dateAddedField: Partial< Field< MediaItem > > = {\n\tid: 'date',\n\ttype: 'datetime',\n\tlabel: __( 'Date added' ),\n\tfilterBy: {\n\t\toperators: [ 'before', 'after' ],\n\t},\n\treadOnly: true,\n};\n\nexport default dateAddedField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AAInB,IAAM,iBAAgD;AAAA,EACrD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,YAAa;AAAA,EACxB,UAAU;AAAA,IACT,WAAW,CAAE,UAAU,OAAQ;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/date_modified/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\n\nconst dateModifiedField: Partial< Field< MediaItem > > = {\n\tid: 'modified',\n\ttype: 'datetime',\n\tlabel: __( 'Date modified' ),\n\tfilterBy: {\n\t\toperators: [ 'before', 'after' ],\n\t},\n\treadOnly: true,\n};\n\nexport default dateModifiedField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AAInB,IAAM,oBAAmD;AAAA,EACxD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,eAAgB;AAAA,EAC3B,UAAU;AAAA,IACT,WAAW,CAAE,UAAU,OAAQ;AAAA,EAChC;AAAA,EACA,UAAU;AACX;AAEA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/media-fields/src/description/index.tsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { TextareaControl } from "@wordpress/components";
|
|
3
|
+
import { TextareaControl as WCTextareaControl } from "@wordpress/components";
|
|
4
4
|
import { getRawContent } from "../utils/get-raw-content.mjs";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
var descriptionField = {
|
|
@@ -11,7 +11,7 @@ var descriptionField = {
|
|
|
11
11
|
render: ({ item }) => /* @__PURE__ */ jsx("div", { children: getRawContent(item?.description) || "-" }),
|
|
12
12
|
Edit: ({ field, onChange, data }) => {
|
|
13
13
|
return /* @__PURE__ */ jsx(
|
|
14
|
-
|
|
14
|
+
WCTextareaControl,
|
|
15
15
|
{
|
|
16
16
|
label: field.label,
|
|
17
17
|
value: getRawContent(data.description) || "",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/description/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { TextareaControl as WCTextareaControl } from '@wordpress/components';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\nimport { getRawContent } from '../utils/get-raw-content';\n\nconst descriptionField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue: ( { item } ) => getRawContent( item?.description ),\n\trender: ( { item } ) => (\n\t\t<div>{ getRawContent( item?.description ) || '-' }</div>\n\t),\n\tEdit: ( { field, onChange, data } ) => {\n\t\treturn (\n\t\t\t<WCTextareaControl\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/>\n\t\t);\n\t},\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\nexport default descriptionField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,mBAAmB,yBAAyB;AAGrD,SAAS,qBAAqB;AAQ5B;AANF,IAAM,mBAAgE;AAAA,EACrE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,aAAc;AAAA,EACzB,UAAU,CAAE,EAAE,KAAK,MAAO,cAAe,MAAM,WAAY;AAAA,EAC3D,QAAQ,CAAE,EAAE,KAAK,MAChB,oBAAC,SAAM,wBAAe,MAAM,WAAY,KAAK,KAAK;AAAA,EAEnD,MAAM,CAAE,EAAE,OAAO,UAAU,KAAK,MAAO;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,MAAM;AAAA,QACd,OAAQ,cAAe,KAAK,WAAY,KAAK;AAAA,QAC7C,UAAW,CAAE,UAAW,SAAU,EAAE,aAAa,MAAM,CAAE;AAAA,QACzD,MAAO;AAAA;AAAA,IACR;AAAA,EAEF;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/filename/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport type { Field } from '@wordpress/dataviews';\nimport type { MediaItem } from '../types';\nimport FileNameView from './view';\n\nconst filenameField: Partial< Field< MediaItem > > = {\n\tid: 'filename',\n\ttype: 'text',\n\tlabel: __( 'File name' ),\n\tgetValue: ( { item }: { item: MediaItem } ) =>\n\t\tgetFilename( item?.source_url || '' ),\n\trender: FileNameView,\n\tenableSorting: false,\n\tfilterBy: false,\n\treadOnly: true,\n};\n\nexport default filenameField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAG5B,OAAO,kBAAkB;AAEzB,IAAM,gBAA+C;AAAA,EACpD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,WAAY;AAAA,EACvB,UAAU,CAAE,EAAE,KAAK,MAClB,YAAa,MAAM,cAAc,EAAG;AAAA,EACrC,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AACX;AAEA,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/filename/view.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useMemo } from '@wordpress/element';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { Tooltip } from '@wordpress/ui';\nimport type { MediaItem } from '../types';\n\n// Proxy threshold for \"long enough that the cell will visually truncate\" —\n// used to decide whether to wrap the filename in a Tooltip showing the full\n// name on hover. Visual truncation itself is handled in CSS.\nconst TRUNCATE_LENGTH = 15;\n\nexport default function FileNameView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst fileName = useMemo(\n\t\t() => ( item?.source_url ? getFilename( item.source_url ) : null ),\n\t\t[ item?.source_url ]\n\t);\n\n\tif ( ! fileName ) {\n\t\treturn '';\n\t}\n\n\tif ( fileName.length <= TRUNCATE_LENGTH ) {\n\t\treturn (\n\t\t\t<span className=\"dataviews-media-field__filename\">\n\t\t\t\t{ fileName }\n\t\t\t</span>\n\t\t);\n\t}\n\n\t// The full filename is always in the DOM, so assistive tech gets it\n\t// regardless. The Tooltip aids mouse users where the cell visually clips\n\t// (DataViews layouts); in a non-truncating context like the DataForm the\n\t// name wraps in full, making it redundant but harmless.\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<span className=\"dataviews-media-field__filename\">\n\t\t\t\t\t\t{ fileName }\n\t\t\t\t\t</span>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ fileName }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAE5B,SAAS,eAAe;AAsBrB,cAWD,YAXC;AAhBH,IAAM,kBAAkB;AAET,SAAR,aAA+B;AAAA,EACrC;AACD,GAA2C;AAC1C,QAAM,WAAW;AAAA,IAChB,MAAQ,MAAM,aAAa,YAAa,KAAK,UAAW,IAAI;AAAA,IAC5D,CAAE,MAAM,UAAW;AAAA,EACpB;AAEA,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AAEA,MAAK,SAAS,UAAU,iBAAkB;AACzC,WACC,oBAAC,UAAK,WAAU,mCACb,oBACH;AAAA,EAEF;AAMA,SACC,qBAAC,QAAQ,MAAR,EACA;AAAA;AAAA,MAAC,QAAQ;AAAA,MAAR;AAAA,QACA,QACC,oBAAC,UAAK,WAAU,mCACb,oBACH;AAAA;AAAA,IAEF;AAAA,IACA,oBAAC,QAAQ,OAAR,EAAgB,oBAAU;AAAA,KAC5B;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/filesize/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
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,SAAS,IAAI,SAAS,UAAU;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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9C;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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/media_dimensions/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __, _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 × %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,SAAS,IAAI,IAAI,eAAe;AAIhC,IAAM,uBAAoE;AAAA,EACzE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,YAAa;AAAA,EACxB,UAAU,CAAE,EAAE,KAAK,MAClB,MAAM,eAAe,SAAS,MAAM,eAAe,SAChD;AAAA;AAAA,IAEA,GAAI,eAAe,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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/media_thumbnail/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\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,SAAS,UAAU;AAGnB,OAAO,wBAAwB;AAE/B,IAAM,sBAAqD;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,WAAY;AAAA,EACvB,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AACX;AAEA,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/media_thumbnail/view.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport { useState, useRef, useLayoutEffect } from '@wordpress/element';\nimport type { Attachment } from '@wordpress/core-data';\nimport { getFilename } from '@wordpress/url';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { getMediaTypeFromMimeType } from '../utils/get-media-type-from-mime-type';\nimport type { MediaItem } from '../types';\n\n/**\n * Given the available image sizes and a target display width, returns the URL\n * of the smallest size whose width is >= the target. Falls back to the largest\n * available size, or the original source_url.\n *\n * @param featuredMedia The media item with size details.\n * @param configSizes The target display size string (e.g. '900px').\n */\nexport function getBestImageUrl(\n\tfeaturedMedia: Attachment | MediaItem,\n\tconfigSizes?: string\n): string {\n\tconst sizes = featuredMedia?.media_details?.sizes;\n\tif ( ! sizes ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\tconst sizeEntries = Object.values( sizes );\n\n\tif ( ! sizeEntries.length ) {\n\t\treturn featuredMedia.source_url;\n\t}\n\n\t// Parse target width from config.sizes (e.g. '900px' → 900).\n\tconst targetWidth = configSizes ? parseInt( configSizes, 10 ) : NaN;\n\n\tif ( ! Number.isNaN( targetWidth ) ) {\n\t\t// Filter to entries that have a valid numeric width.\n\t\tconst validEntries = sizeEntries.filter(\n\t\t\t( s ) => typeof s.width === 'number' && ! Number.isNaN( s.width )\n\t\t);\n\n\t\tif ( ! validEntries.length ) {\n\t\t\treturn featuredMedia.source_url;\n\t\t}\n\n\t\t// Sort ascending by width.\n\t\tconst sorted = [ ...validEntries ].sort(\n\t\t\t( a, b ) => a.width - b.width\n\t\t);\n\t\t// Pick the smallest size that is >= target width.\n\t\tconst match = sorted.find( ( s ) => s.width >= targetWidth );\n\t\tif ( match ) {\n\t\t\treturn match.source_url;\n\t\t}\n\t\t// No size large enough — use the largest available.\n\t\treturn sorted[ sorted.length - 1 ].source_url;\n\t}\n\n\t// If we can't parse the target, fall back to source_url.\n\treturn featuredMedia.source_url;\n}\n\nfunction FallbackView( {\n\titem,\n\tfilename,\n}: {\n\titem: MediaItem;\n\tfilename: string;\n} ) {\n\treturn (\n\t\t<div className=\"dataviews-media-field__media-thumbnail\">\n\t\t\t<VStack\n\t\t\t\tjustify=\"center\"\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail__stack\"\n\t\t\t\tspacing={ 0 }\n\t\t\t>\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--icon\"\n\t\t\t\t\ticon={ getMediaTypeFromMimeType( item.mime_type ).icon }\n\t\t\t\t\tsize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ !! filename && (\n\t\t\t\t\t<div className=\"dataviews-media-field__media-thumbnail__filename\">\n\t\t\t\t\t\t<Truncate className=\"dataviews-media-field__media-thumbnail__filename__truncate\">\n\t\t\t\t\t\t\t{ filename }\n\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nfunction ImageView( {\n\titem,\n\tconfigSizes,\n\tonError,\n}: {\n\titem: Attachment | MediaItem;\n\tconfigSizes?: string;\n\tonError: () => void;\n} ) {\n\tconst imageUrl = getBestImageUrl( item, configSizes );\n\n\t/*\n\t * Use three states to avoid fade-in animation for cached images:\n\t * 'instant' = image already cached, 'loading' = waiting, 'loaded' = just finished.\n\t *\n\t * useLayoutEffect runs synchronously after DOM mutations but before paint,\n\t * so we can check img.complete to detect disk-cached images and skip the\n\t * fade-in animation entirely.\n\t */\n\tconst imgRef = useRef< HTMLImageElement >( null );\n\tconst [ loadingState, setLoadingState ] = useState<\n\t\t'instant' | 'loading' | 'loaded'\n\t>( 'loading' );\n\n\tuseLayoutEffect( () => {\n\t\tif ( imgRef.current?.complete ) {\n\t\t\tsetLoadingState( 'instant' );\n\t\t} else {\n\t\t\tsetLoadingState( 'loading' );\n\t\t}\n\t}, [ imageUrl ] );\n\n\tconst handleLoad = () => {\n\t\tif ( loadingState === 'loading' ) {\n\t\t\tsetLoadingState( 'loaded' );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'dataviews-media-field__media-thumbnail', {\n\t\t\t\t'is-loading': loadingState === 'loading',\n\t\t\t\t'is-loaded': loadingState === 'loaded',\n\t\t\t} ) }\n\t\t>\n\t\t\t<img\n\t\t\t\tref={ imgRef }\n\t\t\t\tclassName=\"dataviews-media-field__media-thumbnail--image\"\n\t\t\t\tsrc={ imageUrl }\n\t\t\t\talt={ item.alt_text || item.title.raw }\n\t\t\t\tonLoad={ handleLoad }\n\t\t\t\tonError={ onError }\n\t\t\t\tloading=\"lazy\"\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default function MediaThumbnailView( {\n\titem,\n\tconfig,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\tconst [ imageError, setImageError ] = useState( false );\n\n\tconst _featuredMedia = useSelect(\n\t\t( select ) => {\n\t\t\t// Avoid the network request if it's not needed. `featured_media` is\n\t\t\t// 0 for images and media without featured media.\n\t\t\tif ( ! item.featured_media ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn select( coreStore ).getEntityRecord< Attachment >(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\titem.featured_media\n\t\t\t);\n\t\t},\n\t\t[ item.featured_media ]\n\t);\n\tconst featuredMedia = item.featured_media ? _featuredMedia : item;\n\n\t// Fetching.\n\tif ( ! featuredMedia ) {\n\t\treturn null;\n\t}\n\n\tconst filename = getFilename( featuredMedia.source_url || '' );\n\n\t// Show fallback if image failed to load or if not an image type.\n\tif (\n\t\timageError ||\n\t\tgetMediaTypeFromMimeType( featuredMedia.mime_type ).type !== 'image'\n\t) {\n\t\treturn (\n\t\t\t<FallbackView item={ featuredMedia } filename={ filename || '' } />\n\t\t);\n\t}\n\n\treturn (\n\t\t<ImageView\n\t\t\titem={ featuredMedia }\n\t\t\tconfigSizes={ config?.sizes }\n\t\t\tonError={ () => setImageError( true ) }\n\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ACD;AACA,aAAO,OAAQ,SAAU,EAAE;AAAA,QAC1B;AAAA,QACA;AAAA,QACA,KAAK;AAAA,MACN;AAAA,IACD;AAAA,IACA,CAAE,KAAK,cAAe;AAAA,EACvB;AACA,QAAM,gBAAgB,KAAK,iBAAiB,iBAAiB;AAG7D,MAAK,CAAE,eAAgB;AACtB,WAAO;AAAA,EACR;AAEA,QAAM,WAAW,YAAa,cAAc,cAAc,EAAG;AAG7D,MACC,cACA,yBAA0B,cAAc,SAAU,EAAE,SAAS,SAC5D;AACD,WACC,oBAAC,gBAAa,MAAO,eAAgB,UAAW,YAAY,IAAK;AAAA,EAEnE;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP,aAAc,QAAQ;AAAA,MACtB,SAAU,MAAM,cAAe,IAAK;AAAA;AAAA,EACrC;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mime_type/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport type { Attachment, Updatable } from '@wordpress/core-data';\nimport type { Field } from '@wordpress/dataviews';\n\nconst mimeTypeField: Partial< Field< Updatable< Attachment > > > = {\n\tid: 'mime_type',\n\ttype: 'text',\n\tlabel: __( 'File type' ),\n\tgetValue: ( { item } ) => item?.mime_type || '',\n\trender: ( { item } ) => item?.mime_type || '-',\n\t// Disable sorting until REST API support for ordering my `mime_type` is added.\n\t// See: https://core.trac.wordpress.org/ticket/64073\n\tenableSorting: false,\n\tfilterBy: false,\n\treadOnly: true,\n};\n\nexport default mimeTypeField;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AAInB,IAAM,gBAA6D;AAAA,EAClE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,WAAY;AAAA,EACvB,UAAU,CAAE,EAAE,KAAK,MAAO,MAAM,aAAa;AAAA,EAC7C,QAAQ,CAAE,EAAE,KAAK,MAAO,MAAM,aAAa;AAAA;AAAA;AAAA,EAG3C,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AACX;AAEA,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/get-media-type-from-mime-type.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { audio, video, image, file } from '@wordpress/icons';\nimport type { MediaType } from '../types';\n\n/**\n * Get the media type from a mime type, including an icon.\n * TODO - media types should be formalized somewhere.\n *\n * References:\n * https://developer.wordpress.org/reference/functions/wp_mime_type_icon/\n * https://developer.wordpress.org/reference/hooks/mime_types/\n * https://developer.wordpress.org/reference/functions/wp_get_mime_types/\n *\n * @param mimeType - The mime type to get the media type from.\n * @return The media type.\n */\nexport function getMediaTypeFromMimeType( mimeType: string ): MediaType {\n\tif ( mimeType.startsWith( 'image/' ) ) {\n\t\treturn {\n\t\t\ttype: 'image',\n\t\t\tlabel: __( 'Image' ),\n\t\t\ticon: image,\n\t\t};\n\t}\n\n\tif ( mimeType.startsWith( 'video/' ) ) {\n\t\treturn {\n\t\t\ttype: 'video',\n\t\t\tlabel: __( 'Video' ),\n\t\t\ticon: video,\n\t\t};\n\t}\n\n\tif ( mimeType.startsWith( 'audio/' ) ) {\n\t\treturn {\n\t\t\ttype: 'audio',\n\t\t\tlabel: __( 'Audio' ),\n\t\t\ticon: audio,\n\t\t};\n\t}\n\n\treturn {\n\t\ttype: 'application',\n\t\tlabel: __( 'Application' ),\n\t\ticon: file,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,OAAO,OAAO,OAAO,YAAY;AAenC,SAAS,yBAA0B,UAA8B;AACvE,MAAK,SAAS,WAAY,QAAS,GAAI;AACtC,WAAO;AAAA,MACN,MAAM;AAAA,MACN,OAAO,GAAI,OAAQ;AAAA,MACnB,MAAM;AAAA,IACP;AAAA,EACD;AAEA,MAAK,SAAS,WAAY,QAAS,GAAI;AACtC,WAAO;AAAA,MACN,MAAM;AAAA,MACN,OAAO,GAAI,OAAQ;AAAA,MACnB,MAAM;AAAA,IACP;AAAA,EACD;AAEA,MAAK,SAAS,WAAY,QAAS,GAAI;AACtC,WAAO;AAAA,MACN,MAAM;AAAA,MACN,OAAO,GAAI,OAAQ;AAAA,MACnB,MAAM;AAAA,IACP;AAAA,EACD;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN,OAAO,GAAI,aAAc;AAAA,IACzB,MAAM;AAAA,EACP;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typography
|
|
3
|
-
*/
|
|
4
1
|
/**
|
|
5
2
|
* SCSS Variables.
|
|
6
3
|
*
|
|
@@ -46,6 +43,20 @@
|
|
|
46
43
|
* React Native specific.
|
|
47
44
|
* These variables do not appear to be used anywhere else.
|
|
48
45
|
*/
|
|
46
|
+
.components-popover__content:has(.dataviews-media-field__attached-to) {
|
|
47
|
+
margin-bottom: 96px;
|
|
48
|
+
}
|
|
49
|
+
.components-popover__content:has(.dataviews-media-field__attached-to):has(.components-form-token-field__suggestions-list) {
|
|
50
|
+
margin-bottom: 0;
|
|
51
|
+
}
|
|
52
|
+
.components-popover__content:has(.dataviews-media-field__attached-to) .components-form-token-field__suggestions-list {
|
|
53
|
+
height: 96px;
|
|
54
|
+
max-height: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Typography
|
|
59
|
+
*/
|
|
49
60
|
/**
|
|
50
61
|
* Breakpoints & Media Queries
|
|
51
62
|
*/
|
package/build-style/style.css
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typography
|
|
3
|
-
*/
|
|
4
1
|
/**
|
|
5
2
|
* SCSS Variables.
|
|
6
3
|
*
|
|
@@ -46,6 +43,20 @@
|
|
|
46
43
|
* React Native specific.
|
|
47
44
|
* These variables do not appear to be used anywhere else.
|
|
48
45
|
*/
|
|
46
|
+
.components-popover__content:has(.dataviews-media-field__attached-to) {
|
|
47
|
+
margin-bottom: 96px;
|
|
48
|
+
}
|
|
49
|
+
.components-popover__content:has(.dataviews-media-field__attached-to):has(.components-form-token-field__suggestions-list) {
|
|
50
|
+
margin-bottom: 0;
|
|
51
|
+
}
|
|
52
|
+
.components-popover__content:has(.dataviews-media-field__attached-to) .components-form-token-field__suggestions-list {
|
|
53
|
+
height: 96px;
|
|
54
|
+
max-height: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Typography
|
|
59
|
+
*/
|
|
49
60
|
/**
|
|
50
61
|
* Breakpoints & Media Queries
|
|
51
62
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/alt_text/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/alt_text/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAElE,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAmC5D,CAAC;eAEa,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/attached_to/edit.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/attached_to/edit.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,MAAM,YAAY,GAAG;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,EACJ,QAAQ,GACR,EAAE,oBAAoB,CAAE,SAAS,CAAE,+BA+HnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/attached_to/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/attached_to/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C,QAAA,MAAM,eAAe,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAQjD,CAAC;eAEa,eAAe"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
2
|
-
/**
|
|
3
|
-
* Internal dependencies
|
|
4
|
-
*/
|
|
5
2
|
import type { MediaItem } from '../types';
|
|
6
3
|
export default function MediaAttachedToView({ item, }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element;
|
|
7
4
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/attached_to/view.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/attached_to/view.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,IAAI,GACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,+BA0BvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/author/index.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/author/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQ1C,QAAA,MAAM,WAAW,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,CAkC7C,CAAC;eAEa,WAAW"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
|
|
2
|
-
/**
|
|
3
|
-
* Internal dependencies
|
|
4
|
-
*/
|
|
5
2
|
import type { MediaItem } from '../types';
|
|
6
3
|
export default function AuthorView({ item, }: DataViewRenderFieldProps<MediaItem>): import("react").JSX.Element;
|
|
7
4
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/author/view.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/author/view.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAE,EACnC,IAAI,GACJ,EAAE,wBAAwB,CAAE,SAAS,CAAE,+BAsDvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caption/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caption/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,QAAA,MAAM,YAAY,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAkB5D,CAAC;eAEa,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_added/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date_added/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,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":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,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":"index.d.ts","sourceRoot":"","sources":["../../src/description/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/description/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,QAAA,MAAM,gBAAgB,EAAE,OAAO,CAAE,KAAK,CAAE,SAAS,CAAE,UAAU,CAAE,CAAE,CAoBhE,CAAC;eAEa,gBAAgB"}
|