@wordpress/media-editor 0.19.0 → 0.20.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 (142) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/media-editor/index.cjs +132 -50
  3. package/build/components/media-editor/index.cjs.map +2 -2
  4. package/build/components/media-editor/use-crop-options.cjs +1 -1
  5. package/build/components/media-editor/use-crop-options.cjs.map +2 -2
  6. package/build/components/media-editor/use-save-media-editor.cjs +36 -20
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +2 -2
  8. package/build/components/media-editor-canvas/index.cjs +8 -8
  9. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  10. package/build/components/media-editor-fine-rotation/index.cjs +1 -1
  11. package/build/components/media-editor-fine-rotation/index.cjs.map +2 -2
  12. package/build/components/media-editor-image-controls/index.cjs +46 -29
  13. package/build/components/media-editor-image-controls/index.cjs.map +2 -2
  14. package/build/components/media-editor-modal/index.cjs +17 -9
  15. package/build/components/media-editor-modal/index.cjs.map +2 -2
  16. package/build/hooks/use-crop-gesture-handlers.cjs +1 -1
  17. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  18. package/build/image-editor/core/interaction-controller.cjs +5 -0
  19. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  20. package/build/image-editor/react/components/cropper.cjs +3 -3
  21. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  22. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +1 -1
  23. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  24. package/build/image-editor/react/hooks/use-aria-announcer.cjs +3 -1
  25. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  26. package/build/image-editor/react/hooks/use-interaction.cjs +1 -1
  27. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  28. package/build/state/composite-reducer.cjs +3 -3
  29. package/build/state/composite-reducer.cjs.map +2 -2
  30. package/build/state/index.cjs.map +1 -1
  31. package/build/state/media-editor-state-provider.cjs +1 -6
  32. package/build/state/media-editor-state-provider.cjs.map +2 -2
  33. package/build/state/use-media-editor-state.cjs +38 -36
  34. package/build/state/use-media-editor-state.cjs.map +2 -2
  35. package/build/store/actions.cjs +2 -0
  36. package/build/store/actions.cjs.map +2 -2
  37. package/build/store/reducer.cjs +3 -1
  38. package/build/store/reducer.cjs.map +2 -2
  39. package/build/store/selectors.cjs +5 -0
  40. package/build/store/selectors.cjs.map +2 -2
  41. package/build-module/components/media-editor/index.mjs +145 -52
  42. package/build-module/components/media-editor/index.mjs.map +2 -2
  43. package/build-module/components/media-editor/use-crop-options.mjs +1 -1
  44. package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
  45. package/build-module/components/media-editor/use-save-media-editor.mjs +36 -20
  46. package/build-module/components/media-editor/use-save-media-editor.mjs.map +2 -2
  47. package/build-module/components/media-editor-canvas/index.mjs +8 -8
  48. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  49. package/build-module/components/media-editor-fine-rotation/index.mjs +1 -1
  50. package/build-module/components/media-editor-fine-rotation/index.mjs.map +2 -2
  51. package/build-module/components/media-editor-image-controls/index.mjs +47 -36
  52. package/build-module/components/media-editor-image-controls/index.mjs.map +2 -2
  53. package/build-module/components/media-editor-modal/index.mjs +17 -9
  54. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  55. package/build-module/hooks/use-crop-gesture-handlers.mjs +1 -1
  56. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  57. package/build-module/image-editor/core/interaction-controller.mjs +5 -0
  58. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  59. package/build-module/image-editor/react/components/cropper.mjs +3 -3
  60. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  61. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +1 -1
  62. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  63. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +3 -1
  64. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  65. package/build-module/image-editor/react/hooks/use-interaction.mjs +1 -1
  66. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  67. package/build-module/state/composite-reducer.mjs +3 -3
  68. package/build-module/state/composite-reducer.mjs.map +2 -2
  69. package/build-module/state/index.mjs.map +1 -1
  70. package/build-module/state/media-editor-state-provider.mjs +1 -6
  71. package/build-module/state/media-editor-state-provider.mjs.map +2 -2
  72. package/build-module/state/use-media-editor-state.mjs +38 -36
  73. package/build-module/state/use-media-editor-state.mjs.map +2 -2
  74. package/build-module/store/actions.mjs +2 -0
  75. package/build-module/store/actions.mjs.map +2 -2
  76. package/build-module/store/reducer.mjs +3 -1
  77. package/build-module/store/reducer.mjs.map +2 -2
  78. package/build-module/store/selectors.mjs +4 -0
  79. package/build-module/store/selectors.mjs.map +2 -2
  80. package/build-style/style-rtl.css +5 -5
  81. package/build-style/style.css +5 -5
  82. package/build-types/components/media-editor/index.d.ts +2 -2
  83. package/build-types/components/media-editor/index.d.ts.map +1 -1
  84. package/build-types/components/media-editor/use-save-media-editor.d.ts +15 -3
  85. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  86. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  87. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  88. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  89. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  90. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  91. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  92. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  93. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  94. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  95. package/build-types/state/composite-reducer.d.ts +5 -5
  96. package/build-types/state/composite-reducer.d.ts.map +1 -1
  97. package/build-types/state/index.d.ts +1 -1
  98. package/build-types/state/index.d.ts.map +1 -1
  99. package/build-types/state/media-editor-state-provider.d.ts +8 -16
  100. package/build-types/state/media-editor-state-provider.d.ts.map +1 -1
  101. package/build-types/state/use-media-editor-state.d.ts +37 -30
  102. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  103. package/build-types/store/actions.d.ts +9 -1
  104. package/build-types/store/actions.d.ts.map +1 -1
  105. package/build-types/store/reducer.d.ts +3 -0
  106. package/build-types/store/reducer.d.ts.map +1 -1
  107. package/build-types/store/selectors.d.ts +1 -0
  108. package/build-types/store/selectors.d.ts.map +1 -1
  109. package/package.json +27 -22
  110. package/src/components/media-editor/index.tsx +203 -59
  111. package/src/components/media-editor/test/restore-original.browser.test.tsx +227 -0
  112. package/src/components/media-editor/test/use-crop-options.jsdom.test.tsx +12 -10
  113. package/src/components/media-editor/use-crop-options.ts +1 -1
  114. package/src/components/media-editor/use-save-media-editor.ts +61 -20
  115. package/src/components/media-editor-canvas/index.tsx +7 -8
  116. package/src/components/media-editor-crop-panel/test/index.jsdom.test.tsx +2 -4
  117. package/src/components/media-editor-fine-rotation/index.tsx +1 -1
  118. package/src/components/media-editor-image-controls/index.tsx +41 -41
  119. package/src/components/media-editor-image-controls/test/index.jsdom.test.tsx +19 -13
  120. package/src/components/media-editor-modal/index.tsx +18 -10
  121. package/src/components/media-editor-modal/test/index.jsdom.test.tsx +18 -1
  122. package/src/hooks/use-crop-gesture-handlers.ts +3 -1
  123. package/src/image-editor/core/interaction-controller.ts +8 -0
  124. package/src/image-editor/core/test/interaction-controller.ts +45 -0
  125. package/src/image-editor/docs/architecture.md +6 -2
  126. package/src/image-editor/docs/recipes.md +8 -8
  127. package/src/image-editor/react/components/cropper.scss +5 -5
  128. package/src/image-editor/react/components/cropper.tsx +8 -3
  129. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +3 -1
  130. package/src/image-editor/react/components/test/cropper.browser.test.tsx +7 -5
  131. package/src/image-editor/react/hooks/use-aria-announcer.ts +3 -1
  132. package/src/image-editor/react/hooks/use-interaction.ts +3 -2
  133. package/src/state/composite-reducer.ts +6 -7
  134. package/src/state/index.ts +1 -1
  135. package/src/state/media-editor-state-provider.tsx +9 -22
  136. package/src/state/test/use-media-editor-state.browser.test.tsx +79 -0
  137. package/src/state/test/use-media-editor-state.jsdom.test.ts +126 -64
  138. package/src/state/use-media-editor-state.ts +79 -68
  139. package/src/store/actions.ts +9 -0
  140. package/src/store/reducer.ts +6 -1
  141. package/src/store/selectors.ts +4 -0
  142. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,14 +1,9 @@
1
1
  // packages/media-editor/src/components/media-editor-image-controls/index.tsx
2
- import {
3
- Button,
4
- DropdownMenu,
5
- MenuGroup,
6
- MenuItem
7
- } from "@wordpress/components";
2
+ import { Button } from "@wordpress/components";
3
+ import { Menu } from "@wordpress/ui";
8
4
  import { __ } from "@wordpress/i18n";
9
5
  import {
10
6
  aspectRatio as aspectRatioIcon,
11
- check,
12
7
  rotateLeft,
13
8
  rotateRight,
14
9
  flipHorizontal,
@@ -31,7 +26,7 @@ function MediaEditorImageControls({
31
26
  zoomFactor = DEFAULT_ZOOM_FACTOR,
32
27
  disabled = false
33
28
  }) {
34
- const { state, setFlip, snapRotate90, setZoom } = useMediaEditor();
29
+ const { state, setFlip, snapRotate90, setZoom } = useMediaEditor().cropper;
35
30
  const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = useCropOptions({ aspectRatioPresets });
36
31
  const hasAspectRatioControl = !withLabels && showAspectRatioControl;
37
32
  const minZoom = getMinZoom(state);
@@ -126,37 +121,53 @@ function MediaEditorImageControls({
126
121
  }
127
122
  )
128
123
  ] });
