@wordpress/media-editor 0.9.0 → 0.10.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 (292) hide show
  1. package/build/components/media-editor/index.cjs +34 -135
  2. package/build/components/media-editor/index.cjs.map +3 -3
  3. package/build/components/media-editor/use-crop-options.cjs +87 -0
  4. package/build/components/media-editor/use-crop-options.cjs.map +7 -0
  5. package/build/components/media-editor/use-save-media-editor.cjs +185 -0
  6. package/build/components/media-editor/use-save-media-editor.cjs.map +7 -0
  7. package/build/components/media-editor-canvas/index.cjs +32 -11
  8. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  9. package/build/components/media-editor-crop-panel/index.cjs +66 -83
  10. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  11. package/build/components/media-editor-modal/index.cjs +40 -11
  12. package/build/components/media-editor-modal/index.cjs.map +3 -3
  13. package/build/components/media-editor-toolbar/index.cjs +7 -3
  14. package/build/components/media-editor-toolbar/index.cjs.map +2 -2
  15. package/build/components/media-form/index.cjs +19 -1
  16. package/build/components/media-form/index.cjs.map +3 -3
  17. package/build/components/media-form/sidebar-datetime-view.cjs +53 -0
  18. package/build/components/media-form/sidebar-datetime-view.cjs.map +7 -0
  19. package/build/components/rotation-ruler/index.cjs +8 -2
  20. package/build/components/rotation-ruler/index.cjs.map +2 -2
  21. package/build/hooks/use-crop-gesture-handlers.cjs +41 -4
  22. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  23. package/build/image-editor/core/camera.cjs +29 -11
  24. package/build/image-editor/core/camera.cjs.map +2 -2
  25. package/build/image-editor/core/constants.cjs +6 -0
  26. package/build/image-editor/core/constants.cjs.map +2 -2
  27. package/build/image-editor/core/containment.cjs +71 -34
  28. package/build/image-editor/core/containment.cjs.map +2 -2
  29. package/build/image-editor/core/crop-rect.cjs +48 -0
  30. package/build/image-editor/core/crop-rect.cjs.map +7 -0
  31. package/build/image-editor/core/index.cjs +12 -0
  32. package/build/image-editor/core/index.cjs.map +2 -2
  33. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  34. package/build/image-editor/core/math/sanitize.cjs +92 -0
  35. package/build/image-editor/core/math/sanitize.cjs.map +7 -0
  36. package/build/image-editor/core/setter-helpers.cjs +64 -0
  37. package/build/image-editor/core/setter-helpers.cjs.map +7 -0
  38. package/build/image-editor/core/source-region.cjs +16 -14
  39. package/build/image-editor/core/source-region.cjs.map +2 -2
  40. package/build/image-editor/core/state.cjs +20 -10
  41. package/build/image-editor/core/state.cjs.map +2 -2
  42. package/build/image-editor/core/stencil-math.cjs +31 -20
  43. package/build/image-editor/core/stencil-math.cjs.map +2 -2
  44. package/build/image-editor/core/transform-style.cjs +12 -6
  45. package/build/image-editor/core/transform-style.cjs.map +2 -2
  46. package/build/image-editor/core/types.cjs.map +1 -1
  47. package/build/image-editor/index.cjs +12 -2
  48. package/build/image-editor/index.cjs.map +2 -2
  49. package/build/image-editor/react/components/cropper-provider.cjs +2 -2
  50. package/build/image-editor/react/components/cropper-provider.cjs.map +2 -2
  51. package/build/image-editor/react/components/cropper.cjs +121 -48
  52. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  53. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +172 -0
  54. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +7 -0
  55. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +20 -10
  56. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  57. package/build/image-editor/react/hooks/build-cropper-setters.cjs +71 -0
  58. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +7 -0
  59. package/build/image-editor/react/hooks/index.cjs +6 -3
  60. package/build/image-editor/react/hooks/index.cjs.map +2 -2
  61. package/build/image-editor/react/hooks/use-aria-announcer.cjs +3 -1
  62. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  63. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +113 -0
  64. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +7 -0
  65. package/build/image-editor/react/hooks/use-interaction.cjs +1 -1
  66. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  67. package/build/state/composite-reducer.cjs +115 -0
  68. package/build/state/composite-reducer.cjs.map +7 -0
  69. package/build/state/index.cjs +48 -0
  70. package/build/state/index.cjs.map +7 -0
  71. package/build/state/media-editor-state-provider.cjs +58 -0
  72. package/build/state/media-editor-state-provider.cjs.map +7 -0
  73. package/build/state/types.cjs +34 -0
  74. package/build/state/types.cjs.map +7 -0
  75. package/build/state/use-media-editor-state.cjs +298 -0
  76. package/build/state/use-media-editor-state.cjs.map +7 -0
  77. package/build-module/components/media-editor/index.mjs +40 -140
  78. package/build-module/components/media-editor/index.mjs.map +2 -2
  79. package/build-module/components/media-editor/use-crop-options.mjs +61 -0
  80. package/build-module/components/media-editor/use-crop-options.mjs.map +7 -0
  81. package/build-module/components/media-editor/use-save-media-editor.mjs +151 -0
  82. package/build-module/components/media-editor/use-save-media-editor.mjs.map +7 -0
  83. package/build-module/components/media-editor-canvas/index.mjs +33 -12
  84. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  85. package/build-module/components/media-editor-crop-panel/index.mjs +68 -83
  86. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  87. package/build-module/components/media-editor-modal/index.mjs +40 -11
  88. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  89. package/build-module/components/media-editor-toolbar/index.mjs +7 -3
  90. package/build-module/components/media-editor-toolbar/index.mjs.map +2 -2
  91. package/build-module/components/media-form/index.mjs +9 -1
  92. package/build-module/components/media-form/index.mjs.map +2 -2
  93. package/build-module/components/media-form/sidebar-datetime-view.mjs +32 -0
  94. package/build-module/components/media-form/sidebar-datetime-view.mjs.map +7 -0
  95. package/build-module/components/rotation-ruler/index.mjs +8 -2
  96. package/build-module/components/rotation-ruler/index.mjs.map +2 -2
  97. package/build-module/hooks/use-crop-gesture-handlers.mjs +41 -4
  98. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  99. package/build-module/image-editor/core/camera.mjs +34 -11
  100. package/build-module/image-editor/core/camera.mjs.map +2 -2
  101. package/build-module/image-editor/core/constants.mjs +4 -0
  102. package/build-module/image-editor/core/constants.mjs.map +2 -2
  103. package/build-module/image-editor/core/containment.mjs +75 -34
  104. package/build-module/image-editor/core/containment.mjs.map +2 -2
  105. package/build-module/image-editor/core/crop-rect.mjs +23 -0
  106. package/build-module/image-editor/core/crop-rect.mjs.map +7 -0
  107. package/build-module/image-editor/core/index.mjs +12 -0
  108. package/build-module/image-editor/core/index.mjs.map +2 -2
  109. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  110. package/build-module/image-editor/core/math/sanitize.mjs +63 -0
  111. package/build-module/image-editor/core/math/sanitize.mjs.map +7 -0
  112. package/build-module/image-editor/core/setter-helpers.mjs +39 -0
  113. package/build-module/image-editor/core/setter-helpers.mjs.map +7 -0
  114. package/build-module/image-editor/core/source-region.mjs +16 -14
  115. package/build-module/image-editor/core/source-region.mjs.map +2 -2
  116. package/build-module/image-editor/core/state.mjs +25 -11
  117. package/build-module/image-editor/core/state.mjs.map +2 -2
  118. package/build-module/image-editor/core/stencil-math.mjs +30 -19
  119. package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
  120. package/build-module/image-editor/core/transform-style.mjs +12 -6
  121. package/build-module/image-editor/core/transform-style.mjs.map +2 -2
  122. package/build-module/image-editor/index.mjs +11 -2
  123. package/build-module/image-editor/index.mjs.map +2 -2
  124. package/build-module/image-editor/react/components/cropper-provider.mjs +3 -3
  125. package/build-module/image-editor/react/components/cropper-provider.mjs.map +2 -2
  126. package/build-module/image-editor/react/components/cropper.mjs +122 -49
  127. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  128. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +147 -0
  129. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +7 -0
  130. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +20 -10
  131. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  132. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +46 -0
  133. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +7 -0
  134. package/build-module/image-editor/react/hooks/index.mjs +4 -2
  135. package/build-module/image-editor/react/hooks/index.mjs.map +2 -2
  136. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +3 -1
  137. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  138. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +100 -0
  139. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +7 -0
  140. package/build-module/image-editor/react/hooks/use-interaction.mjs +1 -1
  141. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  142. package/build-module/state/composite-reducer.mjs +94 -0
  143. package/build-module/state/composite-reducer.mjs.map +7 -0
  144. package/build-module/state/index.mjs +26 -0
  145. package/build-module/state/index.mjs.map +7 -0
  146. package/build-module/state/media-editor-state-provider.mjs +34 -0
  147. package/build-module/state/media-editor-state-provider.mjs.map +7 -0
  148. package/build-module/state/types.mjs +9 -0
  149. package/build-module/state/types.mjs.map +7 -0
  150. package/build-module/state/use-media-editor-state.mjs +289 -0
  151. package/build-module/state/use-media-editor-state.mjs.map +7 -0
  152. package/build-style/style-rtl.css +46 -9
  153. package/build-style/style.css +46 -9
  154. package/build-types/components/media-editor/index.d.ts +4 -7
  155. package/build-types/components/media-editor/index.d.ts.map +1 -1
  156. package/build-types/components/media-editor/use-crop-options.d.ts +37 -0
  157. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -0
  158. package/build-types/components/media-editor/use-save-media-editor.d.ts +29 -0
  159. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -0
  160. package/build-types/components/media-editor-canvas/index.d.ts +5 -10
  161. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  162. package/build-types/components/media-editor-crop-panel/index.d.ts +4 -16
  163. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  164. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  165. package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -1
  166. package/build-types/components/media-form/index.d.ts.map +1 -1
  167. package/build-types/components/media-form/sidebar-datetime-view.d.ts +10 -0
  168. package/build-types/components/media-form/sidebar-datetime-view.d.ts.map +1 -0
  169. package/build-types/components/rotation-ruler/index.d.ts.map +1 -1
  170. package/build-types/hooks/use-crop-gesture-handlers.d.ts +13 -14
  171. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  172. package/build-types/image-editor/core/camera.d.ts.map +1 -1
  173. package/build-types/image-editor/core/constants.d.ts +18 -0
  174. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  175. package/build-types/image-editor/core/containment.d.ts +10 -0
  176. package/build-types/image-editor/core/containment.d.ts.map +1 -1
  177. package/build-types/image-editor/core/crop-rect.d.ts +19 -0
  178. package/build-types/image-editor/core/crop-rect.d.ts.map +1 -0
  179. package/build-types/image-editor/core/index.d.ts +3 -1
  180. package/build-types/image-editor/core/index.d.ts.map +1 -1
  181. package/build-types/image-editor/core/interaction-controller.d.ts +5 -1
  182. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  183. package/build-types/image-editor/core/math/sanitize.d.ts +70 -0
  184. package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -0
  185. package/build-types/image-editor/core/setter-helpers.d.ts +24 -0
  186. package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -0
  187. package/build-types/image-editor/core/source-region.d.ts.map +1 -1
  188. package/build-types/image-editor/core/state.d.ts +12 -0
  189. package/build-types/image-editor/core/state.d.ts.map +1 -1
  190. package/build-types/image-editor/core/stencil-math.d.ts +23 -18
  191. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
  192. package/build-types/image-editor/core/transform-style.d.ts.map +1 -1
  193. package/build-types/image-editor/core/types.d.ts +23 -4
  194. package/build-types/image-editor/core/types.d.ts.map +1 -1
  195. package/build-types/image-editor/index.d.ts +4 -4
  196. package/build-types/image-editor/index.d.ts.map +1 -1
  197. package/build-types/image-editor/react/components/cropper-provider.d.ts +11 -7
  198. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  199. package/build-types/image-editor/react/components/cropper.d.ts +6 -4
  200. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  201. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +36 -0
  202. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -0
  203. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +2 -1
  204. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  205. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +47 -0
  206. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -0
  207. package/build-types/image-editor/react/hooks/index.d.ts +4 -2
  208. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -1
  209. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  210. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +58 -0
  211. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -0
  212. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  213. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
  214. package/build-types/state/composite-reducer.d.ts +39 -0
  215. package/build-types/state/composite-reducer.d.ts.map +1 -0
  216. package/build-types/state/index.d.ts +7 -0
  217. package/build-types/state/index.d.ts.map +1 -0
  218. package/build-types/state/media-editor-state-provider.d.ts +34 -0
  219. package/build-types/state/media-editor-state-provider.d.ts.map +1 -0
  220. package/build-types/state/types.d.ts +104 -0
  221. package/build-types/state/types.d.ts.map +1 -0
  222. package/build-types/state/use-media-editor-state.d.ts +104 -0
  223. package/build-types/state/use-media-editor-state.d.ts.map +1 -0
  224. package/package.json +19 -17
  225. package/src/components/media-editor/index.tsx +52 -188
  226. package/src/components/media-editor/test/use-crop-options.tsx +164 -0
  227. package/src/components/media-editor/use-crop-options.ts +115 -0
  228. package/src/components/media-editor/use-save-media-editor.ts +214 -0
  229. package/src/components/media-editor-canvas/index.tsx +56 -24
  230. package/src/components/media-editor-crop-panel/index.tsx +25 -61
  231. package/src/components/media-editor-crop-panel/test/index.tsx +17 -43
  232. package/src/components/media-editor-modal/index.tsx +50 -12
  233. package/src/components/media-editor-modal/test/build-modifiers.test.ts +14 -0
  234. package/src/components/media-editor-modal/test/index.tsx +143 -0
  235. package/src/components/media-editor-toolbar/index.tsx +9 -5
  236. package/src/components/media-form/index.tsx +15 -1
  237. package/src/components/media-form/sidebar-datetime-view.tsx +47 -0
  238. package/src/components/media-form/test/sidebar-datetime-view.test.tsx +96 -0
  239. package/src/components/rotation-ruler/README.md +11 -25
  240. package/src/components/rotation-ruler/index.tsx +17 -2
  241. package/src/components/rotation-ruler/style.scss +49 -13
  242. package/src/hooks/use-crop-gesture-handlers.ts +66 -17
  243. package/src/image-editor/README.md +28 -129
  244. package/src/image-editor/core/camera.ts +51 -26
  245. package/src/image-editor/core/constants.ts +19 -0
  246. package/src/image-editor/core/containment.ts +102 -49
  247. package/src/image-editor/core/crop-rect.ts +45 -0
  248. package/src/image-editor/core/index.ts +16 -4
  249. package/src/image-editor/core/interaction-controller.ts +5 -1
  250. package/src/image-editor/core/math/sanitize.ts +158 -0
  251. package/src/image-editor/core/math/test/sanitize.ts +244 -0
  252. package/src/image-editor/core/setter-helpers.ts +66 -0
  253. package/src/image-editor/core/source-region.ts +21 -14
  254. package/src/image-editor/core/state.ts +67 -15
  255. package/src/image-editor/core/stencil-math.ts +55 -35
  256. package/src/image-editor/core/test/camera.ts +367 -1
  257. package/src/image-editor/core/test/state.ts +101 -8
  258. package/src/image-editor/core/test/stencil-math.ts +193 -0
  259. package/src/image-editor/core/transform-style.ts +21 -6
  260. package/src/image-editor/core/types.ts +24 -4
  261. package/src/image-editor/docs/architecture.md +48 -89
  262. package/src/image-editor/docs/recipes.md +123 -659
  263. package/src/image-editor/index.ts +12 -3
  264. package/src/image-editor/react/components/cropper-provider.tsx +16 -12
  265. package/src/image-editor/react/components/cropper.scss +23 -4
  266. package/src/image-editor/react/components/cropper.tsx +197 -90
  267. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +269 -0
  268. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +22 -9
  269. package/src/image-editor/react/components/test/cropper.tsx +55 -13
  270. package/src/image-editor/react/hooks/build-cropper-setters.ts +105 -0
  271. package/src/image-editor/react/hooks/index.ts +4 -2
  272. package/src/image-editor/react/hooks/test/{use-cropper-state.ts → use-cropper-reducer.ts} +142 -286
  273. package/src/image-editor/react/hooks/use-aria-announcer.ts +3 -1
  274. package/src/image-editor/react/hooks/use-cropper-reducer.ts +204 -0
  275. package/src/image-editor/react/hooks/use-interaction.ts +3 -2
  276. package/src/image-editor/stories/rectangle-crop.story.tsx +7 -17
  277. package/src/state/composite-reducer.ts +152 -0
  278. package/src/state/index.ts +20 -0
  279. package/src/state/media-editor-state-provider.tsx +70 -0
  280. package/src/state/test/use-media-editor-state.ts +402 -0
  281. package/src/state/types.ts +107 -0
  282. package/src/state/use-media-editor-state.ts +488 -0
  283. package/tsconfig.json +2 -0
  284. package/tsconfig.tsbuildinfo +1 -1
  285. package/build/image-editor/react/hooks/use-cropper-state.cjs +0 -277
  286. package/build/image-editor/react/hooks/use-cropper-state.cjs.map +0 -7
  287. package/build-module/image-editor/react/hooks/use-cropper-state.mjs +0 -262
  288. package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +0 -7
  289. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +0 -97
  290. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +0 -1
  291. package/src/image-editor/docs/roadmap.md +0 -66
  292. package/src/image-editor/react/hooks/use-cropper-state.ts +0 -457
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/image-editor/react/components/overlays/dimensions-overlay.tsx
21
+ var dimensions_overlay_exports = {};
22
+ __export(dimensions_overlay_exports, {
23
+ DimensionsOverlay: () => DimensionsOverlay
24
+ });
25
+ module.exports = __toCommonJS(dimensions_overlay_exports);
26
+ var import_element = require("@wordpress/element");
27
+ var import_jsx_runtime = require("react/jsx-runtime");
28
+ var HANDLE_GAP_PX = 12;
29
+ var TRANSLATE_PERCENT = {
30
+ before: "-100%",
31
+ center: "-50%",
32
+ after: "0"
33
+ };
34
+ var GAP_DIRECTION = {
35
+ before: -1,
36
+ center: 0,
37
+ after: 1
38
+ };
39
+ var OPPOSITE_SIDE = {
40
+ before: "after",
41
+ center: "center",
42
+ after: "before"
43
+ };
44
+ function preferredAnchor(handle) {
45
+ let x = "center";
46
+ if (handle.includes("w")) {
47
+ x = "before";
48
+ } else if (handle.includes("e")) {
49
+ x = "after";
50
+ }
51
+ let y = "center";
52
+ if (handle.includes("n")) {
53
+ y = "before";
54
+ } else if (handle.includes("s")) {
55
+ y = "after";
56
+ }
57
+ return { x, y };
58
+ }
59
+ function sideStart(side, handlePos, length) {
60
+ if (side === "before") {
61
+ return handlePos - HANDLE_GAP_PX - length;
62
+ }
63
+ if (side === "after") {
64
+ return handlePos + HANDLE_GAP_PX;
65
+ }
66
+ return handlePos - length / 2;
67
+ }
68
+ function fittingSide(preferred, handlePos, length, containerLength) {
69
+ const fits = (side) => {
70
+ const start = sideStart(side, handlePos, length);
71
+ return start >= 0 && start + length <= containerLength;
72
+ };
73
+ if (fits(preferred)) {
74
+ return preferred;
75
+ }
76
+ const opposite = OPPOSITE_SIDE[preferred];
77
+ if (opposite !== preferred && fits(opposite)) {
78
+ return opposite;
79
+ }
80
+ if (preferred !== "center" && fits("center")) {
81
+ return "center";
82
+ }
83
+ const overflow = (side) => {
84
+ const start = sideStart(side, handlePos, length);
85
+ return Math.max(0, -start) + Math.max(0, start + length - containerLength);
86
+ };
87
+ const candidates = [preferred, opposite, "center"];
88
+ return candidates.reduce(
89
+ (best, side) => overflow(side) < overflow(best) ? side : best
90
+ );
91
+ }
92
+ function DimensionsOverlay({
93
+ cropRect,
94
+ containerSize,
95
+ imageSize,
96
+ activeHandle,
97
+ outputWidth,
98
+ outputHeight
99
+ }) {
100
+ const tooltipRef = (0, import_element.useRef)(null);
101
+ const [tooltipSize, setTooltipSize] = (0, import_element.useState)(null);
102
+ (0, import_element.useLayoutEffect)(() => {
103
+ if (!tooltipRef.current) {
104
+ return;
105
+ }
106
+ const rect = tooltipRef.current.getBoundingClientRect();
107
+ setTooltipSize((prev) => {
108
+ if (prev && prev.width === rect.width && prev.height === rect.height) {
109
+ return prev;
110
+ }
111
+ return { width: rect.width, height: rect.height };
112
+ });
113
+ }, [outputWidth, outputHeight]);
114
+ if (!activeHandle || containerSize.width === 0 || containerSize.height === 0) {
115
+ return null;
116
+ }
117
+ const offsetX = (containerSize.width - imageSize.width) / 2;
118
+ const offsetY = (containerSize.height - imageSize.height) / 2;
119
+ const left = offsetX + cropRect.x * imageSize.width;
120
+ const top = offsetY + cropRect.y * imageSize.height;
121
+ const width = cropRect.width * imageSize.width;
122
+ const height = cropRect.height * imageSize.height;
123
+ let handleX = left + width / 2;
124
+ if (activeHandle.includes("w")) {
125
+ handleX = left;
126
+ } else if (activeHandle.includes("e")) {
127
+ handleX = left + width;
128
+ }
129
+ let handleY = top + height / 2;
130
+ if (activeHandle.includes("n")) {
131
+ handleY = top;
132
+ } else if (activeHandle.includes("s")) {
133
+ handleY = top + height;
134
+ }
135
+ const preferred = preferredAnchor(activeHandle);
136
+ const anchor = tooltipSize ? {
137
+ x: fittingSide(
138
+ preferred.x,
139
+ handleX,
140
+ tooltipSize.width,
141
+ containerSize.width
142
+ ),
143
+ y: fittingSide(
144
+ preferred.y,
145
+ handleY,
146
+ tooltipSize.height,
147
+ containerSize.height
148
+ )
149
+ } : preferred;
150
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
151
+ "div",
152
+ {
153
+ ref: tooltipRef,
154
+ className: "wp-media-editor-image-editor__dimensions-tooltip",
155
+ "data-testid": "cropper-dimensions-tooltip",
156
+ style: {
157
+ left: handleX + GAP_DIRECTION[anchor.x] * HANDLE_GAP_PX,
158
+ top: handleY + GAP_DIRECTION[anchor.y] * HANDLE_GAP_PX,
159
+ transform: `translate(${TRANSLATE_PERCENT[anchor.x]}, ${TRANSLATE_PERCENT[anchor.y]})`
160
+ },
161
+ "aria-hidden": "true",
162
+ children: `W: ${Math.round(outputWidth)}px H: ${Math.round(
163
+ outputHeight
164
+ )}px`
165
+ }
166
+ );
167
+ }
168
+ // Annotate the CommonJS export names for ESM import in node:
169
+ 0 && (module.exports = {
170
+ DimensionsOverlay
171
+ });
172
+ //# sourceMappingURL=dimensions-overlay.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/image-editor/react/components/overlays/dimensions-overlay.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\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 \u2014 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 }\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkD;AAuPhD;AAhPF,IAAM,gBAAgB;AActB,IAAM,oBAAgD;AAAA,EACrD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AACR;AAEA,IAAM,gBAA4C;AAAA,EACjD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AACR;AAEA,IAAM,gBAA8C;AAAA,EAC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AAA,IACA,GAAG;AAAA,MACF,UAAU;AAAA,MACV;AAAA,MACA,YAAY;AAAA,MACZ,cAAc;AAAA,IACf;AAAA,IACA,GAAG;AAAA,MACF,UAAU;AAAA,MACV;AAAA,MACA,YAAY;AAAA,MACZ,cAAc;AAAA,IACf;AAAA,EACA,IACA;AAEH,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAM;AAAA,MACN,WAAU;AAAA,MACV,eAAY;AAAA,MACZ,OAAQ;AAAA,QACP,MAAM,UAAU,cAAe,OAAO,CAAE,IAAI;AAAA,QAC5C,KAAK,UAAU,cAAe,OAAO,CAAE,IAAI;AAAA,QAC3C,WAAW,aAAc,kBAAmB,OAAO,CAAE,CAAE,KACtD,kBAAmB,OAAO,CAAE,CAC7B;AAAA,MACD;AAAA,MACA,eAAY;AAAA,MAEV,gBAAO,KAAK,MAAO,WAAY,CAAE,SAAU,KAAK;AAAA,QACjD;AAAA,MACD,CAAE;AAAA;AAAA,EACH;AAEF;",
6
+ "names": []
7
+ }
@@ -72,7 +72,8 @@ function RectangleStencil({
72
72
  freeformCrop = false,
73
73
  stencilTransition,
74
74
  cropBounds,
75
- onEscape
75
+ onEscape,
76
+ minCropSize
76
77
  }) {
77
78
  const boundsMinX = cropBounds?.minX ?? 0;
78
79
  const boundsMinY = cropBounds?.minY ?? 0;
@@ -87,7 +88,7 @@ function RectangleStencil({
87
88
  }),
88
89
  [boundsMinX, boundsMinY, boundsMaxX, boundsMaxY]
89
90
  );
