@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
@@ -20,104 +20,90 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // packages/media-editor/src/components/media-editor-crop-panel/index.tsx
21
21
  var media_editor_crop_panel_exports = {};
22
22
  __export(media_editor_crop_panel_exports, {
23
- default: () => MediaEditorCropPanel,
24
- resolveAspectRatio: () => resolveAspectRatio
23
+ default: () => MediaEditorCropPanel
25
24
  });
26
25
  module.exports = __toCommonJS(media_editor_crop_panel_exports);
27
26
  var import_components = require("@wordpress/components");
28
27
  var import_ui = require("@wordpress/ui");
29
28
  var import_i18n = require("@wordpress/i18n");
30
- var import_image_editor = require("../../image-editor/index.cjs");
29
+ var import_state = require("../../state/index.cjs");
31
30
  var import_use_crop_gesture_handlers = require("../../hooks/use-crop-gesture-handlers.cjs");
32
31
  var import_constants = require("../../image-editor/core/constants.cjs");
33
- var import_jsx_runtime = require("react/jsx-runtime");
34
- function resolveAspectRatio(value, imageAspectRatio) {
35
- const num = parseFloat(value);
36
- if (num === 0) {
37
- return void 0;
38
- }
39
- if (num === import_constants.ORIGINAL_ASPECT_RATIO && imageAspectRatio) {
40
- return imageAspectRatio;
41
- }
42
- if (num > 0) {
43
- return num;
44
- }
45
- return void 0;
32
+ var import_containment = require("../../image-editor/core/containment.cjs");
33
+ var import_jsx_runtime = (
34
+ // Tag the whole panel as a crop-control region so the modal's
35
+ // Cmd+Z handler doesn't mistake the SelectControl input for a
36
+ // metadata field (which would suppress undo).
37
+ require("react/jsx-runtime")
38
+ );
39
+ var ZOOM_PERCENTAGE_SCALE = 100;
40
+ var MAX_ZOOM_PERCENTAGE = import_constants.MAX_ZOOM * ZOOM_PERCENTAGE_SCALE;
41
+ function getZoomPercentageForDisplay(zoom) {
42
+ return Math.round(zoom * ZOOM_PERCENTAGE_SCALE);
43
+ }
44
+ function getMinZoomPercentageForDisplay(zoom) {
45
+ return Math.ceil(zoom * ZOOM_PERCENTAGE_SCALE);
46
46
  }
47
47
  function MediaEditorCropPanel({
48
48
  aspectRatioValue,
49
49
  onAspectRatioChange,
50
- freeformCrop,
51
- onFreeformChange,
52
50
  onPlacementControlInteraction,
53
- aspectRatioPresets
51
+ aspectRatioOptions
54
52
  }) {
55
- const { state, setZoom } = (0, import_image_editor.useCropper)();
53
+ const { state, setZoom } = (0, import_state.useMediaEditor)();
56
54
  const zoomGestureHandlers = (0, import_use_crop_gesture_handlers.useCropGestureHandlers)();
57
- const aspectRatioOptions = [
58
- ...import_constants.DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value <= 0),
59
- ...aspectRatioPresets ?? import_constants.DEFAULT_ASPECT_RATIOS.filter((preset) => preset.value > 0)
60
- ];
61
- const handleAspectRatioChange = (value) => {
62
- onAspectRatioChange(value);
63
- if (value === "0" && !freeformCrop) {
64
- onFreeformChange(true);
55
+ const minZoom = (0, import_containment.getMinZoom)(state);
56
+ const zoomPercentage = getZoomPercentageForDisplay(state.zoom);
57
+ const minZoomPercentage = getMinZoomPercentageForDisplay(minZoom);
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
59
+ import_ui.Stack,
60
+ {
61
+ direction: "column",
62
+ gap: "xl",
63
+ ...{ [import_use_crop_gesture_handlers.CROP_CONTROL_ATTR]: true },
64
+ children: [
65
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {}), children: (0, import_i18n.__)("Crop options") }),
66
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
+ import_components.SelectControl,
68
+ {
69
+ __next40pxDefaultSize: true,
70
+ label: (0, import_i18n.__)("Aspect ratio"),
71
+ value: aspectRatioValue,
72
+ onChange: onAspectRatioChange,
73
+ options: aspectRatioOptions.map((preset) => ({
74
+ label: preset.label,
75
+ value: preset.value.toString()
76
+ }))
77
+ }
78
+ ),
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "presentation", ...zoomGestureHandlers, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
+ import_components.RangeControl,
81
+ {
82
+ __next40pxDefaultSize: true,
83
+ label: (0, import_i18n.__)("Zoom (%)"),
84
+ min: minZoomPercentage,
85
+ max: MAX_ZOOM_PERCENTAGE,
86
+ step: 1,
87
+ shiftStep: 10,
88
+ value: zoomPercentage,
89
+ onChange: (value) => {
90
+ onPlacementControlInteraction?.();
91
+ setZoom(
92
+ typeof value === "number" ? value / ZOOM_PERCENTAGE_SCALE : minZoom
93
+ );
94
+ },
95
+ renderTooltipContent: (value) => {
96
+ const percentage = typeof value === "number" ? value : minZoomPercentage;
97
+ return (0, import_i18n.sprintf)(
98
+ /* translators: %d: zoom level as a percentage. */
99
+ (0, import_i18n.__)("%d%%"),
100
+ Math.round(percentage)
101
+ );
102
+ }
103
+ }
104
+ ) })
105
+ ]
65
106
  }
