@wordpress/media-editor 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (386) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +2 -1
  3. package/build/components/media-editor/index.cjs +533 -695
  4. package/build/components/media-editor/index.cjs.map +1 -7
  5. package/build/components/media-editor/use-crop-options.cjs +43 -58
  6. package/build/components/media-editor/use-crop-options.cjs.map +1 -7
  7. package/build/components/media-editor/use-save-media-editor.cjs +111 -185
  8. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
  9. package/build/components/media-editor-canvas/index.cjs +122 -124
  10. package/build/components/media-editor-canvas/index.cjs.map +1 -7
  11. package/build/components/media-editor-crop-panel/index.cjs +65 -68
  12. package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
  13. package/build/components/media-editor-fine-rotation/index.cjs +62 -72
  14. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
  15. package/build/components/media-editor-image-controls/index.cjs +183 -257
  16. package/build/components/media-editor-image-controls/index.cjs.map +1 -7
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +119 -157
  18. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
  19. package/build/components/media-editor-modal/build-modifiers.cjs +107 -88
  20. package/build/components/media-editor-modal/build-modifiers.cjs.map +1 -7
  21. package/build/components/media-editor-modal/index.cjs +112 -153
  22. package/build/components/media-editor-modal/index.cjs.map +1 -7
  23. package/build/components/media-editor-provider/index.cjs +32 -54
  24. package/build/components/media-editor-provider/index.cjs.map +1 -7
  25. package/build/components/media-form/index.cjs +77 -78
  26. package/build/components/media-form/index.cjs.map +1 -7
  27. package/build/components/media-preview/index.cjs +114 -114
  28. package/build/components/media-preview/index.cjs.map +1 -7
  29. package/build/components/rotation-ruler/index.cjs +181 -188
  30. package/build/components/rotation-ruler/index.cjs.map +1 -7
  31. package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
  32. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
  33. package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
  34. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
  35. package/build/image-editor/core/camera.cjs +257 -205
  36. package/build/image-editor/core/camera.cjs.map +1 -7
  37. package/build/image-editor/core/constants.cjs +127 -102
  38. package/build/image-editor/core/constants.cjs.map +1 -7
  39. package/build/image-editor/core/containment.cjs +275 -262
  40. package/build/image-editor/core/containment.cjs.map +1 -7
  41. package/build/image-editor/core/crop-rect.cjs +33 -44
  42. package/build/image-editor/core/crop-rect.cjs.map +1 -7
  43. package/build/image-editor/core/export/canvas-renderer.cjs +165 -135
  44. package/build/image-editor/core/export/canvas-renderer.cjs.map +1 -7
  45. package/build/image-editor/core/index.cjs +88 -61
  46. package/build/image-editor/core/interaction-controller.cjs +583 -646
  47. package/build/image-editor/core/interaction-controller.cjs.map +1 -7
  48. package/build/image-editor/core/math/rotation.cjs +26 -35
  49. package/build/image-editor/core/math/rotation.cjs.map +1 -7
  50. package/build/image-editor/core/math/sanitize.cjs +124 -80
  51. package/build/image-editor/core/math/sanitize.cjs.map +1 -7
  52. package/build/image-editor/core/setter-helpers.cjs +57 -60
  53. package/build/image-editor/core/setter-helpers.cjs.map +1 -7
  54. package/build/image-editor/core/source-region.cjs +220 -190
  55. package/build/image-editor/core/source-region.cjs.map +1 -7
  56. package/build/image-editor/core/state.cjs +278 -265
  57. package/build/image-editor/core/state.cjs.map +1 -7
  58. package/build/image-editor/core/stencil-math.cjs +193 -206
  59. package/build/image-editor/core/stencil-math.cjs.map +1 -7
  60. package/build/image-editor/core/transform-style.cjs +39 -48
  61. package/build/image-editor/core/transform-style.cjs.map +1 -7
  62. package/build/image-editor/core/transforms/pipeline.cjs +36 -38
  63. package/build/image-editor/core/transforms/pipeline.cjs.map +1 -7
  64. package/build/image-editor/core/types.cjs +4 -18
  65. package/build/image-editor/core/viewport-state.cjs +31 -45
  66. package/build/image-editor/core/viewport-state.cjs.map +1 -7
  67. package/build/image-editor/index.cjs +65 -64
  68. package/build/image-editor/react/components/cropper-provider.cjs +44 -45
  69. package/build/image-editor/react/components/cropper-provider.cjs.map +1 -7
  70. package/build/image-editor/react/components/cropper.cjs +583 -720
  71. package/build/image-editor/react/components/cropper.cjs.map +1 -7
  72. package/build/image-editor/react/components/index.cjs +22 -33
  73. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +135 -160
  74. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +1 -7
  75. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +28 -59
  76. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +1 -7
  77. package/build/image-editor/react/components/overlays/grid-overlay.cjs +58 -88
  78. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +1 -7
  79. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +361 -420
  80. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +1 -7
  81. package/build/image-editor/react/components/viewport-provider.cjs +21 -46
  82. package/build/image-editor/react/components/viewport-provider.cjs.map +1 -7
  83. package/build/image-editor/react/hooks/build-cropper-setters.cjs +76 -67
  84. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +1 -7
  85. package/build/image-editor/react/hooks/index.cjs +16 -31
  86. package/build/image-editor/react/hooks/use-aria-announcer.cjs +90 -146
  87. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +1 -7
  88. package/build/image-editor/react/hooks/use-cropper-controller.cjs +80 -0
  89. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +1 -0
  90. package/build/image-editor/react/hooks/use-interaction.cjs +179 -205
  91. package/build/image-editor/react/hooks/use-interaction.cjs.map +1 -7
  92. package/build/image-editor/react/hooks/use-transform-style.cjs +20 -34
  93. package/build/image-editor/react/hooks/use-transform-style.cjs.map +1 -7
  94. package/build/image-editor/react/hooks/use-viewport-state.cjs +36 -47
  95. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +1 -7
  96. package/build/image-editor/react/visually-hidden-style.cjs +21 -38
  97. package/build/image-editor/react/visually-hidden-style.cjs.map +1 -7
  98. package/build/index.cjs +45 -39
  99. package/build/lock-unlock.cjs +9 -35
  100. package/build/lock-unlock.cjs.map +1 -7
  101. package/build/private-apis.cjs +16 -37
  102. package/build/private-apis.cjs.map +1 -7
  103. package/build/state/aspect-ratio-presets.cjs +53 -0
  104. package/build/state/aspect-ratio-presets.cjs.map +1 -0
  105. package/build/state/composite-reducer.cjs +136 -89
  106. package/build/state/composite-reducer.cjs.map +1 -7
  107. package/build/state/index.cjs +63 -47
  108. package/build/state/media-editor-state-provider.cjs +35 -48
  109. package/build/state/media-editor-state-provider.cjs.map +1 -7
  110. package/build/state/types.cjs +12 -31
  111. package/build/state/types.cjs.map +1 -7
  112. package/build/state/use-media-editor-state.cjs +261 -281
  113. package/build/state/use-media-editor-state.cjs.map +1 -7
  114. package/build/store/actions.cjs +17 -44
  115. package/build/store/actions.cjs.map +1 -7
  116. package/build/store/constants.cjs +8 -29
  117. package/build/store/constants.cjs.map +1 -7
  118. package/build/store/index.cjs +33 -40
  119. package/build/store/index.cjs.map +1 -7
  120. package/build/store/reducer.cjs +28 -50
  121. package/build/store/reducer.cjs.map +1 -7
  122. package/build/store/selectors.cjs +16 -41
  123. package/build/store/selectors.cjs.map +1 -7
  124. package/build/utils/get-media-type.cjs +18 -41
  125. package/build/utils/get-media-type.cjs.map +1 -7
  126. package/build/utils/index.cjs +9 -28
  127. package/build-module/components/media-editor/index.mjs +490 -682
  128. package/build-module/components/media-editor/index.mjs.map +1 -7
  129. package/build-module/components/media-editor/use-crop-options.mjs +38 -33
  130. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
  131. package/build-module/components/media-editor/use-save-media-editor.mjs +89 -157
  132. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
  133. package/build-module/components/media-editor-canvas/index.mjs +97 -95
  134. package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
  135. package/build-module/components/media-editor-crop-panel/index.mjs +44 -43
  136. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
  137. package/build-module/components/media-editor-fine-rotation/index.mjs +39 -45
  138. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
  139. package/build-module/components/media-editor-image-controls/index.mjs +172 -237
  140. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
  141. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +112 -137
  142. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
  143. package/build-module/components/media-editor-modal/build-modifiers.mjs +103 -64
  144. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +1 -7
  145. package/build-module/components/media-editor-modal/index.mjs +88 -122
  146. package/build-module/components/media-editor-modal/index.mjs.map +1 -7
  147. package/build-module/components/media-editor-provider/index.mjs +26 -28
  148. package/build-module/components/media-editor-provider/index.mjs.map +1 -7
  149. package/build-module/components/media-form/index.mjs +69 -54
  150. package/build-module/components/media-form/index.mjs.map +1 -7
  151. package/build-module/components/media-preview/index.mjs +105 -89
  152. package/build-module/components/media-preview/index.mjs.map +1 -7
  153. package/build-module/components/rotation-ruler/index.mjs +161 -164
  154. package/build-module/components/rotation-ruler/index.mjs.map +1 -7
  155. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
  156. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
  157. package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
  158. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
  159. package/build-module/image-editor/core/camera.mjs +245 -178
  160. package/build-module/image-editor/core/camera.mjs.map +1 -7
  161. package/build-module/image-editor/core/constants.mjs +110 -64
  162. package/build-module/image-editor/core/constants.mjs.map +1 -7
  163. package/build-module/image-editor/core/containment.mjs +265 -237
  164. package/build-module/image-editor/core/containment.mjs.map +1 -7
  165. package/build-module/image-editor/core/crop-rect.mjs +29 -20
  166. package/build-module/image-editor/core/crop-rect.mjs.map +1 -7
  167. package/build-module/image-editor/core/export/canvas-renderer.mjs +155 -105
  168. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +1 -7
  169. package/build-module/image-editor/core/index.mjs +5 -34
  170. package/build-module/image-editor/core/interaction-controller.mjs +579 -628
  171. package/build-module/image-editor/core/interaction-controller.mjs.map +1 -7
  172. package/build-module/image-editor/core/math/rotation.mjs +21 -10
  173. package/build-module/image-editor/core/math/rotation.mjs.map +1 -7
  174. package/build-module/image-editor/core/math/sanitize.mjs +116 -52
  175. package/build-module/image-editor/core/math/sanitize.mjs.map +1 -7
  176. package/build-module/image-editor/core/setter-helpers.mjs +52 -35
  177. package/build-module/image-editor/core/setter-helpers.mjs.map +1 -7
  178. package/build-module/image-editor/core/source-region.mjs +210 -160
  179. package/build-module/image-editor/core/source-region.mjs.map +1 -7
  180. package/build-module/image-editor/core/state.mjs +271 -243
  181. package/build-module/image-editor/core/state.mjs.map +1 -7
  182. package/build-module/image-editor/core/stencil-math.mjs +185 -178
  183. package/build-module/image-editor/core/stencil-math.mjs.map +1 -7
  184. package/build-module/image-editor/core/transform-style.mjs +34 -23
  185. package/build-module/image-editor/core/transform-style.mjs.map +1 -7
  186. package/build-module/image-editor/core/transforms/pipeline.mjs +29 -11
  187. package/build-module/image-editor/core/transforms/pipeline.mjs.map +1 -7
  188. package/build-module/image-editor/core/types.mjs +0 -1
  189. package/build-module/image-editor/core/viewport-state.mjs +26 -20
  190. package/build-module/image-editor/core/viewport-state.mjs.map +1 -7
  191. package/build-module/image-editor/index.mjs +3 -38
  192. package/build-module/image-editor/react/components/cropper-provider.mjs +38 -21
  193. package/build-module/image-editor/react/components/cropper-provider.mjs.map +1 -7
  194. package/build-module/image-editor/react/components/cropper.mjs +550 -696
  195. package/build-module/image-editor/react/components/cropper.mjs.map +1 -7
  196. package/build-module/image-editor/react/components/index.mjs +1 -7
  197. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +130 -135
  198. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +1 -7
  199. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +24 -35
  200. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +1 -7
  201. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +54 -64
  202. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +1 -7
  203. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +355 -407
  204. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +1 -7
  205. package/build-module/image-editor/react/components/viewport-provider.mjs +15 -22
  206. package/build-module/image-editor/react/components/viewport-provider.mjs.map +1 -7
  207. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +72 -43
  208. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +1 -7
  209. package/build-module/image-editor/react/hooks/index.mjs +2 -7
  210. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +83 -119
  211. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +1 -7
  212. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +75 -0
  213. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +1 -0
  214. package/build-module/image-editor/react/hooks/use-interaction.mjs +175 -183
  215. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +1 -7
  216. package/build-module/image-editor/react/hooks/use-transform-style.mjs +15 -9
  217. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +1 -7
  218. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +32 -26
  219. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +1 -7
  220. package/build-module/image-editor/react/visually-hidden-style.mjs +17 -14
  221. package/build-module/image-editor/react/visually-hidden-style.mjs.map +1 -7
  222. package/build-module/index.mjs +3 -10
  223. package/build-module/lock-unlock.mjs +5 -10
  224. package/build-module/lock-unlock.mjs.map +1 -7
  225. package/build-module/private-apis.mjs +8 -9
  226. package/build-module/private-apis.mjs.map +1 -7
  227. package/build-module/state/aspect-ratio-presets.mjs +48 -0
  228. package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
  229. package/build-module/state/composite-reducer.mjs +114 -75
  230. package/build-module/state/composite-reducer.mjs.map +1 -7
  231. package/build-module/state/index.mjs +5 -25
  232. package/build-module/state/media-editor-state-provider.mjs +29 -24
  233. package/build-module/state/media-editor-state-provider.mjs.map +1 -7
  234. package/build-module/state/types.mjs +8 -7
  235. package/build-module/state/types.mjs.map +1 -7
  236. package/build-module/state/use-media-editor-state.mjs +256 -273
  237. package/build-module/state/use-media-editor-state.mjs.map +1 -7
  238. package/build-module/store/actions.mjs +12 -19
  239. package/build-module/store/actions.mjs.map +1 -7
  240. package/build-module/store/constants.mjs +4 -5
  241. package/build-module/store/constants.mjs.map +1 -7
  242. package/build-module/store/index.mjs +8 -9
  243. package/build-module/store/index.mjs.map +1 -7
  244. package/build-module/store/reducer.mjs +23 -26
  245. package/build-module/store/reducer.mjs.map +1 -7
  246. package/build-module/store/selectors.mjs +8 -13
  247. package/build-module/store/selectors.mjs.map +1 -7
  248. package/build-module/utils/get-media-type.mjs +14 -17
  249. package/build-module/utils/get-media-type.mjs.map +1 -7
  250. package/build-module/utils/index.mjs +1 -6
  251. package/build-style/style-rtl.css +41 -4
  252. package/build-style/style.css +41 -4
  253. package/build-types/components/media-editor/index.d.ts +6 -1
  254. package/build-types/components/media-editor/index.d.ts.map +1 -1
  255. package/build-types/components/media-editor/use-crop-options.d.ts +0 -1
  256. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  257. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  258. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  259. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  260. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  261. package/build-types/components/media-editor-modal/build-modifiers.d.ts +6 -5
  262. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -1
  263. package/build-types/components/media-editor-modal/index.d.ts +7 -2
  264. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  265. package/build-types/components/media-editor-provider/index.d.ts +7 -1
  266. package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
  267. package/build-types/components/media-form/index.d.ts +5 -2
  268. package/build-types/components/media-form/index.d.ts.map +1 -1
  269. package/build-types/components/media-preview/index.d.ts.map +1 -1
  270. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  271. package/build-types/image-editor/core/constants.d.ts +0 -1
  272. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  273. package/build-types/image-editor/core/index.d.ts +1 -1
  274. package/build-types/image-editor/core/index.d.ts.map +1 -1
  275. package/build-types/image-editor/core/setter-helpers.d.ts +1 -1
  276. package/build-types/image-editor/core/types.d.ts +1 -1
  277. package/build-types/image-editor/index.d.ts +7 -6
  278. package/build-types/image-editor/index.d.ts.map +1 -1
  279. package/build-types/image-editor/react/components/cropper-provider.d.ts +2 -2
  280. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  281. package/build-types/image-editor/react/components/cropper.d.ts +5 -14
  282. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  283. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +2 -2
  284. package/build-types/image-editor/react/hooks/index.d.ts +2 -2
  285. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -1
  286. package/build-types/image-editor/react/hooks/{use-cropper-reducer.d.ts → use-cropper-controller.d.ts} +12 -12
  287. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +1 -0
  288. package/build-types/state/aspect-ratio-presets.d.ts +7 -0
  289. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
  290. package/build-types/state/composite-reducer.d.ts +2 -2
  291. package/build-types/state/composite-reducer.d.ts.map +1 -1
  292. package/build-types/state/index.d.ts +2 -1
  293. package/build-types/state/index.d.ts.map +1 -1
  294. package/build-types/state/types.d.ts +36 -6
  295. package/build-types/state/types.d.ts.map +1 -1
  296. package/build-types/state/use-media-editor-state.d.ts +16 -5
  297. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  298. package/package.json +35 -24
  299. package/src/components/media-editor/index.tsx +226 -183
  300. package/src/components/media-editor/style.scss +19 -0
  301. package/src/components/media-editor/use-crop-options.ts +5 -4
  302. package/src/components/media-editor/use-save-media-editor.ts +2 -6
  303. package/src/components/media-editor-canvas/index.tsx +18 -28
  304. package/src/components/media-editor-crop-panel/index.tsx +17 -9
  305. package/src/components/media-editor-image-controls/index.tsx +4 -2
  306. package/src/components/media-editor-image-controls/style.scss +1 -1
  307. package/src/components/media-editor-modal/build-modifiers.ts +13 -7
  308. package/src/components/media-editor-modal/index.tsx +8 -1
  309. package/src/components/media-editor-modal/style.scss +1 -1
  310. package/src/components/media-editor-provider/index.tsx +8 -1
  311. package/src/components/media-form/index.tsx +48 -42
  312. package/src/components/media-preview/index.tsx +68 -25
  313. package/src/components/media-preview/style.scss +16 -2
  314. package/src/components/rotation-ruler/style.scss +6 -2
  315. package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
  316. package/src/image-editor/README.md +8 -8
  317. package/src/image-editor/core/constants.ts +0 -13
  318. package/src/image-editor/core/index.ts +1 -5
  319. package/src/image-editor/core/setter-helpers.ts +1 -1
  320. package/src/image-editor/core/types.ts +1 -1
  321. package/src/image-editor/docs/architecture.md +5 -1
  322. package/src/image-editor/docs/recipes.md +3 -3
  323. package/src/image-editor/index.ts +7 -16
  324. package/src/image-editor/react/components/cropper-provider.tsx +5 -5
  325. package/src/image-editor/react/components/cropper.tsx +20 -42
  326. package/src/image-editor/react/hooks/build-cropper-setters.ts +2 -2
  327. package/src/image-editor/react/hooks/index.ts +2 -2
  328. package/src/image-editor/react/hooks/{use-cropper-reducer.ts → use-cropper-controller.ts} +11 -11
  329. package/src/state/aspect-ratio-presets.ts +18 -0
  330. package/src/state/composite-reducer.ts +26 -13
  331. package/src/state/index.ts +3 -0
  332. package/src/state/types.ts +39 -11
  333. package/src/state/use-media-editor-state.ts +53 -16
  334. package/build/image-editor/core/index.cjs.map +0 -7
  335. package/build/image-editor/core/types.cjs.map +0 -7
  336. package/build/image-editor/index.cjs.map +0 -7
  337. package/build/image-editor/react/components/index.cjs.map +0 -7
  338. package/build/image-editor/react/hooks/index.cjs.map +0 -7
  339. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
  340. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
  341. package/build/index.cjs.map +0 -7
  342. package/build/state/index.cjs.map +0 -7
  343. package/build/utils/index.cjs.map +0 -7
  344. package/build-module/image-editor/core/index.mjs.map +0 -7
  345. package/build-module/image-editor/core/types.mjs.map +0 -7
  346. package/build-module/image-editor/index.mjs.map +0 -7
  347. package/build-module/image-editor/react/components/index.mjs.map +0 -7
  348. package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
  349. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
  350. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
  351. package/build-module/index.mjs.map +0 -7
  352. package/build-module/state/index.mjs.map +0 -7
  353. package/build-module/utils/index.mjs.map +0 -7
  354. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
  355. package/global.d.ts +0 -5
  356. package/src/components/media-editor/test/restore-original.browser.test.tsx +0 -227
  357. package/src/components/media-editor/test/use-crop-options.jsdom.test.tsx +0 -106
  358. package/src/components/media-editor-crop-panel/test/index.jsdom.test.tsx +0 -72
  359. package/src/components/media-editor-image-controls/test/index.jsdom.test.tsx +0 -186
  360. package/src/components/media-editor-modal/test/build-modifiers.test.ts +0 -359
  361. package/src/components/media-editor-modal/test/index.jsdom.test.tsx +0 -182
  362. package/src/components/rotation-ruler/stories/index.story.tsx +0 -43
  363. package/src/components/rotation-ruler/test/index.jsdom.test.tsx +0 -140
  364. package/src/image-editor/core/export/test/canvas-renderer.jsdom.test.ts +0 -823
  365. package/src/image-editor/core/math/test/sanitize.ts +0 -242
  366. package/src/image-editor/core/test/camera.ts +0 -1218
  367. package/src/image-editor/core/test/interaction-controller.ts +0 -1299
  368. package/src/image-editor/core/test/preview-export-parity.ts +0 -249
  369. package/src/image-editor/core/test/render-camera-bridge.ts +0 -349
  370. package/src/image-editor/core/test/state.ts +0 -876
  371. package/src/image-editor/core/test/stencil-math.ts +0 -665
  372. package/src/image-editor/core/transforms/test/pipeline.ts +0 -267
  373. package/src/image-editor/react/components/stencils/test/rectangle-stencil.browser.test.tsx +0 -438
  374. package/src/image-editor/react/components/test/cropper.browser.test.tsx +0 -1462
  375. package/src/image-editor/react/hooks/test/use-aria-announcer.jsdom.test.ts +0 -491
  376. package/src/image-editor/react/hooks/test/use-cropper-reducer.jsdom.test.ts +0 -1049
  377. package/src/image-editor/react/hooks/test/use-interaction.jsdom.test.ts +0 -213
  378. package/src/image-editor/react/hooks/test/use-transform-style.jsdom.test.ts +0 -140
  379. package/src/image-editor/stories/rectangle-crop.story.tsx +0 -1073
  380. package/src/image-editor/stories/style.module.css +0 -65
  381. package/src/state/test/use-media-editor-state.browser.test.tsx +0 -79
  382. package/src/state/test/use-media-editor-state.jsdom.test.ts +0 -386
  383. package/src/store/test/reducer.ts +0 -64
  384. package/tsconfig.build.json +0 -26
  385. package/tsconfig.build.tsbuildinfo +0 -1
  386. package/tsconfig.json +0 -37
