dune-react 0.0.43 → 0.0.44

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 (55) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +6 -0
  2. package/dist/_virtual/index.js +4 -0
  3. package/dist/components/puck-base/media.d.ts +1 -0
  4. package/dist/components/puck-base/media.js +272 -129
  5. package/dist/components/puck-block/gallery-sections/static-grid/static-grid.js +14 -10
  6. package/dist/components/puck-block/testimonial-sections/bento-testimonial/component.js +7 -6
  7. package/dist/components/puck-core/core/props/index.js +7 -0
  8. package/dist/components/shadcn/slider.js +1 -1
  9. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/flipImageAlgorithm.js +44 -0
  10. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/moveCoordinatesAlgorithm.js +8 -0
  11. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/resizeCoordinatesAlgorithm.js +291 -0
  12. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/rotateImageAlgorithm.js +38 -0
  13. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/transformImageAlgorithm.js +84 -0
  14. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/animation/index.js +78 -0
  15. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/boundary/index.js +31 -0
  16. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/canvas/index.js +94 -0
  17. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/constants/index.js +8 -0
  18. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultAreaPositionRestrictions.js +51 -0
  19. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultAreaSizeRestrictions.js +30 -0
  20. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultBoundary.js +10 -0
  21. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultPosition.js +12 -0
  22. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultPositionRestrictions.js +17 -0
  23. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultSize.js +31 -0
  24. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultSizeRestrictions.js +16 -0
  25. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultStencilConstraints.js +13 -0
  26. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultVisibleArea.js +49 -0
  27. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/index.js +84 -0
  28. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/extensions/stencil-size/index.js +107 -0
  29. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/image/index.js +350 -0
  30. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/instance/AbstractCropperInstance.js +494 -0
  31. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/approximateSize.js +30 -0
  32. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/fitCoordinates.js +30 -0
  33. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/fitVisibleArea.js +26 -0
  34. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/helpers.js +125 -0
  35. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/imageTransforms.js +83 -0
  36. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/interactions.js +19 -0
  37. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/normalize.js +83 -0
  38. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/sizeRestrictions.js +58 -0
  39. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/utils.js +313 -0
  40. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/copyState.js +7 -0
  41. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/createState.js +41 -0
  42. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/moveCoordinates.js +15 -0
  43. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/reconcileState.js +44 -0
  44. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/resizeCoordinates.js +22 -0
  45. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/setBoundary.js +31 -0
  46. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/setCoordinates.js +83 -0
  47. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/setVisibleArea.js +18 -0
  48. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/transformImage.js +18 -0
  49. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/types/index.js +16 -0
  50. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/utils/index.js +268 -0
  51. package/dist/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js +63 -0
  52. package/dist/node_modules/.pnpm/react-advanced-cropper@0.20.1_react@19.2.4/node_modules/react-advanced-cropper/dist/index.esm-bundler.js +1715 -0
  53. package/dist/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.js +181 -0
  54. package/dist/style.css +406 -0
  55. package/package.json +21 -20