66
- };
67
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "column", gap: "md", children: [
68
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {}), children: (0, import_i18n.__)("Crop options") }),
69
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
- import_components.SelectControl,
71
- {
72
- __next40pxDefaultSize: true,
73
- __nextHasNoMarginBottom: true,
74
- label: (0, import_i18n.__)("Aspect ratio"),
75
- value: aspectRatioValue,
76
- onChange: handleAspectRatioChange,
77
- options: aspectRatioOptions.map((preset) => ({
78
- label: preset.label,
79
- value: preset.value.toString()
80
- }))
81
- }
82
- ),
83
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
84
- import_components.ToggleControl,
85
- {
86
- __nextHasNoMarginBottom: true,
87
- label: (0, import_i18n.__)("Resize crop area"),
88
- help: (0, import_i18n.__)("Show handles to adjust the crop box."),
89
- checked: freeformCrop,
90
- onChange: onFreeformChange
91
- }
92
- ),
93
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "presentation", ...zoomGestureHandlers, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
- import_components.RangeControl,
95
- {
96
- __next40pxDefaultSize: true,
97
- __nextHasNoMarginBottom: true,
98
- label: (0, import_i18n.__)("Zoom"),
99
- min: import_constants.MIN_ZOOM,
100
- max: import_constants.MAX_ZOOM,
101
- step: 0.1,
102
- value: state.zoom,
103
- onChange: (value) => {
104
- onPlacementControlInteraction?.();
105
- setZoom(typeof value === "number" ? value : import_constants.MIN_ZOOM);
106
- },
107
- renderTooltipContent: (value) => {
108
- const zoom = typeof value === "number" ? value : import_constants.MIN_ZOOM;
109
- return (0, import_i18n.sprintf)(
110
- /* translators: %d: zoom level as a percentage. */
111
- (0, import_i18n.__)("%d%%"),
112
- Math.round(zoom * 100)
113
- );
114
- }
115
- }
116
- ) })
117
- ] });
107
+ );
118
108
  }
