@wordpress/media-editor 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/build/components/media-editor/index.cjs +212 -170
  2. package/build/components/media-editor/index.cjs.map +3 -3
  3. package/build/components/media-editor/use-crop-options.cjs +63 -0
  4. package/build/components/media-editor/use-crop-options.cjs.map +7 -0
  5. package/build/components/media-editor/use-save-media-editor.cjs +185 -0
  6. package/build/components/media-editor/use-save-media-editor.cjs.map +7 -0
  7. package/build/components/media-editor-canvas/index.cjs +33 -12
  8. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  9. package/build/components/media-editor-crop-panel/index.cjs +70 -84
  10. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  11. package/build/components/media-editor-fine-rotation/index.cjs +81 -0
  12. package/build/components/media-editor-fine-rotation/index.cjs.map +7 -0
  13. package/build/components/media-editor-modal/index.cjs +63 -16
  14. package/build/components/media-editor-modal/index.cjs.map +3 -3
  15. package/build/components/media-editor-transform-controls/index.cjs +84 -0
  16. package/build/components/media-editor-transform-controls/index.cjs.map +7 -0
  17. package/build/components/media-form/index.cjs +19 -1
  18. package/build/components/media-form/index.cjs.map +3 -3
  19. package/build/components/media-form/sidebar-datetime-view.cjs +53 -0
  20. package/build/components/media-form/sidebar-datetime-view.cjs.map +7 -0
  21. package/build/components/rotation-ruler/index.cjs +8 -2
  22. package/build/components/rotation-ruler/index.cjs.map +2 -2
  23. package/build/hooks/use-crop-gesture-handlers.cjs +41 -4
  24. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  25. package/build/image-editor/core/camera.cjs +29 -11
  26. package/build/image-editor/core/camera.cjs.map +2 -2
  27. package/build/image-editor/core/constants.cjs +6 -0
  28. package/build/image-editor/core/constants.cjs.map +2 -2
  29. package/build/image-editor/core/containment.cjs +71 -34
  30. package/build/image-editor/core/containment.cjs.map +2 -2
  31. package/build/image-editor/core/crop-rect.cjs +48 -0
  32. package/build/image-editor/core/crop-rect.cjs.map +7 -0
  33. package/build/image-editor/core/index.cjs +12 -0
  34. package/build/image-editor/core/index.cjs.map +2 -2
  35. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  36. package/build/image-editor/core/math/sanitize.cjs +92 -0
  37. package/build/image-editor/core/math/sanitize.cjs.map +7 -0
  38. package/build/image-editor/core/setter-helpers.cjs +64 -0
  39. package/build/image-editor/core/setter-helpers.cjs.map +7 -0
  40. package/build/image-editor/core/source-region.cjs +16 -14
  41. package/build/image-editor/core/source-region.cjs.map +2 -2
  42. package/build/image-editor/core/state.cjs +20 -10
  43. package/build/image-editor/core/state.cjs.map +2 -2
  44. package/build/image-editor/core/stencil-math.cjs +31 -20
  45. package/build/image-editor/core/stencil-math.cjs.map +2 -2
  46. package/build/image-editor/core/transform-style.cjs +12 -6
  47. package/build/image-editor/core/transform-style.cjs.map +2 -2
  48. package/build/image-editor/core/types.cjs.map +1 -1
  49. package/build/image-editor/index.cjs +12 -2
  50. package/build/image-editor/index.cjs.map +2 -2
  51. package/build/image-editor/react/components/cropper-provider.cjs +2 -2
  52. package/build/image-editor/react/components/cropper-provider.cjs.map +2 -2
  53. package/build/image-editor/react/components/cropper.cjs +120 -47
  54. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  55. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +172 -0
  56. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +7 -0
  57. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +19 -9
  58. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  59. package/build/image-editor/react/hooks/build-cropper-setters.cjs +71 -0
  60. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +7 -0
  61. package/build/image-editor/react/hooks/index.cjs +6 -3
  62. package/build/image-editor/react/hooks/index.cjs.map +2 -2
  63. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +113 -0
  64. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +7 -0
  65. package/build/state/composite-reducer.cjs +103 -0
  66. package/build/state/composite-reducer.cjs.map +7 -0
  67. package/build/state/index.cjs +48 -0
  68. package/build/state/index.cjs.map +7 -0
  69. package/build/state/media-editor-state-provider.cjs +58 -0
  70. package/build/state/media-editor-state-provider.cjs.map +7 -0
  71. package/build/state/types.cjs +33 -0
  72. package/build/state/types.cjs.map +7 -0
  73. package/build/state/use-media-editor-state.cjs +287 -0
  74. package/build/state/use-media-editor-state.cjs.map +7 -0
  75. package/build/store/actions.cjs +4 -2
  76. package/build/store/actions.cjs.map +2 -2
  77. package/build/store/reducer.cjs +5 -3
  78. package/build/store/reducer.cjs.map +2 -2
  79. package/build/store/selectors.cjs +5 -0
  80. package/build/store/selectors.cjs.map +2 -2
  81. package/build-module/components/media-editor/index.mjs +224 -177
  82. package/build-module/components/media-editor/index.mjs.map +2 -2
  83. package/build-module/components/media-editor/use-crop-options.mjs +37 -0
  84. package/build-module/components/media-editor/use-crop-options.mjs.map +7 -0
  85. package/build-module/components/media-editor/use-save-media-editor.mjs +151 -0
  86. package/build-module/components/media-editor/use-save-media-editor.mjs.map +7 -0
  87. package/build-module/components/media-editor-canvas/index.mjs +34 -13
  88. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  89. package/build-module/components/media-editor-crop-panel/index.mjs +73 -89
  90. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  91. package/build-module/components/media-editor-fine-rotation/index.mjs +50 -0
  92. package/build-module/components/media-editor-fine-rotation/index.mjs.map +7 -0
  93. package/build-module/components/media-editor-modal/index.mjs +64 -17
  94. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  95. package/build-module/components/media-editor-transform-controls/index.mjs +68 -0
  96. package/build-module/components/media-editor-transform-controls/index.mjs.map +7 -0
  97. package/build-module/components/media-form/index.mjs +9 -1
  98. package/build-module/components/media-form/index.mjs.map +2 -2
  99. package/build-module/components/media-form/sidebar-datetime-view.mjs +32 -0
  100. package/build-module/components/media-form/sidebar-datetime-view.mjs.map +7 -0
  101. package/build-module/components/rotation-ruler/index.mjs +8 -2
  102. package/build-module/components/rotation-ruler/index.mjs.map +2 -2
  103. package/build-module/hooks/use-crop-gesture-handlers.mjs +41 -4
  104. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  105. package/build-module/image-editor/core/camera.mjs +34 -11
  106. package/build-module/image-editor/core/camera.mjs.map +2 -2
  107. package/build-module/image-editor/core/constants.mjs +4 -0
  108. package/build-module/image-editor/core/constants.mjs.map +2 -2
  109. package/build-module/image-editor/core/containment.mjs +75 -34
  110. package/build-module/image-editor/core/containment.mjs.map +2 -2
  111. package/build-module/image-editor/core/crop-rect.mjs +23 -0
  112. package/build-module/image-editor/core/crop-rect.mjs.map +7 -0
  113. package/build-module/image-editor/core/index.mjs +12 -0
  114. package/build-module/image-editor/core/index.mjs.map +2 -2
  115. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  116. package/build-module/image-editor/core/math/sanitize.mjs +63 -0
  117. package/build-module/image-editor/core/math/sanitize.mjs.map +7 -0
  118. package/build-module/image-editor/core/setter-helpers.mjs +39 -0
  119. package/build-module/image-editor/core/setter-helpers.mjs.map +7 -0
  120. package/build-module/image-editor/core/source-region.mjs +16 -14
  121. package/build-module/image-editor/core/source-region.mjs.map +2 -2
  122. package/build-module/image-editor/core/state.mjs +25 -11
  123. package/build-module/image-editor/core/state.mjs.map +2 -2
  124. package/build-module/image-editor/core/stencil-math.mjs +30 -19
  125. package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
  126. package/build-module/image-editor/core/transform-style.mjs +12 -6
  127. package/build-module/image-editor/core/transform-style.mjs.map +2 -2
  128. package/build-module/image-editor/index.mjs +11 -2
  129. package/build-module/image-editor/index.mjs.map +2 -2
  130. package/build-module/image-editor/react/components/cropper-provider.mjs +3 -3
  131. package/build-module/image-editor/react/components/cropper-provider.mjs.map +2 -2
  132. package/build-module/image-editor/react/components/cropper.mjs +121 -48
  133. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  134. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +147 -0
  135. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +7 -0
  136. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +19 -9
  137. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  138. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +46 -0
  139. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +7 -0
  140. package/build-module/image-editor/react/hooks/index.mjs +4 -2
  141. package/build-module/image-editor/react/hooks/index.mjs.map +2 -2
  142. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +100 -0
  143. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +7 -0
  144. package/build-module/state/composite-reducer.mjs +82 -0
  145. package/build-module/state/composite-reducer.mjs.map +7 -0
  146. package/build-module/state/index.mjs +26 -0
  147. package/build-module/state/index.mjs.map +7 -0
  148. package/build-module/state/media-editor-state-provider.mjs +34 -0
  149. package/build-module/state/media-editor-state-provider.mjs.map +7 -0
  150. package/build-module/state/types.mjs +8 -0
  151. package/build-module/state/types.mjs.map +7 -0
  152. package/build-module/state/use-media-editor-state.mjs +278 -0
  153. package/build-module/state/use-media-editor-state.mjs.map +7 -0
  154. package/build-module/store/actions.mjs +4 -2
  155. package/build-module/store/actions.mjs.map +2 -2
  156. package/build-module/store/reducer.mjs +5 -3
  157. package/build-module/store/reducer.mjs.map +2 -2
  158. package/build-module/store/selectors.mjs +4 -0
  159. package/build-module/store/selectors.mjs.map +2 -2
  160. package/build-style/style-rtl.css +97 -44
  161. package/build-style/style.css +97 -44
  162. package/build-types/components/media-editor/index.d.ts +14 -5
  163. package/build-types/components/media-editor/index.d.ts.map +1 -1
  164. package/build-types/components/media-editor/use-crop-options.d.ts +35 -0
  165. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -0
  166. package/build-types/components/media-editor/use-save-media-editor.d.ts +29 -0
  167. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -0
  168. package/build-types/components/media-editor-canvas/index.d.ts +5 -10
  169. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  170. package/build-types/components/media-editor-crop-panel/index.d.ts +6 -25
  171. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  172. package/build-types/components/media-editor-fine-rotation/index.d.ts +14 -0
  173. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -0
  174. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  175. package/build-types/components/media-editor-transform-controls/index.d.ts +8 -0
  176. package/build-types/components/media-editor-transform-controls/index.d.ts.map +1 -0
  177. package/build-types/components/media-form/index.d.ts.map +1 -1
  178. package/build-types/components/media-form/sidebar-datetime-view.d.ts +10 -0
  179. package/build-types/components/media-form/sidebar-datetime-view.d.ts.map +1 -0
  180. package/build-types/components/rotation-ruler/index.d.ts.map +1 -1
  181. package/build-types/hooks/use-crop-gesture-handlers.d.ts +13 -14
  182. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  183. package/build-types/image-editor/core/camera.d.ts.map +1 -1
  184. package/build-types/image-editor/core/constants.d.ts +18 -0
  185. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  186. package/build-types/image-editor/core/containment.d.ts +10 -0
  187. package/build-types/image-editor/core/containment.d.ts.map +1 -1
  188. package/build-types/image-editor/core/crop-rect.d.ts +19 -0
  189. package/build-types/image-editor/core/crop-rect.d.ts.map +1 -0
  190. package/build-types/image-editor/core/index.d.ts +3 -1
  191. package/build-types/image-editor/core/index.d.ts.map +1 -1
  192. package/build-types/image-editor/core/interaction-controller.d.ts +5 -1
  193. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  194. package/build-types/image-editor/core/math/sanitize.d.ts +70 -0
  195. package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -0
  196. package/build-types/image-editor/core/setter-helpers.d.ts +24 -0
  197. package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -0
  198. package/build-types/image-editor/core/source-region.d.ts.map +1 -1
  199. package/build-types/image-editor/core/state.d.ts +12 -0
  200. package/build-types/image-editor/core/state.d.ts.map +1 -1
  201. package/build-types/image-editor/core/stencil-math.d.ts +23 -18
  202. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
  203. package/build-types/image-editor/core/transform-style.d.ts.map +1 -1
  204. package/build-types/image-editor/core/types.d.ts +23 -4
  205. package/build-types/image-editor/core/types.d.ts.map +1 -1
  206. package/build-types/image-editor/index.d.ts +4 -4
  207. package/build-types/image-editor/index.d.ts.map +1 -1
  208. package/build-types/image-editor/react/components/cropper-provider.d.ts +11 -7
  209. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  210. package/build-types/image-editor/react/components/cropper.d.ts +6 -4
  211. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  212. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +36 -0
  213. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -0
  214. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +2 -1
  215. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  216. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +47 -0
  217. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -0
  218. package/build-types/image-editor/react/hooks/index.d.ts +4 -2
  219. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -1
  220. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +58 -0
  221. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -0
  222. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
  223. package/build-types/state/composite-reducer.d.ts +39 -0
  224. package/build-types/state/composite-reducer.d.ts.map +1 -0
  225. package/build-types/state/index.d.ts +7 -0
  226. package/build-types/state/index.d.ts.map +1 -0
  227. package/build-types/state/media-editor-state-provider.d.ts +34 -0
  228. package/build-types/state/media-editor-state-provider.d.ts.map +1 -0
  229. package/build-types/state/types.d.ts +96 -0
  230. package/build-types/state/types.d.ts.map +1 -0
  231. package/build-types/state/use-media-editor-state.d.ts +101 -0
  232. package/build-types/state/use-media-editor-state.d.ts.map +1 -0
  233. package/build-types/store/actions.d.ts +3 -1
  234. package/build-types/store/actions.d.ts.map +1 -1
  235. package/build-types/store/reducer.d.ts +3 -0
  236. package/build-types/store/reducer.d.ts.map +1 -1
  237. package/build-types/store/selectors.d.ts +1 -0
  238. package/build-types/store/selectors.d.ts.map +1 -1
  239. package/package.json +19 -16
  240. package/src/components/media-editor/index.tsx +262 -229
  241. package/src/components/media-editor/style.scss +0 -9
  242. package/src/components/media-editor/test/use-crop-options.tsx +110 -0
  243. package/src/components/media-editor/use-crop-options.ts +79 -0
  244. package/src/components/media-editor/use-save-media-editor.ts +214 -0
  245. package/src/components/media-editor-canvas/index.tsx +57 -25
  246. package/src/components/media-editor-crop-panel/index.tsx +53 -87
  247. package/src/components/media-editor-crop-panel/test/index.tsx +46 -53
  248. package/src/components/media-editor-fine-rotation/index.tsx +74 -0
  249. package/src/components/media-editor-modal/index.tsx +70 -16
  250. package/src/components/media-editor-modal/style.scss +80 -0
  251. package/src/components/media-editor-modal/test/build-modifiers.test.ts +14 -0
  252. package/src/components/media-editor-modal/test/index.tsx +146 -0
  253. package/src/components/media-editor-transform-controls/index.tsx +70 -0
  254. package/src/components/media-editor-transform-controls/style.scss +8 -0
  255. package/src/components/media-form/index.tsx +15 -1
  256. package/src/components/media-form/sidebar-datetime-view.tsx +47 -0
  257. package/src/components/media-form/test/sidebar-datetime-view.test.tsx +96 -0
  258. package/src/components/rotation-ruler/README.md +11 -25
  259. package/src/components/rotation-ruler/index.tsx +17 -2
  260. package/src/components/rotation-ruler/style.scss +49 -13
  261. package/src/hooks/use-crop-gesture-handlers.ts +64 -17
  262. package/src/image-editor/README.md +28 -129
  263. package/src/image-editor/core/camera.ts +51 -26
  264. package/src/image-editor/core/constants.ts +19 -0
  265. package/src/image-editor/core/containment.ts +102 -49
  266. package/src/image-editor/core/crop-rect.ts +45 -0
  267. package/src/image-editor/core/index.ts +16 -4
  268. package/src/image-editor/core/interaction-controller.ts +5 -1
  269. package/src/image-editor/core/math/sanitize.ts +158 -0
  270. package/src/image-editor/core/math/test/sanitize.ts +244 -0
  271. package/src/image-editor/core/setter-helpers.ts +66 -0
  272. package/src/image-editor/core/source-region.ts +21 -14
  273. package/src/image-editor/core/state.ts +67 -15
  274. package/src/image-editor/core/stencil-math.ts +55 -35
  275. package/src/image-editor/core/test/camera.ts +367 -1
  276. package/src/image-editor/core/test/state.ts +101 -8
  277. package/src/image-editor/core/test/stencil-math.ts +193 -0
  278. package/src/image-editor/core/transform-style.ts +21 -6
  279. package/src/image-editor/core/types.ts +24 -4
  280. package/src/image-editor/docs/architecture.md +48 -89
  281. package/src/image-editor/docs/recipes.md +123 -659
  282. package/src/image-editor/index.ts +12 -3
  283. package/src/image-editor/react/components/cropper-provider.tsx +16 -12
  284. package/src/image-editor/react/components/cropper.scss +23 -4
  285. package/src/image-editor/react/components/cropper.tsx +194 -89
  286. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +269 -0
  287. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +19 -8
  288. package/src/image-editor/react/components/test/cropper.tsx +55 -13
  289. package/src/image-editor/react/hooks/build-cropper-setters.ts +105 -0
  290. package/src/image-editor/react/hooks/index.ts +4 -2
  291. package/src/image-editor/react/hooks/test/{use-cropper-state.ts → use-cropper-reducer.ts} +142 -286
  292. package/src/image-editor/react/hooks/use-cropper-reducer.ts +204 -0
  293. package/src/image-editor/stories/rectangle-crop.story.tsx +7 -17
  294. package/src/state/composite-reducer.ts +137 -0
  295. package/src/state/index.ts +20 -0
  296. package/src/state/media-editor-state-provider.tsx +70 -0
  297. package/src/state/test/use-media-editor-state.ts +330 -0
  298. package/src/state/types.ts +101 -0
  299. package/src/state/use-media-editor-state.ts +472 -0
  300. package/src/store/actions.ts +3 -0
  301. package/src/store/reducer.ts +6 -1
  302. package/src/store/selectors.ts +4 -0
  303. package/src/store/test/reducer.ts +9 -0
  304. package/src/style.scss +1 -1
  305. package/tsconfig.json +3 -0
  306. package/tsconfig.tsbuildinfo +1 -1
  307. package/build/components/media-editor-toolbar/index.cjs +0 -214
  308. package/build/components/media-editor-toolbar/index.cjs.map +0 -7
  309. package/build/image-editor/react/hooks/use-cropper-state.cjs +0 -277
  310. package/build/image-editor/react/hooks/use-cropper-state.cjs.map +0 -7
  311. package/build-module/components/media-editor-toolbar/index.mjs +0 -190
  312. package/build-module/components/media-editor-toolbar/index.mjs.map +0 -7
  313. package/build-module/image-editor/react/hooks/use-cropper-state.mjs +0 -262
  314. package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +0 -7
  315. package/build-types/components/media-editor-toolbar/index.d.ts +0 -24
  316. package/build-types/components/media-editor-toolbar/index.d.ts.map +0 -1
  317. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +0 -97
  318. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +0 -1
  319. package/src/components/media-editor-toolbar/index.tsx +0 -209
  320. package/src/components/media-editor-toolbar/style.scss +0 -49
  321. package/src/image-editor/docs/roadmap.md +0 -66
  322. package/src/image-editor/react/hooks/use-cropper-state.ts +0 -457
