@wordpress/media-editor 0.22.0 → 0.24.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 (391) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/build/components/media-editor/index.cjs +229 -126
  3. package/build/components/media-editor/index.cjs.map +1 -1
  4. package/build/components/media-editor/use-crop-options.cjs +4 -5
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -1
  6. package/build/components/media-editor/use-save-media-editor.cjs +41 -11
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  8. package/build/components/media-editor-canvas/index.cjs +15 -18
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  10. package/build/components/media-editor-crop-panel/index.cjs +26 -8
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  12. package/build/components/media-editor-fine-rotation/index.cjs +13 -12
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
  14. package/build/components/media-editor-image-controls/index.cjs +4 -6
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -1
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +33 -33
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  18. package/build/components/media-editor-modal/index.cjs +10 -7
  19. package/build/components/media-editor-modal/index.cjs.map +1 -1
  20. package/build/components/media-editor-panel/error-boundary.cjs +68 -0
  21. package/build/components/media-editor-panel/error-boundary.cjs.map +1 -0
  22. package/build/components/media-editor-panel/index.cjs +158 -0
  23. package/build/components/media-editor-panel/index.cjs.map +1 -0
  24. package/build/components/media-form/index.cjs +7 -1
  25. package/build/components/media-form/index.cjs.map +1 -1
  26. package/build/components/media-preview/index.cjs +143 -37
  27. package/build/components/media-preview/index.cjs.map +1 -1
  28. package/build/components/rotation-ruler/index.cjs +9 -7
  29. package/build/components/rotation-ruler/index.cjs.map +1 -1
  30. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -1
  31. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -1
  32. package/build/index.cjs +10 -8
  33. package/build/private-apis.cjs.map +1 -1
  34. package/build/state/aspect-ratio-presets.cjs +12 -6
  35. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  36. package/build/state/composite-reducer.cjs +41 -74
  37. package/build/state/composite-reducer.cjs.map +1 -1
  38. package/build/state/index.cjs +0 -39
  39. package/build/state/types.cjs +1 -2
  40. package/build/state/types.cjs.map +1 -1
  41. package/build/state/use-media-editor-state.cjs +70 -106
  42. package/build/state/use-media-editor-state.cjs.map +1 -1
  43. package/build/store/index.cjs +11 -9
  44. package/build/store/index.cjs.map +1 -1
  45. package/build/utils/get-media-type.cjs +8 -0
  46. package/build/utils/get-media-type.cjs.map +1 -1
  47. package/build/utils/index.cjs +6 -0
  48. package/build-module/components/media-editor/index.mjs +217 -117
  49. package/build-module/components/media-editor/index.mjs.map +1 -1
  50. package/build-module/components/media-editor/use-crop-options.mjs +4 -5
  51. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
  52. package/build-module/components/media-editor/use-save-media-editor.mjs +32 -4
  53. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  54. package/build-module/components/media-editor-canvas/index.mjs +8 -13
  55. package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
  56. package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
  57. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
  58. package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
  59. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
  60. package/build-module/components/media-editor-image-controls/index.mjs +5 -7
  61. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
  62. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +33 -33
  63. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  64. package/build-module/components/media-editor-modal/index.mjs +1 -0
  65. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  66. package/build-module/components/media-editor-panel/error-boundary.mjs +63 -0
  67. package/build-module/components/media-editor-panel/error-boundary.mjs.map +1 -0
  68. package/build-module/components/media-editor-panel/index.mjs +123 -0
  69. package/build-module/components/media-editor-panel/index.mjs.map +1 -0
  70. package/build-module/components/media-form/index.mjs +7 -1
  71. package/build-module/components/media-form/index.mjs.map +1 -1
  72. package/build-module/components/media-preview/index.mjs +123 -41
  73. package/build-module/components/media-preview/index.mjs.map +1 -1
  74. package/build-module/state/aspect-ratio-presets.mjs +12 -7
  75. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  76. package/build-module/state/composite-reducer.mjs +32 -67
  77. package/build-module/state/composite-reducer.mjs.map +1 -1
  78. package/build-module/state/index.mjs +2 -5
  79. package/build-module/state/types.mjs +1 -2
  80. package/build-module/state/types.mjs.map +1 -1
  81. package/build-module/state/use-media-editor-state.mjs +70 -105
  82. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  83. package/build-module/utils/get-media-type.mjs +8 -1
  84. package/build-module/utils/get-media-type.mjs.map +1 -1
  85. package/build-module/utils/index.mjs +1 -1
  86. package/build-style/style-rtl.css +122 -87
  87. package/build-style/style.css +121 -87
  88. package/build-types/components/media-editor/index.d.ts +25 -3
  89. package/build-types/components/media-editor/index.d.ts.map +1 -1
  90. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  91. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  92. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  93. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  94. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  95. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  96. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  97. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  98. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  99. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  100. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  101. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  102. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  103. package/build-types/components/media-editor-panel/error-boundary.d.ts +23 -0
  104. package/build-types/components/media-editor-panel/error-boundary.d.ts.map +1 -0
  105. package/build-types/components/media-editor-panel/index.d.ts +46 -0
  106. package/build-types/components/media-editor-panel/index.d.ts.map +1 -0
  107. package/build-types/components/media-form/index.d.ts.map +1 -1
  108. package/build-types/components/media-preview/index.d.ts.map +1 -1
  109. package/build-types/state/aspect-ratio-presets.d.ts +20 -3
  110. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
  111. package/build-types/state/composite-reducer.d.ts +17 -19
  112. package/build-types/state/composite-reducer.d.ts.map +1 -1
  113. package/build-types/state/index.d.ts +2 -5
  114. package/build-types/state/index.d.ts.map +1 -1
  115. package/build-types/state/types.d.ts +20 -64
  116. package/build-types/state/types.d.ts.map +1 -1
  117. package/build-types/state/use-media-editor-state.d.ts +40 -54
  118. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  119. package/build-types/utils/get-media-type.d.ts +3 -1
  120. package/build-types/utils/get-media-type.d.ts.map +1 -1
  121. package/build-types/utils/index.d.ts +1 -1
  122. package/build-types/utils/index.d.ts.map +1 -1
  123. package/package.json +27 -24
  124. package/src/components/media-editor/index.tsx +372 -142
  125. package/src/components/media-editor/style.scss +21 -1
  126. package/src/components/media-editor/use-crop-options.ts +7 -11
  127. package/src/components/media-editor/use-save-media-editor.ts +48 -6
  128. package/src/components/media-editor-canvas/index.tsx +15 -26
  129. package/src/components/media-editor-canvas/style.scss +6 -6
  130. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  131. package/src/components/media-editor-crop-panel/style.scss +21 -0
  132. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  133. package/src/components/media-editor-image-controls/index.tsx +11 -9
  134. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +56 -63
  135. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  136. package/src/components/media-editor-modal/index.tsx +4 -1
  137. package/src/components/media-editor-panel/error-boundary.tsx +88 -0
  138. package/src/components/media-editor-panel/index.tsx +211 -0
  139. package/src/components/media-form/index.tsx +7 -1
  140. package/src/components/media-preview/index.tsx +195 -37
  141. package/src/components/media-preview/style.scss +11 -32
  142. package/src/components/rotation-ruler/style.scss +3 -3
  143. package/src/state/README.md +34 -0
  144. package/src/state/aspect-ratio-presets.ts +22 -3
  145. package/src/state/composite-reducer.ts +42 -80
  146. package/src/state/index.ts +2 -18
  147. package/src/state/types.ts +18 -68
  148. package/src/state/use-media-editor-state.ts +162 -242
  149. package/src/style.scss +2 -1
  150. package/src/utils/get-media-type.ts +9 -1
  151. package/src/utils/index.ts +1 -1
  152. package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
  153. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
  154. package/build/image-editor/core/camera.cjs +0 -277
  155. package/build/image-editor/core/camera.cjs.map +0 -1
  156. package/build/image-editor/core/constants.cjs +0 -133
  157. package/build/image-editor/core/constants.cjs.map +0 -1
  158. package/build/image-editor/core/containment.cjs +0 -289
  159. package/build/image-editor/core/containment.cjs.map +0 -1
  160. package/build/image-editor/core/crop-rect.cjs +0 -37
  161. package/build/image-editor/core/crop-rect.cjs.map +0 -1
  162. package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
  163. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
  164. package/build/image-editor/core/index.cjs +0 -89
  165. package/build/image-editor/core/interaction-controller.cjs +0 -591
  166. package/build/image-editor/core/interaction-controller.cjs.map +0 -1
  167. package/build/image-editor/core/math/rotation.cjs +0 -32
  168. package/build/image-editor/core/math/rotation.cjs.map +0 -1
  169. package/build/image-editor/core/math/sanitize.cjs +0 -136
  170. package/build/image-editor/core/math/sanitize.cjs.map +0 -1
  171. package/build/image-editor/core/setter-helpers.cjs +0 -61
  172. package/build/image-editor/core/setter-helpers.cjs.map +0 -1
  173. package/build/image-editor/core/source-region.cjs +0 -236
  174. package/build/image-editor/core/source-region.cjs.map +0 -1
  175. package/build/image-editor/core/state.cjs +0 -296
  176. package/build/image-editor/core/state.cjs.map +0 -1
  177. package/build/image-editor/core/stencil-math.cjs +0 -203
  178. package/build/image-editor/core/stencil-math.cjs.map +0 -1
  179. package/build/image-editor/core/transform-style.cjs +0 -43
  180. package/build/image-editor/core/transform-style.cjs.map +0 -1
  181. package/build/image-editor/core/transforms/pipeline.cjs +0 -41
  182. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
  183. package/build/image-editor/core/types.cjs +0 -5
  184. package/build/image-editor/core/viewport-state.cjs +0 -36
  185. package/build/image-editor/core/viewport-state.cjs.map +0 -1
  186. package/build/image-editor/index.cjs +0 -68
  187. package/build/image-editor/react/components/cropper-provider.cjs +0 -49
  188. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
  189. package/build/image-editor/react/components/cropper.cjs +0 -595
  190. package/build/image-editor/react/components/cropper.cjs.map +0 -1
  191. package/build/image-editor/react/components/index.cjs +0 -25
  192. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
  193. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
  194. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
  195. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
  196. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
  197. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
  198. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
  199. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
  200. package/build/image-editor/react/components/viewport-provider.cjs +0 -26
  201. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
  202. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
  203. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
  204. package/build/image-editor/react/hooks/index.cjs +0 -19
  205. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
  206. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
  207. package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
  208. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
  209. package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
  210. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
  211. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
  212. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
  213. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
  214. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
  215. package/build/image-editor/react/visually-hidden-style.cjs +0 -24
  216. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
  217. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
  218. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
  219. package/build-module/image-editor/core/camera.mjs +0 -265
  220. package/build-module/image-editor/core/camera.mjs.map +0 -1
  221. package/build-module/image-editor/core/constants.mjs +0 -115
  222. package/build-module/image-editor/core/constants.mjs.map +0 -1
  223. package/build-module/image-editor/core/containment.mjs +0 -281
  224. package/build-module/image-editor/core/containment.mjs.map +0 -1
  225. package/build-module/image-editor/core/crop-rect.mjs +0 -32
  226. package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
  227. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
  228. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
  229. package/build-module/image-editor/core/index.mjs +0 -7
  230. package/build-module/image-editor/core/interaction-controller.mjs +0 -586
  231. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
  232. package/build-module/image-editor/core/math/rotation.mjs +0 -26
  233. package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
  234. package/build-module/image-editor/core/math/sanitize.mjs +0 -127
  235. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
  236. package/build-module/image-editor/core/setter-helpers.mjs +0 -56
  237. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
  238. package/build-module/image-editor/core/source-region.mjs +0 -228
  239. package/build-module/image-editor/core/source-region.mjs.map +0 -1
  240. package/build-module/image-editor/core/state.mjs +0 -288
  241. package/build-module/image-editor/core/state.mjs.map +0 -1
  242. package/build-module/image-editor/core/stencil-math.mjs +0 -194
  243. package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
  244. package/build-module/image-editor/core/transform-style.mjs +0 -38
  245. package/build-module/image-editor/core/transform-style.mjs.map +0 -1
  246. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
  247. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
  248. package/build-module/image-editor/core/types.mjs +0 -0
  249. package/build-module/image-editor/core/viewport-state.mjs +0 -30
  250. package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
  251. package/build-module/image-editor/index.mjs +0 -4
  252. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
  253. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
  254. package/build-module/image-editor/react/components/cropper.mjs +0 -568
  255. package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
  256. package/build-module/image-editor/react/components/index.mjs +0 -3
  257. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
  258. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
  259. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
  260. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
  261. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
  262. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
  263. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
  264. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
  265. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
  266. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
  267. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
  268. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
  269. package/build-module/image-editor/react/hooks/index.mjs +0 -3
  270. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
  271. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
  272. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
  273. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
  274. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
  275. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
  276. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
  277. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
  278. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
  279. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
  280. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
  281. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
  282. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
  283. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  284. package/build-types/image-editor/core/camera.d.ts +0 -128
  285. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  286. package/build-types/image-editor/core/constants.d.ts +0 -98
  287. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  288. package/build-types/image-editor/core/containment.d.ts +0 -72
  289. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  290. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  291. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  292. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  293. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  294. package/build-types/image-editor/core/index.d.ts +0 -10
  295. package/build-types/image-editor/core/index.d.ts.map +0 -1
  296. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  297. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  298. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  299. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  300. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  301. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  302. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  303. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  304. package/build-types/image-editor/core/source-region.d.ts +0 -94
  305. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  306. package/build-types/image-editor/core/state.d.ts +0 -51
  307. package/build-types/image-editor/core/state.d.ts.map +0 -1
  308. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  309. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  310. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  311. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  312. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  313. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  314. package/build-types/image-editor/core/types.d.ts +0 -269
  315. package/build-types/image-editor/core/types.d.ts.map +0 -1
  316. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  317. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  318. package/build-types/image-editor/index.d.ts +0 -17
  319. package/build-types/image-editor/index.d.ts.map +0 -1
  320. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  321. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  322. package/build-types/image-editor/react/components/cropper.d.ts +0 -54
  323. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  324. package/build-types/image-editor/react/components/index.d.ts +0 -4
  325. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  326. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  327. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  328. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  329. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  330. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  331. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  332. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  333. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  334. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  335. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  336. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  337. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  338. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  339. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  340. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  341. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  342. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts +0 -55
  343. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +0 -1
  344. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  345. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  346. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  347. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  348. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  349. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  350. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  351. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  352. package/src/components/media-editor-modal/build-modifiers.ts +0 -167
  353. package/src/image-editor/README.md +0 -61
  354. package/src/image-editor/core/camera.ts +0 -429
  355. package/src/image-editor/core/constants.ts +0 -137
  356. package/src/image-editor/core/containment.ts +0 -469
  357. package/src/image-editor/core/crop-rect.ts +0 -42
  358. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  359. package/src/image-editor/core/index.ts +0 -43
  360. package/src/image-editor/core/interaction-controller.ts +0 -976
  361. package/src/image-editor/core/math/rotation.ts +0 -26
  362. package/src/image-editor/core/math/sanitize.ts +0 -155
  363. package/src/image-editor/core/setter-helpers.ts +0 -63
  364. package/src/image-editor/core/source-region.ts +0 -367
  365. package/src/image-editor/core/state.ts +0 -484
  366. package/src/image-editor/core/stencil-math.ts +0 -379
  367. package/src/image-editor/core/transform-style.ts +0 -56
  368. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  369. package/src/image-editor/core/types.ts +0 -230
  370. package/src/image-editor/core/viewport-state.ts +0 -30
  371. package/src/image-editor/docs/architecture.md +0 -63
  372. package/src/image-editor/docs/recipes.md +0 -184
  373. package/src/image-editor/index.ts +0 -43
  374. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  375. package/src/image-editor/react/components/cropper.scss +0 -259
  376. package/src/image-editor/react/components/cropper.tsx +0 -1108
  377. package/src/image-editor/react/components/index.ts +0 -3
  378. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  379. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  380. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  381. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  382. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  383. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  384. package/src/image-editor/react/hooks/index.ts +0 -4
  385. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  386. package/src/image-editor/react/hooks/use-cropper-controller.ts +0 -197
  387. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  388. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  389. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  390. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  391. package/src/image-editor/style.scss +0 -1
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let _wordpress_a11y = require("@wordpress/a11y");
7
- let _wordpress_element = require("@wordpress/element");
8
- let _wordpress_i18n = require("@wordpress/i18n");
9
- let ______core_source_region_ts = require("../../core/source-region.cjs");
10
- // packages/media-editor/src/image-editor/react/hooks/use-aria-announcer.ts
11
- /** Debounce delay for ARIA live announcements (ms). */
12
- const ARIA_DEBOUNCE_MS = 300;
13
- function getFlipAnnouncement(state, previousState) {
14
- if (!previousState || previousState.flip.horizontal === state.flip.horizontal && previousState.flip.vertical === state.flip.vertical) return;
15
- const { horizontal, vertical } = state.flip;
16
- if (horizontal && vertical) return (0, _wordpress_i18n.__)("Flipped horizontally and vertically");
17
- if (horizontal) return (0, _wordpress_i18n.__)("Flipped horizontally");
18
- if (vertical) return (0, _wordpress_i18n.__)("Flipped vertically");
19
- return (0, _wordpress_i18n.__)("Flip removed");
20
- }
21
- function getRotationAnnouncement(state, previousState) {
22
- if (previousState && Math.round(previousState.rotation) === Math.round(state.rotation)) return;
23
- const visualDir = state.flip.horizontal !== state.flip.vertical ? -1 : 1;
24
- let visualRotation = Math.round(state.rotation) * visualDir % 360;
25
- if (visualRotation > 180) visualRotation -= 360;
26
- if (visualRotation <= -180) visualRotation += 360;
27
- if (visualRotation === 0) return previousState ? (0, _wordpress_i18n.__)("Rotation 0 degrees") : void 0;
28
- if (visualRotation > 0) return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Rotated %d degrees clockwise"), visualRotation);
29
- return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Rotated %d degrees counterclockwise"), Math.abs(visualRotation));
30
- }
31
- function getCropAnnouncement(state, previousState) {
32
- if (!state.image) return;
33
- const imageSize = {
34
- width: state.image.naturalWidth,
35
- height: state.image.naturalHeight
36
- };
37
- const region = (0, ______core_source_region_ts.getSourceRegion)(state, imageSize);
38
- if (previousState?.image) {
39
- const previousRegion = (0, ______core_source_region_ts.getSourceRegion)({
40
- ...state,
41
- cropRect: previousState.cropRect
42
- }, imageSize);
43
- if (Math.round(previousRegion.width) === Math.round(region.width) && Math.round(previousRegion.height) === Math.round(region.height)) return;
44
- }
45
- return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Crop %1$d by %2$d pixels"), Math.round(region.width), Math.round(region.height));
46
- }
47
- function getZoomAnnouncement(state, previousState) {
48
- if (previousState && Math.round(previousState.zoom * 100) === Math.round(state.zoom * 100)) return;
49
- return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Zoom %d%%"), Math.round(state.zoom * 100));
50
- }
51
- function buildAnnouncement(state, previousState) {
52
- const flip = getFlipAnnouncement(state, previousState);
53
- if (flip) return flip;
54
- return [
55
- getRotationAnnouncement(state, previousState),
56
- getZoomAnnouncement(state, previousState),
57
- getCropAnnouncement(state, previousState)
58
- ].filter((part) => part !== void 0).join(", ");
59
- }
60
- /**
61
- * Debounce and dedupe ARIA-live announcements for screen readers as the
62
- * cropper state changes. Calls `speak()` from `@wordpress/a11y` to use the
63
- * centralized, persistent live region instead of a local one that may be
64
- * dynamically mounted.
65
- *
66
- * Debouncing avoids flooding announcements during drag/pointermove bursts;
67
- * deduping avoids re-announcing the same state.
68
- *
69
- * @param state The current cropper state to announce.
70
- */
71
- function useAriaAnnouncer(state) {
72
- const timerRef = (0, _wordpress_element.useRef)(void 0);
73
- const prevMessageRef = (0, _wordpress_element.useRef)("");
74
- const prevStateRef = (0, _wordpress_element.useRef)(null);
75
- const latestStateRef = (0, _wordpress_element.useRef)(state);
76
- (0, _wordpress_element.useLayoutEffect)(() => {
77
- latestStateRef.current = state;
78
- }, [state]);
79
- (0, _wordpress_element.useEffect)(() => {
80
- clearTimeout(timerRef.current);
81
- timerRef.current = setTimeout(() => {
82
- const current = latestStateRef.current;
83
- const msg = buildAnnouncement(current, prevStateRef.current);
84
- prevStateRef.current = current;
85
- if (msg !== prevMessageRef.current) {
86
- prevMessageRef.current = msg;
87
- (0, _wordpress_a11y.speak)(msg);
88
- }
89
- }, ARIA_DEBOUNCE_MS);
90
- return () => {
91
- clearTimeout(timerRef.current);
92
- };
93
- }, [
94
- state.zoom,
95
- state.rotation,
96
- state.cropRect.width,
97
- state.cropRect.height,
98
- state.flip.horizontal,
99
- state.flip.vertical
100
- ]);
101
- }
102
- exports.useAriaAnnouncer = useAriaAnnouncer;
103
-
104
- //# sourceMappingURL=use-aria-announcer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-aria-announcer.cjs","names":["__","sprintf","getSourceRegion","useRef"],"sources":["../../../../src/image-editor/react/hooks/use-aria-announcer.ts"],"sourcesContent":["import { speak } from '@wordpress/a11y';\nimport { useEffect, useLayoutEffect, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport type { CropperState } from '../../core/types';\nimport { getSourceRegion } from '../../core/source-region';\n\n/** Debounce delay for ARIA live announcements (ms). */\nconst ARIA_DEBOUNCE_MS = 300;\n\nfunction getFlipAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string | undefined {\n\tif (\n\t\t! previousState ||\n\t\t( previousState.flip.horizontal === state.flip.horizontal &&\n\t\t\tpreviousState.flip.vertical === state.flip.vertical )\n\t) {\n\t\treturn undefined;\n\t}\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\nfunction getRotationAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string | undefined {\n\tif (\n\t\tpreviousState &&\n\t\tMath.round( previousState.rotation ) === Math.round( state.rotation )\n\t) {\n\t\treturn undefined;\n\t}\n\t// Announce the visual rotation — what the user perceives on screen. A\n\t// single-axis flip mirrors the image, reversing the entire on-screen\n\t// rotation relative to the stored field (the same S·R·S inversion the\n\t// reducer applies), so negate the whole angle in that case.\n\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\tconst visualDir = singleFlip ? -1 : 1;\n\t// Normalize to (-180, 180] so the sign indicates direction.\n\tlet visualRotation = ( Math.round( state.rotation ) * visualDir ) % 360;\n\tif ( visualRotation > 180 ) {\n\t\tvisualRotation -= 360;\n\t}\n\tif ( visualRotation <= -180 ) {\n\t\tvisualRotation += 360;\n\t}\n\tif ( visualRotation === 0 ) {\n\t\treturn previousState ? __( 'Rotation 0 degrees' ) : undefined;\n\t}\n\tif ( visualRotation > 0 ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %d: rotation angle in degrees. */\n\t\t\t__( 'Rotated %d degrees clockwise' ),\n\t\t\tvisualRotation\n\t\t);\n\t}\n\treturn sprintf(\n\t\t/* translators: %d: rotation angle in degrees. */\n\t\t__( 'Rotated %d degrees counterclockwise' ),\n\t\tMath.abs( visualRotation )\n\t);\n}\n\nfunction getCropAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string | undefined {\n\tif ( ! state.image ) {\n\t\treturn undefined;\n\t}\n\tconst imageSize = {\n\t\twidth: state.image.naturalWidth,\n\t\theight: state.image.naturalHeight,\n\t};\n\tconst region = getSourceRegion( state, imageSize );\n\t// Announce only when the crop's pixel dimensions change. Measuring both the\n\t// previous and current crop rects under the current rotation and zoom keeps\n\t// the comparison in the same pixel units we announce, and leaves a zoom-only\n\t// change — which doesn't move the crop rect — silent.\n\tif ( previousState?.image ) {\n\t\tconst previousRegion = getSourceRegion(\n\t\t\t{ ...state, cropRect: previousState.cropRect },\n\t\t\timageSize\n\t\t);\n\t\tif (\n\t\t\tMath.round( previousRegion.width ) === Math.round( region.width ) &&\n\t\t\tMath.round( previousRegion.height ) === Math.round( region.height )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn sprintf(\n\t\t/* translators: 1: crop width in pixels, 2: crop height in pixels. */\n\t\t__( 'Crop %1$d by %2$d pixels' ),\n\t\tMath.round( region.width ),\n\t\tMath.round( region.height )\n\t);\n}\n\nfunction getZoomAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string | undefined {\n\tif (\n\t\tpreviousState &&\n\t\tMath.round( previousState.zoom * 100 ) ===\n\t\t\tMath.round( state.zoom * 100 )\n\t) {\n\t\treturn undefined;\n\t}\n\treturn sprintf(\n\t\t/* translators: %d: zoom level as a percentage. */\n\t\t__( 'Zoom %d%%' ),\n\t\tMath.round( state.zoom * 100 )\n\t);\n}\n\nfunction buildAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string {\n\t// Flip changes are announced alone.\n\tconst flip = getFlipAnnouncement( state, previousState );\n\tif ( flip ) {\n\t\treturn flip;\n\t}\n\n\tconst parts = [\n\t\tgetRotationAnnouncement( state, previousState ),\n\t\tgetZoomAnnouncement( state, previousState ),\n\t\tgetCropAnnouncement( state, previousState ),\n\t].filter( ( part ): part is string => part !== undefined );\n\n\treturn parts.join( ', ' );\n}\n\n/**\n * Debounce and dedupe ARIA-live announcements for screen readers as the\n * cropper state changes. Calls `speak()` from `@wordpress/a11y` to use the\n * centralized, persistent live region instead of a local one that may be\n * dynamically mounted.\n *\n * Debouncing avoids flooding announcements 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 ): void {\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\tspeak( 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"],"mappings":";;;;;;;;;;;AAOA,MAAM,mBAAmB;AAEzB,SAAS,oBACR,OACA,eACqB;CACrB,IACC,CAAE,iBACA,cAAc,KAAK,eAAe,MAAM,KAAK,cAC9C,cAAc,KAAK,aAAa,MAAM,KAAK,UAE5C;CAED,MAAM,EAAE,YAAY,aAAa,MAAM;CACvC,IAAK,cAAc,UAClB,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,qCAAsC;CAElD,IAAK,YACJ,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,sBAAuB;CAEnC,IAAK,UACJ,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,oBAAqB;CAEjC,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,cAAe;AAC3B;AAEA,SAAS,wBACR,OACA,eACqB;CACrB,IACC,iBACA,KAAK,MAAO,cAAc,QAAS,MAAM,KAAK,MAAO,MAAM,QAAS,GAEpE;CAOD,MAAM,YADa,MAAM,KAAK,eAAe,MAAM,KAAK,WACzB,KAAK;CAEpC,IAAI,iBAAmB,KAAK,MAAO,MAAM,QAAS,IAAI,YAAc;CACpE,IAAK,iBAAiB,KACrB,kBAAkB;CAEnB,IAAK,kBAAk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AO,aAAc;CACvD,IAAK,MACJ,OAAO;CASR,OANc;EACb,wBAAyB,OAAO,aAAc;EAC9C,oBAAqB,OAAO,aAAc;EAC1C,oBAAqB,OAAO,aAAc;CAC3C,CAAC,CAAC,QAAU,SAA0B,SAAS,KAAA,CAEpC,CAAC,CAAC,KAAM,IAAK;AACzB;;;;;;;;;;;;AAaA,SAAgB,iBAAkB,OAA4B;CAC7D,MAAM,YAAA,GAAWG,mBAAAA,OAAAA,CAChB,KAAA,CACD;CACA,MAAM,kBAAA,GAAiBA,mBAAAA,OAAAA,CAAQ,EAAG;CAClC,MAAM,gBAAA,GAAeA,mBAAAA,OAAAA,CAA+B,IAAK;CACzD,MAAM,kBAAA,GAAiBA,mBAAAA,OAAAA,CAAQ,KAAM;CACrC,CAAA,GAAA,mBAAA,gBAAA,OAAuB;EACtB,eAAe,UAAU;CAC1B,GAAG,CAAE,KAAM,CAAE;CAEb,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,aAAc,SAAS,OAAQ;EAC/B,SAAS,UAAU,iBAAkB;GACpC,MAAM,UAAU,eAAe;GAC/B,MAAM,MAAM,kBAAmB,SAAS,aAAa,OAAQ;GAC7D,aAAa,UAAU;GACvB,IAAK,QAAQ,eAAe,SAAU;IACrC,eAAe,UAAU;IACzB,CAAA,GAAA,gBAAA,MAAA,CAAO,GAAI;GACZ;EACD,GAAG,gBAAiB;EAEpB,aAAa;GACZ,aAAc,SAAS,OAAQ;EAChC;CACD,GAAG;EACF,MAAM;EACN,MAAM;EACN,MAAM,SAAS;EACf,MAAM,SAAS;EACf,MAAM,KAAK;EACX,MAAM,KAAK;CACZ,CAAE;AACH"}
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let _wordpress_element = require("@wordpress/element");
7
- let ______core_constants_ts = require("../../core/constants.cjs");
8
- let ______core_export_canvas_renderer_ts = require("../../core/export/canvas-renderer.cjs");
9
- let ______core_state_ts = require("../../core/state.cjs");
10
- let __build_cropper_setters_ts = require("./build-cropper-setters.cjs");
11
- // packages/media-editor/src/image-editor/react/hooks/use-cropper-controller.ts
12
- function areCropperImagesEqual(a, b) {
13
- return a?.src === b?.src && a?.naturalWidth === b?.naturalWidth && a?.naturalHeight === b?.naturalHeight;
14
- }
15
- /**
16
- * Controller hook for the image cropper: the state, the named setters and
17
- * the export helpers, without history.
18
- *
19
- * Wraps the framework-agnostic `cropperReducer` and exposes named
20
- * setters (built from the shared `buildCropperSetters` factory).
21
- * Does NOT manage undo/redo history — that responsibility belongs to
22
- * the surrounding application (see `useMediaEditorState` for the
23
- * composite store used by the media editor).
24
- *
25
- * @param initialState Optional partial state to merge with DEFAULT_STATE.
26
- * @return The cropper controller — state, setters, and helpers.
27
- */
28
- function useCropperController(initialState) {
29
- const [state, dispatch] = (0, _wordpress_element.useReducer)(______core_state_ts.cropperReducer, initialState, (init) => (0, ______core_state_ts.enforceContainment)({
30
- ...______core_constants_ts.DEFAULT_STATE,
31
- ...init
32
- }));
33
- const [initialBaseline, setInitialBaseline] = (0, _wordpress_element.useState)(() => (0, ______core_state_ts.enforceContainment)({
34
- ...______core_constants_ts.DEFAULT_STATE,
35
- ...initialState
36
- }));
37
- const stateRef = (0, _wordpress_element.useRef)(state);
38
- const dispatchAndSync = (0, _wordpress_element.useCallback)((action) => {
39
- const next = (0, ______core_state_ts.cropperReducer)(stateRef.current, action);
40
- stateRef.current = next;
41
- dispatch(action);
42
- return next;
43
- }, []);
44
- const setImage = (0, _wordpress_element.useCallback)((image) => {
45
- if (areCropperImagesEqual(stateRef.current.image, image)) return;
46
- const next = dispatchAndSync({
47
- type: "SET_IMAGE",
48
- payload: image
49
- });
50
- setInitialBaseline(next);
51
- }, [dispatchAndSync]);
52
- const reset = (0, _wordpress_element.useCallback)((resetState) => {
53
- const nextInitialState = dispatchAndSync({
54
- type: "RESET",
55
- payload: resetState
56
- });
57
- setInitialBaseline(nextInitialState);
58
- }, [dispatchAndSync]);
59
- const setters = (0, _wordpress_element.useMemo)(() => (0, __build_cropper_setters_ts.buildCropperSetters)(dispatchAndSync, () => stateRef.current), [dispatchAndSync]);
60
- const isDirty = (0, ______core_state_ts.isStateDirty)(state, initialBaseline);
61
- const getCroppedImage = (0, _wordpress_element.useCallback)((mimeType, quality) => {
62
- if (!state.image) return Promise.reject(/* @__PURE__ */ new Error("No image loaded — call setImage first."));
63
- return (0, ______core_export_canvas_renderer_ts.exportCroppedImage)(state.image.src, state, mimeType, quality);
64
- }, [state]);
65
- const setVisualSize = (0, _wordpress_element.useCallback)(() => {}, []);
66
- const adjustCropRectForViewport = setters.setCropRect;
67
- return {
68
- ...setters,
69
- state,
70
- setImage,
71
- reset,
72
- isDirty,
73
- getCroppedImage,
74
- setVisualSize,
75
- adjustCropRectForViewport
76
- };
77
- }
78
- exports.useCropperController = useCropperController;
79
-
80
- //# sourceMappingURL=use-cropper-controller.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-cropper-controller.cjs","names":["useReducer","cropperReducer","enforceContainment","DEFAULT_STATE","useState","useRef","useCallback","useMemo","buildCropperSetters","isStateDirty","exportCroppedImage"],"sources":["../../../../src/image-editor/react/hooks/use-cropper-controller.ts"],"sourcesContent":["import {\n\tuseReducer,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport type {\n\tCropperState,\n\tCropperAction,\n\tNormalizedRect,\n\tSize,\n} from '../../core/types';\nimport { DEFAULT_STATE } from '../../core/constants';\nimport { exportCroppedImage } from '../../core/export/canvas-renderer';\nimport {\n\tcropperReducer,\n\tenforceContainment,\n\tisStateDirty,\n} from '../../core/state';\nimport {\n\tbuildCropperSetters,\n\ttype CropperSetters,\n} from './build-cropper-setters';\n\n/**\n * The cropper controller surface — the contract the Cropper component\n * and its interaction hooks consume.\n *\n * History (undo / redo / commitHistory) is intentionally NOT part of\n * this interface. The cropper is a pure state machine; history is a\n * higher-layer concern owned by a composite store\n * (see media-editor/src/state).\n */\nexport interface CropperController extends CropperSetters {\n\t/** The current cropper state (read-only). */\n\tstate: CropperState;\n\t/** Set the loaded image (natural size and src). */\n\tsetImage: ( image: CropperState[ 'image' ] ) => void;\n\t/** Reset the state. Optionally merge partial state overrides. */\n\treset: ( resetState?: Partial< CropperState > ) => void;\n\t/** Whether the current state differs from the initial state. */\n\tisDirty: boolean;\n\t/**\n\t * Export the cropped image as a Blob. Throws on failure — see\n\t * `exportCroppedImage` for error semantics.\n\t */\n\tgetCroppedImage: ( mimeType?: string, quality?: number ) => Promise< Blob >;\n\t/**\n\t * Called by `Cropper` whenever its rendered image size changes; not for\n\t * consumers to call. A composite controller uses the size to reshape the\n\t * crop for an aspect ratio. The pure cropper hook ignores it.\n\t */\n\tsetVisualSize: ( size: Size ) => void;\n\t/**\n\t * Called by `Cropper` when the viewport changes (window or canvas\n\t * resize); not for consumers to call. Like `setCropRect`, except that a\n\t * composite controller records no undo entry for it, since a viewport\n\t * reshape is not an editor action. The pure cropper hook aliases it to\n\t * `setCropRect`.\n\t */\n\tadjustCropRectForViewport: ( rect: NormalizedRect ) => void;\n}\n\nfunction areCropperImagesEqual(\n\ta: CropperState[ 'image' ],\n\tb: CropperState[ 'image' ]\n): boolean {\n\treturn (\n\t\ta?.src === b?.src &&\n\t\ta?.naturalWidth === b?.naturalWidth &&\n\t\ta?.naturalHeight === b?.naturalHeight\n\t);\n}\n\n/**\n * Controller hook for the image cropper: the state, the named setters and\n * the export helpers, without history.\n *\n * Wraps the framework-agnostic `cropperReducer` and exposes named\n * setters (built from the shared `buildCropperSetters` factory).\n * Does NOT manage undo/redo history — that responsibility belongs to\n * the surrounding application (see `useMediaEditorState` for the\n * composite store used by the media editor).\n *\n * @param initialState Optional partial state to merge with DEFAULT_STATE.\n * @return The cropper controller — state, setters, and helpers.\n */\nexport function useCropperController(\n\tinitialState?: Partial< CropperState >\n): CropperController {\n\tconst [ state, dispatch ] = useReducer(\n\t\tcropperReducer,\n\t\tinitialState,\n\t\t( init ) => enforceContainment( { ...DEFAULT_STATE, ...init } )\n\t);\n\n\t// The \"clean\" snapshot the current state is compared against for\n\t// `isDirty`. Stored in state (not a ref) so the comparison reads\n\t// a value, not a ref's `current`. `setImage` and `reset` refresh\n\t// this when the consumer establishes a new baseline.\n\tconst [ initialBaseline, setInitialBaseline ] = useState< CropperState >(\n\t\t() => enforceContainment( { ...DEFAULT_STATE, ...initialState } )\n\t);\n\t// Latest-state ref used by setters that need to read fresh state\n\t// (focal-point zoom, toggleFlip, reset, setImage). Updated\n\t// synchronously inside `dispatchAndSync` so multiple actions in\n\t// one event see each other's output before React commits.\n\tconst stateRef = useRef( state );\n\n\tconst dispatchAndSync = useCallback( ( action: CropperAction ) => {\n\t\tconst next = cropperReducer( stateRef.current, action );\n\t\tstateRef.current = next;\n\t\tdispatch( action );\n\t\treturn next;\n\t}, [] );\n\n\tconst setImage = useCallback(\n\t\t( image: CropperState[ 'image' ] ) => {\n\t\t\tif ( areCropperImagesEqual( stateRef.current.image, image ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst next = dispatchAndSync( {\n\t\t\t\ttype: 'SET_IMAGE',\n\t\t\t\tpayload: image,\n\t\t\t} );\n\t\t\t// Refresh the \"clean\" snapshot to match the post-load state\n\t\t\t// produced by the reducer. Otherwise containment can nudge\n\t\t\t// pan/zoom by tiny amounts on load and `isDirty` would\n\t\t\t// report true from the start.\n\t\t\tsetInitialBaseline( next );\n\t\t},\n\t\t[ dispatchAndSync ]\n\t);\n\n\tconst reset = useCallback(\n\t\t( resetState?: Partial< CropperState > ) => {\n\t\t\tconst nextInitialState = dispatchAndSync( {\n\t\t\t\ttype: 'RESET',\n\t\t\t\tpayload: resetState,\n\t\t\t} );\n\t\t\t// Mirror the reducer's RESET exactly so isDirty stays in\n\t\t\t// sync. The containment step can tweak pan/zoom/cropRect by\n\t\t\t// float ulp; fold those into the \"initial\" snapshot or\n\t\t\t// isDirty would report true after a reset.\n\t\t\tsetInitialBaseline( nextInitialState );\n\t\t},\n\t\t[ dispatchAndSync ]\n\t);\n\n\tconst setters = useMemo(\n\t\t() => buildCropperSetters( dispatchAndSync, () => stateRef.current ),\n\t\t[ dispatchAndSync ]\n\t);\n\n\tconst isDirty = isStateDirty( state, initialBaseline );\n\n\tconst getCroppedImage = useCallback(\n\t\t( mimeType?: string, quality?: number ): Promise< Blob > => {\n\t\t\tif ( ! state.image ) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew Error( 'No image loaded — call setImage first.' )\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn exportCroppedImage(\n\t\t\t\tstate.image.src,\n\t\t\t\tstate,\n\t\t\t\tmimeType,\n\t\t\t\tquality\n\t\t\t);\n\t\t},\n\t\t[ state ]\n\t);\n\n\t// No-op for the pure hook — visualSize matters only when a\n\t// composite store needs to compute aspect-ratio reshapes\n\t// (see useMediaEditorState). Typed to accept a Size so it\n\t// satisfies the controller surface; the value is intentionally\n\t// ignored.\n\tconst setVisualSize = useCallback( () => {}, [] );\n\n\t// In the pure hook, history isn't a concern — viewport-driven\n\t// reshape is identical to setCropRect.\n\tconst adjustCropRectForViewport = setters.setCropRect;\n\n\tconst controller: CropperController = {\n\t\t...setters,\n\t\tstate,\n\t\tsetImage,\n\t\treset,\n\t\tisDirty,\n\t\tgetCroppedImage,\n\t\tsetVisualSize,\n\t\tadjustCropRectForViewport,\n\t};\n\treturn controller;\n}\n"],"mappings":";;;;;;;;;;;AAgEA,SAAS,sBACR,GACA,GACU;CACV,OACC,GAAG,QAAQ,GAAG,OACd,GAAG,iBAAiB,GAAG,gBACvB,GAAG,kBAAkB,GAAG;AAE1B;;;;;;;;;;;;;;AAeA,SAAgB,qBACf,cACoB;CACpB,MAAM,CAAE,OAAO,aAAA,GAAaA,mBAAAA,WAAAA,CAC3BC,oBAAAA,gBACA,eACE,UAAA,GAAUC,oBAAAA,mBAAAA,CAAoB;EAAE,GAAGC,wBAAAA;EAAe,GAA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OA,MAAM,iBAAA,GAAgBJ,mBAAAA,YAAAA,OAAmB,CAAC,GAAG,CAAC,CAAE;CAIhD,MAAM,4BAA4B,QAAQ;CAY1C,OAAO;EATN,GAAG;EACH;EACA;EACA;EACA;EACA;EACA;EACA;CAEe;AACjB"}
@@ -1,187 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let _wordpress_element = require("@wordpress/element");
7
- let ______core_interaction_controller_ts = require("../../core/interaction-controller.cjs");
8
- // packages/media-editor/src/image-editor/react/hooks/use-interaction.ts
9
- /** How long keyboard placement stays active after the latest handled key. */
10
- const KEYBOARD_INTERACTION_IDLE_MS = 300;
11
- function isHandledKeyboardPan(event) {
12
- switch (event.key) {
13
- case "ArrowUp":
14
- case "ArrowDown":
15
- case "ArrowLeft":
16
- case "ArrowRight": return true;
17
- default: return false;
18
- }
19
- }
20
- function isHandledKeyboardZoom(event) {
21
- switch (event.key) {
22
- case "+":
23
- case "=":
24
- case "-":
25
- case "_": return true;
26
- default: return false;
27
- }
28
- }
29
- /**
30
- * Mouse, touch, and keyboard event handling for pan, zoom,
31
- * and crop manipulation.
32
- *
33
- * Returns event handler props to spread on the container element.
34
- * Uses requestAnimationFrame for drag/pinch updates to avoid
35
- * layout thrashing.
36
- *
37
- * @param state The current cropper state.
38
- * @param actions Named state updates for cropper interactions.
39
- * @param containerSize The container dimensions in pixels.
40
- * @param imageSize The rendered image dimensions in pixels.
41
- * @param options Optional configuration for zoom and keyboard behavior.
42
- * @return Event handler props for the container element.
43
- */
44
- function useInteraction(state, actions, containerSize, imageSize, options) {
45
- const [isDragging, setIsDragging] = (0, _wordpress_element.useState)(false);
46
- const [isZooming, setIsZooming] = (0, _wordpress_element.useState)(false);
47
- const [isGestureActive, setIsGestureActive] = (0, _wordpress_element.useState)(false);
48
- const [isKeyboardPanning, setIsKeyboardPanning] = (0, _wordpress_element.useState)(false);
49
- const keyboardInteractionTimerRef = (0, _wordpress_element.useRef)(void 0);
50
- const isKeyboardGestureActiveRef = (0, _wordpress_element.useRef)(false);
51
- const stateRef = (0, _wordpress_element.useRef)(state);
52
- stateRef.current = state;
53
- const containerSizeRef = (0, _wordpress_element.useRef)(containerSize);
54
- containerSizeRef.current = containerSize;
55
- const imageSizeRef = (0, _wordpress_element.useRef)(imageSize);
56
- imageSizeRef.current = imageSize;
57
- const optionsRef = (0, _wordpress_element.useRef)(options);
58
- optionsRef.current = options;
59
- const actionsRef = (0, _wordpress_element.useRef)(actions);
60
- actionsRef.current = actions;
61
- const controllerRef = (0, _wordpress_element.useRef)(null);
62
- const startPlacementGesture = (0, _wordpress_element.useCallback)(() => {
63
- setIsGestureActive(true);
64
- }, []);
65
- const stopPlacementGesture = (0, _wordpress_element.useCallback)(() => {
66
- setIsGestureActive(false);
67
- }, []);
68
- const signalKeyboardGesture = (0, _wordpress_element.useCallback)(() => {
69
- if (!isKeyboardGestureActiveRef.current) {
70
- isKeyboardGestureActiveRef.current = true;
71
- optionsRef.current?.onGestureStart?.();
72
- }
73
- clearTimeout(keyboardInteractionTimerRef.current);
74
- keyboardInteractionTimerRef.current = setTimeout(() => {
75
- isKeyboardGestureActiveRef.current = false;
76
- setIsKeyboardPanning(false);
77
- optionsRef.current?.onGestureEnd?.();
78
- }, KEYBOARD_INTERACTION_IDLE_MS);
79
- }, []);
80
- (0, _wordpress_element.useEffect)(() => {
81
- return () => {
82
- clearTimeout(keyboardInteractionTimerRef.current);
83
- };
84
- }, []);
85
- (0, _wordpress_element.useEffect)(() => {
86
- const controller = new ______core_interaction_controller_ts.InteractionController({
87
- getState: () => stateRef.current,
88
- actions: {
89
- setPan: (pan) => actionsRef.current.setPan(pan),
90
- setZoom: (zoom) => actionsRef.current.setZoom(zoom),
91
- setZoomAtPoint: (zoom, pan) => actionsRef.current.setZoomAtPoint(zoom, pan),
92
- snapRotate90: (direction) => actionsRef.current.snapRotate90(direction),
93
- toggleFlip: (direction) => actionsRef.current.toggleFlip?.(direction)
94
- },
95
- getContainerSize: () => containerSizeRef.current,
96
- getImageSize: () => imageSizeRef.current,
97
- get minZoom() {
98
- return optionsRef.current?.minZoom;
99
- },
100
- get maxZoom() {
101
- return optionsRef.current?.maxZoom;
102
- },
103
- get zoomSpeed() {
104
- return optionsRef.current?.zoomSpeed;
105
- },
106
- get keyboardStep() {
107
- return optionsRef.current?.keyboardStep;
108
- },
109
- get doubleTapZoom() {
110
- return optionsRef.current?.doubleTapZoom;
111
- },
112
- onGestureStart: () => {
113
- startPlacementGesture();
114
- optionsRef.current?.onGestureStart?.();
115
- },
116
- onGestureEnd: () => {
117
- stopPlacementGesture();
118
- optionsRef.current?.onGestureEnd?.();
119
- },
120
- onStatusChange: (status) => {
121
- setIsDragging(status.isDragging);
122
- setIsZooming(status.isZooming);
123
- }
124
- });
125
- controllerRef.current = controller;
126
- return () => {
127
- controller.destroy();
128
- controllerRef.current = null;
129
- };
130
- }, [startPlacementGesture, stopPlacementGesture]);
131
- const isDisabled = options?.disabled ?? false;
132
- (0, _wordpress_element.useEffect)(() => {
133
- if (!isDisabled) return;
134
- controllerRef.current?.destroy();
135
- setIsDragging(false);
136
- setIsZooming(false);
137
- setIsKeyboardPanning(false);
138
- const wasGestureOpen = isGestureActive || isKeyboardGestureActiveRef.current;
139
- if (isKeyboardGestureActiveRef.current) {
140
- isKeyboardGestureActiveRef.current = false;
141
- clearTimeout(keyboardInteractionTimerRef.current);
142
- }
143
- stopPlacementGesture();
144
- if (wasGestureOpen) optionsRef.current?.onGestureEnd?.();
145
- }, [
146
- isDisabled,
147
- isGestureActive,
148
- stopPlacementGesture
149
- ]);
150
- const onPointerDown = (0, _wordpress_element.useCallback)((e) => {
151
- if (optionsRef.current?.disabled) return;
152
- const el = e.currentTarget;
153
- controllerRef.current?.handlePointerDown(e.nativeEvent, el);
154
- }, []);
155
- const onTouchStart = (0, _wordpress_element.useCallback)((e) => {
156
- if (optionsRef.current?.disabled) return;
157
- const el = e.currentTarget;
158
- const rect = el.getBoundingClientRect();
159
- controllerRef.current?.handleTouchStart(e.nativeEvent, rect, el.ownerDocument);
160
- }, []);
161
- const onKeyDown = (0, _wordpress_element.useCallback)((e) => {
162
- if (optionsRef.current?.disabled) return;
163
- if (isHandledKeyboardPan(e.nativeEvent)) {
164
- setIsKeyboardPanning(true);
165
- signalKeyboardGesture();
166
- } else if (isHandledKeyboardZoom(e.nativeEvent)) signalKeyboardGesture();
167
- controllerRef.current?.handleKeyDown(e.nativeEvent);
168
- }, [signalKeyboardGesture]);
169
- const onWheelNative = (0, _wordpress_element.useCallback)((e) => {
170
- if (optionsRef.current?.disabled) return;
171
- controllerRef.current?.handleWheel(e);
172
- }, []);
173
- return {
174
- handlers: {
175
- onPointerDown,
176
- onTouchStart,
177
- onKeyDown
178
- },
179
- onWheelNative,
180
- isDragging,
181
- isZooming,
182
- isPlacementActive: isGestureActive || isKeyboardPanning || isZooming
183
- };
184
- }
185
- exports.useInteraction = useInteraction;
186
-
187
- //# sourceMappingURL=use-interaction.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-interaction.cjs","names":["useState","useRef","useCallback","InteractionController"],"sources":["../../../../src/image-editor/react/hooks/use-interaction.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from '@wordpress/element';\nimport type { CropperState, Size } from '../../core/types';\nimport {\n\tInteractionController,\n\ttype CropperInteractionActions,\n} from '../../core/interaction-controller';\n\n/**\n * The return type of the useInteraction hook.\n */\nexport interface UseInteractionReturn {\n\t/** Event handler props to spread on the container element. */\n\thandlers: {\n\t\tonPointerDown: ( e: React.PointerEvent ) => void;\n\t\tonTouchStart: ( e: React.TouchEvent ) => void;\n\t\tonKeyDown: ( e: React.KeyboardEvent ) => void;\n\t};\n\t/** Native wheel handler — must be registered with { passive: false }. */\n\tonWheelNative: ( e: WheelEvent ) => void;\n\t/** Whether a drag (pan) interaction is in progress. */\n\tisDragging: boolean;\n\t/** Whether a double-tap zoom animation is in progress. */\n\tisZooming: boolean;\n\t/** Whether the user is currently performing a placement interaction. */\n\tisPlacementActive: boolean;\n}\n\n/**\n * Options for the useInteraction hook.\n */\nexport interface UseInteractionOptions {\n\t/** Minimum zoom level. Defaults to MIN_ZOOM. */\n\tminZoom?: number;\n\t/** Maximum zoom level. Defaults to MAX_ZOOM. */\n\tmaxZoom?: number;\n\t/** Zoom speed multiplier for wheel events. Defaults to 0.0025. */\n\tzoomSpeed?: number;\n\t/**\n\t * Pan step size in normalized coords for keyboard events.\n\t * Defaults to 0.01. Shift multiplies it by 10.\n\t */\n\tkeyboardStep?: number;\n\t/** Zoom level for double-tap zoom. Defaults to 2. */\n\tdoubleTapZoom?: number;\n\t/** Fires when a continuous gesture begins (pan drag, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointer release). */\n\tonGestureEnd?: () => void;\n\t/**\n\t * Ignore all interaction. Any gesture already in flight is torn down,\n\t * so a drag started before this flipped cannot keep moving the image.\n\t */\n\tdisabled?: boolean;\n}\n\n/** How long keyboard placement stays active after the latest handled key. */\nconst KEYBOARD_INTERACTION_IDLE_MS = 300;\n\nfunction isHandledKeyboardPan( event: KeyboardEvent ): boolean {\n\tswitch ( event.key ) {\n\t\tcase 'ArrowUp':\n\t\tcase 'ArrowDown':\n\t\tcase 'ArrowLeft':\n\t\tcase 'ArrowRight':\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction isHandledKeyboardZoom( event: KeyboardEvent ): boolean {\n\tswitch ( event.key ) {\n\t\tcase '+':\n\t\tcase '=':\n\t\tcase '-':\n\t\tcase '_':\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Mouse, touch, and keyboard event handling for pan, zoom,\n * and crop manipulation.\n *\n * Returns event handler props to spread on the container element.\n * Uses requestAnimationFrame for drag/pinch updates to avoid\n * layout thrashing.\n *\n * @param state The current cropper state.\n * @param actions Named state updates for cropper interactions.\n * @param containerSize The container dimensions in pixels.\n * @param imageSize The rendered image dimensions in pixels.\n * @param options Optional configuration for zoom and keyboard behavior.\n * @return Event handler props for the container element.\n */\nexport function useInteraction(\n\tstate: CropperState,\n\tactions: CropperInteractionActions,\n\tcontainerSize: Size,\n\timageSize?: Size,\n\toptions?: UseInteractionOptions\n): UseInteractionReturn {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\tconst [ isZooming, setIsZooming ] = useState( false );\n\tconst [ isGestureActive, setIsGestureActive ] = useState( false );\n\tconst [ isKeyboardPanning, setIsKeyboardPanning ] = useState( false );\n\tconst keyboardInteractionTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\t// Tracks whether a keyboard gesture (pan or zoom) is currently active so\n\t// onGestureStart is only fired once per gesture, not on every key repeat.\n\tconst isKeyboardGestureActiveRef = useRef( false );\n\n\t// Keep mutable refs so the controller always reads fresh values\n\t// without needing to be recreated.\n\tconst stateRef = useRef( state );\n\tstateRef.current = state;\n\tconst containerSizeRef = useRef( containerSize );\n\tcontainerSizeRef.current = containerSize;\n\tconst imageSizeRef = useRef( imageSize );\n\timageSizeRef.current = imageSize;\n\tconst optionsRef = useRef( options );\n\toptionsRef.current = options;\n\tconst actionsRef = useRef( actions );\n\tactionsRef.current = actions;\n\n\tconst controllerRef = useRef< InteractionController | null >( null );\n\tconst startPlacementGesture = useCallback( () => {\n\t\tsetIsGestureActive( true );\n\t}, [] );\n\tconst stopPlacementGesture = useCallback( () => {\n\t\tsetIsGestureActive( false );\n\t}, [] );\n\t// Shared timer logic for any keyboard gesture (pan or zoom): fires\n\t// onGestureStart once per burst and onGestureEnd after the idle window.\n\tconst signalKeyboardGesture = useCallback( () => {\n\t\tif ( ! isKeyboardGestureActiveRef.current ) {\n\t\t\tisKeyboardGestureActiveRef.current = true;\n\t\t\toptionsRef.current?.onGestureStart?.();\n\t\t}\n\t\tclearTimeout( keyboardInteractionTimerRef.current );\n\t\tkeyboardInteractionTimerRef.current = setTimeout( () => {\n\t\t\tisKeyboardGestureActiveRef.current = false;\n\t\t\tsetIsKeyboardPanning( false );\n\t\t\toptionsRef.current?.onGestureEnd?.();\n\t\t}, KEYBOARD_INTERACTION_IDLE_MS );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( keyboardInteractionTimerRef.current );\n\t\t};\n\t}, [] );\n\n\t// Create / destroy the controller. The controller reads all volatile\n\t// values through refs, so it can stay mounted across render updates.\n\tuseEffect( () => {\n\t\tconst controller = new InteractionController( {\n\t\t\tgetState: () => stateRef.current,\n\t\t\tactions: {\n\t\t\t\tsetPan: ( pan ) => actionsRef.current.setPan( pan ),\n\t\t\t\tsetZoom: ( zoom ) => actionsRef.current.setZoom( zoom ),\n\t\t\t\tsetZoomAtPoint: ( zoom, pan ) =>\n\t\t\t\t\tactionsRef.current.setZoomAtPoint( zoom, pan ),\n\t\t\t\tsnapRotate90: ( direction ) =>\n\t\t\t\t\tactionsRef.current.snapRotate90( direction ),\n\t\t\t\ttoggleFlip: ( direction ) =>\n\t\t\t\t\tactionsRef.current.toggleFlip?.( direction ),\n\t\t\t},\n\t\t\tgetContainerSize: () => containerSizeRef.current,\n\t\t\tgetImageSize: () => imageSizeRef.current,\n\t\t\tget minZoom() {\n\t\t\t\treturn optionsRef.current?.minZoom;\n\t\t\t},\n\t\t\tget maxZoom() {\n\t\t\t\treturn optionsRef.current?.maxZoom;\n\t\t\t},\n\t\t\tget zoomSpeed() {\n\t\t\t\treturn optionsRef.current?.zoomSpeed;\n\t\t\t},\n\t\t\tget keyboardStep() {\n\t\t\t\treturn optionsRef.current?.keyboardStep;\n\t\t\t},\n\t\t\tget doubleTapZoom() {\n\t\t\t\treturn optionsRef.current?.doubleTapZoom;\n\t\t\t},\n\t\t\tonGestureStart: () => {\n\t\t\t\tstartPlacementGesture();\n\t\t\t\toptionsRef.current?.onGestureStart?.();\n\t\t\t},\n\t\t\tonGestureEnd: () => {\n\t\t\t\tstopPlacementGesture();\n\t\t\t\toptionsRef.current?.onGestureEnd?.();\n\t\t\t},\n\t\t\tonStatusChange: ( status ) => {\n\t\t\t\tsetIsDragging( status.isDragging );\n\t\t\t\tsetIsZooming( status.isZooming );\n\t\t\t},\n\t\t} );\n\t\tcontrollerRef.current = controller;\n\t\treturn () => {\n\t\t\tcontroller.destroy();\n\t\t\tcontrollerRef.current = null;\n\t\t};\n\t}, [ startPlacementGesture, stopPlacementGesture ] );\n\n\t// Cancel any gesture already in flight when interaction is switched off,\n\t// so a drag that started before the flip cannot keep moving the image.\n\t// `destroy()` releases the pointer/touch listeners and the pending rAF;\n\t// the controller keeps working for later gestures once re-enabled.\n\t//\n\t// It does not signal the end of the gesture it just cut short, so that\n\t// is done here: a caller told a gesture began is otherwise left waiting\n\t// for an end that never comes, which keeps undo/redo disabled and leaves\n\t// the cropper's history batch open after a failed save.\n\tconst isDisabled = options?.disabled ?? false;\n\tuseEffect( () => {\n\t\tif ( ! isDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tcontrollerRef.current?.destroy();\n\t\tsetIsDragging( false );\n\t\tsetIsZooming( false );\n\t\tsetIsKeyboardPanning( false );\n\t\tconst wasGestureOpen =\n\t\t\tisGestureActive || isKeyboardGestureActiveRef.current;\n\t\tif ( isKeyboardGestureActiveRef.current ) {\n\t\t\tisKeyboardGestureActiveRef.current = false;\n\t\t\tclearTimeout( keyboardInteractionTimerRef.current );\n\t\t}\n\t\tstopPlacementGesture();\n\t\tif ( wasGestureOpen ) {\n\t\t\toptionsRef.current?.onGestureEnd?.();\n\t\t}\n\t}, [ isDisabled, isGestureActive, stopPlacementGesture ] );\n\n\tconst onPointerDown = useCallback( ( e: React.PointerEvent ) => {\n\t\tif ( optionsRef.current?.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst el = e.currentTarget as HTMLElement;\n\t\tcontrollerRef.current?.handlePointerDown( e.nativeEvent, el );\n\t}, [] );\n\n\tconst onTouchStart = useCallback( ( e: React.TouchEvent ) => {\n\t\tif ( optionsRef.current?.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst el = e.currentTarget as HTMLElement;\n\t\tconst rect = el.getBoundingClientRect();\n\t\tcontrollerRef.current?.handleTouchStart(\n\t\t\te.nativeEvent,\n\t\t\trect,\n\t\t\tel.ownerDocument\n\t\t);\n\t}, [] );\n\n\tconst onKeyDown = useCallback(\n\t\t( e: React.KeyboardEvent ) => {\n\t\t\tif ( optionsRef.current?.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( isHandledKeyboardPan( e.nativeEvent ) ) {\n\t\t\t\tsetIsKeyboardPanning( true );\n\t\t\t\tsignalKeyboardGesture();\n\t\t\t} else if ( isHandledKeyboardZoom( e.nativeEvent ) ) {\n\t\t\t\tsignalKeyboardGesture();\n\t\t\t}\n\t\t\tcontrollerRef.current?.handleKeyDown( e.nativeEvent );\n\t\t},\n\t\t[ signalKeyboardGesture ]\n\t);\n\n\tconst onWheelNative = useCallback( ( e: WheelEvent ) => {\n\t\tif ( optionsRef.current?.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tcontrollerRef.current?.handleWheel( e );\n\t}, [] );\n\n\treturn {\n\t\thandlers: {\n\t\t\tonPointerDown,\n\t\t\tonTouchStart,\n\t\t\tonKeyDown,\n\t\t},\n\t\tonWheelNative,\n\t\tisDragging,\n\t\tisZooming,\n\t\tisPlacementActive: isGestureActive || isKeyboardPanning || isZooming,\n\t};\n}\n"],"mappings":";;;;;;;;;AAwDA,MAAM,+BAA+B;AAErC,SAAS,qBAAsB,OAAgC;CAC9D,QAAS,MAAM,KAAf;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,cACJ,OAAO;EACR,SACC,OAAO;CACT;AACD;AAEA,SAAS,sBAAuB,OAAgC;CAC/D,QAAS,MAAM,KAAf;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,KACJ,OAAO;EACR,SACC,OAAO;CACT;AACD;;;;;;;;;;;;;;;;AAiBA,SAA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qBAAqB;CAC5D;AACD"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let _wordpress_element = require("@wordpress/element");
7
- let ______core_transform_style_ts = require("../../core/transform-style.cjs");
8
- // packages/media-editor/src/image-editor/react/hooks/use-transform-style.ts
9
- /**
10
- * React hook that computes a memoized CSS matrix() transform string
11
- * from the cropper state.
12
- *
13
- * Delegates to the pure `computeTransformStyle` function in core.
14
- *
15
- * @param state The current cropper state.
16
- * @param imageSize The rendered image dimensions in pixels.
17
- * @return A CSS transform string.
18
- */
19
- function useTransformStyle(state, imageSize) {
20
- return (0, _wordpress_element.useMemo)(() => (0, ______core_transform_style_ts.computeTransformStyle)(state, imageSize), [state, imageSize]);
21
- }
22
- exports.useTransformStyle = useTransformStyle;
23
-
24
- //# sourceMappingURL=use-transform-style.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-transform-style.cjs","names":["useMemo","computeTransformStyle"],"sources":["../../../../src/image-editor/react/hooks/use-transform-style.ts"],"sourcesContent":["import { useMemo } from '@wordpress/element';\nimport type { CropperState, Size } from '../../core/types';\nimport { computeTransformStyle } from '../../core/transform-style';\n\n/**\n * React hook that computes a memoized CSS matrix() transform string\n * from the cropper state.\n *\n * Delegates to the pure `computeTransformStyle` function in core.\n *\n * @param state The current cropper state.\n * @param imageSize The rendered image dimensions in pixels.\n * @return A CSS transform string.\n */\nexport function useTransformStyle(\n\tstate: CropperState,\n\timageSize: Size\n): string {\n\treturn useMemo(\n\t\t() => computeTransformStyle( state, imageSize ),\n\t\t[ state, imageSize ]\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAcA,SAAgB,kBACf,OACA,WACS;CACT,QAAA,GAAOA,mBAAAA,QAAAA,QAAAA,GACAC,8BAAAA,sBAAAA,CAAuB,OAAO,SAAU,GAC9C,CAAE,OAAO,SAAU,CACpB;AACD"}
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let _wordpress_element = require("@wordpress/element");
7
- let ______core_viewport_state_ts = require("../../core/viewport-state.cjs");
8
- // packages/media-editor/src/image-editor/react/hooks/use-viewport-state.ts
9
- function useViewportState() {
10
- const [viewport, dispatch] = (0, _wordpress_element.useReducer)(______core_viewport_state_ts.viewportReducer, ______core_viewport_state_ts.DEFAULT_VIEWPORT_STATE);
11
- const setViewportZoom = (0, _wordpress_element.useCallback)((zoom) => {
12
- dispatch({
13
- type: "SET_VIEWPORT_ZOOM",
14
- payload: zoom
15
- });
16
- }, []);
17
- const setViewportPan = (0, _wordpress_element.useCallback)((pan) => {
18
- dispatch({
19
- type: "SET_VIEWPORT_PAN",
20
- payload: pan
21
- });
22
- }, []);
23
- const resetViewport = (0, _wordpress_element.useCallback)(() => {
24
- dispatch({ type: "RESET_VIEWPORT" });
25
- }, []);
26
- return (0, _wordpress_element.useMemo)(() => ({
27
- viewport,
28
- setViewportZoom,
29
- setViewportPan,
30
- resetViewport
31
- }), [
32
- viewport,
33
- setViewportZoom,
34
- setViewportPan,
35
- resetViewport
36
- ]);
37
- }
38
- exports.useViewportState = useViewportState;
39
-
40
- //# sourceMappingURL=use-viewport-state.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-viewport-state.cjs","names":["useReducer","viewportReducer","DEFAULT_VIEWPORT_STATE","useCallback","useMemo"],"sources":["../../../../src/image-editor/react/hooks/use-viewport-state.ts"],"sourcesContent":["import { useReducer, useCallback, useMemo } from '@wordpress/element';\nimport type { ViewportState } from '../../core/types';\nimport {\n\tviewportReducer,\n\tDEFAULT_VIEWPORT_STATE,\n} from '../../core/viewport-state';\n\nexport interface UseViewportStateReturn {\n\tviewport: ViewportState;\n\t/**\n\t * Unused in the current Cropper implementation — scaffolded for the\n\t * upcoming navigator panel (viewport zoom slider).\n\t */\n\tsetViewportZoom: ( zoom: number ) => void;\n\tsetViewportPan: ( pan: { x: number; y: number } ) => void;\n\tresetViewport: () => void;\n}\n\nexport function useViewportState(): UseViewportStateReturn {\n\tconst [ viewport, dispatch ] = useReducer(\n\t\tviewportReducer,\n\t\tDEFAULT_VIEWPORT_STATE\n\t);\n\n\tconst setViewportZoom = useCallback( ( zoom: number ) => {\n\t\tdispatch( { type: 'SET_VIEWPORT_ZOOM', payload: zoom } );\n\t}, [] );\n\n\tconst setViewportPan = useCallback( ( pan: { x: number; y: number } ) => {\n\t\tdispatch( { type: 'SET_VIEWPORT_PAN', payload: pan } );\n\t}, [] );\n\n\tconst resetViewport = useCallback( () => {\n\t\tdispatch( { type: 'RESET_VIEWPORT' } );\n\t}, [] );\n\n\treturn useMemo(\n\t\t() => ( { viewport, setViewportZoom, setViewportPan, resetViewport } ),\n\t\t[ viewport, setViewportZoom, setViewportPan, resetViewport ]\n\t);\n}\n"],"mappings":";;;;;;;;AAkBA,SAAgB,mBAA2C;CAC1D,MAAM,CAAE,UAAU,aAAA,GAAaA,mBAAAA,WAAAA,CAC9BC,6BAAAA,iBACAC,6BAAAA,sBACD;CAEA,MAAM,mBAAA,GAAkBC,mBAAAA,YAAAA,EAAe,SAAkB;EACxD,SAAU;GAAE,MAAM;GAAqB,SAAS;EAAK,CAAE;CACxD,GAAG,CAAC,CAAE;CAEN,MAAM,kBAAA,GAAiBA,mBAAAA,YAAAA,EAAe,QAAmC;EACxE,SAAU;GAAE,MAAM;GAAoB,SAAS;EAAI,CAAE;CACtD,GAAG,CAAC,CAAE;CAEN,MAAM,iBAAA,GAAgBA,mBAAAA,YAAAA,OAAmB;EACxC,SAAU,EAAE,MAAM,iBAAiB,CAAE;CACtC,GAAG,CAAC,CAAE;CAEN,QAAA,GAAOC,mBAAAA,QAAAA,QACE;EAAE;EAAU;EAAiB;EAAgB;CAAc,IACnE;EAAE;EAAU;EAAiB;EAAgB;CAAc,CAC5D;AACD"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- // packages/media-editor/src/image-editor/react/visually-hidden-style.ts
7
- /**
8
- * CSS style object that visually hides an element while keeping it accessible
9
- * to screen readers.
10
- */
11
- const VISUALLY_HIDDEN_STYLE = {
12
- position: "absolute",
13
- width: 1,
14
- height: 1,
15
- padding: 0,
16
- margin: -1,
17
- overflow: "hidden",
18
- clip: "rect(0, 0, 0, 0)",
19
- whiteSpace: "nowrap",
20
- border: 0
21
- };
22
- exports.VISUALLY_HIDDEN_STYLE = VISUALLY_HIDDEN_STYLE;
23
-
24
- //# sourceMappingURL=visually-hidden-style.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"visually-hidden-style.cjs","names":[],"sources":["../../../src/image-editor/react/visually-hidden-style.ts"],"sourcesContent":["/**\n * CSS style object that visually hides an element while keeping it accessible\n * to screen readers.\n */\nexport const VISUALLY_HIDDEN_STYLE: React.CSSProperties = {\n\tposition: 'absolute',\n\twidth: 1,\n\theight: 1,\n\tpadding: 0,\n\tmargin: -1,\n\toverflow: 'hidden',\n\tclip: 'rect(0, 0, 0, 0)',\n\twhiteSpace: 'nowrap',\n\tborder: 0,\n};\n"],"mappings":";;;;;;;;;;AAIA,MAAa,wBAA6C;CACzD,UAAU;CACV,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,UAAU;CACV,MAAM;CACN,YAAY;CACZ,QAAQ;AACT"}