119
- // Annotate the CommonJS export names for ESM import in node:
120
- 0 && (module.exports = {
121
- resolveAspectRatio
122
- });
123
109
  //# sourceMappingURL=index.cjs.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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,gBAAsC;AACtC,kBAA4B;AAK5B,0BAA2B;AAC3B,uCAAuC;AACvC,uBAKO;AAqFL;AApDK,SAAS,mBACf,OACA,kBACqB;AACrB,QAAM,MAAM,WAAY,KAAM;AAC9B,MAAK,QAAQ,GAAI;AAChB,WAAO;AAAA,EACR;AACA,MAAK,QAAQ,0CAAyB,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,QAAI,gCAAW;AACtC,QAAM,0BAAsB,yDAAuB;AACnD,QAAM,qBAAqB;AAAA,IAC1B,GAAG,uCAAsB,OAAQ,CAAE,WAAY,OAAO,SAAS,CAAE;AAAA,IACjE,GAAK,sBACJ,uCAAsB,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,6CAAC,mBAAM,WAAU,UAAS,KAAI,MAC7B;AAAA,gDAAC,4BAAe,QAAS,4CAAC,QAAG,GAC1B,8BAAI,cAAe,GACtB;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,yBAAuB;AAAA,QACvB,WAAQ,gBAAI,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,WAAQ,gBAAI,kBAAmB;AAAA,QAC/B,UAAO,gBAAI,sCAAuC;AAAA,QAClD,SAAU;AAAA,QACV,UAAW;AAAA;AAAA,IACZ;AAAA,IACA,4CAAC,SAAI,MAAK,gBAAiB,GAAG,qBAC7B;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,yBAAuB;AAAA,QACvB,WAAQ,gBAAI,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,yBAAS;AAAA,QACvD;AAAA,QACA,sBAAuB,CAAE,UAAW;AACnC,gBAAM,OACL,OAAO,UAAU,WAAW,QAAQ;AACrC,qBAAO;AAAA;AAAA,gBAEN,gBAAI,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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA4C;AAC5C,gBAAsC;AACtC,kBAA4B;AAK5B,mBAA+B;AAC/B,uCAGO;AACP,uBAAyB;AACzB,yBAA2B;AAsDzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAnDF,IAAM,wBAAwB;AAC9B,IAAM,sBAAsB,4BAAW;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,QAAI,6BAAe;AAC1C,QAAM,0BAAsB,yDAAuB;AACnD,QAAM,cAAU,+BAAY,KAAM;AAClC,QAAM,iBAAiB,4BAA6B,MAAM,IAAK;AAC/D,QAAM,oBAAoB,+BAAgC,OAAQ;AAElE,SAIC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,KAAI;AAAA,MACF,GAAG,EAAE,CAAE,kDAAkB,GAAG,KAAK;AAAA,MAEnC;AAAA,oDAAC,4BAAe,QAAS,4CAAC,QAAG,GAC1B,8BAAI,cAAe,GACtB;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,uBAAqB;AAAA,YACrB,WAAQ,gBAAI,cAAe;AAAA,YAC3B,OAAQ;AAAA,YACR,UAAW;AAAA,YACX,SAAU,mBAAmB,IAAK,CAAE,YAAc;AAAA,cACjD,OAAO,OAAO;AAAA,cACd,OAAO,OAAO,MAAM,SAAS;AAAA,YAC9B,EAAI;AAAA;AAAA,QACL;AAAA,QACA,4CAAC,SAAI,MAAK,gBAAiB,GAAG,qBAC7B;AAAA,UAAC;AAAA;AAAA,YACA,uBAAqB;AAAA,YACrB,WAAQ,gBAAI,UAAW;AAAA,YACvB,KAAM;AAAA,YACN,KAAM;AAAA,YACN,MAAO;AAAA,YACP,WAAY;AAAA,YACZ,OAAQ;AAAA,YACR,UAAW,CAAE,UAAW;AACvB,8CAAgC;AAChC;AAAA,gBACC,OAAO,UAAU,WACd,QAAQ,wBACR;AAAA,cACJ;AAAA,YACD;AAAA,YACA,sBAAuB,CAAE,UAAW;AACnC,oBAAM,aACL,OAAO,UAAU,WACd,QACA;AACJ,yBAAO;AAAA;AAAA,oBAEN,gBAAI,MAAO;AAAA,gBACX,KAAK,MAAO,UAAW;AAAA,cACxB;AAAA,YACD;AAAA;AAAA,QACD,GACD;AAAA;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/media-editor/src/components/media-editor-fine-rotation/index.tsx