90
- const keyboardSettleTimerRef = (0, import_element.useRef)();
91
+ const keyboardSettleTimerRef = (0, import_element.useRef)(void 0);
91
92
  const keyboardResizeActiveRef = (0, import_element.useRef)(false);
92
93
  const resizeHandleDescriptionId = (0, import_element.useId)();
93
94
  const hasLockedRatio = !!(aspectRatio && aspectRatio > 0);
@@ -181,15 +182,22 @@ function RectangleStencil({
181
182
  el.addEventListener("pointermove", onMove);
182
183
  el.addEventListener("pointerup", onEnd);
183
184
  el.addEventListener("lostpointercapture", onEnd);
184
- onResizeStart?.();
185
+ onResizeStart?.(handle);
185
186
  clearTimeout(keyboardSettleTimerRef.current);
186
187
  keyboardResizeActiveRef.current = false;
187
188
  },
188
189
  [cropRect, onResizeStart]
189
190
  );
190
191
  const computeFreeRect = (0, import_element.useCallback)(
191
- (drag, clientX, clientY) => (0, import_stencil_math.computeFreeResizeRect)(drag, clientX, clientY, imageSize, bounds),
192
- [imageSize, bounds]
192
+ (drag, clientX, clientY) => (0, import_stencil_math.computeFreeResizeRect)(
193
+ drag,
194
+ clientX,
195
+ clientY,
196
+ imageSize,
197
+ bounds,
198
+ minCropSize
199
+ ),
200
+ [imageSize, bounds, minCropSize]
193
201
  );