@@ -1,107 +1,91 @@
1
1
  // packages/media-editor/src/components/media-editor-crop-panel/index.tsx
2
- import {
3
- RangeControl,
4
- SelectControl,
5
- ToggleControl
6
- } from "@wordpress/components";
2
+ import { RangeControl, SelectControl } from "@wordpress/components";
7
3
  import { Stack, VisuallyHidden } from "@wordpress/ui";
8
4
  import { __, sprintf } from "@wordpress/i18n";
9
- import { useCropper } from "../../image-editor/index.mjs";
10
- import { useCropGestureHandlers } from "../../hooks/use-crop-gesture-handlers.mjs";
5
+ import { useMediaEditor } from "../../state/index.mjs";
11
6
  import {
12
- DEFAULT_ASPECT_RATIOS,
13
- MAX_ZOOM,
14
- MIN_ZOOM,
15
- ORIGINAL_ASPECT_RATIO
16
- } from "../../image-editor/core/constants.mjs";
7
+ useCropGestureHandlers,
8
+ CROP_CONTROL_ATTR
9
+ } from "../../hooks/use-crop-gesture-handlers.mjs";
10
+ import { MAX_ZOOM } from "../../image-editor/core/constants.mjs";
11
+ import { getMinZoom } from "../../image-editor/core/containment.mjs";
17
12
  import { jsx, jsxs } from "react/jsx-runtime";
