@wordpress/media-editor 0.21.0 → 0.22.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 (339) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/components/media-editor/index.cjs +533 -686
  3. package/build/components/media-editor/index.cjs.map +1 -7
  4. package/build/components/media-editor/use-crop-options.cjs +43 -57
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -7
  6. package/build/components/media-editor/use-save-media-editor.cjs +111 -185
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
  8. package/build/components/media-editor-canvas/index.cjs +122 -124
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -7
  10. package/build/components/media-editor-crop-panel/index.cjs +65 -72
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
  12. package/build/components/media-editor-fine-rotation/index.cjs +62 -72
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
  14. package/build/components/media-editor-image-controls/index.cjs +183 -257
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -7
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +119 -157
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
  18. package/build/components/media-editor-modal/build-modifiers.cjs +107 -88
  19. package/build/components/media-editor-modal/build-modifiers.cjs.map +1 -7
  20. package/build/components/media-editor-modal/index.cjs +112 -155
  21. package/build/components/media-editor-modal/index.cjs.map +1 -7
  22. package/build/components/media-editor-provider/index.cjs +32 -55
  23. package/build/components/media-editor-provider/index.cjs.map +1 -7
  24. package/build/components/media-form/index.cjs +76 -77
  25. package/build/components/media-form/index.cjs.map +1 -7
  26. package/build/components/media-preview/index.cjs +114 -114
  27. package/build/components/media-preview/index.cjs.map +1 -7
  28. package/build/components/rotation-ruler/index.cjs +181 -188
  29. package/build/components/rotation-ruler/index.cjs.map +1 -7
  30. package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
  31. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
  32. package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
  33. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
  34. package/build/image-editor/core/camera.cjs +257 -205
  35. package/build/image-editor/core/camera.cjs.map +1 -7
  36. package/build/image-editor/core/constants.cjs +127 -102
  37. package/build/image-editor/core/constants.cjs.map +1 -7
  38. package/build/image-editor/core/containment.cjs +275 -262
  39. package/build/image-editor/core/containment.cjs.map +1 -7
  40. package/build/image-editor/core/crop-rect.cjs +33 -44
  41. package/build/image-editor/core/crop-rect.cjs.map +1 -7
  42. package/build/image-editor/core/export/canvas-renderer.cjs +165 -135
  43. package/build/image-editor/core/export/canvas-renderer.cjs.map +1 -7
  44. package/build/image-editor/core/index.cjs +88 -61
  45. package/build/image-editor/core/interaction-controller.cjs +583 -646
  46. package/build/image-editor/core/interaction-controller.cjs.map +1 -7
  47. package/build/image-editor/core/math/rotation.cjs +26 -35
  48. package/build/image-editor/core/math/rotation.cjs.map +1 -7
  49. package/build/image-editor/core/math/sanitize.cjs +124 -80
  50. package/build/image-editor/core/math/sanitize.cjs.map +1 -7
  51. package/build/image-editor/core/setter-helpers.cjs +57 -60
  52. package/build/image-editor/core/setter-helpers.cjs.map +1 -7
  53. package/build/image-editor/core/source-region.cjs +220 -190
  54. package/build/image-editor/core/source-region.cjs.map +1 -7
  55. package/build/image-editor/core/state.cjs +278 -265
  56. package/build/image-editor/core/state.cjs.map +1 -7
  57. package/build/image-editor/core/stencil-math.cjs +193 -206
  58. package/build/image-editor/core/stencil-math.cjs.map +1 -7
  59. package/build/image-editor/core/transform-style.cjs +39 -48
  60. package/build/image-editor/core/transform-style.cjs.map +1 -7
  61. package/build/image-editor/core/transforms/pipeline.cjs +36 -38
  62. package/build/image-editor/core/transforms/pipeline.cjs.map +1 -7
  63. package/build/image-editor/core/types.cjs +4 -18
  64. package/build/image-editor/core/viewport-state.cjs +31 -45
  65. package/build/image-editor/core/viewport-state.cjs.map +1 -7
  66. package/build/image-editor/index.cjs +65 -64
  67. package/build/image-editor/react/components/cropper-provider.cjs +44 -45
  68. package/build/image-editor/react/components/cropper-provider.cjs.map +1 -7
  69. package/build/image-editor/react/components/cropper.cjs +583 -710
  70. package/build/image-editor/react/components/cropper.cjs.map +1 -7
  71. package/build/image-editor/react/components/index.cjs +22 -33
  72. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +135 -160
  73. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +1 -7
  74. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +28 -59
  75. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +1 -7
  76. package/build/image-editor/react/components/overlays/grid-overlay.cjs +58 -88
  77. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +1 -7
  78. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +361 -420
  79. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +1 -7
  80. package/build/image-editor/react/components/viewport-provider.cjs +21 -46
  81. package/build/image-editor/react/components/viewport-provider.cjs.map +1 -7
  82. package/build/image-editor/react/hooks/build-cropper-setters.cjs +76 -67
  83. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +1 -7
  84. package/build/image-editor/react/hooks/index.cjs +16 -31
  85. package/build/image-editor/react/hooks/use-aria-announcer.cjs +90 -146
  86. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +1 -7
  87. package/build/image-editor/react/hooks/use-cropper-controller.cjs +80 -0
  88. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +1 -0
  89. package/build/image-editor/react/hooks/use-interaction.cjs +179 -205
  90. package/build/image-editor/react/hooks/use-interaction.cjs.map +1 -7
  91. package/build/image-editor/react/hooks/use-transform-style.cjs +20 -34
  92. package/build/image-editor/react/hooks/use-transform-style.cjs.map +1 -7
  93. package/build/image-editor/react/hooks/use-viewport-state.cjs +36 -47
  94. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +1 -7
  95. package/build/image-editor/react/visually-hidden-style.cjs +21 -38
  96. package/build/image-editor/react/visually-hidden-style.cjs.map +1 -7
  97. package/build/index.cjs +45 -39
  98. package/build/lock-unlock.cjs +9 -35
  99. package/build/lock-unlock.cjs.map +1 -7
  100. package/build/private-apis.cjs +16 -37
  101. package/build/private-apis.cjs.map +1 -7
  102. package/build/state/aspect-ratio-presets.cjs +53 -0
  103. package/build/state/aspect-ratio-presets.cjs.map +1 -0
  104. package/build/state/composite-reducer.cjs +134 -112
  105. package/build/state/composite-reducer.cjs.map +1 -7
  106. package/build/state/index.cjs +63 -47
  107. package/build/state/media-editor-state-provider.cjs +35 -48
  108. package/build/state/media-editor-state-provider.cjs.map +1 -7
  109. package/build/state/types.cjs +12 -31
  110. package/build/state/types.cjs.map +1 -7
  111. package/build/state/use-media-editor-state.cjs +261 -294
  112. package/build/state/use-media-editor-state.cjs.map +1 -7
  113. package/build/store/actions.cjs +17 -44
  114. package/build/store/actions.cjs.map +1 -7
  115. package/build/store/constants.cjs +8 -29
  116. package/build/store/constants.cjs.map +1 -7
  117. package/build/store/index.cjs +33 -40
  118. package/build/store/index.cjs.map +1 -7
  119. package/build/store/reducer.cjs +28 -50
  120. package/build/store/reducer.cjs.map +1 -7
  121. package/build/store/selectors.cjs +16 -41
  122. package/build/store/selectors.cjs.map +1 -7
  123. package/build/utils/get-media-type.cjs +18 -41
  124. package/build/utils/get-media-type.cjs.map +1 -7
  125. package/build/utils/index.cjs +9 -28
  126. package/build-module/components/media-editor/index.mjs +490 -673
  127. package/build-module/components/media-editor/index.mjs.map +1 -7
  128. package/build-module/components/media-editor/use-crop-options.mjs +38 -32
  129. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
  130. package/build-module/components/media-editor/use-save-media-editor.mjs +89 -157
  131. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
  132. package/build-module/components/media-editor-canvas/index.mjs +98 -96
  133. package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
  134. package/build-module/components/media-editor-crop-panel/index.mjs +43 -46
  135. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
  136. package/build-module/components/media-editor-fine-rotation/index.mjs +39 -45
  137. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
  138. package/build-module/components/media-editor-image-controls/index.mjs +172 -237
  139. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
  140. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +112 -137
  141. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
  142. package/build-module/components/media-editor-modal/build-modifiers.mjs +103 -64
  143. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +1 -7
  144. package/build-module/components/media-editor-modal/index.mjs +88 -124
  145. package/build-module/components/media-editor-modal/index.mjs.map +1 -7
  146. package/build-module/components/media-editor-provider/index.mjs +26 -29
  147. package/build-module/components/media-editor-provider/index.mjs.map +1 -7
  148. package/build-module/components/media-form/index.mjs +68 -56
  149. package/build-module/components/media-form/index.mjs.map +1 -7
  150. package/build-module/components/media-preview/index.mjs +106 -90
  151. package/build-module/components/media-preview/index.mjs.map +1 -7
  152. package/build-module/components/rotation-ruler/index.mjs +161 -164
  153. package/build-module/components/rotation-ruler/index.mjs.map +1 -7
  154. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
  155. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
  156. package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
  157. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
  158. package/build-module/image-editor/core/camera.mjs +245 -178
  159. package/build-module/image-editor/core/camera.mjs.map +1 -7
  160. package/build-module/image-editor/core/constants.mjs +110 -64
  161. package/build-module/image-editor/core/constants.mjs.map +1 -7
  162. package/build-module/image-editor/core/containment.mjs +265 -237
  163. package/build-module/image-editor/core/containment.mjs.map +1 -7
  164. package/build-module/image-editor/core/crop-rect.mjs +29 -20
  165. package/build-module/image-editor/core/crop-rect.mjs.map +1 -7
  166. package/build-module/image-editor/core/export/canvas-renderer.mjs +155 -105
  167. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +1 -7
  168. package/build-module/image-editor/core/index.mjs +5 -34
  169. package/build-module/image-editor/core/interaction-controller.mjs +579 -628
  170. package/build-module/image-editor/core/interaction-controller.mjs.map +1 -7
  171. package/build-module/image-editor/core/math/rotation.mjs +21 -10
  172. package/build-module/image-editor/core/math/rotation.mjs.map +1 -7
  173. package/build-module/image-editor/core/math/sanitize.mjs +116 -52
  174. package/build-module/image-editor/core/math/sanitize.mjs.map +1 -7
  175. package/build-module/image-editor/core/setter-helpers.mjs +52 -35
  176. package/build-module/image-editor/core/setter-helpers.mjs.map +1 -7
  177. package/build-module/image-editor/core/source-region.mjs +210 -160
  178. package/build-module/image-editor/core/source-region.mjs.map +1 -7
  179. package/build-module/image-editor/core/state.mjs +271 -243
  180. package/build-module/image-editor/core/state.mjs.map +1 -7
  181. package/build-module/image-editor/core/stencil-math.mjs +185 -178
  182. package/build-module/image-editor/core/stencil-math.mjs.map +1 -7
  183. package/build-module/image-editor/core/transform-style.mjs +34 -23
  184. package/build-module/image-editor/core/transform-style.mjs.map +1 -7
  185. package/build-module/image-editor/core/transforms/pipeline.mjs +29 -11
  186. package/build-module/image-editor/core/transforms/pipeline.mjs.map +1 -7
  187. package/build-module/image-editor/core/types.mjs +0 -1
  188. package/build-module/image-editor/core/viewport-state.mjs +26 -20
  189. package/build-module/image-editor/core/viewport-state.mjs.map +1 -7
  190. package/build-module/image-editor/index.mjs +3 -38
  191. package/build-module/image-editor/react/components/cropper-provider.mjs +38 -21
  192. package/build-module/image-editor/react/components/cropper-provider.mjs.map +1 -7
  193. package/build-module/image-editor/react/components/cropper.mjs +550 -686
  194. package/build-module/image-editor/react/components/cropper.mjs.map +1 -7
  195. package/build-module/image-editor/react/components/index.mjs +1 -7
  196. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +130 -135
  197. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +1 -7
  198. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +24 -35
  199. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +1 -7
  200. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +54 -64
  201. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +1 -7
  202. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +355 -407
  203. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +1 -7
  204. package/build-module/image-editor/react/components/viewport-provider.mjs +15 -22
  205. package/build-module/image-editor/react/components/viewport-provider.mjs.map +1 -7
  206. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +72 -43
  207. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +1 -7
  208. package/build-module/image-editor/react/hooks/index.mjs +2 -7
  209. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +83 -119
  210. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +1 -7
  211. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +75 -0
  212. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +1 -0
  213. package/build-module/image-editor/react/hooks/use-interaction.mjs +175 -183
  214. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +1 -7
  215. package/build-module/image-editor/react/hooks/use-transform-style.mjs +15 -9
  216. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +1 -7
  217. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +32 -26
  218. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +1 -7
  219. package/build-module/image-editor/react/visually-hidden-style.mjs +17 -14
  220. package/build-module/image-editor/react/visually-hidden-style.mjs.map +1 -7
  221. package/build-module/index.mjs +3 -10
  222. package/build-module/lock-unlock.mjs +5 -10
  223. package/build-module/lock-unlock.mjs.map +1 -7
  224. package/build-module/private-apis.mjs +8 -9
  225. package/build-module/private-apis.mjs.map +1 -7
  226. package/build-module/state/aspect-ratio-presets.mjs +48 -0
  227. package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
  228. package/build-module/state/composite-reducer.mjs +114 -90
  229. package/build-module/state/composite-reducer.mjs.map +1 -7
  230. package/build-module/state/index.mjs +5 -25
  231. package/build-module/state/media-editor-state-provider.mjs +29 -24
  232. package/build-module/state/media-editor-state-provider.mjs.map +1 -7
  233. package/build-module/state/types.mjs +8 -7
  234. package/build-module/state/types.mjs.map +1 -7
  235. package/build-module/state/use-media-editor-state.mjs +256 -286
  236. package/build-module/state/use-media-editor-state.mjs.map +1 -7
  237. package/build-module/store/actions.mjs +12 -19
  238. package/build-module/store/actions.mjs.map +1 -7
  239. package/build-module/store/constants.mjs +4 -5
  240. package/build-module/store/constants.mjs.map +1 -7
  241. package/build-module/store/index.mjs +8 -9
  242. package/build-module/store/index.mjs.map +1 -7
  243. package/build-module/store/reducer.mjs +23 -26
  244. package/build-module/store/reducer.mjs.map +1 -7
  245. package/build-module/store/selectors.mjs +8 -13
  246. package/build-module/store/selectors.mjs.map +1 -7
  247. package/build-module/utils/get-media-type.mjs +14 -17
  248. package/build-module/utils/get-media-type.mjs.map +1 -7
  249. package/build-module/utils/index.mjs +1 -6
  250. package/build-style/style-rtl.css +41 -4
  251. package/build-style/style.css +41 -4
  252. package/build-types/components/media-editor/index.d.ts +4 -0
  253. package/build-types/components/media-editor/index.d.ts.map +1 -1
  254. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  255. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  256. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  257. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  258. package/build-types/components/media-editor-modal/build-modifiers.d.ts +6 -5
  259. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -1
  260. package/build-types/components/media-preview/index.d.ts.map +1 -1
  261. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  262. package/build-types/image-editor/core/constants.d.ts +0 -1
  263. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  264. package/build-types/image-editor/core/index.d.ts +1 -1
  265. package/build-types/image-editor/core/index.d.ts.map +1 -1
  266. package/build-types/image-editor/core/setter-helpers.d.ts +1 -1
  267. package/build-types/image-editor/core/types.d.ts +1 -1
  268. package/build-types/image-editor/index.d.ts +7 -6
  269. package/build-types/image-editor/index.d.ts.map +1 -1
  270. package/build-types/image-editor/react/components/cropper-provider.d.ts +2 -2
  271. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  272. package/build-types/image-editor/react/components/cropper.d.ts +5 -14
  273. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  274. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +2 -2
  275. package/build-types/image-editor/react/hooks/index.d.ts +2 -2
  276. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -1
  277. package/build-types/image-editor/react/hooks/{use-cropper-reducer.d.ts → use-cropper-controller.d.ts} +12 -12
  278. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +1 -0
  279. package/build-types/state/aspect-ratio-presets.d.ts +7 -0
  280. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
  281. package/build-types/state/composite-reducer.d.ts +1 -1
  282. package/build-types/state/composite-reducer.d.ts.map +1 -1
  283. package/build-types/state/index.d.ts +1 -0
  284. package/build-types/state/index.d.ts.map +1 -1
  285. package/build-types/state/types.d.ts +2 -1
  286. package/build-types/state/types.d.ts.map +1 -1
  287. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  288. package/package.json +21 -21
  289. package/src/components/media-editor/index.tsx +215 -162
  290. package/src/components/media-editor/style.scss +19 -0
  291. package/src/components/media-editor/use-crop-options.ts +5 -2
  292. package/src/components/media-editor/use-save-media-editor.ts +2 -6
  293. package/src/components/media-editor-canvas/index.tsx +16 -26
  294. package/src/components/media-editor-image-controls/index.tsx +4 -2
  295. package/src/components/media-editor-modal/build-modifiers.ts +13 -7
  296. package/src/components/media-editor-modal/style.scss +1 -1
  297. package/src/components/media-preview/index.tsx +66 -23
  298. package/src/components/media-preview/style.scss +16 -2
  299. package/src/components/rotation-ruler/style.scss +6 -2
  300. package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
  301. package/src/image-editor/README.md +8 -8
  302. package/src/image-editor/core/constants.ts +0 -13
  303. package/src/image-editor/core/index.ts +1 -5
  304. package/src/image-editor/core/setter-helpers.ts +1 -1
  305. package/src/image-editor/core/types.ts +1 -1
  306. package/src/image-editor/docs/architecture.md +1 -1
  307. package/src/image-editor/docs/recipes.md +3 -3
  308. package/src/image-editor/index.ts +7 -16
  309. package/src/image-editor/react/components/cropper-provider.tsx +5 -5
  310. package/src/image-editor/react/components/cropper.tsx +19 -27
  311. package/src/image-editor/react/hooks/build-cropper-setters.ts +2 -2
  312. package/src/image-editor/react/hooks/index.ts +2 -2
  313. package/src/image-editor/react/hooks/{use-cropper-reducer.ts → use-cropper-controller.ts} +11 -11
  314. package/src/state/aspect-ratio-presets.ts +18 -0
  315. package/src/state/composite-reducer.ts +2 -2
  316. package/src/state/index.ts +1 -0
  317. package/src/state/types.ts +2 -6
  318. package/src/state/use-media-editor-state.ts +7 -5
  319. package/build/image-editor/core/index.cjs.map +0 -7
  320. package/build/image-editor/core/types.cjs.map +0 -7
  321. package/build/image-editor/index.cjs.map +0 -7
  322. package/build/image-editor/react/components/index.cjs.map +0 -7
  323. package/build/image-editor/react/hooks/index.cjs.map +0 -7
  324. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
  325. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
  326. package/build/index.cjs.map +0 -7
  327. package/build/state/index.cjs.map +0 -7
  328. package/build/utils/index.cjs.map +0 -7
  329. package/build-module/image-editor/core/index.mjs.map +0 -7
  330. package/build-module/image-editor/core/types.mjs.map +0 -7
  331. package/build-module/image-editor/index.mjs.map +0 -7
  332. package/build-module/image-editor/react/components/index.mjs.map +0 -7
  333. package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
  334. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
  335. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
  336. package/build-module/index.mjs.map +0 -7
  337. package/build-module/state/index.mjs.map +0 -7
  338. package/build-module/utils/index.mjs.map +0 -7
  339. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