194
202
  const computeLockedRect = (0, import_element.useCallback)(
195
203
  (drag, clientX, clientY) => (0, import_stencil_math.computeLockedResizeRect)(
@@ -198,9 +206,10 @@ function RectangleStencil({
198
206
  clientY,
199
207
  imageSize,
200
208
  bounds,
201
- normalizedRatio
209
+ normalizedRatio,
210
+ minCropSize
202
211
  ),
203
- [imageSize, bounds, normalizedRatio]
212
+ [imageSize, bounds, normalizedRatio, minCropSize]
204
213
  );
205
214
  const computeShiftLockedRect = (0, import_element.useCallback)(
206
215
  (drag, clientX, clientY) => (0, import_stencil_math.computeShiftLockedResizeRect)(
@@ -208,9 +217,10 @@ function RectangleStencil({
208
217
  clientX,
209
218
  clientY,
210
219
  imageSize,
211
- bounds
220
+ bounds,
221
+ minCropSize
212
222
  ),
213
- [imageSize, bounds]
223
+ [imageSize, bounds, minCropSize]
214
224
  );
215
225
  latestHandlersRef.current = {
216
226
  hasLockedRatio,
@@ -236,7 +246,7 @@ function RectangleStencil({
236
246
  event.stopPropagation();
237
247
  if (!keyboardResizeActiveRef.current) {
238
248
  keyboardResizeActiveRef.current = true;
239
- onResizeStart?.();
249
+ onResizeStart?.(handle);
240
250
  }
241
251
  const scheduleKeyboardResizeEnd = () => {
242
252
  clearTimeout(keyboardSettleTimerRef.current);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/image-editor/react/components/stencils/rectangle-stencil.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { StencilProps, NormalizedRect } from '../../../core/types';\nimport {\n\tDEFAULT_KEYBOARD_STEP,\n\tKEYBOARD_SHIFT_STEP_MULTIPLIER,\n} from '../../../core/constants';\nimport {\n\tcomputeFreeResizeRect,\n\tcomputeLockedResizeRect,\n\tcomputeShiftLockedResizeRect,\n\ttype HandlePosition,\n\ttype CropBounds,\n\ttype ResizeDragState,\n} from '../../../core/stencil-math';\nimport { VISUALLY_HIDDEN_STYLE } from '../../visually-hidden-style';\n\n/**\n * Corner handle positions only \u2014 used when aspect ratio is locked.\n * Ordered clockwise from top-left for logical tab order.\n */\nconst CORNER_POSITIONS: HandlePosition[] = [ 'nw', 'ne', 'se', 'sw' ];\n\n/**\n * All handle positions rendered by the stencil.\n * Ordered clockwise from top-left for logical tab order.\n */\nconst ALL_POSITIONS: HandlePosition[] = [\n\t'nw',\n\t'n',\n\t'ne',\n\t'e',\n\t'se',\n\t's',\n\t'sw',\n\t'w',\n];\n\n/**\n * Get the translated aria-label for a resize handle position.\n *\n * @param pos The handle position identifier.\n * @return The translated label string.\n */\nfunction getHandleLabel( pos: HandlePosition ): string {\n\tswitch ( pos ) {\n\t\tcase 'n':\n\t\t\treturn __( 'Resize top edge' );\n\t\tcase 's':\n\t\t\treturn __( 'Resize bottom edge' );\n\t\tcase 'e':\n\t\t\treturn __( 'Resize right edge' );\n\t\tcase 'w':\n\t\t\treturn __( 'Resize left edge' );\n\t\tcase 'nw':\n\t\t\treturn __( 'Resize top-left corner' );\n\t\tcase 'ne':\n\t\t\treturn __( 'Resize top-right corner' );\n\t\tcase 'sw':\n\t\t\treturn __( 'Resize bottom-left corner' );\n\t\tcase 'se':\n\t\t\treturn __( 'Resize bottom-right corner' );\n\t}\n}\n\n/** Delay before keyboard resize triggers settle (ms). */\nconst KEYBOARD_SETTLE_DELAY = 500;\n\n/**\n * Props for the RectangleStencil component.\n */\ntype RectangleStencilProps = StencilProps;\n\n/**\n * A rectangular crop stencil with resize handles.\n *\n * In freeform mode, handles resize the crop area. Clicks inside the\n * crop pass through to the container for image panning. The crop\n * auto-centers after resize via SETTLE_CROP.\n *\n * @param props Component props implementing StencilProps.\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 * @param props.onCropChange Callback fired when the crop rect changes.\n * @param props.onResizeStart Callback fired when a resize drag starts.\n * @param props.onResizeEnd Callback fired when a resize drag ends (mouseup).\n * @param props.aspectRatio Optional fixed aspect ratio (width / height).\n * @param props.freeformCrop Whether resize handles are shown.\n * @param props.stencilTransition CSS transition string for settle animation.\n * @param props.cropBounds Maximum crop rect bounds from camera (zoom/rotation-aware).\n * @param props.onEscape Called when Escape is pressed on a resize handle.\n * @return The rectangle stencil element.\n */\nexport function RectangleStencil( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n\tonCropChange,\n\tonResizeStart,\n\tonResizeEnd,\n\taspectRatio,\n\tfreeformCrop = false,\n\tstencilTransition,\n\tcropBounds,\n\tonEscape,\n}: RectangleStencilProps ) {\n\t// Use cropBounds from the camera if available, otherwise default to [0,1].\n\tconst boundsMinX = cropBounds?.minX ?? 0;\n\tconst boundsMinY = cropBounds?.minY ?? 0;\n\tconst boundsMaxX = cropBounds?.maxX ?? 1;\n\tconst boundsMaxY = cropBounds?.maxY ?? 1;\n\tconst bounds: CropBounds = useMemo(\n\t\t() => ( {\n\t\t\tminX: boundsMinX,\n\t\t\tminY: boundsMinY,\n\t\t\tmaxX: boundsMaxX,\n\t\t\tmaxY: boundsMaxY,\n\t\t} ),\n\t\t[ boundsMinX, boundsMinY, boundsMaxX, boundsMaxY ]\n\t);\n\tconst keyboardSettleTimerRef = useRef< ReturnType< typeof setTimeout > >();\n\tconst keyboardResizeActiveRef = useRef( false );\n\tconst resizeHandleDescriptionId = useId();\n\tconst hasLockedRatio = !! ( aspectRatio && aspectRatio > 0 );\n\n\t// Clear the pending keyboard settle timer on unmount so it can't\n\t// fire onResizeEnd / dispatch onto an unmounted parent.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( keyboardSettleTimerRef.current );\n\t\t\tkeyboardResizeActiveRef.current = false;\n\t\t};\n\t}, [] );\n\n\t// Latest callbacks for the drag listeners. The drag closure in\n\t// handlePointerDown reads from this ref so it always sees current\n\t// props without having to re-attach listeners mid-drag. Previously,\n\t// drag listeners lived in a useEffect that re-ran whenever `bounds`\n\t// changed (every SET_CROP_RECT dispatch), creating a window where\n\t// pointerup could be missed and the crop would never settle.\n\tconst latestHandlersRef = useRef< {\n\t\thasLockedRatio: boolean;\n\t\tcomputeLockedRect: (\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t) => NormalizedRect;\n\t\tcomputeFreeRect: (\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t) => NormalizedRect;\n\t\tcomputeShiftLockedRect: (\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t) => NormalizedRect;\n\t\tonCropChange: ( rect: NormalizedRect ) => void;\n\t\tonResizeEnd?: () => void;\n\t} | null >( null );\n\n\t// The normalized aspect ratio: the w/h ratio in normalized space that\n\t// produces the desired pixel aspect ratio.\n\t// pixelW = w * imageSize.width, pixelH = h * imageSize.height\n\t// pixelW / pixelH = aspectRatio => w / h = aspectRatio * imageSize.height / imageSize.width\n\tconst normalizedRatio = useMemo( () => {\n\t\tif ( ! hasLockedRatio || imageSize.width === 0 ) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn ( aspectRatio * imageSize.height ) / imageSize.width;\n\t}, [ aspectRatio, hasLockedRatio, imageSize.width, imageSize.height ] );\n\n\t// Convert normalized crop rect to pixel bounds, accounting for the\n\t// image offset within the container.\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/**\n\t * Start a resize drag on a handle. Registers pointer listeners\n\t * synchronously so no events are missed between capture and the\n\t * next React commit.\n\t */\n\tconst handlePointerDown = useCallback(\n\t\t( handle: HandlePosition, event: React.PointerEvent ) => {\n\t\t\tif ( event.button !== 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\t// Blur any previously focused handle.\n\t\t\tconst ownerDoc = event.currentTarget.ownerDocument;\n\t\t\tif ( ownerDoc.activeElement instanceof HTMLElement ) {\n\t\t\t\townerDoc.activeElement.blur();\n\t\t\t}\n\t\t\t// Capture pointer so drag works across iframe boundaries.\n\t\t\tconst el = event.currentTarget as HTMLButtonElement;\n\t\t\tel.setPointerCapture( event.pointerId );\n\n\t\t\tconst drag: ResizeDragState = {\n\t\t\t\thandle,\n\t\t\t\tstartX: event.clientX,\n\t\t\t\tstartY: event.clientY,\n\t\t\t\tstartRect: { ...cropRect },\n\t\t\t};\n\n\t\t\t// RAF-throttle: stash the latest pointer position and\n\t\t\t// process it once per animation frame. Avoids dispatching\n\t\t\t// on every pointermove (which fires at much higher than\n\t\t\t// screen refresh rate) and matches the pan-drag path in\n\t\t\t// InteractionController.\n\t\t\tlet rafId = 0;\n\t\t\tlet latestX = event.clientX;\n\t\t\tlet latestY = event.clientY;\n\t\t\tlet latestShift = event.shiftKey;\n\n\t\t\tconst onMove = ( e: Event ) => {\n\t\t\t\tconst pe = e as PointerEvent;\n\t\t\t\tlatestX = pe.clientX;\n\t\t\t\tlatestY = pe.clientY;\n\t\t\t\tlatestShift = pe.shiftKey;\n\t\t\t\tif ( rafId ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\trafId = requestAnimationFrame( () => {\n\t\t\t\t\trafId = 0;\n\t\t\t\t\tconst h = latestHandlersRef.current;\n\t\t\t\t\tif ( ! h ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet newRect: NormalizedRect;\n\t\t\t\t\tif ( h.hasLockedRatio ) {\n\t\t\t\t\t\tnewRect = h.computeLockedRect( drag, latestX, latestY );\n\t\t\t\t\t} else if ( latestShift ) {\n\t\t\t\t\t\tnewRect = h.computeShiftLockedRect(\n\t\t\t\t\t\t\tdrag,\n\t\t\t\t\t\t\tlatestX,\n\t\t\t\t\t\t\tlatestY\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewRect = h.computeFreeRect( drag, latestX, latestY );\n\t\t\t\t\t}\n\t\t\t\t\th.onCropChange( newRect );\n\t\t\t\t} );\n\t\t\t};\n\n\t\t\t// Guard against duplicate firing: pointerup and\n\t\t\t// lostpointercapture both fire on normal release.\n\t\t\tlet ended = false;\n\t\t\tconst onEnd = () => {\n\t\t\t\tif ( ended ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tended = true;\n\t\t\t\tif ( rafId ) {\n\t\t\t\t\tcancelAnimationFrame( rafId );\n\t\t\t\t\trafId = 0;\n\t\t\t\t}\n\t\t\t\tel.removeEventListener( 'pointermove', onMove );\n\t\t\t\tel.removeEventListener( 'pointerup', onEnd );\n\t\t\t\tel.removeEventListener( 'lostpointercapture', onEnd );\n\t\t\t\tlatestHandlersRef.current?.onResizeEnd?.();\n\t\t\t\t// Restore focus to the handle so arrow keys work\n\t\t\t\t// immediately after a mouse drag. Browsers suppress\n\t\t\t\t// :focus-visible after pointer interactions, so the\n\t\t\t\t// focus ring stays hidden until the user presses a key.\n\t\t\t\tel.focus( { preventScroll: true } );\n\t\t\t};\n\n\t\t\tel.addEventListener( 'pointermove', onMove );\n\t\t\tel.addEventListener( 'pointerup', onEnd );\n\t\t\tel.addEventListener( 'lostpointercapture', onEnd );\n\n\t\t\tonResizeStart?.();\n\t\t\t// Cancel any pending keyboard settle so it can't fire onResizeEnd\n\t\t\t// mid-drag if the user switches from keyboard to pointer within\n\t\t\t// the settle window.\n\t\t\tclearTimeout( keyboardSettleTimerRef.current );\n\t\t\tkeyboardResizeActiveRef.current = false;\n\t\t},\n\t\t[ cropRect, onResizeStart ]\n\t);\n\n\t/**\n\t * Compute the new crop rect for a free (no aspect ratio) resize.\n\t * Delegates to the pure function in core/stencil-math.ts.\n\t */\n\tconst computeFreeRect = useCallback(\n\t\t(\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t): NormalizedRect =>\n\t\t\tcomputeFreeResizeRect( drag, clientX, clientY, imageSize, bounds ),\n\t\t[ imageSize, bounds ]\n\t);\n\n\t/**\n\t * Compute the new crop rect for a locked-aspect-ratio corner resize.\n\t * Delegates to the pure function in core/stencil-math.ts.\n\t */\n\tconst computeLockedRect = useCallback(\n\t\t(\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t): NormalizedRect =>\n\t\t\tcomputeLockedResizeRect(\n\t\t\t\tdrag,\n\t\t\t\tclientX,\n\t\t\t\tclientY,\n\t\t\t\timageSize,\n\t\t\t\tbounds,\n\t\t\t\tnormalizedRatio\n\t\t\t),\n\t\t[ imageSize, bounds, normalizedRatio ]\n\t);\n\n\t/**\n\t * Compute the new crop rect when Shift is held during a freeform\n\t * resize \u2014 preserves the start rect's aspect ratio.\n\t */\n\tconst computeShiftLockedRect = useCallback(\n\t\t(\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t): NormalizedRect =>\n\t\t\tcomputeShiftLockedResizeRect(\n\t\t\t\tdrag,\n\t\t\t\tclientX,\n\t\t\t\tclientY,\n\t\t\t\timageSize,\n\t\t\t\tbounds\n\t\t\t),\n\t\t[ imageSize, bounds ]\n\t);\n\n\tlatestHandlersRef.current = {\n\t\thasLockedRatio,\n\t\tcomputeLockedRect,\n\t\tcomputeFreeRect,\n\t\tcomputeShiftLockedRect,\n\t\tonCropChange,\n\t\tonResizeEnd,\n\t};\n\n\t/**\n\t * Handle keyboard events on a resize handle.\n\t * Arrow keys resize; Escape returns focus to the canvas.\n\t * Shift multiplies the step size by 10 for coarser movement.\n\t */\n\tconst handleKeyDown = useCallback(\n\t\t( handle: HandlePosition, event: React.KeyboardEvent ) => {\n\t\t\tconst key = event.key;\n\n\t\t\tif ( key === 'Escape' ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tonEscape?.();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tkey !== 'ArrowUp' &&\n\t\t\t\tkey !== 'ArrowDown' &&\n\t\t\t\tkey !== 'ArrowLeft' &&\n\t\t\t\tkey !== 'ArrowRight'\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\n\t\t\tif ( ! keyboardResizeActiveRef.current ) {\n\t\t\t\tkeyboardResizeActiveRef.current = true;\n\t\t\t\tonResizeStart?.();\n\t\t\t}\n\n\t\t\tconst scheduleKeyboardResizeEnd = () => {\n\t\t\t\tclearTimeout( keyboardSettleTimerRef.current );\n\t\t\t\tkeyboardSettleTimerRef.current = setTimeout( () => {\n\t\t\t\t\tkeyboardResizeActiveRef.current = false;\n\t\t\t\t\tonResizeEnd?.();\n\t\t\t\t}, KEYBOARD_SETTLE_DELAY );\n\t\t\t};\n\n\t\t\tconst step = event.shiftKey\n\t\t\t\t? DEFAULT_KEYBOARD_STEP * KEYBOARD_SHIFT_STEP_MULTIPLIER\n\t\t\t\t: DEFAULT_KEYBOARD_STEP;\n\n\t\t\t// Determine the normalized delta from the arrow key.\n\t\t\tlet dx = 0;\n\t\t\tlet dy = 0;\n\t\t\tif ( key === 'ArrowLeft' ) {\n\t\t\t\tdx = -step;\n\t\t\t}\n\t\t\tif ( key === 'ArrowRight' ) {\n\t\t\t\tdx = step;\n\t\t\t}\n\t\t\tif ( key === 'ArrowUp' ) {\n\t\t\t\tdy = -step;\n\t\t\t}\n\t\t\tif ( key === 'ArrowDown' ) {\n\t\t\t\tdy = step;\n\t\t\t}\n\n\t\t\tif ( hasLockedRatio ) {\n\t\t\t\t// For locked aspect ratio, synthesize a drag from the\n\t\t\t\t// current rect and apply the delta via computeLockedRect.\n\t\t\t\tconst syntheticDrag: ResizeDragState = {\n\t\t\t\t\thandle,\n\t\t\t\t\tstartX: 0,\n\t\t\t\t\tstartY: 0,\n\t\t\t\t\tstartRect: { ...cropRect },\n\t\t\t\t};\n\t\t\t\tconst clientX = dx * imageSize.width;\n\t\t\t\tconst clientY = dy * imageSize.height;\n\t\t\t\tonCropChange(\n\t\t\t\t\tcomputeLockedRect( syntheticDrag, clientX, clientY )\n\t\t\t\t);\n\t\t\t\tscheduleKeyboardResizeEnd();\n\t\t\t} else {\n\t\t\t\t// For freeform resize, synthesize a drag via computeFreeRect.\n\t\t\t\tconst syntheticDrag: ResizeDragState = {\n\t\t\t\t\thandle,\n\t\t\t\t\tstartX: 0,\n\t\t\t\t\tstartY: 0,\n\t\t\t\t\tstartRect: { ...cropRect },\n\t\t\t\t};\n\t\t\t\tconst clientX = dx * imageSize.width;\n\t\t\t\tconst clientY = dy * imageSize.height;\n\t\t\t\tonCropChange(\n\t\t\t\t\tcomputeFreeRect( syntheticDrag, clientX, clientY )\n\t\t\t\t);\n\t\t\t\tscheduleKeyboardResizeEnd();\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tcropRect,\n\t\t\thasLockedRatio,\n\t\t\timageSize.width,\n\t\t\timageSize.height,\n\t\t\tcomputeLockedRect,\n\t\t\tcomputeFreeRect,\n\t\t\tonCropChange,\n\t\t\tonResizeStart,\n\t\t\tonResizeEnd,\n\t\t\tonEscape,\n\t\t]\n\t);\n\n\tif ( containerSize.width === 0 || containerSize.height === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst handles = hasLockedRatio ? CORNER_POSITIONS : ALL_POSITIONS;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wp-media-editor-image-editor__stencil\"\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: stencilTransition,\n\t\t\t} }\n\t\t>\n\t\t\t{ freeformCrop && (\n\t\t\t\t<div\n\t\t\t\t\tid={ resizeHandleDescriptionId }\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'Use arrow keys to resize the crop area. Hold Shift for larger steps.'\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ /* The crop rectangle border. pointer-events: none is set in\n\t\t\t\t CSS so clicks pass through to the container for panning. */ }\n\t\t\t<div\n\t\t\t\tclassName=\"wp-media-editor-image-editor__stencil-rect\"\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '100%',\n\t\t\t\t\ttop: 0,\n\t\t\t\t\tleft: 0,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ /* Resize handles \u2014 only in freeform mode.\n\t\t\t\t Semantics: role=\"button\" with aria-label describing\n\t\t\t\t which edge/corner. Arrow keys resize (onKeyDown).\n\t\t\t\t role=\"slider\" would be more precise but requires\n\t\t\t\t per-handle aria-valuemin/max/now which don't map\n\t\t\t\t cleanly to a 2D crop rect. */ }\n\t\t\t{ freeformCrop &&\n\t\t\t\thandles.map( ( pos ) => (\n\t\t\t\t\t<button\n\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclassName={ `wp-media-editor-image-editor__handle wp-media-editor-image-editor__handle--${ pos }` }\n\t\t\t\t\t\tonPointerDown={ ( event ) =>\n\t\t\t\t\t\t\thandlePointerDown( pos, event )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonTouchStart={ ( event ) => event.stopPropagation() }\n\t\t\t\t\t\tonKeyDown={ ( event ) => handleKeyDown( pos, event ) }\n\t\t\t\t\t\taria-label={ getHandleLabel( pos ) }\n\t\t\t\t\t\taria-describedby={ resizeHandleDescriptionId }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t</div>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAMO;AACP,kBAAmB;AAMnB,uBAGO;AACP,0BAOO;AACP,mCAAsC;AAicpC;AA3bF,IAAM,mBAAqC,CAAE,MAAM,MAAM,MAAM,IAAK;AAMpE,IAAM,gBAAkC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAQA,SAAS,eAAgB,KAA8B;AACtD,UAAS,KAAM;AAAA,IACd,KAAK;AACJ,iBAAO,gBAAI,iBAAkB;AAAA,IAC9B,KAAK;AACJ,iBAAO,gBAAI,oBAAqB;AAAA,IACjC,KAAK;AACJ,iBAAO,gBAAI,mBAAoB;AAAA,IAChC,KAAK;AACJ,iBAAO,gBAAI,kBAAmB;AAAA,IAC/B,KAAK;AACJ,iBAAO,gBAAI,wBAAyB;AAAA,IACrC,KAAK;AACJ,iBAAO,gBAAI,yBAA0B;AAAA,IACtC,KAAK;AACJ,iBAAO,gBAAI,2BAA4B;AAAA,IACxC,KAAK;AACJ,iBAAO,gBAAI,4BAA6B;AAAA,EAC1C;AACD;AAGA,IAAM,wBAAwB;AA4BvB,SAAS,iBAAkB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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EA,QAAM,UAAU,iBAAiB,mBAAmB;AAEpD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAY;AAAA,MACb;AAAA,MAEE;AAAA,wBACD;AAAA,UAAC;AAAA;AAAA,YACA,IAAK;AAAA,YACL,OAAQ;AAAA,YAEN;AAAA,cACD;AAAA,YACD;AAAA;AAAA,QACD;AAAA,QAID;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,OAAQ;AAAA,cACP,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,KAAK;AAAA,cACL,MAAM;AAAA,YACP;AAAA;AAAA,QACD;AAAA,QAOE,gBACD,QAAQ,IAAK,CAAE,QACd;AAAA,UAAC;AAAA;AAAA,YAEA,MAAK;AAAA,YACL,WAAY,8EAA+E,GAAI;AAAA,YAC/F,eAAgB,CAAE,UACjB,kBAAmB,KAAK,KAAM;AAAA,YAE/B,cAAe,CAAE,UAAW,MAAM,gBAAgB;AAAA,YAClD,WAAY,CAAE,UAAW,cAAe,KAAK,KAAM;AAAA,YACnD,cAAa,eAAgB,GAAI;AAAA,YACjC,oBAAmB;AAAA;AAAA,UATb;AAAA,QAUP,CACC;AAAA;AAAA;AAAA,EACJ;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { StencilProps, NormalizedRect } from '../../../core/types';\nimport {\n\tDEFAULT_KEYBOARD_STEP,\n\tKEYBOARD_SHIFT_STEP_MULTIPLIER,\n} from '../../../core/constants';\nimport {\n\tcomputeFreeResizeRect,\n\tcomputeLockedResizeRect,\n\tcomputeShiftLockedResizeRect,\n\ttype HandlePosition,\n\ttype CropBounds,\n\ttype ResizeDragState,\n} from '../../../core/stencil-math';\nimport { VISUALLY_HIDDEN_STYLE } from '../../visually-hidden-style';\n\n/**\n * Corner handle positions only \u2014 used when aspect ratio is locked.\n * Ordered clockwise from top-left for logical tab order.\n */\nconst CORNER_POSITIONS: HandlePosition[] = [ 'nw', 'ne', 'se', 'sw' ];\n\n/**\n * All handle positions rendered by the stencil.\n * Ordered clockwise from top-left for logical tab order.\n */\nconst ALL_POSITIONS: HandlePosition[] = [\n\t'nw',\n\t'n',\n\t'ne',\n\t'e',\n\t'se',\n\t's',\n\t'sw',\n\t'w',\n];\n\n/**\n * Get the translated aria-label for a resize handle position.\n *\n * @param pos The handle position identifier.\n * @return The translated label string.\n */\nfunction getHandleLabel( pos: HandlePosition ): string {\n\tswitch ( pos ) {\n\t\tcase 'n':\n\t\t\treturn __( 'Resize top edge' );\n\t\tcase 's':\n\t\t\treturn __( 'Resize bottom edge' );\n\t\tcase 'e':\n\t\t\treturn __( 'Resize right edge' );\n\t\tcase 'w':\n\t\t\treturn __( 'Resize left edge' );\n\t\tcase 'nw':\n\t\t\treturn __( 'Resize top-left corner' );\n\t\tcase 'ne':\n\t\t\treturn __( 'Resize top-right corner' );\n\t\tcase 'sw':\n\t\t\treturn __( 'Resize bottom-left corner' );\n\t\tcase 'se':\n\t\t\treturn __( 'Resize bottom-right corner' );\n\t}\n}\n\n/** Delay before keyboard resize triggers settle (ms). */\nconst KEYBOARD_SETTLE_DELAY = 500;\n\n/**\n * Props for the RectangleStencil component.\n */\ntype RectangleStencilProps = StencilProps;\n\n/**\n * A rectangular crop stencil with resize handles.\n *\n * In freeform mode, handles resize the crop area. Clicks inside the\n * crop pass through to the container for image panning. The crop\n * auto-centers after resize via SETTLE_CROP.\n *\n * @param props Component props implementing StencilProps.\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 * @param props.onCropChange Callback fired when the crop rect changes.\n * @param props.onResizeStart Callback fired when a resize drag starts.\n * @param props.onResizeEnd Callback fired when a resize drag ends (mouseup).\n * @param props.aspectRatio Optional fixed aspect ratio (width / height).\n * @param props.freeformCrop Whether resize handles are shown.\n * @param props.stencilTransition CSS transition string for settle animation.\n * @param props.cropBounds Maximum crop rect bounds from camera (zoom/rotation-aware).\n * @param props.onEscape Called when Escape is pressed on a resize handle.\n * @param props.minCropSize Minimum crop rect dimension in normalized space, per axis.\n * @return The rectangle stencil element.\n */\nexport function RectangleStencil( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n\tonCropChange,\n\tonResizeStart,\n\tonResizeEnd,\n\taspectRatio,\n\tfreeformCrop = false,\n\tstencilTransition,\n\tcropBounds,\n\tonEscape,\n\tminCropSize,\n}: RectangleStencilProps ) {\n\t// Use cropBounds from the camera if available, otherwise default to [0,1].\n\tconst boundsMinX = cropBounds?.minX ?? 0;\n\tconst boundsMinY = cropBounds?.minY ?? 0;\n\tconst boundsMaxX = cropBounds?.maxX ?? 1;\n\tconst boundsMaxY = cropBounds?.maxY ?? 1;\n\tconst bounds: CropBounds = useMemo(\n\t\t() => ( {\n\t\t\tminX: boundsMinX,\n\t\t\tminY: boundsMinY,\n\t\t\tmaxX: boundsMaxX,\n\t\t\tmaxY: boundsMaxY,\n\t\t} ),\n\t\t[ boundsMinX, boundsMinY, boundsMaxX, boundsMaxY ]\n\t);\n\tconst keyboardSettleTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\tconst keyboardResizeActiveRef = useRef( false );\n\tconst resizeHandleDescriptionId = useId();\n\tconst hasLockedRatio = !! ( aspectRatio && aspectRatio > 0 );\n\n\t// Clear the pending keyboard settle timer on unmount so it can't\n\t// fire onResizeEnd / dispatch onto an unmounted parent.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( keyboardSettleTimerRef.current );\n\t\t\tkeyboardResizeActiveRef.current = false;\n\t\t};\n\t}, [] );\n\n\t// Latest callbacks for the drag listeners. The drag closure in\n\t// handlePointerDown reads from this ref so it always sees current\n\t// props without having to re-attach listeners mid-drag. Previously,\n\t// drag listeners lived in a useEffect that re-ran whenever `bounds`\n\t// changed (every SET_CROP_RECT dispatch), creating a window where\n\t// pointerup could be missed and the crop would never settle.\n\tconst latestHandlersRef = useRef< {\n\t\thasLockedRatio: boolean;\n\t\tcomputeLockedRect: (\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t) => NormalizedRect;\n\t\tcomputeFreeRect: (\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t) => NormalizedRect;\n\t\tcomputeShiftLockedRect: (\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t) => NormalizedRect;\n\t\tonCropChange: ( rect: NormalizedRect ) => void;\n\t\tonResizeEnd?: () => void;\n\t} | null >( null );\n\n\t// The normalized aspect ratio: the w/h ratio in normalized space that\n\t// produces the desired pixel aspect ratio.\n\t// pixelW = w * imageSize.width, pixelH = h * imageSize.height\n\t// pixelW / pixelH = aspectRatio => w / h = aspectRatio * imageSize.height / imageSize.width\n\tconst normalizedRatio = useMemo( () => {\n\t\tif ( ! hasLockedRatio || imageSize.width === 0 ) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn ( aspectRatio * imageSize.height ) / imageSize.width;\n\t}, [ aspectRatio, hasLockedRatio, imageSize.width, imageSize.height ] );\n\n\t// Convert normalized crop rect to pixel bounds, accounting for the\n\t// image offset within the container.\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/**\n\t * Start a resize drag on a handle. Registers pointer listeners\n\t * synchronously so no events are missed between capture and the\n\t * next React commit.\n\t */\n\tconst handlePointerDown = useCallback(\n\t\t( handle: HandlePosition, event: React.PointerEvent ) => {\n\t\t\tif ( event.button !== 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\t// Blur any previously focused handle.\n\t\t\tconst ownerDoc = event.currentTarget.ownerDocument;\n\t\t\tif ( ownerDoc.activeElement instanceof HTMLElement ) {\n\t\t\t\townerDoc.activeElement.blur();\n\t\t\t}\n\t\t\t// Capture pointer so drag works across iframe boundaries.\n\t\t\tconst el = event.currentTarget as HTMLButtonElement;\n\t\t\tel.setPointerCapture( event.pointerId );\n\n\t\t\tconst drag: ResizeDragState = {\n\t\t\t\thandle,\n\t\t\t\tstartX: event.clientX,\n\t\t\t\tstartY: event.clientY,\n\t\t\t\tstartRect: { ...cropRect },\n\t\t\t};\n\n\t\t\t// RAF-throttle: stash the latest pointer position and\n\t\t\t// process it once per animation frame. Avoids dispatching\n\t\t\t// on every pointermove (which fires at much higher than\n\t\t\t// screen refresh rate) and matches the pan-drag path in\n\t\t\t// InteractionController.\n\t\t\tlet rafId = 0;\n\t\t\tlet latestX = event.clientX;\n\t\t\tlet latestY = event.clientY;\n\t\t\tlet latestShift = event.shiftKey;\n\n\t\t\tconst onMove = ( e: Event ) => {\n\t\t\t\tconst pe = e as PointerEvent;\n\t\t\t\tlatestX = pe.clientX;\n\t\t\t\tlatestY = pe.clientY;\n\t\t\t\tlatestShift = pe.shiftKey;\n\t\t\t\tif ( rafId ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\trafId = requestAnimationFrame( () => {\n\t\t\t\t\trafId = 0;\n\t\t\t\t\tconst h = latestHandlersRef.current;\n\t\t\t\t\tif ( ! h ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet newRect: NormalizedRect;\n\t\t\t\t\tif ( h.hasLockedRatio ) {\n\t\t\t\t\t\tnewRect = h.computeLockedRect( drag, latestX, latestY );\n\t\t\t\t\t} else if ( latestShift ) {\n\t\t\t\t\t\tnewRect = h.computeShiftLockedRect(\n\t\t\t\t\t\t\tdrag,\n\t\t\t\t\t\t\tlatestX,\n\t\t\t\t\t\t\tlatestY\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewRect = h.computeFreeRect( drag, latestX, latestY );\n\t\t\t\t\t}\n\t\t\t\t\th.onCropChange( newRect );\n\t\t\t\t} );\n\t\t\t};\n\n\t\t\t// Guard against duplicate firing: pointerup and\n\t\t\t// lostpointercapture both fire on normal release.\n\t\t\tlet ended = false;\n\t\t\tconst onEnd = () => {\n\t\t\t\tif ( ended ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tended = true;\n\t\t\t\tif ( rafId ) {\n\t\t\t\t\tcancelAnimationFrame( rafId );\n\t\t\t\t\trafId = 0;\n\t\t\t\t}\n\t\t\t\tel.removeEventListener( 'pointermove', onMove );\n\t\t\t\tel.removeEventListener( 'pointerup', onEnd );\n\t\t\t\tel.removeEventListener( 'lostpointercapture', onEnd );\n\t\t\t\tlatestHandlersRef.current?.onResizeEnd?.();\n\t\t\t\t// Restore focus to the handle so arrow keys work\n\t\t\t\t// immediately after a mouse drag. Browsers suppress\n\t\t\t\t// :focus-visible after pointer interactions, so the\n\t\t\t\t// focus ring stays hidden until the user presses a key.\n\t\t\t\tel.focus( { preventScroll: true } );\n\t\t\t};\n\n\t\t\tel.addEventListener( 'pointermove', onMove );\n\t\t\tel.addEventListener( 'pointerup', onEnd );\n\t\t\tel.addEventListener( 'lostpointercapture', onEnd );\n\n\t\t\tonResizeStart?.( handle );\n\t\t\t// Cancel any pending keyboard settle so it can't fire onResizeEnd\n\t\t\t// mid-drag if the user switches from keyboard to pointer within\n\t\t\t// the settle window.\n\t\t\tclearTimeout( keyboardSettleTimerRef.current );\n\t\t\tkeyboardResizeActiveRef.current = false;\n\t\t},\n\t\t[ cropRect, onResizeStart ]\n\t);\n\n\t/**\n\t * Compute the new crop rect for a free (no aspect ratio) resize.\n\t * Delegates to the pure function in core/stencil-math.ts.\n\t */\n\tconst computeFreeRect = useCallback(\n\t\t(\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t): NormalizedRect =>\n\t\t\tcomputeFreeResizeRect(\n\t\t\t\tdrag,\n\t\t\t\tclientX,\n\t\t\t\tclientY,\n\t\t\t\timageSize,\n\t\t\t\tbounds,\n\t\t\t\tminCropSize\n\t\t\t),\n\t\t[ imageSize, bounds, minCropSize ]\n\t);\n\n\t/**\n\t * Compute the new crop rect for a locked-aspect-ratio corner resize.\n\t * Delegates to the pure function in core/stencil-math.ts.\n\t */\n\tconst computeLockedRect = useCallback(\n\t\t(\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t): NormalizedRect =>\n\t\t\tcomputeLockedResizeRect(\n\t\t\t\tdrag,\n\t\t\t\tclientX,\n\t\t\t\tclientY,\n\t\t\t\timageSize,\n\t\t\t\tbounds,\n\t\t\t\tnormalizedRatio,\n\t\t\t\tminCropSize\n\t\t\t),\n\t\t[ imageSize, bounds, normalizedRatio, minCropSize ]\n\t);\n\n\t/**\n\t * Compute the new crop rect when Shift is held during a freeform\n\t * resize \u2014 preserves the start rect's aspect ratio.\n\t */\n\tconst computeShiftLockedRect = useCallback(\n\t\t(\n\t\t\tdrag: ResizeDragState,\n\t\t\tclientX: number,\n\t\t\tclientY: number\n\t\t): NormalizedRect =>\n\t\t\tcomputeShiftLockedResizeRect(\n\t\t\t\tdrag,\n\t\t\t\tclientX,\n\t\t\t\tclientY,\n\t\t\t\timageSize,\n\t\t\t\tbounds,\n\t\t\t\tminCropSize\n\t\t\t),\n\t\t[ imageSize, bounds, minCropSize ]\n\t);\n\n\tlatestHandlersRef.current = {\n\t\thasLockedRatio,\n\t\tcomputeLockedRect,\n\t\tcomputeFreeRect,\n\t\tcomputeShiftLockedRect,\n\t\tonCropChange,\n\t\tonResizeEnd,\n\t};\n\n\t/**\n\t * Handle keyboard events on a resize handle.\n\t * Arrow keys resize; Escape returns focus to the canvas.\n\t * Shift multiplies the step size by 10 for coarser movement.\n\t */\n\tconst handleKeyDown = useCallback(\n\t\t( handle: HandlePosition, event: React.KeyboardEvent ) => {\n\t\t\tconst key = event.key;\n\n\t\t\tif ( key === 'Escape' ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tonEscape?.();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tkey !== 'ArrowUp' &&\n\t\t\t\tkey !== 'ArrowDown' &&\n\t\t\t\tkey !== 'ArrowLeft' &&\n\t\t\t\tkey !== 'ArrowRight'\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\n\t\t\tif ( ! keyboardResizeActiveRef.current ) {\n\t\t\t\tkeyboardResizeActiveRef.current = true;\n\t\t\t\tonResizeStart?.( handle );\n\t\t\t}\n\n\t\t\tconst scheduleKeyboardResizeEnd = () => {\n\t\t\t\tclearTimeout( keyboardSettleTimerRef.current );\n\t\t\t\tkeyboardSettleTimerRef.current = setTimeout( () => {\n\t\t\t\t\tkeyboardResizeActiveRef.current = false;\n\t\t\t\t\tonResizeEnd?.();\n\t\t\t\t}, KEYBOARD_SETTLE_DELAY );\n\t\t\t};\n\n\t\t\tconst step = event.shiftKey\n\t\t\t\t? DEFAULT_KEYBOARD_STEP * KEYBOARD_SHIFT_STEP_MULTIPLIER\n\t\t\t\t: DEFAULT_KEYBOARD_STEP;\n\n\t\t\t// Determine the normalized delta from the arrow key.\n\t\t\tlet dx = 0;\n\t\t\tlet dy = 0;\n\t\t\tif ( key === 'ArrowLeft' ) {\n\t\t\t\tdx = -step;\n\t\t\t}\n\t\t\tif ( key === 'ArrowRight' ) {\n\t\t\t\tdx = step;\n\t\t\t}\n\t\t\tif ( key === 'ArrowUp' ) {\n\t\t\t\tdy = -step;\n\t\t\t}\n\t\t\tif ( key === 'ArrowDown' ) {\n\t\t\t\tdy = step;\n\t\t\t}\n\n\t\t\tif ( hasLockedRatio ) {\n\t\t\t\t// For locked aspect ratio, synthesize a drag from the\n\t\t\t\t// current rect and apply the delta via computeLockedRect.\n\t\t\t\tconst syntheticDrag: ResizeDragState = {\n\t\t\t\t\thandle,\n\t\t\t\t\tstartX: 0,\n\t\t\t\t\tstartY: 0,\n\t\t\t\t\tstartRect: { ...cropRect },\n\t\t\t\t};\n\t\t\t\tconst clientX = dx * imageSize.width;\n\t\t\t\tconst clientY = dy * imageSize.height;\n\t\t\t\tonCropChange(\n\t\t\t\t\tcomputeLockedRect( syntheticDrag, clientX, clientY )\n\t\t\t\t);\n\t\t\t\tscheduleKeyboardResizeEnd();\n\t\t\t} else {\n\t\t\t\t// For freeform resize, synthesize a drag via computeFreeRect.\n\t\t\t\tconst syntheticDrag: ResizeDragState = {\n\t\t\t\t\thandle,\n\t\t\t\t\tstartX: 0,\n\t\t\t\t\tstartY: 0,\n\t\t\t\t\tstartRect: { ...cropRect },\n\t\t\t\t};\n\t\t\t\tconst clientX = dx * imageSize.width;\n\t\t\t\tconst clientY = dy * imageSize.height;\n\t\t\t\tonCropChange(\n\t\t\t\t\tcomputeFreeRect( syntheticDrag, clientX, clientY )\n\t\t\t\t);\n\t\t\t\tscheduleKeyboardResizeEnd();\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tcropRect,\n\t\t\thasLockedRatio,\n\t\t\timageSize.width,\n\t\t\timageSize.height,\n\t\t\tcomputeLockedRect,\n\t\t\tcomputeFreeRect,\n\t\t\tonCropChange,\n\t\t\tonResizeStart,\n\t\t\tonResizeEnd,\n\t\t\tonEscape,\n\t\t]\n\t);\n\n\tif ( containerSize.width === 0 || containerSize.height === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst handles = hasLockedRatio ? CORNER_POSITIONS : ALL_POSITIONS;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wp-media-editor-image-editor__stencil\"\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: stencilTransition,\n\t\t\t} }\n\t\t>\n\t\t\t{ freeformCrop && (\n\t\t\t\t<div\n\t\t\t\t\tid={ resizeHandleDescriptionId }\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'Use arrow keys to resize the crop area. Hold Shift for larger steps.'\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ /* The crop rectangle border. pointer-events: none is set in\n\t\t\t\t CSS so clicks pass through to the container for panning. */ }\n\t\t\t<div\n\t\t\t\tclassName=\"wp-media-editor-image-editor__stencil-rect\"\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '100%',\n\t\t\t\t\ttop: 0,\n\t\t\t\t\tleft: 0,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ /* Resize handles \u2014 only in freeform mode.\n\t\t\t\t Semantics: role=\"button\" with aria-label describing\n\t\t\t\t which edge/corner. Arrow keys resize (onKeyDown).\n\t\t\t\t role=\"slider\" would be more precise but requires\n\t\t\t\t per-handle aria-valuemin/max/now which don't map\n\t\t\t\t cleanly to a 2D crop rect. */ }\n\t\t\t{ freeformCrop &&\n\t\t\t\thandles.map( ( pos ) => (\n\t\t\t\t\t<button\n\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclassName={ `wp-media-editor-image-editor__handle wp-media-editor-image-editor__handle--${ pos }` }\n\t\t\t\t\t\tonPointerDown={ ( event ) =>\n\t\t\t\t\t\t\thandlePointerDown( pos, event )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonTouchStart={ ( event ) => event.stopPropagation() }\n\t\t\t\t\t\tonKeyDown={ ( event ) => handleKeyDown( pos, event ) }\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A,QACA;AAAA,QACA,YAAY;AAAA,MACb;AAAA,MAEE;AAAA,wBACD;AAAA,UAAC;AAAA;AAAA,YACA,IAAK;AAAA,YACL,OAAQ;AAAA,YAEN;AAAA,cACD;AAAA,YACD;AAAA;AAAA,QACD;AAAA,QAID;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,OAAQ;AAAA,cACP,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,KAAK;AAAA,cACL,MAAM;AAAA,YACP;AAAA;AAAA,QACD;AAAA,QAOE,gBACD,QAAQ,IAAK,CAAE,QACd;AAAA,UAAC;AAAA;AAAA,YAEA,MAAK;AAAA,YACL,WAAY,8EAA+E,GAAI;AAAA,YAC/F,eAAgB,CAAE,UACjB,kBAAmB,KAAK,KAAM;AAAA,YAE/B,cAAe,CAAE,UAAW,MAAM,gBAAgB;AAAA,YAClD,WAAY,CAAE,UAAW,cAAe,KAAK,KAAM;AAAA,YACnD,cAAa,eAAgB,GAAI;AAAA,YACjC,oBAAmB;AAAA;AAAA,UATb;AAAA,QAUP,CACC;AAAA;AAAA;AAAA,EACJ;AAEF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/image-editor/react/hooks/build-cropper-setters.ts
21
+ var build_cropper_setters_exports = {};
22
+ __export(build_cropper_setters_exports, {
23
+ buildCropperSetters: () => buildCropperSetters
24
+ });
25
+ module.exports = __toCommonJS(build_cropper_setters_exports);
26
+ var import_setter_helpers = require("../../core/setter-helpers.cjs");
27
+ function buildCropperSetters(dispatchCropperAction, getCropperState) {
28
+ return {
29
+ setPan: (pan) => dispatchCropperAction({ type: "SET_PAN", payload: pan }),
30
+ setZoom: (zoom) => {
31
+ const action = (0, import_setter_helpers.buildFocalPointZoomAction)(getCropperState(), zoom);
32
+ if (action) {
33
+ dispatchCropperAction(action);
34
+ }
35
+ },
36
+ setZoomAtPoint: (zoom, pan) => dispatchCropperAction({
37
+ type: "SET_ZOOM_AT_POINT",
38
+ payload: { zoom, pan }
39
+ }),
40
+ setRotation: (rotation) => dispatchCropperAction({
41
+ type: "SET_ROTATION",
42
+ payload: rotation
43
+ }),
44
+ setFlip: (flip) => dispatchCropperAction({ type: "SET_FLIP", payload: flip }),
45
+ toggleFlip: (direction) => {
46
+ const { flip } = getCropperState();
47
+ dispatchCropperAction({
48
+ type: "SET_FLIP",
49
+ payload: { ...flip, [direction]: !flip[direction] }
50
+ });
51
+ },
52
+ snapRotate90: (direction) => dispatchCropperAction({
53
+ type: "SNAP_ROTATE_90",
54
+ payload: { direction }
55
+ }),
56
+ setCropRect: (rect) => dispatchCropperAction({
57
+ type: "SET_CROP_RECT",
58
+ payload: rect
59
+ }),
60
+ settleCrop: () => dispatchCropperAction({ type: "SETTLE_CROP" }),
61
+ applyOperation: (op) => dispatchCropperAction({
62
+ type: "APPLY_OPERATION",
63
+ payload: op
64
+ })
65
+ };
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ buildCropperSetters
70
+ });
71
+ //# sourceMappingURL=build-cropper-setters.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/image-editor/react/hooks/build-cropper-setters.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type {\n\tCropperAction,\n\tCropperState,\n\tFlip,\n\tNormalizedPoint,\n\tNormalizedRect,\n\tTransformOperation,\n} from '../../core/types';\nimport { buildFocalPointZoomAction } from '../../core/setter-helpers';\n\n/**\n * The named cropper setters shared by every hook that drives the\n * cropper reducer \u2014 the pure `useCropperReducer` and any composite\n * store that delegates cropper actions (e.g. `useMediaEditorState`).\n *\n * `setImage` and `reset` are intentionally NOT included: each hook\n * has additional bookkeeping for them (dirty-baseline, history clear)\n * that doesn't fit a shared factory.\n */\nexport interface CropperSetters {\n\tsetPan: ( pan: NormalizedPoint ) => void;\n\tsetZoom: ( zoom: number ) => void;\n\tsetZoomAtPoint: ( zoom: number, pan: NormalizedPoint ) => void;\n\tsetRotation: ( rotation: number ) => void;\n\tsetFlip: ( flip: Flip ) => void;\n\ttoggleFlip: ( direction: 'horizontal' | 'vertical' ) => void;\n\tsnapRotate90: ( direction: 1 | -1 ) => void;\n\tsetCropRect: ( rect: NormalizedRect ) => void;\n\tsettleCrop: () => void;\n\tapplyOperation: ( op: TransformOperation ) => void;\n}\n\n/**\n * Build the named cropper setters from a dispatch function and a\n * state getter. The two consuming hooks differ in how they dispatch:\n *\n * - `useCropperReducer` dispatches directly into its `useReducer`.\n * - `useMediaEditorState` wraps cropper actions in a composite\n * `CROPPER` envelope so the history machinery can record them.\n *\n * Both pass their own dispatch function and a getter that returns\n * the current `CropperState`. The factory shape keeps the two hooks\n * in lockstep \u2014 add a setter here once, both hooks get it.\n *\n * @param dispatchCropperAction Apply a `CropperAction` to the\n * underlying reducer.\n * @param getCropperState Return the current `CropperState`.\n * Used by setters that need to read\n * the latest state to compute their\n * payload (focal-point zoom, flip toggle).\n * @return The named cropper setters.\n */\nexport function buildCropperSetters(\n\tdispatchCropperAction: ( action: CropperAction ) => void,\n\tgetCropperState: () => CropperState\n): CropperSetters {\n\treturn {\n\t\tsetPan: ( pan ) =>\n\t\t\tdispatchCropperAction( { type: 'SET_PAN', payload: pan } ),\n\t\tsetZoom: ( zoom ) => {\n\t\t\tconst action = buildFocalPointZoomAction( getCropperState(), zoom );\n\t\t\tif ( action ) {\n\t\t\t\tdispatchCropperAction( action );\n\t\t\t}\n\t\t},\n\t\tsetZoomAtPoint: ( zoom, pan ) =>\n\t\t\tdispatchCropperAction( {\n\t\t\t\ttype: 'SET_ZOOM_AT_POINT',\n\t\t\t\tpayload: { zoom, pan },\n\t\t\t} ),\n\t\tsetRotation: ( rotation ) =>\n\t\t\tdispatchCropperAction( {\n\t\t\t\ttype: 'SET_ROTATION',\n\t\t\t\tpayload: rotation,\n\t\t\t} ),\n\t\tsetFlip: ( flip ) =>\n\t\t\tdispatchCropperAction( { type: 'SET_FLIP', payload: flip } ),\n\t\ttoggleFlip: ( direction ) => {\n\t\t\tconst { flip } = getCropperState();\n\t\t\tdispatchCropperAction( {\n\t\t\t\ttype: 'SET_FLIP',\n\t\t\t\tpayload: { ...flip, [ direction ]: ! flip[ direction ] },\n\t\t\t} );\n\t\t},\n\t\tsnapRotate90: ( direction ) =>\n\t\t\tdispatchCropperAction( {\n\t\t\t\ttype: 'SNAP_ROTATE_90',\n\t\t\t\tpayload: { direction },\n\t\t\t} ),\n\t\tsetCropRect: ( rect ) =>\n\t\t\tdispatchCropperAction( {\n\t\t\t\ttype: 'SET_CROP_RECT',\n\t\t\t\tpayload: rect,\n\t\t\t} ),\n\t\tsettleCrop: () => dispatchCropperAction( { type: 'SETTLE_CROP' } ),\n\t\tapplyOperation: ( op ) =>\n\t\t\tdispatchCropperAction( {\n\t\t\t\ttype: 'APPLY_OPERATION',\n\t\t\t\tpayload: op,\n\t\t\t} ),\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,4BAA0C;AA4CnC,SAAS,oBACf,uBACA,iBACiB;AACjB,SAAO;AAAA,IACN,QAAQ,CAAE,QACT,sBAAuB,EAAE,MAAM,WAAW,SAAS,IAAI,CAAE;AAAA,IAC1D,SAAS,CAAE,SAAU;AACpB,YAAM,aAAS,iDAA2B,gBAAgB,GAAG,IAAK;AAClE,UAAK,QAAS;AACb,8BAAuB,MAAO;AAAA,MAC/B;AAAA,IACD;AAAA,IACA,gBAAgB,CAAE,MAAM,QACvB,sBAAuB;AAAA,MACtB,MAAM;AAAA,MACN,SAAS,EAAE,MAAM,IAAI;AAAA,IACtB,CAAE;AAAA,IACH,aAAa,CAAE,aACd,sBAAuB;AAAA,MACtB,MAAM;AAAA,MACN,SAAS;AAAA,IACV,CAAE;AAAA,IACH,SAAS,CAAE,SACV,sBAAuB,EAAE,MAAM,YAAY,SAAS,KAAK,CAAE;AAAA,IAC5D,YAAY,CAAE,cAAe;AAC5B,YAAM,EAAE,KAAK,IAAI,gBAAgB;AACjC,4BAAuB;AAAA,QACtB,MAAM;AAAA,QACN,SAAS,EAAE,GAAG,MAAM,CAAE,SAAU,GAAG,CAAE,KAAM,SAAU,EAAE;AAAA,MACxD,CAAE;AAAA,IACH;AAAA,IACA,cAAc,CAAE,cACf,sBAAuB;AAAA,MACtB,MAAM;AAAA,MACN,SAAS,EAAE,UAAU;AAAA,IACtB,CAAE;AAAA,IACH,aAAa,CAAE,SACd,sBAAuB;AAAA,MACtB,MAAM;AAAA,MACN,SAAS;AAAA,IACV,CAAE;AAAA,IACH,YAAY,MAAM,sBAAuB,EAAE,MAAM,cAAc,CAAE;AAAA,IACjE,gBAAgB,CAAE,OACjB,sBAAuB;AAAA,MACtB,MAAM;AAAA,MACN,SAAS;AAAA,IACV,CAAE;AAAA,EACJ;AACD;",
6
+ "names": []
7
+ }
@@ -20,12 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // packages/media-editor/src/image-editor/react/hooks/index.ts
21
21
  var hooks_exports = {};
22
22
  __export(hooks_exports, {
23
- useCropperState: () => import_use_cropper_state.useCropperState
23
+ buildCropperSetters: () => import_build_cropper_setters.buildCropperSetters,
24
+ useCropperReducer: () => import_use_cropper_reducer.useCropperReducer
24
25
  });
25
26
  module.exports = __toCommonJS(hooks_exports);
26
- var import_use_cropper_state = require("./use-cropper-state.cjs");
27
+ var import_use_cropper_reducer = require("./use-cropper-reducer.cjs");
28
+ var import_build_cropper_setters = require("./build-cropper-setters.cjs");
27
29
  // Annotate the CommonJS export names for ESM import in node:
28
30
  0 && (module.exports = {
29
- useCropperState
31
+ buildCropperSetters,
32
+ useCropperReducer
30
33
  });
31
34
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/image-editor/react/hooks/index.ts"],
4
- "sourcesContent": ["export { useCropperState } from './use-cropper-state';\nexport type { UseCropperStateReturn } from './use-cropper-state';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;",
4
+ "sourcesContent": ["export { useCropperReducer } from './use-cropper-reducer';\nexport type { CropperController } from './use-cropper-reducer';\nexport { buildCropperSetters } from './build-cropper-setters';\nexport type { CropperSetters } from './build-cropper-setters';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAkC;AAElC,mCAAoC;",
6
6
  "names": []
7
7
  }
@@ -77,7 +77,9 @@ function buildAnnouncement(state, previousState) {
77
77
  }
78
78
  function useAriaAnnouncer(state) {
79
79
  const [ariaMessage, setAriaMessage] = (0, import_element.useState)("");
80
- const timerRef = (0, import_element.useRef)();
80
+ const timerRef = (0, import_element.useRef)(
81
+ void 0
82
+ );
81
83
  const prevMessageRef = (0, import_element.useRef)("");
82
84
  const prevStateRef = (0, import_element.useRef)(null);
83
85
  const latestStateRef = (0, import_element.useRef)(state);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/image-editor/react/hooks/use-aria-announcer.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { CropperState } from '../../core/types';\n\n/** Debounce delay for ARIA live announcements (ms). */\nconst ARIA_DEBOUNCE_MS = 300;\n\nfunction buildFlipAnnouncement( state: CropperState ): string {\n\tconst { horizontal, vertical } = state.flip;\n\tif ( horizontal && vertical ) {\n\t\treturn __( 'Flipped horizontally and vertically' );\n\t}\n\tif ( horizontal ) {\n\t\treturn __( 'Flipped horizontally' );\n\t}\n\tif ( vertical ) {\n\t\treturn __( 'Flipped vertically' );\n\t}\n\treturn __( 'Flip removed' );\n}\n\n// Build a human-readable announcement string from cropper state.\nfunction buildAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string {\n\tif (\n\t\tpreviousState &&\n\t\t( previousState.flip.horizontal !== state.flip.horizontal ||\n\t\t\tpreviousState.flip.vertical !== state.flip.vertical )\n\t) {\n\t\treturn buildFlipAnnouncement( state );\n\t}\n\n\tconst parts: string[] = [];\n\tparts.push(\n\t\tsprintf(\n\t\t\t/* translators: %d: zoom level as a percentage. */\n\t\t\t__( 'Zoom %d%%' ),\n\t\t\tMath.round( state.zoom * 100 )\n\t\t)\n\t);\n\tif ( state.rotation !== 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: rotation angle in degrees. */\n\t\t\t\t__( 'Rotation %d degrees' ),\n\t\t\t\tMath.round( state.rotation )\n\t\t\t)\n\t\t);\n\t}\n\tconst cropW = Math.round( state.cropRect.width * 100 );\n\tconst cropH = Math.round( state.cropRect.height * 100 );\n\tparts.push(\n\t\tsprintf(\n\t\t\t/* translators: 1: crop width as a percentage, 2: crop height as a percentage. */\n\t\t\t__( 'Crop %1$d%% by %2$d%%' ),\n\t\t\tcropW,\n\t\t\tcropH\n\t\t)\n\t);\n\tif ( state.flip.horizontal || state.flip.vertical ) {\n\t\tparts.push( buildFlipAnnouncement( state ) );\n\t}\n\treturn parts.join( ', ' );\n}\n\n/**\n * Debounce and dedupe ARIA-live announcements for screen readers as the\n * cropper state changes. Returns the current announcement message to render\n * inside an `aria-live=\"polite\"` region.\n *\n * Debouncing avoids flooding the live region during drag/pointermove bursts;\n * deduping avoids re-announcing the same state.\n *\n * @param state The current cropper state to announce.\n */\nexport function useAriaAnnouncer( state: CropperState ): string {\n\tconst [ ariaMessage, setAriaMessage ] = useState( '' );\n\tconst timerRef = useRef< ReturnType< typeof setTimeout > >();\n\tconst prevMessageRef = useRef( '' );\n\tconst prevStateRef = useRef< CropperState | null >( null );\n\tconst latestStateRef = useRef( state );\n\tuseLayoutEffect( () => {\n\t\tlatestStateRef.current = state;\n\t}, [ state ] );\n\n\tuseEffect( () => {\n\t\tclearTimeout( timerRef.current );\n\t\ttimerRef.current = setTimeout( () => {\n\t\t\tconst current = latestStateRef.current;\n\t\t\tconst msg = buildAnnouncement( current, prevStateRef.current );\n\t\t\tprevStateRef.current = current;\n\t\t\tif ( msg !== prevMessageRef.current ) {\n\t\t\t\tprevMessageRef.current = msg;\n\t\t\t\tsetAriaMessage( msg );\n\t\t\t}\n\t\t}, ARIA_DEBOUNCE_MS );\n\n\t\treturn () => {\n\t\t\tclearTimeout( timerRef.current );\n\t\t};\n\t}, [\n\t\tstate.zoom,\n\t\tstate.rotation,\n\t\tstate.cropRect.width,\n\t\tstate.cropRect.height,\n\t\tstate.flip.horizontal,\n\t\tstate.flip.vertical,\n\t] );\n\n\treturn ariaMessage;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAKO;AACP,kBAA4B;AAQ5B,IAAM,mBAAmB;AAEzB,SAAS,sBAAuB,OAA8B;AAC7D,QAAM,EAAE,YAAY,SAAS,IAAI,MAAM;AACvC,MAAK,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AACtB,mBAAe,UAAU;AAAA,EAC1B,GAAG,CAAE,KAAM,CAAE;AAEb,gCAAW,MAAM;AAChB,iBAAc,SAAS,OAAQ;AAC/B,aAAS,UAAU,WAAY,MAAM;AACpC,YAAM,UAAU,eAAe;AAC/B,YAAM,MAAM,kBAAmB,SAAS,aAAa,OAAQ;AAC7D,mBAAa,UAAU;AACvB,UAAK,QAAQ,eAAe,SAAU;AACrC,uBAAe,UAAU;AACzB,uBAAgB,GAAI;AAAA,MACrB;AAAA,IACD,GAAG,gBAAiB;AAEpB,WAAO,MAAM;AACZ,mBAAc,SAAS,OAAQ;AAAA,IAChC;AAAA,EACD,GAAG;AAAA,IACF,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM,SAAS;AAAA,IACf,MAAM,SAAS;AAAA,IACf,MAAM,KAAK;AAAA,IACX,MAAM,KAAK;AAAA,EACZ,CAAE;AAEF,SAAO;AACR;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { CropperState } from '../../core/types';\n\n/** Debounce delay for ARIA live announcements (ms). */\nconst ARIA_DEBOUNCE_MS = 300;\n\nfunction buildFlipAnnouncement( state: CropperState ): string {\n\tconst { horizontal, vertical } = state.flip;\n\tif ( horizontal && vertical ) {\n\t\treturn __( 'Flipped horizontally and vertically' );\n\t}\n\tif ( horizontal ) {\n\t\treturn __( 'Flipped horizontally' );\n\t}\n\tif ( vertical ) {\n\t\treturn __( 'Flipped vertically' );\n\t}\n\treturn __( 'Flip removed' );\n}\n\n// Build a human-readable announcement string from cropper state.\nfunction buildAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string {\n\tif (\n\t\tpreviousState &&\n\t\t( previousState.flip.horizontal !== state.flip.horizontal ||\n\t\t\tpreviousState.flip.vertical !== state.flip.vertical )\n\t) {\n\t\treturn buildFlipAnnouncement( state );\n\t}\n\n\tconst parts: string[] = [];\n\tparts.push(\n\t\tsprintf(\n\t\t\t/* translators: %d: zoom level as a percentage. */\n\t\t\t__( 'Zoom %d%%' ),\n\t\t\tMath.round( state.zoom * 100 )\n\t\t)\n\t);\n\tif ( state.rotation !== 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: rotation angle in degrees. */\n\t\t\t\t__( 'Rotation %d degrees' ),\n\t\t\t\tMath.round( state.rotation )\n\t\t\t)\n\t\t);\n\t}\n\tconst cropW = Math.round( state.cropRect.width * 100 );\n\tconst cropH = Math.round( state.cropRect.height * 100 );\n\tparts.push(\n\t\tsprintf(\n\t\t\t/* translators: 1: crop width as a percentage, 2: crop height as a percentage. */\n\t\t\t__( 'Crop %1$d%% by %2$d%%' ),\n\t\t\tcropW,\n\t\t\tcropH\n\t\t)\n\t);\n\tif ( state.flip.horizontal || state.flip.vertical ) {\n\t\tparts.push( buildFlipAnnouncement( state ) );\n\t}\n\treturn parts.join( ', ' );\n}\n\n/**\n * Debounce and dedupe ARIA-live announcements for screen readers as the\n * cropper state changes. Returns the current announcement message to render\n * inside an `aria-live=\"polite\"` region.\n *\n * Debouncing avoids flooding the live region during drag/pointermove bursts;\n * deduping avoids re-announcing the same state.\n *\n * @param state The current cropper state to announce.\n */\nexport function useAriaAnnouncer( state: CropperState ): string {\n\tconst [ ariaMessage, setAriaMessage ] = useState( '' );\n\tconst timerRef = useRef< ReturnType< typeof setTimeout > | undefined >(\n\t\tundefined\n\t);\n\tconst prevMessageRef = useRef( '' );\n\tconst prevStateRef = useRef< CropperState | null >( null );\n\tconst latestStateRef = useRef( state );\n\tuseLayoutEffect( () => {\n\t\tlatestStateRef.current = state;\n\t}, [ state ] );\n\n\tuseEffect( () => {\n\t\tclearTimeout( timerRef.current );\n\t\ttimerRef.current = setTimeout( () => {\n\t\t\tconst current = latestStateRef.current;\n\t\t\tconst msg = buildAnnouncement( current, prevStateRef.current );\n\t\t\tprevStateRef.current = current;\n\t\t\tif ( msg !== prevMessageRef.current ) {\n\t\t\t\tprevMessageRef.current = msg;\n\t\t\t\tsetAriaMessage( msg );\n\t\t\t}\n\t\t}, ARIA_DEBOUNCE_MS );\n\n\t\treturn () => {\n\t\t\tclearTimeout( timerRef.current );\n\t\t};\n\t}, [\n\t\tstate.zoom,\n\t\tstate.rotation,\n\t\tstate.cropRect.width,\n\t\tstate.cropRect.height,\n\t\tstate.flip.horizontal,\n\t\tstate.flip.vertical,\n\t] );\n\n\treturn ariaMessage;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAKO;AACP,kBAA4B;AAQ5B,IAAM,mBAAmB;AAEzB,SAAS,sBAAuB,OAA8B;AAC7D,QAAM,EAAE,YAAY,SAAS,IAAI,MAAM;AACvC,MAAK,cAAc,UAAW;AAC7B,eAAO,gBAAI,qCAAsC;AAAA,EAClD;AACA,MAAK,YAAa;AACjB,eAAO,gBAAI,sBAAuB;AAAA,EACnC;AACA,MAAK,UAAW;AACf,eAAO,gBAAI,oBAAqB;AAAA,EACjC;AACA,aAAO,gBAAI,cAAe;AAC3B;AAGA,SAAS,kBACR,OACA,eACS;AACT,MACC,kBACE,cAAc,KAAK,eAAe,MAAM,KAAK,cAC9C,cAAc,KAAK,aAAa,MAAM,KAAK,WAC3C;AACD,WAAO,sBAAuB,KAAM;AAAA,EACrC;AAEA,QAAM,QAAkB,CAAC;AACzB,QAAM;AAAA,QACL;AAAA;AAAA,UAEC,gBAAI,WAAY;AAAA,MAChB,KAAK,MAAO,MAAM,OAAO,GAAI;AAAA,IAC9B;AAAA,EACD;AACA,MAAK,MAAM,aAAa,GAAI;AAC3B,UAAM;AAAA,UACL;AAAA;AAAA,YAEC,gBAAI,qBAAsB;AAAA,QAC1B,KAAK,MAAO,MAAM,QAAS;AAAA,MAC5B;AAAA,IACD;AAAA,EACD;AACA,QA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