@@ -1,359 +0,0 @@
1
- /**
2
- * buildModifiers ↔ Export-camera parity.
3
- *
4
- * WHAT THIS TEST GUARANTEES
5
- *
6
- * "What the user framed in the stencil is what the server crops from the
7
- * source." The cropper shows the user a live preview via the *export
8
- * camera* (`createExportCamera`); the server receives a `modifiers` array
9
- * from `buildModifiers` and applies them sequentially in the order
10
- * `[flip, rotate, crop]` (Core's `WP_REST_Attachments_Controller
11
- * ::edit_media_item`). Both paths must land on the same source pixel for
12
- * the same spot in the output, otherwise the saved image drifts from
13
- * what the user framed.
14
- *
15
- * This test asserts that invariant holds for every combination of
16
- * rotation, zoom, pan, flip, and crop rect the cropper can produce.
17
- *
18
- * STRATEGY
19
- *
20
- * For each cropper state and each probe point (u, v) ∈ [0, 1]² inside
21
- * the cropped output:
22
- *
23
- * 1. `exportSourcePixel` — inverts the export-camera matrix to find
24
- * the source pixel the cropper draws at (u, v). Ground truth:
25
- * it's literally what the user sees on screen.
26
- * 2. `serverSourcePixel` — simulates the Core pipeline
27
- * (`flip → rotate → crop`) in reverse to find the source pixel the
28
- * server would place at (u, v).
29
- * 3. Assert both answers agree to within 1 source pixel (float slop).
30
- *
31
- * A wrong crop rect, frame, or rotation sign makes the two paths
32
- * diverge and pinpoints the offending (state, probe) pair.
33
- *
34
- * ORDER / SIGN NOTES
35
- *
36
- * The cropper's export camera composes the source-to-screen chain as
37
- * `flip · R(θ)` on the (centered) source — rotate first, then flip.
38
- * Core's `modifiers` pipeline applies `flip` first, then `R(θ')`. For
39
- * these two chains to land on the same pixel, when exactly one flip
40
- * axis is set we must send `θ' = -θ` (since `flip_h · R(θ) = R(-θ) ·
41
- * flip_h`). Both-or-neither flips leave `θ' = θ` because `flip_h · flip_v
42
- * = -I` commutes with rotation.
43
- *
44
- * MAINTENANCE NOTES
45
- *
46
- * - If you change `buildModifiers`, this test is the primary safety net.
47
- * Run it after any edit to that file or to `createExportCamera`.
48
- * - If Core's pipeline operation order ever changes, update
49
- * `serverSourcePixel` to match — it mirrors the server exactly.
50
- * - Adding a new cropper operation (e.g. skew) means: extend
51
- * `CropperState`, teach `buildModifiers` to emit it, extend
52
- * `serverSourcePixel` to undo it, and add values to the grid in
53
- * `buildRows`. The probes don't need to change.
54
- */
55
-
56
- import { describe, expect, it } from 'vitest';
57
- import { mat2d, vec2 } from 'gl-matrix';
58
- import { buildModifiers } from '../build-modifiers';
59
- import type { Modifier } from '../build-modifiers';
60
- import {
61
- createExportCamera,
62
- getRotatedBBox,
63
- } from '../../../image-editor/core/camera';
64
- import { DEFAULT_STATE } from '../../../image-editor/core/constants';
65
- import type { CropperState, Size } from '../../../image-editor/core/types';
66
-
67
- const IMAGE: Size = { width: 1600, height: 900 };
68
-
69
- function makeState( overrides: Partial< CropperState > = {} ): CropperState {
70
- return {
71
- ...DEFAULT_STATE,
72
- image: {
73
- src: 'test.jpg',
74
- naturalWidth: IMAGE.width,
75
- naturalHeight: IMAGE.height,
76
- },
77
- ...overrides,
78
- };
79
- }
80
-
81
- /**
82
- * Source pixel the cropper draws at output position (u, v). Inverts the
83
- * export-camera matrix — the same one the preview uses — so whatever the
84
- * user sees on-screen is exactly what this returns.
85
- *
86
- * @param state Cropper state (rotation/zoom/pan/flip/cropRect).
87
- * @param imageSize Natural dimensions of the source image.
88
- * @param outputSize Output canvas dimensions the camera renders into.
89
- * @param u Horizontal probe in [0, 1] across the output.
90
- * @param v Vertical probe in [0, 1] across the output.
91
- */
92
- function exportSourcePixel(
93
- state: CropperState,
94
- imageSize: Size,
95
- outputSize: Size,
96
- u: number,
97
- v: number
98
- ): { x: number; y: number } {
99
- const camera = createExportCamera( state, imageSize, outputSize );
100
- const inv = mat2d.create();
101
- mat2d.invert( inv, camera );
102
- const out = vec2.create();
103
- vec2.transformMat2d(
104
- out,
105
- [ u * outputSize.width, v * outputSize.height ],
106
- inv
107
- );
108
- return { x: out[ 0 ], y: out[ 1 ] };
109
- }
110
-
111
- /**
112
- * Extract the pieces of the server pipeline we need to simulate from a
113
- * modifier array. `flip` and `rotate` may be absent (identity-pruned),
114
- * `crop` may also be absent when the full-frame is framed; in that case
115
- * the output canvas equals the full rotated AABB.
116
- *
117
- * @param modifiers Ordered modifier array as emitted by `buildModifiers`.
118
- */
119
- function readModifiers( modifiers: Modifier[] ): {
120
- flip: { horizontal: boolean; vertical: boolean };
121
- rotation: number;
122
- crop: { left: number; top: number; width: number; height: number } | null;
123
- } {
124
- const flip = { horizontal: false, vertical: false };
125
- let rotation = 0;
126
- let crop: {
127
- left: number;
128
- top: number;
129
- width: number;
130
- height: number;
131
- } | null = null;
132
-
133
- for ( const m of modifiers ) {
134
- if ( m.type === 'flip' ) {
135
- flip.horizontal = m.args.flip.horizontal;
136
- flip.vertical = m.args.flip.vertical;
137
- } else if ( m.type === 'rotate' ) {
138
- rotation = m.args.angle;
139
- } else if ( m.type === 'crop' ) {
140
- crop = {
141
- left: m.args.left,
142
- top: m.args.top,
143
- width: m.args.width,
144
- height: m.args.height,
145
- };
146
- }
147
- }
148
-
149
- return { flip, rotation, crop };
150
- }
151
-
152
- /**
153
- * Source pixel the server lands on for output point (u, v). Simulates
154
- * Core's `[flip, rotate, crop]` pipeline in reverse:
155
- * 1. Output point o = (u · outW, v · outH).
156
- * 2. Canvas point c = o + (cropX, cropY) in the post-rotate full AABB.
157
- * 3. Undo rotation about the source center to reach the flipped frame.
158
- * 4. Undo flip about the source center.
159
- *
160
- * @param modifiers Ordered modifier array the client sends.
161
- * @param imageSize Natural dimensions of the source image.
162
- * @param u Horizontal probe in [0, 1] across the output.
163
- * @param v Vertical probe in [0, 1] across the output.
164
- */
165
- function serverSourcePixel(
166
- modifiers: Modifier[],
167
- imageSize: Size,
168
- u: number,
169
- v: number
170
- ): { x: number; y: number } {
171
- const { flip, rotation, crop } = readModifiers( modifiers );
172
-
173
- const fullBBox = getRotatedBBox(
174
- imageSize.width,
175
- imageSize.height,
176
- rotation
177
- );
178
-
179
- // Percent → pixels in the full-AABB frame. When crop is absent the
180
- // output canvas is the full AABB itself.
181
- const cropW = crop ? ( crop.width * fullBBox.width ) / 100 : fullBBox.width;
182
- const cropH = crop
183
- ? ( crop.height * fullBBox.height ) / 100
184
- : fullBBox.height;
185
- const cropX = crop ? ( crop.left * fullBBox.width ) / 100 : 0;
186
- const cropY = crop ? ( crop.top * fullBBox.height ) / 100 : 0;
187
-
188
- // Undo crop translation.
189
- const cx = u * cropW + cropX;
190
- const cy = v * cropH + cropY;
191
-
192
- // Undo rotation about source center. Core applies rotation to the
193
- // flipped source, so inverting rotation brings us back to the flipped
194
- // frame (source center at full-AABB center).
195
- const rad = ( rotation * Math.PI ) / 180;
196
- const cos = Math.cos( rad );
197
- const sin = Math.sin( rad );
198
- const dx = cx - fullBBox.width / 2;
199
- const dy = cy - fullBBox.height / 2;
200
- // gl-matrix mat2d.rotate: (x, y) → (x·cos - y·sin, x·sin + y·cos).
201
- // Inverse is the transpose: (x, y) → (x·cos + y·sin, -x·sin + y·cos).
202
- let fx = dx * cos + dy * sin + imageSize.width / 2;
203
- let fy = -dx * sin + dy * cos + imageSize.height / 2;
204
-
205
- // Undo flip about source center (flip is its own inverse).
206
- if ( flip.horizontal ) {
207
- fx = imageSize.width - fx;
208
- }
209
- if ( flip.vertical ) {
210
- fy = imageSize.height - fy;
211
- }
212
-
213
- return { x: fx, y: fy };
214
- }
215
-
216
- // Seven probe points — corners catch offset/scale drift, center catches
217
- // uniform bugs, two asymmetric interior points catch cross-axis bugs
218
- // that a center probe would miss.
219
- const PROBES: { label: string; u: number; v: number }[] = [
220
- { label: 'top-left', u: 0, v: 0 },
221
- { label: 'top-right', u: 1, v: 0 },
222
- { label: 'bottom-right', u: 1, v: 1 },
223
- { label: 'bottom-left', u: 0, v: 1 },
224
- { label: 'center', u: 0.5, v: 0.5 },
225
- { label: 'interior-1', u: 0.3, v: 0.7 },
226
- { label: 'interior-2', u: 0.8, v: 0.25 },
227
- ];
228
-
229
- interface ParityRow {
230
- label: string;
231
- state: CropperState;
232
- probeLabel: string;
233
- u: number;
234
- v: number;
235
- }
236
-
237
- function buildRows(): ParityRow[] {
238
- const rotations = [ 0, 15, 45, 60, 90, 135, 201, 270 ];
239
- const zooms = [ 1, 1.5, 2.5 ];
240
- const pans = [
241
- { x: 0, y: 0 },
242
- { x: 0.08, y: -0.05 },
243
- { x: -0.1, y: 0.12 },
244
- ];
245
- const flips = [
246
- { horizontal: false, vertical: false },
247
- { horizontal: true, vertical: false },
248
- { horizontal: false, vertical: true },
249
- { horizontal: true, vertical: true },
250
- ];
251
- const cropRects = [
252
- { label: 'full', rect: { x: 0, y: 0, width: 1, height: 1 } },
253
- {
254
- label: 'centered',
255
- rect: { x: 0.25, y: 0.25, width: 0.5, height: 0.5 },
256
- },
257
- {
258
- label: 'off-center',
259
- rect: { x: 0.1, y: 0.2, width: 0.45, height: 0.55 },
260
- },
261
- ];
262
-
263
- const rows: ParityRow[] = [];
264
- for ( const rotation of rotations ) {
265
- for ( const zoom of zooms ) {
266
- for ( const pan of pans ) {
267
- for ( const flip of flips ) {
268
- for ( const { label: cropLabel, rect } of cropRects ) {
269
- const flipLabel = `${ flip.horizontal ? 'H' : '-' }${
270
- flip.vertical ? 'V' : '-'
271
- }`;
272
- const stateLabel = `rot=${ rotation } zoom=${ zoom } pan=(${ pan.x },${ pan.y }) flip=${ flipLabel } crop=${ cropLabel }`;
273
- const state = makeState( {
274
- rotation,
275
- zoom,
276
- pan,
277
- flip,
278
- cropRect: rect,
279
- } );
280
- for ( const { label: probeLabel, u, v } of PROBES ) {
281
- rows.push( {
282
- label: `${ stateLabel } probe=${ probeLabel }`,
283
- state,
284
- probeLabel,
285
- u,
286
- v,
287
- } );
288
- }
289
- }
290
- }
291
- }
292
- }
293
- }
294
- const subOneZoomState = makeState( {
295
- rotation: 19,
296
- zoom: 0.98,
297
- cropRect: { x: 0.48, y: 0, width: 0.04, height: 1 },
298
- } );
299
- for ( const { label: probeLabel, u, v } of PROBES ) {
300
- rows.push( {
301
- label: `fine-rotation sub-1 zoom probe=${ probeLabel }`,
302
- state: subOneZoomState,
303
- probeLabel,
304
- u,
305
- v,
306
- } );
307
- }
308
- return rows;
309
- }
310
-
311
- /**
312
- * Output size the server would produce, computed from the modifier list.
313
- * With a crop: the crop's pixel dims in the full-AABB frame. Without a
314
- * crop: the full rotated AABB.
315
- *
316
- * @param modifiers Modifier array the server will apply.
317
- * @param imageSize Natural dimensions of the source image.
318
- */
319
- function outputSizeFor( modifiers: Modifier[], imageSize: Size ): Size {
320
- const { rotation, crop } = readModifiers( modifiers );
321
- const full = getRotatedBBox( imageSize.width, imageSize.height, rotation );
322
- if ( ! crop ) {
323
- return { width: full.width, height: full.height };
324
- }
325
- return {
326
- width: ( crop.width * full.width ) / 100,
327
- height: ( crop.height * full.height ) / 100,
328
- };
329
- }
330
-
331
- describe( 'buildModifiers ↔ Export-camera parity', () => {
332
- const rows = buildRows();
333
-
334
- for ( const { label, state, u, v } of rows ) {
335
- it( label, () => {
336
- const modifiers = buildModifiers( state, IMAGE );
337
-
338
- // Output canvas is whatever the server would emit: the crop rect
339
- // if present, otherwise the full rotated AABB. This makes (u, v)
340
- // map to the same *output* pixel on both paths.
341
- const outputSize = outputSizeFor( modifiers, IMAGE );
342
-
343
- const exported = exportSourcePixel(
344
- state,
345
- IMAGE,
346
- outputSize,
347
- u,
348
- v
349
- );
350
- const server = serverSourcePixel( modifiers, IMAGE, u, v );
351
-
352
- // Tolerance of 1 source pixel. The two paths compose rotations
353
- // and scales in different orders, so sub-pixel disagreement is
354
- // expected from floating-point. Anything larger is a real bug.
355
- expect( server.x ).toBeCloseTo( exported.x, 0 );
356
- expect( server.y ).toBeCloseTo( exported.y, 0 );
357
- } );
358
- }
359
- } );
@@ -1,182 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
2
- import { fireEvent, render, screen } from '@testing-library/react';
3
- import type { ReactNode } from 'react';
4
- import { useDispatch, useSelect } from '@wordpress/data';
5
- import { store as noticesStore } from '@wordpress/notices';
6
- import { MediaEditorModal } from '../index';
7
-
8
- let mockSaveResult: {
9
- id: number;
10
- url: string;
11
- media: { id: number; source_url: string };
12
- previous?: { id: number; url: string };
13
- } = {
14
- id: 11,
15
- url: 'edited.jpg',
16
- media: { id: 11, source_url: 'edited.jpg' },
17
- previous: {
18
- id: 10,
19
- url: 'original.jpg',
20
- },
21
- };
22
- const mockOnUpdate = vi.fn();
23
- let mockOnUndo: ( () => void ) | undefined;
24
- const mockOnClose = vi.fn();
25
- const mockCloseMediaEditorModal = vi.fn();
26
- const mockCreateSuccessNotice = vi.fn();
27
-
28
- vi.mock(
29
- import( '@wordpress/data' ),
30
- () =>
31
- ( {
32
- useDispatch: vi.fn(),
33
- useSelect: vi.fn(),
34
- } ) as unknown as typeof import( '@wordpress/data' )
35
- );
36
-
37
- vi.mock(
38
- import( '@wordpress/components' ),
39
- () =>
40
- ( {
41
- Modal: ( { children }: { children: ReactNode } ) => children,
42
- } ) as unknown as typeof import( '@wordpress/components' )
43
- );
44
-
45
- vi.mock(
46
- import( '@wordpress/keyboard-shortcuts' ),
47
- () =>
48
- ( {
49
- ShortcutProvider: ( { children }: { children: ReactNode } ) =>
50
- children,
51
- } ) as unknown as typeof import( '@wordpress/keyboard-shortcuts' )
52
- );
53
-
54
- vi.mock(
55
- import( '@wordpress/notices' ),
56
- () =>
57
- ( {
58
- store: { name: 'notices' },
59
- } ) as unknown as typeof import( '@wordpress/notices' )
60
- );
61
-
62
- vi.mock(
63
- import( '../../../store' ),
64
- () =>
65
- ( {
66
- store: { name: 'media-editor' },
67
- } ) as unknown as typeof import( '../../../store' )
68
- );
69
-
70
- vi.mock( import( '../../media-editor' ), async () => {
71
- const { createElement } =
72
- await vi.importActual< typeof import( '@wordpress/element' ) >(
73
- '@wordpress/element'
74
- );
75
-
76
- return {
77
- default: vi.fn( ( props ) =>
78
- createElement(
79
- 'button',
80
- { onClick: () => props.onSaved( mockSaveResult ) },
81
- 'Save result'
82
- )
83
- ),
84
- } as unknown as typeof import( '../../media-editor' );
85
- } );
86
-
87
- describe( 'MediaEditorModal', () => {
88
- beforeEach( () => {
89
- vi.clearAllMocks();
90
- mockOnUndo = undefined;
91
- mockSaveResult = {
92
- id: 11,
93
- url: 'edited.jpg',
94
- media: { id: 11, source_url: 'edited.jpg' },
95
- previous: {
96
- id: 10,
97
- url: 'original.jpg',
98
- },
99
- };
100
-
101
- ( useSelect as Mock ).mockImplementation( ( mapSelect ) =>
102
- mapSelect( () => ( {
103
- isOpen: () => true,
104
- getId: () => 10,
105
- getOnUpdate: () => mockOnUpdate,
106
- getOnUndo: () => mockOnUndo,
107
- getOnClose: () => mockOnClose,
108
- } ) )
109
- );
110
- ( useDispatch as Mock ).mockImplementation( ( store ) =>
111
- store === noticesStore
112
- ? { createSuccessNotice: mockCreateSuccessNotice }
113
- : { closeMediaEditorModal: mockCloseMediaEditorModal }
114
- );
115
- } );
116
-
117
- it( 'restores the previous attachment when no Undo callback is supplied', () => {
118
- render( <MediaEditorModal /> );
119
-
120
- fireEvent.click(
121
- screen.getByRole( 'button', { name: 'Save result' } )
122
- );
123
-
124
- expect( mockOnUpdate ).toHaveBeenCalledWith( {
125
- id: 11,
126
- url: 'edited.jpg',
127
- } );
128
- expect( mockCloseMediaEditorModal ).toHaveBeenCalled();
129
- expect( mockOnClose ).toHaveBeenCalled();
130
- expect( mockCreateSuccessNotice ).toHaveBeenCalledWith(
131
- 'Image edited.',
132
- expect.objectContaining( {
133
- type: 'snackbar',
134
- actions: [
135
- expect.objectContaining( {
136
- label: 'Undo',
137
- onClick: expect.any( Function ),
138
- } ),
139
- ],
140
- } )
141
- );
142
-
143
- const noticeOptions = mockCreateSuccessNotice.mock.calls[ 0 ][ 1 ];
144
- expect( noticeOptions ).not.toHaveProperty( 'context' );
145
-
146
- noticeOptions.actions[ 0 ].onClick();
147
-
148
- expect( mockOnUpdate ).toHaveBeenLastCalledWith( {
149
- id: 10,
150
- url: 'original.jpg',
151
- } );
152
- } );
153
-
154
- it( "uses the caller's Undo callback after saving an attachment change", () => {
155
- mockOnUndo = vi.fn();
156
- render( <MediaEditorModal /> );
157
-
158
- fireEvent.click(
159
- screen.getByRole( 'button', { name: 'Save result' } )
160
- );
161
- const noticeOptions = mockCreateSuccessNotice.mock.calls[ 0 ][ 1 ];
162
- noticeOptions.actions[ 0 ].onClick();
163
-
164
- expect( mockOnUndo ).toHaveBeenCalledTimes( 1 );
165
- expect( mockOnUpdate ).toHaveBeenCalledTimes( 1 );
166
- } );
167
-
168
- it( 'does not show the image edited snackbar for metadata-only saves', () => {
169
- mockSaveResult = {
170
- ...mockSaveResult,
171
- previous: undefined,
172
- };
173
-
174
- render( <MediaEditorModal /> );
175
-
176
- fireEvent.click(
177
- screen.getByRole( 'button', { name: 'Save result' } )
178
- );
179
-
180
- expect( mockCreateSuccessNotice ).not.toHaveBeenCalled();
181
- } );
182
- } );
@@ -1,43 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { useState } from '@wordpress/element';
3
- import { __ } from '@wordpress/i18n';
4
- import RotationRuler from '../index';
5
-
6
- const meta: Meta< typeof RotationRuler > = {
7
- id: 'mediaeditor-rotationruler',
8
- title: 'Editor/Media Editor/RotationRuler',
9
- component: RotationRuler,
10
- args: {
11
- label: __( 'Fine rotation' ),
12
- min: -45,
13
- max: 45,
14
- step: 1,
15
- pixelsPerStep: 6,
16
- disabled: false,
17
- },
18
- argTypes: {
19
- value: { control: false },
20
- onChange: { control: false },
21
- },
22
- };
23
- export default meta;
24
-
25
- type Story = StoryObj< typeof RotationRuler >;
26
-
27
- export const Default: Story = {
28
- render: ( args ) => {
29
- const [ value, setValue ] = useState( 0 );
30
- return (
31
- <div style={ { width: 360, color: '#1e1e1e' } }>
32
- <RotationRuler
33
- { ...args }
34
- value={ value }
35
- onChange={ setValue }
36
- />
37
- <p style={ { marginTop: 16 } }>
38
- { __( 'Current value:' ) } { value }°
39
- </p>
40
- </div>
41
- );
42
- },
43
- };