@@ -1,172 +1,147 @@
1
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
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
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"
6
+ let _wordpress_element = require("@wordpress/element");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+ // packages/media-editor/src/image-editor/react/components/overlays/dimensions-overlay.tsx
9
+ const HANDLE_GAP_PX = 12;
10
+ const TRANSLATE_PERCENT = {
11
+ before: "-100%",
12
+ center: "-50%",
13
+ after: "0"
33
14
  };
34
- var GAP_DIRECTION = {
35
- before: -1,
36
- center: 0,
37
- after: 1
15
+ const GAP_DIRECTION = {
16
+ before: -1,
17
+ center: 0,
18
+ after: 1
38
19
  };
39
- var OPPOSITE_SIDE = {
40
- before: "after",
41
- center: "center",
42
- after: "before"
20
+ const OPPOSITE_SIDE = {
21
+ before: "after",
22
+ center: "center",
23
+ after: "before"
43
24
  };
25
+ /**
26
+ * Preferred anchor for a handle, before edge-clipping is considered:
27
+ * tooltip sits outward from the crop rectangle's center.
28
+ *
29
+ * @param handle
30
+ */
44
31
  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 };
32
+ let x = "center";
33
+ if (handle.includes("w")) x = "before";
34
+ else if (handle.includes("e")) x = "after";
35
+ let y = "center";
36
+ if (handle.includes("n")) y = "before";
37
+ else if (handle.includes("s")) y = "after";
38
+ return {
39
+ x,
40
+ y
41
+ };
58
42
  }
