@wordpress/media-editor 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/build/components/media-editor/index.cjs +586 -686
  3. package/build/components/media-editor/index.cjs.map +1 -7
  4. package/build/components/media-editor/use-crop-options.cjs +42 -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 +131 -185
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
  8. package/build/components/media-editor-canvas/index.cjs +117 -124
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -7
  10. package/build/components/media-editor-crop-panel/index.cjs +81 -72
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
  12. package/build/components/media-editor-fine-rotation/index.cjs +61 -72
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
  14. package/build/components/media-editor-image-controls/index.cjs +181 -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 +120 -157
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
  18. package/build/components/media-editor-modal/index.cjs +112 -155
  19. package/build/components/media-editor-modal/index.cjs.map +1 -7
  20. package/build/components/media-editor-provider/index.cjs +32 -55
  21. package/build/components/media-editor-provider/index.cjs.map +1 -7
  22. package/build/components/media-form/index.cjs +82 -77
  23. package/build/components/media-form/index.cjs.map +1 -7
  24. package/build/components/media-preview/index.cjs +113 -114
  25. package/build/components/media-preview/index.cjs.map +1 -7
  26. package/build/components/rotation-ruler/index.cjs +181 -188
  27. package/build/components/rotation-ruler/index.cjs.map +1 -7
  28. package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
  29. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
  30. package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
  31. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
  32. package/build/index.cjs +45 -39
  33. package/build/lock-unlock.cjs +9 -35
  34. package/build/lock-unlock.cjs.map +1 -7
  35. package/build/private-apis.cjs +16 -37
  36. package/build/private-apis.cjs.map +1 -7
  37. package/build/state/aspect-ratio-presets.cjs +59 -0
  38. package/build/state/aspect-ratio-presets.cjs.map +1 -0
  39. package/build/state/composite-reducer.cjs +100 -113
  40. package/build/state/composite-reducer.cjs.map +1 -7
  41. package/build/state/index.cjs +22 -45
  42. package/build/state/media-editor-state-provider.cjs +35 -48
  43. package/build/state/media-editor-state-provider.cjs.map +1 -7
  44. package/build/state/types.cjs +11 -31
  45. package/build/state/types.cjs.map +1 -7
  46. package/build/state/use-media-editor-state.cjs +227 -296
  47. package/build/state/use-media-editor-state.cjs.map +1 -7
  48. package/build/store/actions.cjs +17 -44
  49. package/build/store/actions.cjs.map +1 -7
  50. package/build/store/constants.cjs +8 -29
  51. package/build/store/constants.cjs.map +1 -7
  52. package/build/store/index.cjs +33 -40
  53. package/build/store/index.cjs.map +1 -7
  54. package/build/store/reducer.cjs +28 -50
  55. package/build/store/reducer.cjs.map +1 -7
  56. package/build/store/selectors.cjs +16 -41
  57. package/build/store/selectors.cjs.map +1 -7
  58. package/build/utils/get-media-type.cjs +18 -41
  59. package/build/utils/get-media-type.cjs.map +1 -7
  60. package/build/utils/index.cjs +9 -28
  61. package/build-module/components/media-editor/index.mjs +545 -675
  62. package/build-module/components/media-editor/index.mjs.map +1 -7
  63. package/build-module/components/media-editor/use-crop-options.mjs +37 -32
  64. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
  65. package/build-module/components/media-editor/use-save-media-editor.mjs +109 -157
  66. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
  67. package/build-module/components/media-editor-canvas/index.mjs +95 -98
  68. package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
  69. package/build-module/components/media-editor-crop-panel/index.mjs +59 -46
  70. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
  71. package/build-module/components/media-editor-fine-rotation/index.mjs +39 -46
  72. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
  73. package/build-module/components/media-editor-image-controls/index.mjs +171 -238
  74. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
  75. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +113 -137
  76. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
  77. package/build-module/components/media-editor-modal/index.mjs +88 -124
  78. package/build-module/components/media-editor-modal/index.mjs.map +1 -7
  79. package/build-module/components/media-editor-provider/index.mjs +26 -29
  80. package/build-module/components/media-editor-provider/index.mjs.map +1 -7
  81. package/build-module/components/media-form/index.mjs +74 -56
  82. package/build-module/components/media-form/index.mjs.map +1 -7
  83. package/build-module/components/media-preview/index.mjs +105 -90
  84. package/build-module/components/media-preview/index.mjs.map +1 -7
  85. package/build-module/components/rotation-ruler/index.mjs +161 -164
  86. package/build-module/components/rotation-ruler/index.mjs.map +1 -7
  87. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
  88. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
  89. package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
  90. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
  91. package/build-module/index.mjs +3 -10
  92. package/build-module/lock-unlock.mjs +5 -10
  93. package/build-module/lock-unlock.mjs.map +1 -7
  94. package/build-module/private-apis.mjs +8 -9
  95. package/build-module/private-apis.mjs.map +1 -7
  96. package/build-module/state/aspect-ratio-presets.mjs +53 -0
  97. package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
  98. package/build-module/state/composite-reducer.mjs +80 -91
  99. package/build-module/state/composite-reducer.mjs.map +1 -7
  100. package/build-module/state/index.mjs +3 -26
  101. package/build-module/state/media-editor-state-provider.mjs +29 -24
  102. package/build-module/state/media-editor-state-provider.mjs.map +1 -7
  103. package/build-module/state/types.mjs +7 -7
  104. package/build-module/state/types.mjs.map +1 -7
  105. package/build-module/state/use-media-editor-state.mjs +223 -288
  106. package/build-module/state/use-media-editor-state.mjs.map +1 -7
  107. package/build-module/store/actions.mjs +12 -19
  108. package/build-module/store/actions.mjs.map +1 -7
  109. package/build-module/store/constants.mjs +4 -5
  110. package/build-module/store/constants.mjs.map +1 -7
  111. package/build-module/store/index.mjs +8 -9
  112. package/build-module/store/index.mjs.map +1 -7
  113. package/build-module/store/reducer.mjs +23 -26
  114. package/build-module/store/reducer.mjs.map +1 -7
  115. package/build-module/store/selectors.mjs +8 -13
  116. package/build-module/store/selectors.mjs.map +1 -7
  117. package/build-module/utils/get-media-type.mjs +14 -17
  118. package/build-module/utils/get-media-type.mjs.map +1 -7
  119. package/build-module/utils/index.mjs +1 -6
  120. package/build-style/style-rtl.css +145 -61
  121. package/build-style/style.css +144 -61
  122. package/build-types/components/media-editor/index.d.ts +20 -2
  123. package/build-types/components/media-editor/index.d.ts.map +1 -1
  124. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  125. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  126. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  127. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  128. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  129. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  130. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  131. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  132. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  133. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  134. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  135. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  136. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  137. package/build-types/components/media-form/index.d.ts.map +1 -1
  138. package/build-types/components/media-preview/index.d.ts.map +1 -1
  139. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  140. package/build-types/state/aspect-ratio-presets.d.ts +24 -0
  141. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
  142. package/build-types/state/composite-reducer.d.ts +17 -19
  143. package/build-types/state/composite-reducer.d.ts.map +1 -1
  144. package/build-types/state/index.d.ts +2 -4
  145. package/build-types/state/index.d.ts.map +1 -1
  146. package/build-types/state/types.d.ts +20 -63
  147. package/build-types/state/types.d.ts.map +1 -1
  148. package/build-types/state/use-media-editor-state.d.ts +33 -52
  149. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  150. package/package.json +22 -23
  151. package/src/components/media-editor/index.tsx +355 -167
  152. package/src/components/media-editor/style.scss +19 -0
  153. package/src/components/media-editor/use-crop-options.ts +9 -10
  154. package/src/components/media-editor/use-save-media-editor.ts +48 -10
  155. package/src/components/media-editor-canvas/index.tsx +30 -51
  156. package/src/components/media-editor-canvas/style.scss +6 -6
  157. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  158. package/src/components/media-editor-crop-panel/style.scss +21 -0
  159. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  160. package/src/components/media-editor-image-controls/index.tsx +15 -11
  161. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  162. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  163. package/src/components/media-editor-modal/index.tsx +1 -1
  164. package/src/components/media-editor-modal/style.scss +1 -1
  165. package/src/components/media-form/index.tsx +7 -1
  166. package/src/components/media-preview/index.tsx +65 -23
  167. package/src/components/media-preview/style.scss +16 -2
  168. package/src/components/rotation-ruler/style.scss +9 -5
  169. package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
  170. package/src/state/README.md +32 -0
  171. package/src/state/aspect-ratio-presets.ts +37 -0
  172. package/src/state/composite-reducer.ts +42 -80
  173. package/src/state/index.ts +2 -17
  174. package/src/state/types.ts +18 -72
  175. package/src/state/use-media-editor-state.ts +155 -238
  176. package/src/style.scss +2 -1
  177. package/build/components/media-editor-modal/build-modifiers.cjs +0 -91
  178. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -7
  179. package/build/image-editor/core/camera.cjs +0 -225
  180. package/build/image-editor/core/camera.cjs.map +0 -7
  181. package/build/image-editor/core/constants.cjs +0 -108
  182. package/build/image-editor/core/constants.cjs.map +0 -7
  183. package/build/image-editor/core/containment.cjs +0 -276
  184. package/build/image-editor/core/containment.cjs.map +0 -7
  185. package/build/image-editor/core/crop-rect.cjs +0 -48
  186. package/build/image-editor/core/crop-rect.cjs.map +0 -7
  187. package/build/image-editor/core/export/canvas-renderer.cjs +0 -151
  188. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -7
  189. package/build/image-editor/core/index.cjs +0 -62
  190. package/build/image-editor/core/index.cjs.map +0 -7
  191. package/build/image-editor/core/interaction-controller.cjs +0 -654
  192. package/build/image-editor/core/interaction-controller.cjs.map +0 -7
  193. package/build/image-editor/core/math/rotation.cjs +0 -41
  194. package/build/image-editor/core/math/rotation.cjs.map +0 -7
  195. package/build/image-editor/core/math/sanitize.cjs +0 -92
  196. package/build/image-editor/core/math/sanitize.cjs.map +0 -7
  197. package/build/image-editor/core/setter-helpers.cjs +0 -64
  198. package/build/image-editor/core/setter-helpers.cjs.map +0 -7
  199. package/build/image-editor/core/source-region.cjs +0 -206
  200. package/build/image-editor/core/source-region.cjs.map +0 -7
  201. package/build/image-editor/core/state.cjs +0 -283
  202. package/build/image-editor/core/state.cjs.map +0 -7
  203. package/build/image-editor/core/stencil-math.cjs +0 -216
  204. package/build/image-editor/core/stencil-math.cjs.map +0 -7
  205. package/build/image-editor/core/transform-style.cjs +0 -52
  206. package/build/image-editor/core/transform-style.cjs.map +0 -7
  207. package/build/image-editor/core/transforms/pipeline.cjs +0 -43
  208. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -7
  209. package/build/image-editor/core/types.cjs +0 -19
  210. package/build/image-editor/core/types.cjs.map +0 -7
  211. package/build/image-editor/core/viewport-state.cjs +0 -50
  212. package/build/image-editor/core/viewport-state.cjs.map +0 -7
  213. package/build/image-editor/index.cjs +0 -67
  214. package/build/image-editor/index.cjs.map +0 -7
  215. package/build/image-editor/react/components/cropper-provider.cjs +0 -50
  216. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -7
  217. package/build/image-editor/react/components/cropper.cjs +0 -722
  218. package/build/image-editor/react/components/cropper.cjs.map +0 -7
  219. package/build/image-editor/react/components/index.cjs +0 -36
  220. package/build/image-editor/react/components/index.cjs.map +0 -7
  221. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -172
  222. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -7
  223. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -62
  224. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -7
  225. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -91
  226. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -7
  227. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -426
  228. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -7
  229. package/build/image-editor/react/components/viewport-provider.cjs +0 -51
  230. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -7
  231. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -71
  232. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -7
  233. package/build/image-editor/react/hooks/index.cjs +0 -34
  234. package/build/image-editor/react/hooks/index.cjs.map +0 -7
  235. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -160
  236. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -7
  237. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
  238. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
  239. package/build/image-editor/react/hooks/use-interaction.cjs +0 -213
  240. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -7
  241. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -38
  242. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -7
  243. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -51
  244. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -7
  245. package/build/image-editor/react/visually-hidden-style.cjs +0 -41
  246. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -7
  247. package/build/index.cjs.map +0 -7
  248. package/build/state/index.cjs.map +0 -7
  249. package/build/utils/index.cjs.map +0 -7
  250. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -66
  251. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -7
  252. package/build-module/image-editor/core/camera.mjs +0 -198
  253. package/build-module/image-editor/core/camera.mjs.map +0 -7
  254. package/build-module/image-editor/core/constants.mjs +0 -69
  255. package/build-module/image-editor/core/constants.mjs.map +0 -7
  256. package/build-module/image-editor/core/containment.mjs +0 -253
  257. package/build-module/image-editor/core/containment.mjs.map +0 -7
  258. package/build-module/image-editor/core/crop-rect.mjs +0 -23
  259. package/build-module/image-editor/core/crop-rect.mjs.map +0 -7
  260. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -120
  261. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -7
  262. package/build-module/image-editor/core/index.mjs +0 -36
  263. package/build-module/image-editor/core/index.mjs.map +0 -7
  264. package/build-module/image-editor/core/interaction-controller.mjs +0 -635
  265. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -7
  266. package/build-module/image-editor/core/math/rotation.mjs +0 -15
  267. package/build-module/image-editor/core/math/rotation.mjs.map +0 -7
  268. package/build-module/image-editor/core/math/sanitize.mjs +0 -63
  269. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -7
  270. package/build-module/image-editor/core/setter-helpers.mjs +0 -39
  271. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -7
  272. package/build-module/image-editor/core/source-region.mjs +0 -178
  273. package/build-module/image-editor/core/source-region.mjs.map +0 -7
  274. package/build-module/image-editor/core/state.mjs +0 -260
  275. package/build-module/image-editor/core/state.mjs.map +0 -7
  276. package/build-module/image-editor/core/stencil-math.mjs +0 -187
  277. package/build-module/image-editor/core/stencil-math.mjs.map +0 -7
  278. package/build-module/image-editor/core/transform-style.mjs +0 -27
  279. package/build-module/image-editor/core/transform-style.mjs.map +0 -7
  280. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -17
  281. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -7
  282. package/build-module/image-editor/core/types.mjs +0 -1
  283. package/build-module/image-editor/core/types.mjs.map +0 -7
  284. package/build-module/image-editor/core/viewport-state.mjs +0 -24
  285. package/build-module/image-editor/core/viewport-state.mjs.map +0 -7
  286. package/build-module/image-editor/index.mjs +0 -39
  287. package/build-module/image-editor/index.mjs.map +0 -7
  288. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -26
  289. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -7
  290. package/build-module/image-editor/react/components/cropper.mjs +0 -704
  291. package/build-module/image-editor/react/components/cropper.mjs.map +0 -7
  292. package/build-module/image-editor/react/components/index.mjs +0 -9
  293. package/build-module/image-editor/react/components/index.mjs.map +0 -7
  294. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -147
  295. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -7
  296. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -37
  297. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -7
  298. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -66
  299. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -7
  300. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -414
  301. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -7
  302. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -27
  303. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -7
  304. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -46
  305. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -7
  306. package/build-module/image-editor/react/hooks/index.mjs +0 -8
  307. package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
  308. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -135
  309. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -7
  310. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
  311. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
  312. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -190
  313. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -7
  314. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -13
  315. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -7
  316. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -29
  317. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -7
  318. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -16
  319. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -7
  320. package/build-module/index.mjs.map +0 -7
  321. package/build-module/state/index.mjs.map +0 -7
  322. package/build-module/utils/index.mjs.map +0 -7
  323. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -80
  324. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  325. package/build-types/image-editor/core/camera.d.ts +0 -128
  326. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  327. package/build-types/image-editor/core/constants.d.ts +0 -99
  328. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  329. package/build-types/image-editor/core/containment.d.ts +0 -72
  330. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  331. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  332. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  333. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  334. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  335. package/build-types/image-editor/core/index.d.ts +0 -10
  336. package/build-types/image-editor/core/index.d.ts.map +0 -1
  337. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  338. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  339. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  340. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  341. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  342. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  343. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  344. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  345. package/build-types/image-editor/core/source-region.d.ts +0 -94
  346. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  347. package/build-types/image-editor/core/state.d.ts +0 -51
  348. package/build-types/image-editor/core/state.d.ts.map +0 -1
  349. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  350. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  351. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  352. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  353. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  354. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  355. package/build-types/image-editor/core/types.d.ts +0 -269
  356. package/build-types/image-editor/core/types.d.ts.map +0 -1
  357. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  358. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  359. package/build-types/image-editor/index.d.ts +0 -16
  360. package/build-types/image-editor/index.d.ts.map +0 -1
  361. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  362. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  363. package/build-types/image-editor/react/components/cropper.d.ts +0 -63
  364. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  365. package/build-types/image-editor/react/components/index.d.ts +0 -4
  366. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  367. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  368. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  369. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  370. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  371. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  372. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  373. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  374. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  375. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  376. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  377. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  378. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  379. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  380. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  381. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  382. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  383. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -55
  384. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
  385. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  386. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  387. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  388. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  389. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  390. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  391. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  392. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  393. package/src/components/media-editor-modal/build-modifiers.ts +0 -161
  394. package/src/image-editor/README.md +0 -61
  395. package/src/image-editor/core/camera.ts +0 -429
  396. package/src/image-editor/core/constants.ts +0 -150
  397. package/src/image-editor/core/containment.ts +0 -469
  398. package/src/image-editor/core/crop-rect.ts +0 -42
  399. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  400. package/src/image-editor/core/index.ts +0 -47
  401. package/src/image-editor/core/interaction-controller.ts +0 -976
  402. package/src/image-editor/core/math/rotation.ts +0 -26
  403. package/src/image-editor/core/math/sanitize.ts +0 -155
  404. package/src/image-editor/core/setter-helpers.ts +0 -63
  405. package/src/image-editor/core/source-region.ts +0 -367
  406. package/src/image-editor/core/state.ts +0 -484
  407. package/src/image-editor/core/stencil-math.ts +0 -379
  408. package/src/image-editor/core/transform-style.ts +0 -56
  409. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  410. package/src/image-editor/core/types.ts +0 -230
  411. package/src/image-editor/core/viewport-state.ts +0 -30
  412. package/src/image-editor/docs/architecture.md +0 -63
  413. package/src/image-editor/docs/recipes.md +0 -184
  414. package/src/image-editor/index.ts +0 -52
  415. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  416. package/src/image-editor/react/components/cropper.scss +0 -259
  417. package/src/image-editor/react/components/cropper.tsx +0 -1116
  418. package/src/image-editor/react/components/index.ts +0 -3
  419. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  420. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  421. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  422. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  423. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  424. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  425. package/src/image-editor/react/hooks/index.ts +0 -4
  426. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  427. package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -197
  428. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  429. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  430. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  431. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  432. package/src/image-editor/style.scss +0 -1
