@wordpress/fields 0.40.0 → 0.40.2-next.v.202606191442.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 +11 -1
- package/README.md +28 -0
- package/build/components/media-edit/index.cjs +4 -1
- package/build/components/media-edit/index.cjs.map +3 -3
- package/build/fields/description/index.cjs +69 -0
- package/build/fields/description/index.cjs.map +7 -0
- package/build/fields/index.cjs +19 -2
- package/build/fields/index.cjs.map +2 -2
- package/build/fields/last-edited/index.cjs +51 -0
- package/build/fields/last-edited/index.cjs.map +7 -0
- package/build/fields/last-edited/last-edited-date-view.cjs +40 -0
- package/build/fields/last-edited/last-edited-date-view.cjs.map +7 -0
- package/build/fields/parent/parent-edit.cjs +3 -2
- package/build/fields/parent/parent-edit.cjs.map +2 -2
- package/build/fields/pattern-title/view.cjs +14 -9
- package/build/fields/pattern-title/view.cjs.map +3 -3
- package/build/fields/posts-page-title/index.cjs +47 -0
- package/build/fields/posts-page-title/index.cjs.map +7 -0
- package/build/fields/posts-per-page/index.cjs +42 -0
- package/build/fields/posts-per-page/index.cjs.map +7 -0
- package/build/fields/{date/scheduled → scheduled-date}/index.cjs +6 -6
- package/build/fields/scheduled-date/index.cjs.map +7 -0
- package/build/fields/site-discussion/index.cjs +58 -0
- package/build/fields/site-discussion/index.cjs.map +7 -0
- package/build/fields/template-title/index.cjs +1 -1
- package/build/fields/template-title/index.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build-module/components/media-edit/index.mjs +6 -4
- package/build-module/components/media-edit/index.mjs.map +2 -2
- package/build-module/fields/description/index.mjs +44 -0
- package/build-module/fields/description/index.mjs.map +7 -0
- package/build-module/fields/index.mjs +27 -13
- package/build-module/fields/index.mjs.map +2 -2
- package/build-module/fields/last-edited/index.mjs +20 -0
- package/build-module/fields/last-edited/index.mjs.map +7 -0
- package/build-module/fields/last-edited/last-edited-date-view.mjs +19 -0
- package/build-module/fields/last-edited/last-edited-date-view.mjs.map +7 -0
- package/build-module/fields/parent/parent-edit.mjs +3 -2
- package/build-module/fields/parent/parent-edit.mjs.map +2 -2
- package/build-module/fields/pattern-title/view.mjs +15 -10
- package/build-module/fields/pattern-title/view.mjs.map +2 -2
- package/build-module/fields/posts-page-title/index.mjs +26 -0
- package/build-module/fields/posts-page-title/index.mjs.map +7 -0
- package/build-module/fields/posts-per-page/index.mjs +21 -0
- package/build-module/fields/posts-per-page/index.mjs.map +7 -0
- package/build-module/fields/{date/scheduled → scheduled-date}/index.mjs +3 -3
- package/build-module/fields/scheduled-date/index.mjs.map +7 -0
- package/build-module/fields/site-discussion/index.mjs +37 -0
- package/build-module/fields/site-discussion/index.mjs.map +7 -0
- package/build-module/fields/template-title/index.mjs +1 -1
- package/build-module/fields/template-title/index.mjs.map +2 -2
- package/build-style/style-rtl.css +6 -3
- package/build-style/style.css +6 -3
- package/build-types/components/media-edit/index.d.ts.map +1 -1
- package/build-types/fields/description/index.d.ts +20 -0
- package/build-types/fields/description/index.d.ts.map +1 -0
- package/build-types/fields/index.d.ts +6 -1
- package/build-types/fields/index.d.ts.map +1 -1
- package/build-types/fields/last-edited/index.d.ts +14 -0
- package/build-types/fields/last-edited/index.d.ts.map +1 -0
- package/build-types/fields/last-edited/last-edited-date-view.d.ts +8 -0
- package/build-types/fields/last-edited/last-edited-date-view.d.ts.map +1 -0
- package/build-types/fields/parent/parent-edit.d.ts.map +1 -1
- package/build-types/fields/pattern-title/view.d.ts.map +1 -1
- package/build-types/fields/posts-page-title/index.d.ts +14 -0
- package/build-types/fields/posts-page-title/index.d.ts.map +1 -0
- package/build-types/fields/posts-per-page/index.d.ts +14 -0
- package/build-types/fields/posts-per-page/index.d.ts.map +1 -0
- package/build-types/fields/{date/scheduled → scheduled-date}/index.d.ts +1 -1
- package/build-types/fields/scheduled-date/index.d.ts.map +1 -0
- package/build-types/fields/site-discussion/index.d.ts +14 -0
- package/build-types/fields/site-discussion/index.d.ts.map +1 -0
- package/build-types/types.d.ts +10 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +35 -30
- package/src/components/media-edit/index.tsx +5 -5
- package/src/fields/description/index.tsx +64 -0
- package/src/fields/index.ts +9 -1
- package/src/fields/last-edited/index.tsx +29 -0
- package/src/fields/last-edited/last-edited-date-view.tsx +26 -0
- package/src/fields/parent/parent-edit.tsx +1 -0
- package/src/fields/pattern-title/view.tsx +12 -7
- package/src/fields/posts-page-title/index.ts +35 -0
- package/src/fields/posts-per-page/index.ts +30 -0
- package/src/fields/{date/scheduled → scheduled-date}/index.tsx +1 -1
- package/src/fields/site-discussion/index.ts +48 -0
- package/src/fields/template-title/index.ts +1 -1
- package/src/types.ts +10 -0
- package/build/fields/date/scheduled/index.cjs.map +0 -7
- package/build-module/fields/date/scheduled/index.mjs.map +0 -7
- package/build-types/fields/date/scheduled/index.d.ts.map +0 -1
- package/build-types/index.native.d.ts +0 -1
- package/build-types/index.native.d.ts.map +0 -1
- package/src/index.native.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
## 0.40.
|
|
5
|
+
## 0.40.1 (2026-06-16)
|
|
6
|
+
|
|
7
|
+
## 0.40.0 (2026-06-10)
|
|
8
|
+
|
|
9
|
+
### Code Quality
|
|
10
|
+
|
|
11
|
+
- Add missing `@types/react` dependency. [#78882](https://github.com/WordPress/gutenberg/pull/78882).
|
|
12
|
+
|
|
13
|
+
### Internal
|
|
14
|
+
|
|
15
|
+
- Migrate `Tooltip` consumers from `@wordpress/components` to the new compositional `Tooltip` in `@wordpress/ui` ([#78691](https://github.com/WordPress/gutenberg/pull/78691)).
|
|
6
16
|
|
|
7
17
|
## 0.39.0 (2026-05-27)
|
|
8
18
|
|
package/README.md
CHANGED
|
@@ -47,6 +47,10 @@ Date field for BasePost.
|
|
|
47
47
|
|
|
48
48
|
Delete action for Templates, Patterns and Template Parts.
|
|
49
49
|
|
|
50
|
+
### descriptionField
|
|
51
|
+
|
|
52
|
+
Description field for templates.
|
|
53
|
+
|
|
50
54
|
### discussionField
|
|
51
55
|
|
|
52
56
|
Discussion field for BasePost with custom render logic.
|
|
@@ -79,6 +83,10 @@ Featured Image field for BasePostWithEmbeddedFeaturedMedia.
|
|
|
79
83
|
|
|
80
84
|
Format field for BasePost.
|
|
81
85
|
|
|
86
|
+
### lastEditedDateField
|
|
87
|
+
|
|
88
|
+
Last edited date field for BasePost.
|
|
89
|
+
|
|
82
90
|
### MediaEdit
|
|
83
91
|
|
|
84
92
|
A media edit control component that provides a media picker UI with upload functionality for selecting WordPress media attachments. Supports both the traditional WordPress media library and the experimental DataViews media modal.
|
|
@@ -160,10 +168,26 @@ Ping status field for BasePost.
|
|
|
160
168
|
|
|
161
169
|
Post content information field for BasePost.
|
|
162
170
|
|
|
171
|
+
### postsPageTitleField
|
|
172
|
+
|
|
173
|
+
Title field for the posts page (the `page` assigned as `page_for_posts`).
|
|
174
|
+
|
|
175
|
+
### postsPerPageField
|
|
176
|
+
|
|
177
|
+
Posts per page field for the `root/site` entity.
|
|
178
|
+
|
|
163
179
|
### PostType
|
|
164
180
|
|
|
165
181
|
Undocumented declaration.
|
|
166
182
|
|
|
183
|
+
### readOnlyDescriptionField
|
|
184
|
+
|
|
185
|
+
Read-only description field for theme-provided templates, which can't be edited. Shares the display config with `descriptionField` but renders as read-only and is only visible when a description exists.
|
|
186
|
+
|
|
187
|
+
_Type_
|
|
188
|
+
|
|
189
|
+
- `Field< Template >`
|
|
190
|
+
|
|
167
191
|
### renamePost
|
|
168
192
|
|
|
169
193
|
Rename action for PostWithPermissions.
|
|
@@ -184,6 +208,10 @@ Restore action for PostWithPermissions.
|
|
|
184
208
|
|
|
185
209
|
ScheduledDate Field.
|
|
186
210
|
|
|
211
|
+
### siteDiscussionField
|
|
212
|
+
|
|
213
|
+
Discussion field for the `root/site` entity.
|
|
214
|
+
|
|
187
215
|
### slugField
|
|
188
216
|
|
|
189
217
|
Slug field for BasePost.
|
|
@@ -143,7 +143,10 @@ function MediaPickerButton({
|
|
|
143
143
|
if (!showTooltip) {
|
|
144
144
|
return mediaPickerButton;
|
|
145
145
|
}
|
|
146
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
146
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Tooltip.Root, { children: [
|
|
147
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tooltip.Trigger, { render: mediaPickerButton }),
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tooltip.Popup, { children: label })
|
|
149
|
+
] });
|
|
147
150
|
}
|
|
148
151
|
var archiveMimeTypes = [
|
|
149
152
|
"application/zip",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/media-edit/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tDropZone,\n\tIcon as WCIcon,\n\tSpinner,\n\t__experimentalText as WCText,\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\tBaseControl,\n\tTooltip as WCTooltip,\n} from '@wordpress/components';\nimport { isBlobURL, getBlobTypeByURL } from '@wordpress/blob';\nimport { store as coreStore, type Attachment } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tarchive,\n\taudio,\n\tvideo,\n\tfile,\n\tcloseSmall,\n\terror as errorIcon,\n\tchevronUp,\n\tchevronDown,\n\tchevronLeft,\n\tchevronRight,\n} from '@wordpress/icons';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport {\n\tMediaUpload,\n\tuploadMedia,\n\tprivateApis as mediaUtilsPrivateApis,\n} from '@wordpress/media-utils';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport type { MediaEditProps } from '../../types';\nimport useMovingAnimation from './use-moving-animation';\n\nconst { MediaUploadModal } = unlock( mediaUtilsPrivateApis );\n\nfunction AnimatedMediaItem( {\n\tchildren,\n\tindex,\n\tclassName,\n}: {\n\tchildren: React.ReactNode;\n\tindex: number;\n\tclassName?: string;\n} ) {\n\tconst ref = useMovingAnimation( index );\n\treturn (\n\t\t<div ref={ ref } className={ className }>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\ntype BlobItem = {\n\tid: string;\n\tsource_url: string;\n\tmime_type: string | undefined;\n\talt_text?: string;\n};\n\nfunction normalizeValue( value: number | number[] | undefined ): number[] {\n\tif ( Array.isArray( value ) ) {\n\t\treturn value;\n\t}\n\treturn value ? [ value ] : [];\n}\n\n/**\n * Conditional Media component that uses MediaUploadModal when experiment is enabled,\n * otherwise falls back to media-utils MediaUpload.\n *\n * @param root0 Component props.\n * @param root0.render Render prop function that receives { open } object.\n * @param root0.multiple Whether to allow multiple media selections.\n * @return The component.\n */\nfunction ConditionalMediaUpload( { render, multiple, ...props }: any ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tif ( ( window as any ).__experimentalDataViewsMediaModal ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ render && render( { open: () => setIsModalOpen( true ) } ) }\n\t\t\t\t{ isModalOpen && (\n\t\t\t\t\t<MediaUploadModal\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\tprops.onClose?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonSelect={ ( media: any ) => {\n\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\tprops.onSelect?.( media );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\t// Fallback to media-utils MediaUpload when experiment is disabled.\n\treturn (\n\t\t<MediaUpload\n\t\t\t{ ...props }\n\t\t\trender={ render }\n\t\t\tmultiple={ multiple ? 'add' : undefined }\n\t\t/>\n\t);\n}\n\nfunction MediaPickerButton( {\n\topen,\n\tchildren,\n\tlabel,\n\tshowTooltip = false,\n\tonFilesDrop,\n\tattachment,\n\tisUploading = false,\n}: {\n\topen: () => void;\n\tchildren: React.ReactNode;\n\tlabel: string;\n\tshowTooltip?: boolean;\n\tonFilesDrop: MediaEditAttachmentsProps[ 'onFilesDrop' ];\n\tattachment?: MediaEditAttachment;\n\tisUploading?: boolean;\n} ) {\n\tconst isBlob = attachment && isBlobURL( attachment.source_url );\n\tconst mediaPickerButton = (\n\t\t<div\n\t\t\tclassName={ clsx( 'fields__media-edit-picker-button', {\n\t\t\t\t'has-attachment': attachment,\n\t\t\t} ) }\n\t\t\trole=\"button\"\n\t\t\ttabIndex={ 0 }\n\t\t\tonClick={ () => {\n\t\t\t\tif ( ! isUploading ) {\n\t\t\t\t\topen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( isUploading ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( event.key === 'Enter' || event.key === ' ' ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\topen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\taria-label={ label }\n\t\t\taria-disabled={ isUploading }\n\t\t>\n\t\t\t{ children }\n\t\t\t{ isBlob && (\n\t\t\t\t<span className=\"fields__media-edit-picker-button-spinner\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</span>\n\t\t\t) }\n\t\t\t{ ! isUploading && (\n\t\t\t\t<DropZone\n\t\t\t\t\tonFilesDrop={ ( files ) =>\n\t\t\t\t\t\tonFilesDrop( files, attachment?.id as number )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n\tif ( ! showTooltip ) {\n\t\treturn mediaPickerButton;\n\t}\n\treturn (\n\t\t<WCTooltip text={ label } placement=\"top\">\n\t\t\t{ mediaPickerButton }\n\t\t</WCTooltip>\n\t);\n}\n\nconst archiveMimeTypes = [\n\t'application/zip',\n\t'application/x-zip-compressed',\n\t'application/x-rar-compressed',\n\t'application/x-7z-compressed',\n\t'application/x-tar',\n\t'application/x-gzip',\n];\n\nfunction MediaTitle( { attachment }: { attachment: Attachment< 'view' > } ) {\n\treturn (\n\t\t<Truncate className=\"fields__media-edit-filename\">\n\t\t\t{ attachment.title.rendered }\n\t\t</Truncate>\n\t);\n}\n\nfunction MediaEditPlaceholder( props: {\n\topen: () => void;\n\tlabel: string;\n\tonFilesDrop: MediaEditAttachmentsProps[ 'onFilesDrop' ];\n\tisUploading: boolean;\n} ) {\n\treturn (\n\t\t<MediaPickerButton { ...props }>\n\t\t\t<span className=\"fields__media-edit-placeholder\">\n\t\t\t\t{ props.label }\n\t\t\t</span>\n\t\t</MediaPickerButton>\n\t);\n}\n\nfunction MoveButtons( {\n\titemId,\n\tindex,\n\ttotalItems,\n\tisUploading,\n\tmoveItem,\n\torientation = 'vertical',\n}: {\n\titemId: number;\n\tindex: number;\n\ttotalItems: number;\n\tisUploading: boolean;\n\tmoveItem: ( id: number, direction: 'up' | 'down' ) => void;\n\torientation?: 'vertical' | 'horizontal';\n} ) {\n\tconst isHorizontal = orientation === 'horizontal';\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\ticon={ isHorizontal ? chevronLeft : chevronUp }\n\t\t\t\tlabel={ isHorizontal ? __( 'Move left' ) : __( 'Move up' ) }\n\t\t\t\tsize=\"small\"\n\t\t\t\tdisabled={ isUploading || index === 0 }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\tonClick={ ( event: React.MouseEvent< HTMLButtonElement > ) => {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tmoveItem( itemId, 'up' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\ticon={ isHorizontal ? chevronRight : chevronDown }\n\t\t\t\tlabel={ isHorizontal ? __( 'Move right' ) : __( 'Move down' ) }\n\t\t\t\tsize=\"small\"\n\t\t\t\tdisabled={ isUploading || index === totalItems - 1 }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\tonClick={ ( event: React.MouseEvent< HTMLButtonElement > ) => {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tmoveItem( itemId, 'down' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nfunction MediaPreview( { attachment }: { attachment: MediaEditAttachment } ) {\n\tconst url = attachment.source_url;\n\tconst mimeType = attachment.mime_type || '';\n\tif ( mimeType.startsWith( 'image' ) ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields__media-edit-thumbnail\"\n\t\t\t\talt={ attachment.alt_text || '' }\n\t\t\t\tsrc={ url }\n\t\t\t/>\n\t\t);\n\t} else if ( mimeType.startsWith( 'audio' ) ) {\n\t\treturn <WCIcon icon={ audio } />;\n\t} else if ( mimeType.startsWith( 'video' ) ) {\n\t\treturn <WCIcon icon={ video } />;\n\t} else if ( archiveMimeTypes.includes( mimeType ) ) {\n\t\treturn <WCIcon icon={ archive } />;\n\t}\n\treturn <WCIcon icon={ file } />;\n}\n\ntype MediaEditAttachment = Attachment< 'view' > | BlobItem;\ninterface MediaEditAttachmentsProps {\n\tallItems: Array< MediaEditAttachment > | null;\n\taddButtonLabel: string;\n\tmultiple?: boolean;\n\tremoveItem: ( itemId: number ) => void;\n\tmoveItem: ( itemId: number, direction: 'up' | 'down' ) => void;\n\topen: () => void;\n\tonFilesDrop: ( files: File[], attachmentId?: number ) => void;\n\tisUploading: boolean;\n\tsetTargetItemId: ( id?: number ) => void;\n}\n\nfunction ExpandedMediaEditAttachments( {\n\tallItems,\n\taddButtonLabel,\n\tmultiple,\n\tremoveItem,\n\tmoveItem,\n\topen,\n\tonFilesDrop,\n\tisUploading,\n\tsetTargetItemId,\n}: MediaEditAttachmentsProps ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'fields__media-edit-expanded', {\n\t\t\t\t'is-multiple': multiple,\n\t\t\t\t'is-single': ! multiple,\n\t\t\t\t'is-empty': ! allItems?.length,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ allItems?.map( ( attachment, index ) => {\n\t\t\t\tconst hasPreviewImage =\n\t\t\t\t\tattachment.mime_type?.startsWith( 'image' );\n\t\t\t\tconst isBlob = isBlobURL( attachment.source_url );\n\t\t\t\tconst attachmentNumericId = attachment.id as number;\n\t\t\t\treturn (\n\t\t\t\t\t<AnimatedMediaItem\n\t\t\t\t\t\tkey={ attachment.id }\n\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\tclassName={ clsx( 'fields__media-edit-expanded-item', {\n\t\t\t\t\t\t\t'has-preview-image': hasPreviewImage,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MediaPickerButton\n\t\t\t\t\t\t\topen={ () => {\n\t\t\t\t\t\t\t\tsetTargetItemId( attachmentNumericId );\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t! isBlob\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: The title of the media item. */\n\t\t\t\t\t\t\t\t\t\t\t__( 'Replace %s' ),\n\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\tattachment as Attachment< 'view' >\n\t\t\t\t\t\t\t\t\t\t\t ).title.rendered\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __( 'Replace' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"fields__media-edit-expanded-preview\">\n\t\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-expanded-preview-stack\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ ( ! isBlob || hasPreviewImage ) && (\n\t\t\t\t\t\t\t\t\t\t<MediaPreview\n\t\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</MediaPickerButton>\n\t\t\t\t\t\t{ ! isBlob && (\n\t\t\t\t\t\t\t<div className=\"fields__media-edit-expanded-overlay\">\n\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-expanded-actions\"\n\t\t\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\t\t\talignment=\"flex-end\"\n\t\t\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ multiple && allItems.length > 1 && (\n\t\t\t\t\t\t\t\t\t\t<MoveButtons\n\t\t\t\t\t\t\t\t\t\t\titemId={ attachmentNumericId }\n\t\t\t\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\t\t\t\ttotalItems={ allItems.length }\n\t\t\t\t\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t\t\t\t\t\tmoveItem={ moveItem }\n\t\t\t\t\t\t\t\t\t\t\torientation=\"horizontal\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\tdisabled={ isUploading }\n\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\tremoveItem( attachmentNumericId );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AnimatedMediaItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ ( multiple || ! allItems?.length ) && (\n\t\t\t\t<MediaEditPlaceholder\n\t\t\t\t\topen={ () => {\n\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ addButtonLabel }\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction CompactMediaEditAttachments( {\n\tallItems,\n\taddButtonLabel,\n\tmultiple,\n\tremoveItem,\n\tmoveItem,\n\topen,\n\tonFilesDrop,\n\tisUploading,\n\tsetTargetItemId,\n}: MediaEditAttachmentsProps ) {\n\treturn (\n\t\t<>\n\t\t\t{ !! allItems?.length && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'fields__media-edit-compact-group', {\n\t\t\t\t\t\t'is-single': allItems.length === 1,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<VStack spacing={ 0 }>\n\t\t\t\t\t\t{ allItems.map( ( attachment, index ) => {\n\t\t\t\t\t\t\tconst isBlob = isBlobURL( attachment.source_url );\n\t\t\t\t\t\t\tconst showMoveButtons =\n\t\t\t\t\t\t\t\tmultiple && allItems.length > 1;\n\t\t\t\t\t\t\tconst attachmentNumericId = attachment.id as number;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<AnimatedMediaItem\n\t\t\t\t\t\t\t\t\tkey={ attachment.id }\n\t\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-compact\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<MediaPickerButton\n\t\t\t\t\t\t\t\t\t\topen={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetTargetItemId(\n\t\t\t\t\t\t\t\t\t\t\t\tattachmentNumericId\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<MediaPreview\n\t\t\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t{ ! isBlob && (\n\t\t\t\t\t\t\t\t\t\t\t\t<MediaTitle\n\t\t\t\t\t\t\t\t\t\t\t\t\tattachment={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tattachment as Attachment< 'view' >\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t</MediaPickerButton>\n\t\t\t\t\t\t\t\t\t{ ! isBlob && (\n\t\t\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-compact-movers\"\n\t\t\t\t\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\t\t\t\t\talignment=\"flex-end\"\n\t\t\t\t\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ showMoveButtons && (\n\t\t\t\t\t\t\t\t\t\t\t\t<MoveButtons\n\t\t\t\t\t\t\t\t\t\t\t\t\titemId={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tattachmentNumericId\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\t\t\t\t\t\ttotalItems={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tallItems.length\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t\t\t\t\t\t\t\tmoveItem={ moveItem }\n\t\t\t\t\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tdisabled={ isUploading }\n\t\t\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tremoveItem(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tattachmentNumericId\n\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</AnimatedMediaItem>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</VStack>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ( multiple || ! allItems?.length ) && (\n\t\t\t\t<MediaEditPlaceholder\n\t\t\t\t\topen={ () => {\n\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ addButtonLabel }\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * A media edit control component that provides a media picker UI with upload functionality\n * for selecting WordPress media attachments. Supports both the traditional WordPress media\n * library and the experimental DataViews media modal.\n *\n * This component is intended to be used as the `Edit` property of a field definition when\n * registering fields with `registerEntityField` from `@wordpress/editor`.\n *\n * @template Item - The type of the item being edited.\n *\n * @param {MediaEditProps<Item>} props - The component props.\n * @param {Item} props.data - The item being edited.\n * @param {Object} props.field - The field configuration with getValue and setValue methods.\n * @param {Function} props.onChange - Callback function when the media selection changes.\n * @param {string[]} [props.allowedTypes] - Array of allowed media types. Use `['*']` to allow all file types. Default `['image']`.\n * @param {boolean} [props.multiple] - Whether to allow multiple media selections. Default `false`.\n * @param {boolean} [props.hideLabelFromVision] - Whether the label should be hidden from vision.\n * @param {boolean} [props.isExpanded] - Whether to render in an expanded form. Default `false`.\n *\n * @return {React.JSX.Element} The media edit control component.\n *\n * @example\n * ```tsx\n * import { MediaEdit } from '@wordpress/fields';\n * import type { DataFormControlProps } from '@wordpress/dataviews';\n *\n * const featuredImageField = {\n * id: 'featured_media',\n * type: 'media',\n * label: 'Featured Image',\n * Edit: (props: DataFormControlProps<MyPostType>) => (\n * <MediaEdit\n * {...props}\n * allowedTypes={['image']}\n * />\n * ),\n * };\n * ```\n */\nexport default function MediaEdit< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tallowedTypes = [ 'image' ],\n\tmultiple,\n\tisExpanded,\n\tvalidity,\n}: MediaEditProps< Item > ) {\n\tconst value = field.getValue( { item: data } );\n\tconst [ isTouched, setIsTouched ] = useState( false );\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst [ customValidity, setCustomValidity ] = useState<\n\t\t| { type: 'valid' | 'validating' | 'invalid'; message?: string }\n\t\t| undefined\n\t>( undefined );\n\t// Listen for invalid event (e.g., form submission, reportValidity())\n\t// to show validation messages even before blur.\n\tuseEffect( () => {\n\t\tconst validityTarget = validityTargetRef.current;\n\t\tconst handler = () => {\n\t\t\tsetIsTouched( true );\n\t\t};\n\t\tvalidityTarget?.addEventListener( 'invalid', handler );\n\t\treturn () => validityTarget?.removeEventListener( 'invalid', handler );\n\t}, [] );\n\tconst attachments = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! value ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst normalizedValue = normalizeValue( value );\n\t\t\t// Sorted IDs ensure stable cache key, avoiding\n\t\t\t// unnecessary new requests on reorder.\n\t\t\tconst sortedIds = normalizedValue.toSorted( ( a, b ) => a - b );\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'postType', 'attachment', {\n\t\t\t\tinclude: sortedIds,\n\t\t\t} ) as Attachment< 'view' >[] | null;\n\t\t},\n\t\t[ value ]\n\t);\n\t// Keep previous attachments during null transitions. When value changes,\n\t// useSelect briefly returns null while the new query resolves. For pure\n\t// reorders (same IDs), we fall back to the cached list to avoid a visual\n\t// flash in compact mode. For replacements/uploads (new IDs not in cache),\n\t// we let attachments be null as normal.\n\tconst stableAttachmentsRef = useRef< Attachment< 'view' >[] | null >(\n\t\tnull\n\t);\n\tif ( attachments !== null ) {\n\t\tstableAttachmentsRef.current = attachments;\n\t}\n\tlet stableAttachments = attachments;\n\tif ( attachments === null && stableAttachmentsRef.current && value ) {\n\t\tconst stableIds = new Set(\n\t\t\tstableAttachmentsRef.current.map( ( a ) => a.id )\n\t\t);\n\t\tif ( normalizeValue( value ).every( ( id ) => stableIds.has( id ) ) ) {\n\t\t\tstableAttachments = stableAttachmentsRef.current;\n\t\t}\n\t}\n\t// Reorder attachments to match value order.\n\tconst orderedAttachments = useMemo( () => {\n\t\tif ( ! stableAttachments ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst normalizedValue = normalizeValue( value );\n\t\tconst attachmentMap = new Map(\n\t\t\tstableAttachments.map( ( a ) => [ a.id, a ] )\n\t\t);\n\t\treturn normalizedValue\n\t\t\t.map( ( id ) => attachmentMap.get( id ) )\n\t\t\t.filter( ( a ): a is Attachment< 'view' > => a !== undefined );\n\t}, [ stableAttachments, value ] );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { receiveEntityRecords } = useDispatch( coreStore );\n\t// Support one upload action at a time for now.\n\tconst [ targetItemId, setTargetItemId ] = useState< number >();\n\t// Deferred open: the legacy class-based MediaUpload reads props\n\t// imperatively when `open()` is called, so calling it in the same\n\t// handler as `setTargetItemId()` would open the modal with stale\n\t// `value`/`multiple` props. Setting a pending flag defers the open\n\t// until after the next render when props are up to date.\n\tconst openModalRef = useRef< () => void >( undefined );\n\tconst [ pendingOpen, setPendingOpen ] = useState( false );\n\tconst [ blobs, setBlobs ] = useState< string[] >( [] );\n\tuseEffect( () => {\n\t\tif ( pendingOpen ) {\n\t\t\tsetPendingOpen( false );\n\t\t\topenModalRef.current?.();\n\t\t}\n\t}, [ pendingOpen ] );\n\tconst onChangeControl = useCallback(\n\t\t( newValue: number | number[] | undefined ) =>\n\t\t\tonChange( field.setValue( { item: data, value: newValue } ) ),\n\t\t[ data, field, onChange ]\n\t);\n\tconst removeItem = useCallback(\n\t\t( itemId: number ) => {\n\t\t\tconst currentIds = normalizeValue( value );\n\t\t\tconst newIds = currentIds.filter( ( id ) => id !== itemId );\n\t\t\t// Mark as touched to immediately show any validation error.\n\t\t\tsetIsTouched( true );\n\t\t\tonChangeControl( newIds.length ? newIds : undefined );\n\t\t},\n\t\t[ value, onChangeControl ]\n\t);\n\tconst moveItem = useCallback(\n\t\t( itemId: number, direction: 'up' | 'down' ) => {\n\t\t\tif ( ! orderedAttachments ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst currentIds = orderedAttachments.map( ( a ) => a.id );\n\t\t\tconst index = currentIds.indexOf( itemId );\n\t\t\tconst newIndex = direction === 'up' ? index - 1 : index + 1;\n\t\t\t[ currentIds[ index ], currentIds[ newIndex ] ] = [\n\t\t\t\tcurrentIds[ newIndex ],\n\t\t\t\tcurrentIds[ index ],\n\t\t\t];\n\t\t\tonChangeControl( currentIds );\n\t\t},\n\t\t[ orderedAttachments, onChangeControl ]\n\t);\n\tconst onFilesDrop = useCallback(\n\t\t( files: File[], _targetItemId?: number ) => {\n\t\t\tsetTargetItemId( _targetItemId );\n\t\t\tuploadMedia( {\n\t\t\t\tallowedTypes: allowedTypes?.length ? allowedTypes : undefined,\n\t\t\t\tfilesList: files,\n\t\t\t\tonFileChange( uploadedMedia: any[] ) {\n\t\t\t\t\tconst blobUrls = uploadedMedia\n\t\t\t\t\t\t.filter( ( item ) => isBlobURL( item.url ) )\n\t\t\t\t\t\t.map( ( item ) => item.url );\n\t\t\t\t\tsetBlobs( blobUrls );\n\t\t\t\t\t// Wait for all uploads to complete before updating value.\n\t\t\t\t\tif ( !! blobUrls.length ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// `uploadMedia` creates attachments via `apiFetch`\n\t\t\t\t\t// outside the core-data store, so invalidate\n\t\t\t\t\t// all attachment queries to keep them fresh for\n\t\t\t\t\t// other components that rely on core-data.\n\t\t\t\t\treceiveEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t[],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t);\n\t\t\t\t\tconst uploadedIds = uploadedMedia.map(\n\t\t\t\t\t\t( item ) => item.id\n\t\t\t\t\t);\n\t\t\t\t\tif ( ! multiple ) {\n\t\t\t\t\t\tonChangeControl( uploadedIds[ 0 ] );\n\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst currentValue = normalizeValue( value );\n\t\t\t\t\t// Dropped on placeholder: append new items.\n\t\t\t\t\tif ( _targetItemId === undefined ) {\n\t\t\t\t\t\tonChangeControl( [ ...currentValue, ...uploadedIds ] );\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Dropped on existing item: insert at that position.\n\t\t\t\t\t\tconst newValue = [ ...currentValue ];\n\t\t\t\t\t\tnewValue.splice(\n\t\t\t\t\t\t\tcurrentValue.indexOf( _targetItemId ),\n\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t...uploadedIds\n\t\t\t\t\t\t);\n\t\t\t\t\t\tonChangeControl( newValue );\n\t\t\t\t\t}\n\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t},\n\t\t\t\tonError( error: Error ) {\n\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\tsetBlobs( [] );\n\t\t\t\t\tcreateErrorNotice( error.message, { type: 'snackbar' } );\n\t\t\t\t},\n\t\t\t\tmultiple: !! multiple,\n\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tallowedTypes,\n\t\t\tvalue,\n\t\t\tmultiple,\n\t\t\tcreateErrorNotice,\n\t\t\tonChangeControl,\n\t\t\treceiveEntityRecords,\n\t\t]\n\t);\n\tconst addButtonLabel =\n\t\tfield.placeholder ||\n\t\t( multiple ? __( 'Choose files' ) : __( 'Choose file' ) );\n\t// Merge real attachments with any existing blob items that are being uploaded.\n\tconst allItems: Array< MediaEditAttachment > | null = useMemo( () => {\n\t\tif ( ! blobs.length ) {\n\t\t\treturn orderedAttachments;\n\t\t}\n\t\tconst items: Array< MediaEditAttachment > = [\n\t\t\t...( orderedAttachments || [] ),\n\t\t];\n\t\tconst blobItems = blobs.map( ( url ) => ( {\n\t\t\tid: url,\n\t\t\tsource_url: url,\n\t\t\tmime_type: getBlobTypeByURL( url ),\n\t\t} ) );\n\t\tif ( targetItemId !== undefined ) {\n\t\t\t// When files are dropped in existing media item, place the blobs at that item.\n\t\t\tconst targetIndex = items.findIndex(\n\t\t\t\t( a ) => a.id === targetItemId\n\t\t\t);\n\t\t\titems.splice( targetIndex, 1, ...blobItems );\n\t\t} else {\n\t\t\titems.push( ...blobItems );\n\t\t}\n\t\treturn items;\n\t}, [ orderedAttachments, targetItemId, blobs ] );\n\tuseEffect( () => {\n\t\tif ( ! isTouched ) {\n\t\t\treturn;\n\t\t}\n\t\tconst input = validityTargetRef.current;\n\t\tif ( ! input ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( validity ) {\n\t\t\tconst customValidityResult = validity?.custom;\n\t\t\tsetCustomValidity( customValidityResult );\n\n\t\t\t// Set custom validity on hidden input for HTML5 form validation.\n\t\t\tif ( customValidityResult?.type === 'invalid' ) {\n\t\t\t\tinput.setCustomValidity(\n\t\t\t\t\tcustomValidityResult.message || __( 'Invalid' )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinput.setCustomValidity( '' ); // Clear validity.\n\t\t\t}\n\t\t} else {\n\t\t\t// Clear any previous validation.\n\t\t\tinput.setCustomValidity( '' );\n\t\t\tsetCustomValidity( undefined );\n\t\t}\n\t}, [ isTouched, field.isValid, validity ] );\n\tconst onBlur = useCallback(\n\t\t( event: React.FocusEvent< HTMLElement > ) => {\n\t\t\tif ( isTouched ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t! event.relatedTarget ||\n\t\t\t\t! event.currentTarget.contains( event.relatedTarget )\n\t\t\t) {\n\t\t\t\tsetIsTouched( true );\n\t\t\t}\n\t\t},\n\t\t[ isTouched ]\n\t);\n\treturn (\n\t\t<div onBlur={ onBlur }>\n\t\t\t<fieldset className=\"fields__media-edit\" data-field-id={ field.id }>\n\t\t\t\t<ConditionalMediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: any ) => {\n\t\t\t\t\t\tif ( ! multiple ) {\n\t\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst newIds = Array.isArray( selectedMedia )\n\t\t\t\t\t\t\t? selectedMedia.map( ( m: any ) => m.id )\n\t\t\t\t\t\t\t: [ selectedMedia.id ];\n\t\t\t\t\t\tconst currentValue = normalizeValue( value );\n\t\t\t\t\t\tif ( ! currentValue.length ) {\n\t\t\t\t\t\t\tonChangeControl( newIds );\n\t\t\t\t\t\t} else if ( targetItemId === undefined ) {\n\t\t\t\t\t\t\t// Placeholder clicked: keep existing items that are\n\t\t\t\t\t\t\t// still selected, then append newly selected items.\n\t\t\t\t\t\t\tconst existingItems = currentValue.filter( ( id ) =>\n\t\t\t\t\t\t\t\tnewIds.includes( id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst newItems = newIds.filter(\n\t\t\t\t\t\t\t\t( id ) => ! currentValue.includes( id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonChangeControl( [\n\t\t\t\t\t\t\t\t...existingItems,\n\t\t\t\t\t\t\t\t...newItems,\n\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t} else if ( selectedMedia.id !== targetItemId ) {\n\t\t\t\t\t\t\t// Remove selected item from its old position, if it\n\t\t\t\t\t\t\t// already exists in the value.\n\t\t\t\t\t\t\tconst filtered = currentValue.filter(\n\t\t\t\t\t\t\t\t( id ) => id !== selectedMedia.id\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t// Replace the clicked item with the selected one.\n\t\t\t\t\t\t\tonChangeControl(\n\t\t\t\t\t\t\t\tfiltered.map( ( id ) =>\n\t\t\t\t\t\t\t\t\tid === targetItemId ? selectedMedia.id : id\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t} }\n\t\t\t\t\tonClose={ () => setTargetItemId( undefined ) }\n\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t// When replacing an existing item, pass only that item's ID\n\t\t\t\t\t// and open in single-select mode so the user picks exactly\n\t\t\t\t\t// one replacement, even if `multiple` is true.\n\t\t\t\t\tvalue={ targetItemId !== undefined ? targetItemId : value }\n\t\t\t\t\tmultiple={ multiple && targetItemId === undefined }\n\t\t\t\t\ttitle={ field.label }\n\t\t\t\t\trender={ ( { open }: any ) => {\n\t\t\t\t\t\t// Keep a ref to the latest `open` so the deferred effect can call it.\n\t\t\t\t\t\topenModalRef.current = open;\n\t\t\t\t\t\tconst AttachmentsComponent = isExpanded\n\t\t\t\t\t\t\t? ExpandedMediaEditAttachments\n\t\t\t\t\t\t\t: CompactMediaEditAttachments;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<VStack spacing={ 2 }>\n\t\t\t\t\t\t\t\t{ field.label &&\n\t\t\t\t\t\t\t\t\t( hideLabelFromVision ? (\n\t\t\t\t\t\t\t\t\t\t<VisuallyHidden render={ <legend /> }>\n\t\t\t\t\t\t\t\t\t\t\t{ field.label }\n\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<BaseControl.VisualLabel\n\t\t\t\t\t\t\t\t\t\t\tas=\"legend\"\n\t\t\t\t\t\t\t\t\t\t\tstyle={ { marginBottom: 0 } }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ field.label }\n\t\t\t\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t<AttachmentsComponent\n\t\t\t\t\t\t\t\t\tallItems={ allItems }\n\t\t\t\t\t\t\t\t\taddButtonLabel={ addButtonLabel }\n\t\t\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\t\t\tremoveItem={ removeItem }\n\t\t\t\t\t\t\t\t\tmoveItem={ moveItem }\n\t\t\t\t\t\t\t\t\topen={ () => setPendingOpen( true ) }\n\t\t\t\t\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\t\t\t\t\tisUploading={ !! blobs.length }\n\t\t\t\t\t\t\t\t\tsetTargetItemId={ setTargetItemId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ field.description && (\n\t\t\t\t\t\t\t\t\t<WCText\n\t\t\t\t\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-description\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ field.description }\n\t\t\t\t\t\t\t\t\t</WCText>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</fieldset>\n\t\t\t{ /* Visually hidden text input for validation. */ }\n\t\t\t<VisuallyHidden>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tref={ validityTargetRef }\n\t\t\t\t\tvalue={ value ?? '' }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tonChange={ () => {} }\n\t\t\t\t/>\n\t\t\t</VisuallyHidden>\n\t\t\t{ customValidity && (\n\t\t\t\t<div aria-live=\"polite\">\n\t\t\t\t\t<p\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'components-validated-control__indicator',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-invalid': customValidity.type === 'invalid',\n\t\t\t\t\t\t\t\t'is-valid': customValidity.type === 'valid',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<WCIcon\n\t\t\t\t\t\t\tclassName=\"components-validated-control__indicator-icon\"\n\t\t\t\t\t\t\ticon={ errorIcon }\n\t\t\t\t\t\t\tsize={ 16 }\n\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ customValidity.message }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wBAWO;AACP,kBAA4C;AAC5C,uBAAoD;AACpD,kBAA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A,YACT;AAAA,aAEF;AAAA,QAEF;AAAA;AAAA,IACD,GACD;AAAA,IAEA,4CAAC,4BACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,KAAM;AAAA,QACN,OAAQ,SAAS;AAAA,QACjB,UAAW;AAAA,QACX,eAAY;AAAA,QACZ,UAAW,MAAM;AAAA,QAAC;AAAA;AAAA,IACnB,GACD;AAAA,IACE,kBACD,4CAAC,SAAI,aAAU,UACd;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAR;AAAA,UACX;AAAA,UACA;AAAA,YACC,cAAc,eAAe,SAAS;AAAA,YACtC,YAAY,eAAe,SAAS;AAAA,UACrC;AAAA,QACD;AAAA,QAEA;AAAA;AAAA,YAAC,kBAAAG;AAAA,YAAA;AAAA,cACA,WAAU;AAAA,cACV,MAAO,aAAAM;AAAA,cACP,MAAO;AAAA,cACP,MAAK;AAAA;AAAA,UACN;AAAA,UACE,eAAe;AAAA;AAAA;AAAA,IAClB,GACD;AAAA,KAEF;AAEF;",
|
|
6
|
-
"names": ["mediaUtilsPrivateApis", "useMovingAnimation", "clsx", "
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tDropZone,\n\tIcon as WCIcon,\n\tSpinner,\n\t__experimentalText as WCText,\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\tBaseControl,\n} from '@wordpress/components';\nimport { isBlobURL, getBlobTypeByURL } from '@wordpress/blob';\nimport { store as coreStore, type Attachment } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tarchive,\n\taudio,\n\tvideo,\n\tfile,\n\tcloseSmall,\n\terror as errorIcon,\n\tchevronUp,\n\tchevronDown,\n\tchevronLeft,\n\tchevronRight,\n} from '@wordpress/icons';\nimport { VisuallyHidden, Tooltip } from '@wordpress/ui';\nimport {\n\tMediaUpload,\n\tuploadMedia,\n\tprivateApis as mediaUtilsPrivateApis,\n} from '@wordpress/media-utils';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport type { MediaEditProps } from '../../types';\nimport useMovingAnimation from './use-moving-animation';\n\nconst { MediaUploadModal } = unlock( mediaUtilsPrivateApis );\n\nfunction AnimatedMediaItem( {\n\tchildren,\n\tindex,\n\tclassName,\n}: {\n\tchildren: React.ReactNode;\n\tindex: number;\n\tclassName?: string;\n} ) {\n\tconst ref = useMovingAnimation( index );\n\treturn (\n\t\t<div ref={ ref } className={ className }>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\ntype BlobItem = {\n\tid: string;\n\tsource_url: string;\n\tmime_type: string | undefined;\n\talt_text?: string;\n};\n\nfunction normalizeValue( value: number | number[] | undefined ): number[] {\n\tif ( Array.isArray( value ) ) {\n\t\treturn value;\n\t}\n\treturn value ? [ value ] : [];\n}\n\n/**\n * Conditional Media component that uses MediaUploadModal when experiment is enabled,\n * otherwise falls back to media-utils MediaUpload.\n *\n * @param root0 Component props.\n * @param root0.render Render prop function that receives { open } object.\n * @param root0.multiple Whether to allow multiple media selections.\n * @return The component.\n */\nfunction ConditionalMediaUpload( { render, multiple, ...props }: any ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tif ( ( window as any ).__experimentalDataViewsMediaModal ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ render && render( { open: () => setIsModalOpen( true ) } ) }\n\t\t\t\t{ isModalOpen && (\n\t\t\t\t\t<MediaUploadModal\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\tisOpen={ isModalOpen }\n\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\tprops.onClose?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonSelect={ ( media: any ) => {\n\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\tprops.onSelect?.( media );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\t// Fallback to media-utils MediaUpload when experiment is disabled.\n\treturn (\n\t\t<MediaUpload\n\t\t\t{ ...props }\n\t\t\trender={ render }\n\t\t\tmultiple={ multiple ? 'add' : undefined }\n\t\t/>\n\t);\n}\n\nfunction MediaPickerButton( {\n\topen,\n\tchildren,\n\tlabel,\n\tshowTooltip = false,\n\tonFilesDrop,\n\tattachment,\n\tisUploading = false,\n}: {\n\topen: () => void;\n\tchildren: React.ReactNode;\n\tlabel: string;\n\tshowTooltip?: boolean;\n\tonFilesDrop: MediaEditAttachmentsProps[ 'onFilesDrop' ];\n\tattachment?: MediaEditAttachment;\n\tisUploading?: boolean;\n} ) {\n\tconst isBlob = attachment && isBlobURL( attachment.source_url );\n\tconst mediaPickerButton = (\n\t\t<div\n\t\t\tclassName={ clsx( 'fields__media-edit-picker-button', {\n\t\t\t\t'has-attachment': attachment,\n\t\t\t} ) }\n\t\t\trole=\"button\"\n\t\t\ttabIndex={ 0 }\n\t\t\tonClick={ () => {\n\t\t\t\tif ( ! isUploading ) {\n\t\t\t\t\topen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( isUploading ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( event.key === 'Enter' || event.key === ' ' ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\topen();\n\t\t\t\t}\n\t\t\t} }\n\t\t\taria-label={ label }\n\t\t\taria-disabled={ isUploading }\n\t\t>\n\t\t\t{ children }\n\t\t\t{ isBlob && (\n\t\t\t\t<span className=\"fields__media-edit-picker-button-spinner\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</span>\n\t\t\t) }\n\t\t\t{ ! isUploading && (\n\t\t\t\t<DropZone\n\t\t\t\t\tonFilesDrop={ ( files ) =>\n\t\t\t\t\t\tonFilesDrop( files, attachment?.id as number )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n\tif ( ! showTooltip ) {\n\t\treturn mediaPickerButton;\n\t}\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger render={ mediaPickerButton } />\n\t\t\t<Tooltip.Popup>{ label }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n\nconst archiveMimeTypes = [\n\t'application/zip',\n\t'application/x-zip-compressed',\n\t'application/x-rar-compressed',\n\t'application/x-7z-compressed',\n\t'application/x-tar',\n\t'application/x-gzip',\n];\n\nfunction MediaTitle( { attachment }: { attachment: Attachment< 'view' > } ) {\n\treturn (\n\t\t<Truncate className=\"fields__media-edit-filename\">\n\t\t\t{ attachment.title.rendered }\n\t\t</Truncate>\n\t);\n}\n\nfunction MediaEditPlaceholder( props: {\n\topen: () => void;\n\tlabel: string;\n\tonFilesDrop: MediaEditAttachmentsProps[ 'onFilesDrop' ];\n\tisUploading: boolean;\n} ) {\n\treturn (\n\t\t<MediaPickerButton { ...props }>\n\t\t\t<span className=\"fields__media-edit-placeholder\">\n\t\t\t\t{ props.label }\n\t\t\t</span>\n\t\t</MediaPickerButton>\n\t);\n}\n\nfunction MoveButtons( {\n\titemId,\n\tindex,\n\ttotalItems,\n\tisUploading,\n\tmoveItem,\n\torientation = 'vertical',\n}: {\n\titemId: number;\n\tindex: number;\n\ttotalItems: number;\n\tisUploading: boolean;\n\tmoveItem: ( id: number, direction: 'up' | 'down' ) => void;\n\torientation?: 'vertical' | 'horizontal';\n} ) {\n\tconst isHorizontal = orientation === 'horizontal';\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\ticon={ isHorizontal ? chevronLeft : chevronUp }\n\t\t\t\tlabel={ isHorizontal ? __( 'Move left' ) : __( 'Move up' ) }\n\t\t\t\tsize=\"small\"\n\t\t\t\tdisabled={ isUploading || index === 0 }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\tonClick={ ( event: React.MouseEvent< HTMLButtonElement > ) => {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tmoveItem( itemId, 'up' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\ticon={ isHorizontal ? chevronRight : chevronDown }\n\t\t\t\tlabel={ isHorizontal ? __( 'Move right' ) : __( 'Move down' ) }\n\t\t\t\tsize=\"small\"\n\t\t\t\tdisabled={ isUploading || index === totalItems - 1 }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\tonClick={ ( event: React.MouseEvent< HTMLButtonElement > ) => {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tmoveItem( itemId, 'down' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nfunction MediaPreview( { attachment }: { attachment: MediaEditAttachment } ) {\n\tconst url = attachment.source_url;\n\tconst mimeType = attachment.mime_type || '';\n\tif ( mimeType.startsWith( 'image' ) ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields__media-edit-thumbnail\"\n\t\t\t\talt={ attachment.alt_text || '' }\n\t\t\t\tsrc={ url }\n\t\t\t/>\n\t\t);\n\t} else if ( mimeType.startsWith( 'audio' ) ) {\n\t\treturn <WCIcon icon={ audio } />;\n\t} else if ( mimeType.startsWith( 'video' ) ) {\n\t\treturn <WCIcon icon={ video } />;\n\t} else if ( archiveMimeTypes.includes( mimeType ) ) {\n\t\treturn <WCIcon icon={ archive } />;\n\t}\n\treturn <WCIcon icon={ file } />;\n}\n\ntype MediaEditAttachment = Attachment< 'view' > | BlobItem;\ninterface MediaEditAttachmentsProps {\n\tallItems: Array< MediaEditAttachment > | null;\n\taddButtonLabel: string;\n\tmultiple?: boolean;\n\tremoveItem: ( itemId: number ) => void;\n\tmoveItem: ( itemId: number, direction: 'up' | 'down' ) => void;\n\topen: () => void;\n\tonFilesDrop: ( files: File[], attachmentId?: number ) => void;\n\tisUploading: boolean;\n\tsetTargetItemId: ( id?: number ) => void;\n}\n\nfunction ExpandedMediaEditAttachments( {\n\tallItems,\n\taddButtonLabel,\n\tmultiple,\n\tremoveItem,\n\tmoveItem,\n\topen,\n\tonFilesDrop,\n\tisUploading,\n\tsetTargetItemId,\n}: MediaEditAttachmentsProps ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'fields__media-edit-expanded', {\n\t\t\t\t'is-multiple': multiple,\n\t\t\t\t'is-single': ! multiple,\n\t\t\t\t'is-empty': ! allItems?.length,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ allItems?.map( ( attachment, index ) => {\n\t\t\t\tconst hasPreviewImage =\n\t\t\t\t\tattachment.mime_type?.startsWith( 'image' );\n\t\t\t\tconst isBlob = isBlobURL( attachment.source_url );\n\t\t\t\tconst attachmentNumericId = attachment.id as number;\n\t\t\t\treturn (\n\t\t\t\t\t<AnimatedMediaItem\n\t\t\t\t\t\tkey={ attachment.id }\n\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\tclassName={ clsx( 'fields__media-edit-expanded-item', {\n\t\t\t\t\t\t\t'has-preview-image': hasPreviewImage,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MediaPickerButton\n\t\t\t\t\t\t\topen={ () => {\n\t\t\t\t\t\t\t\tsetTargetItemId( attachmentNumericId );\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t! isBlob\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: The title of the media item. */\n\t\t\t\t\t\t\t\t\t\t\t__( 'Replace %s' ),\n\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\tattachment as Attachment< 'view' >\n\t\t\t\t\t\t\t\t\t\t\t ).title.rendered\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __( 'Replace' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"fields__media-edit-expanded-preview\">\n\t\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-expanded-preview-stack\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ ( ! isBlob || hasPreviewImage ) && (\n\t\t\t\t\t\t\t\t\t\t<MediaPreview\n\t\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</MediaPickerButton>\n\t\t\t\t\t\t{ ! isBlob && (\n\t\t\t\t\t\t\t<div className=\"fields__media-edit-expanded-overlay\">\n\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-expanded-actions\"\n\t\t\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\t\t\talignment=\"flex-end\"\n\t\t\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ multiple && allItems.length > 1 && (\n\t\t\t\t\t\t\t\t\t\t<MoveButtons\n\t\t\t\t\t\t\t\t\t\t\titemId={ attachmentNumericId }\n\t\t\t\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\t\t\t\ttotalItems={ allItems.length }\n\t\t\t\t\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t\t\t\t\t\tmoveItem={ moveItem }\n\t\t\t\t\t\t\t\t\t\t\torientation=\"horizontal\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\tdisabled={ isUploading }\n\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\tremoveItem( attachmentNumericId );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AnimatedMediaItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ ( multiple || ! allItems?.length ) && (\n\t\t\t\t<MediaEditPlaceholder\n\t\t\t\t\topen={ () => {\n\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ addButtonLabel }\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction CompactMediaEditAttachments( {\n\tallItems,\n\taddButtonLabel,\n\tmultiple,\n\tremoveItem,\n\tmoveItem,\n\topen,\n\tonFilesDrop,\n\tisUploading,\n\tsetTargetItemId,\n}: MediaEditAttachmentsProps ) {\n\treturn (\n\t\t<>\n\t\t\t{ !! allItems?.length && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'fields__media-edit-compact-group', {\n\t\t\t\t\t\t'is-single': allItems.length === 1,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<VStack spacing={ 0 }>\n\t\t\t\t\t\t{ allItems.map( ( attachment, index ) => {\n\t\t\t\t\t\t\tconst isBlob = isBlobURL( attachment.source_url );\n\t\t\t\t\t\t\tconst showMoveButtons =\n\t\t\t\t\t\t\t\tmultiple && allItems.length > 1;\n\t\t\t\t\t\t\tconst attachmentNumericId = attachment.id as number;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<AnimatedMediaItem\n\t\t\t\t\t\t\t\t\tkey={ attachment.id }\n\t\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-compact\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<MediaPickerButton\n\t\t\t\t\t\t\t\t\t\topen={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetTargetItemId(\n\t\t\t\t\t\t\t\t\t\t\t\tattachmentNumericId\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<MediaPreview\n\t\t\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t{ ! isBlob && (\n\t\t\t\t\t\t\t\t\t\t\t\t<MediaTitle\n\t\t\t\t\t\t\t\t\t\t\t\t\tattachment={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tattachment as Attachment< 'view' >\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t</MediaPickerButton>\n\t\t\t\t\t\t\t\t\t{ ! isBlob && (\n\t\t\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-compact-movers\"\n\t\t\t\t\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\t\t\t\t\talignment=\"flex-end\"\n\t\t\t\t\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ showMoveButtons && (\n\t\t\t\t\t\t\t\t\t\t\t\t<MoveButtons\n\t\t\t\t\t\t\t\t\t\t\t\t\titemId={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tattachmentNumericId\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\t\t\t\t\t\ttotalItems={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tallItems.length\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t\t\t\t\t\t\t\tmoveItem={ moveItem }\n\t\t\t\t\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tdisabled={ isUploading }\n\t\t\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tremoveItem(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tattachmentNumericId\n\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</AnimatedMediaItem>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</VStack>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ( multiple || ! allItems?.length ) && (\n\t\t\t\t<MediaEditPlaceholder\n\t\t\t\t\topen={ () => {\n\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ addButtonLabel }\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * A media edit control component that provides a media picker UI with upload functionality\n * for selecting WordPress media attachments. Supports both the traditional WordPress media\n * library and the experimental DataViews media modal.\n *\n * This component is intended to be used as the `Edit` property of a field definition when\n * registering fields with `registerEntityField` from `@wordpress/editor`.\n *\n * @template Item - The type of the item being edited.\n *\n * @param {MediaEditProps<Item>} props - The component props.\n * @param {Item} props.data - The item being edited.\n * @param {Object} props.field - The field configuration with getValue and setValue methods.\n * @param {Function} props.onChange - Callback function when the media selection changes.\n * @param {string[]} [props.allowedTypes] - Array of allowed media types. Use `['*']` to allow all file types. Default `['image']`.\n * @param {boolean} [props.multiple] - Whether to allow multiple media selections. Default `false`.\n * @param {boolean} [props.hideLabelFromVision] - Whether the label should be hidden from vision.\n * @param {boolean} [props.isExpanded] - Whether to render in an expanded form. Default `false`.\n *\n * @return {React.JSX.Element} The media edit control component.\n *\n * @example\n * ```tsx\n * import { MediaEdit } from '@wordpress/fields';\n * import type { DataFormControlProps } from '@wordpress/dataviews';\n *\n * const featuredImageField = {\n * id: 'featured_media',\n * type: 'media',\n * label: 'Featured Image',\n * Edit: (props: DataFormControlProps<MyPostType>) => (\n * <MediaEdit\n * {...props}\n * allowedTypes={['image']}\n * />\n * ),\n * };\n * ```\n */\nexport default function MediaEdit< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tallowedTypes = [ 'image' ],\n\tmultiple,\n\tisExpanded,\n\tvalidity,\n}: MediaEditProps< Item > ) {\n\tconst value = field.getValue( { item: data } );\n\tconst [ isTouched, setIsTouched ] = useState( false );\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst [ customValidity, setCustomValidity ] = useState<\n\t\t| { type: 'valid' | 'validating' | 'invalid'; message?: string }\n\t\t| undefined\n\t>( undefined );\n\t// Listen for invalid event (e.g., form submission, reportValidity())\n\t// to show validation messages even before blur.\n\tuseEffect( () => {\n\t\tconst validityTarget = validityTargetRef.current;\n\t\tconst handler = () => {\n\t\t\tsetIsTouched( true );\n\t\t};\n\t\tvalidityTarget?.addEventListener( 'invalid', handler );\n\t\treturn () => validityTarget?.removeEventListener( 'invalid', handler );\n\t}, [] );\n\tconst attachments = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! value ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst normalizedValue = normalizeValue( value );\n\t\t\t// Sorted IDs ensure stable cache key, avoiding\n\t\t\t// unnecessary new requests on reorder.\n\t\t\tconst sortedIds = normalizedValue.toSorted( ( a, b ) => a - b );\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'postType', 'attachment', {\n\t\t\t\tinclude: sortedIds,\n\t\t\t} ) as Attachment< 'view' >[] | null;\n\t\t},\n\t\t[ value ]\n\t);\n\t// Keep previous attachments during null transitions. When value changes,\n\t// useSelect briefly returns null while the new query resolves. For pure\n\t// reorders (same IDs), we fall back to the cached list to avoid a visual\n\t// flash in compact mode. For replacements/uploads (new IDs not in cache),\n\t// we let attachments be null as normal.\n\tconst stableAttachmentsRef = useRef< Attachment< 'view' >[] | null >(\n\t\tnull\n\t);\n\tif ( attachments !== null ) {\n\t\tstableAttachmentsRef.current = attachments;\n\t}\n\tlet stableAttachments = attachments;\n\tif ( attachments === null && stableAttachmentsRef.current && value ) {\n\t\tconst stableIds = new Set(\n\t\t\tstableAttachmentsRef.current.map( ( a ) => a.id )\n\t\t);\n\t\tif ( normalizeValue( value ).every( ( id ) => stableIds.has( id ) ) ) {\n\t\t\tstableAttachments = stableAttachmentsRef.current;\n\t\t}\n\t}\n\t// Reorder attachments to match value order.\n\tconst orderedAttachments = useMemo( () => {\n\t\tif ( ! stableAttachments ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst normalizedValue = normalizeValue( value );\n\t\tconst attachmentMap = new Map(\n\t\t\tstableAttachments.map( ( a ) => [ a.id, a ] )\n\t\t);\n\t\treturn normalizedValue\n\t\t\t.map( ( id ) => attachmentMap.get( id ) )\n\t\t\t.filter( ( a ): a is Attachment< 'view' > => a !== undefined );\n\t}, [ stableAttachments, value ] );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { receiveEntityRecords } = useDispatch( coreStore );\n\t// Support one upload action at a time for now.\n\tconst [ targetItemId, setTargetItemId ] = useState< number >();\n\t// Deferred open: the legacy class-based MediaUpload reads props\n\t// imperatively when `open()` is called, so calling it in the same\n\t// handler as `setTargetItemId()` would open the modal with stale\n\t// `value`/`multiple` props. Setting a pending flag defers the open\n\t// until after the next render when props are up to date.\n\tconst openModalRef = useRef< () => void >( undefined );\n\tconst [ pendingOpen, setPendingOpen ] = useState( false );\n\tconst [ blobs, setBlobs ] = useState< string[] >( [] );\n\tuseEffect( () => {\n\t\tif ( pendingOpen ) {\n\t\t\tsetPendingOpen( false );\n\t\t\topenModalRef.current?.();\n\t\t}\n\t}, [ pendingOpen ] );\n\tconst onChangeControl = useCallback(\n\t\t( newValue: number | number[] | undefined ) =>\n\t\t\tonChange( field.setValue( { item: data, value: newValue } ) ),\n\t\t[ data, field, onChange ]\n\t);\n\tconst removeItem = useCallback(\n\t\t( itemId: number ) => {\n\t\t\tconst currentIds = normalizeValue( value );\n\t\t\tconst newIds = currentIds.filter( ( id ) => id !== itemId );\n\t\t\t// Mark as touched to immediately show any validation error.\n\t\t\tsetIsTouched( true );\n\t\t\tonChangeControl( newIds.length ? newIds : undefined );\n\t\t},\n\t\t[ value, onChangeControl ]\n\t);\n\tconst moveItem = useCallback(\n\t\t( itemId: number, direction: 'up' | 'down' ) => {\n\t\t\tif ( ! orderedAttachments ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst currentIds = orderedAttachments.map( ( a ) => a.id );\n\t\t\tconst index = currentIds.indexOf( itemId );\n\t\t\tconst newIndex = direction === 'up' ? index - 1 : index + 1;\n\t\t\t[ currentIds[ index ], currentIds[ newIndex ] ] = [\n\t\t\t\tcurrentIds[ newIndex ],\n\t\t\t\tcurrentIds[ index ],\n\t\t\t];\n\t\t\tonChangeControl( currentIds );\n\t\t},\n\t\t[ orderedAttachments, onChangeControl ]\n\t);\n\tconst onFilesDrop = useCallback(\n\t\t( files: File[], _targetItemId?: number ) => {\n\t\t\tsetTargetItemId( _targetItemId );\n\t\t\tuploadMedia( {\n\t\t\t\tallowedTypes: allowedTypes?.length ? allowedTypes : undefined,\n\t\t\t\tfilesList: files,\n\t\t\t\tonFileChange( uploadedMedia: any[] ) {\n\t\t\t\t\tconst blobUrls = uploadedMedia\n\t\t\t\t\t\t.filter( ( item ) => isBlobURL( item.url ) )\n\t\t\t\t\t\t.map( ( item ) => item.url );\n\t\t\t\t\tsetBlobs( blobUrls );\n\t\t\t\t\t// Wait for all uploads to complete before updating value.\n\t\t\t\t\tif ( !! blobUrls.length ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// `uploadMedia` creates attachments via `apiFetch`\n\t\t\t\t\t// outside the core-data store, so invalidate\n\t\t\t\t\t// all attachment queries to keep them fresh for\n\t\t\t\t\t// other components that rely on core-data.\n\t\t\t\t\treceiveEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t[],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t);\n\t\t\t\t\tconst uploadedIds = uploadedMedia.map(\n\t\t\t\t\t\t( item ) => item.id\n\t\t\t\t\t);\n\t\t\t\t\tif ( ! multiple ) {\n\t\t\t\t\t\tonChangeControl( uploadedIds[ 0 ] );\n\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst currentValue = normalizeValue( value );\n\t\t\t\t\t// Dropped on placeholder: append new items.\n\t\t\t\t\tif ( _targetItemId === undefined ) {\n\t\t\t\t\t\tonChangeControl( [ ...currentValue, ...uploadedIds ] );\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Dropped on existing item: insert at that position.\n\t\t\t\t\t\tconst newValue = [ ...currentValue ];\n\t\t\t\t\t\tnewValue.splice(\n\t\t\t\t\t\t\tcurrentValue.indexOf( _targetItemId ),\n\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t...uploadedIds\n\t\t\t\t\t\t);\n\t\t\t\t\t\tonChangeControl( newValue );\n\t\t\t\t\t}\n\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t},\n\t\t\t\tonError( error: Error ) {\n\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\tsetBlobs( [] );\n\t\t\t\t\tcreateErrorNotice( error.message, { type: 'snackbar' } );\n\t\t\t\t},\n\t\t\t\tmultiple: !! multiple,\n\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tallowedTypes,\n\t\t\tvalue,\n\t\t\tmultiple,\n\t\t\tcreateErrorNotice,\n\t\t\tonChangeControl,\n\t\t\treceiveEntityRecords,\n\t\t]\n\t);\n\tconst addButtonLabel =\n\t\tfield.placeholder ||\n\t\t( multiple ? __( 'Choose files' ) : __( 'Choose file' ) );\n\t// Merge real attachments with any existing blob items that are being uploaded.\n\tconst allItems: Array< MediaEditAttachment > | null = useMemo( () => {\n\t\tif ( ! blobs.length ) {\n\t\t\treturn orderedAttachments;\n\t\t}\n\t\tconst items: Array< MediaEditAttachment > = [\n\t\t\t...( orderedAttachments || [] ),\n\t\t];\n\t\tconst blobItems = blobs.map( ( url ) => ( {\n\t\t\tid: url,\n\t\t\tsource_url: url,\n\t\t\tmime_type: getBlobTypeByURL( url ),\n\t\t} ) );\n\t\tif ( targetItemId !== undefined ) {\n\t\t\t// When files are dropped in existing media item, place the blobs at that item.\n\t\t\tconst targetIndex = items.findIndex(\n\t\t\t\t( a ) => a.id === targetItemId\n\t\t\t);\n\t\t\titems.splice( targetIndex, 1, ...blobItems );\n\t\t} else {\n\t\t\titems.push( ...blobItems );\n\t\t}\n\t\treturn items;\n\t}, [ orderedAttachments, targetItemId, blobs ] );\n\tuseEffect( () => {\n\t\tif ( ! isTouched ) {\n\t\t\treturn;\n\t\t}\n\t\tconst input = validityTargetRef.current;\n\t\tif ( ! input ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( validity ) {\n\t\t\tconst customValidityResult = validity?.custom;\n\t\t\tsetCustomValidity( customValidityResult );\n\n\t\t\t// Set custom validity on hidden input for HTML5 form validation.\n\t\t\tif ( customValidityResult?.type === 'invalid' ) {\n\t\t\t\tinput.setCustomValidity(\n\t\t\t\t\tcustomValidityResult.message || __( 'Invalid' )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinput.setCustomValidity( '' ); // Clear validity.\n\t\t\t}\n\t\t} else {\n\t\t\t// Clear any previous validation.\n\t\t\tinput.setCustomValidity( '' );\n\t\t\tsetCustomValidity( undefined );\n\t\t}\n\t}, [ isTouched, field.isValid, validity ] );\n\tconst onBlur = useCallback(\n\t\t( event: React.FocusEvent< HTMLElement > ) => {\n\t\t\tif ( isTouched ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t! event.relatedTarget ||\n\t\t\t\t! event.currentTarget.contains( event.relatedTarget )\n\t\t\t) {\n\t\t\t\tsetIsTouched( true );\n\t\t\t}\n\t\t},\n\t\t[ isTouched ]\n\t);\n\treturn (\n\t\t<div onBlur={ onBlur }>\n\t\t\t<fieldset className=\"fields__media-edit\" data-field-id={ field.id }>\n\t\t\t\t<ConditionalMediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: any ) => {\n\t\t\t\t\t\tif ( ! multiple ) {\n\t\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst newIds = Array.isArray( selectedMedia )\n\t\t\t\t\t\t\t? selectedMedia.map( ( m: any ) => m.id )\n\t\t\t\t\t\t\t: [ selectedMedia.id ];\n\t\t\t\t\t\tconst currentValue = normalizeValue( value );\n\t\t\t\t\t\tif ( ! currentValue.length ) {\n\t\t\t\t\t\t\tonChangeControl( newIds );\n\t\t\t\t\t\t} else if ( targetItemId === undefined ) {\n\t\t\t\t\t\t\t// Placeholder clicked: keep existing items that are\n\t\t\t\t\t\t\t// still selected, then append newly selected items.\n\t\t\t\t\t\t\tconst existingItems = currentValue.filter( ( id ) =>\n\t\t\t\t\t\t\t\tnewIds.includes( id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst newItems = newIds.filter(\n\t\t\t\t\t\t\t\t( id ) => ! currentValue.includes( id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonChangeControl( [\n\t\t\t\t\t\t\t\t...existingItems,\n\t\t\t\t\t\t\t\t...newItems,\n\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t} else if ( selectedMedia.id !== targetItemId ) {\n\t\t\t\t\t\t\t// Remove selected item from its old position, if it\n\t\t\t\t\t\t\t// already exists in the value.\n\t\t\t\t\t\t\tconst filtered = currentValue.filter(\n\t\t\t\t\t\t\t\t( id ) => id !== selectedMedia.id\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t// Replace the clicked item with the selected one.\n\t\t\t\t\t\t\tonChangeControl(\n\t\t\t\t\t\t\t\tfiltered.map( ( id ) =>\n\t\t\t\t\t\t\t\t\tid === targetItemId ? selectedMedia.id : id\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetTargetItemId( undefined );\n\t\t\t\t\t} }\n\t\t\t\t\tonClose={ () => setTargetItemId( undefined ) }\n\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t// When replacing an existing item, pass only that item's ID\n\t\t\t\t\t// and open in single-select mode so the user picks exactly\n\t\t\t\t\t// one replacement, even if `multiple` is true.\n\t\t\t\t\tvalue={ targetItemId !== undefined ? targetItemId : value }\n\t\t\t\t\tmultiple={ multiple && targetItemId === undefined }\n\t\t\t\t\ttitle={ field.label }\n\t\t\t\t\trender={ ( { open }: any ) => {\n\t\t\t\t\t\t// Keep a ref to the latest `open` so the deferred effect can call it.\n\t\t\t\t\t\topenModalRef.current = open;\n\t\t\t\t\t\tconst AttachmentsComponent = isExpanded\n\t\t\t\t\t\t\t? ExpandedMediaEditAttachments\n\t\t\t\t\t\t\t: CompactMediaEditAttachments;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<VStack spacing={ 2 }>\n\t\t\t\t\t\t\t\t{ field.label &&\n\t\t\t\t\t\t\t\t\t( hideLabelFromVision ? (\n\t\t\t\t\t\t\t\t\t\t<VisuallyHidden render={ <legend /> }>\n\t\t\t\t\t\t\t\t\t\t\t{ field.label }\n\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<BaseControl.VisualLabel\n\t\t\t\t\t\t\t\t\t\t\tas=\"legend\"\n\t\t\t\t\t\t\t\t\t\t\tstyle={ { marginBottom: 0 } }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ field.label }\n\t\t\t\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t<AttachmentsComponent\n\t\t\t\t\t\t\t\t\tallItems={ allItems }\n\t\t\t\t\t\t\t\t\taddButtonLabel={ addButtonLabel }\n\t\t\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\t\t\tremoveItem={ removeItem }\n\t\t\t\t\t\t\t\t\tmoveItem={ moveItem }\n\t\t\t\t\t\t\t\t\topen={ () => setPendingOpen( true ) }\n\t\t\t\t\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\t\t\t\t\tisUploading={ !! blobs.length }\n\t\t\t\t\t\t\t\t\tsetTargetItemId={ setTargetItemId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ field.description && (\n\t\t\t\t\t\t\t\t\t<WCText\n\t\t\t\t\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields__media-edit-description\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ field.description }\n\t\t\t\t\t\t\t\t\t</WCText>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</fieldset>\n\t\t\t{ /* Visually hidden text input for validation. */ }\n\t\t\t<VisuallyHidden>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tref={ validityTargetRef }\n\t\t\t\t\tvalue={ value ?? '' }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tonChange={ () => {} }\n\t\t\t\t/>\n\t\t\t</VisuallyHidden>\n\t\t\t{ customValidity && (\n\t\t\t\t<div aria-live=\"polite\">\n\t\t\t\t\t<p\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'components-validated-control__indicator',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-invalid': customValidity.type === 'invalid',\n\t\t\t\t\t\t\t\t'is-valid': customValidity.type === 'valid',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<WCIcon\n\t\t\t\t\t\t\tclassName=\"components-validated-control__indicator-icon\"\n\t\t\t\t\t\t\ticon={ errorIcon }\n\t\t\t\t\t\t\tsize={ 16 }\n\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ customValidity.message }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n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AAA,gBACA,MAAO,MAAM,eAAgB,IAAK;AAAA,gBAClC;AAAA,gBACA,aAAc,CAAC,CAAE,MAAM;AAAA,gBACvB;AAAA;AAAA,YACD;AAAA,YACE,MAAM,eACP;AAAA,cAAC,kBAAAI;AAAA,cAAA;AAAA,gBACA,SAAQ;AAAA,gBACR,WAAU;AAAA,gBAER,gBAAM;AAAA;AAAA,YACT;AAAA,aAEF;AAAA,QAEF;AAAA;AAAA,IACD,GACD;AAAA,IAEA,4CAAC,4BACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,KAAM;AAAA,QACN,OAAQ,SAAS;AAAA,QACjB,UAAW;AAAA,QACX,eAAY;AAAA,QACZ,UAAW,MAAM;AAAA,QAAC;AAAA;AAAA,IACnB,GACD;AAAA,IACE,kBACD,4CAAC,SAAI,aAAU,UACd;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAP;AAAA,UACX;AAAA,UACA;AAAA,YACC,cAAc,eAAe,SAAS;AAAA,YACtC,YAAY,eAAe,SAAS;AAAA,UACrC;AAAA,QACD;AAAA,QAEA;AAAA;AAAA,YAAC,kBAAAE;AAAA,YAAA;AAAA,cACA,WAAU;AAAA,cACV,MAAO,aAAAM;AAAA,cACP,MAAO;AAAA,cACP,MAAK;AAAA;AAAA,UACN;AAAA,UACE,eAAe;AAAA;AAAA;AAAA,IAClB,GACD;AAAA,KAEF;AAEF;",
|
|
6
|
+
"names": ["mediaUtilsPrivateApis", "useMovingAnimation", "clsx", "Truncate", "WCIcon", "VStack", "HStack", "coreStore", "noticesStore", "WCText", "errorIcon"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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/fields/src/fields/description/index.tsx
|
|
21
|
+
var description_exports = {};
|
|
22
|
+
__export(description_exports, {
|
|
23
|
+
default: () => description_default,
|
|
24
|
+
readOnlyDescriptionField: () => readOnlyDescriptionField
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(description_exports);
|
|
27
|
+
var import_html_entities = require("@wordpress/html-entities");
|
|
28
|
+
var import_i18n = require("@wordpress/i18n");
|
|
29
|
+
var import_ui = require("@wordpress/ui");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var isCustomTemplate = (item) => item.source === "custom" && !item.has_theme_file && item.is_custom;
|
|
32
|
+
var getValue = ({ item }) => (0, import_html_entities.decodeEntities)(item.description || "");
|
|
33
|
+
var render = ({ item }) => {
|
|
34
|
+
const { description } = item;
|
|
35
|
+
return description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Text, { children: (0, import_html_entities.decodeEntities)(description) });
|
|
36
|
+
};
|
|
37
|
+
var descriptionField = {
|
|
38
|
+
id: "description",
|
|
39
|
+
type: "text",
|
|
40
|
+
label: (0, import_i18n.__)("Description"),
|
|
41
|
+
placeholder: (0, import_i18n.__)("Add a description"),
|
|
42
|
+
getValue,
|
|
43
|
+
render,
|
|
44
|
+
Edit: {
|
|
45
|
+
control: "textarea",
|
|
46
|
+
rows: 4
|
|
47
|
+
},
|
|
48
|
+
isVisible: isCustomTemplate,
|
|
49
|
+
enableSorting: false,
|
|
50
|
+
filterBy: false,
|
|
51
|
+
enableGlobalSearch: true
|
|
52
|
+
};
|
|
53
|
+
var readOnlyDescriptionField = {
|
|
54
|
+
id: "description_readonly",
|
|
55
|
+
type: "text",
|
|
56
|
+
label: (0, import_i18n.__)("Description"),
|
|
57
|
+
getValue,
|
|
58
|
+
render,
|
|
59
|
+
readOnly: true,
|
|
60
|
+
isVisible: (item) => !isCustomTemplate(item) && !!item.description,
|
|
61
|
+
enableSorting: false,
|
|
62
|
+
filterBy: false
|
|
63
|
+
};
|
|
64
|
+
var description_default = descriptionField;
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
readOnlyDescriptionField
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/fields/description/index.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { Text } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type { Template } from '../../types';\n\n// A template is editable only when it's a user-created custom template.\n// Theme-provided templates surface a read-only description instead.\nconst isCustomTemplate = ( item: Template ) =>\n\titem.source === 'custom' && ! item.has_theme_file && item.is_custom;\n\nconst getValue = ( { item }: { item: Template } ) =>\n\tdecodeEntities( item.description || '' );\n\nconst render = ( { item }: { item: Template } ) => {\n\tconst { description } = item;\n\treturn description && <Text>{ decodeEntities( description ) }</Text>;\n};\n\nconst descriptionField: Field< Template > = {\n\tid: 'description',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tplaceholder: __( 'Add a description' ),\n\tgetValue,\n\trender,\n\tEdit: {\n\t\tcontrol: 'textarea',\n\t\trows: 4,\n\t},\n\tisVisible: isCustomTemplate,\n\tenableSorting: false,\n\tfilterBy: false,\n\tenableGlobalSearch: true,\n};\n\n/**\n * Read-only description field for theme-provided templates, which can't be\n * edited. Shares the display config with `descriptionField` but renders as\n * read-only and is only visible when a description exists.\n */\nexport const readOnlyDescriptionField: Field< Template > = {\n\tid: 'description_readonly',\n\ttype: 'text',\n\tlabel: __( 'Description' ),\n\tgetValue,\n\trender,\n\treadOnly: true,\n\tisVisible: ( item ) => ! isCustomTemplate( item ) && !! item.description,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * Description field for templates.\n */\nexport default descriptionField;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,2BAA+B;AAC/B,kBAAmB;AACnB,gBAAqB;AAiBE;AARvB,IAAM,mBAAmB,CAAE,SAC1B,KAAK,WAAW,YAAY,CAAE,KAAK,kBAAkB,KAAK;AAE3D,IAAM,WAAW,CAAE,EAAE,KAAK,UACzB,qCAAgB,KAAK,eAAe,EAAG;AAExC,IAAM,SAAS,CAAE,EAAE,KAAK,MAA2B;AAClD,QAAM,EAAE,YAAY,IAAI;AACxB,SAAO,eAAe,4CAAC,kBAAO,mDAAgB,WAAY,GAAG;AAC9D;AAEA,IAAM,mBAAsC;AAAA,EAC3C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,aAAc;AAAA,EACzB,iBAAa,gBAAI,mBAAoB;AAAA,EACrC;AAAA,EACA;AAAA,EACA,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EACP;AAAA,EACA,WAAW;AAAA,EACX,eAAe;AAAA,EACf,UAAU;AAAA,EACV,oBAAoB;AACrB;AAOO,IAAM,2BAA8C;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,aAAc;AAAA,EACzB;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,WAAW,CAAE,SAAU,CAAE,iBAAkB,IAAK,KAAK,CAAC,CAAE,KAAK;AAAA,EAC7D,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,sBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/fields/index.cjs
CHANGED
|
@@ -33,10 +33,12 @@ __export(fields_exports, {
|
|
|
33
33
|
authorField: () => import_author.default,
|
|
34
34
|
commentStatusField: () => import_comment_status.default,
|
|
35
35
|
dateField: () => import_date.default,
|
|
36
|
+
descriptionField: () => import_description.default,
|
|
36
37
|
discussionField: () => import_discussion.default,
|
|
37
38
|
excerptField: () => import_excerpt.default,
|
|
38
39
|
featuredImageField: () => import_featured_image.default,
|
|
39
40
|
formatField: () => import_format.default,
|
|
41
|
+
lastEditedDateField: () => import_last_edited.default,
|
|
40
42
|
notesField: () => import_notes.default,
|
|
41
43
|
orderField: () => import_order.default,
|
|
42
44
|
pageTitleField: () => import_page_title.default,
|
|
@@ -45,7 +47,11 @@ __export(fields_exports, {
|
|
|
45
47
|
patternTitleField: () => import_pattern_title.default,
|
|
46
48
|
pingStatusField: () => import_ping_status.default,
|
|
47
49
|
postContentInfoField: () => import_post_content_info.default,
|
|
48
|
-
|
|
50
|
+
postsPageTitleField: () => import_posts_page_title.default,
|
|
51
|
+
postsPerPageField: () => import_posts_per_page.default,
|
|
52
|
+
readOnlyDescriptionField: () => import_description.readOnlyDescriptionField,
|
|
53
|
+
scheduledDateField: () => import_scheduled_date.default,
|
|
54
|
+
siteDiscussionField: () => import_site_discussion.default,
|
|
49
55
|
slugField: () => import_slug.default,
|
|
50
56
|
statusField: () => import_status.default,
|
|
51
57
|
stickyField: () => import_sticky.default,
|
|
@@ -69,22 +75,29 @@ var import_comment_status = __toESM(require("./comment-status/index.cjs"));
|
|
|
69
75
|
var import_ping_status = __toESM(require("./ping-status/index.cjs"));
|
|
70
76
|
var import_discussion = __toESM(require("./discussion/index.cjs"));
|
|
71
77
|
var import_date = __toESM(require("./date/index.cjs"));
|
|
72
|
-
var
|
|
78
|
+
var import_scheduled_date = __toESM(require("./scheduled-date/index.cjs"));
|
|
79
|
+
var import_last_edited = __toESM(require("./last-edited/index.cjs"));
|
|
73
80
|
var import_author = __toESM(require("./author/index.cjs"));
|
|
74
81
|
var import_notes = __toESM(require("./notes/index.cjs"));
|
|
75
82
|
var import_excerpt = __toESM(require("./excerpt/index.cjs"));
|
|
83
|
+
var import_description = __toESM(require("./description/index.cjs"));
|
|
76
84
|
var import_format = __toESM(require("./format/index.cjs"));
|
|
77
85
|
var import_post_content_info = __toESM(require("./post-content-info/index.cjs"));
|
|
78
86
|
var import_sticky = __toESM(require("./sticky/index.cjs"));
|
|
87
|
+
var import_posts_per_page = __toESM(require("./posts-per-page/index.cjs"));
|
|
88
|
+
var import_site_discussion = __toESM(require("./site-discussion/index.cjs"));
|
|
89
|
+
var import_posts_page_title = __toESM(require("./posts-page-title/index.cjs"));
|
|
79
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
80
91
|
0 && (module.exports = {
|
|
81
92
|
authorField,
|
|
82
93
|
commentStatusField,
|
|
83
94
|
dateField,
|
|
95
|
+
descriptionField,
|
|
84
96
|
discussionField,
|
|
85
97
|
excerptField,
|
|
86
98
|
featuredImageField,
|
|
87
99
|
formatField,
|
|
100
|
+
lastEditedDateField,
|
|
88
101
|
notesField,
|
|
89
102
|
orderField,
|
|
90
103
|
pageTitleField,
|
|
@@ -93,7 +106,11 @@ var import_sticky = __toESM(require("./sticky/index.cjs"));
|
|
|
93
106
|
patternTitleField,
|
|
94
107
|
pingStatusField,
|
|
95
108
|
postContentInfoField,
|
|
109
|
+
postsPageTitleField,
|
|
110
|
+
postsPerPageField,
|
|
111
|
+
readOnlyDescriptionField,
|
|
96
112
|
scheduledDateField,
|
|
113
|
+
siteDiscussionField,
|
|
97
114
|
slugField,
|
|
98
115
|
statusField,
|
|
99
116
|
stickyField,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/fields/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as pageTitleField } from './page-title';\nexport { default as templateTitleField } from './template-title';\nexport { default as patternTitleField } from './pattern-title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as templateField } from './template';\nexport { default as parentField } from './parent';\nexport { default as passwordField } from './password';\nexport { default as statusField } from './status';\nexport { default as commentStatusField } from './comment-status';\nexport { default as pingStatusField } from './ping-status';\nexport { default as discussionField } from './discussion';\nexport { default as dateField } from './date';\nexport { default as scheduledDateField } from './date
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqC;AACrC,mBAAsC;AACtC,wBAA0C;AAC1C,4BAA8C;AAC9C,2BAA6C;AAC7C,mBAAsC;AACtC,4BAA8C;AAC9C,sBAAyC;AACzC,oBAAuC;AACvC,sBAAyC;AACzC,oBAAuC;AACvC,4BAA8C;AAC9C,yBAA2C;AAC3C,wBAA2C;AAC3C,kBAAqC;AACrC,
|
|
4
|
+
"sourcesContent": ["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as pageTitleField } from './page-title';\nexport { default as templateTitleField } from './template-title';\nexport { default as patternTitleField } from './pattern-title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as templateField } from './template';\nexport { default as parentField } from './parent';\nexport { default as passwordField } from './password';\nexport { default as statusField } from './status';\nexport { default as commentStatusField } from './comment-status';\nexport { default as pingStatusField } from './ping-status';\nexport { default as discussionField } from './discussion';\nexport { default as dateField } from './date';\nexport { default as scheduledDateField } from './scheduled-date';\nexport { default as lastEditedDateField } from './last-edited';\nexport { default as authorField } from './author';\nexport { default as notesField } from './notes';\nexport { default as excerptField } from './excerpt';\nexport {\n\tdefault as descriptionField,\n\treadOnlyDescriptionField,\n} from './description';\nexport { default as formatField } from './format';\nexport { default as postContentInfoField } from './post-content-info';\nexport { default as stickyField } from './sticky';\nexport { default as postsPerPageField } from './posts-per-page';\nexport { default as siteDiscussionField } from './site-discussion';\nexport { default as postsPageTitleField } from './posts-page-title';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqC;AACrC,mBAAsC;AACtC,wBAA0C;AAC1C,4BAA8C;AAC9C,2BAA6C;AAC7C,mBAAsC;AACtC,4BAA8C;AAC9C,sBAAyC;AACzC,oBAAuC;AACvC,sBAAyC;AACzC,oBAAuC;AACvC,4BAA8C;AAC9C,yBAA2C;AAC3C,wBAA2C;AAC3C,kBAAqC;AACrC,4BAA8C;AAC9C,yBAA+C;AAC/C,oBAAuC;AACvC,mBAAsC;AACtC,qBAAwC;AACxC,yBAGO;AACP,oBAAuC;AACvC,+BAAgD;AAChD,oBAAuC;AACvC,4BAA6C;AAC7C,6BAA+C;AAC/C,8BAA+C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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/fields/src/fields/last-edited/index.tsx
|
|
31
|
+
var last_edited_exports = {};
|
|
32
|
+
__export(last_edited_exports, {
|
|
33
|
+
default: () => last_edited_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(last_edited_exports);
|
|
36
|
+
var import_i18n = require("@wordpress/i18n");
|
|
37
|
+
var import_last_edited_date_view = __toESM(require("./last-edited-date-view.cjs"));
|
|
38
|
+
var lastEditedDateField = {
|
|
39
|
+
id: "last_edited_date",
|
|
40
|
+
type: "datetime",
|
|
41
|
+
label: (0, import_i18n.__)("Last edited"),
|
|
42
|
+
render: import_last_edited_date_view.default,
|
|
43
|
+
getValue: ({ item }) => item.modified,
|
|
44
|
+
isVisible: (item) => !!item.modified,
|
|
45
|
+
readOnly: true,
|
|
46
|
+
enableHiding: false,
|
|
47
|
+
enableSorting: false,
|
|
48
|
+
filterBy: false
|
|
49
|
+
};
|
|
50
|
+
var last_edited_default = lastEditedDateField;
|
|
51
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/fields/last-edited/index.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport LastEditedDateView from './last-edited-date-view';\n\nconst lastEditedDateField: Field< BasePost > = {\n\tid: 'last_edited_date',\n\ttype: 'datetime',\n\tlabel: __( 'Last edited' ),\n\trender: LastEditedDateView,\n\tgetValue: ( { item } ) => item.modified,\n\tisVisible: ( item ) => !! item.modified,\n\treadOnly: true,\n\tenableHiding: false,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * Last edited date field for BasePost.\n */\nexport default lastEditedDateField;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AAMnB,mCAA+B;AAE/B,IAAM,sBAAyC;AAAA,EAC9C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAO,gBAAI,aAAc;AAAA,EACzB,QAAQ,6BAAAA;AAAA,EACR,UAAU,CAAE,EAAE,KAAK,MAAO,KAAK;AAAA,EAC/B,WAAW,CAAE,SAAU,CAAC,CAAE,KAAK;AAAA,EAC/B,UAAU;AAAA,EACV,cAAc;AAAA,EACd,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,sBAAQ;",
|
|
6
|
+
"names": ["LastEditedDateView"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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/fields/src/fields/last-edited/last-edited-date-view.tsx
|
|
21
|
+
var last_edited_date_view_exports = {};
|
|
22
|
+
__export(last_edited_date_view_exports, {
|
|
23
|
+
default: () => LastEditedDateView
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(last_edited_date_view_exports);
|
|
26
|
+
var import_ui = require("@wordpress/ui");
|
|
27
|
+
var import_i18n = require("@wordpress/i18n");
|
|
28
|
+
var import_date = require("@wordpress/date");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
function LastEditedDateView({ item }) {
|
|
31
|
+
if (!item.modified) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Text, { children: (0, import_i18n.sprintf)(
|
|
35
|
+
// translators: %s: Human-readable time difference, e.g. "2 days ago".
|
|
36
|
+
(0, import_i18n.__)("Last edited %s."),
|
|
37
|
+
(0, import_date.humanTimeDiff)(item.modified)
|
|
38
|
+
) });
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=last-edited-date-view.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/fields/last-edited/last-edited-date-view.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Text } from '@wordpress/ui';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { humanTimeDiff } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport default function LastEditedDateView( { item }: { item: BasePost } ) {\n\tif ( ! item.modified ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Text>\n\t\t\t{ sprintf(\n\t\t\t\t// translators: %s: Human-readable time difference, e.g. \"2 days ago\".\n\t\t\t\t__( 'Last edited %s.' ),\n\t\t\t\thumanTimeDiff( item.modified )\n\t\t\t) }\n\t\t</Text>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gBAAqB;AACrB,kBAA4B;AAC5B,kBAA8B;AAY5B;AALa,SAAR,mBAAqC,EAAE,KAAK,GAAwB;AAC1E,MAAK,CAAE,KAAK,UAAW;AACtB,WAAO;AAAA,EACR;AACA,SACC,4CAAC,kBACE;AAAA;AAAA,QAED,gBAAI,iBAAkB;AAAA,QACtB,2BAAe,KAAK,QAAS;AAAA,EAC9B,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|