43
+ /**
44
+ * Start coordinate of a tooltip placed on the given side of `handlePos`,
45
+ * accounting for the per-side handle gap and the tooltip's own length.
46
+ *
47
+ * @param side
48
+ * @param handlePos
49
+ * @param length
50
+ */
59
51
  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;
52
+ if (side === "before") return handlePos - HANDLE_GAP_PX - length;
53
+ if (side === "after") return handlePos + HANDLE_GAP_PX;
54
+ return handlePos - length / 2;
67
55
  }
56
+ /**
57
+ * Picks a side that keeps the tooltip inside the container along one
58
+ * axis, preferring the supplied side and falling back to its opposite,
59
+ * then center.
60
+ *
61
+ * @param preferred
62
+ * @param handlePos
63
+ * @param length
64
+ * @param containerLength
65
+ */
68
66
  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
- );
67
+ const fits = (side) => {
68
+ const start = sideStart(side, handlePos, length);
69
+ return start >= 0 && start + length <= containerLength;
70
+ };
71
+ if (fits(preferred)) return preferred;
72
+ const opposite = OPPOSITE_SIDE[preferred];
73
+ if (opposite !== preferred && fits(opposite)) return opposite;
74
+ if (preferred !== "center" && fits("center")) return "center";
75
+ const overflow = (side) => {
76
+ const start = sideStart(side, handlePos, length);
77
+ return Math.max(0, -start) + Math.max(0, start + length - containerLength);
78
+ };
79
+ return [
80
+ preferred,
81
+ opposite,
82
+ "center"
83
+ ].reduce((best, side) => overflow(side) < overflow(best) ? side : best);
91
84
  }
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
- );
85
+ /**
86
+ * Tooltip that follows the active resize handle during a pointer drag,
87
+ * showing the current output dimensions of the crop in source pixels.
88
+ *
89
+ * Renders nothing outside of a pointer-driven resize, so keyboard
90
+ * arrow-key adjustments and pan/zoom gestures stay quiet.
91
+ *
92
+ * @param props
93
+ * @param props.cropRect
94
+ * @param props.containerSize
95
+ * @param props.imageSize
96
+ * @param props.activeHandle
97
+ * @param props.outputWidth
98
+ * @param props.outputHeight
99
+ */
100
+ function DimensionsOverlay({ cropRect, containerSize, imageSize, activeHandle, outputWidth, outputHeight }) {
101
+ const tooltipRef = (0, _wordpress_element.useRef)(null);
102
+ const [tooltipSize, setTooltipSize] = (0, _wordpress_element.useState)(null);
103
+ (0, _wordpress_element.useLayoutEffect)(() => {
104
+ if (!tooltipRef.current) return;
105
+ const rect = tooltipRef.current.getBoundingClientRect();
106
+ setTooltipSize((prev) => {
107
+ if (prev && prev.width === rect.width && prev.height === rect.height) return prev;
108
+ return {
109
+ width: rect.width,
110
+ height: rect.height
111
+ };
112
+ });
113
+ }, [outputWidth, outputHeight]);
114
+ if (!activeHandle || containerSize.width === 0 || containerSize.height === 0) return null;
115
+ const offsetX = (containerSize.width - imageSize.width) / 2;
116
+ const offsetY = (containerSize.height - imageSize.height) / 2;
117
+ const left = offsetX + cropRect.x * imageSize.width;
118
+ const top = offsetY + cropRect.y * imageSize.height;
119
+ const width = cropRect.width * imageSize.width;
120
+ const height = cropRect.height * imageSize.height;
121
+ let handleX = left + width / 2;
122
+ if (activeHandle.includes("w")) handleX = left;
123
+ else if (activeHandle.includes("e")) handleX = left + width;
124
+ let handleY = top + height / 2;
125
+ if (activeHandle.includes("n")) handleY = top;
126
+ else if (activeHandle.includes("s")) handleY = top + height;
127
+ const preferred = preferredAnchor(activeHandle);
128
+ const anchor = tooltipSize ? {
129
+ x: fittingSide(preferred.x, handleX, tooltipSize.width, containerSize.width),
130
+ y: fittingSide(preferred.y, handleY, tooltipSize.height, containerSize.height)
131
+ } : preferred;
132
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
133
+ ref: tooltipRef,
134
+ className: "wp-media-editor-image-editor__dimensions-tooltip",
135
+ "data-testid": "cropper-dimensions-tooltip",
136
+ style: {
137
+ left: handleX + GAP_DIRECTION[anchor.x] * HANDLE_GAP_PX,
138
+ top: handleY + GAP_DIRECTION[anchor.y] * HANDLE_GAP_PX,
139
+ transform: `translate(${TRANSLATE_PERCENT[anchor.x]}, ${TRANSLATE_PERCENT[anchor.y]})`
140
+ },
141
+ "aria-hidden": "true",
142
+ children: `W: ${Math.round(outputWidth)}px H: ${Math.round(outputHeight)}px`
143
+ });
167
144
  }