31
+ var media_editor_fine_rotation_exports = {};
32
+ __export(media_editor_fine_rotation_exports, {
33
+ default: () => MediaEditorFineRotation
34
+ });
35
+ module.exports = __toCommonJS(media_editor_fine_rotation_exports);
36
+ var import_i18n = require("@wordpress/i18n");
37
+ var import_state = require("../../state/index.cjs");
38
+ var import_use_crop_gesture_handlers = require("../../hooks/use-crop-gesture-handlers.cjs");
39
+ var import_constants = require("../../image-editor/core/constants.cjs");
40
+ var import_rotation_ruler = __toESM(require("../rotation-ruler/index.cjs"));
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ function MediaEditorFineRotation({
43
+ onPlacementControlInteraction
44
+ }) {
45
+ const { state, setRotation } = (0, import_state.useMediaEditor)();
46
+ const rotationGestureHandlers = (0, import_use_crop_gesture_handlers.useCropGestureHandlers)({
47
+ commitOnKeyUp: false
48
+ });
49
+ const baseAngle = Math.round(state.rotation / 90) * 90;
50
+ const singleFlip = state.flip.horizontal !== state.flip.vertical;
51
+ const visualDir = singleFlip ? -1 : 1;
52
+ const fineOffset = (state.rotation - baseAngle) * visualDir;
53
+ const handleRotationSlider = (value) => {
54
+ const EPS = 0.01;
55
+ const clamped = Math.max(
56
+ -import_constants.MAX_ROTATION_OFFSET + EPS,
57
+ Math.min(import_constants.MAX_ROTATION_OFFSET - EPS, value)
58
+ );
59
+ onPlacementControlInteraction?.();
60
+ setRotation(baseAngle + clamped * visualDir);
61
+ };
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
+ "div",
64
+ {
65
+ role: "presentation",
66
+ className: "media-editor-fine-rotation",
67
+ ...rotationGestureHandlers,
68
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ import_rotation_ruler.default,
70
+ {
71
+ label: (0, import_i18n.__)("Fine rotation"),
72
+ min: -import_constants.MAX_ROTATION_OFFSET,
73
+ max: import_constants.MAX_ROTATION_OFFSET,
74
+ value: fineOffset,
75
+ onChange: handleRotationSlider
76
+ }
77
+ )
78
+ }
79
+ );
80
+ }
81
+ //# sourceMappingURL=index.cjs.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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,mBAA+B;AAC/B,uCAAuC;AACvC,uBAAoC;AACpC,4BAA0B;AAqDvB;AAtCY,SAAR,wBAA0C;AAAA,EAChD;AACD,GAAkC;AACjC,QAAM,EAAE,OAAO,YAAY,QAAI,6BAAe;AAI9C,QAAM,8BAA0B,yDAAwB;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,uCAAsB;AAAA,MACvB,KAAK,IAAK,uCAAsB,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,sBAAAA;AAAA,QAAA;AAAA,UACA,WAAQ,gBAAI,eAAgB;AAAA,UAC5B,KAAM,CAAC;AAAA,UACP,KAAM;AAAA,UACN,OAAQ;AAAA,UACR,UAAW;AAAA;AAAA,MACZ;AAAA;AAAA,EACD;AAEF;",
6
+ "names": ["RotationRuler"]
7
+ }
@@ -37,6 +37,8 @@ module.exports = __toCommonJS(media_editor_modal_exports);
37
37
  var import_components = require("@wordpress/components");
38
38
  var import_data = require("@wordpress/data");