@@ -1,83 +1,72 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
13
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _wordpress_i18n = require("@wordpress/i18n");
28
+ let ______state_index_ts = require("../../state/index.cjs");
29
+ let ______hooks_use_crop_gesture_handlers_ts = require("../../hooks/use-crop-gesture-handlers.cjs");
30
+ let ___rotation_ruler_index_tsx = require("../rotation-ruler/index.cjs");
31
+ ___rotation_ruler_index_tsx = __toESM(___rotation_ruler_index_tsx);
32
+ let react_jsx_runtime = require("react/jsx-runtime");
30
33
  // packages/media-editor/src/components/media-editor-fine-rotation/index.tsx
31
- var media_editor_fine_rotation_exports = {};
32
- __export(media_editor_fine_rotation_exports, {
33
- default: () => MediaEditorFineRotation
34
- });
35
- module.exports = __toCommonJS(media_editor_fine_rotation_exports);
36
- var import_i18n = require("@wordpress/i18n");
37
- var import_state = require("../../state/index.cjs");
38
- var import_use_crop_gesture_handlers = require("../../hooks/use-crop-gesture-handlers.cjs");
39
- var import_constants = require("../../image-editor/core/constants.cjs");
40
- var import_rotation_ruler = __toESM(require("../rotation-ruler/index.cjs"));
41
- var import_jsx_runtime = require("react/jsx-runtime");
42
- function MediaEditorFineRotation({
43
- onPlacementControlInteraction,
44
- disabled = false
45
- }) {
46
- const { state, setRotation } = (0, import_state.useMediaEditor)().cropper;
47
- const rotationGestureHandlers = (0, import_use_crop_gesture_handlers.useCropGestureHandlers)({
48
- commitOnKeyUp: false
49
- });
50
- const baseAngle = Math.round(state.rotation / 90) * 90;
51
- const singleFlip = state.flip.horizontal !== state.flip.vertical;
52
- const visualDir = singleFlip ? -1 : 1;
53
- const fineOffset = (state.rotation - baseAngle) * visualDir;
54
- const handleRotationSlider = (value) => {
55
- const EPS = 0.01;
56
- const clamped = Math.max(
57
- -import_constants.MAX_ROTATION_OFFSET + EPS,
58
- Math.min(import_constants.MAX_ROTATION_OFFSET - EPS, value)
59
- );
60
- onPlacementControlInteraction?.();
61
- setRotation(baseAngle + clamped * visualDir);
62
- };
63
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
- "div",
65
- {
66
- role: "presentation",
67
- className: "media-editor-fine-rotation",
68
- ...rotationGestureHandlers,
69
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
- import_rotation_ruler.default,
71
- {
72
- label: (0, import_i18n.__)("Fine rotation"),
73
- min: -import_constants.MAX_ROTATION_OFFSET,
74
- max: import_constants.MAX_ROTATION_OFFSET,
75
- value: fineOffset,
76
- onChange: handleRotationSlider,
77
- disabled
78
- }
79
- )
80
- }
81
- );
34
+ /**
35
+ * Fine-rotation slider for the media editor. It renders under the canvas so it
36
+ * stays constrained to the canvas column at all viewport sizes. Lives
37
+ * separately from the snap-rotate / flip buttons so the two can be placed
38
+ * independently per viewport.
39
+ *
40
+ * @param props
41
+ * @param props.onPlacementControlInteraction
42
+ * @param props.disabled
43
+ */
44
+ function MediaEditorFineRotation({ onPlacementControlInteraction, disabled = false }) {
45
+ const { state, setRotation, maxRotationOffset } = (0, ______state_index_ts.useMediaEditor)().imageEditor;
46
+ const rotationGestureHandlers = (0, ______hooks_use_crop_gesture_handlers_ts.useCropGestureHandlers)({ commitOnKeyUp: false });
47
+ const baseAngle = Math.round(state.rotation / 90) * 90;
48
+ const visualDir = state.flip.horizontal !== state.flip.vertical ? -1 : 1;
49
+ const fineOffset = (state.rotation - baseAngle) * visualDir;
50
+ const handleRotationSlider = (value) => {
51
+ const EPS = .01;
52
+ const clamped = Math.max(-maxRotationOffset + EPS, Math.min(maxRotationOffset - EPS, value));
53
+ onPlacementControlInteraction?.();
54
+ setRotation(baseAngle + clamped * visualDir);
55
+ };
56
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
57
+ role: "presentation",
58
+ className: "media-editor-fine-rotation",
59
+ ...rotationGestureHandlers,
60
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___rotation_ruler_index_tsx.default, {
61
+ label: (0, _wordpress_i18n.__)("Fine rotation"),
62
+ min: -maxRotationOffset,
63
+ max: maxRotationOffset,
64
+ value: fineOffset,
65
+ onChange: handleRotationSlider,
66
+ disabled
67
+ })
68
+ });
82
69
  }
