@wordpress/fields 0.29.0 → 0.29.1-next.06ee73755.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 +0 -2
- package/LICENSE.md +1 -1
- package/README.md +41 -0
- package/build/actions/{delete-post.js → delete-post.cjs} +4 -4
- package/build/actions/{duplicate-pattern.js → duplicate-pattern.cjs} +2 -2
- package/build/actions/{duplicate-post.js → duplicate-post.cjs} +2 -2
- package/build/actions/{duplicate-template-part.js → duplicate-template-part.cjs} +3 -3
- package/build/actions/{export-pattern.js → export-pattern.cjs} +2 -2
- package/build/actions/{index.js → index.cjs} +14 -14
- package/build/actions/{permanently-delete-post.js → permanently-delete-post.cjs} +2 -2
- package/build/actions/{rename-post.js → rename-post.cjs} +3 -4
- package/build/actions/{rename-post.js.map → rename-post.cjs.map} +2 -2
- package/build/actions/{reorder-page.js → reorder-page.cjs} +2 -2
- package/build/actions/reorder-page.cjs.map +7 -0
- package/build/actions/{reset-post.js → reset-post.cjs} +2 -2
- package/build/actions/{restore-post.js → restore-post.cjs} +2 -2
- package/build/actions/{trash-post.js → trash-post.cjs} +2 -2
- package/build/actions/{utils.js → utils.cjs} +1 -1
- package/build/actions/{view-post-revisions.js → view-post-revisions.cjs} +1 -1
- package/build/actions/{view-post.js → view-post.cjs} +1 -1
- package/build/components/create-template-part-modal/{index.js → index.cjs} +3 -4
- package/build/components/create-template-part-modal/index.cjs.map +7 -0
- package/build/components/create-template-part-modal/{utils.js → utils.cjs} +1 -1
- package/build/components/media-edit/index.cjs +494 -0
- package/build/components/media-edit/index.cjs.map +7 -0
- package/build/fields/author/{author-view.js → author-view.cjs} +1 -1
- package/build/fields/author/{index.js → index.cjs} +2 -2
- package/build/fields/comment-status/{index.js → index.cjs} +1 -1
- package/build/fields/date/{date-view.js → date-view.cjs} +1 -1
- package/build/fields/date/{index.js → index.cjs} +2 -2
- package/build/fields/discussion/{index.js → index.cjs} +1 -1
- package/build/fields/featured-image/{featured-image-view.js → featured-image-view.cjs} +1 -1
- package/build/fields/featured-image/index.cjs +52 -0
- package/build/fields/featured-image/index.cjs.map +7 -0
- package/build/fields/{index.js → index.cjs} +18 -18
- package/build/fields/notes/{index.js → index.cjs} +1 -1
- package/build/fields/order/{index.js → index.cjs} +1 -1
- package/build/fields/page-title/{index.js → index.cjs} +3 -3
- package/build/fields/page-title/{view.js → view.cjs} +3 -3
- package/build/fields/parent/{index.js → index.cjs} +3 -3
- package/build/fields/parent/{parent-edit.js → parent-edit.cjs} +2 -3
- package/build/fields/parent/{parent-edit.js.map → parent-edit.cjs.map} +2 -2
- package/build/fields/parent/{parent-view.js → parent-view.cjs} +2 -2
- package/build/fields/parent/{utils.js → utils.cjs} +1 -1
- package/build/fields/password/{edit.js → edit.cjs} +1 -3
- package/build/fields/password/{edit.js.map → edit.cjs.map} +2 -2
- package/build/fields/password/{index.js → index.cjs} +2 -2
- package/build/fields/pattern-title/{index.js → index.cjs} +3 -3
- package/build/fields/pattern-title/{view.js → view.cjs} +3 -3
- package/build/fields/ping-status/{index.js → index.cjs} +1 -2
- package/build/fields/ping-status/index.cjs.map +7 -0
- package/build/fields/slug/{index.js → index.cjs} +3 -3
- package/build/fields/slug/{slug-edit.js → slug-edit.cjs} +2 -2
- package/build/fields/slug/{slug-view.js → slug-view.cjs} +2 -2
- package/build/fields/slug/{utils.js → utils.cjs} +2 -2
- package/build/fields/status/{index.js → index.cjs} +3 -3
- package/build/fields/status/{status-elements.js → status-elements.cjs} +1 -1
- package/build/fields/status/{status-view.js → status-view.cjs} +2 -2
- package/build/fields/template/{index.js → index.cjs} +2 -2
- package/build/fields/template/{template-edit.js → template-edit.cjs} +3 -3
- package/build/fields/template-title/{index.js → index.cjs} +3 -3
- package/build/fields/title/{index.js → index.cjs} +3 -3
- package/build/fields/title/{view.js → view.cjs} +2 -2
- package/build/{index.js → index.cjs} +10 -7
- package/build/index.cjs.map +7 -0
- package/build/{lock-unlock.js → lock-unlock.cjs} +1 -1
- package/build/mutation/{index.js → index.cjs} +1 -1
- package/build/{types.js → types.cjs} +1 -1
- package/build/types.cjs.map +7 -0
- package/build-module/actions/{delete-post.js → delete-post.mjs} +4 -4
- package/build-module/actions/{duplicate-pattern.js → duplicate-pattern.mjs} +2 -2
- package/build-module/actions/{duplicate-post.js → duplicate-post.mjs} +2 -2
- package/build-module/actions/{duplicate-template-part.js → duplicate-template-part.mjs} +3 -3
- package/build-module/actions/{export-pattern.js → export-pattern.mjs} +2 -2
- package/build-module/actions/index.mjs +30 -0
- package/build-module/actions/{permanently-delete-post.js → permanently-delete-post.mjs} +2 -2
- package/build-module/actions/{rename-post.js → rename-post.mjs} +3 -4
- package/build-module/actions/{rename-post.js.map → rename-post.mjs.map} +2 -2
- package/build-module/actions/{reorder-page.js → reorder-page.mjs} +2 -2
- package/build-module/actions/reorder-page.mjs.map +7 -0
- package/build-module/actions/{reset-post.js → reset-post.mjs} +2 -2
- package/build-module/actions/{restore-post.js → restore-post.mjs} +2 -2
- package/build-module/actions/{trash-post.js → trash-post.mjs} +2 -2
- package/build-module/actions/{utils.js → utils.mjs} +1 -1
- package/build-module/actions/{view-post-revisions.js → view-post-revisions.mjs} +1 -1
- package/build-module/actions/{view-post.js → view-post.mjs} +1 -1
- package/build-module/components/create-template-part-modal/{index.js → index.mjs} +3 -4
- package/build-module/components/create-template-part-modal/index.mjs.map +7 -0
- package/build-module/components/create-template-part-modal/{utils.js → utils.mjs} +1 -1
- package/build-module/components/media-edit/index.mjs +478 -0
- package/build-module/components/media-edit/index.mjs.map +7 -0
- package/build-module/fields/author/{author-view.js → author-view.mjs} +1 -1
- package/build-module/fields/author/{index.js → index.mjs} +2 -2
- package/build-module/fields/comment-status/{index.js → index.mjs} +1 -1
- package/build-module/fields/date/{date-view.js → date-view.mjs} +1 -1
- package/build-module/fields/date/{index.js → index.mjs} +2 -2
- package/build-module/fields/discussion/{index.js → index.mjs} +1 -1
- package/build-module/fields/featured-image/{featured-image-view.js → featured-image-view.mjs} +1 -1
- package/build-module/fields/featured-image/{index.js → index.mjs} +8 -5
- package/build-module/fields/featured-image/index.mjs.map +7 -0
- package/build-module/fields/index.mjs +38 -0
- package/build-module/fields/notes/{index.js → index.mjs} +1 -1
- package/build-module/fields/order/{index.js → index.mjs} +1 -1
- package/build-module/fields/page-title/{index.js → index.mjs} +3 -3
- package/build-module/fields/page-title/{view.js → view.mjs} +3 -3
- package/build-module/fields/parent/{index.js → index.mjs} +3 -3
- package/build-module/fields/parent/{parent-edit.js → parent-edit.mjs} +2 -3
- package/build-module/fields/parent/{parent-edit.js.map → parent-edit.mjs.map} +2 -2
- package/build-module/fields/parent/{parent-view.js → parent-view.mjs} +2 -2
- package/build-module/fields/parent/{utils.js → utils.mjs} +1 -1
- package/build-module/fields/password/{edit.js → edit.mjs} +1 -3
- package/build-module/fields/password/{edit.js.map → edit.mjs.map} +2 -2
- package/build-module/fields/password/{index.js → index.mjs} +2 -2
- package/build-module/fields/pattern-title/{index.js → index.mjs} +3 -3
- package/build-module/fields/pattern-title/{view.js → view.mjs} +3 -3
- package/build-module/fields/ping-status/{index.js → index.mjs} +1 -2
- package/build-module/fields/ping-status/index.mjs.map +7 -0
- package/build-module/fields/slug/{index.js → index.mjs} +3 -3
- package/build-module/fields/slug/{slug-edit.js → slug-edit.mjs} +2 -2
- package/build-module/fields/slug/{slug-view.js → slug-view.mjs} +2 -2
- package/build-module/fields/slug/{utils.js → utils.mjs} +2 -2
- package/build-module/fields/status/{index.js → index.mjs} +3 -3
- package/build-module/fields/status/{status-elements.js → status-elements.mjs} +1 -1
- package/build-module/fields/status/{status-view.js → status-view.mjs} +2 -2
- package/build-module/fields/template/{index.js → index.mjs} +2 -2
- package/build-module/fields/template/{template-edit.js → template-edit.mjs} +3 -3
- package/build-module/fields/template-title/{index.js → index.mjs} +3 -3
- package/build-module/fields/title/{index.js → index.mjs} +3 -3
- package/build-module/fields/title/{view.js → view.mjs} +2 -2
- package/build-module/index.mjs +10 -0
- package/build-module/index.mjs.map +7 -0
- package/build-module/{lock-unlock.js → lock-unlock.mjs} +1 -1
- package/build-module/mutation/{index.js → index.mjs} +1 -1
- package/build-module/types.mjs +1 -0
- package/build-style/style-rtl.css +191 -62
- package/build-style/style.css +191 -62
- package/build-types/actions/rename-post.d.ts.map +1 -1
- package/build-types/actions/reorder-page.d.ts.map +1 -1
- package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
- package/build-types/components/media-edit/index.d.ts +42 -0
- package/build-types/components/media-edit/index.d.ts.map +1 -0
- package/build-types/fields/featured-image/index.d.ts +0 -3
- package/build-types/fields/featured-image/index.d.ts.map +1 -1
- package/build-types/fields/parent/parent-edit.d.ts.map +1 -1
- package/build-types/fields/password/edit.d.ts.map +1 -1
- package/build-types/fields/ping-status/index.d.ts.map +1 -1
- package/build-types/index.d.ts +2 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/types.d.ts +24 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +38 -30
- package/src/actions/rename-post.tsx +0 -1
- package/src/actions/reorder-page.tsx +1 -2
- package/src/components/create-template-part-modal/index.tsx +2 -3
- package/src/components/media-edit/index.tsx +616 -0
- package/src/components/media-edit/style.scss +232 -0
- package/src/fields/featured-image/{index.ts → index.tsx} +5 -2
- package/src/fields/featured-image/style.scss +7 -89
- package/src/fields/parent/parent-edit.tsx +0 -1
- package/src/fields/password/edit.tsx +0 -2
- package/src/fields/ping-status/index.tsx +0 -1
- package/src/index.ts +2 -0
- package/src/style.scss +1 -0
- package/src/types.ts +30 -0
- package/build/actions/reorder-page.js.map +0 -7
- package/build/components/create-template-part-modal/index.js.map +0 -7
- package/build/fields/featured-image/featured-image-edit.js +0 -162
- package/build/fields/featured-image/featured-image-edit.js.map +0 -7
- package/build/fields/featured-image/index.js +0 -39
- package/build/fields/featured-image/index.js.map +0 -7
- package/build/fields/ping-status/index.js.map +0 -7
- package/build/index.js.map +0 -7
- package/build/types.js.map +0 -7
- package/build-module/actions/index.js +0 -30
- package/build-module/actions/reorder-page.js.map +0 -7
- package/build-module/components/create-template-part-modal/index.js.map +0 -7
- package/build-module/fields/featured-image/featured-image-edit.js +0 -140
- package/build-module/fields/featured-image/featured-image-edit.js.map +0 -7
- package/build-module/fields/featured-image/index.js.map +0 -7
- package/build-module/fields/index.js +0 -38
- package/build-module/fields/ping-status/index.js.map +0 -7
- package/build-module/index.js +0 -8
- package/build-module/index.js.map +0 -7
- package/build-module/types.js +0 -1
- package/build-types/fields/featured-image/featured-image-edit.d.ts +0 -7
- package/build-types/fields/featured-image/featured-image-edit.d.ts.map +0 -1
- package/src/fields/featured-image/featured-image-edit.tsx +0 -170
- package/tsconfig.json +0 -31
- package/tsconfig.tsbuildinfo +0 -1
- /package/build/actions/{delete-post.js.map → delete-post.cjs.map} +0 -0
- /package/build/actions/{duplicate-pattern.js.map → duplicate-pattern.cjs.map} +0 -0
- /package/build/actions/{duplicate-post.js.map → duplicate-post.cjs.map} +0 -0
- /package/build/actions/{duplicate-template-part.js.map → duplicate-template-part.cjs.map} +0 -0
- /package/build/actions/{export-pattern.js.map → export-pattern.cjs.map} +0 -0
- /package/build/actions/{index.js.map → index.cjs.map} +0 -0
- /package/build/actions/{permanently-delete-post.js.map → permanently-delete-post.cjs.map} +0 -0
- /package/build/actions/{reset-post.js.map → reset-post.cjs.map} +0 -0
- /package/build/actions/{restore-post.js.map → restore-post.cjs.map} +0 -0
- /package/build/actions/{trash-post.js.map → trash-post.cjs.map} +0 -0
- /package/build/actions/{utils.js.map → utils.cjs.map} +0 -0
- /package/build/actions/{view-post-revisions.js.map → view-post-revisions.cjs.map} +0 -0
- /package/build/actions/{view-post.js.map → view-post.cjs.map} +0 -0
- /package/build/components/create-template-part-modal/{utils.js.map → utils.cjs.map} +0 -0
- /package/build/fields/author/{author-view.js.map → author-view.cjs.map} +0 -0
- /package/build/fields/author/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/comment-status/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/date/{date-view.js.map → date-view.cjs.map} +0 -0
- /package/build/fields/date/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/discussion/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/featured-image/{featured-image-view.js.map → featured-image-view.cjs.map} +0 -0
- /package/build/fields/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/notes/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/order/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/page-title/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/page-title/{view.js.map → view.cjs.map} +0 -0
- /package/build/fields/parent/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/parent/{parent-view.js.map → parent-view.cjs.map} +0 -0
- /package/build/fields/parent/{utils.js.map → utils.cjs.map} +0 -0
- /package/build/fields/password/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/pattern-title/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/pattern-title/{view.js.map → view.cjs.map} +0 -0
- /package/build/fields/slug/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/slug/{slug-edit.js.map → slug-edit.cjs.map} +0 -0
- /package/build/fields/slug/{slug-view.js.map → slug-view.cjs.map} +0 -0
- /package/build/fields/slug/{utils.js.map → utils.cjs.map} +0 -0
- /package/build/fields/status/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/status/{status-elements.js.map → status-elements.cjs.map} +0 -0
- /package/build/fields/status/{status-view.js.map → status-view.cjs.map} +0 -0
- /package/build/fields/template/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/template/{template-edit.js.map → template-edit.cjs.map} +0 -0
- /package/build/fields/template-title/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/title/{index.js.map → index.cjs.map} +0 -0
- /package/build/fields/title/{view.js.map → view.cjs.map} +0 -0
- /package/build/{lock-unlock.js.map → lock-unlock.cjs.map} +0 -0
- /package/build/mutation/{index.js.map → index.cjs.map} +0 -0
- /package/build-module/actions/{delete-post.js.map → delete-post.mjs.map} +0 -0
- /package/build-module/actions/{duplicate-pattern.js.map → duplicate-pattern.mjs.map} +0 -0
- /package/build-module/actions/{duplicate-post.js.map → duplicate-post.mjs.map} +0 -0
- /package/build-module/actions/{duplicate-template-part.js.map → duplicate-template-part.mjs.map} +0 -0
- /package/build-module/actions/{export-pattern.js.map → export-pattern.mjs.map} +0 -0
- /package/build-module/actions/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/actions/{permanently-delete-post.js.map → permanently-delete-post.mjs.map} +0 -0
- /package/build-module/actions/{reset-post.js.map → reset-post.mjs.map} +0 -0
- /package/build-module/actions/{restore-post.js.map → restore-post.mjs.map} +0 -0
- /package/build-module/actions/{trash-post.js.map → trash-post.mjs.map} +0 -0
- /package/build-module/actions/{utils.js.map → utils.mjs.map} +0 -0
- /package/build-module/actions/{view-post-revisions.js.map → view-post-revisions.mjs.map} +0 -0
- /package/build-module/actions/{view-post.js.map → view-post.mjs.map} +0 -0
- /package/build-module/components/create-template-part-modal/{utils.js.map → utils.mjs.map} +0 -0
- /package/build-module/fields/author/{author-view.js.map → author-view.mjs.map} +0 -0
- /package/build-module/fields/author/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/comment-status/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/date/{date-view.js.map → date-view.mjs.map} +0 -0
- /package/build-module/fields/date/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/discussion/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/featured-image/{featured-image-view.js.map → featured-image-view.mjs.map} +0 -0
- /package/build-module/fields/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/notes/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/order/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/page-title/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/page-title/{view.js.map → view.mjs.map} +0 -0
- /package/build-module/fields/parent/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/parent/{parent-view.js.map → parent-view.mjs.map} +0 -0
- /package/build-module/fields/parent/{utils.js.map → utils.mjs.map} +0 -0
- /package/build-module/fields/password/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/pattern-title/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/pattern-title/{view.js.map → view.mjs.map} +0 -0
- /package/build-module/fields/slug/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/slug/{slug-edit.js.map → slug-edit.mjs.map} +0 -0
- /package/build-module/fields/slug/{slug-view.js.map → slug-view.mjs.map} +0 -0
- /package/build-module/fields/slug/{utils.js.map → utils.mjs.map} +0 -0
- /package/build-module/fields/status/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/status/{status-elements.js.map → status-elements.mjs.map} +0 -0
- /package/build-module/fields/status/{status-view.js.map → status-view.mjs.map} +0 -0
- /package/build-module/fields/template/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/template/{template-edit.js.map → template-edit.mjs.map} +0 -0
- /package/build-module/fields/template-title/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/title/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/fields/title/{view.js.map → view.mjs.map} +0 -0
- /package/build-module/{lock-unlock.js.map → lock-unlock.mjs.map} +0 -0
- /package/build-module/mutation/{index.js.map → index.mjs.map} +0 -0
- /package/build-module/{types.js.map → types.mjs.map} +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/colors" as *;
|
|
2
|
+
@use "@wordpress/base-styles/variables" as *;
|
|
3
|
+
|
|
4
|
+
@mixin preview-overlay {
|
|
5
|
+
border-radius: $radius-x-small;
|
|
6
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
7
|
+
background: rgba(255, 255, 255, 0.75);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@mixin compact-drop-zone-label {
|
|
11
|
+
// Align text and icons horizontally to avoid clipping when we show the compact placeholder.
|
|
12
|
+
.components-drop-zone .components-drop-zone__content-inner {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: $grid-unit-10;
|
|
16
|
+
|
|
17
|
+
.components-drop-zone__content-icon {
|
|
18
|
+
margin: 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fieldset.fields__media-edit {
|
|
24
|
+
// Reset `fieldset` browser defaults.
|
|
25
|
+
border: 0;
|
|
26
|
+
padding: 0;
|
|
27
|
+
margin: 0;
|
|
28
|
+
|
|
29
|
+
width: 100%;
|
|
30
|
+
|
|
31
|
+
/* stylelint-disable-next-line property-no-unknown -- '@container' not globally permitted */
|
|
32
|
+
container-type: inline-size;
|
|
33
|
+
|
|
34
|
+
.fields__media-edit-compact {
|
|
35
|
+
display: grid;
|
|
36
|
+
grid-template-columns: 1fr auto;
|
|
37
|
+
gap: $grid-unit-10;
|
|
38
|
+
align-items: center;
|
|
39
|
+
@include compact-drop-zone-label;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Apply to placeholders outside of expanded view (compact contexts)
|
|
43
|
+
.fields__media-edit-picker-button:has(.fields__media-edit-placeholder):not(.fields__media-edit-expanded *) {
|
|
44
|
+
@include compact-drop-zone-label;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.fields__media-edit-picker-button {
|
|
48
|
+
position: relative;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: $grid-unit-15;
|
|
52
|
+
border: $border-width dashed $gray-600;
|
|
53
|
+
border-radius: $radius-x-small;
|
|
54
|
+
padding: calc(8px - #{$border-width});
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
min-width: 0;
|
|
57
|
+
|
|
58
|
+
&:hover {
|
|
59
|
+
background-color: $gray-100;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:focus-visible {
|
|
63
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
64
|
+
outline: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&[aria-disabled="true"] {
|
|
68
|
+
opacity: 0.6;
|
|
69
|
+
cursor: default;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.fields__media-edit-picker-button-spinner {
|
|
73
|
+
position: absolute;
|
|
74
|
+
top: 50%;
|
|
75
|
+
left: 50%;
|
|
76
|
+
transform: translate(-50%, -50%);
|
|
77
|
+
z-index: 1;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.fields__media-edit-filename,
|
|
82
|
+
.fields__media-edit-placeholder {
|
|
83
|
+
flex: 1;
|
|
84
|
+
width: 100%;
|
|
85
|
+
min-width: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.fields__media-edit-placeholder {
|
|
89
|
+
text-align: center;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.fields__media-edit-thumbnail {
|
|
93
|
+
width: $grid-unit-30;
|
|
94
|
+
aspect-ratio: 1 / 1;
|
|
95
|
+
flex-shrink: 0;
|
|
96
|
+
border-radius: $radius-small;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.fields__media-edit-expanded {
|
|
100
|
+
// Always use grid layout
|
|
101
|
+
display: grid;
|
|
102
|
+
gap: $grid-unit-10;
|
|
103
|
+
|
|
104
|
+
&.is-empty {
|
|
105
|
+
@include compact-drop-zone-label;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.fields__media-edit-expanded-preview {
|
|
109
|
+
position: relative;
|
|
110
|
+
width: 100%;
|
|
111
|
+
aspect-ratio: 3/2;
|
|
112
|
+
border-radius: $radius-small;
|
|
113
|
+
padding: $grid-unit-05;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
|
|
119
|
+
.fields__media-edit-expanded-preview-stack {
|
|
120
|
+
width: 100%;
|
|
121
|
+
height: 100%;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.fields__media-edit-expanded-overlay {
|
|
126
|
+
position: absolute;
|
|
127
|
+
top: 0;
|
|
128
|
+
left: 0;
|
|
129
|
+
right: 0;
|
|
130
|
+
bottom: 0;
|
|
131
|
+
opacity: 0;
|
|
132
|
+
pointer-events: none;
|
|
133
|
+
|
|
134
|
+
@media not (prefers-reduced-motion) {
|
|
135
|
+
transition: opacity 50ms ease-out;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
* {
|
|
139
|
+
pointer-events: auto;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.fields__media-edit-expanded-remove {
|
|
144
|
+
position: absolute;
|
|
145
|
+
top: $grid-unit-10;
|
|
146
|
+
right: $grid-unit-10;
|
|
147
|
+
@include preview-overlay;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.fields__media-edit-expanded-title {
|
|
151
|
+
position: absolute;
|
|
152
|
+
bottom: 0;
|
|
153
|
+
left: 0;
|
|
154
|
+
right: 0;
|
|
155
|
+
margin: $grid-unit-10;
|
|
156
|
+
padding: $grid-unit-05;
|
|
157
|
+
text-align: center;
|
|
158
|
+
@include preview-overlay;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.fields__media-edit-expanded-item {
|
|
162
|
+
position: relative;
|
|
163
|
+
min-width: 0;
|
|
164
|
+
|
|
165
|
+
&:hover,
|
|
166
|
+
&:focus-within {
|
|
167
|
+
.fields__media-edit-expanded-overlay {
|
|
168
|
+
opacity: 1;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&:not(.has-preview-image) {
|
|
173
|
+
.fields__media-edit-expanded-preview-stack {
|
|
174
|
+
padding: $grid-unit-10;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.fields__media-edit-thumbnail {
|
|
180
|
+
width: 100%;
|
|
181
|
+
height: 100%;
|
|
182
|
+
object-fit: cover;
|
|
183
|
+
object-position: 50% 50%;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.fields__media-edit-filename {
|
|
187
|
+
text-align: center;
|
|
188
|
+
flex: none;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.fields__media-edit-picker-button-spinner {
|
|
192
|
+
svg {
|
|
193
|
+
margin: 0;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
&.is-single {
|
|
198
|
+
grid-template-columns: 1fr;
|
|
199
|
+
|
|
200
|
+
.fields__media-edit-expanded-preview {
|
|
201
|
+
aspect-ratio: 2/1;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
&.is-multiple:not(.is-empty) {
|
|
206
|
+
grid-template-columns: repeat(3, 1fr);
|
|
207
|
+
|
|
208
|
+
/* stylelint-disable-next-line property-no-unknown -- '@container' not globally permitted */
|
|
209
|
+
@container (max-width: 768px) {
|
|
210
|
+
grid-template-columns: repeat(2, 1fr);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* stylelint-disable-next-line property-no-unknown -- '@container' not globally permitted */
|
|
214
|
+
@container (max-width: 280px) {
|
|
215
|
+
grid-template-columns: 1fr;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
&:not(.is-empty) {
|
|
220
|
+
.fields__media-edit-picker-button {
|
|
221
|
+
padding: 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.fields__media-edit-placeholder {
|
|
225
|
+
display: flex;
|
|
226
|
+
align-items: center;
|
|
227
|
+
justify-content: center;
|
|
228
|
+
aspect-ratio: 3/2;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -7,16 +7,19 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
+
import MediaEdit from '../../components/media-edit';
|
|
10
11
|
import type { BasePostWithEmbeddedFeaturedMedia } from '../../types';
|
|
11
|
-
import { FeaturedImageEdit } from './featured-image-edit';
|
|
12
12
|
import { FeaturedImageView } from './featured-image-view';
|
|
13
13
|
|
|
14
14
|
const featuredImageField: Field< BasePostWithEmbeddedFeaturedMedia > = {
|
|
15
15
|
id: 'featured_media',
|
|
16
16
|
type: 'media',
|
|
17
17
|
label: __( 'Featured Image' ),
|
|
18
|
-
Edit:
|
|
18
|
+
Edit: MediaEdit,
|
|
19
19
|
render: FeaturedImageView,
|
|
20
|
+
setValue: ( { value } ) => ( {
|
|
21
|
+
featured_media: value ?? 0,
|
|
22
|
+
} ),
|
|
20
23
|
enableSorting: false,
|
|
21
24
|
filterBy: false,
|
|
22
25
|
};
|
|
@@ -1,95 +1,6 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/colors" as *;
|
|
2
2
|
@use "@wordpress/base-styles/variables" as *;
|
|
3
3
|
|
|
4
|
-
.fields-controls__featured-image-placeholder {
|
|
5
|
-
border-radius: $radius-small;
|
|
6
|
-
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
|
|
7
|
-
display: inline-block;
|
|
8
|
-
padding: 0;
|
|
9
|
-
background:
|
|
10
|
-
$white
|
|
11
|
-
linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.fields-controls__featured-image-title {
|
|
15
|
-
width: 100%;
|
|
16
|
-
color: $gray-900;
|
|
17
|
-
white-space: nowrap;
|
|
18
|
-
text-overflow: ellipsis;
|
|
19
|
-
overflow: hidden;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.fields-controls__featured-image-image {
|
|
23
|
-
width: 100%;
|
|
24
|
-
height: 100%;
|
|
25
|
-
border-radius: $radius-small;
|
|
26
|
-
align-self: center;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.fields-controls__featured-image-container {
|
|
30
|
-
.fields-controls__featured-image-placeholder {
|
|
31
|
-
margin: 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
span {
|
|
35
|
-
margin-right: auto;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
fieldset.fields-controls__featured-image {
|
|
40
|
-
// Reset `fieldset` browser defaults.
|
|
41
|
-
border: 0;
|
|
42
|
-
padding: 0;
|
|
43
|
-
margin: 0;
|
|
44
|
-
|
|
45
|
-
.fields-controls__featured-image-container {
|
|
46
|
-
border: $border-width solid $gray-300;
|
|
47
|
-
border-radius: $radius-small;
|
|
48
|
-
padding: 8px 12px;
|
|
49
|
-
cursor: pointer;
|
|
50
|
-
&:hover {
|
|
51
|
-
background-color: $gray-100;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.fields-controls__featured-image-placeholder {
|
|
56
|
-
width: 24px;
|
|
57
|
-
height: 24px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
span {
|
|
61
|
-
align-self: center;
|
|
62
|
-
text-align: start;
|
|
63
|
-
white-space: nowrap;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.fields-controls__featured-image-upload-button {
|
|
67
|
-
padding: 0;
|
|
68
|
-
height: fit-content;
|
|
69
|
-
&:hover,
|
|
70
|
-
&:focus {
|
|
71
|
-
border: 0;
|
|
72
|
-
color: unset;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.fields-controls__featured-image-remove-button {
|
|
77
|
-
place-self: end;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.dataforms-layouts-panel__field-control {
|
|
82
|
-
.fields-controls__featured-image-image {
|
|
83
|
-
width: 16px;
|
|
84
|
-
height: 16px;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.fields-controls__featured-image-placeholder {
|
|
88
|
-
width: 16px;
|
|
89
|
-
height: 16px;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
4
|
.dataviews-view-grid__media,
|
|
94
5
|
.dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media,
|
|
95
6
|
.dataviews-view-list__media-wrapper {
|
|
@@ -114,3 +25,10 @@ fieldset.fields-controls__featured-image {
|
|
|
114
25
|
height: 32px;
|
|
115
26
|
}
|
|
116
27
|
}
|
|
28
|
+
|
|
29
|
+
.dataforms-layouts-panel__field-control {
|
|
30
|
+
.fields-controls__featured-image-image {
|
|
31
|
+
width: 16px;
|
|
32
|
+
height: 16px;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -38,7 +38,6 @@ function PasswordEdit( {
|
|
|
38
38
|
className="fields-controls__password"
|
|
39
39
|
>
|
|
40
40
|
<CheckboxControl
|
|
41
|
-
__nextHasNoMarginBottom
|
|
42
41
|
label={ __( 'Password protected' ) }
|
|
43
42
|
help={ __( 'Only visible to those who know the password' ) }
|
|
44
43
|
checked={ showPassword }
|
|
@@ -57,7 +56,6 @@ function PasswordEdit( {
|
|
|
57
56
|
placeholder={ __( 'Use a secure password' ) }
|
|
58
57
|
type="text"
|
|
59
58
|
__next40pxDefaultSize
|
|
60
|
-
__nextHasNoMarginBottom
|
|
61
59
|
maxLength={ 255 }
|
|
62
60
|
/>
|
|
63
61
|
</div>
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from './fields';
|
|
2
2
|
export * from './actions';
|
|
3
3
|
export { default as CreateTemplatePartModal } from './components/create-template-part-modal';
|
|
4
|
+
export { default as MediaEdit } from './components/media-edit';
|
|
4
5
|
export type {
|
|
5
6
|
BasePostWithEmbeddedAuthor,
|
|
6
7
|
BasePost,
|
|
8
|
+
MediaEditProps,
|
|
7
9
|
PostType,
|
|
8
10
|
Pattern,
|
|
9
11
|
} from './types';
|
package/src/style.scss
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/default-custom-properties";
|
|
2
2
|
@use "./components/create-template-part-modal/style.scss" as *;
|
|
3
|
+
@use "./components/media-edit/style.scss" as *;
|
|
3
4
|
@use "./fields/slug/style.scss" as *;
|
|
4
5
|
@use "./fields/featured-image/style.scss" as *;
|
|
5
6
|
@use "./fields/parent/style.scss" as *;
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { DataFormControlProps } from '@wordpress/dataviews';
|
|
5
|
+
|
|
1
6
|
type PostStatus =
|
|
2
7
|
| 'publish'
|
|
3
8
|
| 'draft'
|
|
@@ -133,3 +138,28 @@ export interface PostType {
|
|
|
133
138
|
|
|
134
139
|
// Will be unnecessary after typescript 5.0 upgrade.
|
|
135
140
|
export type CoreDataError = { message?: string; code?: string };
|
|
141
|
+
|
|
142
|
+
export interface MediaEditProps< Item >
|
|
143
|
+
extends Pick<
|
|
144
|
+
DataFormControlProps< Item >,
|
|
145
|
+
'data' | 'field' | 'onChange' | 'hideLabelFromVision'
|
|
146
|
+
> {
|
|
147
|
+
/**
|
|
148
|
+
* Array of allowed media types (e.g., ['image', 'video']).
|
|
149
|
+
*
|
|
150
|
+
* @default ['image']
|
|
151
|
+
*/
|
|
152
|
+
allowedTypes?: string[];
|
|
153
|
+
/**
|
|
154
|
+
* Whether to allow multiple media selections.
|
|
155
|
+
*
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
158
|
+
multiple?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Whether to render in an expanded form.
|
|
161
|
+
*
|
|
162
|
+
* @default false
|
|
163
|
+
*/
|
|
164
|
+
isExpanded?: boolean;
|
|
165
|
+
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/actions/reorder-page.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalInputControl as InputControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { CoreDataError, BasePost } from '../types';\n\ninterface RenderModalProps< Item > {\n\titems: Item[];\n\tcloseModal?: () => void;\n\tonActionPerformed?: ( items: Item[] ) => void;\n}\n\ninterface Action< Item > {\n\tid: string;\n\tlabel: string;\n\tisEligible?: ( item: Item ) => boolean;\n\tmodalFocusOnMount?: string;\n\tRenderModal: ( props: RenderModalProps< Item > ) => JSX.Element;\n}\n\nfunction isItemValid( item: BasePost ): boolean {\n\treturn (\n\t\ttypeof item.menu_order === 'number' &&\n\t\tNumber.isInteger( item.menu_order ) &&\n\t\titem.menu_order > 0\n\t);\n}\n\nfunction ReorderModal( {\n\titems,\n\tcloseModal,\n\tonActionPerformed,\n}: RenderModalProps< BasePost > ) {\n\tconst [ item, setItem ] = useState( items[ 0 ] );\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst isValid = isItemValid( item );\n\n\tasync function onOrder( event: React.FormEvent ) {\n\t\tevent.preventDefault();\n\n\t\tif ( ! isValid ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\tmenu_order: item.menu_order,\n\t\t\t} );\n\t\t\tcloseModal?.();\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\tcreateSuccessNotice( __( 'Order updated.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\tonActionPerformed?.( items );\n\t\t} catch ( error ) {\n\t\t\tconst typedError = error as CoreDataError;\n\t\t\tconst errorMessage =\n\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t? typedError.message\n\t\t\t\t\t: __( 'An error occurred while updating the order' );\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t}\n\n\treturn (\n\t\t<form onSubmit={ onOrder }>\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<div>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.'\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<InputControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Order' ) }\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\ttypeof item.menu_order === 'number' &&\n\t\t\t\t\t\tNumber.isInteger( item.menu_order )\n\t\t\t\t\t\t\t? String( item.menu_order )\n\t\t\t\t\t\t\t: ''\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tconst parsed = parseInt( value as string, 10 ); // absorbs '' and undefined\n\t\t\t\t\t\tsetItem( {\n\t\t\t\t\t\t\t...item,\n\t\t\t\t\t\t\tmenu_order: isNaN( parsed ) ? undefined : parsed,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tdisabled={ ! isValid }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n\nconst reorderPage: Action< BasePost > = {\n\tid: 'order-pages',\n\tlabel: __( 'Order' ),\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tmodalFocusOnMount: 'firstContentElement',\n\tRenderModal: ReorderModal,\n};\n\n/**\n * Reorder action for BasePost.\n */\nexport default reorderPage;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,uBAAmC;AACnC,kBAAmB;AACnB,qBAAsC;AACtC,qBAAyB;AACzB,wBAKO;AA6EH;AAxDJ,SAAS,YAAa,MAA0B;AAC/C,SACC,OAAO,KAAK,eAAe,YAC3B,OAAO,UAAW,KAAK,UAAW,KAClC,KAAK,aAAa;AAEpB;AAEA,SAAS,aAAc;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AACjC,QAAM,CAAE,MAAM,OAAQ,QAAI,yBAAU,MAAO,CAAE,CAAE;AAC/C,QAAM,EAAE,kBAAkB,uBAAuB,QAChD,yBAAa,iBAAAA,KAAU;AACxB,QAAM,EAAE,qBAAqB,kBAAkB,QAC9C,yBAAa,eAAAC,KAAa;AAE3B,QAAM,UAAU,YAAa,IAAK;AAElC,iBAAe,QAAS,OAAyB;AAChD,UAAM,eAAe;AAErB,QAAK,CAAE,SAAU;AAChB;AAAA,IACD;AAEA,QAAI;AACH,YAAM,iBAAkB,YAAY,KAAK,MAAM,KAAK,IAAI;AAAA,QACvD,YAAY,KAAK;AAAA,MAClB,CAAE;AACF,mBAAa;AAEb,YAAM,uBAAwB,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AAA;AAAA,MACd;AAAA,OACD;AAAA,KACD,GACD;AAEF;AAEA,IAAM,cAAkC;AAAA,EACvC,IAAI;AAAA,EACJ,WAAO,gBAAI,OAAQ;AAAA,EACnB,WAAY,EAAE,OAAO,GAAI;AACxB,WAAO,WAAW;AAAA,EACnB;AAAA,EACA,mBAAmB;AAAA,EACnB,aAAa;AACd;AAKA,IAAO,uBAAQ;",
|
|
6
|
-
"names": ["coreStore", "noticesStore", "VStack", "InputControl", "HStack"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/create-template-part-modal/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport type { TemplatePartArea } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tcheck,\n\tfooter as footerIcon,\n\theader as headerIcon,\n\tsidebar as sidebarIcon,\n\ttableColumnAfter as overlayIcon,\n\tsymbolFilled as symbolFilledIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n// @ts-expect-error serialize is not typed\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetCleanTemplatePartSlug,\n\tgetUniqueTemplatePartTitle,\n\tuseExistingTemplateParts,\n} from './utils';\n\nfunction getAreaRadioId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-${ value }-${ instanceId }`;\n}\nfunction getAreaRadioDescriptionId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-description-${ value }-${ instanceId }`;\n}\n\ntype CreateTemplatePartModalContentsProps = {\n\tdefaultArea?: string;\n\tblocks: any[];\n\tconfirmLabel?: string;\n\tcloseModal: () => void;\n\tonCreate: ( templatePart: any ) => void;\n\tonError?: () => void;\n\tdefaultTitle?: string;\n};\n\n/**\n * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.\n * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.\n * @param props The component props.\n * @param props.modalTitle\n */\nexport default function CreateTemplatePartModal( {\n\tmodalTitle,\n\t...restProps\n}: {\n\tmodalTitle?: string;\n} & CreateTemplatePartModalContentsProps ) {\n\tconst defaultModalTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getPostType( 'wp_template_part' )?.labels\n\t\t\t\t?.add_new_item,\n\t\t[]\n\t);\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle || defaultModalTitle }\n\t\t\tonRequestClose={ restProps.closeModal }\n\t\t\toverlayClassName=\"fields-create-template-part-modal\"\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<CreateTemplatePartModalContents { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\n/**\n * Helper function to retrieve the corresponding icon by area name or icon name.\n *\n * @param {string} areaOrIconName The area name (e.g., 'header', 'overlay') or icon name (e.g., 'menu').\n *\n * @return {Object} The corresponding icon.\n */\nconst getTemplatePartIcon = ( areaOrIconName: string ) => {\n\t// Handle area names first\n\tif ( 'header' === areaOrIconName ) {\n\t\treturn headerIcon;\n\t} else if ( 'footer' === areaOrIconName ) {\n\t\treturn footerIcon;\n\t} else if ( 'sidebar' === areaOrIconName ) {\n\t\treturn sidebarIcon;\n\t} else if ( 'overlay' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\t// Handle icon names for backwards compatibility\n\tif ( 'menu' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\treturn symbolFilledIcon;\n};\n\n/**\n * A React component that renders the content of a model for creating a template part.\n * This component should not live in this package; it should be moved to a dedicated package responsible for managing template.\n *\n * @param {Object} props - The component props.\n * @param {string} [props.defaultArea=uncategorized] - The default area for the template part.\n * @param {Array} [props.blocks=[]] - The blocks to be included in the template part.\n * @param {string} [props.confirmLabel='Add'] - The label for the confirm button.\n * @param {Function} props.closeModal - Function to close the modal.\n * @param {Function} props.onCreate - Function to call when the template part is successfully created.\n * @param {Function} [props.onError] - Function to call when there is an error creating the template part.\n * @param {string} [props.defaultTitle=''] - The default title for the template part.\n */\nexport function CreateTemplatePartModalContents( {\n\tdefaultArea = 'uncategorized',\n\tblocks = [],\n\tconfirmLabel = __( 'Add' ),\n\tcloseModal,\n\tonCreate,\n\tonError,\n\tdefaultTitle = '',\n}: CreateTemplatePartModalContentsProps ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tconst [ title, setTitle ] = useState( defaultTitle );\n\tconst [ area, setArea ] = useState( defaultArea );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst defaultTemplatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_part_areas,\n\t\t[]\n\t);\n\n\tasync function createTemplatePart() {\n\t\tif ( ! title || isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSubmitting( true );\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error &&\n\t\t\t\t'code' in error &&\n\t\t\t\terror.message &&\n\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tonError?.();\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait createTemplatePart();\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"4\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<fieldset className=\"fields-create-template-part-modal__area-fieldset\">\n\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t{ __( 'Area' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<div className=\"fields-create-template-part-modal__area-radio-group\">\n\t\t\t\t\t\t{ ( defaultTemplatePartAreas ?? [] ).map(\n\t\t\t\t\t\t\t( item: TemplatePartArea ) => {\n\t\t\t\t\t\t\t\tconst icon = getTemplatePartIcon( item.icon );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tkey={ item.area }\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-wrapper\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tname={ `fields-create-template-part-modal__area-${ instanceId }` }\n\t\t\t\t\t\t\t\t\t\t\tvalue={ item.area }\n\t\t\t\t\t\t\t\t\t\t\tchecked={ area === item.area }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tsetArea( item.area );\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\taria-describedby={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\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\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-icon\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\t\thtmlFor={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-label\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-checkmark\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-description\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\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\t\t{ item.description }\n\t\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t</div>\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</div>\n\t\t\t\t</fieldset>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title || isSubmitting }\n\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ confirmLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VSt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AAAA,wBACV,IAAK;AAAA,0BACJ,KAAK;AAAA,0BACL;AAAA,wBACD;AAAA,wBAEE,eAAK;AAAA;AAAA,oBACR;AAAA;AAAA;AAAA,gBA7CM,KAAK;AAAA,cA8CZ;AAAA,YAEF;AAAA,UACD,GACD;AAAA,WACD;AAAA,QACA,6CAAC,kBAAAC,sBAAA,EAAO,SAAQ,SACf;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU,MAAM;AACf,2BAAW;AAAA,cACZ;AAAA,cAEE,8BAAI,QAAS;AAAA;AAAA,UAChB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,iBAAgB,CAAE,SAAS;AAAA,cAC3B,QAAS;AAAA,cAEP;AAAA;AAAA,UACH;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
-
"names": ["coreStore", "headerIcon", "footerIcon", "sidebarIcon", "overlayIcon", "symbolFilledIcon", "noticesStore", "VStack", "HStack"]
|
|
7
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
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/featured-image/featured-image-edit.tsx
|
|
21
|
-
var featured_image_edit_exports = {};
|
|
22
|
-
__export(featured_image_edit_exports, {
|
|
23
|
-
FeaturedImageEdit: () => FeaturedImageEdit
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(featured_image_edit_exports);
|
|
26
|
-
var import_components = require("@wordpress/components");
|
|
27
|
-
var import_data = require("@wordpress/data");
|
|
28
|
-
var import_element = require("@wordpress/element");
|
|
29
|
-
var import_media_utils = require("@wordpress/media-utils");
|
|
30
|
-
var import_icons = require("@wordpress/icons");
|
|
31
|
-
var import_core_data = require("@wordpress/core-data");
|
|
32
|
-
var import_i18n = require("@wordpress/i18n");
|
|
33
|
-
var import_lock_unlock = require("../../lock-unlock");
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
var { MediaUploadModal } = (0, import_lock_unlock.unlock)(import_media_utils.privateApis);
|
|
36
|
-
function ConditionalMediaUpload({ render, ...props }) {
|
|
37
|
-
const [isModalOpen, setIsModalOpen] = (0, import_element.useState)(false);
|
|
38
|
-
if (window.__experimentalDataViewsMediaModal) {
|
|
39
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
40
|
-
render && render({ open: () => setIsModalOpen(true) }),
|
|
41
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
42
|
-
MediaUploadModal,
|
|
43
|
-
{
|
|
44
|
-
...props,
|
|
45
|
-
isOpen: isModalOpen,
|
|
46
|
-
onClose: () => {
|
|
47
|
-
setIsModalOpen(false);
|
|
48
|
-
props.onClose?.();
|
|
49
|
-
},
|
|
50
|
-
onSelect: (media) => {
|
|
51
|
-
setIsModalOpen(false);
|
|
52
|
-
props.onSelect?.(media);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
)
|
|
56
|
-
] });
|
|
57
|
-
}
|
|
58
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_utils.MediaUpload, { ...props, render });
|
|
59
|
-
}
|
|
60
|
-
var FeaturedImageEdit = ({
|
|
61
|
-
data,
|
|
62
|
-
field,
|
|
63
|
-
onChange
|
|
64
|
-
}) => {
|
|
65
|
-
const { id } = field;
|
|
66
|
-
const value = field.getValue({ item: data });
|
|
67
|
-
const media = (0, import_data.useSelect)(
|
|
68
|
-
(select) => {
|
|
69
|
-
const { getEntityRecord } = select(import_core_data.store);
|
|
70
|
-
return getEntityRecord("postType", "attachment", value);
|
|
71
|
-
},
|
|
72
|
-
[value]
|
|
73
|
-
);
|
|
74
|
-
const onChangeControl = (0, import_element.useCallback)(
|
|
75
|
-
(newValue) => onChange({
|
|
76
|
-
[id]: newValue
|
|
77
|
-
}),
|
|
78
|
-
[id, onChange]
|
|
79
|
-
);
|
|
80
|
-
const url = media?.source_url;
|
|
81
|
-
const title = media?.title?.rendered;
|
|
82
|
-
const ref = (0, import_element.useRef)(null);
|
|
83
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("fieldset", { className: "fields-controls__featured-image", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "fields-controls__featured-image-container", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
84
|
-
ConditionalMediaUpload,
|
|
85
|
-
{
|
|
86
|
-
onSelect: (selectedMedia) => {
|
|
87
|
-
onChangeControl(selectedMedia.id);
|
|
88
|
-
},
|
|
89
|
-
allowedTypes: ["image"],
|
|
90
|
-
value,
|
|
91
|
-
title: (0, import_i18n.__)("Select Featured Image"),
|
|
92
|
-
render: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
93
|
-
"div",
|
|
94
|
-
{
|
|
95
|
-
ref,
|
|
96
|
-
role: "button",
|
|
97
|
-
tabIndex: -1,
|
|
98
|
-
onClick: open,
|
|
99
|
-
onKeyDown: (event) => {
|
|
100
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
101
|
-
event.preventDefault();
|
|
102
|
-
open();
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
106
|
-
import_components.__experimentalGrid,
|
|
107
|
-
{
|
|
108
|
-
rowGap: 0,
|
|
109
|
-
columnGap: 8,
|
|
110
|
-
templateColumns: "24px 1fr 24px",
|
|
111
|
-
children: [
|
|
112
|
-
url && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
113
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
114
|
-
"img",
|
|
115
|
-
{
|
|
116
|
-
className: "fields-controls__featured-image-image",
|
|
117
|
-
alt: "",
|
|
118
|
-
width: 24,
|
|
119
|
-
height: 24,
|
|
120
|
-
src: url
|
|
121
|
-
}
|
|
122
|
-
),
|
|
123
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "fields-controls__featured-image-title", children: title })
|
|
124
|
-
] }),
|
|
125
|
-
!url && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
126
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
-
"span",
|
|
128
|
-
{
|
|
129
|
-
className: "fields-controls__featured-image-placeholder",
|
|
130
|
-
style: {
|
|
131
|
-
width: "24px",
|
|
132
|
-
height: "24px"
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
),
|
|
136
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "fields-controls__featured-image-title", children: (0, import_i18n.__)("Choose an image\u2026") })
|
|
137
|
-
] }),
|
|
138
|
-
url && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
139
|
-
import_components.Button,
|
|
140
|
-
{
|
|
141
|
-
size: "small",
|
|
142
|
-
className: "fields-controls__featured-image-remove-button",
|
|
143
|
-
icon: import_icons.lineSolid,
|
|
144
|
-
onClick: (event) => {
|
|
145
|
-
event.stopPropagation();
|
|
146
|
-
onChangeControl(0);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
) })
|
|
150
|
-
]
|
|
151
|
-
}
|
|
152
|
-
)
|
|
153
|
-
}
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
) }) });
|
|
157
|
-
};
|
|
158
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
-
0 && (module.exports = {
|
|
160
|
-
FeaturedImageEdit
|
|
161
|
-
});
|
|
162
|
-
//# sourceMappingURL=featured-image-edit.js.map
|