39
39
  var import_i18n = require("@wordpress/i18n");
40
+ var import_keyboard_shortcuts = require("@wordpress/keyboard-shortcuts");
41
+ var import_notices = require("@wordpress/notices");
40
42
  var import_media_editor = __toESM(require("../media-editor/index.cjs"));
41
43
  var import_store = require("../../store/index.cjs");
42
44
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -44,19 +46,28 @@ function MediaEditorModal({
44
46
  fields = [],
45
47
  aspectRatioPresets
46
48
  }) {
47
- const { isModalOpen, id, onUpdate } = (0, import_data.useSelect)((select) => {
48
- const { isOpen, getId, getOnUpdate } = select(import_store.store);
49
+ const { isModalOpen, id, onUpdate, onClose } = (0, import_data.useSelect)((select) => {
50
+ const { isOpen, getId, getOnUpdate, getOnClose } = select(import_store.store);
49
51
  return {
50
52
  isModalOpen: isOpen(),
51
53
  id: getId(),
52
- onUpdate: getOnUpdate()
54
+ onUpdate: getOnUpdate(),
55
+ onClose: getOnClose()
53
56
  };
54
57
  }, []);
55
58
  const { closeMediaEditorModal } = (0, import_data.useDispatch)(import_store.store);
59
+ const { createSuccessNotice } = (0, import_data.useDispatch)(import_notices.store);
56
60
  if (!isModalOpen || !id) {
57
61
  return null;
58
62
  }
59
63
  const portalElement = typeof document === "undefined" ? null : document.body;
64
+ const stopKeyDownPropagation = (event) => {
65
+ event.stopPropagation();
66
+ };
67
+ const handleClose = () => {
68
+ closeMediaEditorModal();
69
+ onClose?.();
70
+ };
60
71
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
61
72
  import_media_editor.default,
62
73
  {
@@ -67,8 +78,8 @@ function MediaEditorModal({
67
78
  shouldCloseOnEsc: true,
68
79
  noticesClassName: "media-editor-modal__snackbar",
69
80
  noticesPortalElement: portalElement,
70
- onClose: closeMediaEditorModal,
71
- onSaved: ({ id: savedId, url }) => {
81
+ onClose: handleClose,
82
+ onSaved: ({ id: savedId, url, previous }) => {
72
83
  if (savedId && onUpdate) {
73
84
  const update = {
74
85
  id: savedId,
@@ -76,26 +87,62 @@ function MediaEditorModal({
76
87
  };
77
88
  onUpdate(update);
78
89
  }
79
- closeMediaEditorModal();
90
+ handleClose();
91
+ if (previous && savedId !== previous.id && onUpdate) {
92
+ createSuccessNotice((0, import_i18n.__)("Image edited."), {
93
+ type: "snackbar",
94
+ actions: [
95
+ {
96
+ label: (0, import_i18n.__)("Undo"),
97
+ onClick: () => {
98
+ onUpdate({
99
+ id: previous.id,
100
+ url: previous.url
101
+ });
102
+ }
103
+ }
104
+ ]
105
+ });
106
+ }
80
107
  },
81
108
  renderFrame: ({
82
109
  children,
83
110
  headerActions,
111
+ footerActions,
112
+ footerLayout,
84
113
  onRequestClose,
85
114
  onKeyDown,
86
115
  shouldCloseOnClickOutside
87
116
  }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
- import_components.Modal,
117
+ import_keyboard_shortcuts.ShortcutProvider,
89
118
  {
90
- className: "media-editor-modal",
91
- title: (0, import_i18n.__)("Edit media"),
92
- size: "fill",
93
- isDismissible: false,
94
- shouldCloseOnClickOutside,
95
- onKeyDown,
96
- onRequestClose,
97
- headerActions,
98
- children
119
+ className: "media-editor-modal__shortcut-scope",
120
+ onKeyDown: stopKeyDownPropagation,
121
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
122
+ import_components.Modal,
123
+ {
124
+ className: "media-editor-modal",
125
+ title: (0, import_i18n.__)("Edit media"),
126
+ size: "fill",
127
+ isDismissible: false,
128
+ shouldCloseOnClickOutside,
129
+ onKeyDown,
130
+ onRequestClose,
131
+ headerActions,
132
+ children: [
133
+ children,
134
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
135
+ "div",
136
+ {
137
+ className: `media-editor-modal__footer is-${footerLayout}`,
138
+ role: "region",
139
+ "aria-label": (0, import_i18n.__)("Editor actions"),
140
+ children: footerActions
141
+ }
142
+ )
143
+ ]
144
+ }
145
+ )
99
146
  }
100
147
  )
101
148
  }
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAsB;AACtB,kBAAuC;AACvC,kBAAmB;AAMnB,0BAAwB;AAExB,mBAA0C;AAoEtC;AAjDG,SAAS,iBAAkB;AAAA,EACjC,SAAS,CAAC;AAAA,EACV;AACD,GAA2B;AAC1B,QAAM,EAAE,aAAa,IAAI,SAAS,QAAI,uBAAW,CAAE,WAAY;AAC9D,UAAM,EAAE,QAAQ,OAAO,YAAY,IAAI,OAAQ,aAAAA,KAAiB;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,QAAI,yBAAa,aAAAA,KAAiB;AAEhE,MAAK,CAAE,eAAe,CAAE,IAAK;AAC5B,WAAO;AAAA,EACR;AAEA,QAAM,gBACL,OAAO,aAAa,cAAc,OAAO,SAAS;AAEnD,SACC;AAAA,IAAC,oBAAAC;AAAA,IAAA;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,WAAQ,gBAAI,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;",
6
- "names": ["mediaEditorStore", "MediaEditor"]
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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAsB;AACtB,kBAAuC;AACvC,kBAAmB;AACnB,gCAAiC;AACjC,qBAAsC;AAOtC,0BAAwB;AAExB,mBAA0C;AA+GrC;AA5FE,SAAS,iBAAkB;AAAA,EACjC,SAAS,CAAC;AAAA,EACV;AACD,GAA2B;AAC1B,QAAM,EAAE,aAAa,IAAI,UAAU,QAAQ,QAAI,uBAAW,CAAE,WAAY;AACvE,UAAM,EAAE,QAAQ,OAAO,aAAa,WAAW,IAC9C,OAAQ,aAAAA,KAAiB;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,QAAI,yBAAa,aAAAA,KAAiB;AAChE,QAAM,EAAE,oBAAoB,QAAI,yBAAa,eAAAC,KAAa;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,oBAAAC;AAAA,IAAA;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,kCAAqB,gBAAI,eAAgB,GAAG;AAAA,YAC3C,MAAM;AAAA,YACN,SAAS;AAAA,cACR;AAAA,gBACC,WAAO,gBAAI,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,WAAQ,gBAAI,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,kBAAa,gBAAI,gBAAiB;AAAA,oBAEhC;AAAA;AAAA,gBACH;AAAA;AAAA;AAAA,UACD;AAAA;AAAA,MACD;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,6BAAQ;",
6
+ "names": ["mediaEditorStore", "noticesStore", "MediaEditor"]
7
7
  }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/components/media-editor-transform-controls/index.tsx
21
+ var media_editor_transform_controls_exports = {};
22
+ __export(media_editor_transform_controls_exports, {
23
+ default: () => MediaEditorTransformControls
24
+ });
25
+ module.exports = __toCommonJS(media_editor_transform_controls_exports);
26
+ var import_components = require("@wordpress/components");
27
+ var import_i18n = require("@wordpress/i18n");
28
+ var import_icons = require("@wordpress/icons");
29
+ var import_state = require("../../state/index.cjs");
30
+ var import_jsx_runtime = require("react/jsx-runtime");
31
+ function MediaEditorTransformControls() {
32
+ const { state, setFlip, snapRotate90 } = (0, import_state.useMediaEditor)();
33
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-transform-controls", children: [
34
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
35
+ import_components.Button,
36
+ {
37
+ size: "compact",
38
+ icon: import_icons.rotateLeft,
39
+ label: (0, import_i18n.__)("Rotate 90\xB0 counter-clockwise"),
40
+ showTooltip: true,
41
+ onClick: () => snapRotate90(-1)
42
+ }
43
+ ),
44
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
45
+ import_components.Button,
46
+ {
47
+ size: "compact",
48
+ icon: import_icons.rotateRight,
49
+ label: (0, import_i18n.__)("Rotate 90\xB0 clockwise"),
50
+ showTooltip: true,
51
+ onClick: () => snapRotate90(1)
52
+ }
53
+ ),
54
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
55
+ import_components.Button,
56
+ {
57
+ size: "compact",
58
+ icon: import_icons.flipHorizontal,
59
+ label: (0, import_i18n.__)("Flip horizontal"),
60
+ showTooltip: true,
61
+ isPressed: state.flip.horizontal,
62
+ onClick: () => setFlip({
63
+ horizontal: !state.flip.horizontal,
64
+ vertical: state.flip.vertical
65
+ })
66
+ }
67
+ ),
68
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ import_components.Button,
70
+ {
71
+ size: "compact",
72
+ icon: import_icons.flipVertical,
73
+ label: (0, import_i18n.__)("Flip vertical"),
74
+ showTooltip: true,
75
+ isPressed: state.flip.vertical,
76
+ onClick: () => setFlip({
77
+ horizontal: state.flip.horizontal,
78
+ vertical: !state.flip.vertical
79
+ })
80
+ }
81
+ )
82
+ ] });
83
+ }
84
+ //# sourceMappingURL=index.cjs.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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAuB;AACvB,kBAAmB;AACnB,mBAKO;AAKP,mBAA+B;AAW7B;AAHa,SAAR,+BAAgD;AACtD,QAAM,EAAE,OAAO,SAAS,aAAa,QAAI,6BAAe;AACxD,SACC,6CAAC,SAAI,WAAU,mCACd;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,WAAQ,gBAAI,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,WAAQ,gBAAI,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,WAAQ,gBAAI,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,WAAQ,gBAAI,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
+ }
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // packages/media-editor/src/components/media-form/index.tsx
@@ -27,13 +37,21 @@ var import_dataviews = require("@wordpress/dataviews");
27
37
  var import_components = require("@wordpress/components");