18
- function resolveAspectRatio(value, imageAspectRatio) {
19
- const num = parseFloat(value);
20
- if (num === 0) {
21
- return void 0;
22
- }
23
- if (num === ORIGINAL_ASPECT_RATIO && imageAspectRatio) {
24
- return imageAspectRatio;
25
- }
26
- if (num > 0) {
27
- return num;
28
- }
29
- return void 0;
13
+ var ZOOM_PERCENTAGE_SCALE = 100;
14
+ var MAX_ZOOM_PERCENTAGE = MAX_ZOOM * ZOOM_PERCENTAGE_SCALE;
15
+ function getZoomPercentageForDisplay(zoom) {
16
+ return Math.round(zoom * ZOOM_PERCENTAGE_SCALE);
17
+ }
18
+ function getMinZoomPercentageForDisplay(zoom) {
19
+ return Math.ceil(zoom * ZOOM_PERCENTAGE_SCALE);
30
20
  }
31
21
  function MediaEditorCropPanel({
32
22
  aspectRatioValue,
33
23
  onAspectRatioChange,
34
- freeformCrop,
35
- onFreeformChange,
36
24
  onPlacementControlInteraction,
37
- aspectRatioPresets
25
+ aspectRatioOptions
38
26
  }) {
39
- const { state, setZoom } = useCropper();
27
+ const { state, setZoom } = useMediaEditor();
40
28
  const zoomGestureHandlers = useCropGestureHandlers();
41
- const aspectRatioOptions = [
42
- ...DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value <= 0),
43
- ...aspectRatioPresets ?? DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value > 0)
44
- ];
45
- const handleAspectRatioChange = (value) => {
46
- onAspectRatioChange(value);
47
- if (value === "0" && !freeformCrop) {
48
- onFreeformChange(true);
49
- }
50
- };
51
- return /* @__PURE__ */ jsxs(Stack, { direction: "column", gap: "md", children: [
52
- /* @__PURE__ */ jsx(VisuallyHidden, { render: /* @__PURE__ */ jsx("h2", {}), children: __("Crop options") }),
53
- /* @__PURE__ */ jsx(
54
- SelectControl,
55
- {
56
- __next40pxDefaultSize: true,
57
- __nextHasNoMarginBottom: true,
58
- label: __("Aspect ratio"),
59
- value: aspectRatioValue,
60
- onChange: handleAspectRatioChange,
61
- options: aspectRatioOptions.map((preset) => ({
62
- label: preset.label,
63
- value: preset.value.toString()
64
- }))
65
- }
66
- ),
67
- /* @__PURE__ */ jsx(
68
- ToggleControl,
69
- {
70
- __nextHasNoMarginBottom: true,
71
- label: __("Resize crop area"),
72
- help: __("Show handles to adjust the crop box."),
73
- checked: freeformCrop,
74
- onChange: onFreeformChange
75
- }
76
- ),
77
- /* @__PURE__ */ jsx("div", { role: "presentation", ...zoomGestureHandlers, children: /* @__PURE__ */ jsx(
78
- RangeControl,
29
+ const minZoom = getMinZoom(state);
30
+ const zoomPercentage = getZoomPercentageForDisplay(state.zoom);
31
+ const minZoomPercentage = getMinZoomPercentageForDisplay(minZoom);
32
+ return (
33
+ // Tag the whole panel as a crop-control region so the modal's
34
+ // Cmd+Z handler doesn't mistake the SelectControl input for a
35
+ // metadata field (which would suppress undo).
36
+ /* @__PURE__ */ jsxs(
37
+ Stack,
79
38
  {
80
- __next40pxDefaultSize: true,
81
- __nextHasNoMarginBottom: true,
82
- label: __("Zoom"),
83
- min: MIN_ZOOM,
84
- max: MAX_ZOOM,
85
- step: 0.1,
86
- value: state.zoom,
87
- onChange: (value) => {
88
- onPlacementControlInteraction?.();
89
- setZoom(typeof value === "number" ? value : MIN_ZOOM);
90
- },
91
- renderTooltipContent: (value) => {
92
- const zoom = typeof value === "number" ? value : MIN_ZOOM;
93
- return sprintf(
94
- /* translators: %d: zoom level as a percentage. */
95
- __("%d%%"),
96
- Math.round(zoom * 100)
97
- );
98
- }
39
+ direction: "column",
40
+ gap: "xl",
41
+ ...{ [CROP_CONTROL_ATTR]: true },
42
+ children: [
43
+ /* @__PURE__ */ jsx(VisuallyHidden, { render: /* @__PURE__ */ jsx("h2", {}), children: __("Crop options") }),
44
+ /* @__PURE__ */ jsx(
45
+ SelectControl,
46
+ {
47
+ __next40pxDefaultSize: true,
48
+ label: __("Aspect ratio"),
49
+ value: aspectRatioValue,
50
+ onChange: onAspectRatioChange,
51
+ options: aspectRatioOptions.map((preset) => ({
52
+ label: preset.label,
53
+ value: preset.value.toString()
54
+ }))
55
+ }
56
+ ),
57
+ /* @__PURE__ */ jsx("div", { role: "presentation", ...zoomGestureHandlers, children: /* @__PURE__ */ jsx(
58
+ RangeControl,
59
+ {
60
+ __next40pxDefaultSize: true,
61
+ label: __("Zoom (%)"),
62
+ min: minZoomPercentage,
63
+ max: MAX_ZOOM_PERCENTAGE,
64
+ step: 1,
65
+ shiftStep: 10,
66
+ value: zoomPercentage,
67
+ onChange: (value) => {
68
+ onPlacementControlInteraction?.();
69
+ setZoom(
70
+ typeof value === "number" ? value / ZOOM_PERCENTAGE_SCALE : minZoom
71
+ );
72
+ },
73
+ renderTooltipContent: (value) => {
74
+ const percentage = typeof value === "number" ? value : minZoomPercentage;
75
+ return sprintf(
76
+ /* translators: %d: zoom level as a percentage. */
77
+ __("%d%%"),
78
+ Math.round(percentage)
79
+ );
80
+ }
81
+ }
82
+ ) })
83
+ ]
99
84
  }
100
- ) })
101
- ] });
85
+ )
86
+ );
102
87
  }
103
88
  export {
104
- MediaEditorCropPanel as default,
105
- resolveAspectRatio
89
+ MediaEditorCropPanel as default
106
90
  };
