@wordpress/media-editor 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/media-editor/index.cjs +74 -21
  3. package/build/components/media-editor/index.cjs.map +1 -1
  4. package/build/components/media-editor/use-crop-options.cjs +4 -5
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -1
  6. package/build/components/media-editor/use-save-media-editor.cjs +23 -3
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  8. package/build/components/media-editor-canvas/index.cjs +6 -11
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  10. package/build/components/media-editor-crop-panel/index.cjs +17 -1
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  12. package/build/components/media-editor-fine-rotation/index.cjs +4 -5
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
  14. package/build/components/media-editor-image-controls/index.cjs +4 -6
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -1
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +1 -0
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  18. package/build/components/media-editor-modal/index.cjs.map +1 -1
  19. package/build/components/media-form/index.cjs +7 -1
  20. package/build/components/media-form/index.cjs.map +1 -1
  21. package/build/components/media-preview/index.cjs +0 -1
  22. package/build/components/media-preview/index.cjs.map +1 -1
  23. package/build/state/aspect-ratio-presets.cjs +10 -4
  24. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  25. package/build/state/composite-reducer.cjs +32 -67
  26. package/build/state/composite-reducer.cjs.map +1 -1
  27. package/build/state/index.cjs +0 -39
  28. package/build/state/types.cjs +1 -2
  29. package/build/state/types.cjs.map +1 -1
  30. package/build/state/use-media-editor-state.cjs +70 -106
  31. package/build/state/use-media-editor-state.cjs.map +1 -1
  32. package/build-module/components/media-editor/index.mjs +78 -25
  33. package/build-module/components/media-editor/index.mjs.map +1 -1
  34. package/build-module/components/media-editor/use-crop-options.mjs +4 -5
  35. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
  36. package/build-module/components/media-editor/use-save-media-editor.mjs +23 -3
  37. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  38. package/build-module/components/media-editor-canvas/index.mjs +8 -13
  39. package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
  40. package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
  41. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
  42. package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
  43. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
  44. package/build-module/components/media-editor-image-controls/index.mjs +5 -7
  45. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
  46. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +1 -0
  47. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  48. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  49. package/build-module/components/media-form/index.mjs +7 -1
  50. package/build-module/components/media-form/index.mjs.map +1 -1
  51. package/build-module/components/media-preview/index.mjs +0 -1
  52. package/build-module/components/media-preview/index.mjs.map +1 -1
  53. package/build-module/state/aspect-ratio-presets.mjs +10 -5
  54. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  55. package/build-module/state/composite-reducer.mjs +32 -67
  56. package/build-module/state/composite-reducer.mjs.map +1 -1
  57. package/build-module/state/index.mjs +2 -5
  58. package/build-module/state/types.mjs +1 -2
  59. package/build-module/state/types.mjs.map +1 -1
  60. package/build-module/state/use-media-editor-state.mjs +70 -105
  61. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  62. package/build-style/style-rtl.css +104 -57
  63. package/build-style/style.css +103 -57
  64. package/build-types/components/media-editor/index.d.ts +17 -3
  65. package/build-types/components/media-editor/index.d.ts.map +1 -1
  66. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  67. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  68. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  69. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  70. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  71. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  72. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  73. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  74. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  75. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  76. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  77. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  78. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  79. package/build-types/components/media-form/index.d.ts.map +1 -1
  80. package/build-types/components/media-preview/index.d.ts.map +1 -1
  81. package/build-types/state/aspect-ratio-presets.d.ts +20 -3
  82. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
  83. package/build-types/state/composite-reducer.d.ts +17 -19
  84. package/build-types/state/composite-reducer.d.ts.map +1 -1
  85. package/build-types/state/index.d.ts +2 -5
  86. package/build-types/state/index.d.ts.map +1 -1
  87. package/build-types/state/types.d.ts +20 -64
  88. package/build-types/state/types.d.ts.map +1 -1
  89. package/build-types/state/use-media-editor-state.d.ts +33 -52
  90. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  91. package/package.json +22 -23
  92. package/src/components/media-editor/index.tsx +163 -28
  93. package/src/components/media-editor/use-crop-options.ts +7 -11
  94. package/src/components/media-editor/use-save-media-editor.ts +48 -6
  95. package/src/components/media-editor-canvas/index.tsx +15 -26
  96. package/src/components/media-editor-canvas/style.scss +6 -6
  97. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  98. package/src/components/media-editor-crop-panel/style.scss +21 -0
  99. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  100. package/src/components/media-editor-image-controls/index.tsx +11 -9
  101. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  102. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  103. package/src/components/media-editor-modal/index.tsx +1 -1
  104. package/src/components/media-form/index.tsx +7 -1
  105. package/src/components/media-preview/index.tsx +0 -1
  106. package/src/components/rotation-ruler/style.scss +3 -3
  107. package/src/state/README.md +32 -0
  108. package/src/state/aspect-ratio-presets.ts +22 -3
  109. package/src/state/composite-reducer.ts +42 -80
  110. package/src/state/index.ts +2 -18
  111. package/src/state/types.ts +18 -68
  112. package/src/state/use-media-editor-state.ts +155 -240
  113. package/src/style.scss +2 -1
  114. package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
  115. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
  116. package/build/image-editor/core/camera.cjs +0 -277
  117. package/build/image-editor/core/camera.cjs.map +0 -1
  118. package/build/image-editor/core/constants.cjs +0 -133
  119. package/build/image-editor/core/constants.cjs.map +0 -1
  120. package/build/image-editor/core/containment.cjs +0 -289
  121. package/build/image-editor/core/containment.cjs.map +0 -1
  122. package/build/image-editor/core/crop-rect.cjs +0 -37
  123. package/build/image-editor/core/crop-rect.cjs.map +0 -1
  124. package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
  125. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
  126. package/build/image-editor/core/index.cjs +0 -89
  127. package/build/image-editor/core/interaction-controller.cjs +0 -591
  128. package/build/image-editor/core/interaction-controller.cjs.map +0 -1
  129. package/build/image-editor/core/math/rotation.cjs +0 -32
  130. package/build/image-editor/core/math/rotation.cjs.map +0 -1
  131. package/build/image-editor/core/math/sanitize.cjs +0 -136
  132. package/build/image-editor/core/math/sanitize.cjs.map +0 -1
  133. package/build/image-editor/core/setter-helpers.cjs +0 -61
  134. package/build/image-editor/core/setter-helpers.cjs.map +0 -1
  135. package/build/image-editor/core/source-region.cjs +0 -236
  136. package/build/image-editor/core/source-region.cjs.map +0 -1
  137. package/build/image-editor/core/state.cjs +0 -296
  138. package/build/image-editor/core/state.cjs.map +0 -1
  139. package/build/image-editor/core/stencil-math.cjs +0 -203
  140. package/build/image-editor/core/stencil-math.cjs.map +0 -1
  141. package/build/image-editor/core/transform-style.cjs +0 -43
  142. package/build/image-editor/core/transform-style.cjs.map +0 -1
  143. package/build/image-editor/core/transforms/pipeline.cjs +0 -41
  144. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
  145. package/build/image-editor/core/types.cjs +0 -5
  146. package/build/image-editor/core/viewport-state.cjs +0 -36
  147. package/build/image-editor/core/viewport-state.cjs.map +0 -1
  148. package/build/image-editor/index.cjs +0 -68
  149. package/build/image-editor/react/components/cropper-provider.cjs +0 -49
  150. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
  151. package/build/image-editor/react/components/cropper.cjs +0 -595
  152. package/build/image-editor/react/components/cropper.cjs.map +0 -1
  153. package/build/image-editor/react/components/index.cjs +0 -25
  154. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
  155. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
  156. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
  157. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
  158. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
  159. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
  160. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
  161. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
  162. package/build/image-editor/react/components/viewport-provider.cjs +0 -26
  163. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
  164. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
  165. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
  166. package/build/image-editor/react/hooks/index.cjs +0 -19
  167. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
  168. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
  169. package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
  170. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
  171. package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
  172. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
  173. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
  174. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
  175. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
  176. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
  177. package/build/image-editor/react/visually-hidden-style.cjs +0 -24
  178. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
  179. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
  180. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
  181. package/build-module/image-editor/core/camera.mjs +0 -265
  182. package/build-module/image-editor/core/camera.mjs.map +0 -1
  183. package/build-module/image-editor/core/constants.mjs +0 -115
  184. package/build-module/image-editor/core/constants.mjs.map +0 -1
  185. package/build-module/image-editor/core/containment.mjs +0 -281
  186. package/build-module/image-editor/core/containment.mjs.map +0 -1
  187. package/build-module/image-editor/core/crop-rect.mjs +0 -32
  188. package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
  189. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
  190. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
  191. package/build-module/image-editor/core/index.mjs +0 -7
  192. package/build-module/image-editor/core/interaction-controller.mjs +0 -586
  193. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
  194. package/build-module/image-editor/core/math/rotation.mjs +0 -26
  195. package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
  196. package/build-module/image-editor/core/math/sanitize.mjs +0 -127
  197. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
  198. package/build-module/image-editor/core/setter-helpers.mjs +0 -56
  199. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
  200. package/build-module/image-editor/core/source-region.mjs +0 -228
  201. package/build-module/image-editor/core/source-region.mjs.map +0 -1
  202. package/build-module/image-editor/core/state.mjs +0 -288
  203. package/build-module/image-editor/core/state.mjs.map +0 -1
  204. package/build-module/image-editor/core/stencil-math.mjs +0 -194
  205. package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
  206. package/build-module/image-editor/core/transform-style.mjs +0 -38
  207. package/build-module/image-editor/core/transform-style.mjs.map +0 -1
  208. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
  209. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
  210. package/build-module/image-editor/core/types.mjs +0 -0
  211. package/build-module/image-editor/core/viewport-state.mjs +0 -30
  212. package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
  213. package/build-module/image-editor/index.mjs +0 -4
  214. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
  215. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
  216. package/build-module/image-editor/react/components/cropper.mjs +0 -568
  217. package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
  218. package/build-module/image-editor/react/components/index.mjs +0 -3
  219. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
  220. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
  221. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
  222. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
  223. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
  224. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
  225. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
  226. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
  227. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
  228. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
  229. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
  230. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
  231. package/build-module/image-editor/react/hooks/index.mjs +0 -3
  232. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
  233. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
  234. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
  235. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
  236. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
  237. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
  238. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
  239. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
  240. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
  241. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
  242. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
  243. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
  244. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
  245. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  246. package/build-types/image-editor/core/camera.d.ts +0 -128
  247. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  248. package/build-types/image-editor/core/constants.d.ts +0 -98
  249. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  250. package/build-types/image-editor/core/containment.d.ts +0 -72
  251. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  252. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  253. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  254. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  255. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  256. package/build-types/image-editor/core/index.d.ts +0 -10
  257. package/build-types/image-editor/core/index.d.ts.map +0 -1
  258. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  259. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  260. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  261. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  262. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  263. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  264. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  265. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  266. package/build-types/image-editor/core/source-region.d.ts +0 -94
  267. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  268. package/build-types/image-editor/core/state.d.ts +0 -51
  269. package/build-types/image-editor/core/state.d.ts.map +0 -1
  270. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  271. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  272. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  273. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  274. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  275. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  276. package/build-types/image-editor/core/types.d.ts +0 -269
  277. package/build-types/image-editor/core/types.d.ts.map +0 -1
  278. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  279. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  280. package/build-types/image-editor/index.d.ts +0 -17
  281. package/build-types/image-editor/index.d.ts.map +0 -1
  282. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  283. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  284. package/build-types/image-editor/react/components/cropper.d.ts +0 -54
  285. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  286. package/build-types/image-editor/react/components/index.d.ts +0 -4
  287. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  288. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  289. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  290. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  291. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  292. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  293. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  294. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  295. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  296. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  297. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  298. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  299. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  300. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  301. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  302. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  303. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  304. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts +0 -55
  305. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +0 -1
  306. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  307. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  308. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  309. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  310. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  311. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  312. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  313. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  314. package/src/components/media-editor-modal/build-modifiers.ts +0 -167
  315. package/src/image-editor/README.md +0 -61
  316. package/src/image-editor/core/camera.ts +0 -429
  317. package/src/image-editor/core/constants.ts +0 -137
  318. package/src/image-editor/core/containment.ts +0 -469
  319. package/src/image-editor/core/crop-rect.ts +0 -42
  320. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  321. package/src/image-editor/core/index.ts +0 -43
  322. package/src/image-editor/core/interaction-controller.ts +0 -976
  323. package/src/image-editor/core/math/rotation.ts +0 -26
  324. package/src/image-editor/core/math/sanitize.ts +0 -155
  325. package/src/image-editor/core/setter-helpers.ts +0 -63
  326. package/src/image-editor/core/source-region.ts +0 -367
  327. package/src/image-editor/core/state.ts +0 -484
  328. package/src/image-editor/core/stencil-math.ts +0 -379
  329. package/src/image-editor/core/transform-style.ts +0 -56
  330. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  331. package/src/image-editor/core/types.ts +0 -230
  332. package/src/image-editor/core/viewport-state.ts +0 -30
  333. package/src/image-editor/docs/architecture.md +0 -63
  334. package/src/image-editor/docs/recipes.md +0 -184
  335. package/src/image-editor/index.ts +0 -43
  336. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  337. package/src/image-editor/react/components/cropper.scss +0 -259
  338. package/src/image-editor/react/components/cropper.tsx +0 -1108
  339. package/src/image-editor/react/components/index.ts +0 -3
  340. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  341. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  342. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  343. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  344. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  345. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  346. package/src/image-editor/react/hooks/index.ts +0 -4
  347. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  348. package/src/image-editor/react/hooks/use-cropper-controller.ts +0 -197
  349. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  350. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  351. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  352. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  353. package/src/image-editor/style.scss +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"cropper.cjs","names":["RectangleStencil","useViewport","useRef","useId","useState","useCallback","useMemo","getImageFit","computeInscribedRect","getImageCropBounds","getMinZoom","getViewScale","SETTLE_TARGET_CANVAS_FILL","MAX_VIEW_SCALE","PIXEL_SNAP_DISPLAY_SCALE","getRotatedBBox","getMinCropPixels","snapCropRectToSourcePixels","snapCropRectToSourcePixelGrid","useInteraction","useTransformStyle","getSourceRegion","__","VISUALLY_HIDDEN_STYLE","DimmingOverlay","GridOverlay","DimensionsOverlay","forwardRef","ViewportProvider"],"sources":["../../../../src/image-editor/react/components/cropper.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport {\n\tuseState,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseId,\n\tforwardRef,\n\tflushSync,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type {\n\tHandlePosition,\n\tStencilProps,\n\tSize,\n\tNormalizedRect,\n} from '../../core/types';\nimport type { CropperController } from '../hooks/use-cropper-controller';\nimport { getImageFit, getRotatedBBox, getViewScale } from '../../core/camera';\nimport { getImageCropBounds, getMinZoom } from '../../core/containment';\nimport {\n\tMAX_VIEW_SCALE,\n\tPIXEL_SNAP_DISPLAY_SCALE,\n\tSETTLE_TARGET_CANVAS_FILL,\n} from '../../core/constants';\nimport { computeInscribedRect } from '../../core/crop-rect';\nimport { getMinCropPixels } from '../../core/stencil-math';\nimport { useInteraction } from '../hooks/use-interaction';\nimport { useTransformStyle } from '../hooks/use-transform-style';\nimport { useAriaAnnouncer } from '../hooks/use-aria-announcer';\nimport { RectangleStencil } from './stencils/rectangle-stencil';\nimport { DimmingOverlay } from './overlays/dimming-overlay';\nimport { GridOverlay } from './overlays/grid-overlay';\nimport { DimensionsOverlay } from './overlays/dimensions-overlay';\nimport {\n\tgetSourceRegion,\n\tsnapCropRectToSourcePixelGrid,\n\tsnapCropRectToSourcePixels,\n} from '../../core/source-region';\nimport { ViewportProvider, useViewport } from './viewport-provider';\nimport { VISUALLY_HIDDEN_STYLE } from '../visually-hidden-style';\n\n/** Threshold for comparing normalized crop rect values. */\nconst CROP_RECT_EPSILON = 1e-6;\n/** Threshold for deciding whether rotation is at a 90-degree stop. */\nconst CARDINAL_ROTATION_EPSILON = 1e-6;\n/** Duration of the settle transform transition after resize end. */\nconst SETTLE_TRANSITION_DURATION_MS = 200;\n// Fallback timer for when the computed transform is unchanged and no\n// `transitionend` fires. Sits past the CSS duration so it only wins the race\n// when the transition genuinely never runs.\nconst SETTLE_TRANSITION_FALLBACK_MS = SETTLE_TRANSITION_DURATION_MS + 100;\nconst SETTLE_TRANSFORM_TRANSITION = `transform ${ SETTLE_TRANSITION_DURATION_MS }ms ease-out`;\nconst SETTLE_STENCIL_TRANSITION = [\n\t`left ${ SETTLE_TRANSITION_DURATION_MS }ms ease-out`,\n\t`top ${ SETTLE_TRANSITION_DURATION_MS }ms ease-out`,\n\t`width ${ SETTLE_TRANSITION_DURATION_MS }ms ease-out`,\n\t`height ${ SETTLE_TRANSITION_DURATION_MS }ms ease-out`,\n].join( ', ' );\n\n/**\n * Props for the Cropper component.\n */\nexport interface CropperProps {\n\t/** Image source URL. */\n\tsrc: string;\n\t/** The cropper controller from `useCropperController` or a composite store. */\n\tcontroller: CropperController;\n\t/** Stencil component for the crop area. Defaults to RectangleStencil. */\n\tstencil?: React.ComponentType< StencilProps >;\n\t/** Show the rule-of-thirds grid overlay, or only during interactions. */\n\tshowGrid?: boolean | 'interactive';\n\t/** Whether external placement activity should keep the grid visible. */\n\tisPlacementActive?: boolean;\n\t/** Show the dimming overlay outside the crop area. */\n\tshowDimming?: boolean;\n\t/** Show the live output dimensions tooltip during a resize. */\n\tshowDimensions?: boolean;\n\t/** Minimum zoom level override. Defaults to the coverage-aware minimum. */\n\tminZoom?: number;\n\t/** Maximum zoom level. */\n\tmaxZoom?: number;\n\t/** Fixed aspect ratio (width / height) in pixel space for the crop area. */\n\taspectRatio?: number;\n\t/**\n\t * Enable freeform crop mode with resizable handles.\n\t * When false (default), the crop area is fixed and centered.\n\t * When true, the crop area has resize handles and can be freely repositioned.\n\t */\n\tfreeformCrop?: boolean;\n\t/** Focus the crop area when the cropper mounts. */\n\tfocusOnMount?: boolean;\n\t/**\n\t * Ignore all crop interaction: pointer drags, wheel zoom, keyboard\n\t * pan/zoom and the stencil's resize handles. Any gesture already in\n\t * flight is cancelled. Used while the edit is being saved, so the\n\t * modifiers sent to the server cannot change after the request starts.\n\t */\n\tdisabled?: boolean;\n\t/** Callback fired when the image is loaded. */\n\tonImageLoaded?: ( size: Size ) => void;\n\t/** Callback fired when the image fails to load. */\n\tonImageError?: () => void;\n\t/** Fires when a continuous gesture begins (pan drag, handle resize, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointerup, resize settle). */\n\tonGestureEnd?: () => void;\n\t/** Additional className for the container. */\n\tclassName?: string;\n}\n\n/**\n * The main image cropper component.\n *\n * Renders an image within a container with interactive crop overlays.\n * Creates the camera once per render via getImageFit, then passes\n * derived values to stencil, overlays, and interaction hooks.\n *\n * The component fills its parent container (100% width and height).\n * Wrap it in a sized container to control its dimensions.\n *\n * @param root0 Component props implementing CropperProps.\n * @param root0.src Image source URL.\n * @param root0.controller The cropper controller from `useCropperController` or a composite store.\n * @param root0.stencil Custom stencil component.\n * @param root0.showGrid Grid overlay mode: false | true | 'interactive'.\n * @param root0.isPlacementActive Keep grid visible during external placement activity.\n * @param root0.showDimming Show dimming overlay outside crop.\n * @param root0.showDimensions Show live dimensions tooltip during resize.\n * @param root0.minZoom Minimum zoom level override.\n * @param root0.maxZoom Maximum zoom level.\n * @param root0.aspectRatio Fixed aspect ratio (width/height).\n * @param root0.freeformCrop Enable resize handles.\n * @param root0.focusOnMount Focus the crop area on mount.\n * @param root0.disabled Ignore all crop interaction.\n * @param root0.onImageLoaded Image load callback.\n * @param root0.onImageError Image error callback.\n * @param root0.onGestureStart Gesture boundary start.\n * @param root0.onGestureEnd Gesture boundary end.\n * @param root0.className Additional CSS class.\n * @param ref Forwarded ref for the container div.\n */\nfunction CropperInner(\n\t{\n\t\tsrc,\n\t\tcontroller,\n\t\tstencil: StencilComponent = RectangleStencil,\n\t\tshowGrid = false,\n\t\tisPlacementActive = false,\n\t\tshowDimming = true,\n\t\tshowDimensions = true,\n\t\tminZoom,\n\t\tmaxZoom,\n\t\taspectRatio,\n\t\tfreeformCrop = false,\n\t\tfocusOnMount = false,\n\t\tdisabled = false,\n\t\tonImageLoaded,\n\t\tonImageError,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t\tclassName,\n\t}: CropperProps,\n\tref: React.ForwardedRef< HTMLDivElement >\n) {\n\tconst {\n\t\tstate,\n\t\tsetImage,\n\t\tsetCropRect,\n\t\tsettleCrop,\n\t\tsetVisualSize,\n\t\tadjustCropRectForViewport,\n\t} = controller;\n\tconst {\n\t\tviewport: viewportState,\n\t\tsetViewportPan,\n\t\tresetViewport,\n\t} = useViewport();\n\t// Canvas measurement via ResizeObserver. The canvas is the inner\n\t// positioning context for image/stencil/handles — inset from the root\n\t// by the handle gutter, so crop math operates on the reduced box.\n\tconst canvasRef = useRef< HTMLDivElement >( null );\n\tconst cropAreaDescriptionId = useId();\n\tconst [ isCropAreaFocused, setIsCropAreaFocused ] =\n\t\tuseState( focusOnMount );\n\tconst [ isFocusVisible, setIsFocusVisible ] = useState( false );\n\tconst [ canvasSize, setCanvasSize ] = useState< Size >( {\n\t\twidth: 0,\n\t\theight: 0,\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tif ( focusOnMount ) {\n\t\t\tcanvasRef.current?.focus( { preventScroll: true } );\n\t\t}\n\t}, [ focusOnMount ] );\n\n\tconst handleCropAreaFocus = useCallback(\n\t\t( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\t\tconst target = event.target as HTMLElement;\n\t\t\tif ( target === event.currentTarget ) {\n\t\t\t\tsetIsCropAreaFocused( true );\n\t\t\t}\n\t\t\t// Show the outline only when focus arrived via keyboard\n\t\t\t// navigation. relatedTarget is null for pointer-initiated and\n\t\t\t// cross-window focus, so it reliably excludes those cases\n\t\t\t// without needing a separate ref or flag. Applies to focus\n\t\t\t// arriving on the canvas itself or on a descendant handle.\n\t\t\tif (\n\t\t\t\tevent.relatedTarget !== null &&\n\t\t\t\ttarget.matches( ':focus-visible' )\n\t\t\t) {\n\t\t\t\tsetIsFocusVisible( true );\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\tconst handleCropAreaBlur = useCallback(\n\t\t( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\tsetIsCropAreaFocused( false );\n\t\t\t}\n\t\t\t// Reset keyboard-active styling only when focus leaves the\n\t\t\t// cropper entirely. Moves between the canvas and a handle (or\n\t\t\t// between handles) keep the keyboard-active state intact.\n\t\t\tif (\n\t\t\t\t! event.currentTarget.contains(\n\t\t\t\t\tevent.relatedTarget as Node | null\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tsetIsFocusVisible( false );\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tconst element = canvasRef.current;\n\t\tif ( ! element ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new ResizeObserver( ( entries ) => {\n\t\t\tfor ( const entry of entries ) {\n\t\t\t\tconst { width, height } = entry.contentRect;\n\t\t\t\t// Render before the next paint, so the image keeps up with\n\t\t\t\t// a container that is resizing every frame (such as while\n\t\t\t\t// the sidebar animates) instead of trailing it by a frame.\n\t\t\t\tflushSync( () => {\n\t\t\t\t\tsetCanvasSize( ( prev ) => {\n\t\t\t\t\t\tif ( prev.width === width && prev.height === height ) {\n\t\t\t\t\t\t\treturn prev;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { width, height };\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t\tobserver.observe( element );\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [] );\n\n\t// ARIA announcements: announce significant state changes for screen readers\n\t// via the centralized @wordpress/a11y speak() API called inside the hook.\n\tuseAriaAnnouncer( state );\n\n\t// Compute fitted image dimensions and visual bounds from camera math.\n\tconst naturalWidth = state.image?.naturalWidth ?? 0;\n\tconst naturalHeight = state.image?.naturalHeight ?? 0;\n\tconst { elementSize, visualSize } = useMemo(\n\t\t() =>\n\t\t\tgetImageFit(\n\t\t\t\tcanvasSize,\n\t\t\t\t{ width: naturalWidth, height: naturalHeight },\n\t\t\t\tstate.rotation\n\t\t\t),\n\t\t[ canvasSize, naturalWidth, naturalHeight, state.rotation ]\n\t);\n\n\t// Report the rendered image size to the controller. Composite\n\t// controllers need it to compute aspect-ratio reshapes from the\n\t// reducer (the dropdown dispatches without DOM access); pure\n\t// controllers ignore it.\n\tuseEffect( () => {\n\t\tsetVisualSize( visualSize );\n\t}, [ visualSize, setVisualSize ] );\n\n\t// In fixed-crop mode, auto-size the crop rect only when a fixed\n\t// aspect ratio is selected. With \"Free\" selected, turning freeform\n\t// handles off should preserve the user's current unconstrained\n\t// crop. Uses `adjustCropRectForViewport` so window-resize-driven\n\t// reshapes don't create undo entries (composite controller); the\n\t// dedup at lines below avoids redundant dispatches when the\n\t// reducer has already updated the cropRect for an aspect change.\n\tuseEffect( () => {\n\t\tif (\n\t\t\tfreeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0 ||\n\t\t\t! aspectRatio ||\n\t\t\taspectRatio <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = computeInscribedRect( aspectRatio, visualSize );\n\t\tconst current = state.cropRect;\n\t\tif (\n\t\t\tMath.abs( current.x - rect.x ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.y - rect.y ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.width - rect.width ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.height - rect.height ) < CROP_RECT_EPSILON\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tadjustCropRectForViewport( rect );\n\t}, [\n\t\tfreeformCrop,\n\t\taspectRatio,\n\t\tvisualSize,\n\t\tadjustCropRectForViewport,\n\t\tstate.cropRect,\n\t] );\n\n\t// In freeform mode, when aspectRatio changes, reshape the crop to\n\t// the largest inscribed rect of the new ratio. Bails out when the\n\t// cropRect already matches the inscribed rect — composite stores\n\t// reshape atomically inside the reducer, so this effect is a\n\t// no-op there.\n\tconst prevAspectRatioRef = useRef( aspectRatio );\n\tuseEffect( () => {\n\t\tif ( prevAspectRatioRef.current === aspectRatio ) {\n\t\t\treturn;\n\t\t}\n\t\tprevAspectRatioRef.current = aspectRatio;\n\n\t\tif (\n\t\t\t! freeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0 ||\n\t\t\t! aspectRatio ||\n\t\t\taspectRatio <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = computeInscribedRect( aspectRatio, visualSize );\n\t\tconst current = state.cropRect;\n\t\tif (\n\t\t\tMath.abs( current.x - rect.x ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.y - rect.y ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.width - rect.width ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.height - rect.height ) < CROP_RECT_EPSILON\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tadjustCropRectForViewport( rect );\n\t}, [\n\t\taspectRatio,\n\t\tfreeformCrop,\n\t\tvisualSize,\n\t\tadjustCropRectForViewport,\n\t\tstate.cropRect,\n\t] );\n\n\t// Compute the crop handle bounds from the actual image footprint.\n\t// Depends on the full state object because getImageCropBounds reads\n\t// crop, zoom, rotation, flip, and image. React Compiler requires\n\t// the complete dependency; the computation is lightweight (a few\n\t// trig ops + 4 corner transforms).\n\tconst cropBounds = useMemo( () => {\n\t\tif ( ! state.image || elementSize.width === 0 ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getImageCropBounds( state, elementSize, visualSize );\n\t}, [ state, elementSize, visualSize ] );\n\tconst effectiveMinZoom =\n\t\tminZoom !== undefined ? minZoom : getMinZoom( state );\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst isResizingRef = useRef( false );\n\tconst isSettlingRef = useRef( false );\n\tconst [ isTouchPinching, setIsTouchPinchingState ] = useState( false );\n\tconst isTouchPinchingRef = useRef( false );\n\tconst setTouchPinching = useCallback( ( isPinching: boolean ) => {\n\t\tisTouchPinchingRef.current = isPinching;\n\t\tsetIsTouchPinchingState( isPinching );\n\t}, [] );\n\t// Direction of the handle the user is currently resizing — pointer or\n\t// keyboard. `null` outside of an active resize. Drives the live\n\t// dimensions tooltip overlay.\n\tconst [ activeHandle, setActiveHandle ] = useState< HandlePosition | null >(\n\t\tnull\n\t);\n\n\t// Presentational magnification so the at-rest crop fills the canvas. The\n\t// crop overlay is laid out as `cropRect * visualSize` (the contain-fit\n\t// footprint, no zoom), so a crop whose aspect differs from the image's can\n\t// render far smaller than the canvas allows. Scaling `elementSize` and\n\t// `visualSize` together magnifies the whole scene uniformly — image,\n\t// overlays, and the pixel->normalized interaction math — and the root's\n\t// `overflow: hidden` clips the image bleed. Magnifying around the footprint\n\t// centre keeps the crop centred only because the at-rest crop is always\n\t// centred (SETTLE_CROP, computeInscribedRect, and the initial full-frame\n\t// crop all centre it).\n\tconst viewScaleRest = useMemo(\n\t\t() =>\n\t\t\tgetViewScale(\n\t\t\t\tstate.cropRect,\n\t\t\t\tcanvasSize,\n\t\t\t\tvisualSize,\n\t\t\t\tSETTLE_TARGET_CANVAS_FILL,\n\t\t\t\tMAX_VIEW_SCALE\n\t\t\t),\n\t\t[ state.cropRect, canvasSize, visualSize ]\n\t);\n\t// During a resize the magnification is frozen at its pre-drag value rather\n\t// than recomputed per pointer move: recomputing live would zoom the scene\n\t// under the cursor, and snapping to 1 would reset the zoom the moment a\n\t// handle is grabbed. `handleResizeStart` snapshots the current rest value\n\t// into `frozenViewScale`; on release the settle recomputes from the new crop.\n\tconst [ frozenViewScale, setFrozenViewScale ] = useState( 1 );\n\tconst viewScale = isResizing ? frozenViewScale : viewScaleRest;\n\tconst scaledVisualSize = useMemo(\n\t\t() => ( {\n\t\t\twidth: visualSize.width * viewScale,\n\t\t\theight: visualSize.height * viewScale,\n\t\t} ),\n\t\t[ visualSize.width, visualSize.height, viewScale ]\n\t);\n\t// CSS pixels rendered per source pixel: the contain fit\n\t// (elementSize / natural), times zoom and the view-scale magnification.\n\tconst displayScale =\n\t\tnaturalWidth > 0\n\t\t\t? ( elementSize.width / naturalWidth ) * state.zoom * viewScale\n\t\t\t: 0;\n\tconst keyboardResizeStep = useMemo( () => {\n\t\tif (\n\t\t\tdisplayScale < PIXEL_SNAP_DISPLAY_SCALE ||\n\t\t\t( aspectRatio && aspectRatio > 0 ) ||\n\t\t\tnaturalWidth <= 0 ||\n\t\t\tnaturalHeight <= 0\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\t\tif (\n\t\t\tMath.abs( state.rotation - snapRotation ) >=\n\t\t\tCARDINAL_ROTATION_EPSILON\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst bbox = getRotatedBBox(\n\t\t\tnaturalWidth,\n\t\t\tnaturalHeight,\n\t\t\tsnapRotation\n\t\t);\n\t\tif ( bbox.width <= 0 || bbox.height <= 0 ) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Keyboard steps are normalized crop-space deltas, but snapping wants\n\t\t// one source pixel per key press. The normalized delta for one source\n\t\t// pixel is different on each axis when the snap-rotation bbox is not\n\t\t// square, so this must be an object with separate width/height steps\n\t\t// instead of a single scalar.\n\t\treturn {\n\t\t\twidth: state.zoom / bbox.width,\n\t\t\theight: state.zoom / bbox.height,\n\t\t};\n\t}, [\n\t\tdisplayScale,\n\t\taspectRatio,\n\t\tnaturalWidth,\n\t\tnaturalHeight,\n\t\tstate.rotation,\n\t\tstate.zoom,\n\t] );\n\n\t// Per-axis minimum crop size in normalized space, expressing a pixel floor\n\t// on the captured source region. cropRect is normalized in the viewport's\n\t// snap-rotation bbox; the captured source-pixel width is\n\t// `cropRect.width * bbox.width / zoom`, so the normalized floor scales with\n\t// `zoom` to keep the source-pixel floor constant. The floor itself adapts to\n\t// the on-screen display scale (fit × zoom × view scale) via\n\t// `getMinCropPixels`, so on a large image shown small the crop can't shrink\n\t// until the handles collapse — it yields to the 24px source floor only once\n\t// the image is shown large enough.\n\tconst minCropSize: Size | undefined = useMemo( () => {\n\t\tif ( naturalWidth <= 0 || naturalHeight <= 0 ) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\t\tconst bbox = getRotatedBBox(\n\t\t\tnaturalWidth,\n\t\t\tnaturalHeight,\n\t\t\tsnapRotation\n\t\t);\n\t\tconst minPixels = getMinCropPixels( displayScale );\n\t\treturn {\n\t\t\twidth: Math.min( 1, ( minPixels * state.zoom ) / bbox.width ),\n\t\t\theight: Math.min( 1, ( minPixels * state.zoom ) / bbox.height ),\n\t\t};\n\t}, [\n\t\tnaturalWidth,\n\t\tnaturalHeight,\n\t\tstate.rotation,\n\t\tstate.zoom,\n\t\tdisplayScale,\n\t] );\n\n\tconst snapCropRect = useCallback(\n\t\t( rect: NormalizedRect, handle: HandlePosition ): NormalizedRect => {\n\t\t\tif (\n\t\t\t\tdisplayScale < PIXEL_SNAP_DISPLAY_SCALE ||\n\t\t\t\tnaturalWidth <= 0 ||\n\t\t\t\tnaturalHeight <= 0\n\t\t\t) {\n\t\t\t\treturn rect;\n\t\t\t}\n\t\t\treturn snapCropRectToSourcePixels(\n\t\t\t\tstate,\n\t\t\t\t{ width: naturalWidth, height: naturalHeight },\n\t\t\t\trect,\n\t\t\t\thandle\n\t\t\t);\n\t\t},\n\t\t[ displayScale, naturalWidth, naturalHeight, state ]\n\t);\n\n\tconst wasPixelSnapEnabledRef = useRef( false );\n\tuseEffect( () => {\n\t\tconst isPixelSnapEnabled =\n\t\t\tfreeformCrop &&\n\t\t\t( ! aspectRatio || aspectRatio <= 0 ) &&\n\t\t\tdisplayScale >= PIXEL_SNAP_DISPLAY_SCALE &&\n\t\t\tnaturalWidth > 0 &&\n\t\t\tnaturalHeight > 0;\n\t\tconst wasPixelSnapEnabled = wasPixelSnapEnabledRef.current;\n\t\twasPixelSnapEnabledRef.current = isPixelSnapEnabled;\n\n\t\tif ( ! isPixelSnapEnabled || wasPixelSnapEnabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst snappedCropRect = snapCropRectToSourcePixelGrid(\n\t\t\tstate,\n\t\t\t{ width: naturalWidth, height: naturalHeight },\n\t\t\tstate.cropRect\n\t\t);\n\t\tconst currentCropRect = state.cropRect;\n\t\tif (\n\t\t\tMath.abs( currentCropRect.x - snappedCropRect.x ) <\n\t\t\t\tCROP_RECT_EPSILON &&\n\t\t\tMath.abs( currentCropRect.y - snappedCropRect.y ) <\n\t\t\t\tCROP_RECT_EPSILON &&\n\t\t\tMath.abs( currentCropRect.width - snappedCropRect.width ) <\n\t\t\t\tCROP_RECT_EPSILON &&\n\t\t\tMath.abs( currentCropRect.height - snappedCropRect.height ) <\n\t\t\t\tCROP_RECT_EPSILON\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The display scale crossing the threshold is not an edit, so the\n\t\t// snap must not record an undo entry. Recording it here would also\n\t\t// clear the redo stack whenever an undo or redo crosses it.\n\t\tadjustCropRectForViewport( snappedCropRect );\n\t}, [\n\t\tadjustCropRectForViewport,\n\t\taspectRatio,\n\t\tdisplayScale,\n\t\tfreeformCrop,\n\t\tnaturalWidth,\n\t\tnaturalHeight,\n\t\tstate,\n\t] );\n\n\t// Use the interaction hook for mouse, touch, and keyboard events.\n\tconst {\n\t\thandlers,\n\t\tonWheelNative,\n\t\tisDragging,\n\t\tisZooming,\n\t\tisPlacementActive: isInteractionPlacementActive,\n\t} = useInteraction( state, controller, canvasSize, scaledVisualSize, {\n\t\tminZoom: effectiveMinZoom,\n\t\tmaxZoom,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t\tdisabled,\n\t} );\n\n\t// Compose focus-visibility tracking into the canvas event handlers.\n\t// Kept as a spread rather than explicit props to avoid triggering\n\t// jsx-a11y/no-noninteractive-element-interactions on role=\"group\".\n\t//\n\t// The pointer/key tracking lives in the capture phase so it runs\n\t// before any child handler — handles call stopPropagation in their\n\t// own onPointerDown / onKeyDown, which would otherwise prevent the\n\t// keyboard-active state from updating when the user interacts with\n\t// a handle directly.\n\tconst canvasHandlers = {\n\t\t...handlers,\n\t\tonPointerDownCapture: () => {\n\t\t\tsetIsFocusVisible( false );\n\t\t},\n\t\tonTouchStartCapture: ( event: React.TouchEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.touches.length > 1 ) {\n\t\t\t\tsetTouchPinching( true );\n\t\t\t}\n\t\t},\n\t\tonTouchMoveCapture: ( event: React.TouchEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.touches.length > 1 ) {\n\t\t\t\tsetTouchPinching( true );\n\t\t\t}\n\t\t},\n\t\tonTouchEndCapture: ( event: React.TouchEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.touches.length === 0 ) {\n\t\t\t\tsetTouchPinching( false );\n\t\t\t}\n\t\t},\n\t\tonTouchCancelCapture: ( event: React.TouchEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.touches.length === 0 ) {\n\t\t\t\tsetTouchPinching( false );\n\t\t\t}\n\t\t},\n\t\tonKeyDownCapture: ( event: React.KeyboardEvent< HTMLDivElement > ) => {\n\t\t\t// Modifier-only keypresses precede another key rather than\n\t\t\t// indicating deliberate keyboard interaction on their own.\n\t\t\tif (\n\t\t\t\t! [ 'Shift', 'Control', 'Alt', 'Meta' ].includes( event.key )\n\t\t\t) {\n\t\t\t\tsetIsFocusVisible( true );\n\t\t\t}\n\t\t},\n\t\tonPointerDown: ( event: React.PointerEvent< HTMLDivElement > ) => {\n\t\t\tif (\n\t\t\t\tdisabled ||\n\t\t\t\tisResizingRef.current ||\n\t\t\t\tisTouchPinchingRef.current ||\n\t\t\t\t( event.pointerType === 'touch' && event.isPrimary === false )\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thandlers.onPointerDown?.( event );\n\t\t\t// Re-assert false after handlers run — el.focus() inside the\n\t\t\t// handler fires onFocus, which may otherwise set it back to true.\n\t\t\tsetIsFocusVisible( false );\n\t\t},\n\t};\n\n\t// Register wheel handler natively with { passive: false } so\n\t// preventDefault works. React's onWheel registers as passive. Bound\n\t// to the canvas (not the root) so pointer geometry inside the handler\n\t// resolves against the canvas box.\n\tuseEffect( () => {\n\t\tconst el = canvasRef.current;\n\t\tif ( ! el ) {\n\t\t\treturn;\n\t\t}\n\t\tconst handleWheel = ( event: WheelEvent ) => {\n\t\t\t// Block wheel zoom while resizing or settling — the stage CSS\n\t\t\t// transform changes getBoundingClientRect() during this window,\n\t\t\t// so focal-point math would resolve against the wrong center.\n\t\t\tif ( isResizingRef.current || isSettlingRef.current ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonWheelNative( event );\n\t\t};\n\t\tel.addEventListener( 'wheel', handleWheel, {\n\t\t\tpassive: false,\n\t\t} );\n\t\treturn () => {\n\t\t\tel.removeEventListener( 'wheel', handleWheel );\n\t\t};\n\t}, [ onWheelNative ] );\n\n\t// Use the unscaled contain-fit footprint here. `imageStyle` prepends\n\t// `scale(viewScale)` to this matrix, so pan translations are magnified with\n\t// the rest of the scene; using `scaledVisualSize` here would apply viewScale\n\t// to pan twice.\n\tconst transformString = useTransformStyle( state, visualSize );\n\n\t/**\n\t * Handle the image load event.\n\t */\n\tconst handleImageLoad = useCallback(\n\t\t( event: React.SyntheticEvent< HTMLImageElement > ) => {\n\t\t\tconst img = event.currentTarget;\n\t\t\tconst size: Size = {\n\t\t\t\twidth: img.naturalWidth,\n\t\t\t\theight: img.naturalHeight,\n\t\t\t};\n\n\t\t\tsetImage( {\n\t\t\t\tsrc,\n\t\t\t\tnaturalWidth: size.width,\n\t\t\t\tnaturalHeight: size.height,\n\t\t\t} );\n\n\t\t\tonImageLoaded?.( size );\n\t\t},\n\t\t[ src, setImage, onImageLoaded ]\n\t);\n\n\tconst handleCropChange = useCallback(\n\t\t( rect: NormalizedRect ) => {\n\t\t\tif ( isTouchPinchingRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetCropRect( rect );\n\t\t\t// During a resize drag, pan the viewport so the handle stays\n\t\t\t// visible even when the crop extends beyond the canvas edge.\n\t\t\tif (\n\t\t\t\tisResizingRef.current &&\n\t\t\t\tscaledVisualSize.width > 0 &&\n\t\t\t\tscaledVisualSize.height > 0\n\t\t\t) {\n\t\t\t\tconst offsetX =\n\t\t\t\t\t( canvasSize.width - scaledVisualSize.width ) / 2;\n\t\t\t\tconst offsetY =\n\t\t\t\t\t( canvasSize.height - scaledVisualSize.height ) / 2;\n\t\t\t\tconst rightOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\toffsetX +\n\t\t\t\t\t\t( rect.x + rect.width ) * scaledVisualSize.width -\n\t\t\t\t\t\tcanvasSize.width\n\t\t\t\t);\n\t\t\t\tconst leftOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\t-( offsetX + rect.x * scaledVisualSize.width )\n\t\t\t\t);\n\t\t\t\tconst bottomOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\toffsetY +\n\t\t\t\t\t\t( rect.y + rect.height ) * scaledVisualSize.height -\n\t\t\t\t\t\tcanvasSize.height\n\t\t\t\t);\n\t\t\t\tconst topOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\t-( offsetY + rect.y * scaledVisualSize.height )\n\t\t\t\t);\n\t\t\t\tsetViewportPan( {\n\t\t\t\t\tx: -rightOverflow + leftOverflow,\n\t\t\t\t\ty: -bottomOverflow + topOverflow,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ setCropRect, setViewportPan, canvasSize, scaledVisualSize ]\n\t);\n\n\t// Settling animation: brief transition after resize end.\n\tconst [ settling, setSettling ] = useState( false );\n\tconst settleTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\tconst finishSettling = useCallback( () => {\n\t\tclearTimeout( settleTimerRef.current );\n\t\tisSettlingRef.current = false;\n\t\tsetSettling( false );\n\t}, [] );\n\n\t// Clear the pending settle timer on unmount so it can't fire a\n\t// state update on an unmounted component.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( settleTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tconst isInteractiveGrid = showGrid === 'interactive';\n\tconst showInteractiveGrid =\n\t\tisInteractiveGrid &&\n\t\t( isInteractionPlacementActive || isResizing || isPlacementActive );\n\n\t// Output crop size in source pixels — drives the live tooltip\n\t// overlay. Only computed during pointer drags, so the per-frame\n\t// state churn during pan/zoom doesn't pay for it.\n\tconst outputSize = useMemo( () => {\n\t\tif ( ! showDimensions || ! activeHandle || ! state.image ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst region = getSourceRegion( state, {\n\t\t\twidth: state.image.naturalWidth,\n\t\t\theight: state.image.naturalHeight,\n\t\t} );\n\t\treturn { width: region.width, height: region.height };\n\t}, [ showDimensions, activeHandle, state ] );\n\n\t/**\n\t * Handle Escape on a resize handle — return focus to the canvas so\n\t * arrow keys pan the image rather than resize.\n\t */\n\tconst handleEscape = useCallback( () => {\n\t\t// Escape is always a keyboard action, so show the outline immediately\n\t\t// rather than relying on the focus handler's :focus-visible check.\n\t\tsetIsFocusVisible( true );\n\t\tcanvasRef.current?.focus( { preventScroll: true } );\n\t}, [] );\n\n\tconst handleResizeStart = useCallback(\n\t\t( handle?: HandlePosition ) => {\n\t\t\tif ( isTouchPinchingRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Freeze the magnification at its current value so grabbing a\n\t\t\t// handle doesn't reset the zoom; it holds for the whole drag.\n\t\t\tsetFrozenViewScale( viewScaleRest );\n\t\t\tisResizingRef.current = true;\n\t\t\tsetIsResizing( true );\n\t\t\tsetActiveHandle( handle ?? null );\n\t\t\t// Clear any in-flight settle so transitions don't apply during the\n\t\t\t// new drag (rapid successive resizes would otherwise inherit the\n\t\t\t// previous settle animation).\n\t\t\tfinishSettling();\n\t\t\tresetViewport();\n\t\t\tonGestureStart?.();\n\t\t},\n\t\t[ finishSettling, onGestureStart, resetViewport, viewScaleRest ]\n\t);\n\n\t/**\n\t * Handle resize end — settle the crop rect (re-center, fill height)\n\t * and reset the viewport pan back to neutral.\n\t */\n\tconst handleResizeEnd = useCallback( () => {\n\t\tconst isCancellingForPinch = isTouchPinchingRef.current;\n\t\tisResizingRef.current = false;\n\t\tsetIsResizing( false );\n\t\tsetActiveHandle( null );\n\t\tclearTimeout( settleTimerRef.current );\n\n\t\tif ( isCancellingForPinch ) {\n\t\t\t// A pinch took over mid-resize. Tear down resize UI without\n\t\t\t// settling or firing onGestureEnd: the pinch owns the gesture\n\t\t\t// boundary and fires the end on its own touchend. The resize and\n\t\t\t// the pinch therefore collapse into a single undo step, since\n\t\t\t// `beginGesture` is idempotent and the snapshot captured at resize\n\t\t\t// start is flushed by the pinch's `endGesture`.\n\t\t\tfinishSettling();\n\t\t\tresetViewport();\n\t\t\treturn;\n\t\t}\n\n\t\tisSettlingRef.current = true;\n\t\tsetSettling( true );\n\t\t// Reset viewport pan first so it transitions back to zero in sync\n\t\t// with the settle animation on the image.\n\t\tresetViewport();\n\t\tsettleCrop();\n\t\tonGestureEnd?.();\n\t\t// Normal completion is driven by transitionend so settling cannot clear\n\t\t// before the browser has actually finished animating. Keep a fallback for\n\t\t// cases where the computed transform is unchanged and no event fires.\n\t\tsettleTimerRef.current = setTimeout(\n\t\t\tfinishSettling,\n\t\t\tSETTLE_TRANSITION_FALLBACK_MS\n\t\t);\n\t}, [ finishSettling, settleCrop, onGestureEnd, resetViewport ] );\n\n\t/**\n\t * Finish settling when the settle transform transition actually completes.\n\t * The handler lives on the stage, but in the common (un-panned) case the\n\t * transform transition runs on the image layer and its `transitionend`\n\t * bubbles up to here. Other transitionend events (stencil left/top/width/\n\t * height) also bubble up, so only the transform transition should clear the\n\t * settle state.\n\t */\n\tconst handleSettleTransitionEnd = useCallback(\n\t\t( event: React.TransitionEvent< HTMLDivElement > ) => {\n\t\t\tif (\n\t\t\t\t! isSettlingRef.current ||\n\t\t\t\tevent.propertyName !== 'transform'\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinishSettling();\n\t\t},\n\t\t[ finishSettling ]\n\t);\n\n\tlet imageTransition: string | undefined;\n\tif ( settling ) {\n\t\timageTransition = SETTLE_TRANSFORM_TRANSITION;\n\t} else if ( isZooming ) {\n\t\timageTransition = 'transform 150ms linear';\n\t}\n\tconst settleStencilTransition = settling\n\t\t? SETTLE_STENCIL_TRANSITION\n\t\t: undefined;\n\n\t// Compute the image's CSS style. The element keeps its contain-fit box; the\n\t// view-scale magnification is folded into the transform as an outer\n\t// `scale()` so the whole settle motion (zoom, pan, and magnification) is one\n\t// coherent transform that interpolates as a unit — the image slides/scales\n\t// to its position rather than animating its box separately. Magnifying\n\t// around the centred box keeps the (centred) crop centred.\n\tconst imageStyle = useMemo( (): React.CSSProperties => {\n\t\tif ( elementSize.width === 0 || elementSize.height === 0 ) {\n\t\t\treturn {};\n\t\t}\n\t\tconst centerX = ( canvasSize.width - elementSize.width ) / 2;\n\t\tconst centerY = ( canvasSize.height - elementSize.height ) / 2;\n\t\t// Above 1:1 the image is upscaled, so render nearest-neighbour to keep\n\t\t// pixel boundaries crisp (e.g. small images the cropper magnifies);\n\t\t// below 1:1 leave smoothing on for downscaled large images.\n\t\treturn {\n\t\t\twidth: elementSize.width,\n\t\t\theight: elementSize.height,\n\t\t\tmaxWidth: elementSize.width,\n\t\t\tmaxHeight: elementSize.height,\n\t\t\tleft: centerX,\n\t\t\ttop: centerY,\n\t\t\t// Always lead with `scale()` (identity at rest) so the transform's\n\t\t\t// function list stays structurally constant across rest, resize, and\n\t\t\t// settle. A conditional that dropped `scale()` at viewScale === 1\n\t\t\t// would change the list shape exactly when the settle transition\n\t\t\t// crosses 1:1, forcing the browser to fall back to matrix-decomposition\n\t\t\t// interpolation instead of interpolating each function in turn.\n\t\t\ttransform: `scale(${ viewScale }) ${ transformString }`,\n\t\t\ttransition: imageTransition,\n\t\t\timageRendering: displayScale > 1 ? 'pixelated' : undefined,\n\t\t};\n\t}, [\n\t\tcanvasSize,\n\t\telementSize,\n\t\ttransformString,\n\t\timageTransition,\n\t\tdisplayScale,\n\t\tviewScale,\n\t] );\n\n\t// Viewport pan CSS transform for the stage div. Applied during resize\n\t// drags to keep handles visible when the crop extends past the canvas edge.\n\t// Transitions back to zero during the settle animation.\n\t// will-change promotes the stage to its own compositor layer while the\n\t// transform is active, keeping per-frame pan updates off the main thread.\n\tconst settleTransition = settling ? SETTLE_TRANSFORM_TRANSITION : undefined;\n\tconst willChange = isResizing || settling ? 'transform' : undefined;\n\tlet stageStyle: React.CSSProperties | undefined;\n\tif ( viewportState.pan.x !== 0 || viewportState.pan.y !== 0 ) {\n\t\tstageStyle = {\n\t\t\ttransform: `translate(${ viewportState.pan.x }px, ${ viewportState.pan.y }px)`,\n\t\t\ttransition: settleTransition,\n\t\t\twillChange,\n\t\t};\n\t} else if ( settling ) {\n\t\t// Animate the viewport pan back to an explicit identity translate rather\n\t\t// than dropping the transform property, so the reset eases instead of\n\t\t// snapping (transitions to a removed transform are unreliable).\n\t\tstageStyle = {\n\t\t\ttransform: 'translate(0px, 0px)',\n\t\t\ttransition: settleTransition,\n\t\t\twillChange,\n\t\t};\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wp-media-editor-image-editor',\n\t\t\t\tisDragging && 'wp-media-editor-image-editor--dragging',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t{ /*\n\t\t\t * The canvas is the interactive, inset surface. Handles and\n\t\t\t * the ARIA role/tabIndex live here so pointer geometry\n\t\t\t * (getBoundingClientRect on e.currentTarget) resolves against\n\t\t\t * the same box that crop math uses. The root stays as the\n\t\t\t * clipping shell for the dimming overlay's box-shadow.\n\t\t\t *\n\t\t\t * Not role=\"application\" — that disables the screen reader's\n\t\t\t * normal keyboard interception, too heavy-handed for a single\n\t\t\t * widget. Screen reader users get the ARIA live region below\n\t\t\t * as the announcement channel.\n\t\t\t */ }\n\t\t\t<div\n\t\t\t\tref={ canvasRef }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wp-media-editor-image-editor__canvas',\n\t\t\t\t\tisInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--grid-interactive',\n\t\t\t\t\tshowInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--show-grid',\n\t\t\t\t\tsettling &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--settling',\n\t\t\t\t\t// Marks the cropper as in keyboard-interaction mode.\n\t\t\t\t\t// CSS uses :focus on the canvas to show the stencil\n\t\t\t\t\t// outline and :focus on a handle to show its ring,\n\t\t\t\t\t// so the class applies whenever any cropper element\n\t\t\t\t\t// has keyboard focus.\n\t\t\t\t\tisFocusVisible &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--focus-visible'\n\t\t\t\t) }\n\t\t\t\ttabIndex={ 0 }\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ __( 'Crop area' ) }\n\t\t\t\taria-describedby={\n\t\t\t\t\tisCropAreaFocused ? cropAreaDescriptionId : undefined\n\t\t\t\t}\n\t\t\t\tonFocus={ handleCropAreaFocus }\n\t\t\t\tonBlur={ handleCropAreaBlur }\n\t\t\t\t{ ...canvasHandlers }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tid={ cropAreaDescriptionId }\n\t\t\t\t\tstyle={ VISUALLY_HIDDEN_STYLE }\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'When this area is focused, use arrow keys to move the image and plus or minus to zoom. Tab to resize handles and controls.'\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ /*\n\t\t\t\t * The stage is an inner full-size div that receives the\n\t\t\t\t * viewport pan CSS transform. Keeping the transform here\n\t\t\t\t * (rather than on the canvas) means the canvas always stays\n\t\t\t\t * at its natural position, so the root div's background is\n\t\t\t\t * never exposed when the stage is panned during a resize drag.\n\t\t\t\t */ }\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"wp-media-editor-image-editor__stage\"\n\t\t\t\t\tdata-testid=\"cropper-stage\"\n\t\t\t\t\tstyle={ stageStyle }\n\t\t\t\t\tonTransitionEnd={ handleSettleTransitionEnd }\n\t\t\t\t>\n\t\t\t\t\t{ /* The image layer */ }\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"wp-media-editor-image-editor__image\"\n\t\t\t\t\t\tdata-testid=\"cropper-image\"\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tonLoad={ handleImageLoad }\n\t\t\t\t\t\tonError={ onImageError }\n\t\t\t\t\t\tstyle={ imageStyle }\n\t\t\t\t\t\tdraggable={ false }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Dimming overlay outside the crop area */ }\n\t\t\t\t\t{ showDimming && (\n\t\t\t\t\t\t<DimmingOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ scaledVisualSize }\n\t\t\t\t\t\t\ttransition={ settleStencilTransition }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ /* The stencil (crop area with handles) */ }\n\t\t\t\t\t<StencilComponent\n\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\timageSize={ scaledVisualSize }\n\t\t\t\t\t\tonCropChange={ handleCropChange }\n\t\t\t\t\t\tonResizeStart={ handleResizeStart }\n\t\t\t\t\t\tonResizeEnd={ handleResizeEnd }\n\t\t\t\t\t\tonEscape={ handleEscape }\n\t\t\t\t\t\taspectRatio={ aspectRatio }\n\t\t\t\t\t\tfreeformCrop={ freeformCrop }\n\t\t\t\t\t\tisResizeDisabled={ isTouchPinching || disabled }\n\t\t\t\t\t\tstencilTransition={ settleStencilTransition }\n\t\t\t\t\t\tcropBounds={ cropBounds }\n\t\t\t\t\t\tminCropSize={ minCropSize }\n\t\t\t\t\t\tsnapCropRect={ snapCropRect }\n\t\t\t\t\t\tkeyboardResizeStep={ keyboardResizeStep }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Rule-of-thirds grid */ }\n\t\t\t\t\t{ ( showGrid === true || isInteractiveGrid ) && (\n\t\t\t\t\t\t<GridOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ scaledVisualSize }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ /* Live dimensions tooltip pinned to the dragged handle. */ }\n\t\t\t\t\t{ activeHandle && outputSize && (\n\t\t\t\t\t\t<DimensionsOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ scaledVisualSize }\n\t\t\t\t\t\t\tactiveHandle={ activeHandle }\n\t\t\t\t\t\t\toutputWidth={ outputSize.width }\n\t\t\t\t\t\t\toutputHeight={ outputSize.height }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nconst CropperInnerWithRef = forwardRef< HTMLDivElement, CropperProps >(\n\tCropperInner\n);\n\nexport const Cropper = forwardRef< HTMLDivElement, CropperProps >(\n\t( props, ref ) => (\n\t\t<ViewportProvider>\n\t\t\t<CropperInnerWithRef { ...props } ref={ ref } />\n\t\t</ViewportProvider>\n\t)\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,oBAAoB;;AAE1B,MAAM,4BAA4B;;AAElC,MAAM,gCAAgC;AAItC,MAAM,gCAAgC;AACtC,MAAM,8BAA8B,aAAc,8BAA+B;AACjF,MAAM,4BAA4B;CACjC,QAAS,8BAA+B;CACxC,OAAQ,8BAA+B;CACvC,SAAU,8BAA+B;CACzC,UAAW,8BAA+B;AAC3C,CAAC,CAAC,KAAM,IAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFb,SAAS,aACR,EACC,KACA,YACA,SAAS,mBAAmBA,iCAAAA,kBAC5B,WAAW,OACX,oBAAoB,OACpB,cAAc,MACd,iBAAiB,MACjB,SACA,SACA,aACA,eAAe,OACf,eAAe,OACf,WAAW,OACX,eACA,cACA,gBACA,cACA,aAED,KACC;CACD,MAAM,EACL,OACA,UACA,aACA,YACA,eACA,8BACG;CACJ,MAAM,EACL,UAAU,eACV,gBACA,mBAAA,GACGC,wBAAAA,YAAAA,CAAY;CAIhB,MAAM,aAAA,GAAYC,mBAAAA,OAAAA,CAA0B,IAAK;CACjD,MAAM,yBAAA,GAAwBC,mBAAAA,MAAAA,CAAM;CACpC,MAAM,CAAE,mBAAmB,yBAAA,GAC1BC,mBAAAA,SAAAA,CAAU,YAAa;CACxB,MAAM,CAAE,gBAAgB,sBAAA,GAAsBA,mBAAAA,SAAAA,CAAU,KAAM;CAC9D,MAAM,CAAE,YAAY,kBAAA,GAAkBA,mBAAAA,SAAAA,CAAkB;EACvD,OAAO;EACP,QAAQ;CACT,CAAE;CAEF,CAAA,GAAA,mBAAA,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,OAAQ;IACR,iBAAkB;IAJnB,UAAA;KAOC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;MACC,WAAU;MACV,eAAY;MACN;MACN,KAAI;MACJ,QAAS;MACT,SAAU;MACV,OAAQ;MACR,WAAY;KACZ,CAAA;KAGC,eACD,iBAAA,GAAA,kBAAA,IAAA,CAACE,+BAAAA,gBAAD;MACC,UAAW,MAAM;MACjB,eAAgB;MAChB,WAAY;MACZ,YAAa;KACb,CAAA;KAIF,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAD;MACC,UAAW,MAAM;MACjB,eAAgB;MAChB,WAAY;MACZ,cAAe;MACf,eAAgB;MAChB,aAAc;MACd,UAAW;MACG;MACC;MACf,kBAAmB,mBAAmB;MACtC,mBAAoB;MACP;MACC;MACC;MACM;KACrB,CAAA;MAGG,aAAa,QAAQ,sBACxB,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAAA,aAAD;MACC,UAAW,MAAM;MACjB,eAAgB;MAChB,WAAY;KACZ,CAAA;KAIA,gBAAgB,cACjB,iBAAA,GAAA,kBAAA,IAAA,CAACC,kCAAAA,mBAAD;MACC,UAAW,MAAM;MACjB,eAAgB;MAChB,WAAY;MACG;MACf,aAAc,WAAW;MACzB,cAAe,WAAW;KAC1B,CAAA;IAEE;GACD,CAAA,CAAA;;CACD,CAAA;AAEP;AAEA,MAAM,uBAAA,GAAsBC,mBAAAA,WAAAA,CAC3B,YACD;AAEA,MAAa,WAAA,GAAUA,mBAAAA,WAAAA,EACpB,OAAO,QACR,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,kBAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,qBAAD;CAAqB,GAAK;CAAc;AAAO,CAAA,EAC9B,CAAA,CAEpB"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let __cropper_tsx = require("./cropper.cjs");
7
- let __cropper_provider_tsx = require("./cropper-provider.cjs");
8
- Object.defineProperty(exports, "Cropper", {
9
- enumerable: true,
10
- get: function() {
11
- return __cropper_tsx.Cropper;
12
- }
13
- });
14
- Object.defineProperty(exports, "CropperProvider", {
15
- enumerable: true,
16
- get: function() {
17
- return __cropper_provider_tsx.CropperProvider;
18
- }
19
- });
20
- Object.defineProperty(exports, "useCropper", {
21
- enumerable: true,
22
- get: function() {
23
- return __cropper_provider_tsx.useCropper;
24
- }
25
- });
@@ -1,147 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let _wordpress_element = require("@wordpress/element");
7
- let react_jsx_runtime = require("react/jsx-runtime");
8
- // packages/media-editor/src/image-editor/react/components/overlays/dimensions-overlay.tsx
9
- const HANDLE_GAP_PX = 12;
10
- const TRANSLATE_PERCENT = {
11
- before: "-100%",
12
- center: "-50%",
13
- after: "0"
14
- };
15
- const GAP_DIRECTION = {
16
- before: -1,
17
- center: 0,
18
- after: 1
19
- };
20
- const OPPOSITE_SIDE = {
21
- before: "after",
22
- center: "center",
23
- after: "before"
24
- };
25
- /**
26
- * Preferred anchor for a handle, before edge-clipping is considered:
27
- * tooltip sits outward from the crop rectangle's center.
28
- *
29
- * @param handle
30
- */
31
- function preferredAnchor(handle) {
32
- let x = "center";
33
- if (handle.includes("w")) x = "before";
34
- else if (handle.includes("e")) x = "after";
35
- let y = "center";
36
- if (handle.includes("n")) y = "before";
37
- else if (handle.includes("s")) y = "after";
38
- return {
39
- x,
40
- y
41
- };
42
- }
43
- /**
44
- * Start coordinate of a tooltip placed on the given side of `handlePos`,
45
- * accounting for the per-side handle gap and the tooltip's own length.
46
- *
47
- * @param side
48
- * @param handlePos
49
- * @param length
50
- */
51
- function sideStart(side, handlePos, length) {
52
- if (side === "before") return handlePos - HANDLE_GAP_PX - length;
53
- if (side === "after") return handlePos + HANDLE_GAP_PX;
54
- return handlePos - length / 2;
55
- }
56
- /**
57
- * Picks a side that keeps the tooltip inside the container along one
58
- * axis, preferring the supplied side and falling back to its opposite,
59
- * then center.
60
- *
61
- * @param preferred
62
- * @param handlePos
63
- * @param length
64
- * @param containerLength
65
- */
66
- function fittingSide(preferred, handlePos, length, containerLength) {
67
- const fits = (side) => {
68
- const start = sideStart(side, handlePos, length);
69
- return start >= 0 && start + length <= containerLength;
70
- };
71
- if (fits(preferred)) return preferred;
72
- const opposite = OPPOSITE_SIDE[preferred];
73
- if (opposite !== preferred && fits(opposite)) return opposite;
74
- if (preferred !== "center" && fits("center")) return "center";
75
- const overflow = (side) => {
76
- const start = sideStart(side, handlePos, length);
77
- return Math.max(0, -start) + Math.max(0, start + length - containerLength);
78
- };
79
- return [
80
- preferred,
81
- opposite,
82
- "center"
83
- ].reduce((best, side) => overflow(side) < overflow(best) ? side : best);
84
- }
85
- /**
86
- * Tooltip that follows the active resize handle during a pointer drag,
87
- * showing the current output dimensions of the crop in source pixels.
88
- *
89
- * Renders nothing outside of a pointer-driven resize, so keyboard
90
- * arrow-key adjustments and pan/zoom gestures stay quiet.
91
- *
92
- * @param props
93
- * @param props.cropRect
94
- * @param props.containerSize
95
- * @param props.imageSize
96
- * @param props.activeHandle
97
- * @param props.outputWidth
98
- * @param props.outputHeight
99
- */
100
- function DimensionsOverlay({ cropRect, containerSize, imageSize, activeHandle, outputWidth, outputHeight }) {
101
- const tooltipRef = (0, _wordpress_element.useRef)(null);
102
- const [tooltipSize, setTooltipSize] = (0, _wordpress_element.useState)(null);
103
- (0, _wordpress_element.useLayoutEffect)(() => {
104
- if (!tooltipRef.current) return;
105
- const rect = tooltipRef.current.getBoundingClientRect();
106
- setTooltipSize((prev) => {
107
- if (prev && prev.width === rect.width && prev.height === rect.height) return prev;
108
- return {
109
- width: rect.width,
110
- height: rect.height
111
- };
112
- });
113
- }, [outputWidth, outputHeight]);
114
- if (!activeHandle || containerSize.width === 0 || containerSize.height === 0) return null;
115
- const offsetX = (containerSize.width - imageSize.width) / 2;
116
- const offsetY = (containerSize.height - imageSize.height) / 2;
117
- const left = offsetX + cropRect.x * imageSize.width;
118
- const top = offsetY + cropRect.y * imageSize.height;
119
- const width = cropRect.width * imageSize.width;
120
- const height = cropRect.height * imageSize.height;
121
- let handleX = left + width / 2;
122
- if (activeHandle.includes("w")) handleX = left;
123
- else if (activeHandle.includes("e")) handleX = left + width;
124
- let handleY = top + height / 2;
125
- if (activeHandle.includes("n")) handleY = top;
126
- else if (activeHandle.includes("s")) handleY = top + height;
127
- const preferred = preferredAnchor(activeHandle);
128
- const anchor = tooltipSize ? {
129
- x: fittingSide(preferred.x, handleX, tooltipSize.width, containerSize.width),
130
- y: fittingSide(preferred.y, handleY, tooltipSize.height, containerSize.height)
131
- } : preferred;
132
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
133
- ref: tooltipRef,
134
- className: "wp-media-editor-image-editor__dimensions-tooltip",
135
- "data-testid": "cropper-dimensions-tooltip",
136
- style: {
137
- left: handleX + GAP_DIRECTION[anchor.x] * HANDLE_GAP_PX,
138
- top: handleY + GAP_DIRECTION[anchor.y] * HANDLE_GAP_PX,
139
- transform: `translate(${TRANSLATE_PERCENT[anchor.x]}, ${TRANSLATE_PERCENT[anchor.y]})`
140
- },
141
- "aria-hidden": "true",
142
- children: `W: ${Math.round(outputWidth)}px H: ${Math.round(outputHeight)}px`
143
- });
144
- }
145
- exports.DimensionsOverlay = DimensionsOverlay;
146
-
147
- //# sourceMappingURL=dimensions-overlay.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dimensions-overlay.cjs","names":["useRef","useState"],"sources":["../../../../../src/image-editor/react/components/overlays/dimensions-overlay.tsx"],"sourcesContent":["import { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport type { HandlePosition, NormalizedRect, Size } from '../../../core/types';\n\nconst HANDLE_GAP_PX = 12;\n\n/**\n * Which side of the handle a tooltip axis sits on. `before` places the\n * tooltip on the negative side of the handle (above for Y, left for X),\n * `after` on the positive side, `center` keeps it aligned with the handle.\n */\ntype AxisSide = 'before' | 'center' | 'after';\n\ninterface Anchor {\n\tx: AxisSide;\n\ty: AxisSide;\n}\n\nconst TRANSLATE_PERCENT: Record< AxisSide, string > = {\n\tbefore: '-100%',\n\tcenter: '-50%',\n\tafter: '0',\n};\n\nconst GAP_DIRECTION: Record< AxisSide, number > = {\n\tbefore: -1,\n\tcenter: 0,\n\tafter: 1,\n};\n\nconst OPPOSITE_SIDE: Record< AxisSide, AxisSide > = {\n\tbefore: 'after',\n\tcenter: 'center',\n\tafter: 'before',\n};\n\n/**\n * Preferred anchor for a handle, before edge-clipping is considered:\n * tooltip sits outward from the crop rectangle's center.\n *\n * @param handle\n */\nfunction preferredAnchor( handle: HandlePosition ): Anchor {\n\tlet x: AxisSide = 'center';\n\tif ( handle.includes( 'w' ) ) {\n\t\tx = 'before';\n\t} else if ( handle.includes( 'e' ) ) {\n\t\tx = 'after';\n\t}\n\n\tlet y: AxisSide = 'center';\n\tif ( handle.includes( 'n' ) ) {\n\t\ty = 'before';\n\t} else if ( handle.includes( 's' ) ) {\n\t\ty = 'after';\n\t}\n\n\treturn { x, y };\n}\n\n/**\n * Start coordinate of a tooltip placed on the given side of `handlePos`,\n * accounting for the per-side handle gap and the tooltip's own length.\n *\n * @param side\n * @param handlePos\n * @param length\n */\nfunction sideStart(\n\tside: AxisSide,\n\thandlePos: number,\n\tlength: number\n): number {\n\tif ( side === 'before' ) {\n\t\treturn handlePos - HANDLE_GAP_PX - length;\n\t}\n\tif ( side === 'after' ) {\n\t\treturn handlePos + HANDLE_GAP_PX;\n\t}\n\treturn handlePos - length / 2;\n}\n\n/**\n * Picks a side that keeps the tooltip inside the container along one\n * axis, preferring the supplied side and falling back to its opposite,\n * then center.\n *\n * @param preferred\n * @param handlePos\n * @param length\n * @param containerLength\n */\nfunction fittingSide(\n\tpreferred: AxisSide,\n\thandlePos: number,\n\tlength: number,\n\tcontainerLength: number\n): AxisSide {\n\tconst fits = ( side: AxisSide ) => {\n\t\tconst start = sideStart( side, handlePos, length );\n\t\treturn start >= 0 && start + length <= containerLength;\n\t};\n\n\tif ( fits( preferred ) ) {\n\t\treturn preferred;\n\t}\n\tconst opposite = OPPOSITE_SIDE[ preferred ];\n\tif ( opposite !== preferred && fits( opposite ) ) {\n\t\treturn opposite;\n\t}\n\tif ( preferred !== 'center' && fits( 'center' ) ) {\n\t\treturn 'center';\n\t}\n\t// None of the candidates fully fit — pick the one that pushes the\n\t// least past the container edge. Without this, the chain falls back\n\t// to `preferred`, which is the off-canvas side that triggered the\n\t// flip in the first place, so the tooltip ends up clipped.\n\tconst overflow = ( side: AxisSide ) => {\n\t\tconst start = sideStart( side, handlePos, length );\n\t\treturn (\n\t\t\tMath.max( 0, -start ) +\n\t\t\tMath.max( 0, start + length - containerLength )\n\t\t);\n\t};\n\tconst candidates: AxisSide[] = [ preferred, opposite, 'center' ];\n\treturn candidates.reduce( ( best, side ) =>\n\t\toverflow( side ) < overflow( best ) ? side : best\n\t);\n}\n\ninterface DimensionsOverlayProps {\n\t/** Crop rectangle in normalized coordinates. */\n\tcropRect: NormalizedRect;\n\t/** Container element dimensions in pixels. */\n\tcontainerSize: Size;\n\t/** Rendered image dimensions in pixels within the container. */\n\timageSize: Size;\n\t/** Currently-dragged handle, or null when no pointer drag is active. */\n\tactiveHandle: HandlePosition | null;\n\t/** Output crop width in source pixels. */\n\toutputWidth: number;\n\t/** Output crop height in source pixels. */\n\toutputHeight: number;\n}\n\n/**\n * Tooltip that follows the active resize handle during a pointer drag,\n * showing the current output dimensions of the crop in source pixels.\n *\n * Renders nothing outside of a pointer-driven resize, so keyboard\n * arrow-key adjustments and pan/zoom gestures stay quiet.\n *\n * @param props\n * @param props.cropRect\n * @param props.containerSize\n * @param props.imageSize\n * @param props.activeHandle\n * @param props.outputWidth\n * @param props.outputHeight\n */\nexport function DimensionsOverlay( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n\tactiveHandle,\n\toutputWidth,\n\toutputHeight,\n}: DimensionsOverlayProps ) {\n\tconst tooltipRef = useRef< HTMLDivElement >( null );\n\tconst [ tooltipSize, setTooltipSize ] = useState< Size | null >( null );\n\n\t// Measure the rendered tooltip so we can flip its anchor when it\n\t// would otherwise be clipped by the cropper's `overflow: hidden`\n\t// root. Runs synchronously before paint, so the user never sees\n\t// the un-flipped position. Tracks `outputWidth`/`outputHeight`\n\t// because they drive the digit count, the only thing that changes\n\t// the tooltip's intrinsic size during a drag.\n\tuseLayoutEffect( () => {\n\t\tif ( ! tooltipRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = tooltipRef.current.getBoundingClientRect();\n\t\tsetTooltipSize( ( prev ) => {\n\t\t\tif (\n\t\t\t\tprev &&\n\t\t\t\tprev.width === rect.width &&\n\t\t\t\tprev.height === rect.height\n\t\t\t) {\n\t\t\t\treturn prev;\n\t\t\t}\n\t\t\treturn { width: rect.width, height: rect.height };\n\t\t} );\n\t}, [ outputWidth, outputHeight ] );\n\n\tif (\n\t\t! activeHandle ||\n\t\tcontainerSize.width === 0 ||\n\t\tcontainerSize.height === 0\n\t) {\n\t\treturn null;\n\t}\n\n\tconst offsetX = ( containerSize.width - imageSize.width ) / 2;\n\tconst offsetY = ( containerSize.height - imageSize.height ) / 2;\n\tconst left = offsetX + cropRect.x * imageSize.width;\n\tconst top = offsetY + cropRect.y * imageSize.height;\n\tconst width = cropRect.width * imageSize.width;\n\tconst height = cropRect.height * imageSize.height;\n\n\t// Handle pixel position within the container. Same math as the\n\t// stencil's handle layout, just keyed by direction here so the\n\t// tooltip can anchor to any of the eight.\n\tlet handleX = left + width / 2;\n\tif ( activeHandle.includes( 'w' ) ) {\n\t\thandleX = left;\n\t} else if ( activeHandle.includes( 'e' ) ) {\n\t\thandleX = left + width;\n\t}\n\tlet handleY = top + height / 2;\n\tif ( activeHandle.includes( 'n' ) ) {\n\t\thandleY = top;\n\t} else if ( activeHandle.includes( 's' ) ) {\n\t\thandleY = top + height;\n\t}\n\n\tconst preferred = preferredAnchor( activeHandle );\n\tconst anchor: Anchor = tooltipSize\n\t\t? {\n\t\t\t\tx: fittingSide(\n\t\t\t\t\tpreferred.x,\n\t\t\t\t\thandleX,\n\t\t\t\t\ttooltipSize.width,\n\t\t\t\t\tcontainerSize.width\n\t\t\t\t),\n\t\t\t\ty: fittingSide(\n\t\t\t\t\tpreferred.y,\n\t\t\t\t\thandleY,\n\t\t\t\t\ttooltipSize.height,\n\t\t\t\t\tcontainerSize.height\n\t\t\t\t),\n\t\t\t}\n\t\t: preferred;\n\n\treturn (\n\t\t<div\n\t\t\tref={ tooltipRef }\n\t\t\tclassName=\"wp-media-editor-image-editor__dimensions-tooltip\"\n\t\t\tdata-testid=\"cropper-dimensions-tooltip\"\n\t\t\tstyle={ {\n\t\t\t\tleft: handleX + GAP_DIRECTION[ anchor.x ] * HANDLE_GAP_PX,\n\t\t\t\ttop: handleY + GAP_DIRECTION[ anchor.y ] * HANDLE_GAP_PX,\n\t\t\t\ttransform: `translate(${ TRANSLATE_PERCENT[ anchor.x ] }, ${\n\t\t\t\t\tTRANSLATE_PERCENT[ anchor.y ]\n\t\t\t\t})`,\n\t\t\t} }\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t{ `W: ${ Math.round( outputWidth ) }px H: ${ Math.round(\n\t\t\t\toutputHeight\n\t\t\t) }px` }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,MAAM,gBAAgB;AActB,MAAM,oBAAgD;CACrD,QAAQ;CACR,QAAQ;CACR,OAAO;AACR;AAEA,MAAM,gBAA4C;CACjD,QAAQ;CACR,QAAQ;CACR,OAAO;AACR;AAEA,MAAM,gBAA8C;CACnD,QAAQ;CACR,QAAQ;CACR,OAAO;AACR;;;;;;;AAQA,SAAS,gBAAiB,QAAiC;CAC1D,IAAI,IAAc;CAClB,IAAK,OAAO,SAAU,GAAI,GACzB,IAAI;MACE,IAAK,OAAO,SAAU,GAAI,GAChC,IAAI;C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AAEP"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let react_jsx_runtime = require("react/jsx-runtime");
7
- // packages/media-editor/src/image-editor/react/components/overlays/dimming-overlay.tsx
8
- function DimmingOverlay({ cropRect, containerSize, imageSize, transition }) {
9
- if (containerSize.width === 0 || containerSize.height === 0) return null;
10
- const offsetX = (containerSize.width - imageSize.width) / 2;
11
- const offsetY = (containerSize.height - imageSize.height) / 2;
12
- const left = offsetX + cropRect.x * imageSize.width;
13
- const top = offsetY + cropRect.y * imageSize.height;
14
- const width = cropRect.width * imageSize.width;
15
- const height = cropRect.height * imageSize.height;
16
- const composedTransition = transition ? `${transition}, box-shadow 0.15s ease` : void 0;
17
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
18
- className: "wp-media-editor-image-editor__dimming",
19
- "data-testid": "cropper-dimming",
20
- style: {
21
- left,
22
- top,
23
- width,
24
- height,
25
- transition: composedTransition
26
- }
27
- });
28
- }
29
- exports.DimmingOverlay = DimmingOverlay;
30
-
31
- //# sourceMappingURL=dimming-overlay.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dimming-overlay.cjs","names":[],"sources":["../../../../../src/image-editor/react/components/overlays/dimming-overlay.tsx"],"sourcesContent":["import type { NormalizedRect, Size } from '../../../core/types';\n\n/**\n * Props for the DimmingOverlay component.\n */\ninterface DimmingOverlayProps {\n\t/** The crop rectangle in normalized coordinates. */\n\tcropRect: NormalizedRect;\n\t/** The container element dimensions in pixels. */\n\tcontainerSize: Size;\n\t/** The rendered image dimensions in pixels within the container. */\n\timageSize: Size;\n\t/** CSS transition string, e.g. during settle animation. */\n\ttransition?: string;\n}\n\n// Renders a semi-transparent overlay outside the crop rectangle using a\n// box-shadow that dims everything outside the crop rect position.\nexport function DimmingOverlay( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n\ttransition,\n}: DimmingOverlayProps ) {\n\tif ( containerSize.width === 0 || containerSize.height === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst offsetX = ( containerSize.width - imageSize.width ) / 2;\n\tconst offsetY = ( containerSize.height - imageSize.height ) / 2;\n\tconst left = offsetX + cropRect.x * imageSize.width;\n\tconst top = offsetY + cropRect.y * imageSize.height;\n\tconst width = cropRect.width * imageSize.width;\n\tconst height = cropRect.height * imageSize.height;\n\n\t// Compose any incoming transition with the stylesheet's box-shadow\n\t// transition so the drag-dimming effect isn't overwritten.\n\tconst composedTransition = transition\n\t\t? `${ transition }, box-shadow 0.15s ease`\n\t\t: undefined;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wp-media-editor-image-editor__dimming\"\n\t\t\tdata-testid=\"cropper-dimming\"\n\t\t\tstyle={ {\n\t\t\t\tleft,\n\t\t\t\ttop,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\ttransition: composedTransition,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,eAAgB,EAC/B,UACA,eACA,WACA,cACwB;CACxB,IAAK,cAAc,UAAU,KAAK,cAAc,WAAW,GAC1D,OAAO;CAGR,MAAM,WAAY,cAAc,QAAQ,UAAU,SAAU;CAC5D,MAAM,WAAY,cAAc,SAAS,UAAU,UAAW;CAC9D,MAAM,OAAO,UAAU,SAAS,IAAI,UAAU;CAC9C,MAAM,MAAM,UAAU,SAAS,IAAI,UAAU;CAC7C,MAAM,QAAQ,SAAS,QAAQ,UAAU;CACzC,MAAM,SAAS,SAAS,SAAS,UAAU;CAI3C,MAAM,qBAAqB,aACxB,GAAI,WAAY,2BAChB,KAAA;CAEH,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACC,WAAU;EACV,eAAY;EACZ,OAAQ;GACP;GACA;GACA;GACA;GACA,YAAY;EACb;CACA,CAAA;AAEH"}
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let react_jsx_runtime = require("react/jsx-runtime");
7
- // packages/media-editor/src/image-editor/react/components/overlays/grid-overlay.tsx
8
- /**
9
- * Renders a rule-of-thirds grid inside the crop rectangle.
10
- *
11
- * Displays 2 horizontal and 2 vertical lines at 1/3 and 2/3
12
- * positions within the crop area.
13
- *
14
- * @param props Component props.
15
- * @param props.cropRect The crop rectangle in normalized coordinates.
16
- * @param props.containerSize The container element dimensions in pixels.
17
- * @param props.imageSize The rendered image dimensions in pixels.
18
- * @return The grid overlay element.
19
- */
20
- function GridOverlay({ cropRect, containerSize, imageSize }) {
21
- if (containerSize.width === 0 || containerSize.height === 0) return null;
22
- const offsetX = (containerSize.width - imageSize.width) / 2;
23
- const offsetY = (containerSize.height - imageSize.height) / 2;
24
- const left = offsetX + cropRect.x * imageSize.width;
25
- const top = offsetY + cropRect.y * imageSize.height;
26
- const width = cropRect.width * imageSize.width;
27
- const height = cropRect.height * imageSize.height;
28
- const thirdW = width / 3;
29
- const thirdH = height / 3;
30
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
31
- className: "wp-media-editor-image-editor__grid",
32
- "data-testid": "cropper-grid",
33
- style: {
34
- left,
35
- top,
36
- width,
37
- height
38
- },
39
- children: [
40
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
41
- className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
42
- style: { top: thirdH }
43
- }),
44
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
45
- className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
46
- style: { top: thirdH * 2 }
47
- }),
48
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
49
- className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
50
- style: { left: thirdW }
51
- }),
52
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
53
- className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
54
- style: { left: thirdW * 2 }
55
- })
56
- ]
57
- });
58
- }
59
- exports.GridOverlay = GridOverlay;
60
-
61
- //# sourceMappingURL=grid-overlay.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grid-overlay.cjs","names":[],"sources":["../../../../../src/image-editor/react/components/overlays/grid-overlay.tsx"],"sourcesContent":["import type { NormalizedRect, Size } from '../../../core/types';\n\n/**\n * Props for the GridOverlay component.\n */\ninterface GridOverlayProps {\n\t/** The crop rectangle in normalized coordinates. */\n\tcropRect: NormalizedRect;\n\t/** The container element dimensions in pixels. */\n\tcontainerSize: Size;\n\t/** The rendered image dimensions in pixels within the container. */\n\timageSize: Size;\n}\n\n/**\n * Renders a rule-of-thirds grid inside the crop rectangle.\n *\n * Displays 2 horizontal and 2 vertical lines at 1/3 and 2/3\n * positions within the crop area.\n *\n * @param props Component props.\n * @param props.cropRect The crop rectangle in normalized coordinates.\n * @param props.containerSize The container element dimensions in pixels.\n * @param props.imageSize The rendered image dimensions in pixels.\n * @return The grid overlay element.\n */\nexport function GridOverlay( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n}: GridOverlayProps ) {\n\tif ( containerSize.width === 0 || containerSize.height === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst offsetX = ( containerSize.width - imageSize.width ) / 2;\n\tconst offsetY = ( containerSize.height - imageSize.height ) / 2;\n\tconst left = offsetX + cropRect.x * imageSize.width;\n\tconst top = offsetY + cropRect.y * imageSize.height;\n\tconst width = cropRect.width * imageSize.width;\n\tconst height = cropRect.height * imageSize.height;\n\n\tconst thirdW = width / 3;\n\tconst thirdH = height / 3;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wp-media-editor-image-editor__grid\"\n\t\t\tdata-testid=\"cropper-grid\"\n\t\t\tstyle={ {\n\t\t\t\tleft,\n\t\t\t\ttop,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t} }\n\t\t>\n\t\t\t{ /* Horizontal lines at 1/3 and 2/3 */ }\n\t\t\t<div\n\t\t\t\tclassName=\"wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal\"\n\t\t\t\tstyle={ { top: thirdH } }\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tclassName=\"wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal\"\n\t\t\t\tstyle={ { top: thirdH * 2 } }\n\t\t\t/>\n\t\t\t{ /* Vertical lines at 1/3 and 2/3 */ }\n\t\t\t<div\n\t\t\t\tclassName=\"wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical\"\n\t\t\t\tstyle={ { left: thirdW } }\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tclassName=\"wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical\"\n\t\t\t\tstyle={ { left: thirdW * 2 } }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,YAAa,EAC5B,UACA,eACA,aACqB;CACrB,IAAK,cAAc,UAAU,KAAK,cAAc,WAAW,GAC1D,OAAO;CAGR,MAAM,WAAY,cAAc,QAAQ,UAAU,SAAU;CAC5D,MAAM,WAAY,cAAc,SAAS,UAAU,UAAW;CAC9D,MAAM,OAAO,UAAU,SAAS,IAAI,UAAU;CAC9C,MAAM,MAAM,UAAU,SAAS,IAAI,UAAU;CAC7C,MAAM,QAAQ,SAAS,QAAQ,UAAU;CACzC,MAAM,SAAS,SAAS,SAAS,UAAU;CAE3C,MAAM,SAAS,QAAQ;CACvB,MAAM,SAAS,SAAS;CAExB,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EACC,WAAU;EACV,eAAY;EACZ,OAAQ;GACP;GACA;GACA;GACA;EACD;EARD,UAAA;GAWC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IACC,WAAU;IACV,OAAQ,EAAE,KAAK,OAAO;GACtB,CAAA;GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IACC,WAAU;IACV,OAAQ,EAAE,KAAK,SAAS,EAAE;GAC1B,CAAA;GAED,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IACC,WAAU;IACV,OAAQ,EAAE,MAAM,OAAO;GACvB,CAAA;GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IACC,WAAU;IACV,OAAQ,EAAE,MAAM,SAAS,EAAE;GAC3B,CAAA;EACG;;AAEP"}