28
38
  var import_ui = require("@wordpress/ui");
29
39
  var import_i18n = require("@wordpress/i18n");
40
+ var import_element = require("@wordpress/element");
30
41
  var import_media_editor_provider = require("../media-editor-provider/index.cjs");
42
+ var import_sidebar_datetime_view = __toESM(require("./sidebar-datetime-view.cjs"));
31
43
  var import_jsx_runtime = require("react/jsx-runtime");
32
44
  function MediaForm({
33
45
  form: formOverrides,
34
46
  header
35
47
  }) {
36
48
  const { media, fields, onChange } = (0, import_media_editor_provider.useMediaEditorContext)();
49
+ const formFields = (0, import_element.useMemo)(
50
+ () => fields.map(
51
+ (field) => field.type === "datetime" && field.readOnly ? { ...field, render: import_sidebar_datetime_view.default } : field
52
+ ),
53
+ [fields]
54
+ );
37
55
  if (!media || !onChange) {
38
56
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor-form media-editor-form--loading", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) });
39
57
  }
@@ -64,7 +82,7 @@ function MediaForm({
64
82
  import_dataviews.DataForm,
65
83
  {
66
84
  data: media,
67
- fields,
85
+ fields: formFields,
68
86
  form,
69
87
  onChange
70
88
  }