107
91
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor-crop-panel/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tRangeControl,\n\tSelectControl,\n\tToggleControl,\n} from '@wordpress/components';\nimport { Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useCropper } from '../../image-editor';\nimport { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';\nimport {\n\tDEFAULT_ASPECT_RATIOS,\n\tMAX_ZOOM,\n\tMIN_ZOOM,\n\tORIGINAL_ASPECT_RATIO,\n} from '../../image-editor/core/constants';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Whether the cropper is in freeform (resize-handle) mode. */\n\tfreeformCrop: boolean;\n\t/** Setter for freeform mode. */\n\tonFreeformChange: ( value: boolean ) => void;\n\t/** Signal that a placement-oriented control is being adjusted. */\n\tonPlacementControlInteraction?: () => void;\n\t/**\n\t * Fixed aspect-ratio presets to display after Free and Original. When\n\t * omitted, the media editor's default fixed-ratio presets are used.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\n/**\n * Resolve an aspect-ratio preset value into a number suitable for\n * `<Cropper aspectRatio=...>`. Returns `undefined` for Free (no lock).\n *\n * @param value Preset value as a string.\n * @param imageAspectRatio Image's natural width / height \u2014 used for\n * the Original preset.\n */\nexport function resolveAspectRatio(\n\tvalue: string,\n\timageAspectRatio: number | null\n): number | undefined {\n\tconst num = parseFloat( value );\n\tif ( num === 0 ) {\n\t\treturn undefined;\n\t}\n\tif ( num === ORIGINAL_ASPECT_RATIO && imageAspectRatio ) {\n\t\treturn imageAspectRatio;\n\t}\n\tif ( num > 0 ) {\n\t\treturn num;\n\t}\n\treturn undefined;\n}\n\n/**\n * Sidebar panel for crop-shape controls \u2014 aspect-ratio presets and\n * freeform toggle. The tactile verbs (rotate, flip) live in the\n * bottom toolbar instead.\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.freeformCrop\n * @param props.onFreeformChange\n * @param props.onPlacementControlInteraction\n * @param props.aspectRatioPresets\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\tfreeformCrop,\n\tonFreeformChange,\n\tonPlacementControlInteraction,\n\taspectRatioPresets,\n}: MediaEditorCropPanelProps ) {\n\tconst { state, setZoom } = useCropper();\n\tconst zoomGestureHandlers = useCropGestureHandlers();\n\tconst aspectRatioOptions = [\n\t\t...DEFAULT_ASPECT_RATIOS.filter( ( preset ) => preset.value <= 0 ),\n\t\t...( aspectRatioPresets ??\n\t\t\tDEFAULT_ASPECT_RATIOS.filter( ( preset ) => preset.value > 0 ) ),\n\t];\n\tconst handleAspectRatioChange = ( value: string ) => {\n\t\tonAspectRatioChange( value );\n\t\tif ( value === '0' && ! freeformCrop ) {\n\t\t\tonFreeformChange( true );\n\t\t}\n\t};\n\n\treturn (\n\t\t<Stack direction=\"column\" gap=\"md\">\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<SelectControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ handleAspectRatioChange }\n\t\t\t\toptions={ aspectRatioOptions.map( ( preset ) => ( {\n\t\t\t\t\tlabel: preset.label,\n\t\t\t\t\tvalue: preset.value.toString(),\n\t\t\t\t} ) ) }\n\t\t\t/>\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Resize crop area' ) }\n\t\t\t\thelp={ __( 'Show handles to adjust the crop box.' ) }\n\t\t\t\tchecked={ freeformCrop }\n\t\t\t\tonChange={ onFreeformChange }\n\t\t\t/>\n\t\t\t<div role=\"presentation\" { ...zoomGestureHandlers }>\n\t\t\t\t<RangeControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Zoom' ) }\n\t\t\t\t\tmin={ MIN_ZOOM }\n\t\t\t\t\tmax={ MAX_ZOOM }\n\t\t\t\t\tstep={ 0.1 }\n\t\t\t\t\tvalue={ state.zoom }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tonPlacementControlInteraction?.();\n\t\t\t\t\t\tsetZoom( typeof value === 'number' ? value : MIN_ZOOM );\n\t\t\t\t\t} }\n\t\t\t\t\trenderTooltipContent={ ( value ) => {\n\t\t\t\t\t\tconst zoom =\n\t\t\t\t\t\t\ttypeof value === 'number' ? value : MIN_ZOOM;\n\t\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t\t/* translators: %d: zoom level as a percentage. */\n\t\t\t\t\t\t\t__( '%d%%' ),\n\t\t\t\t\t\t\tMath.round( zoom * 100 )\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Stack>\n\t);\n}\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,OAAO,sBAAsB;AACtC,SAAS,IAAI,eAAe;AAK5B,SAAS,kBAAkB;AAC3B,SAAS,8BAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAqFL,SAC0B,KAD1B;AApDK,SAAS,mBACf,OACA,kBACqB;AACrB,QAAM,MAAM,WAAY,KAAM;AAC9B,MAAK,QAAQ,GAAI;AAChB,WAAO;AAAA,EACR;AACA,MAAK,QAAQ,yBAAyB,kBAAmB;AACxD,WAAO;AAAA,EACR;AACA,MAAK,MAAM,GAAI;AACd,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAce,SAAR,qBAAuC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA+B;AAC9B,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW;AACtC,QAAM,sBAAsB,uBAAuB;AACnD,QAAM,qBAAqB;AAAA,IAC1B,GAAG,sBAAsB,OAAQ,CAAE,WAAY,OAAO,SAAS,CAAE;AAAA,IACjE,GAAK,sBACJ,sBAAsB,OAAQ,CAAE,WAAY,OAAO,QAAQ,CAAE;AAAA,EAC/D;AACA,QAAM,0BAA0B,CAAE,UAAmB;AACpD,wBAAqB,KAAM;AAC3B,QAAK,UAAU,OAAO,CAAE,cAAe;AACtC,uBAAkB,IAAK;AAAA,IACxB;AAAA,EACD;AAEA,SACC,qBAAC,SAAM,WAAU,UAAS,KAAI,MAC7B;AAAA,wBAAC,kBAAe,QAAS,oBAAC,QAAG,GAC1B,aAAI,cAAe,GACtB;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,yBAAuB;AAAA,QACvB,OAAQ,GAAI,cAAe;AAAA,QAC3B,OAAQ;AAAA,QACR,UAAW;AAAA,QACX,SAAU,mBAAmB,IAAK,CAAE,YAAc;AAAA,UACjD,OAAO,OAAO;AAAA,UACd,OAAO,OAAO,MAAM,SAAS;AAAA,QAC9B,EAAI;AAAA;AAAA,IACL;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,yBAAuB;AAAA,QACvB,OAAQ,GAAI,kBAAmB;AAAA,QAC/B,MAAO,GAAI,sCAAuC;AAAA,QAClD,SAAU;AAAA,QACV,UAAW;AAAA;AAAA,IACZ;AAAA,IACA,oBAAC,SAAI,MAAK,gBAAiB,GAAG,qBAC7B;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,yBAAuB;AAAA,QACvB,OAAQ,GAAI,MAAO;AAAA,QACnB,KAAM;AAAA,QACN,KAAM;AAAA,QACN,MAAO;AAAA,QACP,OAAQ,MAAM;AAAA,QACd,UAAW,CAAE,UAAW;AACvB,0CAAgC;AAChC,kBAAS,OAAO,UAAU,WAAW,QAAQ,QAAS;AAAA,QACvD;AAAA,QACA,sBAAuB,CAAE,UAAW;AACnC,gBAAM,OACL,OAAO,UAAU,WAAW,QAAQ;AACrC,iBAAO;AAAA;AAAA,YAEN,GAAI,MAAO;AAAA,YACX,KAAK,MAAO,OAAO,GAAI;AAAA,UACxB;AAAA,QACD;AAAA;AAAA,IACD,GACD;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { RangeControl, SelectControl } from '@wordpress/components';\nimport { Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../../state';\nimport {\n\tuseCropGestureHandlers,\n\tCROP_CONTROL_ATTR,\n} from '../../hooks/use-crop-gesture-handlers';\nimport { MAX_ZOOM } from '../../image-editor/core/constants';\nimport { getMinZoom } from '../../image-editor/core/containment';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\nconst ZOOM_PERCENTAGE_SCALE = 100;\nconst MAX_ZOOM_PERCENTAGE = MAX_ZOOM * ZOOM_PERCENTAGE_SCALE;\n\nfunction getZoomPercentageForDisplay( zoom: number ): number {\n\treturn Math.round( zoom * ZOOM_PERCENTAGE_SCALE );\n}\n\nfunction getMinZoomPercentageForDisplay( zoom: number ): number {\n\treturn Math.ceil( zoom * ZOOM_PERCENTAGE_SCALE );\n}\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Signal that a placement-oriented control is being adjusted. */\n\tonPlacementControlInteraction?: () => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n}\n\n/**\n * Sidebar panel for crop-shape controls. The tactile verbs (rotate, flip)\n * live in the bottom toolbar instead.\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.onPlacementControlInteraction\n * @param props.aspectRatioOptions\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\tonPlacementControlInteraction,\n\taspectRatioOptions,\n}: MediaEditorCropPanelProps ) {\n\tconst { state, setZoom } = useMediaEditor();\n\tconst zoomGestureHandlers = useCropGestureHandlers();\n\tconst minZoom = getMinZoom( state );\n\tconst zoomPercentage = getZoomPercentageForDisplay( state.zoom );\n\tconst minZoomPercentage = getMinZoomPercentageForDisplay( minZoom );\n\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl input for a\n\t\t// metadata field (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"xl\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<SelectControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ onAspectRatioChange }\n\t\t\t\toptions={ aspectRatioOptions.map( ( preset ) => ( {\n\t\t\t\t\tlabel: preset.label,\n\t\t\t\t\tvalue: preset.value.toString(),\n\t\t\t\t} ) ) }\n\t\t\t/>\n\t\t\t<div role=\"presentation\" { ...zoomGestureHandlers }>\n\t\t\t\t<RangeControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Zoom (%)' ) }\n\t\t\t\t\tmin={ minZoomPercentage }\n\t\t\t\t\tmax={ MAX_ZOOM_PERCENTAGE }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tshiftStep={ 10 }\n\t\t\t\t\tvalue={ zoomPercentage }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tonPlacementControlInteraction?.();\n\t\t\t\t\t\tsetZoom(\n\t\t\t\t\t\t\ttypeof value === 'number'\n\t\t\t\t\t\t\t\t? value / ZOOM_PERCENTAGE_SCALE\n\t\t\t\t\t\t\t\t: minZoom\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t\trenderTooltipContent={ ( value ) => {\n\t\t\t\t\t\tconst percentage =\n\t\t\t\t\t\t\ttypeof value === 'number'\n\t\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t\t: minZoomPercentage;\n\t\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t\t/* translators: %d: zoom level as a percentage. */\n\t\t\t\t\t\t\t__( '%d%%' ),\n\t\t\t\t\t\t\tMath.round( percentage )\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Stack>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,cAAc,qBAAqB;AAC5C,SAAS,OAAO,sBAAsB;AACtC,SAAS,IAAI,eAAe;AAK5B,SAAS,sBAAsB;AAC/B;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAsDzB,SAK0B,KAL1B;AAnDF,IAAM,wBAAwB;AAC9B,IAAM,sBAAsB,WAAW;AAEvC,SAAS,4BAA6B,MAAuB;AAC5D,SAAO,KAAK,MAAO,OAAO,qBAAsB;AACjD;AAEA,SAAS,+BAAgC,MAAuB;AAC/D,SAAO,KAAK,KAAM,OAAO,qBAAsB;AAChD;AA0Be,SAAR,qBAAuC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA+B;AAC9B,QAAM,EAAE,OAAO,QAAQ,IAAI,eAAe;AAC1C,QAAM,sBAAsB,uBAAuB;AACnD,QAAM,UAAU,WAAY,KAAM;AAClC,QAAM,iBAAiB,4BAA6B,MAAM,IAAK;AAC/D,QAAM,oBAAoB,+BAAgC,OAAQ;AAElE;AAAA;AAAA;AAAA;AAAA,IAIC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,KAAI;AAAA,QACF,GAAG,EAAE,CAAE,iBAAkB,GAAG,KAAK;AAAA,QAEnC;AAAA,8BAAC,kBAAe,QAAS,oBAAC,QAAG,GAC1B,aAAI,cAAe,GACtB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,OAAQ,GAAI,cAAe;AAAA,cAC3B,OAAQ;AAAA,cACR,UAAW;AAAA,cACX,SAAU,mBAAmB,IAAK,CAAE,YAAc;AAAA,gBACjD,OAAO,OAAO;AAAA,gBACd,OAAO,OAAO,MAAM,SAAS;AAAA,cAC9B,EAAI;AAAA;AAAA,UACL;AAAA,UACA,oBAAC,SAAI,MAAK,gBAAiB,GAAG,qBAC7B;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,OAAQ,GAAI,UAAW;AAAA,cACvB,KAAM;AAAA,cACN,KAAM;AAAA,cACN,MAAO;AAAA,cACP,WAAY;AAAA,cACZ,OAAQ;AAAA,cACR,UAAW,CAAE,UAAW;AACvB,gDAAgC;AAChC;AAAA,kBACC,OAAO,UAAU,WACd,QAAQ,wBACR;AAAA,gBACJ;AAAA,cACD;AAAA,cACA,sBAAuB,CAAE,UAAW;AACnC,sBAAM,aACL,OAAO,UAAU,WACd,QACA;AACJ,uBAAO;AAAA;AAAA,kBAEN,GAAI,MAAO;AAAA,kBACX,KAAK,MAAO,UAAW;AAAA,gBACxB;AAAA,cACD;AAAA;AAAA,UACD,GACD;AAAA;AAAA;AAAA,IACD;AAAA;AAEF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,50 @@
1
+ // packages/media-editor/src/components/media-editor-fine-rotation/index.tsx
2
+ import { __ } from "@wordpress/i18n";
3
+ import { useMediaEditor } from "../../state/index.mjs";
4
+ import { useCropGestureHandlers } from "../../hooks/use-crop-gesture-handlers.mjs";
5
+ import { MAX_ROTATION_OFFSET } from "../../image-editor/core/constants.mjs";
6
+ import RotationRuler from "../rotation-ruler/index.mjs";
7
+ import { jsx } from "react/jsx-runtime";
8
+ function MediaEditorFineRotation({
9
+ onPlacementControlInteraction
10
+ }) {
11
+ const { state, setRotation } = useMediaEditor();
12
+ const rotationGestureHandlers = useCropGestureHandlers({
13
+ commitOnKeyUp: false
14
+ });
15
+ const baseAngle = Math.round(state.rotation / 90) * 90;
16
+ const singleFlip = state.flip.horizontal !== state.flip.vertical;
17
+ const visualDir = singleFlip ? -1 : 1;
18
+ const fineOffset = (state.rotation - baseAngle) * visualDir;
19
+ const handleRotationSlider = (value) => {
20
+ const EPS = 0.01;
21
+ const clamped = Math.max(
22
+ -MAX_ROTATION_OFFSET + EPS,
23
+ Math.min(MAX_ROTATION_OFFSET - EPS, value)
24
+ );
25
+ onPlacementControlInteraction?.();
26
+ setRotation(baseAngle + clamped * visualDir);
27
+ };
28
+ return /* @__PURE__ */ jsx(
29
+ "div",
30
+ {
31
+ role: "presentation",
32
+ className: "media-editor-fine-rotation",
33
+ ...rotationGestureHandlers,
34
+ children: /* @__PURE__ */ jsx(
35
+ RotationRuler,
36
+ {
37
+ label: __("Fine rotation"),
38
+ min: -MAX_ROTATION_OFFSET,
39
+ max: MAX_ROTATION_OFFSET,
40
+ value: fineOffset,
41
+ onChange: handleRotationSlider
42
+ }
43
+ )
44
+ }
45
+ );
46
+ }
47
+ export {
48
+ MediaEditorFineRotation as default
49
+ };
50
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/media-editor-fine-rotation/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../../state';\nimport { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';\nimport { MAX_ROTATION_OFFSET } from '../../image-editor/core/constants';\nimport RotationRuler from '../rotation-ruler';\n\nexport interface MediaEditorFineRotationProps {\n\t/** Signal that a placement-oriented control is being adjusted. */\n\tonPlacementControlInteraction?: () => void;\n}\n\n/**\n * Fine-rotation slider for the media-editor footer. Lives separately from\n * the snap-rotate / flip buttons so the footer can place the two halves on\n * different rows at intermediate viewport widths.\n *\n * @param props\n * @param props.onPlacementControlInteraction\n */\nexport default function MediaEditorFineRotation( {\n\tonPlacementControlInteraction,\n}: MediaEditorFineRotationProps ) {\n\tconst { state, setRotation } = useMediaEditor();\n\t// `commitOnKeyUp: false` lets rapid arrow-key adjustments coalesce\n\t// into one undo entry via the gesture idle window. Pointer-up still\n\t// closes pointer drags immediately.\n\tconst rotationGestureHandlers = useCropGestureHandlers( {\n\t\tcommitOnKeyUp: false,\n\t} );\n\n\t// `setRotation` is an absolute-angle setter. When a single flip is active\n\t// the visual direction inverts, so slider input must flip sign to match\n\t// what the user sees. `snapRotate90` already handles this internally.\n\tconst baseAngle = Math.round( state.rotation / 90 ) * 90;\n\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\tconst visualDir = singleFlip ? -1 : 1;\n\tconst fineOffset = ( state.rotation - baseAngle ) * visualDir;\n\n\tconst handleRotationSlider = ( value: number ) => {\n\t\t// Clamp strictly inside [-MAX, MAX). Exactly \u00B1MAX lands state on a\n\t\t// 90\u00B0 midpoint and flips the derived baseAngle on the next render,\n\t\t// causing subsequent events to spiral.\n\t\tconst EPS = 0.01;\n\t\tconst clamped = Math.max(\n\t\t\t-MAX_ROTATION_OFFSET + EPS,\n\t\t\tMath.min( MAX_ROTATION_OFFSET - EPS, value )\n\t\t);\n\t\tonPlacementControlInteraction?.();\n\t\tsetRotation( baseAngle + clamped * visualDir );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\trole=\"presentation\"\n\t\t\tclassName=\"media-editor-fine-rotation\"\n\t\t\t{ ...rotationGestureHandlers }\n\t\t>\n\t\t\t<RotationRuler\n\t\t\t\tlabel={ __( 'Fine rotation' ) }\n\t\t\t\tmin={ -MAX_ROTATION_OFFSET }\n\t\t\t\tmax={ MAX_ROTATION_OFFSET }\n\t\t\t\tvalue={ fineOffset }\n\t\t\t\tonChange={ handleRotationSlider }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AAKnB,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,OAAO,mBAAmB;AAqDvB;AAtCY,SAAR,wBAA0C;AAAA,EAChD;AACD,GAAkC;AACjC,QAAM,EAAE,OAAO,YAAY,IAAI,eAAe;AAI9C,QAAM,0BAA0B,uBAAwB;AAAA,IACvD,eAAe;AAAA,EAChB,CAAE;AAKF,QAAM,YAAY,KAAK,MAAO,MAAM,WAAW,EAAG,IAAI;AACtD,QAAM,aAAa,MAAM,KAAK,eAAe,MAAM,KAAK;AACxD,QAAM,YAAY,aAAa,KAAK;AACpC,QAAM,cAAe,MAAM,WAAW,aAAc;AAEpD,QAAM,uBAAuB,CAAE,UAAmB;AAIjD,UAAM,MAAM;AACZ,UAAM,UAAU,KAAK;AAAA,MACpB,CAAC,sBAAsB;AAAA,MACvB,KAAK,IAAK,sBAAsB,KAAK,KAAM;AAAA,IAC5C;AACA,oCAAgC;AAChC,gBAAa,YAAY,UAAU,SAAU;AAAA,EAC9C;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,WAAU;AAAA,MACR,GAAG;AAAA,MAEL;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ,GAAI,eAAgB;AAAA,UAC5B,KAAM,CAAC;AAAA,UACP,KAAM;AAAA,UACN,OAAQ;AAAA,UACR,UAAW;AAAA;AAAA,MACZ;AAAA;AAAA,EACD;AAEF;",
6
+ "names": []
7
+ }
@@ -2,26 +2,37 @@
2
2
  import { Modal } from "@wordpress/components";
3
3
  import { useDispatch, useSelect } from "@wordpress/data";
4
4
  import { __ } from "@wordpress/i18n";
5
+ import { ShortcutProvider } from "@wordpress/keyboard-shortcuts";
6
+ import { store as noticesStore } from "@wordpress/notices";
5
7
  import MediaEditor from "../media-editor/index.mjs";
6
8
  import { store as mediaEditorStore } from "../../store/index.mjs";
7
- import { jsx } from "react/jsx-runtime";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
8
10
  function MediaEditorModal({
9
11
  fields = [],
10
12
  aspectRatioPresets
11
13
  }) {
12
- const { isModalOpen, id, onUpdate } = useSelect((select) => {
13
- const { isOpen, getId, getOnUpdate } = select(mediaEditorStore);
14
+ const { isModalOpen, id, onUpdate, onClose } = useSelect((select) => {
15
+ const { isOpen, getId, getOnUpdate, getOnClose } = select(mediaEditorStore);
14
16
  return {
15
17
  isModalOpen: isOpen(),
16
18
  id: getId(),
17
- onUpdate: getOnUpdate()
19
+ onUpdate: getOnUpdate(),
20
+ onClose: getOnClose()
18
21
  };
19
22
  }, []);
20
23
  const { closeMediaEditorModal } = useDispatch(mediaEditorStore);
24
+ const { createSuccessNotice } = useDispatch(noticesStore);
21
25
  if (!isModalOpen || !id) {
22
26
  return null;
23
27
  }
24
28
  const portalElement = typeof document === "undefined" ? null : document.body;
29
+ const stopKeyDownPropagation = (event) => {
30
+ event.stopPropagation();
31
+ };
32
+ const handleClose = () => {
33
+ closeMediaEditorModal();
34
+ onClose?.();
35
+ };
25
36
  return /* @__PURE__ */ jsx(
26
37
  MediaEditor,
27
38
  {
@@ -32,8 +43,8 @@ function MediaEditorModal({
32
43
  shouldCloseOnEsc: true,
33
44
  noticesClassName: "media-editor-modal__snackbar",
34
45
  noticesPortalElement: portalElement,
35
- onClose: closeMediaEditorModal,
36
- onSaved: ({ id: savedId, url }) => {
46
+ onClose: handleClose,
47
+ onSaved: ({ id: savedId, url, previous }) => {
37
48
  if (savedId && onUpdate) {
38
49
  const update = {
39
50
  id: savedId,
@@ -41,26 +52,62 @@ function MediaEditorModal({
41
52
  };
42
53
  onUpdate(update);
43
54
  }
44
- closeMediaEditorModal();
55
+ handleClose();
56
+ if (previous && savedId !== previous.id && onUpdate) {
57
+ createSuccessNotice(__("Image edited."), {
58
+ type: "snackbar",
59
+ actions: [
60
+ {
61
+ label: __("Undo"),
62
+ onClick: () => {
63
+ onUpdate({
64
+ id: previous.id,
65
+ url: previous.url
66
+ });
67
+ }
68
+ }
69
+ ]
70
+ });
71
+ }
45
72
  },
46
73
  renderFrame: ({
47
74
  children,
48
75
  headerActions,
76
+ footerActions,
77
+ footerLayout,
49
78
  onRequestClose,
50
79
  onKeyDown,
51
80
  shouldCloseOnClickOutside
52
81
  }) => /* @__PURE__ */ jsx(
53
- Modal,
82
+ ShortcutProvider,
54
83
  {
55
- className: "media-editor-modal",
56
- title: __("Edit media"),
57
- size: "fill",
58
- isDismissible: false,
59
- shouldCloseOnClickOutside,
60
- onKeyDown,
61
- onRequestClose,
62
- headerActions,
63
- children
84
+ className: "media-editor-modal__shortcut-scope",
85
+ onKeyDown: stopKeyDownPropagation,
86
+ children: /* @__PURE__ */ jsxs(
87
+ Modal,
88
+ {
89
+ className: "media-editor-modal",
90
+ title: __("Edit media"),
91
+ size: "fill",
92
+ isDismissible: false,
93
+ shouldCloseOnClickOutside,
94
+ onKeyDown,
95
+ onRequestClose,
96
+ headerActions,
97
+ children: [
98
+ children,
99
+ /* @__PURE__ */ jsx(
100
+ "div",
101
+ {
102
+ className: `media-editor-modal__footer is-${footerLayout}`,
103
+ role: "region",
104
+ "aria-label": __("Editor actions"),
105
+ children: footerActions
106
+ }
107
+ )
108
+ ]
109
+ }
110
+ )
64
111
  }
65
112
  )
66
113
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor-modal/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate } = useSelect( ( select ) => {\n\t\tconst { isOpen, getId, getOnUpdate } = select( mediaEditorStore );\n\t\treturn {\n\t\t\tisModalOpen: isOpen(),\n\t\t\tid: getId(),\n\t\t\tonUpdate: getOnUpdate(),\n\t\t};\n\t}, [] );\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshowCloseButton\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\tonClose={ closeMediaEditorModal }\n\t\t\tonSaved={ ( { id: savedId, url } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\tcloseMediaEditorModal();\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\theaderActions,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<Modal\n\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\theaderActions={ headerActions }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default MediaEditorModal;\n"],
5
- "mappings": ";AAGA,SAAS,aAAa;AACtB,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AAMnB,OAAO,iBAAiB;AAExB,SAAS,SAAS,wBAAwB;AAoEtC;AAjDG,SAAS,iBAAkB;AAAA,EACjC,SAAS,CAAC;AAAA,EACV;AACD,GAA2B;AAC1B,QAAM,EAAE,aAAa,IAAI,SAAS,IAAI,UAAW,CAAE,WAAY;AAC9D,UAAM,EAAE,QAAQ,OAAO,YAAY,IAAI,OAAQ,gBAAiB;AAChE,WAAO;AAAA,MACN,aAAa,OAAO;AAAA,MACpB,IAAI,MAAM;AAAA,MACV,UAAU,YAAY;AAAA,IACvB;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAEhE,MAAK,CAAE,eAAe,CAAE,IAAK;AAC5B,WAAO;AAAA,EACR;AAEA,QAAM,gBACL,OAAO,aAAa,cAAc,OAAO,SAAS;AAEnD,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAe;AAAA,MACf,kBAAgB;AAAA,MAChB,kBAAiB;AAAA,MACjB,sBAAuB;AAAA,MACvB,SAAU;AAAA,MACV,SAAU,CAAE,EAAE,IAAI,SAAS,IAAI,MAAO;AACrC,YAAK,WAAW,UAAW;AAC1B,gBAAM,SAAiC;AAAA,YACtC,IAAI;AAAA,YACJ;AAAA,UACD;AACA,mBAAU,MAAO;AAAA,QAClB;AACA,8BAAsB;AAAA,MACvB;AAAA,MACA,aAAc,CAAE;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,MACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,OAAQ,GAAI,YAAa;AAAA,UACzB,MAAK;AAAA,UACL,eAAgB;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UAEE;AAAA;AAAA,MACH;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,6BAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\n\n/**\n * Internal dependencies\n */\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate, onClose } = useSelect( ( select ) => {\n\t\tconst { isOpen, getId, getOnUpdate, getOnClose } =\n\t\t\tselect( mediaEditorStore );\n\t\treturn {\n\t\t\tisModalOpen: isOpen(),\n\t\t\tid: getId(),\n\t\t\tonUpdate: getOnUpdate(),\n\t\t\tonClose: getOnClose(),\n\t\t};\n\t}, [] );\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\t// React synthetic events bubble through the React tree, not the DOM tree,\n\t// so a host `ShortcutProvider` higher up still receives keydown events\n\t// from inside this portaled modal. Stop propagation at the modal boundary\n\t// so host shortcuts (undo/redo, save, etc.) don't fire from within.\n\tconst stopKeyDownPropagation = (\n\t\tevent: ReactKeyboardEvent< HTMLDivElement >\n\t) => {\n\t\tevent.stopPropagation();\n\t};\n\n\tconst handleClose = () => {\n\t\tcloseMediaEditorModal();\n\t\tonClose?.();\n\t};\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshowCloseButton\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\tonClose={ handleClose }\n\t\t\tonSaved={ ( { id: savedId, url, previous } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\thandleClose();\n\t\t\t\tif ( previous && savedId !== previous.id && onUpdate ) {\n\t\t\t\t\t// Intentionally unscoped: the modal is closing, so the\n\t\t\t\t\t// snackbar surfaces in the host editor (not the media\n\t\t\t\t\t// editor's `MEDIA_EDITOR_NOTICES_CONTEXT` region).\n\t\t\t\t\tcreateSuccessNotice( __( 'Image edited.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\tonUpdate( {\n\t\t\t\t\t\t\t\t\t\tid: previous.id,\n\t\t\t\t\t\t\t\t\t\turl: previous.url,\n\t\t\t\t\t\t\t\t\t} );\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} );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\theaderActions,\n\t\t\t\tfooterActions,\n\t\t\t\tfooterLayout,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<ShortcutProvider\n\t\t\t\t\tclassName=\"media-editor-modal__shortcut-scope\"\n\t\t\t\t\tonKeyDown={ stopKeyDownPropagation }\n\t\t\t\t>\n\t\t\t\t\t<Modal\n\t\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\t\theaderActions={ headerActions }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ `media-editor-modal__footer is-${ footerLayout }` }\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ __( 'Editor actions' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ footerActions }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Modal>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default MediaEditorModal;\n"],
5
+ "mappings": ";AAGA,SAAS,aAAa;AACtB,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,SAAS,oBAAoB;AAOtC,OAAO,iBAAiB;AAExB,SAAS,SAAS,wBAAwB;AA+GrC,SAWC,KAXD;AA5FE,SAAS,iBAAkB;AAAA,EACjC,SAAS,CAAC;AAAA,EACV;AACD,GAA2B;AAC1B,QAAM,EAAE,aAAa,IAAI,UAAU,QAAQ,IAAI,UAAW,CAAE,WAAY;AACvE,UAAM,EAAE,QAAQ,OAAO,aAAa,WAAW,IAC9C,OAAQ,gBAAiB;AAC1B,WAAO;AAAA,MACN,aAAa,OAAO;AAAA,MACpB,IAAI,MAAM;AAAA,MACV,UAAU,YAAY;AAAA,MACtB,SAAS,WAAW;AAAA,IACrB;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAChE,QAAM,EAAE,oBAAoB,IAAI,YAAa,YAAa;AAE1D,MAAK,CAAE,eAAe,CAAE,IAAK;AAC5B,WAAO;AAAA,EACR;AAEA,QAAM,gBACL,OAAO,aAAa,cAAc,OAAO,SAAS;AAMnD,QAAM,yBAAyB,CAC9B,UACI;AACJ,UAAM,gBAAgB;AAAA,EACvB;AAEA,QAAM,cAAc,MAAM;AACzB,0BAAsB;AACtB,cAAU;AAAA,EACX;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAe;AAAA,MACf,kBAAgB;AAAA,MAChB,kBAAiB;AAAA,MACjB,sBAAuB;AAAA,MACvB,SAAU;AAAA,MACV,SAAU,CAAE,EAAE,IAAI,SAAS,KAAK,SAAS,MAAO;AAC/C,YAAK,WAAW,UAAW;AAC1B,gBAAM,SAAiC;AAAA,YACtC,IAAI;AAAA,YACJ;AAAA,UACD;AACA,mBAAU,MAAO;AAAA,QAClB;AACA,oBAAY;AACZ,YAAK,YAAY,YAAY,SAAS,MAAM,UAAW;AAItD,8BAAqB,GAAI,eAAgB,GAAG;AAAA,YAC3C,MAAM;AAAA,YACN,SAAS;AAAA,cACR;AAAA,gBACC,OAAO,GAAI,MAAO;AAAA,gBAClB,SAAS,MAAM;AACd,2BAAU;AAAA,oBACT,IAAI,SAAS;AAAA,oBACb,KAAK,SAAS;AAAA,kBACf,CAAE;AAAA,gBACH;AAAA,cACD;AAAA,YACD;AAAA,UACD,CAAE;AAAA,QACH;AAAA,MACD;AAAA,MACA,aAAc,CAAE;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,MACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,WAAY;AAAA,UAEZ;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,OAAQ,GAAI,YAAa;AAAA,cACzB,MAAK;AAAA,cACL,eAAgB;AAAA,cAChB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cAEE;AAAA;AAAA,gBACF;AAAA,kBAAC;AAAA;AAAA,oBACA,WAAY,iCAAkC,YAAa;AAAA,oBAC3D,MAAK;AAAA,oBACL,cAAa,GAAI,gBAAiB;AAAA,oBAEhC;AAAA;AAAA,gBACH;AAAA;AAAA;AAAA,UACD;AAAA;AAAA,MACD;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,6BAAQ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,68 @@
1
+ // packages/media-editor/src/components/media-editor-transform-controls/index.tsx
2
+ import { Button } from "@wordpress/components";
3
+ import { __ } from "@wordpress/i18n";
4
+ import {
5
+ rotateLeft,
6
+ rotateRight,
7
+ flipHorizontal,
8
+ flipVertical
9
+ } from "@wordpress/icons";
10
+ import { useMediaEditor } from "../../state/index.mjs";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ function MediaEditorTransformControls() {
13
+ const { state, setFlip, snapRotate90 } = useMediaEditor();
14
+ return /* @__PURE__ */ jsxs("div", { className: "media-editor-transform-controls", children: [
15
+ /* @__PURE__ */ jsx(
16
+ Button,
17
+ {
18
+ size: "compact",
19
+ icon: rotateLeft,
20
+ label: __("Rotate 90\xB0 counter-clockwise"),
21
+ showTooltip: true,
22
+ onClick: () => snapRotate90(-1)
23
+ }
24
+ ),
25
+ /* @__PURE__ */ jsx(
26
+ Button,
27
+ {
28
+ size: "compact",
29
+ icon: rotateRight,
30
+ label: __("Rotate 90\xB0 clockwise"),
31
+ showTooltip: true,
32
+ onClick: () => snapRotate90(1)
33
+ }
34
+ ),
35
+ /* @__PURE__ */ jsx(
36
+ Button,
37
+ {
38
+ size: "compact",
39
+ icon: flipHorizontal,
40
+ label: __("Flip horizontal"),
41
+ showTooltip: true,
42
+ isPressed: state.flip.horizontal,
43
+ onClick: () => setFlip({
44
+ horizontal: !state.flip.horizontal,
45
+ vertical: state.flip.vertical
46
+ })
47
+ }
48
+ ),
49
+ /* @__PURE__ */ jsx(
50
+ Button,
51
+ {
52
+ size: "compact",
53
+ icon: flipVertical,
54
+ label: __("Flip vertical"),
55
+ showTooltip: true,
56
+ isPressed: state.flip.vertical,
57
+ onClick: () => setFlip({
58
+ horizontal: state.flip.horizontal,
59
+ vertical: !state.flip.vertical
60
+ })
61
+ }
62
+ )
63
+ ] });
64
+ }
65
+ export {
66
+ MediaEditorTransformControls as default
67
+ };
68
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/media-editor-transform-controls/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\trotateLeft,\n\trotateRight,\n\tflipHorizontal,\n\tflipVertical,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../../state';\n\n/**\n * Snap-rotate and flip controls for the media-editor footer. Rotation and\n * reflection are both geometric transforms, hence \"transform controls\".\n * Lives separately from the fine-rotation slider so the footer can place\n * the two halves on different rows at intermediate viewport widths.\n */\nexport default function MediaEditorTransformControls() {\n\tconst { state, setFlip, snapRotate90 } = useMediaEditor();\n\treturn (\n\t\t<div className=\"media-editor-transform-controls\">\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateLeft }\n\t\t\t\tlabel={ __( 'Rotate 90\u00B0 counter-clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tonClick={ () => snapRotate90( -1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateRight }\n\t\t\t\tlabel={ __( 'Rotate 90\u00B0 clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tonClick={ () => snapRotate90( 1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipHorizontal }\n\t\t\t\tlabel={ __( 'Flip horizontal' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.horizontal }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: ! state.flip.horizontal,\n\t\t\t\t\t\tvertical: state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipVertical }\n\t\t\t\tlabel={ __( 'Flip vertical' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.vertical }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: state.flip.horizontal,\n\t\t\t\t\t\tvertical: ! state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,sBAAsB;AAW7B,SACC,KADD;AAHa,SAAR,+BAAgD;AACtD,QAAM,EAAE,OAAO,SAAS,aAAa,IAAI,eAAe;AACxD,SACC,qBAAC,SAAI,WAAU,mCACd;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,OAAQ,GAAI,iCAA+B;AAAA,QAC3C,aAAW;AAAA,QACX,SAAU,MAAM,aAAc,EAAG;AAAA;AAAA,IAClC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,OAAQ,GAAI,yBAAuB;AAAA,QACnC,aAAW;AAAA,QACX,SAAU,MAAM,aAAc,CAAE;AAAA;AAAA,IACjC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,OAAQ,GAAI,iBAAkB;AAAA,QAC9B,aAAW;AAAA,QACX,WAAY,MAAM,KAAK;AAAA,QACvB,SAAU,MACT,QAAS;AAAA,UACR,YAAY,CAAE,MAAM,KAAK;AAAA,UACzB,UAAU,MAAM,KAAK;AAAA,QACtB,CAAE;AAAA;AAAA,IAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,OAAQ,GAAI,eAAgB;AAAA,QAC5B,aAAW;AAAA,QACX,WAAY,MAAM,KAAK;AAAA,QACvB,SAAU,MACT,QAAS;AAAA,UACR,YAAY,MAAM,KAAK;AAAA,UACvB,UAAU,CAAE,MAAM,KAAK;AAAA,QACxB,CAAE;AAAA;AAAA,IAEJ;AAAA,KACD;AAEF;",
6
+ "names": []
7
+ }
@@ -3,13 +3,21 @@ import { DataForm } from "@wordpress/dataviews";
3
3
  import { Spinner, __experimentalVStack as VStack } from "@wordpress/components";
4
4
  import { VisuallyHidden } from "@wordpress/ui";
5
5
  import { __ } from "@wordpress/i18n";
6
+ import { useMemo } from "@wordpress/element";
6
7
  import { useMediaEditorContext } from "../media-editor-provider/index.mjs";
8
+ import SidebarDatetimeView from "./sidebar-datetime-view.mjs";
7
9
  import { jsx, jsxs } from "react/jsx-runtime";
8
10
  function MediaForm({
9
11
  form: formOverrides,
10
12
  header
11
13
  }) {
12
14
  const { media, fields, onChange } = useMediaEditorContext();
15
+ const formFields = useMemo(
16
+ () => fields.map(
17
+ (field) => field.type === "datetime" && field.readOnly ? { ...field, render: SidebarDatetimeView } : field
18
+ ),
19
+ [fields]
20
+ );
13
21
  if (!media || !onChange) {
14
22
  return /* @__PURE__ */ jsx("div", { className: "media-editor-form media-editor-form--loading", children: /* @__PURE__ */ jsx(Spinner, {}) });
15
23
  }
@@ -40,7 +48,7 @@ function MediaForm({
40
48
  DataForm,
41
49
  {
42
50
  data: media,
43
- fields,
51
+ fields: formFields,
44
52
  form,
45
53
  onChange
46
54
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-form/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataForm } from '@wordpress/dataviews';\nimport type { Form, Field } from '@wordpress/dataviews';\nimport { Spinner, __experimentalVStack as VStack } from '@wordpress/components';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport type { Media } from '../media-editor-provider';\n\n/**\n * Props for MediaForm component.\n */\nexport interface MediaFormProps {\n\tform?: Form;\n\theader?: ReactNode;\n}\n\n/**\n * MediaForm component for editing media metadata.\n *\n * Renders a DataForm with fields for editing media properties like\n * title, alt text, caption, description, etc.\n *\n * @param props - Component props.\n * @param props.form - Optional form configuration.\n * @param props.header - Optional header content to display above the form.\n * @return The MediaForm component.\n */\nexport default function MediaForm( {\n\tform: formOverrides,\n\theader,\n}: MediaFormProps ) {\n\tconst { media, fields, onChange } = useMediaEditorContext();\n\n\tif ( ! media || ! onChange ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-form media-editor-form--loading\">\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Default form structure with panel layout\n\tconst defaultForm: Form = {\n\t\tlayout: {\n\t\t\ttype: 'panel',\n\t\t},\n\t\tfields: fields.map( ( field: Field< Media > ) => {\n\t\t\t// Use regular layout for main editable fields\n\t\t\tif (\n\t\t\t\t[ 'title', 'alt_text', 'caption', 'description' ].includes(\n\t\t\t\t\tfield.id\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\tid: field.id,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\ttype: 'regular',\n\t\t\t\t\t\tlabelPosition: 'top',\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn field.id;\n\t\t} ),\n\t};\n\n\tconst form = formOverrides || defaultForm;\n\n\treturn (\n\t\t<div className=\"media-editor-form\">\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t\t{ __( 'Media details' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t{ header }\n\t\t\t\t<DataForm\n\t\t\t\t\tdata={ media }\n\t\t\t\t\tfields={ fields }\n\t\t\t\t\tform={ form }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,gBAAgB;AAEzB,SAAS,SAAS,wBAAwB,cAAc;AACxD,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AAMnB,SAAS,6BAA6B;AA+BlC,cAiCD,YAjCC;AATW,SAAR,UAA4B;AAAA,EAClC,MAAM;AAAA,EACN;AACD,GAAoB;AACnB,QAAM,EAAE,OAAO,QAAQ,SAAS,IAAI,sBAAsB;AAE1D,MAAK,CAAE,SAAS,CAAE,UAAW;AAC5B,WACC,oBAAC,SAAI,WAAU,gDACd,8BAAC,WAAQ,GACV;AAAA,EAEF;AAGA,QAAM,cAAoB;AAAA,IACzB,QAAQ;AAAA,MACP,MAAM;AAAA,IACP;AAAA,IACA,QAAQ,OAAO,IAAK,CAAE,UAA2B;AAEhD,UACC,CAAE,SAAS,YAAY,WAAW,aAAc,EAAE;AAAA,QACjD,MAAM;AAAA,MACP,GACC;AACD,eAAO;AAAA,UACN,IAAI,MAAM;AAAA,UACV,QAAQ;AAAA,YACP,MAAM;AAAA,YACN,eAAe;AAAA,UAChB;AAAA,QACD;AAAA,MACD;AACA,aAAO,MAAM;AAAA,IACd,CAAE;AAAA,EACH;AAEA,QAAM,OAAO,iBAAiB;AAE9B,SACC,oBAAC,SAAI,WAAU,qBACd,+BAAC,UAAO,SAAU,GACjB;AAAA,wBAAC,kBAAe,QAAS,oBAAC,QAAG,GAC1B,aAAI,eAAgB,GACvB;AAAA,IACE;AAAA,IACF;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataForm } from '@wordpress/dataviews';\nimport type { Form, Field } from '@wordpress/dataviews';\nimport { Spinner, __experimentalVStack as VStack } from '@wordpress/components';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport type { Media } from '../media-editor-provider';\nimport SidebarDatetimeView from './sidebar-datetime-view';\n\n/**\n * Props for MediaForm component.\n */\nexport interface MediaFormProps {\n\tform?: Form;\n\theader?: ReactNode;\n}\n\n/**\n * MediaForm component for editing media metadata.\n *\n * Renders a DataForm with fields for editing media properties like\n * title, alt text, caption, description, etc.\n *\n * @param props - Component props.\n * @param props.form - Optional form configuration.\n * @param props.header - Optional header content to display above the form.\n * @return The MediaForm component.\n */\nexport default function MediaForm( {\n\tform: formOverrides,\n\theader,\n}: MediaFormProps ) {\n\tconst { media, fields, onChange } = useMediaEditorContext();\n\n\t// Render readonly datetime fields compactly in the sidebar: date only,\n\t// with the full datetime exposed on hover via Tooltip and `title`.\n\tconst formFields = useMemo(\n\t\t() =>\n\t\t\tfields.map( ( field: Field< Media > ) =>\n\t\t\t\tfield.type === 'datetime' && field.readOnly\n\t\t\t\t\t? { ...field, render: SidebarDatetimeView }\n\t\t\t\t\t: field\n\t\t\t),\n\t\t[ fields ]\n\t);\n\n\tif ( ! media || ! onChange ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-form media-editor-form--loading\">\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Default form structure with panel layout\n\tconst defaultForm: Form = {\n\t\tlayout: {\n\t\t\ttype: 'panel',\n\t\t},\n\t\tfields: fields.map( ( field: Field< Media > ) => {\n\t\t\t// Use regular layout for main editable fields\n\t\t\tif (\n\t\t\t\t[ 'title', 'alt_text', 'caption', 'description' ].includes(\n\t\t\t\t\tfield.id\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\tid: field.id,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\ttype: 'regular',\n\t\t\t\t\t\tlabelPosition: 'top',\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn field.id;\n\t\t} ),\n\t};\n\n\tconst form = formOverrides || defaultForm;\n\n\treturn (\n\t\t<div className=\"media-editor-form\">\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t\t{ __( 'Media details' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t{ header }\n\t\t\t\t<DataForm\n\t\t\t\t\tdata={ media }\n\t\t\t\t\tfields={ formFields }\n\t\t\t\t\tform={ form }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,gBAAgB;AAEzB,SAAS,SAAS,wBAAwB,cAAc;AACxD,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AACnB,SAAS,eAAe;AAMxB,SAAS,6BAA6B;AAEtC,OAAO,yBAAyB;AA0C5B,cAiCD,YAjCC;AArBW,SAAR,UAA4B;AAAA,EAClC,MAAM;AAAA,EACN;AACD,GAAoB;AACnB,QAAM,EAAE,OAAO,QAAQ,SAAS,IAAI,sBAAsB;AAI1D,QAAM,aAAa;AAAA,IAClB,MACC,OAAO;AAAA,MAAK,CAAE,UACb,MAAM,SAAS,cAAc,MAAM,WAChC,EAAE,GAAG,OAAO,QAAQ,oBAAoB,IACxC;AAAA,IACJ;AAAA,IACD,CAAE,MAAO;AAAA,EACV;AAEA,MAAK,CAAE,SAAS,CAAE,UAAW;AAC5B,WACC,oBAAC,SAAI,WAAU,gDACd,8BAAC,WAAQ,GACV;AAAA,EAEF;AAGA,QAAM,cAAoB;AAAA,IACzB,QAAQ;AAAA,MACP,MAAM;AAAA,IACP;AAAA,IACA,QAAQ,OAAO,IAAK,CAAE,UAA2B;AAEhD,UACC,CAAE,SAAS,YAAY,WAAW,aAAc,EAAE;AAAA,QACjD,MAAM;AAAA,MACP,GACC;AACD,eAAO;AAAA,UACN,IAAI,MAAM;AAAA,UACV,QAAQ;AAAA,YACP,MAAM;AAAA,YACN,eAAe;AAAA,UAChB;AAAA,QACD;AAAA,MACD;AACA,aAAO,MAAM;AAAA,IACd,CAAE;AAAA,EACH;AAEA,QAAM,OAAO,iBAAiB;AAE9B,SACC,oBAAC,SAAI,WAAU,qBACd,+BAAC,UAAO,SAAU,GACjB;AAAA,wBAAC,kBAAe,QAAS,oBAAC,QAAG,GAC1B,aAAI,eAAgB,GACvB;AAAA,IACE;AAAA,IACF;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP,QAAS;AAAA,QACT;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,32 @@
1
+ // packages/media-editor/src/components/media-form/sidebar-datetime-view.tsx
2
+ import { dateI18n, getDate, getSettings } from "@wordpress/date";
3
+ import { Tooltip as WCTooltip } from "@wordpress/components";
4
+ import { jsx } from "react/jsx-runtime";
5
+ function SidebarDatetimeView({
6
+ item,
7
+ field
8
+ }) {
9
+ const value = field.getValue({ item });
10
+ if (!value) {
11
+ return null;
12
+ }
13
+ const settings = getSettings();
14
+ const dateOnly = dateI18n(settings.formats.date, getDate(value));
15
+ const fullDatetime = dateI18n(
16
+ settings.formats.datetimeAbbreviated,
17
+ getDate(value)
18
+ );
19
+ return /* @__PURE__ */ jsx(WCTooltip, { text: fullDatetime, placement: "top", children: /* @__PURE__ */ jsx(
20
+ "time",
21
+ {
22
+ dateTime: value,
23
+ "aria-label": fullDatetime,
24
+ tabIndex: -1,
25
+ children: dateOnly
26
+ }
27
+ ) });
28
+ }
29
+ export {
30
+ SidebarDatetimeView as default
31
+ };
32
+ //# sourceMappingURL=sidebar-datetime-view.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/media-form/sidebar-datetime-view.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { dateI18n, getDate, getSettings } from '@wordpress/date';\nimport { Tooltip as WCTooltip } from '@wordpress/components';\nimport type { NormalizedField } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Media } from '../media-editor-provider';\n\nexport default function SidebarDatetimeView( {\n\titem,\n\tfield,\n}: {\n\titem: Media;\n\tfield: NormalizedField< Media >;\n} ) {\n\tconst value = field.getValue( { item } ) as string | null | undefined;\n\tif ( ! value ) {\n\t\treturn null;\n\t}\n\tconst settings = getSettings();\n\tconst dateOnly = dateI18n( settings.formats.date, getDate( value ) );\n\tconst fullDatetime = dateI18n(\n\t\tsettings.formats.datetimeAbbreviated,\n\t\tgetDate( value )\n\t);\n\t// `aria-label` makes assistive tech announce the full date (the visible\n\t// text is a shortened summary; `<time dateTime>` is for machines, not\n\t// announced by screen readers). `tabIndex={-1}` keeps the Tooltip anchor\n\t// out of the keyboard tab order \u2014 Ariakit's `useFocusable` preserves an\n\t// explicit `tabIndex` on non-natively-focusable elements rather than\n\t// defaulting it to `0`. The Tooltip remains available on mouse hover.\n\treturn (\n\t\t<WCTooltip text={ fullDatetime } placement=\"top\">\n\t\t\t<time\n\t\t\t\tdateTime={ value }\n\t\t\t\taria-label={ fullDatetime }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t>\n\t\t\t\t{ dateOnly }\n\t\t\t</time>\n\t\t</WCTooltip>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU,SAAS,mBAAmB;AAC/C,SAAS,WAAW,iBAAiB;AAiClC;AAzBY,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AACD,GAGI;AACH,QAAM,QAAQ,MAAM,SAAU,EAAE,KAAK,CAAE;AACvC,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AACA,QAAM,WAAW,YAAY;AAC7B,QAAM,WAAW,SAAU,SAAS,QAAQ,MAAM,QAAS,KAAM,CAAE;AACnE,QAAM,eAAe;AAAA,IACpB,SAAS,QAAQ;AAAA,IACjB,QAAS,KAAM;AAAA,EAChB;AAOA,SACC,oBAAC,aAAU,MAAO,cAAe,WAAU,OAC1C;AAAA,IAAC;AAAA;AAAA,MACA,UAAW;AAAA,MACX,cAAa;AAAA,MACb,UAAW;AAAA,MAET;AAAA;AAAA,EACH,GACD;AAEF;",
6
+ "names": []
7
+ }