168
- // Annotate the CommonJS export names for ESM import in node:
169
- 0 && (module.exports = {
170
- DimensionsOverlay
171
- });
172
- //# sourceMappingURL=dimensions-overlay.cjs.map
145
+ exports.DimensionsOverlay = DimensionsOverlay;
146
+
147
+ //# sourceMappingURL=dimensions-overlay.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/image-editor/react/components/overlays/dimensions-overlay.tsx"],
4
- "sourcesContent": ["import { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport type { HandlePosition, NormalizedRect, Size } from '../../../core/types';\n\nconst HANDLE_GAP_PX = 12;\n\n/**\n * Which side of the handle a tooltip axis sits on. `before` places the\n * tooltip on the negative side of the handle (above for Y, left for X),\n * `after` on the positive side, `center` keeps it aligned with the handle.\n */\ntype AxisSide = 'before' | 'center' | 'after';\n\ninterface Anchor {\n\tx: AxisSide;\n\ty: AxisSide;\n}\n\nconst TRANSLATE_PERCENT: Record< AxisSide, string > = {\n\tbefore: '-100%',\n\tcenter: '-50%',\n\tafter: '0',\n};\n\nconst GAP_DIRECTION: Record< AxisSide, number > = {\n\tbefore: -1,\n\tcenter: 0,\n\tafter: 1,\n};\n\nconst OPPOSITE_SIDE: Record< AxisSide, AxisSide > = {\n\tbefore: 'after',\n\tcenter: 'center',\n\tafter: 'before',\n};\n\n/**\n * Preferred anchor for a handle, before edge-clipping is considered:\n * tooltip sits outward from the crop rectangle's center.\n *\n * @param handle\n */\nfunction preferredAnchor( handle: HandlePosition ): Anchor {\n\tlet x: AxisSide = 'center';\n\tif ( handle.includes( 'w' ) ) {\n\t\tx = 'before';\n\t} else if ( handle.includes( 'e' ) ) {\n\t\tx = 'after';\n\t}\n\n\tlet y: AxisSide = 'center';\n\tif ( handle.includes( 'n' ) ) {\n\t\ty = 'before';\n\t} else if ( handle.includes( 's' ) ) {\n\t\ty = 'after';\n\t}\n\n\treturn { x, y };\n}\n\n/**\n * Start coordinate of a tooltip placed on the given side of `handlePos`,\n * accounting for the per-side handle gap and the tooltip's own length.\n *\n * @param side\n * @param handlePos\n * @param length\n */\nfunction sideStart(\n\tside: AxisSide,\n\thandlePos: number,\n\tlength: number\n): number {\n\tif ( side === 'before' ) {\n\t\treturn handlePos - HANDLE_GAP_PX - length;\n\t}\n\tif ( side === 'after' ) {\n\t\treturn handlePos + HANDLE_GAP_PX;\n\t}\n\treturn handlePos - length / 2;\n}\n\n/**\n * Picks a side that keeps the tooltip inside the container along one\n * axis, preferring the supplied side and falling back to its opposite,\n * then center.\n *\n * @param preferred\n * @param handlePos\n * @param length\n * @param containerLength\n */\nfunction fittingSide(\n\tpreferred: AxisSide,\n\thandlePos: number,\n\tlength: number,\n\tcontainerLength: number\n): AxisSide {\n\tconst fits = ( side: AxisSide ) => {\n\t\tconst start = sideStart( side, handlePos, length );\n\t\treturn start >= 0 && start + length <= containerLength;\n\t};\n\n\tif ( fits( preferred ) ) {\n\t\treturn preferred;\n\t}\n\tconst opposite = OPPOSITE_SIDE[ preferred ];\n\tif ( opposite !== preferred && fits( opposite ) ) {\n\t\treturn opposite;\n\t}\n\tif ( preferred !== 'center' && fits( 'center' ) ) {\n\t\treturn 'center';\n\t}\n\t// None of the candidates fully fit — pick the one that pushes the\n\t// least past the container edge. Without this, the chain falls back\n\t// to `preferred`, which is the off-canvas side that triggered the\n\t// flip in the first place, so the tooltip ends up clipped.\n\tconst overflow = ( side: AxisSide ) => {\n\t\tconst start = sideStart( side, handlePos, length );\n\t\treturn (\n\t\t\tMath.max( 0, -start ) +\n\t\t\tMath.max( 0, start + length - containerLength )\n\t\t);\n\t};\n\tconst candidates: AxisSide[] = [ preferred, opposite, 'center' ];\n\treturn candidates.reduce( ( best, side ) =>\n\t\toverflow( side ) < overflow( best ) ? side : best\n\t);\n}\n\ninterface DimensionsOverlayProps {\n\t/** Crop rectangle in normalized coordinates. */\n\tcropRect: NormalizedRect;\n\t/** Container element dimensions in pixels. */\n\tcontainerSize: Size;\n\t/** Rendered image dimensions in pixels within the container. */\n\timageSize: Size;\n\t/** Currently-dragged handle, or null when no pointer drag is active. */\n\tactiveHandle: HandlePosition | null;\n\t/** Output crop width in source pixels. */\n\toutputWidth: number;\n\t/** Output crop height in source pixels. */\n\toutputHeight: number;\n}\n\n/**\n * Tooltip that follows the active resize handle during a pointer drag,\n * showing the current output dimensions of the crop in source pixels.\n *\n * Renders nothing outside of a pointer-driven resize, so keyboard\n * arrow-key adjustments and pan/zoom gestures stay quiet.\n *\n * @param props\n * @param props.cropRect\n * @param props.containerSize\n * @param props.imageSize\n * @param props.activeHandle\n * @param props.outputWidth\n * @param props.outputHeight\n */\nexport function DimensionsOverlay( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n\tactiveHandle,\n\toutputWidth,\n\toutputHeight,\n}: DimensionsOverlayProps ) {\n\tconst tooltipRef = useRef< HTMLDivElement >( null );\n\tconst [ tooltipSize, setTooltipSize ] = useState< Size | null >( null );\n\n\t// Measure the rendered tooltip so we can flip its anchor when it\n\t// would otherwise be clipped by the cropper's `overflow: hidden`\n\t// root. Runs synchronously before paint, so the user never sees\n\t// the un-flipped position. Tracks `outputWidth`/`outputHeight`\n\t// because they drive the digit count, the only thing that changes\n\t// the tooltip's intrinsic size during a drag.\n\tuseLayoutEffect( () => {\n\t\tif ( ! tooltipRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = tooltipRef.current.getBoundingClientRect();\n\t\tsetTooltipSize( ( prev ) => {\n\t\t\tif (\n\t\t\t\tprev &&\n\t\t\t\tprev.width === rect.width &&\n\t\t\t\tprev.height === rect.height\n\t\t\t) {\n\t\t\t\treturn prev;\n\t\t\t}\n\t\t\treturn { width: rect.width, height: rect.height };\n\t\t} );\n\t}, [ outputWidth, outputHeight ] );\n\n\tif (\n\t\t! activeHandle ||\n\t\tcontainerSize.width === 0 ||\n\t\tcontainerSize.height === 0\n\t) {\n\t\treturn null;\n\t}\n\n\tconst offsetX = ( containerSize.width - imageSize.width ) / 2;\n\tconst offsetY = ( containerSize.height - imageSize.height ) / 2;\n\tconst left = offsetX + cropRect.x * imageSize.width;\n\tconst top = offsetY + cropRect.y * imageSize.height;\n\tconst width = cropRect.width * imageSize.width;\n\tconst height = cropRect.height * imageSize.height;\n\n\t// Handle pixel position within the container. Same math as the\n\t// stencil's handle layout, just keyed by direction here so the\n\t// tooltip can anchor to any of the eight.\n\tlet handleX = left + width / 2;\n\tif ( activeHandle.includes( 'w' ) ) {\n\t\thandleX = left;\n\t} else if ( activeHandle.includes( 'e' ) ) {\n\t\thandleX = left + width;\n\t}\n\tlet handleY = top + height / 2;\n\tif ( activeHandle.includes( 'n' ) ) {\n\t\thandleY = top;\n\t} else if ( activeHandle.includes( 's' ) ) {\n\t\thandleY = top + height;\n\t}\n\n\tconst preferred = preferredAnchor( activeHandle );\n\tconst anchor: Anchor = tooltipSize\n\t\t? {\n\t\t\t\tx: fittingSide(\n\t\t\t\t\tpreferred.x,\n\t\t\t\t\thandleX,\n\t\t\t\t\ttooltipSize.width,\n\t\t\t\t\tcontainerSize.width\n\t\t\t\t),\n\t\t\t\ty: fittingSide(\n\t\t\t\t\tpreferred.y,\n\t\t\t\t\thandleY,\n\t\t\t\t\ttooltipSize.height,\n\t\t\t\t\tcontainerSize.height\n\t\t\t\t),\n\t\t\t}\n\t\t: preferred;\n\n\treturn (\n\t\t<div\n\t\t\tref={ tooltipRef }\n\t\t\tclassName=\"wp-media-editor-image-editor__dimensions-tooltip\"\n\t\t\tdata-testid=\"cropper-dimensions-tooltip\"\n\t\t\tstyle={ {\n\t\t\t\tleft: handleX + GAP_DIRECTION[ anchor.x ] * HANDLE_GAP_PX,\n\t\t\t\ttop: handleY + GAP_DIRECTION[ anchor.y ] * HANDLE_GAP_PX,\n\t\t\t\ttransform: `translate(${ TRANSLATE_PERCENT[ anchor.x ] }, ${\n\t\t\t\t\tTRANSLATE_PERCENT[ anchor.y ]\n\t\t\t\t})`,\n\t\t\t} }\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t{ `W: ${ Math.round( outputWidth ) }px H: ${ Math.round(\n\t\t\t\toutputHeight\n\t\t\t) }px` }\n\t\t</div>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAkD;AAmPhD;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,EACnD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AACR;AAQA,SAAS,gBAAiB,QAAiC;AAC1D,MAAI,IAAc;AAClB,MAAK,OAAO,SAAU,GAAI,GAAI;AAC7B,QAAI;AAAA,EACL,WAAY,OAAO,SAAU,GAAI,GAAI;AACpC,QAAI;AAAA,EACL;AAEA,MAAI,IAAc;AAClB,MAAK,OAAO,SAAU,GAAI,GAAI;AAC7B,QAAI;AAAA,EACL,WAAY,OAAO,SAAU,GAAI,GAAI;AACpC,QAAI;AAAA,EACL;AAEA,SAAO,EAAE,GAAG,EAAE;AACf;AAUA,SAAS,UACR,MACA,WACA,QACS;AACT,MAAK,SAAS,UAAW;AACxB,WAAO,YAAY,gBAAgB;AAAA,EACpC;AACA,MAAK,SAAS,SAAU;AACvB,WAAO,YAAY;AAAA,EACpB;AACA,SAAO,YAAY,SAAS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E,SAAU,KAAK;AAAA,QACjD;AAAA,MACD,CAAE;AAAA;AAAA,EACH;AAEF;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"dimensions-overlay.cjs","names":["useRef","useState"],"sources":["../../../../../src/image-editor/react/components/overlays/dimensions-overlay.tsx"],"sourcesContent":["import { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport type { HandlePosition, NormalizedRect, Size } from '../../../core/types';\n\nconst HANDLE_GAP_PX = 12;\n\n/**\n * Which side of the handle a tooltip axis sits on. `before` places the\n * tooltip on the negative side of the handle (above for Y, left for X),\n * `after` on the positive side, `center` keeps it aligned with the handle.\n */\ntype AxisSide = 'before' | 'center' | 'after';\n\ninterface Anchor {\n\tx: AxisSide;\n\ty: AxisSide;\n}\n\nconst TRANSLATE_PERCENT: Record< AxisSide, string > = {\n\tbefore: '-100%',\n\tcenter: '-50%',\n\tafter: '0',\n};\n\nconst GAP_DIRECTION: Record< AxisSide, number > = {\n\tbefore: -1,\n\tcenter: 0,\n\tafter: 1,\n};\n\nconst OPPOSITE_SIDE: Record< AxisSide, AxisSide > = {\n\tbefore: 'after',\n\tcenter: 'center',\n\tafter: 'before',\n};\n\n/**\n * Preferred anchor for a handle, before edge-clipping is considered:\n * tooltip sits outward from the crop rectangle's center.\n *\n * @param handle\n */\nfunction preferredAnchor( handle: HandlePosition ): Anchor {\n\tlet x: AxisSide = 'center';\n\tif ( handle.includes( 'w' ) ) {\n\t\tx = 'before';\n\t} else if ( handle.includes( 'e' ) ) {\n\t\tx = 'after';\n\t}\n\n\tlet y: AxisSide = 'center';\n\tif ( handle.includes( 'n' ) ) {\n\t\ty = 'before';\n\t} else if ( handle.includes( 's' ) ) {\n\t\ty = 'after';\n\t}\n\n\treturn { x, y };\n}\n\n/**\n * Start coordinate of a tooltip placed on the given side of `handlePos`,\n * accounting for the per-side handle gap and the tooltip's own length.\n *\n * @param side\n * @param handlePos\n * @param length\n */\nfunction sideStart(\n\tside: AxisSide,\n\thandlePos: number,\n\tlength: number\n): number {\n\tif ( side === 'before' ) {\n\t\treturn handlePos - HANDLE_GAP_PX - length;\n\t}\n\tif ( side === 'after' ) {\n\t\treturn handlePos + HANDLE_GAP_PX;\n\t}\n\treturn handlePos - length / 2;\n}\n\n/**\n * Picks a side that keeps the tooltip inside the container along one\n * axis, preferring the supplied side and falling back to its opposite,\n * then center.\n *\n * @param preferred\n * @param handlePos\n * @param length\n * @param containerLength\n */\nfunction fittingSide(\n\tpreferred: AxisSide,\n\thandlePos: number,\n\tlength: number,\n\tcontainerLength: number\n): AxisSide {\n\tconst fits = ( side: AxisSide ) => {\n\t\tconst start = sideStart( side, handlePos, length );\n\t\treturn start >= 0 && start + length <= containerLength;\n\t};\n\n\tif ( fits( preferred ) ) {\n\t\treturn preferred;\n\t}\n\tconst opposite = OPPOSITE_SIDE[ preferred ];\n\tif ( opposite !== preferred && fits( opposite ) ) {\n\t\treturn opposite;\n\t}\n\tif ( preferred !== 'center' && fits( 'center' ) ) {\n\t\treturn 'center';\n\t}\n\t// None of the candidates fully fit — pick the one that pushes the\n\t// least past the container edge. Without this, the chain falls back\n\t// to `preferred`, which is the off-canvas side that triggered the\n\t// flip in the first place, so the tooltip ends up clipped.\n\tconst overflow = ( side: AxisSide ) => {\n\t\tconst start = sideStart( side, handlePos, length );\n\t\treturn (\n\t\t\tMath.max( 0, -start ) +\n\t\t\tMath.max( 0, start + length - containerLength )\n\t\t);\n\t};\n\tconst candidates: AxisSide[] = [ preferred, opposite, 'center' ];\n\treturn candidates.reduce( ( best, side ) =>\n\t\toverflow( side ) < overflow( best ) ? side : best\n\t);\n}\n\ninterface DimensionsOverlayProps {\n\t/** Crop rectangle in normalized coordinates. */\n\tcropRect: NormalizedRect;\n\t/** Container element dimensions in pixels. */\n\tcontainerSize: Size;\n\t/** Rendered image dimensions in pixels within the container. */\n\timageSize: Size;\n\t/** Currently-dragged handle, or null when no pointer drag is active. */\n\tactiveHandle: HandlePosition | null;\n\t/** Output crop width in source pixels. */\n\toutputWidth: number;\n\t/** Output crop height in source pixels. */\n\toutputHeight: number;\n}\n\n/**\n * Tooltip that follows the active resize handle during a pointer drag,\n * showing the current output dimensions of the crop in source pixels.\n *\n * Renders nothing outside of a pointer-driven resize, so keyboard\n * arrow-key adjustments and pan/zoom gestures stay quiet.\n *\n * @param props\n * @param props.cropRect\n * @param props.containerSize\n * @param props.imageSize\n * @param props.activeHandle\n * @param props.outputWidth\n * @param props.outputHeight\n */\nexport function DimensionsOverlay( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n\tactiveHandle,\n\toutputWidth,\n\toutputHeight,\n}: DimensionsOverlayProps ) {\n\tconst tooltipRef = useRef< HTMLDivElement >( null );\n\tconst [ tooltipSize, setTooltipSize ] = useState< Size | null >( null );\n\n\t// Measure the rendered tooltip so we can flip its anchor when it\n\t// would otherwise be clipped by the cropper's `overflow: hidden`\n\t// root. Runs synchronously before paint, so the user never sees\n\t// the un-flipped position. Tracks `outputWidth`/`outputHeight`\n\t// because they drive the digit count, the only thing that changes\n\t// the tooltip's intrinsic size during a drag.\n\tuseLayoutEffect( () => {\n\t\tif ( ! tooltipRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = tooltipRef.current.getBoundingClientRect();\n\t\tsetTooltipSize( ( prev ) => {\n\t\t\tif (\n\t\t\t\tprev &&\n\t\t\t\tprev.width === rect.width &&\n\t\t\t\tprev.height === rect.height\n\t\t\t) {\n\t\t\t\treturn prev;\n\t\t\t}\n\t\t\treturn { width: rect.width, height: rect.height };\n\t\t} );\n\t}, [ outputWidth, outputHeight ] );\n\n\tif (\n\t\t! activeHandle ||\n\t\tcontainerSize.width === 0 ||\n\t\tcontainerSize.height === 0\n\t) {\n\t\treturn null;\n\t}\n\n\tconst offsetX = ( containerSize.width - imageSize.width ) / 2;\n\tconst offsetY = ( containerSize.height - imageSize.height ) / 2;\n\tconst left = offsetX + cropRect.x * imageSize.width;\n\tconst top = offsetY + cropRect.y * imageSize.height;\n\tconst width = cropRect.width * imageSize.width;\n\tconst height = cropRect.height * imageSize.height;\n\n\t// Handle pixel position within the container. Same math as the\n\t// stencil's handle layout, just keyed by direction here so the\n\t// tooltip can anchor to any of the eight.\n\tlet handleX = left + width / 2;\n\tif ( activeHandle.includes( 'w' ) ) {\n\t\thandleX = left;\n\t} else if ( activeHandle.includes( 'e' ) ) {\n\t\thandleX = left + width;\n\t}\n\tlet handleY = top + height / 2;\n\tif ( activeHandle.includes( 'n' ) ) {\n\t\thandleY = top;\n\t} else if ( activeHandle.includes( 's' ) ) {\n\t\thandleY = top + height;\n\t}\n\n\tconst preferred = preferredAnchor( activeHandle );\n\tconst anchor: Anchor = tooltipSize\n\t\t? {\n\t\t\t\tx: fittingSide(\n\t\t\t\t\tpreferred.x,\n\t\t\t\t\thandleX,\n\t\t\t\t\ttooltipSize.width,\n\t\t\t\t\tcontainerSize.width\n\t\t\t\t),\n\t\t\t\ty: fittingSide(\n\t\t\t\t\tpreferred.y,\n\t\t\t\t\thandleY,\n\t\t\t\t\ttooltipSize.height,\n\t\t\t\t\tcontainerSize.height\n\t\t\t\t),\n\t\t\t}\n\t\t: preferred;\n\n\treturn (\n\t\t<div\n\t\t\tref={ tooltipRef }\n\t\t\tclassName=\"wp-media-editor-image-editor__dimensions-tooltip\"\n\t\t\tdata-testid=\"cropper-dimensions-tooltip\"\n\t\t\tstyle={ {\n\t\t\t\tleft: handleX + GAP_DIRECTION[ anchor.x ] * HANDLE_GAP_PX,\n\t\t\t\ttop: handleY + GAP_DIRECTION[ anchor.y ] * HANDLE_GAP_PX,\n\t\t\t\ttransform: `translate(${ TRANSLATE_PERCENT[ anchor.x ] }, ${\n\t\t\t\t\tTRANSLATE_PERCENT[ anchor.y ]\n\t\t\t\t})`,\n\t\t\t} }\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t{ `W: ${ Math.round( outputWidth ) }px H: ${ Math.round(\n\t\t\t\toutputHeight\n\t\t\t) }px` }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;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MACf;CACD,IACC;CAEH,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACC,KAAM;EACN,WAAU;EACV,eAAY;EACZ,OAAQ;GACP,MAAM,UAAU,cAAe,OAAO,KAAM;GAC5C,KAAK,UAAU,cAAe,OAAO,KAAM;GAC3C,WAAW,aAAc,kBAAmB,OAAO,GAAK,IACvD,kBAAmB,OAAO,GAC1B;EACF;EACA,eAAY;EAEV,UAAA,MAAO,KAAK,MAAO,WAAY,EAAG,QAAS,KAAK,MACjD,YACD,EAAG;CACC,CAAA;AAEP"}
@@ -1,62 +1,31 @@
1
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/dimming-overlay.tsx
21
- var dimming_overlay_exports = {};
22
- __export(dimming_overlay_exports, {
23
- DimmingOverlay: () => DimmingOverlay
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(dimming_overlay_exports);
26
- var import_jsx_runtime = require("react/jsx-runtime");
27
- function DimmingOverlay({
28
- cropRect,
29
- containerSize,
30
- imageSize,
31
- transition
32
- }) {
33
- if (containerSize.width === 0 || containerSize.height === 0) {
34
- return null;
35
- }
36
- const offsetX = (containerSize.width - imageSize.width) / 2;
37
- const offsetY = (containerSize.height - imageSize.height) / 2;
38
- const left = offsetX + cropRect.x * imageSize.width;
39
- const top = offsetY + cropRect.y * imageSize.height;
40
- const width = cropRect.width * imageSize.width;
41
- const height = cropRect.height * imageSize.height;
42
- const composedTransition = transition ? `${transition}, box-shadow 0.15s ease` : void 0;
43
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
44
- "div",
45
- {
46
- className: "wp-media-editor-image-editor__dimming",
47
- "data-testid": "cropper-dimming",
48
- style: {
49
- left,
50
- top,
51
- width,
52
- height,
53
- transition: composedTransition
54
- }
55
- }
56
- );
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ // packages/media-editor/src/image-editor/react/components/overlays/dimming-overlay.tsx
8
+ function DimmingOverlay({ cropRect, containerSize, imageSize, transition }) {
9
+ if (containerSize.width === 0 || containerSize.height === 0) return null;
10
+ const offsetX = (containerSize.width - imageSize.width) / 2;
11
+ const offsetY = (containerSize.height - imageSize.height) / 2;
12
+ const left = offsetX + cropRect.x * imageSize.width;
13
+ const top = offsetY + cropRect.y * imageSize.height;
14
+ const width = cropRect.width * imageSize.width;
15
+ const height = cropRect.height * imageSize.height;
16
+ const composedTransition = transition ? `${transition}, box-shadow 0.15s ease` : void 0;
17
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
18
+ className: "wp-media-editor-image-editor__dimming",
19
+ "data-testid": "cropper-dimming",
20
+ style: {
21
+ left,
22
+ top,
23
+ width,
24
+ height,
25
+ transition: composedTransition
26
+ }
27
+ });
57
28
  }
58
- // Annotate the CommonJS export names for ESM import in node:
59
- 0 && (module.exports = {
60
- DimmingOverlay
61
- });
62
- //# sourceMappingURL=dimming-overlay.cjs.map
29
+ exports.DimmingOverlay = DimmingOverlay;
30
+
31
+ //# sourceMappingURL=dimming-overlay.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/image-editor/react/components/overlays/dimming-overlay.tsx"],
4
- "sourcesContent": ["import type { NormalizedRect, Size } from '../../../core/types';\n\n/**\n * Props for the DimmingOverlay component.\n */\ninterface DimmingOverlayProps {\n\t/** The crop rectangle in normalized coordinates. */\n\tcropRect: NormalizedRect;\n\t/** The container element dimensions in pixels. */\n\tcontainerSize: Size;\n\t/** The rendered image dimensions in pixels within the container. */\n\timageSize: Size;\n\t/** CSS transition string, e.g. during settle animation. */\n\ttransition?: string;\n}\n\n// Renders a semi-transparent overlay outside the crop rectangle using a\n// box-shadow that dims everything outside the crop rect position.\nexport function DimmingOverlay( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n\ttransition,\n}: DimmingOverlayProps ) {\n\tif ( containerSize.width === 0 || containerSize.height === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst offsetX = ( containerSize.width - imageSize.width ) / 2;\n\tconst offsetY = ( containerSize.height - imageSize.height ) / 2;\n\tconst left = offsetX + cropRect.x * imageSize.width;\n\tconst top = offsetY + cropRect.y * imageSize.height;\n\tconst width = cropRect.width * imageSize.width;\n\tconst height = cropRect.height * imageSize.height;\n\n\t// Compose any incoming transition with the stylesheet's box-shadow\n\t// transition so the drag-dimming effect isn't overwritten.\n\tconst composedTransition = transition\n\t\t? `${ transition }, box-shadow 0.15s ease`\n\t\t: undefined;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wp-media-editor-image-editor__dimming\"\n\t\t\tdata-testid=\"cropper-dimming\"\n\t\t\tstyle={ {\n\t\t\t\tleft,\n\t\t\t\ttop,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\ttransition: composedTransition,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CE;AAxBK,SAAS,eAAgB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAyB;AACxB,MAAK,cAAc,UAAU,KAAK,cAAc,WAAW,GAAI;AAC9D,WAAO;AAAA,EACR;AAEA,QAAM,WAAY,cAAc,QAAQ,UAAU,SAAU;AAC5D,QAAM,WAAY,cAAc,SAAS,UAAU,UAAW;AAC9D,QAAM,OAAO,UAAU,SAAS,IAAI,UAAU;AAC9C,QAAM,MAAM,UAAU,SAAS,IAAI,UAAU;AAC7C,QAAM,QAAQ,SAAS,QAAQ,UAAU;AACzC,QAAM,SAAS,SAAS,SAAS,UAAU;AAI3C,QAAM,qBAAqB,aACxB,GAAI,UAAW,4BACf;AAEH,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,eAAY;AAAA,MACZ,OAAQ;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAY;AAAA,MACb;AAAA;AAAA,EACD;AAEF;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"dimming-overlay.cjs","names":[],"sources":["../../../../../src/image-editor/react/components/overlays/dimming-overlay.tsx"],"sourcesContent":["import type { NormalizedRect, Size } from '../../../core/types';\n\n/**\n * Props for the DimmingOverlay component.\n */\ninterface DimmingOverlayProps {\n\t/** The crop rectangle in normalized coordinates. */\n\tcropRect: NormalizedRect;\n\t/** The container element dimensions in pixels. */\n\tcontainerSize: Size;\n\t/** The rendered image dimensions in pixels within the container. */\n\timageSize: Size;\n\t/** CSS transition string, e.g. during settle animation. */\n\ttransition?: string;\n}\n\n// Renders a semi-transparent overlay outside the crop rectangle using a\n// box-shadow that dims everything outside the crop rect position.\nexport function DimmingOverlay( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n\ttransition,\n}: DimmingOverlayProps ) {\n\tif ( containerSize.width === 0 || containerSize.height === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst offsetX = ( containerSize.width - imageSize.width ) / 2;\n\tconst offsetY = ( containerSize.height - imageSize.height ) / 2;\n\tconst left = offsetX + cropRect.x * imageSize.width;\n\tconst top = offsetY + cropRect.y * imageSize.height;\n\tconst width = cropRect.width * imageSize.width;\n\tconst height = cropRect.height * imageSize.height;\n\n\t// Compose any incoming transition with the stylesheet's box-shadow\n\t// transition so the drag-dimming effect isn't overwritten.\n\tconst composedTransition = transition\n\t\t? `${ transition }, box-shadow 0.15s ease`\n\t\t: undefined;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wp-media-editor-image-editor__dimming\"\n\t\t\tdata-testid=\"cropper-dimming\"\n\t\t\tstyle={ {\n\t\t\t\tleft,\n\t\t\t\ttop,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\ttransition: composedTransition,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,eAAgB,EAC/B,UACA,eACA,WACA,cACwB;CACxB,IAAK,cAAc,UAAU,KAAK,cAAc,WAAW,GAC1D,OAAO;CAGR,MAAM,WAAY,cAAc,QAAQ,UAAU,SAAU;CAC5D,MAAM,WAAY,cAAc,SAAS,UAAU,UAAW;CAC9D,MAAM,OAAO,UAAU,SAAS,IAAI,UAAU;CAC9C,MAAM,MAAM,UAAU,SAAS,IAAI,UAAU;CAC7C,MAAM,QAAQ,SAAS,QAAQ,UAAU;CACzC,MAAM,SAAS,SAAS,SAAS,UAAU;CAI3C,MAAM,qBAAqB,aACxB,GAAI,WAAY,2BAChB,KAAA;CAEH,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACC,WAAU;EACV,eAAY;EACZ,OAAQ;GACP;GACA;GACA;GACA;GACA,YAAY;EACb;CACA,CAAA;AAEH"}
@@ -1,91 +1,61 @@
1
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/grid-overlay.tsx
21
- var grid_overlay_exports = {};
22
- __export(grid_overlay_exports, {
23
- GridOverlay: () => GridOverlay
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(grid_overlay_exports);
26
- var import_jsx_runtime = require("react/jsx-runtime");
27
- function GridOverlay({
28
- cropRect,
29
- containerSize,
30
- imageSize
31
- }) {
32
- if (containerSize.width === 0 || containerSize.height === 0) {
33
- return null;
34
- }
35
- const offsetX = (containerSize.width - imageSize.width) / 2;
36
- const offsetY = (containerSize.height - imageSize.height) / 2;
37
- const left = offsetX + cropRect.x * imageSize.width;
38
- const top = offsetY + cropRect.y * imageSize.height;
39
- const width = cropRect.width * imageSize.width;
40
- const height = cropRect.height * imageSize.height;
41
- const thirdW = width / 3;
42
- const thirdH = height / 3;
43
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
44
- "div",
45
- {
46
- className: "wp-media-editor-image-editor__grid",
47
- "data-testid": "cropper-grid",
48
- style: {
49
- left,
50
- top,
51
- width,
52
- height
53
- },
54
- children: [
55
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
- "div",
57
- {
58
- className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
59
- style: { top: thirdH }
60
- }
61
- ),
62
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
- "div",
64
- {
65
- className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
66
- style: { top: thirdH * 2 }
67
- }
68
- ),
69
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
- "div",
71
- {
72
- className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
73
- style: { left: thirdW }
74
- }
75
- ),
76
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
77
- "div",
78
- {
79
- className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
80
- style: { left: thirdW * 2 }
81
- }
82
- )
83
- ]
84
- }
85
- );
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ // packages/media-editor/src/image-editor/react/components/overlays/grid-overlay.tsx
8
+ /**
9
+ * Renders a rule-of-thirds grid inside the crop rectangle.
10
+ *
11
+ * Displays 2 horizontal and 2 vertical lines at 1/3 and 2/3
12
+ * positions within the crop area.
13
+ *
14
+ * @param props Component props.
15
+ * @param props.cropRect The crop rectangle in normalized coordinates.
16
+ * @param props.containerSize The container element dimensions in pixels.
17
+ * @param props.imageSize The rendered image dimensions in pixels.
18
+ * @return The grid overlay element.
19
+ */
20
+ function GridOverlay({ cropRect, containerSize, imageSize }) {
21
+ if (containerSize.width === 0 || containerSize.height === 0) return null;
22
+ const offsetX = (containerSize.width - imageSize.width) / 2;
23
+ const offsetY = (containerSize.height - imageSize.height) / 2;
24
+ const left = offsetX + cropRect.x * imageSize.width;
25
+ const top = offsetY + cropRect.y * imageSize.height;
26
+ const width = cropRect.width * imageSize.width;
27
+ const height = cropRect.height * imageSize.height;
28
+ const thirdW = width / 3;
29
+ const thirdH = height / 3;
30
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
31
+ className: "wp-media-editor-image-editor__grid",
32
+ "data-testid": "cropper-grid",
33
+ style: {
34
+ left,
35
+ top,
36
+ width,
37
+ height
38
+ },
39
+ children: [
40
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
41
+ className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
42
+ style: { top: thirdH }
43
+ }),
44
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
45
+ className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal",
46
+ style: { top: thirdH * 2 }
47
+ }),
48
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
49
+ className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
50
+ style: { left: thirdW }
51
+ }),
52
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
53
+ className: "wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical",
54
+ style: { left: thirdW * 2 }
55
+ })
56
+ ]
57
+ });
86
58
  }
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 0 && (module.exports = {
89
- GridOverlay
90
- });
91
- //# sourceMappingURL=grid-overlay.cjs.map
59
+ exports.GridOverlay = GridOverlay;
60
+
61
+ //# sourceMappingURL=grid-overlay.cjs.map