@@ -0,0 +1,494 @@
1
+ import { __assign, __rest, __spreadArrays } from "../../../../tslib@2.8.1/node_modules/tslib/tslib.es6.js";
2
+ import { getOptions, deepClone, debounce, isArray, isFunction, deepCompare, isUndefined, isObject } from "../utils/index.js";
3
+ import { getCoefficient, isConsistentState, getStencilCoordinates, getRoundedCoordinates } from "../service/helpers.js";
4
+ import { copyState } from "../state/copyState.js";
5
+ import { setCoordinates, SetCoordinatesMode } from "../state/setCoordinates.js";
6
+ import { setVisibleArea } from "../state/setVisibleArea.js";
7
+ import { createState } from "../state/createState.js";
8
+ import { moveCoordinates } from "../state/moveCoordinates.js";
9
+ import { resizeCoordinates } from "../state/resizeCoordinates.js";
10
+ import { setBoundary } from "../state/setBoundary.js";
11
+ import { transformImage } from "../state/transformImage.js";
12
+ import { reconcileState } from "../state/reconcileState.js";
13
+ import { normalizeImageTransform, normalizeFlip, normalizeMoveDirections, fillMoveDirections, normalizeResizeDirections, fillResizeDirections } from "../service/normalize.js";
14
+ import { hasInteractions } from "../service/interactions.js";
15
+ function runCallback(callback, getInstance) {
16
+ if (callback && getInstance) {
17
+ var instance = getInstance();
18
+ if (instance) {
19
+ callback(instance);
20
+ }
21
+ }
22
+ }
23
+ function runCallbacks(callbacks, getInstance) {
24
+ callbacks.forEach(function(callback) {
25
+ runCallback(callback, getInstance);
26
+ });
27
+ }
28
+ var AbstractCropperInstance = (
29
+ /** @class */
30
+ /* @__PURE__ */ function() {
31
+ function AbstractCropperInstance2() {
32
+ var _this = this;
33
+ this.getTransitions = function() {
34
+ var data = _this.getData();
35
+ var transitions = _this.getProps().transitions;
36
+ return __assign(__assign({}, getOptions(transitions, {
37
+ timingFunction: "ease-in-out",
38
+ duration: 350
39
+ })), { active: data.transitions });
40
+ };
41
+ this.getInteractions = function() {
42
+ var interactions = _this.getData().interactions;
43
+ return deepClone(interactions);
44
+ };
45
+ this.hasInteractions = function() {
46
+ var interactions = _this.getData().interactions;
47
+ return hasInteractions(interactions);
48
+ };
49
+ this.startTransitions = function() {
50
+ var _a = _this.getProps(), onTransitionsStart = _a.onTransitionsStart, onUpdate = _a.onUpdate, getInstance = _a.getInstance;
51
+ var _b = _this.getData(), transitions = _b.transitions, data = __rest(_b, ["transitions"]);
52
+ _this.setData(__assign(__assign({}, data), { transitions: true }));
53
+ if (!transitions) {
54
+ runCallbacks([onTransitionsStart, onUpdate], getInstance);
55
+ }
56
+ _this.endTransitions();
57
+ };
58
+ this.endTransitions = debounce(function() {
59
+ var _a = _this.getProps(), onTransitionsEnd = _a.onTransitionsEnd, onUpdate = _a.onUpdate, getInstance = _a.getInstance;
60
+ _this.setData(__assign(__assign({}, _this.getData()), { transitions: false }));
61
+ runCallbacks([onTransitionsEnd, onUpdate], getInstance);
62
+ }, function() {
63
+ return _this.getTransitions().duration;
64
+ });
65
+ this.applyPostProcess = function(action, state) {
66
+ var _a = _this.getProps(), settings = _a.settings, postProcess = _a.postProcess;
67
+ var name = action.name, _b = action.interaction, interaction = _b === void 0 ? false : _b, _c = action.transitions, transitions = _c === void 0 ? false : _c, _d = action.immediately, immediately = _d === void 0 ? false : _d;
68
+ var preparedAction = {
69
+ name,
70
+ interaction,
71
+ transitions,
72
+ immediately
73
+ };
74
+ if (isArray(postProcess)) {
75
+ return postProcess.reduce(function(processedState, p) {
76
+ return p(processedState, settings, preparedAction);
77
+ }, state);
78
+ } else if (isFunction(postProcess)) {
79
+ return postProcess(state, settings, preparedAction);
80
+ } else {
81
+ return state;
82
+ }
83
+ };
84
+ this.updateState = function(modifier, options, callbacks) {
85
+ if (options === void 0) {
86
+ options = {};
87
+ }
88
+ if (callbacks === void 0) {
89
+ callbacks = [];
90
+ }
91
+ var _a = options.transitions, transitions = _a === void 0 ? false : _a;
92
+ var _b = _this.getProps(), onTransitionsStart = _b.onTransitionsStart, getInstance = _b.getInstance, onChange = _b.onChange, onUpdate = _b.onUpdate, settings = _b.settings;
93
+ var previousData = _this.getData();
94
+ var state = isFunction(modifier) ? modifier(previousData.state, settings) : modifier;
95
+ var tolerance = state ? 1e-3 * getCoefficient(state) : 1e-3;
96
+ var somethingChanged = !deepCompare(previousData.state, state, tolerance);
97
+ var affectTransitionProperties = [
98
+ "coordinates",
99
+ "boundary",
100
+ "visibleArea",
101
+ "imageSize",
102
+ "transforms"
103
+ ].some(function(property) {
104
+ var _a2;
105
+ return !deepCompare((_a2 = previousData.state) === null || _a2 === void 0 ? void 0 : _a2[property], state === null || state === void 0 ? void 0 : state[property], tolerance);
106
+ });
107
+ var currentData = previousData;
108
+ if (somethingChanged) {
109
+ if (transitions && affectTransitionProperties) {
110
+ _this.endTransitions();
111
+ }
112
+ currentData = __assign(__assign({}, currentData), { state: copyState(state), transitions: transitions && affectTransitionProperties });
113
+ _this.setData(currentData);
114
+ runCallback(onChange, getInstance);
115
+ }
116
+ if (currentData.transitions && !previousData.transitions) {
117
+ runCallback(onTransitionsStart, getInstance);
118
+ }
119
+ runCallbacks(__spreadArrays(callbacks, [onUpdate]), getInstance);
120
+ };
121
+ this.setInteractions = function(interactions) {
122
+ var _a = _this.getProps(), onInteractionStart = _a.onInteractionStart, onInteractionEnd = _a.onInteractionEnd, getInstance = _a.getInstance;
123
+ var previousInteractions = _this.getInteractions();
124
+ var currentInteractions = __assign(__assign({}, previousInteractions), interactions);
125
+ if (!deepCompare(previousInteractions, currentInteractions)) {
126
+ _this.setData(__assign(__assign({}, _this.getData()), { interactions: currentInteractions }));
127
+ }
128
+ if (hasInteractions(previousInteractions) !== hasInteractions(currentInteractions)) {
129
+ if (!hasInteractions(previousInteractions)) {
130
+ runCallback(onInteractionStart, getInstance);
131
+ } else {
132
+ var state_1 = _this.getData().state;
133
+ _this.updateState(function() {
134
+ return state_1 && _this.applyPostProcess({
135
+ name: "interactionEnd",
136
+ immediately: true,
137
+ transitions: true
138
+ }, state_1);
139
+ }, {
140
+ transitions: true
141
+ }, [onInteractionEnd]);
142
+ }
143
+ }
144
+ };
145
+ this.resetState = function(boundary, image) {
146
+ _this.updateState(_this.createDefaultState(boundary, image));
147
+ };
148
+ this.clear = function() {
149
+ _this.updateState(null);
150
+ };
151
+ this.reconcileState = function(options) {
152
+ if (options === void 0) {
153
+ options = {};
154
+ }
155
+ var _a = _this.getProps(), reconcileStateAlgorithm = _a.reconcileStateAlgorithm, settings = _a.settings;
156
+ var state = _this.getData().state;
157
+ var _b = options.transitions, transitions = _b === void 0 ? false : _b;
158
+ if (state && !isConsistentState(state, settings)) {
159
+ var reconciledState = (reconcileStateAlgorithm || reconcileState)(state, settings);
160
+ reconciledState = _this.applyPostProcess({
161
+ name: "reconcileState",
162
+ immediately: true,
163
+ transitions
164
+ }, reconciledState);
165
+ _this.updateState(reconciledState, {
166
+ transitions
167
+ });
168
+ }
169
+ };
170
+ this.transformImage = function(transform, options) {
171
+ if (options === void 0) {
172
+ options = {};
173
+ }
174
+ var _a = options.transitions, transitions = _a === void 0 ? true : _a, _b = options.interaction, interaction = _b === void 0 ? true : _b, _c = options.immediately, immediately = _c === void 0 ? false : _c, _d = options.normalize, normalize = _d === void 0 ? true : _d;
175
+ var _e = _this.getProps(), transformImageAlgorithm = _e.transformImageAlgorithm, onTransformImage = _e.onTransformImage, onTransformImageEnd = _e.onTransformImageEnd, settings = _e.settings;
176
+ var state = _this.getData().state;
177
+ var callbacks = [];
178
+ if (state) {
179
+ if (normalize) {
180
+ transform = normalizeImageTransform(state, transform);
181
+ }
182
+ var result = _this.applyPostProcess({
183
+ name: "transformImage",
184
+ transitions,
185
+ immediately
186
+ }, (transformImageAlgorithm || transformImage)(state, settings, transform));
187
+ callbacks.push(onTransformImage);
188
+ if (interaction) {
189
+ _this.setInteractions({
190
+ transformImage: {
191
+ rotate: !isUndefined(transform.rotate),
192
+ flip: !isUndefined(transform.flip),
193
+ scale: !isUndefined(transform.scale),
194
+ move: !isUndefined(transform.move)
195
+ }
196
+ });
197
+ } else {
198
+ result = _this.applyPostProcess({
199
+ name: "transformImageEnd",
200
+ transitions,
201
+ immediately: true
202
+ }, result);
203
+ callbacks.push(onTransformImageEnd);
204
+ }
205
+ _this.updateState(result, {
206
+ transitions: immediately && transitions
207
+ }, callbacks);
208
+ }
209
+ };
210
+ this.transformImageEnd = function(options) {
211
+ if (options === void 0) {
212
+ options = {};
213
+ }
214
+ var _a = options.immediately, immediately = _a === void 0 ? true : _a, _b = options.transitions, transitions = _b === void 0 ? true : _b;
215
+ var state = _this.getData().state;
216
+ var onTransformImageEnd = _this.getProps().onTransformImageEnd;
217
+ _this.updateState(function() {
218
+ return state && _this.applyPostProcess({ name: "transformImageEnd", immediately, transitions }, state);
219
+ }, {
220
+ transitions
221
+ }, [onTransformImageEnd]);
222
+ _this.setInteractions({
223
+ transformImage: {
224
+ rotate: false,
225
+ flip: false,
226
+ scale: false,
227
+ move: false
228
+ }
229
+ });
230
+ };
231
+ this.zoomImage = function(scale, options) {
232
+ if (options === void 0) {
233
+ options = {};
234
+ }
235
+ var _a = options.interaction, interaction = _a === void 0 ? false : _a, _b = options.immediately, immediately = _b === void 0 ? true : _b, _c = options.transitions, transitions = _c === void 0 ? true : _c, _d = options.normalize, normalize = _d === void 0 ? false : _d;
236
+ _this.transformImage({
237
+ scale
238
+ }, { interaction, immediately, transitions, normalize });
239
+ };
240
+ this.moveImage = function(left, top, options) {
241
+ if (options === void 0) {
242
+ options = {};
243
+ }
244
+ var _a = options.interaction, interaction = _a === void 0 ? false : _a, _b = options.immediately, immediately = _b === void 0 ? true : _b, _c = options.transitions, transitions = _c === void 0 ? true : _c, _d = options.normalize, normalize = _d === void 0 ? false : _d;
245
+ _this.transformImage({
246
+ move: {
247
+ left,
248
+ top
249
+ }
250
+ }, { interaction, immediately, transitions, normalize });
251
+ };
252
+ this.flipImage = function(horizontal, vertical, options) {
253
+ if (options === void 0) {
254
+ options = {};
255
+ }
256
+ var _a = options.interaction, interaction = _a === void 0 ? false : _a, _b = options.immediately, immediately = _b === void 0 ? true : _b, _c = options.transitions, transitions = _c === void 0 ? true : _c, _d = options.normalize, normalize = _d === void 0 ? true : _d;
257
+ var state = _this.getState();
258
+ var flip = {
259
+ horizontal,
260
+ vertical
261
+ };
262
+ _this.transformImage({
263
+ flip: state && normalize ? normalizeFlip(state, flip) : flip
264
+ }, { interaction, immediately, transitions });
265
+ };
266
+ this.rotateImage = function(rotate, options) {
267
+ if (options === void 0) {
268
+ options = {};
269
+ }
270
+ var _a = options.interaction, interaction = _a === void 0 ? false : _a, _b = options.immediately, immediately = _b === void 0 ? true : _b, _c = options.transitions, transitions = _c === void 0 ? true : _c, _d = options.normalize, normalize = _d === void 0 ? false : _d;
271
+ _this.transformImage({
272
+ rotate
273
+ }, { interaction, immediately, transitions, normalize });
274
+ };
275
+ this.reset = function(boundary, image) {
276
+ _this.resetState(boundary, image);
277
+ };
278
+ this.setState = function(modifier, options) {
279
+ if (options === void 0) {
280
+ options = {};
281
+ }
282
+ var settings = _this.getSettings();
283
+ var state = _this.getData().state;
284
+ var _a = options.transitions, transitions = _a === void 0 ? true : _a, _b = options.immediately, immediately = _b === void 0 ? false : _b, _c = options.interaction, interaction = _c === void 0 ? false : _c, _d = options.postprocess, postprocess = _d === void 0 ? false : _d;
285
+ var newState = modifier && (isFunction(modifier) ? modifier(state, settings) : __assign(__assign({}, state), modifier));
286
+ _this.updateState(function() {
287
+ return postprocess ? newState && _this.applyPostProcess({
288
+ name: "setState",
289
+ immediately,
290
+ transitions,
291
+ interaction
292
+ }, newState) : newState;
293
+ }, {
294
+ transitions
295
+ });
296
+ };
297
+ this.setCoordinates = function(transforms, options) {
298
+ if (options === void 0) {
299
+ options = {};
300
+ }
301
+ var state = _this.getData().state;
302
+ var _a = _this.getProps(), setCoordinatesAlgorithm = _a.setCoordinatesAlgorithm, settings = _a.settings;
303
+ var _b = options.transitions, transitions = _b === void 0 ? true : _b, _c = options.immediately, immediately = _c === void 0 ? true : _c;
304
+ _this.updateState(function() {
305
+ return state && _this.applyPostProcess({
306
+ name: "setCoordinates",
307
+ immediately,
308
+ transitions
309
+ }, (setCoordinatesAlgorithm || setCoordinates)(state, settings, transforms, SetCoordinatesMode.zoom));
310
+ }, {
311
+ transitions
312
+ });
313
+ };
314
+ this.setVisibleArea = function(visibleArea, options) {
315
+ if (options === void 0) {
316
+ options = {};
317
+ }
318
+ var _a = options.transitions, transitions = _a === void 0 ? true : _a, _b = options.immediately, immediately = _b === void 0 ? true : _b;
319
+ var state = _this.getData().state;
320
+ var _c = _this.getProps(), setVisibleAreaAlgorithm = _c.setVisibleAreaAlgorithm, settings = _c.settings;
321
+ _this.updateState(function() {
322
+ return state && _this.applyPostProcess({ name: "setVisibleArea", immediately, transitions }, (setVisibleAreaAlgorithm || setVisibleArea)(state, settings, visibleArea));
323
+ }, {
324
+ transitions
325
+ });
326
+ };
327
+ this.setBoundary = function(boundary, options) {
328
+ if (options === void 0) {
329
+ options = {};
330
+ }
331
+ var state = _this.getData().state;
332
+ var _a = _this.getProps(), setBoundaryAlgorithm = _a.setBoundaryAlgorithm, settings = _a.settings;
333
+ var _b = options.transitions, transitions = _b === void 0 ? false : _b, _c = options.immediately, immediately = _c === void 0 ? true : _c;
334
+ if (boundary) {
335
+ _this.updateState(function() {
336
+ return state && _this.applyPostProcess({ name: "setBoundary", immediately, transitions }, (setBoundaryAlgorithm || setBoundary)(state, settings, boundary));
337
+ });
338
+ } else {
339
+ _this.updateState(null);
340
+ }
341
+ };
342
+ this.moveCoordinates = function(directions, options) {
343
+ if (options === void 0) {
344
+ options = {};
345
+ }
346
+ var data = _this.getData();
347
+ var _a = _this.getProps(), moveCoordinatesAlgorithm = _a.moveCoordinatesAlgorithm, onMove = _a.onMove, onMoveEnd = _a.onMoveEnd, settings = _a.settings;
348
+ var _b = options.interaction, interaction = _b === void 0 ? true : _b, _c = options.transitions, transitions = _c === void 0 ? false : _c, _d = options.immediately, immediately = _d === void 0 ? false : _d, _e = options.normalize, normalize = _e === void 0 ? true : _e;
349
+ var callbacks = [];
350
+ if (!data.transitions && data.state) {
351
+ var normalizedDirections = normalize ? normalizeMoveDirections(data.state, directions) : fillMoveDirections(directions);
352
+ var result = _this.applyPostProcess({ name: "moveCoordinates", interaction, immediately, transitions }, (moveCoordinatesAlgorithm || moveCoordinates)(data.state, settings, normalizedDirections));
353
+ callbacks.push(onMove);
354
+ if (interaction) {
355
+ _this.setInteractions({
356
+ moveCoordinates: true
357
+ });
358
+ } else {
359
+ result = _this.applyPostProcess({ name: "moveCoordinatesEnd", interaction, immediately, transitions }, result);
360
+ callbacks.push(onMoveEnd);
361
+ }
362
+ _this.updateState(result, {
363
+ transitions: immediately && transitions
364
+ }, callbacks);
365
+ }
366
+ };
367
+ this.moveCoordinatesEnd = function(options) {
368
+ if (options === void 0) {
369
+ options = {};
370
+ }
371
+ var state = _this.getData().state;
372
+ var onMoveEnd = _this.getProps().onMoveEnd;
373
+ var _a = options.transitions, transitions = _a === void 0 ? true : _a, _b = options.immediately, immediately = _b === void 0 ? false : _b;
374
+ _this.updateState(function() {
375
+ return state && _this.applyPostProcess({ name: "moveCoordinatesEnd", transitions, immediately }, state);
376
+ }, {
377
+ transitions
378
+ }, [onMoveEnd]);
379
+ _this.setInteractions({
380
+ moveCoordinates: false
381
+ });
382
+ };
383
+ this.resizeCoordinates = function(anchor, directions, parameters, options) {
384
+ if (options === void 0) {
385
+ options = {};
386
+ }
387
+ var state = _this.getData().state;
388
+ var _a = _this.getProps(), resizeCoordinatesAlgorithm = _a.resizeCoordinatesAlgorithm, onResize = _a.onResize, onResizeEnd = _a.onResizeEnd, settings = _a.settings;
389
+ var _b = options.interaction, interaction = _b === void 0 ? true : _b, _c = options.transitions, transitions = _c === void 0 ? false : _c, _d = options.immediately, immediately = _d === void 0 ? false : _d, _e = options.normalize, normalize = _e === void 0 ? true : _e;
390
+ var transitionsOptions = _this.getTransitions();
391
+ if (!transitionsOptions.active && state) {
392
+ var callbacks = [];
393
+ var normalizedDirections = normalize ? normalizeResizeDirections(state, directions) : fillResizeDirections(directions);
394
+ var result = _this.applyPostProcess({ name: "resizeCoordinates", interaction, immediately, transitions }, (resizeCoordinatesAlgorithm || resizeCoordinates)(state, settings, anchor, normalizedDirections, isObject(parameters) ? parameters : {}));
395
+ callbacks.push(onResize);
396
+ if (interaction) {
397
+ _this.setInteractions({
398
+ resizeCoordinates: true
399
+ });
400
+ } else {
401
+ result = _this.applyPostProcess({ name: "resizeCoordinatesEnd", interaction, immediately, transitions }, result);
402
+ callbacks.push(onResizeEnd);
403
+ }
404
+ _this.updateState(result, {
405
+ transitions: immediately && transitions
406
+ }, callbacks);
407
+ }
408
+ };
409
+ this.resizeCoordinatesEnd = function(options) {
410
+ if (options === void 0) {
411
+ options = {};
412
+ }
413
+ var onResizeEnd = _this.getProps().onResizeEnd;
414
+ var state = _this.getData().state;
415
+ var _a = options.transitions, transitions = _a === void 0 ? true : _a, _b = options.immediately, immediately = _b === void 0 ? false : _b;
416
+ _this.updateState(function() {
417
+ return state && _this.applyPostProcess({ name: "resizeCoordinatesEnd", transitions, immediately }, state);
418
+ }, {
419
+ transitions
420
+ }, [onResizeEnd]);
421
+ _this.setInteractions({
422
+ resizeCoordinates: false
423
+ });
424
+ };
425
+ this.getStencilCoordinates = function() {
426
+ var state = _this.getData().state;
427
+ return getStencilCoordinates(state);
428
+ };
429
+ this.getCoordinates = function(options) {
430
+ if (options === void 0) {
431
+ options = {};
432
+ }
433
+ var state = _this.getData().state;
434
+ var settings = _this.getProps().settings;
435
+ if (state && state.coordinates) {
436
+ var _a = options.round, round = _a === void 0 ? true : _a;
437
+ if (round) {
438
+ return getRoundedCoordinates(state, settings);
439
+ } else {
440
+ return __assign({}, state.coordinates);
441
+ }
442
+ } else {
443
+ return null;
444
+ }
445
+ };
446
+ this.getVisibleArea = function() {
447
+ var state = _this.getData().state;
448
+ if (state === null || state === void 0 ? void 0 : state.visibleArea) {
449
+ return __assign({}, state.visibleArea);
450
+ } else {
451
+ return null;
452
+ }
453
+ };
454
+ this.getSettings = function() {
455
+ var settings = _this.getProps().settings;
456
+ return __assign({}, settings);
457
+ };
458
+ this.getState = function() {
459
+ var state = _this.getData().state;
460
+ return copyState(state);
461
+ };
462
+ this.getTransforms = function() {
463
+ var state = _this.getData().state;
464
+ return state ? deepClone(state.transforms) : {
465
+ rotate: 0,
466
+ flip: {
467
+ horizontal: false,
468
+ vertical: false
469
+ }
470
+ };
471
+ };
472
+ this.createDefaultState = function(boundary, image) {
473
+ var _a = _this.getProps(), createStateAlgorithm = _a.createStateAlgorithm, settings = _a.settings;
474
+ return _this.applyPostProcess({
475
+ name: "createState",
476
+ immediately: true,
477
+ transitions: false
478
+ }, (createStateAlgorithm || createState)({
479
+ image,
480
+ boundary
481
+ }, settings));
482
+ };
483
+ this.isConsistent = function() {
484
+ var state = _this.getData().state;
485
+ var settings = _this.getProps().settings;
486
+ return state ? isConsistentState(state, settings) : true;
487
+ };
488
+ }
489
+ return AbstractCropperInstance2;
490
+ }()
491
+ );
492
+ export {
493
+ AbstractCropperInstance
494
+ };
@@ -0,0 +1,30 @@
1
+ import { createAspectRatio, resizeToSizeRestrictions, getCloserSize } from "./utils.js";
2
+ function approximateSize(params) {
3
+ var width = params.width, height = params.height;
4
+ var sizeRestrictions = params.sizeRestrictions || {
5
+ minWidth: 0,
6
+ minHeight: 0,
7
+ maxWidth: Infinity,
8
+ maxHeight: Infinity
9
+ };
10
+ var aspectRatio = createAspectRatio(params.aspectRatio);
11
+ var coordinates = {
12
+ width: Math.max(sizeRestrictions.minWidth, Math.min(sizeRestrictions.maxWidth, width)),
13
+ height: Math.max(sizeRestrictions.minHeight, Math.min(sizeRestrictions.maxHeight, height))
14
+ };
15
+ var candidates = [coordinates];
16
+ if (aspectRatio) {
17
+ [aspectRatio.minimum, aspectRatio.maximum].forEach(function(ratio) {
18
+ if (ratio) {
19
+ candidates.push({ width: coordinates.width, height: coordinates.width / ratio }, { width: coordinates.height * ratio, height: coordinates.height });
20
+ }
21
+ });
22
+ }
23
+ candidates = candidates.map(function(candidate) {
24
+ return resizeToSizeRestrictions(candidate, sizeRestrictions);
25
+ });
26
+ return getCloserSize(candidates, { width, height }, sizeRestrictions, aspectRatio);
27
+ }
28
+ export {
29
+ approximateSize
30
+ };
@@ -0,0 +1,30 @@
1
+ import { __assign } from "../../../../tslib@2.8.1/node_modules/tslib/tslib.es6.js";
2
+ import { applyMove, diff, getCenter, moveToPositionRestrictions, mergePositionRestrictions, coordinatesToPositionRestrictions } from "./utils.js";
3
+ import { getAspectRatio, getSizeRestrictions, getPositionRestrictions } from "./helpers.js";
4
+ import { copyState } from "../state/copyState.js";
5
+ import { approximateSize } from "./approximateSize.js";
6
+ function fitCoordinates(state, settings) {
7
+ if (state.coordinates) {
8
+ var result = copyState(state);
9
+ var aspectRatio = getAspectRatio(state, settings);
10
+ var sizeRestrictions = getSizeRestrictions(state, settings);
11
+ result.coordinates = __assign(__assign({}, state.coordinates), approximateSize({
12
+ width: state.coordinates.width,
13
+ height: state.coordinates.height,
14
+ aspectRatio,
15
+ sizeRestrictions: state.visibleArea ? {
16
+ maxWidth: Math.min(state.visibleArea.width, sizeRestrictions.maxWidth),
17
+ maxHeight: Math.min(state.visibleArea.height, sizeRestrictions.maxHeight),
18
+ minHeight: Math.min(state.visibleArea.height, sizeRestrictions.minHeight),
19
+ minWidth: Math.min(state.visibleArea.width, sizeRestrictions.minWidth)
20
+ } : sizeRestrictions
21
+ }));
22
+ result.coordinates = applyMove(result.coordinates, diff(getCenter(state.coordinates), getCenter(result.coordinates)));
23
+ result.coordinates = moveToPositionRestrictions(result.coordinates, state.visibleArea ? mergePositionRestrictions(coordinatesToPositionRestrictions(state.visibleArea), getPositionRestrictions(result, settings)) : getPositionRestrictions(result, settings));
24
+ return result;
25
+ }
26
+ return state;
27
+ }
28
+ export {
29
+ fitCoordinates
30
+ };
@@ -0,0 +1,26 @@
1
+ import { __assign } from "../../../../tslib@2.8.1/node_modules/tslib/tslib.es6.js";
2
+ import { ratio, applyMove, diff, getCenter, moveToPositionRestrictions } from "./utils.js";
3
+ import { getAreaSizeRestrictions, getAreaPositionRestrictions } from "./helpers.js";
4
+ import { copyState } from "../state/copyState.js";
5
+ import { approximateSize } from "./approximateSize.js";
6
+ function fitVisibleArea(state, settings) {
7
+ var result = copyState(state);
8
+ if (state.visibleArea) {
9
+ var areaSizeRestrictions = getAreaSizeRestrictions(state, settings);
10
+ result.visibleArea = __assign(__assign({}, state.visibleArea), approximateSize({
11
+ width: state.visibleArea.width,
12
+ height: state.visibleArea.height,
13
+ aspectRatio: {
14
+ minimum: ratio(result.boundary),
15
+ maximum: ratio(result.boundary)
16
+ },
17
+ sizeRestrictions: areaSizeRestrictions
18
+ }));
19
+ result.visibleArea = applyMove(result.visibleArea, diff(getCenter(state.visibleArea), getCenter(result.visibleArea)));
20
+ result.visibleArea = moveToPositionRestrictions(result.visibleArea, getAreaPositionRestrictions(result, settings));
21
+ }
22
+ return result;
23
+ }
24
+ export {
25
+ fitVisibleArea
26
+ };