83
- //# sourceMappingURL=index.cjs.map
70
+ exports.default = MediaEditorFineRotation;
71
+
72
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/media-editor-fine-rotation/index.tsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useMediaEditor } from '../../state';\nimport { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';\nimport { MAX_ROTATION_OFFSET } from '../../image-editor/core/constants';\nimport RotationRuler from '../rotation-ruler';\n\nexport interface MediaEditorFineRotationProps {\n\t/** Signal that a placement-oriented control is being adjusted. */\n\tonPlacementControlInteraction?: () => void;\n\t/**\n\t * Disable the ruler. Set while the edit is saving; `RotationRuler`\n\t * cancels an in-flight drag when this flips.\n\t */\n\tdisabled?: boolean;\n}\n\n/**\n * Fine-rotation slider for the media editor. It renders under the canvas so it\n * stays constrained to the canvas column at all viewport sizes. Lives\n * separately from the snap-rotate / flip buttons so the two can be placed\n * independently per viewport.\n *\n * @param props\n * @param props.onPlacementControlInteraction\n * @param props.disabled\n */\nexport default function MediaEditorFineRotation( {\n\tonPlacementControlInteraction,\n\tdisabled = false,\n}: MediaEditorFineRotationProps ) {\n\tconst { state, setRotation } = useMediaEditor().cropper;\n\t// `commitOnKeyUp: false` lets rapid arrow-key adjustments coalesce\n\t// into one undo entry via the gesture idle window. Pointer-up still\n\t// closes pointer drags immediately.\n\tconst rotationGestureHandlers = useCropGestureHandlers( {\n\t\tcommitOnKeyUp: false,\n\t} );\n\n\t// `setRotation` is an absolute-angle setter. When a single flip is active\n\t// the visual direction inverts, so slider input must flip sign to match\n\t// what the user sees. `snapRotate90` already handles this internally.\n\tconst baseAngle = Math.round( state.rotation / 90 ) * 90;\n\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\tconst visualDir = singleFlip ? -1 : 1;\n\tconst fineOffset = ( state.rotation - baseAngle ) * visualDir;\n\n\tconst handleRotationSlider = ( value: number ) => {\n\t\t// Clamp strictly inside [-MAX, MAX). Exactly ±MAX lands state on a\n\t\t// 90° midpoint and flips the derived baseAngle on the next render,\n\t\t// causing subsequent events to spiral.\n\t\tconst EPS = 0.01;\n\t\tconst clamped = Math.max(\n\t\t\t-MAX_ROTATION_OFFSET + EPS,\n\t\t\tMath.min( MAX_ROTATION_OFFSET - EPS, value )\n\t\t);\n\t\tonPlacementControlInteraction?.();\n\t\tsetRotation( baseAngle + clamped * visualDir );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\trole=\"presentation\"\n\t\t\tclassName=\"media-editor-fine-rotation\"\n\t\t\t{ ...rotationGestureHandlers }\n\t\t>\n\t\t\t<RotationRuler\n\t\t\t\tlabel={ __( 'Fine rotation' ) }\n\t\t\t\tmin={ -MAX_ROTATION_OFFSET }\n\t\t\t\tmax={ MAX_ROTATION_OFFSET }\n\t\t\t\tvalue={ fineOffset }\n\t\t\t\tonChange={ handleRotationSlider }\n\t\t\t\tdisabled={ disabled }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,mBAA+B;AAC/B,uCAAuC;AACvC,uBAAoC;AACpC,4BAA0B;AA6DvB;AAvCY,SAAR,wBAA0C;AAAA,EAChD;AAAA,EACA,WAAW;AACZ,GAAkC;AACjC,QAAM,EAAE,OAAO,YAAY,QAAI,6BAAe,EAAE;AAIhD,QAAM,8BAA0B,yDAAwB;AAAA,IACvD,eAAe;AAAA,EAChB,CAAE;AAKF,QAAM,YAAY,KAAK,MAAO,MAAM,WAAW,EAAG,IAAI;AACtD,QAAM,aAAa,MAAM,KAAK,eAAe,MAAM,KAAK;AACxD,QAAM,YAAY,aAAa,KAAK;AACpC,QAAM,cAAe,MAAM,WAAW,aAAc;AAEpD,QAAM,uBAAuB,CAAE,UAAmB;AAIjD,UAAM,MAAM;AACZ,UAAM,UAAU,KAAK;AAAA,MACpB,CAAC,uCAAsB;AAAA,MACvB,KAAK,IAAK,uCAAsB,KAAK,KAAM;AAAA,IAC5C;AACA,oCAAgC;AAChC,gBAAa,YAAY,UAAU,SAAU;AAAA,EAC9C;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,WAAU;AAAA,MACR,GAAG;AAAA,MAEL;AAAA,QAAC,sBAAAA;AAAA,QAAA;AAAA,UACA,WAAQ,gBAAI,eAAgB;AAAA,UAC5B,KAAM,CAAC;AAAA,UACP,KAAM;AAAA,UACN,OAAQ;AAAA,UACR,UAAW;AAAA,UACX;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
6
- "names": ["RotationRuler"]
7
- }
1
+ {"version":3,"file":"index.cjs","names":["useMediaEditor","useCropGestureHandlers","RotationRuler","__"],"sources":["../../../src/components/media-editor-fine-rotation/index.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { useMediaEditor } from '../../state';\nimport { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';\nimport RotationRuler from '../rotation-ruler';\n\nexport interface MediaEditorFineRotationProps {\n\t/** Signal that a placement-oriented control is being adjusted. */\n\tonPlacementControlInteraction?: () => void;\n\t/**\n\t * Disable the ruler. Set while the edit is saving; `RotationRuler`\n\t * cancels an in-flight drag when this flips.\n\t */\n\tdisabled?: boolean;\n}\n\n/**\n * Fine-rotation slider for the media editor. It renders under the canvas so it\n * stays constrained to the canvas column at all viewport sizes. Lives\n * separately from the snap-rotate / flip buttons so the two can be placed\n * independently per viewport.\n *\n * @param props\n * @param props.onPlacementControlInteraction\n * @param props.disabled\n */\nexport default function MediaEditorFineRotation( {\n\tonPlacementControlInteraction,\n\tdisabled = false,\n}: MediaEditorFineRotationProps ) {\n\tconst { state, setRotation, maxRotationOffset } =\n\t\tuseMediaEditor().imageEditor;\n\t// `commitOnKeyUp: false` lets rapid arrow-key adjustments coalesce\n\t// into one undo entry via the gesture idle window. Pointer-up still\n\t// closes pointer drags immediately.\n\tconst rotationGestureHandlers = useCropGestureHandlers( {\n\t\tcommitOnKeyUp: false,\n\t} );\n\n\t// `setRotation` is an absolute-angle setter. When a single flip is active\n\t// the visual direction inverts, so slider input must flip sign to match\n\t// what the user sees. `snapRotate90` already handles this internally.\n\tconst baseAngle = Math.round( state.rotation / 90 ) * 90;\n\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\tconst visualDir = singleFlip ? -1 : 1;\n\tconst fineOffset = ( state.rotation - baseAngle ) * visualDir;\n\n\tconst handleRotationSlider = ( value: number ) => {\n\t\t// Clamp strictly inside [-MAX, MAX). Exactly ±MAX lands state on a\n\t\t// 90° midpoint and flips the derived baseAngle on the next render,\n\t\t// causing subsequent events to spiral.\n\t\tconst EPS = 0.01;\n\t\tconst clamped = Math.max(\n\t\t\t-maxRotationOffset + EPS,\n\t\t\tMath.min( maxRotationOffset - EPS, value )\n\t\t);\n\t\tonPlacementControlInteraction?.();\n\t\tsetRotation( baseAngle + clamped * visualDir );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\trole=\"presentation\"\n\t\t\tclassName=\"media-editor-fine-rotation\"\n\t\t\t{ ...rotationGestureHandlers }\n\t\t>\n\t\t\t<RotationRuler\n\t\t\t\tlabel={ __( 'Fine rotation' ) }\n\t\t\t\tmin={ -maxRotationOffset }\n\t\t\t\tmax={ maxRotationOffset }\n\t\t\t\tvalue={ fineOffset }\n\t\t\t\tonChange={ handleRotationSlider }\n\t\t\t\tdisabled={ disabled }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAwB,wBAAyB,EAChD,+BACA,WAAW,SACsB;CACjC,MAAM,EAAE,OAAO,aAAa,uBAAA,GAC3BA,qBAAAA,eAAAA,CAAe,CAAC,CAAC;CAIlB,MAAM,2BAAA,GAA0BC,yCAAAA,uBAAAA,CAAwB,EACvD,eAAe,MAChB,CAAE;CAKF,MAAM,YAAY,KAAK,MAAO,MAAM,WAAW,EAAG,IAAI;CAEtD,MAAM,YADa,MAAM,KAAK,eAAe,MAAM,KAAK,WACzB,KAAK;CACpC,MAAM,cAAe,MAAM,WAAW,aAAc;CAEpD,MAAM,wBAAyB,UAAmB;EAIjD,MAAM,MAAM;EACZ,MAAM,UAAU,KAAK,IACpB,CAAC,oBAAoB,KACrB,KAAK,IAAK,oBAAoB,KAAK,KAAM,CAC1C;EACA,gCAAgC;EAChC,YAAa,YAAY,UAAU,SAAU;CAC9C;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACC,MAAK;EACL,WAAU;EACV,GAAK;EAEL,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAAA,SAAD;GACC,QAAA,GAAQC,gBAAAA,GAAAA,CAAI,eAAgB;GAC5B,KAAM,CAAC;GACP,KAAM;GACN,OAAQ;GACR,UAAW;GACA;EACX,CAAA;CACG,CAAA;AAEP"}
@@ -1,260 +1,184 @@
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/components/media-editor-image-controls/index.tsx
21
- var media_editor_image_controls_exports = {};
22
- __export(media_editor_image_controls_exports, {
23
- DEFAULT_ZOOM_FACTOR: () => DEFAULT_ZOOM_FACTOR,
24
- default: () => MediaEditorImageControls
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
25
5
  });
26
- module.exports = __toCommonJS(media_editor_image_controls_exports);
27
- var import_components = require("@wordpress/components");
28
- var import_ui = require("@wordpress/ui");
29
- var import_i18n = require("@wordpress/i18n");
30
- var import_icons = require("@wordpress/icons");
31
- var import_state = require("../../state/index.cjs");
32
- var import_constants = require("../../image-editor/core/constants.cjs");
33
- var import_containment = require("../../image-editor/core/containment.cjs");
34
- var import_use_crop_options = require("../media-editor/use-crop-options.cjs");
35
- var import_jsx_runtime = require("react/jsx-runtime");
36
- var DEFAULT_ZOOM_FACTOR = 1.2;
37
- function MediaEditorImageControls({
38
- withLabels = false,
39
- showAspectRatioControl = false,
40
- aspectRatioPresets,
41
- zoomFactor = DEFAULT_ZOOM_FACTOR,
42
- disabled = false
43
- }) {
44
- const { state, setFlip, snapRotate90, setZoom } = (0, import_state.useMediaEditor)().cropper;
45
- const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, import_use_crop_options.useCropOptions)({ aspectRatioPresets });
46
- const hasAspectRatioControl = !withLabels && showAspectRatioControl;
47
- const minZoom = (0, import_containment.getMinZoom)(state);
48
- const zoomByFactor = (factor) => {
49
- setZoom(
50
- Math.min(import_constants.MAX_ZOOM, Math.max(minZoom, state.zoom * factor))
51
- );
52
- };
53
- const rotateButtons = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
54
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
55
- import_components.Button,
56
- {
57
- size: "compact",
58
- icon: import_icons.rotateLeft,
59
- label: (0, import_i18n.__)("Rotate 90° counter-clockwise"),
60
- showTooltip: true,
61
- disabled,
62
- accessibleWhenDisabled: true,
63
- onClick: () => snapRotate90(-1)
64
- }
65
- ),
66
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
- import_components.Button,
68
- {
69
- size: "compact",
70
- icon: import_icons.rotateRight,
71
- label: (0, import_i18n.__)("Rotate 90° clockwise"),
72
- showTooltip: true,
73
- disabled,
74
- accessibleWhenDisabled: true,
75
- onClick: () => snapRotate90(1)
76
- }
77
- )
78
- ] });
79
- const flipButtons = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
80
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
81
- import_components.Button,
82
- {
83
- size: "compact",
84
- icon: import_icons.flipHorizontal,
85
- label: (0, import_i18n.__)("Flip horizontal"),
86
- showTooltip: true,
87
- isPressed: state.flip.horizontal,
88
- disabled,
89
- accessibleWhenDisabled: true,
90
- onClick: () => setFlip({
91
- horizontal: !state.flip.horizontal,
92
- vertical: state.flip.vertical
93
- })
94
- }
95
- ),
96
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
97
- import_components.Button,
98
- {
99
- size: "compact",
100
- icon: import_icons.flipVertical,
101
- label: (0, import_i18n.__)("Flip vertical"),
102
- showTooltip: true,
103
- isPressed: state.flip.vertical,
104
- disabled,
105
- accessibleWhenDisabled: true,
106
- onClick: () => setFlip({
107
- horizontal: state.flip.horizontal,
108
- vertical: !state.flip.vertical
109
- })
110
- }
111
- )
112
- ] });
113
- const zoomButtons = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
114
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
115
- import_components.Button,
116
- {
117
- size: "compact",
118
- icon: import_icons.plus,
119
- label: (0, import_i18n.__)("Zoom in"),
120
- showTooltip: true,
121
- disabled: disabled || state.zoom >= import_constants.MAX_ZOOM,
122
- accessibleWhenDisabled: true,
123
- onClick: () => zoomByFactor(zoomFactor)
124
- }
125
- ),
126
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
127
- import_components.Button,
128
- {
129
- size: "compact",
130
- icon: import_icons.lineSolid,
131
- label: (0, import_i18n.__)("Zoom out"),
132
- showTooltip: true,
133
- disabled: disabled || state.zoom <= minZoom,
134
- accessibleWhenDisabled: true,
135
- onClick: () => zoomByFactor(1 / zoomFactor)
136
- }
137
- )
138
- ] });
139
- const aspectRatioDropdown = hasAspectRatioControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Menu.Root, { children: [
140
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
- import_ui.Menu.Trigger,
142
- {
143
- disabled,
144
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
145
- import_components.Button,
146
- {
147
- size: "compact",
148
- icon: import_icons.aspectRatio,
149
- label: (0, import_i18n.__)("Aspect ratio"),
150
- accessibleWhenDisabled: true
151
- }
152
- )
153
- }
154
- ),
155
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
156
- import_ui.Menu.Popup,
157
- {
158
- positioner: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Menu.Positioner, { side: "top", align: "center" }),
159
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
160
- import_ui.Menu.RadioGroup,
161
- {
162
- value: aspectRatioValue,
163
- onValueChange: (value) => {
164
- if (!disabled) {
165
- setAspectRatioValue(value);
166
- }
167
- },
168
- children: [
169
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Menu.GroupLabel, { children: (0, import_i18n.__)("Aspect ratio") }),
170
- aspectRatioOptions.map((preset) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
171
- import_ui.Menu.RadioItem,
172
- {
173
- value: preset.value.toString(),
174
- closeOnClick: true,
175
- disabled,
176
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Menu.ItemLabel, { children: preset.label })
177
- },
178
- preset.value
179
- ))
180
- ]
181
- }
182
- )
183
- }
184
- )
185
- ] }) : null;
186
- if (withLabels) {
187
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-image-controls is-stacked", children: [
188
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-image-controls__transforms", children: [
189
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
190
- "div",
191
- {
192
- className: "media-editor-image-controls__group",
193
- role: "group",
194
- "aria-label": (0, import_i18n.__)("Rotate"),
195
- children: [
196
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
197
- "span",
198
- {
199
- className: "media-editor-image-controls__label",
200
- "aria-hidden": "true",
201
- children: (0, import_i18n.__)("Rotate")
202
- }
203
- ),
204
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor-image-controls__buttons", children: rotateButtons })
205
- ]
206
- }
207
- ),
208
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
209
- "div",
210
- {
211
- className: "media-editor-image-controls__group",
212
- role: "group",
213
- "aria-label": (0, import_i18n.__)("Flip"),
214
- children: [
215
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
216
- "span",
217
- {
218
- className: "media-editor-image-controls__label",
219
- "aria-hidden": "true",
220
- children: (0, import_i18n.__)("Flip")
221
- }
222
- ),
223
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor-image-controls__buttons", children: flipButtons })
224
- ]
225
- }
226
- )
227
- ] }),
228
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
229
- "div",
230
- {
231
- className: "media-editor-image-controls__group",
232
- role: "group",
233
- "aria-label": (0, import_i18n.__)("Zoom"),
234
- children: [
235
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
- "span",
237
- {
238
- className: "media-editor-image-controls__label",
239
- "aria-hidden": "true",
240
- children: (0, import_i18n.__)("Zoom")
241
- }
242
- ),
243
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor-image-controls__buttons", children: zoomButtons })
244
- ]
245
- }
246
- )
247
- ] });
248
- }
249
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-image-controls", children: [
250
- rotateButtons,
251
- flipButtons,
252
- zoomButtons,
253
- aspectRatioDropdown
254
- ] });
6
+ let _wordpress_components = require("@wordpress/components");
7
+ let _wordpress_ui = require("@wordpress/ui");
8
+ let _wordpress_i18n = require("@wordpress/i18n");
9
+ let _wordpress_icons = require("@wordpress/icons");
10
+ let ______state_index_ts = require("../../state/index.cjs");
11
+ let ___media_editor_use_crop_options_ts = require("../media-editor/use-crop-options.cjs");
12
+ let react_jsx_runtime = require("react/jsx-runtime");
13
+ // packages/media-editor/src/components/media-editor-image-controls/index.tsx
14
+ /**
15
+ * Default zoom factor per +/- click. Zooming is geometric, so a fixed
16
+ * multiplier — rather than an additive step — makes each click feel like the
17
+ * same amount of zoom at any level (an additive `+0.1` is a 10% jump at 1× but
18
+ * a ~1% nudge at 10×). `1.2` is ~+20% per click. Overridable via the
19
+ * `zoomFactor` prop.
20
+ */
21
+ const DEFAULT_ZOOM_FACTOR = 1.2;
22
+ /**
23
+ * Image editing controls placed independently per viewport: on wide viewports
24
+ * rotate/flip/zoom render inside the Crop panel (`withLabels`), and at narrower
25
+ * widths they fall back into the footer toolbar (flat row), where the
26
+ * aspect-ratio dropdown can also be shown.
27
+ *
28
+ * @param props
29
+ * @param props.withLabels
30
+ * @param props.showAspectRatioControl
31
+ * @param props.aspectRatioPresets
32
+ * @param props.zoomFactor
33
+ * @param props.disabled
34
+ */
35
+ function MediaEditorImageControls({ withLabels = false, showAspectRatioControl = false, aspectRatioPresets, zoomFactor = DEFAULT_ZOOM_FACTOR, disabled = false }) {
36
+ const { state, setFlip, snapRotate90, setZoom, minZoom, maxZoom } = (0, ______state_index_ts.useMediaEditor)().imageEditor;
37
+ const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, ___media_editor_use_crop_options_ts.useCropOptions)({ aspectRatioPresets });
38
+ const hasAspectRatioControl = !withLabels && showAspectRatioControl;
39
+ const zoomByFactor = (factor) => {
40
+ setZoom(Math.min(maxZoom, Math.max(minZoom, state.zoom * factor)));
41
+ };
42
+ const rotateButtons = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
43
+ size: "compact",
44
+ icon: _wordpress_icons.rotateLeft,
45
+ label: (0, _wordpress_i18n.__)("Rotate 90° counter-clockwise"),
46
+ showTooltip: true,
47
+ disabled,
48
+ accessibleWhenDisabled: true,
49
+ onClick: () => snapRotate90(-1)
50
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
51
+ size: "compact",
52
+ icon: _wordpress_icons.rotateRight,
53
+ label: (0, _wordpress_i18n.__)("Rotate 90° clockwise"),
54
+ showTooltip: true,
55
+ disabled,
56
+ accessibleWhenDisabled: true,
57
+ onClick: () => snapRotate90(1)
58
+ })] });
59
+ const flipButtons = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
60
+ size: "compact",
61
+ icon: _wordpress_icons.flipHorizontal,
62
+ label: (0, _wordpress_i18n.__)("Flip horizontal"),
63
+ showTooltip: true,
64
+ isPressed: state.flip.horizontal,
65
+ disabled,
66
+ accessibleWhenDisabled: true,
67
+ onClick: () => setFlip({
68
+ horizontal: !state.flip.horizontal,
69
+ vertical: state.flip.vertical
70
+ })
71
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
72
+ size: "compact",
73
+ icon: _wordpress_icons.flipVertical,
74
+ label: (0, _wordpress_i18n.__)("Flip vertical"),
75
+ showTooltip: true,
76
+ isPressed: state.flip.vertical,
77
+ disabled,
78
+ accessibleWhenDisabled: true,
79
+ onClick: () => setFlip({
80
+ horizontal: state.flip.horizontal,
81
+ vertical: !state.flip.vertical
82
+ })
83
+ })] });
84
+ const zoomButtons = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
85
+ size: "compact",
86
+ icon: _wordpress_icons.plus,
87
+ label: (0, _wordpress_i18n.__)("Zoom in"),
88
+ showTooltip: true,
89
+ disabled: disabled || state.zoom >= maxZoom,
90
+ accessibleWhenDisabled: true,
91
+ onClick: () => zoomByFactor(zoomFactor)
92
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
93
+ size: "compact",
94
+ icon: _wordpress_icons.lineSolid,
95
+ label: (0, _wordpress_i18n.__)("Zoom out"),
96
+ showTooltip: true,
97
+ disabled: disabled || state.zoom <= minZoom,
98
+ accessibleWhenDisabled: true,
99
+ onClick: () => zoomByFactor(1 / zoomFactor)
100
+ })] });
101
+ const aspectRatioDropdown = hasAspectRatioControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Menu.Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.Trigger, {
102
+ disabled,
103
+ render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
104
+ size: "compact",
105
+ icon: _wordpress_icons.aspectRatio,
106
+ label: (0, _wordpress_i18n.__)("Aspect ratio"),
107
+ accessibleWhenDisabled: true
108
+ })
109
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.Popup, {
110
+ positioner: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.Positioner, {
111
+ side: "top",
112
+ align: "center"
113
+ }),
114
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Menu.RadioGroup, {
115
+ value: aspectRatioValue,
116
+ onValueChange: (value) => {
117
+ if (!disabled) setAspectRatioValue(value);
118
+ },
119
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.GroupLabel, { children: (0, _wordpress_i18n.__)("Aspect ratio") }), aspectRatioOptions.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.RadioItem, {
120
+ value: preset.value.toString(),
121
+ closeOnClick: true,
122
+ disabled,
123
+ prefix: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.PrefixIcon, { icon: (0, _wordpress_icons.getAspectRatioIcon)(preset.value) }),
124
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.ItemLabel, { children: preset.label })
125
+ }, preset.value))]
126
+ })
127
+ })] }) : null;
128
+ if (withLabels) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
129
+ className: "media-editor-image-controls is-stacked",
130
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
131
+ className: "media-editor-image-controls__transforms",
132
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
133
+ className: "media-editor-image-controls__group",
134
+ role: "group",
135
+ "aria-label": (0, _wordpress_i18n.__)("Rotate"),
136
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
137
+ className: "media-editor-image-controls__label",
138
+ "aria-hidden": "true",
139
+ children: (0, _wordpress_i18n.__)("Rotate")
140
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
141
+ className: "media-editor-image-controls__buttons",
142
+ children: rotateButtons
143
+ })]
144
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
145
+ className: "media-editor-image-controls__group",
146
+ role: "group",
147
+ "aria-label": (0, _wordpress_i18n.__)("Flip"),
148
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
149
+ className: "media-editor-image-controls__label",
150
+ "aria-hidden": "true",
151
+ children: (0, _wordpress_i18n.__)("Flip")
152
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
153
+ className: "media-editor-image-controls__buttons",
154
+ children: flipButtons
155
+ })]
156
+ })]
157
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
158
+ className: "media-editor-image-controls__group",
159
+ role: "group",
160
+ "aria-label": (0, _wordpress_i18n.__)("Zoom"),
161
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
162
+ className: "media-editor-image-controls__label",
163
+ "aria-hidden": "true",
164
+ children: (0, _wordpress_i18n.__)("Zoom")
165
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
166
+ className: "media-editor-image-controls__buttons",
167
+ children: zoomButtons
168
+ })]
169
+ })]
170
+ });
171
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
172
+ className: "media-editor-image-controls",
173
+ children: [
174
+ rotateButtons,
175
+ flipButtons,
176
+ zoomButtons,
177
+ aspectRatioDropdown
178
+ ]
179
+ });
255
180
  }
256
- // Annotate the CommonJS export names for ESM import in node:
257
- 0 && (module.exports = {
258
- DEFAULT_ZOOM_FACTOR
259
- });
260
- //# sourceMappingURL=index.cjs.map
181
+ exports.DEFAULT_ZOOM_FACTOR = DEFAULT_ZOOM_FACTOR;
182
+ exports.default = MediaEditorImageControls;
183
+
184
+ //# sourceMappingURL=index.cjs.map