129
- const aspectRatioDropdown = hasAspectRatioControl ? /* @__PURE__ */ jsx(
130
- DropdownMenu,
131
- {
132
- icon: aspectRatioIcon,
133
- label: __("Aspect ratio"),
134
- popoverProps: { placement: "top" },
135
- toggleProps: { size: "compact", disabled },
136
- children: ({ onClose }) => /* @__PURE__ */ jsx(MenuGroup, { label: __("Aspect ratio"), children: aspectRatioOptions.map((preset) => {
137
- const value = preset.value.toString();
138
- const isSelected = value === aspectRatioValue;
139
- return /* @__PURE__ */ jsx(
140
- MenuItem,
124
+ const aspectRatioDropdown = hasAspectRatioControl ? /* @__PURE__ */ jsxs(Menu.Root, { children: [
125
+ /* @__PURE__ */ jsx(
126
+ Menu.Trigger,
127
+ {
128
+ disabled,
129
+ render: /* @__PURE__ */ jsx(
130
+ Button,
131
+ {
132
+ size: "compact",
133
+ icon: aspectRatioIcon,
134
+ label: __("Aspect ratio"),
135
+ accessibleWhenDisabled: true
136
+ }
137
+ )
138
+ }
139
+ ),
140
+ /* @__PURE__ */ jsx(
141
+ Menu.Popup,
142
+ {
143
+ positioner: /* @__PURE__ */ jsx(Menu.Positioner, { side: "top", align: "center" }),
144
+ children: /* @__PURE__ */ jsxs(
145
+ Menu.RadioGroup,
141
146
  {
142
- role: "menuitemradio",
143
- isSelected,
144
- icon: isSelected ? check : void 0,
145
- disabled,
146
- onClick: () => {
147
- if (disabled) {
148
- return;
147
+ value: aspectRatioValue,
148
+ onValueChange: (value) => {
149
+ if (!disabled) {
150
+ setAspectRatioValue(value);
149
151
  }
150
- setAspectRatioValue(value);
151
- onClose();
152
152
  },
153
- children: preset.label
154
- },
155
- value
156
- );
157
- }) })
158
- }
159
- ) : null;
153
+ children: [
154
+ /* @__PURE__ */ jsx(Menu.GroupLabel, { children: __("Aspect ratio") }),
155
+ aspectRatioOptions.map((preset) => /* @__PURE__ */ jsx(
156
+ Menu.RadioItem,
157
+ {
158
+ value: preset.value.toString(),
159
+ closeOnClick: true,
160
+ disabled,
161
+ children: /* @__PURE__ */ jsx(Menu.ItemLabel, { children: preset.label })
162
+ },
163
+ preset.value
164
+ ))
165
+ ]
166
+ }
167
+ )
168
+ }
169
+ )
170
+ ] }) : null;
160
171
  if (withLabels) {
161
172
  return /* @__PURE__ */ jsxs("div", { className: "media-editor-image-controls is-stacked", children: [
162
173
  /* @__PURE__ */ jsxs("div", { className: "media-editor-image-controls__transforms", children: [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor-image-controls/index.tsx"],
4
- "sourcesContent": ["import {\n\tButton,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\taspectRatio as aspectRatioIcon,\n\tcheck,\n\trotateLeft,\n\trotateRight,\n\tflipHorizontal,\n\tflipVertical,\n\tlineSolid,\n\tplus,\n} from '@wordpress/icons';\nimport { useMediaEditor } from '../../state';\nimport {\n\tMAX_ZOOM,\n\ttype AspectRatioPreset,\n} from '../../image-editor/core/constants';\nimport { getMinZoom } from '../../image-editor/core/containment';\nimport { useCropOptions } from '../media-editor/use-crop-options';\n\n/**\n * Default zoom factor per +/- click. Zooming is geometric, so a fixed\n * multiplier — rather than an additive step — makes each click feel like the\n * same amount of zoom at any level (an additive `+0.1` is a 10% jump at 1× but\n * a ~1% nudge at 10×). `1.2` is ~+20% per click. Overridable via the\n * `zoomFactor` prop.\n */\nexport const DEFAULT_ZOOM_FACTOR = 1.2;\n\nexport interface MediaEditorImageControlsProps {\n\t/**\n\t * When `true`, render rotate, flip and zoom as labelled groups — the Crop\n\t * panel layout used on wide viewports. When `false` (default), render a\n\t * single flat row of icon buttons — the footer layout used at narrower\n\t * widths.\n\t */\n\twithLabels?: boolean;\n\t/**\n\t * When `true`, include an aspect-ratio dropdown in the flat toolbar.\n\t * Omitted from the labelled panel layout because the Crop panel already\n\t * renders the full aspect-ratio select control.\n\t */\n\tshowAspectRatioControl?: boolean;\n\t/** Optional caller-supplied aspect-ratio presets. */\n\taspectRatioPresets?: AspectRatioPreset[];\n\t/**\n\t * Multiplier applied to the zoom per +/- click — zoom in multiplies by it,\n\t * zoom out divides by it. Must be greater than 1. Defaults to\n\t * `DEFAULT_ZOOM_FACTOR` (1.2).\n\t */\n\tzoomFactor?: number;\n\t/**\n\t * Disable every control. Set while the edit is saving, so the crop the\n\t * request was built from cannot change under it.\n\t */\n\tdisabled?: boolean;\n}\n\n/**\n * Image editing controls placed independently per viewport: on wide viewports\n * rotate/flip/zoom render inside the Crop panel (`withLabels`), and at narrower\n * widths they fall back into the footer toolbar (flat row), where the\n * aspect-ratio dropdown can also be shown.\n *\n * @param props\n * @param props.withLabels\n * @param props.showAspectRatioControl\n * @param props.aspectRatioPresets\n * @param props.zoomFactor\n * @param props.disabled\n */\nexport default function MediaEditorImageControls( {\n\twithLabels = false,\n\tshowAspectRatioControl = false,\n\taspectRatioPresets,\n\tzoomFactor = DEFAULT_ZOOM_FACTOR,\n\tdisabled = false,\n}: MediaEditorImageControlsProps ) {\n\tconst { state, setFlip, snapRotate90, setZoom } = useMediaEditor();\n\tconst { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } =\n\t\tuseCropOptions( { aspectRatioPresets } );\n\tconst hasAspectRatioControl = ! withLabels && showAspectRatioControl;\n\tconst minZoom = getMinZoom( state );\n\tconst zoomByFactor = ( factor: number ) => {\n\t\tsetZoom(\n\t\t\tMath.min( MAX_ZOOM, Math.max( minZoom, state.zoom * factor ) )\n\t\t);\n\t};\n\n\tconst rotateButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateLeft }\n\t\t\t\tlabel={ __( 'Rotate 90° counter-clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => snapRotate90( -1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateRight }\n\t\t\t\tlabel={ __( 'Rotate 90° clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => snapRotate90( 1 ) }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst flipButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipHorizontal }\n\t\t\t\tlabel={ __( 'Flip horizontal' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.horizontal }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: ! state.flip.horizontal,\n\t\t\t\t\t\tvertical: state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipVertical }\n\t\t\t\tlabel={ __( 'Flip vertical' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.vertical }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: state.flip.horizontal,\n\t\t\t\t\t\tvertical: ! state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst zoomButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ plus }\n\t\t\t\tlabel={ __( 'Zoom in' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled || state.zoom >= MAX_ZOOM }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => zoomByFactor( zoomFactor ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ lineSolid }\n\t\t\t\tlabel={ __( 'Zoom out' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled || state.zoom <= minZoom }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => zoomByFactor( 1 / zoomFactor ) }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst aspectRatioDropdown = hasAspectRatioControl ? (\n\t\t<DropdownMenu\n\t\t\ticon={ aspectRatioIcon }\n\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\tpopoverProps={ { placement: 'top' } }\n\t\t\ttoggleProps={ { size: 'compact', disabled } }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup label={ __( 'Aspect ratio' ) }>\n\t\t\t\t\t{ aspectRatioOptions.map( ( preset ) => {\n\t\t\t\t\t\tconst value = preset.value.toString();\n\t\t\t\t\t\tconst isSelected = value === aspectRatioValue;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\ticon={ isSelected ? check : undefined }\n\t\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tif ( disabled ) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetAspectRatioValue( value );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ preset.label }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t) : null;\n\n\tif ( withLabels ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-image-controls is-stacked\">\n\t\t\t\t<div className=\"media-editor-image-controls__transforms\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-label={ __( 'Rotate' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rotate' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t\t{ rotateButtons }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-label={ __( 'Flip' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Flip' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t\t{ flipButtons }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-label={ __( 'Zoom' ) }\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Zoom' ) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t{ zoomButtons }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"media-editor-image-controls\">\n\t\t\t{ rotateButtons }\n\t\t\t{ flipButtons }\n\t\t\t{ z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A,WAAU;AAAA,UACV,MAAK;AAAA,UACL,cAAa,GAAI,MAAO;AAAA,UAExB;AAAA;AAAA,cAAC;AAAA;AAAA,gBACA,WAAU;AAAA,gBACV,eAAY;AAAA,gBAEV,aAAI,MAAO;AAAA;AAAA,YACd;AAAA,YACA,oBAAC,SAAI,WAAU,wCACZ,uBACH;AAAA;AAAA;AAAA,MACD;AAAA,OACD;AAAA,EAEF;AAEA,SACC,qBAAC,SAAI,WAAU,+BACZ;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KACH;AAEF;",
4
+ "sourcesContent": ["import { Button } from '@wordpress/components';\n// eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of the new Menu, pending WordPress/gutenberg#76135.\nimport { Menu } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport {\n\taspectRatio as aspectRatioIcon,\n\trotateLeft,\n\trotateRight,\n\tflipHorizontal,\n\tflipVertical,\n\tlineSolid,\n\tplus,\n} from '@wordpress/icons';\nimport { useMediaEditor } from '../../state';\nimport {\n\tMAX_ZOOM,\n\ttype AspectRatioPreset,\n} from '../../image-editor/core/constants';\nimport { getMinZoom } from '../../image-editor/core/containment';\nimport { useCropOptions } from '../media-editor/use-crop-options';\n\n/**\n * Default zoom factor per +/- click. Zooming is geometric, so a fixed\n * multiplier — rather than an additive step — makes each click feel like the\n * same amount of zoom at any level (an additive `+0.1` is a 10% jump at 1× but\n * a ~1% nudge at 10×). `1.2` is ~+20% per click. Overridable via the\n * `zoomFactor` prop.\n */\nexport const DEFAULT_ZOOM_FACTOR = 1.2;\n\nexport interface MediaEditorImageControlsProps {\n\t/**\n\t * When `true`, render rotate, flip and zoom as labelled groups — the Crop\n\t * panel layout used on wide viewports. When `false` (default), render a\n\t * single flat row of icon buttons — the footer layout used at narrower\n\t * widths.\n\t */\n\twithLabels?: boolean;\n\t/**\n\t * When `true`, include an aspect-ratio dropdown in the flat toolbar.\n\t * Omitted from the labelled panel layout because the Crop panel already\n\t * renders the full aspect-ratio select control.\n\t */\n\tshowAspectRatioControl?: boolean;\n\t/** Optional caller-supplied aspect-ratio presets. */\n\taspectRatioPresets?: AspectRatioPreset[];\n\t/**\n\t * Multiplier applied to the zoom per +/- click — zoom in multiplies by it,\n\t * zoom out divides by it. Must be greater than 1. Defaults to\n\t * `DEFAULT_ZOOM_FACTOR` (1.2).\n\t */\n\tzoomFactor?: number;\n\t/**\n\t * Disable every control. Set while the edit is saving, so the crop the\n\t * request was built from cannot change under it.\n\t */\n\tdisabled?: boolean;\n}\n\n/**\n * Image editing controls placed independently per viewport: on wide viewports\n * rotate/flip/zoom render inside the Crop panel (`withLabels`), and at narrower\n * widths they fall back into the footer toolbar (flat row), where the\n * aspect-ratio dropdown can also be shown.\n *\n * @param props\n * @param props.withLabels\n * @param props.showAspectRatioControl\n * @param props.aspectRatioPresets\n * @param props.zoomFactor\n * @param props.disabled\n */\nexport default function MediaEditorImageControls( {\n\twithLabels = false,\n\tshowAspectRatioControl = false,\n\taspectRatioPresets,\n\tzoomFactor = DEFAULT_ZOOM_FACTOR,\n\tdisabled = false,\n}: MediaEditorImageControlsProps ) {\n\tconst { state, setFlip, snapRotate90, setZoom } = useMediaEditor().cropper;\n\tconst { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } =\n\t\tuseCropOptions( { aspectRatioPresets } );\n\tconst hasAspectRatioControl = ! withLabels && showAspectRatioControl;\n\tconst minZoom = getMinZoom( state );\n\tconst zoomByFactor = ( factor: number ) => {\n\t\tsetZoom(\n\t\t\tMath.min( MAX_ZOOM, Math.max( minZoom, state.zoom * factor ) )\n\t\t);\n\t};\n\n\tconst rotateButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateLeft }\n\t\t\t\tlabel={ __( 'Rotate 90° counter-clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => snapRotate90( -1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateRight }\n\t\t\t\tlabel={ __( 'Rotate 90° clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => snapRotate90( 1 ) }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst flipButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipHorizontal }\n\t\t\t\tlabel={ __( 'Flip horizontal' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.horizontal }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: ! state.flip.horizontal,\n\t\t\t\t\t\tvertical: state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipVertical }\n\t\t\t\tlabel={ __( 'Flip vertical' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.vertical }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: state.flip.horizontal,\n\t\t\t\t\t\tvertical: ! state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst zoomButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ plus }\n\t\t\t\tlabel={ __( 'Zoom in' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled || state.zoom >= MAX_ZOOM }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => zoomByFactor( zoomFactor ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ lineSolid }\n\t\t\t\tlabel={ __( 'Zoom out' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled || state.zoom <= minZoom }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => zoomByFactor( 1 / zoomFactor ) }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst aspectRatioDropdown = hasAspectRatioControl ? (\n\t\t<Menu.Root>\n\t\t\t<Menu.Trigger\n\t\t\t\tdisabled={ disabled }\n\t\t\t\trender={\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\ticon={ aspectRatioIcon }\n\t\t\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Menu.Popup\n\t\t\t\tpositioner={ <Menu.Positioner side=\"top\" align=\"center\" /> }\n\t\t\t>\n\t\t\t\t<Menu.RadioGroup\n\t\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\t\tonValueChange={ ( value ) => {\n\t\t\t\t\t\tif ( ! disabled ) {\n\t\t\t\t\t\t\tsetAspectRatioValue( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Menu.GroupLabel>{ __( 'Aspect ratio' ) }</Menu.GroupLabel>\n\t\t\t\t\t{ aspectRatioOptions.map( ( preset ) => (\n\t\t\t\t\t\t<Menu.RadioItem\n\t\t\t\t\t\t\tkey={ preset.value }\n\t\t\t\t\t\t\tvalue={ preset.value.toString() }\n\t\t\t\t\t\t\tcloseOnClick\n\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Menu.ItemLabel>{ preset.label }</Menu.ItemLabel>\n\t\t\t\t\t\t</Menu.RadioItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</Menu.RadioGroup>\n\t\t\t</Menu.Popup>\n\t\t</Menu.Root>\n\t) : null;\n\n\tif ( withLabels ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-image-controls is-stacked\">\n\t\t\t\t<div className=\"media-editor-image-controls__transforms\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-label={ __( 'Rotate' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rotate' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t\t{ rotateButtons }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-label={ __( 'Flip' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Flip' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t\t{ flipButtons }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-label={ __( 'Zoom' ) }\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Zoom' ) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t{ zoomButtons }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"media-editor-image-controls\">\n\t\t\t{ rotateButtons }\n\t\t\t{ flipButtons }\n\t\t\t{ zoomButtons }\n\t\t\t{ aspectRatioDropdown }\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";AAAA,SAAS,cAAc;AAEvB,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB;AAAA,EACC,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,sBAAsB;AAC/B;AAAA,EACC;AAAA,OAEM;AACP,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAwE7B,mBACC,KADD;AA/DK,IAAM,sBAAsB;AA4CpB,SAAR,yBAA2C;AAAA,EACjD,aAAa;AAAA,EACb,yBAAyB;AAAA,EACzB;AAAA,EACA,aAAa;AAAA,EACb,WAAW;AACZ,GAAmC;AAClC,QAAM,EAAE,OAAO,SAAS,cAAc,QAAQ,IAAI,eAAe,EAAE;AACnE,QAAM,EAAE,kBAAkB,qBAAqB,mBAAmB,IACjE,eAAgB,EAAE,mBAAmB,CAAE;AACxC,QAAM,wBAAwB,CAAE,cAAc;AAC9C,QAAM,UAAU,WAAY,KAAM;AAClC,QAAM,eAAe,CAAE,WAAoB;AAC1C;AAAA,MACC,KAAK,IAAK,UAAU,KAAK,IAAK,SAAS,MAAM,OAAO,MAAO,CAAE;AAAA,IAC9D;AAAA,EACD;AAEA,QAAM,gBACL,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,OAAQ,GAAI,8BAA+B;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YACL,cAAa,GAAI,QAAS;AAAA,YAE1B;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,WAAU;AAAA,kBACV,eAAY;AAAA,kBAEV,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA,cACA,oBAAC,SAAI,WAAU,wCACZ,yBACH;AAAA;AAAA;AAAA,QACD;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAK;AAAA,YACL,cAAa,GAAI,MAAO;AAAA,YAExB;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,WAAU;AAAA,kBACV,eAAY;AAAA,kBAEV,aAAI,MAAO;AAAA;AAAA,cACd;AAAA,cACA,oBAAC,SAAI,WAAU,wCACZ,uBACH;AAAA;AAAA;AAAA,QACD;AAAA,SACD;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,MAAK;AAAA,UACL,cAAa,GAAI,MAAO;AAAA,UAExB;AAAA;AAAA,cAAC;AAAA;AAAA,gBACA,WAAU;AAAA,gBACV,eAAY;AAAA,gBAEV,aAAI,MAAO;AAAA;AAAA,YACd;AAAA,YACA,oBAAC,SAAI,WAAU,wCACZ,uBACH;AAAA;AAAA;AAAA,MACD;AAAA,OACD;AAAA,EAEF;AAEA,SACC,qBAAC,SAAI,WAAU,+BACZ;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KACH;AAEF;",
6
6
  "names": []
7
7
  }
@@ -25,15 +25,19 @@ function MediaEditorModal({
25
25
  fields = [],
26
26
  aspectRatioPresets
27
27
  }) {
28
- const { isModalOpen, id, onUpdate, onClose } = useSelect((select) => {
29
- const { isOpen, getId, getOnUpdate, getOnClose } = select(mediaEditorStore);
30
- return {
31
- isModalOpen: isOpen(),
32
- id: getId(),
33
- onUpdate: getOnUpdate(),
34
- onClose: getOnClose()
35
- };
36
- }, []);
28
+ const { isModalOpen, id, onUpdate, onUndo, onClose } = useSelect(
29
+ (select) => {
30
+ const { isOpen, getId, getOnUpdate, getOnUndo, getOnClose } = select(mediaEditorStore);
31
+ return {
32
+ isModalOpen: isOpen(),
33
+ id: getId(),
34
+ onUpdate: getOnUpdate(),
35
+ onUndo: getOnUndo(),
36
+ onClose: getOnClose()
37
+ };
38
+ },
39
+ []
40
+ );
37
41
  const { closeMediaEditorModal } = useDispatch(mediaEditorStore);
38
42
  const { createSuccessNotice } = useDispatch(noticesStore);
39
43
  if (!isModalOpen || !id) {
@@ -73,6 +77,10 @@ function MediaEditorModal({
73
77
  {
74
78
  label: __("Undo"),
75
79
  onClick: () => {
80
+ if (onUndo) {
81
+ onUndo();
82
+ return;
83
+ }
76
84
  onUpdate({
77
85
  id: previous.id,
78
86
  url: previous.url
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor-modal/index.tsx"],
4
- "sourcesContent": ["import { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\n/**\n * The modal's footer chrome. The fine-rotation ruler and the image controls\n * both live under the canvas (in `media-editor__content`), never here, so the\n * footer has one layout at every width: History on the left, Cancel/Save on\n * the right.\n */\nfunction ModalFooter() {\n\treturn (\n\t\t<div\n\t\t\tclassName=\"media-editor-modal__footer\"\n\t\t\trole=\"region\"\n\t\t\taria-label={ __( 'Editor actions' ) }\n\t\t>\n\t\t\t<MediaEditor.HistoryActions />\n\t\t\t<MediaEditor.SaveActions />\n\t\t</div>\n\t);\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate, onClose } = useSelect( ( select ) => {\n\t\tconst { isOpen, getId, getOnUpdate, getOnClose } =\n\t\t\tselect( mediaEditorStore );\n\t\treturn {\n\t\t\tisModalOpen: isOpen(),\n\t\t\tid: getId(),\n\t\t\tonUpdate: getOnUpdate(),\n\t\t\tonClose: getOnClose(),\n\t\t};\n\t}, [] );\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\t// React synthetic events bubble through the React tree, not the DOM tree,\n\t// so a host `ShortcutProvider` higher up still receives keydown events\n\t// from inside this portaled modal. Stop propagation at the modal boundary\n\t// so host shortcuts (undo/redo, save, etc.) don't fire from within.\n\tconst stopKeyDownPropagation = (\n\t\tevent: ReactKeyboardEvent< HTMLDivElement >\n\t) => {\n\t\tevent.stopPropagation();\n\t};\n\n\tconst handleClose = () => {\n\t\tcloseMediaEditorModal();\n\t\tonClose?.();\n\t};\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\tonClose={ handleClose }\n\t\t\tonSaved={ ( { id: savedId, url, previous } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\thandleClose();\n\t\t\t\tif ( previous && savedId !== previous.id && onUpdate ) {\n\t\t\t\t\t// Intentionally unscoped: the modal is closing, so the\n\t\t\t\t\t// snackbar surfaces in the host editor (not the media\n\t\t\t\t\t// editor's `MEDIA_EDITOR_NOTICES_CONTEXT` region).\n\t\t\t\t\tcreateSuccessNotice( __( 'Image edited.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\tonUpdate( {\n\t\t\t\t\t\t\t\t\t\tid: previous.id,\n\t\t\t\t\t\t\t\t\t\turl: previous.url,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<ShortcutProvider\n\t\t\t\t\tclassName=\"media-editor-modal__shortcut-scope\"\n\t\t\t\t\tonKeyDown={ stopKeyDownPropagation }\n\t\t\t\t>\n\t\t\t\t\t<Modal\n\t\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\t\theaderActions={\n\t\t\t\t\t\t\t<MediaEditor.HeaderActions showCloseButton />\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<ModalFooter />\n\t\t\t\t\t</Modal>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default MediaEditorModal;\n"],
5
- "mappings": ";AAAA,SAAS,aAAa;AACtB,SAAS,aAAa,iBAAiB;AACvC,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,SAAS,oBAAoB;AAGtC,OAAO,iBAAiB;AAExB,SAAS,SAAS,wBAAwB;AA2BxC,SAKC,KALD;AAFF,SAAS,cAAc;AACtB,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,MAAK;AAAA,MACL,cAAa,GAAI,gBAAiB;AAAA,MAElC;AAAA,4BAAC,YAAY,gBAAZ,EAA2B;AAAA,QAC5B,oBAAC,YAAY,aAAZ,EAAwB;AAAA;AAAA;AAAA,EAC1B;AAEF;AAEO,SAAS,iBAAkB;AAAA,EACjC,SAAS,CAAC;AAAA,EACV;AACD,GAA2B;AAC1B,QAAM,EAAE,aAAa,IAAI,UAAU,QAAQ,IAAI,UAAW,CAAE,WAAY;AACvE,UAAM,EAAE,QAAQ,OAAO,aAAa,WAAW,IAC9C,OAAQ,gBAAiB;AAC1B,WAAO;AAAA,MACN,aAAa,OAAO;AAAA,MACpB,IAAI,MAAM;AAAA,MACV,UAAU,YAAY;AAAA,MACtB,SAAS,WAAW;AAAA,IACrB;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAChE,QAAM,EAAE,oBAAoB,IAAI,YAAa,YAAa;AAE1D,MAAK,CAAE,eAAe,CAAE,IAAK;AAC5B,WAAO;AAAA,EACR;AAEA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;AAAA;AAAA,MACD;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,6BAAQ;",
4
+ "sourcesContent": ["import { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\n/**\n * The modal's footer chrome. The fine-rotation ruler and the image controls\n * both live under the canvas (in `media-editor__content`), never here, so the\n * footer has one layout at every width: History on the left, Cancel/Save on\n * the right.\n */\nfunction ModalFooter() {\n\treturn (\n\t\t<div\n\t\t\tclassName=\"media-editor-modal__footer\"\n\t\t\trole=\"region\"\n\t\t\taria-label={ __( 'Editor actions' ) }\n\t\t>\n\t\t\t<MediaEditor.HistoryActions />\n\t\t\t<MediaEditor.SaveActions />\n\t\t</div>\n\t);\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate, onUndo, onClose } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isOpen, getId, getOnUpdate, getOnUndo, getOnClose } =\n\t\t\t\tselect( mediaEditorStore );\n\t\t\treturn {\n\t\t\t\tisModalOpen: isOpen(),\n\t\t\t\tid: getId(),\n\t\t\t\tonUpdate: getOnUpdate(),\n\t\t\t\tonUndo: getOnUndo(),\n\t\t\t\tonClose: getOnClose(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\t// React synthetic events bubble through the React tree, not the DOM tree,\n\t// so a host `ShortcutProvider` higher up still receives keydown events\n\t// from inside this portaled modal. Stop propagation at the modal boundary\n\t// so host shortcuts (undo/redo, save, etc.) don't fire from within.\n\tconst stopKeyDownPropagation = (\n\t\tevent: ReactKeyboardEvent< HTMLDivElement >\n\t) => {\n\t\tevent.stopPropagation();\n\t};\n\n\tconst handleClose = () => {\n\t\tcloseMediaEditorModal();\n\t\tonClose?.();\n\t};\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\tonClose={ handleClose }\n\t\t\tonSaved={ ( { id: savedId, url, previous } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\thandleClose();\n\t\t\t\tif ( previous && savedId !== previous.id && onUpdate ) {\n\t\t\t\t\t// Intentionally unscoped: the modal is closing, so the\n\t\t\t\t\t// snackbar surfaces in the host editor (not the media\n\t\t\t\t\t// editor's `MEDIA_EDITOR_NOTICES_CONTEXT` region).\n\t\t\t\t\tcreateSuccessNotice( __( 'Image edited.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\tif ( onUndo ) {\n\t\t\t\t\t\t\t\t\t\tonUndo();\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonUpdate( {\n\t\t\t\t\t\t\t\t\t\tid: previous.id,\n\t\t\t\t\t\t\t\t\t\turl: previous.url,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<ShortcutProvider\n\t\t\t\t\tclassName=\"media-editor-modal__shortcut-scope\"\n\t\t\t\t\tonKeyDown={ stopKeyDownPropagation }\n\t\t\t\t>\n\t\t\t\t\t<Modal\n\t\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\t\theaderActions={\n\t\t\t\t\t\t\t<MediaEditor.HeaderActions showCloseButton />\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<ModalFooter />\n\t\t\t\t\t</Modal>\n\t\t\t\t</ShortcutProvider>\n\t\t\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(options = {}) {
7
7
  const { commitOnKeyUp = true } = options;
8
8
  const { beginGesture, endGesture } = useMediaEditor();
9
- const keyboardTimerRef = useRef();
9
+ const keyboardTimerRef = useRef(void 0);
10
10
  const clearKeyboardTimer = useCallback(() => {
11
11
  clearTimeout(keyboardTimerRef.current);
12
12
  }, []);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/use-crop-gesture-handlers.ts"],
4
- "sourcesContent": ["import { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMediaEditor } from '../state';\n\n/**\n * Data attribute applied to crop control wrappers. The modal's keyboard\n * shortcut handler uses this to distinguish crop controls (where custom\n * undo/redo should fire) from metadata text fields (where the browser's\n * native undo should be preserved).\n */\nexport const CROP_CONTROL_ATTR = 'data-crop-control';\n\n/** Idle window used to group repeated keyboard input into one gesture. */\nconst KEYBOARD_GESTURE_IDLE_MS = 300;\n\nexport interface UseCropGestureHandlersOptions {\n\t/**\n\t * When `true` (default), key-up closes the gesture so each\n\t * discrete keypress becomes its own undo step. Set to `false` for\n\t * continuous-input controls (e.g. the rotation ruler) where rapid\n\t * keypresses should coalesce into a single history entry across\n\t * the whole gesture.\n\t */\n\tcommitOnKeyUp?: boolean;\n}\n\n/**\n * Event handler props to spread onto a wrapper element around a crop\n * control. Marks the wrapper as a crop control (via `data-crop-control`)\n * so the modal's Cmd+Z handler can identify it, and wires gesture\n * boundaries on the composite store so a slider drag becomes a single\n * undo entry rather than one per tick.\n *\n * Usage:\n * const gestureHandlers = useCropGestureHandlers();\n * <div role=\"presentation\" { ...gestureHandlers }>\n * <RangeControl ... />\n * </div>\n *\n * @param options Optional behavior flags.\n */\nexport function useCropGestureHandlers(\n\toptions: UseCropGestureHandlersOptions = {}\n) {\n\tconst { commitOnKeyUp = true } = options;\n\tconst { beginGesture, endGesture } = useMediaEditor();\n\tconst keyboardTimerRef = useRef< ReturnType< typeof setTimeout > >();\n\n\tconst clearKeyboardTimer = useCallback( () => {\n\t\tclearTimeout( keyboardTimerRef.current );\n\t}, [] );\n\n\tconst scheduleKeyboardEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tkeyboardTimerRef.current = setTimeout( () => {\n\t\t\tendGesture();\n\t\t}, KEYBOARD_GESTURE_IDLE_MS );\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tuseEffect( () => clearKeyboardTimer, [ clearKeyboardTimer ] );\n\n\tconst handlePointerDownCapture = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tbeginGesture();\n\t}, [ beginGesture, clearKeyboardTimer ] );\n\n\tconst handlePointerEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tendGesture();\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tconst handleKeyDownCapture = useCallback( () => {\n\t\tbeginGesture();\n\t\tif ( ! commitOnKeyUp ) {\n\t\t\tscheduleKeyboardEnd();\n\t\t}\n\t}, [ beginGesture, commitOnKeyUp, scheduleKeyboardEnd ] );\n\n\tconst handleKeyUp = useCallback( () => {\n\t\tif ( commitOnKeyUp ) {\n\t\t\tendGesture();\n\t\t\treturn;\n\t\t}\n\t\tscheduleKeyboardEnd();\n\t}, [ commitOnKeyUp, endGesture, scheduleKeyboardEnd ] );\n\n\treturn {\n\t\t[ CROP_CONTROL_ATTR ]: true,\n\t\tonPointerDownCapture: handlePointerDownCapture,\n\t\tonPointerUp: handlePointerEnd,\n\t\tonPointerCancel: handlePointerEnd,\n\t\tonKeyDownCapture: handleKeyDownCapture,\n\t\tonKeyUp: handleKeyUp,\n\t};\n}\n"],
5
- "mappings": ";AAAA,SAAS,aAAa,WAAW,cAAc;AAC/C,SAAS,sBAAsB;AAQxB,IAAM,oBAAoB;AAGjC,IAAM,2BAA2B;AA4B1B,SAAS,uBACf,UAAyC,CAAC,GACzC;AACD,QAAM,EAAE,gBAAgB,KAAK,IAAI;AACjC,QAAM,EAAE,cAAc,WAAW,IAAI,eAAe;AACpD,QAAM,mBAAmB,OAA0C;AAEnE,QAAM,qBAAqB,YAAa,MAAM;AAC7C,iBAAc,iBAAiB,OAAQ;AAAA,EACxC,GAAG,CAAC,CAAE;AAEN,QAAM,sBAAsB,YAAa,MAAM;AAC9C,uBAAmB;AACnB,qBAAiB,UAAU,WAAY,MAAM;AAC5C,iBAAW;AAAA,IACZ,GAAG,wBAAyB;AAAA,EAC7B,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,YAAW,MAAM,oBAAoB,CAAE,kBAAmB,CAAE;AAE5D,QAAM,2BAA2B,YAAa,MAAM;AACnD,uBAAmB;AACnB,iBAAa;AAAA,EACd,GAAG,CAAE,cAAc,kBAAmB,CAAE;AAExC,QAAM,mBAAmB,YAAa,MAAM;AAC3C,uBAAmB;AACnB,eAAW;AAAA,EACZ,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,QAAM,uBAAuB,YAAa,MAAM;AAC/C,iBAAa;AACb,QAAK,CAAE,eAAgB;AACtB,0BAAoB;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,cAAc,eAAe,mBAAoB,CAAE;AAExD,QAAM,cAAc,YAAa,MAAM;AACtC,QAAK,eAAgB;AACpB,iBAAW;AACX;AAAA,IACD;AACA,wBAAoB;AAAA,EACrB,GAAG,CAAE,eAAe,YAAY,mBAAoB,CAAE;AAEtD,SAAO;AAAA,IACN,CAAE,iBAAkB,GAAG;AAAA,IACvB,sBAAsB;AAAA,IACtB,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,SAAS;AAAA,EACV;AACD;",
4
+ "sourcesContent": ["import { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMediaEditor } from '../state';\n\n/**\n * Data attribute applied to crop control wrappers. The modal's keyboard\n * shortcut handler uses this to distinguish crop controls (where custom\n * undo/redo should fire) from metadata text fields (where the browser's\n * native undo should be preserved).\n */\nexport const CROP_CONTROL_ATTR = 'data-crop-control';\n\n/** Idle window used to group repeated keyboard input into one gesture. */\nconst KEYBOARD_GESTURE_IDLE_MS = 300;\n\nexport interface UseCropGestureHandlersOptions {\n\t/**\n\t * When `true` (default), key-up closes the gesture so each\n\t * discrete keypress becomes its own undo step. Set to `false` for\n\t * continuous-input controls (e.g. the rotation ruler) where rapid\n\t * keypresses should coalesce into a single history entry across\n\t * the whole gesture.\n\t */\n\tcommitOnKeyUp?: boolean;\n}\n\n/**\n * Event handler props to spread onto a wrapper element around a crop\n * control. Marks the wrapper as a crop control (via `data-crop-control`)\n * so the modal's Cmd+Z handler can identify it, and wires gesture\n * boundaries on the composite store so a slider drag becomes a single\n * undo entry rather than one per tick.\n *\n * Usage:\n * const gestureHandlers = useCropGestureHandlers();\n * <div role=\"presentation\" { ...gestureHandlers }>\n * <RangeControl ... />\n * </div>\n *\n * @param options Optional behavior flags.\n */\nexport function useCropGestureHandlers(\n\toptions: UseCropGestureHandlersOptions = {}\n) {\n\tconst { commitOnKeyUp = true } = options;\n\tconst { beginGesture, endGesture } = useMediaEditor();\n\tconst keyboardTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\n\tconst clearKeyboardTimer = useCallback( () => {\n\t\tclearTimeout( keyboardTimerRef.current );\n\t}, [] );\n\n\tconst scheduleKeyboardEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tkeyboardTimerRef.current = setTimeout( () => {\n\t\t\tendGesture();\n\t\t}, KEYBOARD_GESTURE_IDLE_MS );\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tuseEffect( () => clearKeyboardTimer, [ clearKeyboardTimer ] );\n\n\tconst handlePointerDownCapture = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tbeginGesture();\n\t}, [ beginGesture, clearKeyboardTimer ] );\n\n\tconst handlePointerEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tendGesture();\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tconst handleKeyDownCapture = useCallback( () => {\n\t\tbeginGesture();\n\t\tif ( ! commitOnKeyUp ) {\n\t\t\tscheduleKeyboardEnd();\n\t\t}\n\t}, [ beginGesture, commitOnKeyUp, scheduleKeyboardEnd ] );\n\n\tconst handleKeyUp = useCallback( () => {\n\t\tif ( commitOnKeyUp ) {\n\t\t\tendGesture();\n\t\t\treturn;\n\t\t}\n\t\tscheduleKeyboardEnd();\n\t}, [ commitOnKeyUp, endGesture, scheduleKeyboardEnd ] );\n\n\treturn {\n\t\t[ CROP_CONTROL_ATTR ]: true,\n\t\tonPointerDownCapture: handlePointerDownCapture,\n\t\tonPointerUp: handlePointerEnd,\n\t\tonPointerCancel: handlePointerEnd,\n\t\tonKeyDownCapture: handleKeyDownCapture,\n\t\tonKeyUp: handleKeyUp,\n\t};\n}\n"],
5
+ "mappings": ";AAAA,SAAS,aAAa,WAAW,cAAc;AAC/C,SAAS,sBAAsB;AAQxB,IAAM,oBAAoB;AAGjC,IAAM,2BAA2B;AA4B1B,SAAS,uBACf,UAAyC,CAAC,GACzC;AACD,QAAM,EAAE,gBAAgB,KAAK,IAAI;AACjC,QAAM,EAAE,cAAc,WAAW,IAAI,eAAe;AACpD,QAAM,mBAAmB,OAEtB,MAAU;AAEb,QAAM,qBAAqB,YAAa,MAAM;AAC7C,iBAAc,iBAAiB,OAAQ;AAAA,EACxC,GAAG,CAAC,CAAE;AAEN,QAAM,sBAAsB,YAAa,MAAM;AAC9C,uBAAmB;AACnB,qBAAiB,UAAU,WAAY,MAAM;AAC5C,iBAAW;AAAA,IACZ,GAAG,wBAAyB;AAAA,EAC7B,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,YAAW,MAAM,oBAAoB,CAAE,kBAAmB,CAAE;AAE5D,QAAM,2BAA2B,YAAa,MAAM;AACnD,uBAAmB;AACnB,iBAAa;AAAA,EACd,GAAG,CAAE,cAAc,kBAAmB,CAAE;AAExC,QAAM,mBAAmB,YAAa,MAAM;AAC3C,uBAAmB;AACnB,eAAW;AAAA,EACZ,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,QAAM,uBAAuB,YAAa,MAAM;AAC/C,iBAAa;AACb,QAAK,CAAE,eAAgB;AACtB,0BAAoB;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,cAAc,eAAe,mBAAoB,CAAE;AAExD,QAAM,cAAc,YAAa,MAAM;AACtC,QAAK,eAAgB;AACpB,iBAAW;AACX;AAAA,IACD;AACA,wBAAoB;AAAA,EACrB,GAAG,CAAE,eAAe,YAAY,mBAAoB,CAAE;AAEtD,SAAO;AAAA,IACN,CAAE,iBAAkB,GAAG;AAAA,IACvB,sBAAsB;AAAA,IACtB,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,SAAS;AAAA,EACV;AACD;",
6
6
  "names": []
7
7
  }
@@ -124,6 +124,11 @@ var InteractionController = class {
124
124
  }
125
125
  el.focus();
126
126
  el.setPointerCapture(e.pointerId);
127
+ if (this.wheelGestureActive) {
128
+ clearTimeout(this.wheelGestureTimer);
129
+ this.wheelGestureActive = false;
130
+ this.options.onGestureEnd?.();
131
+ }
127
132
  this.setStatus({ isDragging: true });
128
133
  this.options.onGestureStart?.();
129
134
  const currentState = this.options.getState();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/image-editor/core/interaction-controller.ts"],
4
- "sourcesContent": ["import type { CropperState, NormalizedPoint, Size } from './types';\nimport {\n\tDEFAULT_KEYBOARD_STEP,\n\tDEFAULT_WHEEL_ZOOM_SPEED,\n\tKEYBOARD_SHIFT_STEP_MULTIPLIER,\n\tMIN_ZOOM,\n\tMAX_ZOOM,\n} from './constants';\nimport { restrictPanZoom } from './containment';\n\n/** Time window for detecting a double-tap gesture (ms). */\nconst DOUBLE_TAP_TIME = 300;\n/** Max distance between taps to count as a double-tap (px). */\nconst DOUBLE_TAP_DISTANCE = 30;\n/** Duration of the zoom animation state (ms). */\nconst ZOOM_ANIMATION_DURATION = 200;\n\n/**\n * Get the natural image dimensions from cropper state, falling back to 1x1.\n *\n * @param state The current cropper state.\n * @return The image dimensions.\n */\nfunction getImageSizeFromState( state: CropperState ): {\n\twidth: number;\n\theight: number;\n} {\n\treturn state.image\n\t\t? { width: state.image.naturalWidth, height: state.image.naturalHeight }\n\t\t: { width: 1, height: 1 };\n}\n\n/**\n * Get the distance between two touch points.\n *\n * @param t1 The first touch.\n * @param t2 The second touch.\n * @return The pixel distance between the two touches.\n */\nfunction getTouchDistance( t1: Touch, t2: Touch ): number {\n\tconst dx = t1.clientX - t2.clientX;\n\tconst dy = t1.clientY - t2.clientY;\n\treturn Math.sqrt( dx * dx + dy * dy );\n}\n\n/**\n * Status reported by the interaction controller when drag/zoom state changes.\n */\nexport interface InteractionStatus {\n\t/** Whether a drag (pan) interaction is in progress. */\n\tisDragging: boolean;\n\t/** Whether a double-tap zoom animation is in progress. */\n\tisZooming: boolean;\n}\n\n/**\n * State updates the interaction controller can request from its host UI.\n */\nexport interface CropperInteractionActions {\n\t/** Set the image pan offset in normalized coordinates. */\n\tsetPan: ( pan: NormalizedPoint ) => void;\n\t/**\n\t * Set the zoom level. Cursorless surfaces (slider, keyboard `+`/`-`)\n\t * rely on this anchoring at the crop center; pointer-driven zoom\n\t * paths use `setZoomAtPoint` with an explicit focal point instead.\n\t */\n\tsetZoom: ( zoom: number ) => void;\n\t/** Set zoom and pan together for focal-point zoom. */\n\tsetZoomAtPoint: ( zoom: number, pan: NormalizedPoint ) => void;\n\t/** Snap rotate by 90 degrees. */\n\tsnapRotate90: ( direction: 1 | -1 ) => void;\n\t/** Toggle flip on the given axis. */\n\ttoggleFlip?: ( direction: 'horizontal' | 'vertical' ) => void;\n}\n\n/**\n * Options for creating an InteractionController.\n *\n * Scalar options (minZoom, maxZoom, etc.) are read lazily on each\n * interaction, so changes to the options object take effect immediately\n * without recreating the controller.\n */\nexport interface InteractionControllerOptions {\n\t/** Returns the current cropper state. Called on every interaction. */\n\tgetState: () => CropperState;\n\t/** State updates the interaction controller can request from its host UI. */\n\tactions: CropperInteractionActions;\n\t/** Returns the container dimensions in pixels. */\n\tgetContainerSize: () => Size;\n\t/** Returns the rendered image dimensions in pixels, if available. */\n\tgetImageSize: () => Size | undefined;\n\t/** Minimum zoom level. Defaults to MIN_ZOOM. Read lazily. */\n\tminZoom?: number;\n\t/** Maximum zoom level. Defaults to MAX_ZOOM. Read lazily. */\n\tmaxZoom?: number;\n\t/** Zoom speed multiplier for wheel events. Defaults to 0.0025. Read lazily. */\n\tzoomSpeed?: number;\n\t/**\n\t * Pan step size in normalized coords for keyboard events.\n\t * Defaults to 0.01. Read lazily. Shift multiplies it by 10.\n\t */\n\tkeyboardStep?: number;\n\t/** Zoom level for double-tap zoom. Defaults to 2. Read lazily. */\n\tdoubleTapZoom?: number;\n\t/** Fires when a continuous gesture begins (pan drag, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointer release). */\n\tonGestureEnd?: () => void;\n\t/** Called when isDragging or isZooming changes. */\n\tonStatusChange?: ( status: InteractionStatus ) => void;\n}\n\n/**\n * Framework-agnostic imperative controller for image cropper interactions.\n *\n * Handles mouse, touch, and keyboard event processing for pan, zoom,\n * and crop manipulation. Uses requestAnimationFrame for drag/pinch\n * updates to avoid layout thrashing.\n *\n * The controller does not register DOM event listeners itself — that is the\n * responsibility of the UI layer (React hook, Vue directive, or vanilla JS).\n * Instead it exposes `handlePointerDown`, `handleWheel`, `handleTouchStart`,\n * and `handleKeyDown` methods that the UI layer calls with native DOM events.\n *\n * Scalar options (minZoom, maxZoom, zoomSpeed, keyboardStep, doubleTapZoom)\n * are read lazily from `this.options` on each interaction, so the UI layer\n * can update them without recreating the controller.\n *\n * Call `destroy()` to clean up timers and pending animation frames.\n */\nexport class InteractionController {\n\tprivate readonly options: InteractionControllerOptions;\n\n\t/** Current drag/zoom status. */\n\tprivate isDragging = false;\n\tprivate isZooming = false;\n\n\t/** Active drag state during pointer interactions. */\n\tprivate drag: {\n\t\tstartX: number;\n\t\tstartY: number;\n\t\tstartPanX: number;\n\t\tstartPanY: number;\n\t} | null = null;\n\n\t/** Active touch state during touch interactions. */\n\tprivate touch: {\n\t\t/** Finger distance at pinch start (0 until pinch detected). */\n\t\tstartDistance: number;\n\t\t/** Zoom level when pinch was detected. */\n\t\tstartZoom: number;\n\t\t/** First touch X/Y (for single-finger pan delta). */\n\t\tlastTouchX: number;\n\t\tlastTouchY: number;\n\t\t/** Pan when gesture started. */\n\t\tstartPanX: number;\n\t\tstartPanY: number;\n\t\t/** Container rect snapshot for focal-point math. */\n\t\tcontainerRect?: DOMRect;\n\t\t/** Midpoint of two fingers when pinch was detected. */\n\t\tstartMidX: number;\n\t\tstartMidY: number;\n\t\t/** Whether pinch was ever detected during this gesture. */\n\t\tdidPinch: boolean;\n\t\t/** Whether any dispatch has occurred (prevents dispatching before first move). */\n\t\tmoved: boolean;\n\t} | null = null;\n\n\t/** Cleanup function for active touch listeners on document. */\n\tprivate touchCleanup: ( () => void ) | null = null;\n\n\t/**\n\t * Cleanup function for active pointer-drag listeners on the\n\t * captured element. Set while a pointer drag is in progress so\n\t * `destroy()` can tear the drag down cleanly if the consumer\n\t * unmounts mid-drag. Cleared on pointerup/lostpointercapture.\n\t */\n\tprivate pointerCleanup: ( () => void ) | null = null;\n\n\t/** Last tap info for double-tap detection. */\n\tprivate lastTap: {\n\t\ttime: number;\n\t\tx: number;\n\t\ty: number;\n\t} | null = null;\n\n\t/** Timer for the zoom animation state (double-tap). */\n\tprivate zoomTimer: ReturnType< typeof setTimeout > | undefined;\n\n\t/** Timer for wheel gesture debounce. */\n\tprivate wheelGestureTimer: ReturnType< typeof setTimeout > | undefined;\n\n\t/** Whether a wheel gesture is currently active. */\n\tprivate wheelGestureActive = false;\n\n\t/** Current requestAnimationFrame ID. */\n\tprivate rafId = 0;\n\n\tconstructor( options: InteractionControllerOptions ) {\n\t\tthis.options = options;\n\t}\n\n\t/** Read minZoom lazily so option changes take effect immediately. */\n\tprivate get minZoom(): number {\n\t\treturn this.options.minZoom ?? MIN_ZOOM;\n\t}\n\n\t/** Read maxZoom lazily so option changes take effect immediately. */\n\tprivate get maxZoom(): number {\n\t\treturn this.options.maxZoom ?? MAX_ZOOM;\n\t}\n\n\t/** Read zoomSpeed lazily so option changes take effect immediately. */\n\tprivate get zoomSpeed(): number {\n\t\treturn this.options.zoomSpeed ?? DEFAULT_WHEEL_ZOOM_SPEED;\n\t}\n\n\t/** Read keyboardStep lazily so option changes take effect immediately. */\n\tprivate get keyboardStep(): number {\n\t\treturn this.options.keyboardStep ?? DEFAULT_KEYBOARD_STEP;\n\t}\n\n\t/**\n\t * Get the keyboard pan step, including modifier-based coarse movement.\n\t *\n\t * @param event The native KeyboardEvent.\n\t * @return The normalized pan step.\n\t */\n\tprivate getKeyboardStep( event: KeyboardEvent ): number {\n\t\treturn event.shiftKey\n\t\t\t? this.keyboardStep * KEYBOARD_SHIFT_STEP_MULTIPLIER\n\t\t\t: this.keyboardStep;\n\t}\n\n\t/** Read doubleTapZoom lazily so option changes take effect immediately. */\n\tprivate get doubleTapZoom(): number {\n\t\treturn this.options.doubleTapZoom ?? 2;\n\t}\n\n\t/**\n\t * Update the drag/zoom status and notify via callback if changed.\n\t *\n\t * @param update Partial status with isDragging and/or isZooming.\n\t */\n\tprivate setStatus(\n\t\tupdate: Partial< { isDragging: boolean; isZooming: boolean } >\n\t): void {\n\t\tlet changed = false;\n\t\tif (\n\t\t\tupdate.isDragging !== undefined &&\n\t\t\tupdate.isDragging !== this.isDragging\n\t\t) {\n\t\t\tthis.isDragging = update.isDragging;\n\t\t\tchanged = true;\n\t\t}\n\t\tif (\n\t\t\tupdate.isZooming !== undefined &&\n\t\t\tupdate.isZooming !== this.isZooming\n\t\t) {\n\t\t\tthis.isZooming = update.isZooming;\n\t\t\tchanged = true;\n\t\t}\n\t\tif ( changed ) {\n\t\t\tthis.options.onStatusChange?.( {\n\t\t\t\tisDragging: this.isDragging,\n\t\t\t\tisZooming: this.isZooming,\n\t\t\t} );\n\t\t}\n\t}\n\n\t/**\n\t * Handle a pointer-down event on the container element.\n\t *\n\t * Initiates a drag (pan) interaction. Captures the pointer on the\n\t * provided element and registers pointermove/pointerup/lostpointercapture\n\t * listeners for the duration of the drag.\n\t *\n\t * @param e The native PointerEvent.\n\t * @param el The DOM element to capture the pointer on.\n\t */\n\thandlePointerDown( e: PointerEvent, el: HTMLElement ): void {\n\t\t// Only handle primary button (left click / first touch).\n\t\tif ( e.button !== 0 ) {\n\t\t\treturn;\n\t\t}\n\t\t// Touch gestures are handled by touchstart/touchmove. Starting the\n\t\t// pointer drag path too can briefly toggle drag UI before pinch begins.\n\t\tif ( e.pointerType === 'touch' ) {\n\t\t\treturn;\n\t\t}\n\t\te.preventDefault();\n\n\t\t// Blur any focused handle so its focus ring doesn't linger,\n\t\t// but leave the canvas itself alone so keyboard control works after drag.\n\t\tconst ownerDoc = el.ownerDocument;\n\t\tif (\n\t\t\townerDoc?.activeElement instanceof HTMLElement &&\n\t\t\townerDoc.activeElement !== el\n\t\t) {\n\t\t\townerDoc.activeElement.blur();\n\t\t}\n\n\t\tel.focus();\n\n\t\t// Capture pointer so drag works across iframe boundaries.\n\t\tel.setPointerCapture( e.pointerId );\n\n\t\tthis.setStatus( { isDragging: true } );\n\t\tthis.options.onGestureStart?.();\n\n\t\tconst currentState = this.options.getState();\n\t\tthis.drag = {\n\t\t\tstartX: e.clientX,\n\t\t\tstartY: e.clientY,\n\t\t\tstartPanX: currentState.pan.x,\n\t\t\tstartPanY: currentState.pan.y,\n\t\t};\n\n\t\tconst onPointerMove = ( moveEvent: Event ) => {\n\t\t\tconst drag = this.drag;\n\t\t\tif ( ! drag ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst pe = moveEvent as PointerEvent;\n\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tthis.rafId = requestAnimationFrame( () => {\n\t\t\t\tconst s = this.options.getState();\n\t\t\t\tconst imgSize = this.options.getImageSize();\n\t\t\t\tconst containerSize = this.options.getContainerSize();\n\t\t\t\tconst panSize = imgSize ?? containerSize;\n\t\t\t\tconst deltaX =\n\t\t\t\t\tpanSize.width > 0\n\t\t\t\t\t\t? ( pe.clientX - drag.startX ) / panSize.width\n\t\t\t\t\t\t: 0;\n\t\t\t\tconst deltaY =\n\t\t\t\t\tpanSize.height > 0\n\t\t\t\t\t\t? ( pe.clientY - drag.startY ) / panSize.height\n\t\t\t\t\t\t: 0;\n\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...s,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: drag.startPanX + deltaX,\n\t\t\t\t\t\t\ty: drag.startPanY + deltaY,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\ts.cropRect\n\t\t\t\t);\n\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t} );\n\t\t};\n\n\t\tconst removeListeners = () => {\n\t\t\tel.removeEventListener( 'pointermove', onPointerMove );\n\t\t\tel.removeEventListener( 'pointerup', onPointerUp );\n\t\t\tel.removeEventListener( 'lostpointercapture', onPointerUp );\n\t\t};\n\n\t\tconst onPointerUp = () => {\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\tthis.options.onGestureEnd?.();\n\t\t\tthis.drag = null;\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tremoveListeners();\n\t\t\tthis.pointerCleanup = null;\n\t\t};\n\n\t\tel.addEventListener( 'pointermove', onPointerMove );\n\t\tel.addEventListener( 'pointerup', onPointerUp );\n\t\tel.addEventListener( 'lostpointercapture', onPointerUp );\n\t\t// Expose cleanup to destroy() in case the consumer unmounts\n\t\t// mid-drag. The pending rAF is cancelled in destroy().\n\t\tthis.pointerCleanup = removeListeners;\n\t}\n\n\t/**\n\t * Handle a wheel event on the container element.\n\t *\n\t * Implements focal-point zoom: the point under the cursor stays\n\t * stationary on screen while the zoom level changes.\n\t *\n\t * Must be registered with `{ passive: false }` to allow preventDefault.\n\t *\n\t * @param e The native WheelEvent.\n\t */\n\thandleWheel( e: WheelEvent ): void {\n\t\te.preventDefault();\n\n\t\tif ( this.drag ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Debounced gesture boundaries for wheel zoom.\n\t\t// Start on first wheel event, end after 300ms of no events.\n\t\tif ( ! this.wheelGestureActive ) {\n\t\t\tthis.wheelGestureActive = true;\n\t\t\tthis.options.onGestureStart?.();\n\t\t}\n\t\tclearTimeout( this.wheelGestureTimer );\n\t\tthis.wheelGestureTimer = setTimeout( () => {\n\t\t\tthis.wheelGestureActive = false;\n\t\t\tthis.options.onGestureEnd?.();\n\t\t}, DOUBLE_TAP_TIME );\n\n\t\tconst s = this.options.getState();\n\t\tconst delta = -e.deltaY * this.zoomSpeed;\n\t\tconst newZoom = Math.min(\n\t\t\tthis.maxZoom,\n\t\t\tMath.max( this.minZoom, s.zoom + delta )\n\t\t);\n\n\t\tif ( newZoom === s.zoom ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Focal-point zoom: keep the point under the cursor stationary.\n\t\tconst containerSize = this.options.getContainerSize();\n\t\tconst imgSize = this.options.getImageSize();\n\t\tconst visSize = imgSize ?? containerSize;\n\t\tconst target = e.currentTarget;\n\t\tconst rect =\n\t\t\ttarget instanceof Element\n\t\t\t\t? target.getBoundingClientRect()\n\t\t\t\t: undefined;\n\t\tif ( visSize.width > 0 && visSize.height > 0 && rect ) {\n\t\t\tconst fx = e.clientX - rect.left - containerSize.width / 2;\n\t\t\tconst fy = e.clientY - rect.top - containerSize.height / 2;\n\n\t\t\tconst zoomRatio = 1 - newZoom / s.zoom;\n\t\t\tconst focalNormX = fx / visSize.width;\n\t\t\tconst focalNormY = fy / visSize.height;\n\t\t\tconst newCropX = s.pan.x + ( focalNormX - s.pan.x ) * zoomRatio;\n\t\t\tconst newCropY = s.pan.y + ( focalNormY - s.pan.y ) * zoomRatio;\n\n\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t{ ...s, zoom: newZoom, pan: { x: newCropX, y: newCropY } },\n\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\ts.cropRect\n\t\t\t);\n\t\t\tthis.options.actions.setZoomAtPoint( newZoom, clampedCrop );\n\t\t} else {\n\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t}\n\t}\n\n\t/**\n\t * Handle a touch-start event on the container element.\n\t *\n\t * Supports single-finger pan, two-finger pinch zoom, and\n\t * double-tap to toggle between fit and 2x zoom. Registers\n\t * touchmove/touchend/touchcancel on the provided document for the\n\t * duration of the gesture.\n\t *\n\t * @param e The native TouchEvent.\n\t * @param containerRect The bounding rect of the container element.\n\t * @param doc The document to register move/end listeners on.\n\t * Defaults to globalThis.document. Pass the iframe's\n\t * contentDocument when running inside an iframe.\n\t */\n\thandleTouchStart(\n\t\te: TouchEvent,\n\t\tcontainerRect: DOMRect,\n\t\tdoc: Document = document\n\t): void {\n\t\t// Second finger arriving during an existing gesture — snapshot\n\t\t// pinch start values. handleTouchMove will detect 2 touches and\n\t\t// handle pinch automatically.\n\t\tif ( this.touch && e.touches.length === 2 ) {\n\t\t\tconst s = this.options.getState();\n\t\t\tconst distance = getTouchDistance( e.touches[ 0 ], e.touches[ 1 ] );\n\t\t\tconst midX =\n\t\t\t\t( e.touches[ 0 ].clientX + e.touches[ 1 ].clientX ) / 2;\n\t\t\tconst midY =\n\t\t\t\t( e.touches[ 0 ].clientY + e.touches[ 1 ].clientY ) / 2;\n\t\t\tthis.touch.didPinch = true;\n\t\t\tthis.touch.startDistance = distance;\n\t\t\tthis.touch.startZoom = s.zoom;\n\t\t\tthis.touch.startPanX = s.pan.x;\n\t\t\tthis.touch.startPanY = s.pan.y;\n\t\t\tthis.touch.startMidX = midX;\n\t\t\tthis.touch.startMidY = midY;\n\t\t\tthis.touch.containerRect = containerRect;\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( e.touches.length === 1 ) {\n\t\t\tconst tapX = e.touches[ 0 ].clientX;\n\t\t\tconst tapY = e.touches[ 0 ].clientY;\n\t\t\tif ( this.tryDoubleTap( e, tapX, tapY, containerRect ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentState = this.options.getState();\n\n\t\t\t// Record touch state. Don't decide pan vs pinch yet —\n\t\t\t// that happens in handleTouchMove based on touches.length.\n\t\t\tthis.touch = {\n\t\t\t\tstartDistance: 0,\n\t\t\t\tstartZoom: currentState.zoom,\n\t\t\t\tlastTouchX: e.touches[ 0 ].clientX,\n\t\t\t\tlastTouchY: e.touches[ 0 ].clientY,\n\t\t\t\tstartPanX: currentState.pan.x,\n\t\t\t\tstartPanY: currentState.pan.y,\n\t\t\t\tcontainerRect,\n\t\t\t\tstartMidX: 0,\n\t\t\t\tstartMidY: 0,\n\t\t\t\tdidPinch: false,\n\t\t\t\tmoved: false,\n\t\t\t};\n\t\t\tthis.options.onGestureStart?.();\n\t\t} else if ( e.touches.length === 2 ) {\n\t\t\t// Both fingers landed simultaneously (rare but possible).\n\t\t\tconst currentState = this.options.getState();\n\t\t\tconst distance = getTouchDistance( e.touches[ 0 ], e.touches[ 1 ] );\n\t\t\tconst midX =\n\t\t\t\t( e.touches[ 0 ].clientX + e.touches[ 1 ].clientX ) / 2;\n\t\t\tconst midY =\n\t\t\t\t( e.touches[ 0 ].clientY + e.touches[ 1 ].clientY ) / 2;\n\t\t\tthis.touch = {\n\t\t\t\tstartDistance: distance,\n\t\t\t\tstartZoom: currentState.zoom,\n\t\t\t\tlastTouchX: 0,\n\t\t\t\tlastTouchY: 0,\n\t\t\t\tstartPanX: currentState.pan.x,\n\t\t\t\tstartPanY: currentState.pan.y,\n\t\t\t\tcontainerRect,\n\t\t\t\tstartMidX: midX,\n\t\t\t\tstartMidY: midY,\n\t\t\t\tdidPinch: true,\n\t\t\t\tmoved: false,\n\t\t\t};\n\t\t\tthis.options.onGestureStart?.();\n\t\t}\n\n\t\tconst onTouchEnd = () => {\n\t\t\tthis.touch = null;\n\t\t\tthis.touchCleanup = null;\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tdoc.removeEventListener( 'touchmove', this.handleTouchMove );\n\t\t\tdoc.removeEventListener( 'touchend', onTouchEnd );\n\t\t\tdoc.removeEventListener( 'touchcancel', onTouchEnd );\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\tthis.options.onGestureEnd?.();\n\t\t};\n\n\t\t// Clean up any previous touch listeners before registering new ones.\n\t\tthis.touchCleanup?.();\n\n\t\tdoc.addEventListener( 'touchmove', this.handleTouchMove, {\n\t\t\tpassive: false,\n\t\t} );\n\t\tdoc.addEventListener( 'touchend', onTouchEnd );\n\t\tdoc.addEventListener( 'touchcancel', onTouchEnd );\n\n\t\tthis.touchCleanup = onTouchEnd;\n\t}\n\n\t// Handle a touchmove event during an active touch gesture. Decides pinch\n\t// vs. pan based on current `moveEvent.touches.length`, so the gesture\n\t// can transition between modes without timing sensitivity (e.g. fingers\n\t// landing 0ms vs 200ms apart). Arrow-property binding so `this` stays\n\t// attached when used as an event listener.\n\tprivate handleTouchMove = ( moveEvent: TouchEvent ): void => {\n\t\tconst touch = this.touch;\n\t\tif ( ! touch ) {\n\t\t\treturn;\n\t\t}\n\t\tmoveEvent.preventDefault();\n\n\t\tcancelAnimationFrame( this.rafId );\n\t\tthis.rafId = requestAnimationFrame( () => {\n\t\t\tconst s = this.options.getState();\n\n\t\t\tif ( moveEvent.touches.length === 2 ) {\n\t\t\t\t// Two fingers → always pinch, regardless of how gesture\n\t\t\t\t// started. Initialize pinch state on first 2-finger move.\n\t\t\t\tif ( ! touch.didPinch ) {\n\t\t\t\t\ttouch.didPinch = true;\n\t\t\t\t\ttouch.startDistance = getTouchDistance(\n\t\t\t\t\t\tmoveEvent.touches[ 0 ],\n\t\t\t\t\t\tmoveEvent.touches[ 1 ]\n\t\t\t\t\t);\n\t\t\t\t\ttouch.startZoom = s.zoom;\n\t\t\t\t\ttouch.startPanX = s.pan.x;\n\t\t\t\t\ttouch.startPanY = s.pan.y;\n\t\t\t\t\ttouch.startMidX =\n\t\t\t\t\t\t( moveEvent.touches[ 0 ].clientX +\n\t\t\t\t\t\t\tmoveEvent.touches[ 1 ].clientX ) /\n\t\t\t\t\t\t2;\n\t\t\t\t\ttouch.startMidY =\n\t\t\t\t\t\t( moveEvent.touches[ 0 ].clientY +\n\t\t\t\t\t\t\tmoveEvent.touches[ 1 ].clientY ) /\n\t\t\t\t\t\t2;\n\t\t\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst latestContainerSize = this.options.getContainerSize();\n\t\t\t\tconst latestImageSize = this.options.getImageSize();\n\n\t\t\t\t// Pinch zoom with focal point at finger midpoint,\n\t\t\t\t// plus simultaneous pan from midpoint drift.\n\t\t\t\tconst t0 = moveEvent.touches[ 0 ];\n\t\t\t\tconst t1 = moveEvent.touches[ 1 ];\n\t\t\t\tconst currentDistance = getTouchDistance( t0, t1 );\n\t\t\t\tconst ratio = currentDistance / touch.startDistance;\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, touch.startZoom * ratio )\n\t\t\t\t);\n\n\t\t\t\tconst visSize = latestImageSize ?? latestContainerSize;\n\t\t\t\tconst rect = touch.containerRect;\n\t\t\t\tif ( visSize.width > 0 && visSize.height > 0 && rect ) {\n\t\t\t\t\t// Current midpoint.\n\t\t\t\t\tconst mx =\n\t\t\t\t\t\t( t0.clientX + t1.clientX ) / 2 -\n\t\t\t\t\t\trect.left -\n\t\t\t\t\t\tlatestContainerSize.width / 2;\n\t\t\t\t\tconst my =\n\t\t\t\t\t\t( t0.clientY + t1.clientY ) / 2 -\n\t\t\t\t\t\trect.top -\n\t\t\t\t\t\tlatestContainerSize.height / 2;\n\n\t\t\t\t\t// Pan from midpoint drift (fingers moving together).\n\t\t\t\t\tconst startMx =\n\t\t\t\t\t\ttouch.startMidX -\n\t\t\t\t\t\trect.left -\n\t\t\t\t\t\tlatestContainerSize.width / 2;\n\t\t\t\t\tconst startMy =\n\t\t\t\t\t\ttouch.startMidY -\n\t\t\t\t\t\trect.top -\n\t\t\t\t\t\tlatestContainerSize.height / 2;\n\t\t\t\t\tconst panDx =\n\t\t\t\t\t\tvisSize.width > 0\n\t\t\t\t\t\t\t? ( mx - startMx ) / visSize.width\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tconst panDy =\n\t\t\t\t\t\tvisSize.height > 0\n\t\t\t\t\t\t\t? ( my - startMy ) / visSize.height\n\t\t\t\t\t\t\t: 0;\n\n\t\t\t\t\t// Focal-point zoom correction. Keep this based on the\n\t\t\t\t\t// pinch-start state; using the current reducer state here\n\t\t\t\t\t// compounds prior touchmove frames and makes a fixed pinch\n\t\t\t\t\t// center drift after the image is already zoomed or panned.\n\t\t\t\t\tconst zoomRatio =\n\t\t\t\t\t\ttouch.startZoom !== 0\n\t\t\t\t\t\t\t? 1 - newZoom / touch.startZoom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tconst startFocalNormX = startMx / visSize.width;\n\t\t\t\t\tconst startFocalNormY = startMy / visSize.height;\n\n\t\t\t\t\t// Combined: midpoint drift + zoom around the pinch-start\n\t\t\t\t\t// midpoint, so moving both fingers together pans while\n\t\t\t\t\t// symmetric pinches keep the start center stationary.\n\t\t\t\t\tconst newCropX =\n\t\t\t\t\t\ttouch.startPanX +\n\t\t\t\t\t\tpanDx +\n\t\t\t\t\t\t( startFocalNormX - touch.startPanX ) * zoomRatio;\n\t\t\t\t\tconst newCropY =\n\t\t\t\t\t\ttouch.startPanY +\n\t\t\t\t\t\tpanDy +\n\t\t\t\t\t\t( startFocalNormY - touch.startPanY ) * zoomRatio;\n\n\t\t\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\tzoom: newZoom,\n\t\t\t\t\t\t\tpan: { x: newCropX, y: newCropY },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\t\ts.cropRect\n\t\t\t\t\t);\n\t\t\t\t\tthis.options.actions.setZoomAtPoint( newZoom, clampedCrop );\n\t\t\t\t} else if ( newZoom !== s.zoom ) {\n\t\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\t}\n\t\t\t} else if ( moveEvent.touches.length === 1 && ! touch.didPinch ) {\n\t\t\t\t// One finger and no pinch ever detected → pan.\n\t\t\t\t// If fingers went 2→1 (didPinch is true), we do NOT\n\t\t\t\t// switch to pan — avoids accidental pan after releasing\n\t\t\t\t// one finger from a pinch.\n\t\t\t\tif ( ! touch.moved ) {\n\t\t\t\t\ttouch.moved = true;\n\t\t\t\t\tthis.setStatus( { isDragging: true } );\n\t\t\t\t}\n\t\t\t\tconst panImageSize = this.options.getImageSize();\n\t\t\t\tconst panContainerSize = this.options.getContainerSize();\n\t\t\t\tconst panSize = panImageSize ?? panContainerSize;\n\t\t\t\tconst deltaX =\n\t\t\t\t\tpanSize.width > 0\n\t\t\t\t\t\t? ( moveEvent.touches[ 0 ].clientX -\n\t\t\t\t\t\t\t\ttouch.lastTouchX ) /\n\t\t\t\t\t\t\tpanSize.width\n\t\t\t\t\t\t: 0;\n\t\t\t\tconst deltaY =\n\t\t\t\t\tpanSize.height > 0\n\t\t\t\t\t\t? ( moveEvent.touches[ 0 ].clientY -\n\t\t\t\t\t\t\t\ttouch.lastTouchY ) /\n\t\t\t\t\t\t\tpanSize.height\n\t\t\t\t\t\t: 0;\n\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...s,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: touch.startPanX + deltaX,\n\t\t\t\t\t\t\ty: touch.startPanY + deltaY,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\ts.cropRect\n\t\t\t\t);\n\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t}\n\t\t} );\n\t};\n\n\t// Handle double-tap-to-toggle-zoom. On a second tap within the configured\n\t// time/distance threshold, toggles zoom between `minZoom` and\n\t// `doubleTapZoom` around the tap point and dispatches. Returns `true` if\n\t// the tap was handled as a double-tap (caller should early-return),\n\t// `false` otherwise (caller proceeds with normal single-tap handling).\n\t// Either way, records the tap for next time.\n\tprivate tryDoubleTap(\n\t\te: TouchEvent,\n\t\ttapX: number,\n\t\ttapY: number,\n\t\tcontainerRect: DOMRect\n\t): boolean {\n\t\tconst now = Date.now();\n\t\tconst lastTap = this.lastTap;\n\t\tif ( ! lastTap ) {\n\t\t\tthis.lastTap = { time: now, x: tapX, y: tapY };\n\t\t\treturn false;\n\t\t}\n\t\tconst timeDelta = now - lastTap.time;\n\t\tconst distDelta = Math.sqrt(\n\t\t\t( tapX - lastTap.x ) ** 2 + ( tapY - lastTap.y ) ** 2\n\t\t);\n\t\tconst isDoubleTap =\n\t\t\ttimeDelta < DOUBLE_TAP_TIME && distDelta < DOUBLE_TAP_DISTANCE;\n\t\tif ( ! isDoubleTap ) {\n\t\t\tthis.lastTap = { time: now, x: tapX, y: tapY };\n\t\t\treturn false;\n\t\t}\n\n\t\t// It's a double-tap — suppress browser zoom.\n\t\te.preventDefault();\n\t\tthis.lastTap = null;\n\n\t\tconst currentState = this.options.getState();\n\t\tconst containerSize = this.options.getContainerSize();\n\t\tconst imgSize = this.options.getImageSize();\n\n\t\t// Toggle: if past halfway to doubleTapZoom, go back to 1x.\n\t\tconst targetZoom =\n\t\t\tcurrentState.zoom > ( this.minZoom + this.doubleTapZoom ) / 2\n\t\t\t\t? this.minZoom\n\t\t\t\t: this.doubleTapZoom;\n\t\tconst visSize = imgSize ?? containerSize;\n\n\t\t// Enable zoom animation before dispatching.\n\t\tthis.setStatus( { isZooming: true } );\n\t\tclearTimeout( this.zoomTimer );\n\t\tthis.zoomTimer = setTimeout( () => {\n\t\t\tthis.setStatus( { isZooming: false } );\n\t\t}, ZOOM_ANIMATION_DURATION );\n\n\t\t// Double-tap bypasses the normal handleTouchStart gesture path so\n\t\t// onGestureStart/End are never called — fire them here so undo\n\t\t// receives a proper boundary around this discrete zoom action.\n\t\tthis.options.onGestureStart?.();\n\n\t\tif ( visSize.width > 0 && visSize.height > 0 ) {\n\t\t\tconst fx = tapX - containerRect.left - containerSize.width / 2;\n\t\t\tconst fy = tapY - containerRect.top - containerSize.height / 2;\n\n\t\t\tconst zoomRatio = 1 - targetZoom / currentState.zoom;\n\t\t\tconst focalNormX = fx / visSize.width;\n\t\t\tconst focalNormY = fy / visSize.height;\n\t\t\tconst newCropX =\n\t\t\t\tcurrentState.pan.x +\n\t\t\t\t( focalNormX - currentState.pan.x ) * zoomRatio;\n\t\t\tconst newCropY =\n\t\t\t\tcurrentState.pan.y +\n\t\t\t\t( focalNormY - currentState.pan.y ) * zoomRatio;\n\n\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t{\n\t\t\t\t\t...currentState,\n\t\t\t\t\tzoom: targetZoom,\n\t\t\t\t\tpan: { x: newCropX, y: newCropY },\n\t\t\t\t},\n\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\tcurrentState.cropRect\n\t\t\t);\n\t\t\tthis.options.actions.setZoomAtPoint( targetZoom, clampedCrop );\n\t\t} else {\n\t\t\tthis.options.actions.setZoom( targetZoom );\n\t\t}\n\n\t\tthis.options.onGestureEnd?.();\n\t\treturn true;\n\t}\n\n\t/**\n\t * Handle a keydown event on the container element.\n\t *\n\t * Supports arrow keys for panning, +/- for zoom, and r/R for rotation.\n\t *\n\t * @param e The native KeyboardEvent.\n\t */\n\thandleKeyDown( e: KeyboardEvent ): void {\n\t\tconst currentState = this.options.getState();\n\n\t\tswitch ( e.key ) {\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x,\n\t\t\t\t\t\t\ty: currentState.pan.y + keyboardStep,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x,\n\t\t\t\t\t\t\ty: currentState.pan.y - keyboardStep,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowLeft': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x + keyboardStep,\n\t\t\t\t\t\t\ty: currentState.pan.y,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowRight': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x - keyboardStep,\n\t\t\t\t\t\t\ty: currentState.pan.y,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '+':\n\t\t\tcase '=': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, currentState.zoom + 0.5 )\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '-':\n\t\t\tcase '_': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, currentState.zoom - 0.5 )\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'r':\n\t\t\tcase 'R': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.snapRotate90( e.shiftKey ? -1 : 1 );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'h':\n\t\t\tcase 'H': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey || e.shiftKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.toggleFlip?.( 'horizontal' );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'v':\n\t\t\tcase 'V': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey || e.shiftKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.toggleFlip?.( 'vertical' );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up all timers, animation frames, and active touch listeners.\n\t *\n\t * Must be called when the controller is no longer needed (e.g., on\n\t * component unmount or element removal).\n\t */\n\tdestroy(): void {\n\t\tcancelAnimationFrame( this.rafId );\n\t\tclearTimeout( this.zoomTimer );\n\t\tclearTimeout( this.wheelGestureTimer );\n\t\tthis.touchCleanup?.();\n\t\tthis.touchCleanup = null;\n\t\tthis.pointerCleanup?.();\n\t\tthis.pointerCleanup = null;\n\t\tthis.drag = null;\n\t\tthis.touch = null;\n\t\tthis.lastTap = null;\n\t\t// Reset the gesture bookkeeping too. The timers above are cancelled\n\t\t// rather than run, so these flags would otherwise stay set: a stale\n\t\t// `wheelGestureActive` suppresses the next wheel gesture's start,\n\t\t// and `setStatus` dedupes against `isDragging` / `isZooming`, so a\n\t\t// stale value swallows the next real change.\n\t\tthis.wheelGestureActive = false;\n\t\tthis.isDragging = false;\n\t\tthis.isZooming = false;\n\t}\n}\n"],
5
- "mappings": ";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,uBAAuB;AAGhC,IAAM,kBAAkB;AAExB,IAAM,sBAAsB;AAE5B,IAAM,0BAA0B;AAQhC,SAAS,sBAAuB,OAG9B;AACD,SAAO,MAAM,QACV,EAAE,OAAO,MAAM,MAAM,cAAc,QAAQ,MAAM,MAAM,cAAc,IACrE,EAAE,OAAO,GAAG,QAAQ,EAAE;AAC1B;AASA,SAAS,iBAAkB,IAAW,IAAoB;AACzD,QAAM,KAAK,GAAG,UAAU,GAAG;AAC3B,QAAM,KAAK,GAAG,UAAU,GAAG;AAC3B,SAAO,KAAK,KA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;AACA,aAAK,QAAQ,QAAQ,QAAS,OAAQ;AACtC;AAAA,MACD;AAAA,MACA,KAAK;AAAA,MACL,KAAK,KAAK;AACT,YAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAS;AACzC;AAAA,QACD;AACA,UAAE,eAAe;AACjB,aAAK,QAAQ,QAAQ,aAAc,EAAE,WAAW,KAAK,CAAE;AACvD;AAAA,MACD;AAAA,MACA,KAAK;AAAA,MACL,KAAK,KAAK;AACT,YAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAW;AACvD;AAAA,QACD;AACA,UAAE,eAAe;AACjB,aAAK,QAAQ,QAAQ,aAAc,YAAa;AAChD;AAAA,MACD;AAAA,MACA,KAAK;AAAA,MACL,KAAK,KAAK;AACT,YAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAW;AACvD;AAAA,QACD;AACA,UAAE,eAAe;AACjB,aAAK,QAAQ,QAAQ,aAAc,UAAW;AAC9C;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,UAAgB;AACf,yBAAsB,KAAK,KAAM;AACjC,iBAAc,KAAK,SAAU;AAC7B,iBAAc,KAAK,iBAAkB;AACrC,SAAK,eAAe;AACpB,SAAK,eAAe;AACpB,SAAK,iBAAiB;AACtB,SAAK,iBAAiB;AACtB,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,UAAU;AAMf,SAAK,qBAAqB;AAC1B,SAAK,aAAa;AAClB,SAAK,YAAY;AAAA,EAClB;AACD;",
4
+ "sourcesContent": ["import type { CropperState, NormalizedPoint, Size } from './types';\nimport {\n\tDEFAULT_KEYBOARD_STEP,\n\tDEFAULT_WHEEL_ZOOM_SPEED,\n\tKEYBOARD_SHIFT_STEP_MULTIPLIER,\n\tMIN_ZOOM,\n\tMAX_ZOOM,\n} from './constants';\nimport { restrictPanZoom } from './containment';\n\n/** Time window for detecting a double-tap gesture (ms). */\nconst DOUBLE_TAP_TIME = 300;\n/** Max distance between taps to count as a double-tap (px). */\nconst DOUBLE_TAP_DISTANCE = 30;\n/** Duration of the zoom animation state (ms). */\nconst ZOOM_ANIMATION_DURATION = 200;\n\n/**\n * Get the natural image dimensions from cropper state, falling back to 1x1.\n *\n * @param state The current cropper state.\n * @return The image dimensions.\n */\nfunction getImageSizeFromState( state: CropperState ): {\n\twidth: number;\n\theight: number;\n} {\n\treturn state.image\n\t\t? { width: state.image.naturalWidth, height: state.image.naturalHeight }\n\t\t: { width: 1, height: 1 };\n}\n\n/**\n * Get the distance between two touch points.\n *\n * @param t1 The first touch.\n * @param t2 The second touch.\n * @return The pixel distance between the two touches.\n */\nfunction getTouchDistance( t1: Touch, t2: Touch ): number {\n\tconst dx = t1.clientX - t2.clientX;\n\tconst dy = t1.clientY - t2.clientY;\n\treturn Math.sqrt( dx * dx + dy * dy );\n}\n\n/**\n * Status reported by the interaction controller when drag/zoom state changes.\n */\nexport interface InteractionStatus {\n\t/** Whether a drag (pan) interaction is in progress. */\n\tisDragging: boolean;\n\t/** Whether a double-tap zoom animation is in progress. */\n\tisZooming: boolean;\n}\n\n/**\n * State updates the interaction controller can request from its host UI.\n */\nexport interface CropperInteractionActions {\n\t/** Set the image pan offset in normalized coordinates. */\n\tsetPan: ( pan: NormalizedPoint ) => void;\n\t/**\n\t * Set the zoom level. Cursorless surfaces (slider, keyboard `+`/`-`)\n\t * rely on this anchoring at the crop center; pointer-driven zoom\n\t * paths use `setZoomAtPoint` with an explicit focal point instead.\n\t */\n\tsetZoom: ( zoom: number ) => void;\n\t/** Set zoom and pan together for focal-point zoom. */\n\tsetZoomAtPoint: ( zoom: number, pan: NormalizedPoint ) => void;\n\t/** Snap rotate by 90 degrees. */\n\tsnapRotate90: ( direction: 1 | -1 ) => void;\n\t/** Toggle flip on the given axis. */\n\ttoggleFlip?: ( direction: 'horizontal' | 'vertical' ) => void;\n}\n\n/**\n * Options for creating an InteractionController.\n *\n * Scalar options (minZoom, maxZoom, etc.) are read lazily on each\n * interaction, so changes to the options object take effect immediately\n * without recreating the controller.\n */\nexport interface InteractionControllerOptions {\n\t/** Returns the current cropper state. Called on every interaction. */\n\tgetState: () => CropperState;\n\t/** State updates the interaction controller can request from its host UI. */\n\tactions: CropperInteractionActions;\n\t/** Returns the container dimensions in pixels. */\n\tgetContainerSize: () => Size;\n\t/** Returns the rendered image dimensions in pixels, if available. */\n\tgetImageSize: () => Size | undefined;\n\t/** Minimum zoom level. Defaults to MIN_ZOOM. Read lazily. */\n\tminZoom?: number;\n\t/** Maximum zoom level. Defaults to MAX_ZOOM. Read lazily. */\n\tmaxZoom?: number;\n\t/** Zoom speed multiplier for wheel events. Defaults to 0.0025. Read lazily. */\n\tzoomSpeed?: number;\n\t/**\n\t * Pan step size in normalized coords for keyboard events.\n\t * Defaults to 0.01. Read lazily. Shift multiplies it by 10.\n\t */\n\tkeyboardStep?: number;\n\t/** Zoom level for double-tap zoom. Defaults to 2. Read lazily. */\n\tdoubleTapZoom?: number;\n\t/** Fires when a continuous gesture begins (pan drag, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointer release). */\n\tonGestureEnd?: () => void;\n\t/** Called when isDragging or isZooming changes. */\n\tonStatusChange?: ( status: InteractionStatus ) => void;\n}\n\n/**\n * Framework-agnostic imperative controller for image cropper interactions.\n *\n * Handles mouse, touch, and keyboard event processing for pan, zoom,\n * and crop manipulation. Uses requestAnimationFrame for drag/pinch\n * updates to avoid layout thrashing.\n *\n * The controller does not register DOM event listeners itself — that is the\n * responsibility of the UI layer (React hook, Vue directive, or vanilla JS).\n * Instead it exposes `handlePointerDown`, `handleWheel`, `handleTouchStart`,\n * and `handleKeyDown` methods that the UI layer calls with native DOM events.\n *\n * Scalar options (minZoom, maxZoom, zoomSpeed, keyboardStep, doubleTapZoom)\n * are read lazily from `this.options` on each interaction, so the UI layer\n * can update them without recreating the controller.\n *\n * Call `destroy()` to clean up timers and pending animation frames.\n */\nexport class InteractionController {\n\tprivate readonly options: InteractionControllerOptions;\n\n\t/** Current drag/zoom status. */\n\tprivate isDragging = false;\n\tprivate isZooming = false;\n\n\t/** Active drag state during pointer interactions. */\n\tprivate drag: {\n\t\tstartX: number;\n\t\tstartY: number;\n\t\tstartPanX: number;\n\t\tstartPanY: number;\n\t} | null = null;\n\n\t/** Active touch state during touch interactions. */\n\tprivate touch: {\n\t\t/** Finger distance at pinch start (0 until pinch detected). */\n\t\tstartDistance: number;\n\t\t/** Zoom level when pinch was detected. */\n\t\tstartZoom: number;\n\t\t/** First touch X/Y (for single-finger pan delta). */\n\t\tlastTouchX: number;\n\t\tlastTouchY: number;\n\t\t/** Pan when gesture started. */\n\t\tstartPanX: number;\n\t\tstartPanY: number;\n\t\t/** Container rect snapshot for focal-point math. */\n\t\tcontainerRect?: DOMRect;\n\t\t/** Midpoint of two fingers when pinch was detected. */\n\t\tstartMidX: number;\n\t\tstartMidY: number;\n\t\t/** Whether pinch was ever detected during this gesture. */\n\t\tdidPinch: boolean;\n\t\t/** Whether any dispatch has occurred (prevents dispatching before first move). */\n\t\tmoved: boolean;\n\t} | null = null;\n\n\t/** Cleanup function for active touch listeners on document. */\n\tprivate touchCleanup: ( () => void ) | null = null;\n\n\t/**\n\t * Cleanup function for active pointer-drag listeners on the\n\t * captured element. Set while a pointer drag is in progress so\n\t * `destroy()` can tear the drag down cleanly if the consumer\n\t * unmounts mid-drag. Cleared on pointerup/lostpointercapture.\n\t */\n\tprivate pointerCleanup: ( () => void ) | null = null;\n\n\t/** Last tap info for double-tap detection. */\n\tprivate lastTap: {\n\t\ttime: number;\n\t\tx: number;\n\t\ty: number;\n\t} | null = null;\n\n\t/** Timer for the zoom animation state (double-tap). */\n\tprivate zoomTimer: ReturnType< typeof setTimeout > | undefined;\n\n\t/** Timer for wheel gesture debounce. */\n\tprivate wheelGestureTimer: ReturnType< typeof setTimeout > | undefined;\n\n\t/** Whether a wheel gesture is currently active. */\n\tprivate wheelGestureActive = false;\n\n\t/** Current requestAnimationFrame ID. */\n\tprivate rafId = 0;\n\n\tconstructor( options: InteractionControllerOptions ) {\n\t\tthis.options = options;\n\t}\n\n\t/** Read minZoom lazily so option changes take effect immediately. */\n\tprivate get minZoom(): number {\n\t\treturn this.options.minZoom ?? MIN_ZOOM;\n\t}\n\n\t/** Read maxZoom lazily so option changes take effect immediately. */\n\tprivate get maxZoom(): number {\n\t\treturn this.options.maxZoom ?? MAX_ZOOM;\n\t}\n\n\t/** Read zoomSpeed lazily so option changes take effect immediately. */\n\tprivate get zoomSpeed(): number {\n\t\treturn this.options.zoomSpeed ?? DEFAULT_WHEEL_ZOOM_SPEED;\n\t}\n\n\t/** Read keyboardStep lazily so option changes take effect immediately. */\n\tprivate get keyboardStep(): number {\n\t\treturn this.options.keyboardStep ?? DEFAULT_KEYBOARD_STEP;\n\t}\n\n\t/**\n\t * Get the keyboard pan step, including modifier-based coarse movement.\n\t *\n\t * @param event The native KeyboardEvent.\n\t * @return The normalized pan step.\n\t */\n\tprivate getKeyboardStep( event: KeyboardEvent ): number {\n\t\treturn event.shiftKey\n\t\t\t? this.keyboardStep * KEYBOARD_SHIFT_STEP_MULTIPLIER\n\t\t\t: this.keyboardStep;\n\t}\n\n\t/** Read doubleTapZoom lazily so option changes take effect immediately. */\n\tprivate get doubleTapZoom(): number {\n\t\treturn this.options.doubleTapZoom ?? 2;\n\t}\n\n\t/**\n\t * Update the drag/zoom status and notify via callback if changed.\n\t *\n\t * @param update Partial status with isDragging and/or isZooming.\n\t */\n\tprivate setStatus(\n\t\tupdate: Partial< { isDragging: boolean; isZooming: boolean } >\n\t): void {\n\t\tlet changed = false;\n\t\tif (\n\t\t\tupdate.isDragging !== undefined &&\n\t\t\tupdate.isDragging !== this.isDragging\n\t\t) {\n\t\t\tthis.isDragging = update.isDragging;\n\t\t\tchanged = true;\n\t\t}\n\t\tif (\n\t\t\tupdate.isZooming !== undefined &&\n\t\t\tupdate.isZooming !== this.isZooming\n\t\t) {\n\t\t\tthis.isZooming = update.isZooming;\n\t\t\tchanged = true;\n\t\t}\n\t\tif ( changed ) {\n\t\t\tthis.options.onStatusChange?.( {\n\t\t\t\tisDragging: this.isDragging,\n\t\t\t\tisZooming: this.isZooming,\n\t\t\t} );\n\t\t}\n\t}\n\n\t/**\n\t * Handle a pointer-down event on the container element.\n\t *\n\t * Initiates a drag (pan) interaction. Captures the pointer on the\n\t * provided element and registers pointermove/pointerup/lostpointercapture\n\t * listeners for the duration of the drag.\n\t *\n\t * @param e The native PointerEvent.\n\t * @param el The DOM element to capture the pointer on.\n\t */\n\thandlePointerDown( e: PointerEvent, el: HTMLElement ): void {\n\t\t// Only handle primary button (left click / first touch).\n\t\tif ( e.button !== 0 ) {\n\t\t\treturn;\n\t\t}\n\t\t// Touch gestures are handled by touchstart/touchmove. Starting the\n\t\t// pointer drag path too can briefly toggle drag UI before pinch begins.\n\t\tif ( e.pointerType === 'touch' ) {\n\t\t\treturn;\n\t\t}\n\t\te.preventDefault();\n\n\t\t// Blur any focused handle so its focus ring doesn't linger,\n\t\t// but leave the canvas itself alone so keyboard control works after drag.\n\t\tconst ownerDoc = el.ownerDocument;\n\t\tif (\n\t\t\townerDoc?.activeElement instanceof HTMLElement &&\n\t\t\townerDoc.activeElement !== el\n\t\t) {\n\t\t\townerDoc.activeElement.blur();\n\t\t}\n\n\t\tel.focus();\n\n\t\t// Capture pointer so drag works across iframe boundaries.\n\t\tel.setPointerCapture( e.pointerId );\n\n\t\t// End a pending wheel gesture now, so its debounce timer cannot\n\t\t// fire mid-drag and end the drag's gesture along with it.\n\t\tif ( this.wheelGestureActive ) {\n\t\t\tclearTimeout( this.wheelGestureTimer );\n\t\t\tthis.wheelGestureActive = false;\n\t\t\tthis.options.onGestureEnd?.();\n\t\t}\n\n\t\tthis.setStatus( { isDragging: true } );\n\t\tthis.options.onGestureStart?.();\n\n\t\tconst currentState = this.options.getState();\n\t\tthis.drag = {\n\t\t\tstartX: e.clientX,\n\t\t\tstartY: e.clientY,\n\t\t\tstartPanX: currentState.pan.x,\n\t\t\tstartPanY: currentState.pan.y,\n\t\t};\n\n\t\tconst onPointerMove = ( moveEvent: Event ) => {\n\t\t\tconst drag = this.drag;\n\t\t\tif ( ! drag ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst pe = moveEvent as PointerEvent;\n\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tthis.rafId = requestAnimationFrame( () => {\n\t\t\t\tconst s = this.options.getState();\n\t\t\t\tconst imgSize = this.options.getImageSize();\n\t\t\t\tconst containerSize = this.options.getContainerSize();\n\t\t\t\tconst panSize = imgSize ?? containerSize;\n\t\t\t\tconst deltaX =\n\t\t\t\t\tpanSize.width > 0\n\t\t\t\t\t\t? ( pe.clientX - drag.startX ) / panSize.width\n\t\t\t\t\t\t: 0;\n\t\t\t\tconst deltaY =\n\t\t\t\t\tpanSize.height > 0\n\t\t\t\t\t\t? ( pe.clientY - drag.startY ) / panSize.height\n\t\t\t\t\t\t: 0;\n\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...s,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: drag.startPanX + deltaX,\n\t\t\t\t\t\t\ty: drag.startPanY + deltaY,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\ts.cropRect\n\t\t\t\t);\n\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t} );\n\t\t};\n\n\t\tconst removeListeners = () => {\n\t\t\tel.removeEventListener( 'pointermove', onPointerMove );\n\t\t\tel.removeEventListener( 'pointerup', onPointerUp );\n\t\t\tel.removeEventListener( 'lostpointercapture', onPointerUp );\n\t\t};\n\n\t\tconst onPointerUp = () => {\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\tthis.options.onGestureEnd?.();\n\t\t\tthis.drag = null;\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tremoveListeners();\n\t\t\tthis.pointerCleanup = null;\n\t\t};\n\n\t\tel.addEventListener( 'pointermove', onPointerMove );\n\t\tel.addEventListener( 'pointerup', onPointerUp );\n\t\tel.addEventListener( 'lostpointercapture', onPointerUp );\n\t\t// Expose cleanup to destroy() in case the consumer unmounts\n\t\t// mid-drag. The pending rAF is cancelled in destroy().\n\t\tthis.pointerCleanup = removeListeners;\n\t}\n\n\t/**\n\t * Handle a wheel event on the container element.\n\t *\n\t * Implements focal-point zoom: the point under the cursor stays\n\t * stationary on screen while the zoom level changes.\n\t *\n\t * Must be registered with `{ passive: false }` to allow preventDefault.\n\t *\n\t * @param e The native WheelEvent.\n\t */\n\thandleWheel( e: WheelEvent ): void {\n\t\te.preventDefault();\n\n\t\tif ( this.drag ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Debounced gesture boundaries for wheel zoom.\n\t\t// Start on first wheel event, end after 300ms of no events.\n\t\tif ( ! this.wheelGestureActive ) {\n\t\t\tthis.wheelGestureActive = true;\n\t\t\tthis.options.onGestureStart?.();\n\t\t}\n\t\tclearTimeout( this.wheelGestureTimer );\n\t\tthis.wheelGestureTimer = setTimeout( () => {\n\t\t\tthis.wheelGestureActive = false;\n\t\t\tthis.options.onGestureEnd?.();\n\t\t}, DOUBLE_TAP_TIME );\n\n\t\tconst s = this.options.getState();\n\t\tconst delta = -e.deltaY * this.zoomSpeed;\n\t\tconst newZoom = Math.min(\n\t\t\tthis.maxZoom,\n\t\t\tMath.max( this.minZoom, s.zoom + delta )\n\t\t);\n\n\t\tif ( newZoom === s.zoom ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Focal-point zoom: keep the point under the cursor stationary.\n\t\tconst containerSize = this.options.getContainerSize();\n\t\tconst imgSize = this.options.getImageSize();\n\t\tconst visSize = imgSize ?? containerSize;\n\t\tconst target = e.currentTarget;\n\t\tconst rect =\n\t\t\ttarget instanceof Element\n\t\t\t\t? target.getBoundingClientRect()\n\t\t\t\t: undefined;\n\t\tif ( visSize.width > 0 && visSize.height > 0 && rect ) {\n\t\t\tconst fx = e.clientX - rect.left - containerSize.width / 2;\n\t\t\tconst fy = e.clientY - rect.top - containerSize.height / 2;\n\n\t\t\tconst zoomRatio = 1 - newZoom / s.zoom;\n\t\t\tconst focalNormX = fx / visSize.width;\n\t\t\tconst focalNormY = fy / visSize.height;\n\t\t\tconst newCropX = s.pan.x + ( focalNormX - s.pan.x ) * zoomRatio;\n\t\t\tconst newCropY = s.pan.y + ( focalNormY - s.pan.y ) * zoomRatio;\n\n\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t{ ...s, zoom: newZoom, pan: { x: newCropX, y: newCropY } },\n\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\ts.cropRect\n\t\t\t);\n\t\t\tthis.options.actions.setZoomAtPoint( newZoom, clampedCrop );\n\t\t} else {\n\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t}\n\t}\n\n\t/**\n\t * Handle a touch-start event on the container element.\n\t *\n\t * Supports single-finger pan, two-finger pinch zoom, and\n\t * double-tap to toggle between fit and 2x zoom. Registers\n\t * touchmove/touchend/touchcancel on the provided document for the\n\t * duration of the gesture.\n\t *\n\t * @param e The native TouchEvent.\n\t * @param containerRect The bounding rect of the container element.\n\t * @param doc The document to register move/end listeners on.\n\t * Defaults to globalThis.document. Pass the iframe's\n\t * contentDocument when running inside an iframe.\n\t */\n\thandleTouchStart(\n\t\te: TouchEvent,\n\t\tcontainerRect: DOMRect,\n\t\tdoc: Document = document\n\t): void {\n\t\t// Second finger arriving during an existing gesture — snapshot\n\t\t// pinch start values. handleTouchMove will detect 2 touches and\n\t\t// handle pinch automatically.\n\t\tif ( this.touch && e.touches.length === 2 ) {\n\t\t\tconst s = this.options.getState();\n\t\t\tconst distance = getTouchDistance( e.touches[ 0 ], e.touches[ 1 ] );\n\t\t\tconst midX =\n\t\t\t\t( e.touches[ 0 ].clientX + e.touches[ 1 ].clientX ) / 2;\n\t\t\tconst midY =\n\t\t\t\t( e.touches[ 0 ].clientY + e.touches[ 1 ].clientY ) / 2;\n\t\t\tthis.touch.didPinch = true;\n\t\t\tthis.touch.startDistance = distance;\n\t\t\tthis.touch.startZoom = s.zoom;\n\t\t\tthis.touch.startPanX = s.pan.x;\n\t\t\tthis.touch.startPanY = s.pan.y;\n\t\t\tthis.touch.startMidX = midX;\n\t\t\tthis.touch.startMidY = midY;\n\t\t\tthis.touch.containerRect = containerRect;\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( e.touches.length === 1 ) {\n\t\t\tconst tapX = e.touches[ 0 ].clientX;\n\t\t\tconst tapY = e.touches[ 0 ].clientY;\n\t\t\tif ( this.tryDoubleTap( e, tapX, tapY, containerRect ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentState = this.options.getState();\n\n\t\t\t// Record touch state. Don't decide pan vs pinch yet —\n\t\t\t// that happens in handleTouchMove based on touches.length.\n\t\t\tthis.touch = {\n\t\t\t\tstartDistance: 0,\n\t\t\t\tstartZoom: currentState.zoom,\n\t\t\t\tlastTouchX: e.touches[ 0 ].clientX,\n\t\t\t\tlastTouchY: e.touches[ 0 ].clientY,\n\t\t\t\tstartPanX: currentState.pan.x,\n\t\t\t\tstartPanY: currentState.pan.y,\n\t\t\t\tcontainerRect,\n\t\t\t\tstartMidX: 0,\n\t\t\t\tstartMidY: 0,\n\t\t\t\tdidPinch: false,\n\t\t\t\tmoved: false,\n\t\t\t};\n\t\t\tthis.options.onGestureStart?.();\n\t\t} else if ( e.touches.length === 2 ) {\n\t\t\t// Both fingers landed simultaneously (rare but possible).\n\t\t\tconst currentState = this.options.getState();\n\t\t\tconst distance = getTouchDistance( e.touches[ 0 ], e.touches[ 1 ] );\n\t\t\tconst midX =\n\t\t\t\t( e.touches[ 0 ].clientX + e.touches[ 1 ].clientX ) / 2;\n\t\t\tconst midY =\n\t\t\t\t( e.touches[ 0 ].clientY + e.touches[ 1 ].clientY ) / 2;\n\t\t\tthis.touch = {\n\t\t\t\tstartDistance: distance,\n\t\t\t\tstartZoom: currentState.zoom,\n\t\t\t\tlastTouchX: 0,\n\t\t\t\tlastTouchY: 0,\n\t\t\t\tstartPanX: currentState.pan.x,\n\t\t\t\tstartPanY: currentState.pan.y,\n\t\t\t\tcontainerRect,\n\t\t\t\tstartMidX: midX,\n\t\t\t\tstartMidY: midY,\n\t\t\t\tdidPinch: true,\n\t\t\t\tmoved: false,\n\t\t\t};\n\t\t\tthis.options.onGestureStart?.();\n\t\t}\n\n\t\tconst onTouchEnd = () => {\n\t\t\tthis.touch = null;\n\t\t\tthis.touchCleanup = null;\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tdoc.removeEventListener( 'touchmove', this.handleTouchMove );\n\t\t\tdoc.removeEventListener( 'touchend', onTouchEnd );\n\t\t\tdoc.removeEventListener( 'touchcancel', onTouchEnd );\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\tthis.options.onGestureEnd?.();\n\t\t};\n\n\t\t// Clean up any previous touch listeners before registering new ones.\n\t\tthis.touchCleanup?.();\n\n\t\tdoc.addEventListener( 'touchmove', this.handleTouchMove, {\n\t\t\tpassive: false,\n\t\t} );\n\t\tdoc.addEventListener( 'touchend', onTouchEnd );\n\t\tdoc.addEventListener( 'touchcancel', onTouchEnd );\n\n\t\tthis.touchCleanup = onTouchEnd;\n\t}\n\n\t// Handle a touchmove event during an active touch gesture. Decides pinch\n\t// vs. pan based on current `moveEvent.touches.length`, so the gesture\n\t// can transition between modes without timing sensitivity (e.g. fingers\n\t// landing 0ms vs 200ms apart). Arrow-property binding so `this` stays\n\t// attached when used as an event listener.\n\tprivate handleTouchMove = ( moveEvent: TouchEvent ): void => {\n\t\tconst touch = this.touch;\n\t\tif ( ! touch ) {\n\t\t\treturn;\n\t\t}\n\t\tmoveEvent.preventDefault();\n\n\t\tcancelAnimationFrame( this.rafId );\n\t\tthis.rafId = requestAnimationFrame( () => {\n\t\t\tconst s = this.options.getState();\n\n\t\t\tif ( moveEvent.touches.length === 2 ) {\n\t\t\t\t// Two fingers → always pinch, regardless of how gesture\n\t\t\t\t// started. Initialize pinch state on first 2-finger move.\n\t\t\t\tif ( ! touch.didPinch ) {\n\t\t\t\t\ttouch.didPinch = true;\n\t\t\t\t\ttouch.startDistance = getTouchDistance(\n\t\t\t\t\t\tmoveEvent.touches[ 0 ],\n\t\t\t\t\t\tmoveEvent.touches[ 1 ]\n\t\t\t\t\t);\n\t\t\t\t\ttouch.startZoom = s.zoom;\n\t\t\t\t\ttouch.startPanX = s.pan.x;\n\t\t\t\t\ttouch.startPanY = s.pan.y;\n\t\t\t\t\ttouch.startMidX =\n\t\t\t\t\t\t( moveEvent.touches[ 0 ].clientX +\n\t\t\t\t\t\t\tmoveEvent.touches[ 1 ].clientX ) /\n\t\t\t\t\t\t2;\n\t\t\t\t\ttouch.startMidY =\n\t\t\t\t\t\t( moveEvent.touches[ 0 ].clientY +\n\t\t\t\t\t\t\tmoveEvent.touches[ 1 ].clientY ) /\n\t\t\t\t\t\t2;\n\t\t\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst latestContainerSize = this.options.getContainerSize();\n\t\t\t\tconst latestImageSize = this.options.getImageSize();\n\n\t\t\t\t// Pinch zoom with focal point at finger midpoint,\n\t\t\t\t// plus simultaneous pan from midpoint drift.\n\t\t\t\tconst t0 = moveEvent.touches[ 0 ];\n\t\t\t\tconst t1 = moveEvent.touches[ 1 ];\n\t\t\t\tconst currentDistance = getTouchDistance( t0, t1 );\n\t\t\t\tconst ratio = currentDistance / touch.startDistance;\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, touch.startZoom * ratio )\n\t\t\t\t);\n\n\t\t\t\tconst visSize = latestImageSize ?? latestContainerSize;\n\t\t\t\tconst rect = touch.containerRect;\n\t\t\t\tif ( visSize.width > 0 && visSize.height > 0 && rect ) {\n\t\t\t\t\t// Current midpoint.\n\t\t\t\t\tconst mx =\n\t\t\t\t\t\t( t0.clientX + t1.clientX ) / 2 -\n\t\t\t\t\t\trect.left -\n\t\t\t\t\t\tlatestContainerSize.width / 2;\n\t\t\t\t\tconst my =\n\t\t\t\t\t\t( t0.clientY + t1.clientY ) / 2 -\n\t\t\t\t\t\trect.top -\n\t\t\t\t\t\tlatestContainerSize.height / 2;\n\n\t\t\t\t\t// Pan from midpoint drift (fingers moving together).\n\t\t\t\t\tconst startMx =\n\t\t\t\t\t\ttouch.startMidX -\n\t\t\t\t\t\trect.left -\n\t\t\t\t\t\tlatestContainerSize.width / 2;\n\t\t\t\t\tconst startMy =\n\t\t\t\t\t\ttouch.startMidY -\n\t\t\t\t\t\trect.top -\n\t\t\t\t\t\tlatestContainerSize.height / 2;\n\t\t\t\t\tconst panDx =\n\t\t\t\t\t\tvisSize.width > 0\n\t\t\t\t\t\t\t? ( mx - startMx ) / visSize.width\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tconst panDy =\n\t\t\t\t\t\tvisSize.height > 0\n\t\t\t\t\t\t\t? ( my - startMy ) / visSize.height\n\t\t\t\t\t\t\t: 0;\n\n\t\t\t\t\t// Focal-point zoom correction. Keep this based on the\n\t\t\t\t\t// pinch-start state; using the current reducer state here\n\t\t\t\t\t// compounds prior touchmove frames and makes a fixed pinch\n\t\t\t\t\t// center drift after the image is already zoomed or panned.\n\t\t\t\t\tconst zoomRatio =\n\t\t\t\t\t\ttouch.startZoom !== 0\n\t\t\t\t\t\t\t? 1 - newZoom / touch.startZoom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tconst startFocalNormX = startMx / visSize.width;\n\t\t\t\t\tconst startFocalNormY = startMy / visSize.height;\n\n\t\t\t\t\t// Combined: midpoint drift + zoom around the pinch-start\n\t\t\t\t\t// midpoint, so moving both fingers together pans while\n\t\t\t\t\t// symmetric pinches keep the start center stationary.\n\t\t\t\t\tconst newCropX =\n\t\t\t\t\t\ttouch.startPanX +\n\t\t\t\t\t\tpanDx +\n\t\t\t\t\t\t( startFocalNormX - touch.startPanX ) * zoomRatio;\n\t\t\t\t\tconst newCropY =\n\t\t\t\t\t\ttouch.startPanY +\n\t\t\t\t\t\tpanDy +\n\t\t\t\t\t\t( startFocalNormY - touch.startPanY ) * zoomRatio;\n\n\t\t\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\tzoom: newZoom,\n\t\t\t\t\t\t\tpan: { x: newCropX, y: newCropY },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\t\ts.cropRect\n\t\t\t\t\t);\n\t\t\t\t\tthis.options.actions.setZoomAtPoint( newZoom, clampedCrop );\n\t\t\t\t} else if ( newZoom !== s.zoom ) {\n\t\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\t}\n\t\t\t} else if ( moveEvent.touches.length === 1 && ! touch.didPinch ) {\n\t\t\t\t// One finger and no pinch ever detected → pan.\n\t\t\t\t// If fingers went 2→1 (didPinch is true), we do NOT\n\t\t\t\t// switch to pan — avoids accidental pan after releasing\n\t\t\t\t// one finger from a pinch.\n\t\t\t\tif ( ! touch.moved ) {\n\t\t\t\t\ttouch.moved = true;\n\t\t\t\t\tthis.setStatus( { isDragging: true } );\n\t\t\t\t}\n\t\t\t\tconst panImageSize = this.options.getImageSize();\n\t\t\t\tconst panContainerSize = this.options.getContainerSize();\n\t\t\t\tconst panSize = panImageSize ?? panContainerSize;\n\t\t\t\tconst deltaX =\n\t\t\t\t\tpanSize.width > 0\n\t\t\t\t\t\t? ( moveEvent.touches[ 0 ].clientX -\n\t\t\t\t\t\t\t\ttouch.lastTouchX ) /\n\t\t\t\t\t\t\tpanSize.width\n\t\t\t\t\t\t: 0;\n\t\t\t\tconst deltaY =\n\t\t\t\t\tpanSize.height > 0\n\t\t\t\t\t\t? ( moveEvent.touches[ 0 ].clientY -\n\t\t\t\t\t\t\t\ttouch.lastTouchY ) /\n\t\t\t\t\t\t\tpanSize.height\n\t\t\t\t\t\t: 0;\n\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...s,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: touch.startPanX + deltaX,\n\t\t\t\t\t\t\ty: touch.startPanY + deltaY,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\ts.cropRect\n\t\t\t\t);\n\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t}\n\t\t} );\n\t};\n\n\t// Handle double-tap-to-toggle-zoom. On a second tap within the configured\n\t// time/distance threshold, toggles zoom between `minZoom` and\n\t// `doubleTapZoom` around the tap point and dispatches. Returns `true` if\n\t// the tap was handled as a double-tap (caller should early-return),\n\t// `false` otherwise (caller proceeds with normal single-tap handling).\n\t// Either way, records the tap for next time.\n\tprivate tryDoubleTap(\n\t\te: TouchEvent,\n\t\ttapX: number,\n\t\ttapY: number,\n\t\tcontainerRect: DOMRect\n\t): boolean {\n\t\tconst now = Date.now();\n\t\tconst lastTap = this.lastTap;\n\t\tif ( ! lastTap ) {\n\t\t\tthis.lastTap = { time: now, x: tapX, y: tapY };\n\t\t\treturn false;\n\t\t}\n\t\tconst timeDelta = now - lastTap.time;\n\t\tconst distDelta = Math.sqrt(\n\t\t\t( tapX - lastTap.x ) ** 2 + ( tapY - lastTap.y ) ** 2\n\t\t);\n\t\tconst isDoubleTap =\n\t\t\ttimeDelta < DOUBLE_TAP_TIME && distDelta < DOUBLE_TAP_DISTANCE;\n\t\tif ( ! isDoubleTap ) {\n\t\t\tthis.lastTap = { time: now, x: tapX, y: tapY };\n\t\t\treturn false;\n\t\t}\n\n\t\t// It's a double-tap — suppress browser zoom.\n\t\te.preventDefault();\n\t\tthis.lastTap = null;\n\n\t\tconst currentState = this.options.getState();\n\t\tconst containerSize = this.options.getContainerSize();\n\t\tconst imgSize = this.options.getImageSize();\n\n\t\t// Toggle: if past halfway to doubleTapZoom, go back to 1x.\n\t\tconst targetZoom =\n\t\t\tcurrentState.zoom > ( this.minZoom + this.doubleTapZoom ) / 2\n\t\t\t\t? this.minZoom\n\t\t\t\t: this.doubleTapZoom;\n\t\tconst visSize = imgSize ?? containerSize;\n\n\t\t// Enable zoom animation before dispatching.\n\t\tthis.setStatus( { isZooming: true } );\n\t\tclearTimeout( this.zoomTimer );\n\t\tthis.zoomTimer = setTimeout( () => {\n\t\t\tthis.setStatus( { isZooming: false } );\n\t\t}, ZOOM_ANIMATION_DURATION );\n\n\t\t// Double-tap bypasses the normal handleTouchStart gesture path so\n\t\t// onGestureStart/End are never called — fire them here so undo\n\t\t// receives a proper boundary around this discrete zoom action.\n\t\tthis.options.onGestureStart?.();\n\n\t\tif ( visSize.width > 0 && visSize.height > 0 ) {\n\t\t\tconst fx = tapX - containerRect.left - containerSize.width / 2;\n\t\t\tconst fy = tapY - containerRect.top - containerSize.height / 2;\n\n\t\t\tconst zoomRatio = 1 - targetZoom / currentState.zoom;\n\t\t\tconst focalNormX = fx / visSize.width;\n\t\t\tconst focalNormY = fy / visSize.height;\n\t\t\tconst newCropX =\n\t\t\t\tcurrentState.pan.x +\n\t\t\t\t( focalNormX - currentState.pan.x ) * zoomRatio;\n\t\t\tconst newCropY =\n\t\t\t\tcurrentState.pan.y +\n\t\t\t\t( focalNormY - currentState.pan.y ) * zoomRatio;\n\n\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t{\n\t\t\t\t\t...currentState,\n\t\t\t\t\tzoom: targetZoom,\n\t\t\t\t\tpan: { x: newCropX, y: newCropY },\n\t\t\t\t},\n\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\tcurrentState.cropRect\n\t\t\t);\n\t\t\tthis.options.actions.setZoomAtPoint( targetZoom, clampedCrop );\n\t\t} else {\n\t\t\tthis.options.actions.setZoom( targetZoom );\n\t\t}\n\n\t\tthis.options.onGestureEnd?.();\n\t\treturn true;\n\t}\n\n\t/**\n\t * Handle a keydown event on the container element.\n\t *\n\t * Supports arrow keys for panning, +/- for zoom, and r/R for rotation.\n\t *\n\t * @param e The native KeyboardEvent.\n\t */\n\thandleKeyDown( e: KeyboardEvent ): void {\n\t\tconst currentState = this.options.getState();\n\n\t\tswitch ( e.key ) {\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x,\n\t\t\t\t\t\t\ty: currentState.pan.y + keyboardStep,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x,\n\t\t\t\t\t\t\ty: currentState.pan.y - keyboardStep,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowLeft': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x + keyboardStep,\n\t\t\t\t\t\t\ty: currentState.pan.y,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowRight': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x - keyboardStep,\n\t\t\t\t\t\t\ty: currentState.pan.y,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '+':\n\t\t\tcase '=': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, currentState.zoom + 0.5 )\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '-':\n\t\t\tcase '_': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, currentState.zoom - 0.5 )\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'r':\n\t\t\tcase 'R': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.snapRotate90( e.shiftKey ? -1 : 1 );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'h':\n\t\t\tcase 'H': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey || e.shiftKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.toggleFlip?.( 'horizontal' );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'v':\n\t\t\tcase 'V': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey || e.shiftKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.toggleFlip?.( 'vertical' );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up all timers, animation frames, and active touch listeners.\n\t *\n\t * Must be called when the controller is no longer needed (e.g., on\n\t * component unmount or element removal).\n\t */\n\tdestroy(): void {\n\t\tcancelAnimationFrame( this.rafId );\n\t\tclearTimeout( this.zoomTimer );\n\t\tclearTimeout( this.wheelGestureTimer );\n\t\tthis.touchCleanup?.();\n\t\tthis.touchCleanup = null;\n\t\tthis.pointerCleanup?.();\n\t\tthis.pointerCleanup = null;\n\t\tthis.drag = null;\n\t\tthis.touch = null;\n\t\tthis.lastTap = null;\n\t\t// Reset the gesture bookkeeping too. The timers above are cancelled\n\t\t// rather than run, so these flags would otherwise stay set: a stale\n\t\t// `wheelGestureActive` suppresses the next wheel gesture's start,\n\t\t// and `setStatus` dedupes against `isDragging` / `isZooming`, so a\n\t\t// stale value swallows the next real change.\n\t\tthis.wheelGestureActive = false;\n\t\tthis.isDragging = false;\n\t\tthis.isZooming = false;\n\t}\n}\n"],
5
+ "mappings": ";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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,iBAAc,KAAK,SAAU;AAC7B,iBAAc,KAAK,iBAAkB;AACrC,SAAK,eAAe;AACpB,SAAK,eAAe;AACpB,SAAK,iBAAiB;AACtB,SAAK,iBAAiB;AACtB,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,UAAU;AAMf,SAAK,qBAAqB;AAC1B,SAAK,aAAa;AAClB,SAAK,YAAY;AAAA,EAClB;AACD;",
6
6
  "names": []
7
7
  }
@@ -314,14 +314,14 @@ function CropperInner({
314
314
  if (Math.abs(currentCropRect.x - snappedCropRect.x) < CROP_RECT_EPSILON && Math.abs(currentCropRect.y - snappedCropRect.y) < CROP_RECT_EPSILON && Math.abs(currentCropRect.width - snappedCropRect.width) < CROP_RECT_EPSILON && Math.abs(currentCropRect.height - snappedCropRect.height) < CROP_RECT_EPSILON) {
315
315
  return;
316
316
  }
317
- setCropRect(snappedCropRect);
317
+ adjustCropRectForViewport(snappedCropRect);
318
318
  }, [
319
+ adjustCropRectForViewport,
319
320
  aspectRatio,
320
321
  displayScale,
321
322
  freeformCrop,
322
323
  naturalWidth,
323
324
  naturalHeight,
324
- setCropRect,
325
325
  state
326
326
  ]);
327
327
  const {
@@ -446,7 +446,7 @@ function CropperInner({
446
446
  [setCropRect, setViewportPan, canvasSize, scaledVisualSize]
447
447
  );
448
448
  const [settling, setSettling] = useState(false);
449
- const settleTimerRef = useRef();
449
+ const settleTimerRef = useRef(void 0);
450
450
  const finishSettling = useCallback(() => {
451
451
  clearTimeout(settleTimerRef.current);
452
452
  isSettlingRef.current = false;