@ntlab/ntjs-assets 2.115.0 → 2.116.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.
@@ -50,7 +50,7 @@
50
50
  "ckeditor": ""
51
51
  },
52
52
  "cropper": {
53
- "version": "2.0.1",
53
+ "version": "2.1.0",
54
54
  "jsdelivr-dist": "cropperjs"
55
55
  },
56
56
  "DataTables": {
@@ -38,6 +38,7 @@ declare class Cropper {
38
38
  getCropperImage(): CropperImage | null;
39
39
  getCropperSelection(): CropperSelection | null;
40
40
  getCropperSelections(): NodeListOf<CropperSelection> | null;
41
+ destroy(): void;
41
42
  }
42
43
  export default Cropper;
43
44
 
@@ -1302,6 +1303,16 @@ export declare class CropperImage extends CropperElement_3 {
1302
1303
  skewable: boolean;
1303
1304
  slottable: boolean;
1304
1305
  translatable: boolean;
1306
+ alt: string;
1307
+ crossorigin: string;
1308
+ decoding: string;
1309
+ elementtiming: string;
1310
+ fetchpriority: string;
1311
+ loading: string;
1312
+ referrerpolicy: string;
1313
+ sizes: string;
1314
+ src: string;
1315
+ srcset: string;
1305
1316
  protected set $canvas(element: CropperCanvas_2);
1306
1317
  protected get $canvas(): CropperCanvas_2;
1307
1318
  protected static get observedAttributes(): string[];
@@ -1438,6 +1449,16 @@ declare class CropperImage_2 extends CropperElement_2_5 {
1438
1449
  skewable: boolean;
1439
1450
  slottable: boolean;
1440
1451
  translatable: boolean;
1452
+ alt: string;
1453
+ crossorigin: string;
1454
+ decoding: string;
1455
+ elementtiming: string;
1456
+ fetchpriority: string;
1457
+ loading: string;
1458
+ referrerpolicy: string;
1459
+ sizes: string;
1460
+ src: string;
1461
+ srcset: string;
1441
1462
  protected set $canvas(element: CropperCanvas_5);
1442
1463
  protected get $canvas(): CropperCanvas_5;
1443
1464
  protected static get observedAttributes(): string[];
@@ -1805,9 +1826,9 @@ declare class CropperSelection_2 extends CropperElement_4_2 {
1805
1826
  export declare class CropperShade extends CropperElement_4 {
1806
1827
  static $name: string;
1807
1828
  static $version: string;
1808
- protected $onCanvasChange: EventListener | null;
1809
1829
  protected $onCanvasActionEnd: EventListener | null;
1810
1830
  protected $onCanvasActionStart: EventListener | null;
1831
+ protected $onSelectionChange: EventListener | null;
1811
1832
  protected $style: string;
1812
1833
  x: number;
1813
1834
  y: number;
@@ -1928,6 +1949,15 @@ export declare function getAdjustedSizes(data: SizeAdjustmentData | SizeAdjustme
1928
1949
  height: number;
1929
1950
  };
1930
1951
 
1952
+ /**
1953
+ * Get the real event target by checking composed path.
1954
+ * This is useful when dealing with events that can cross shadow DOM boundaries.
1955
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath}
1956
+ * @param {Event} event The event object.
1957
+ * @returns {EventTarget | null} The first element in the composed path, or the original event target.
1958
+ */
1959
+ export declare function getComposedPathTarget(event: Event): EventTarget | null;
1960
+
1931
1961
  /**
1932
1962
  * Get the offset base on the document.
1933
1963
  * @param {Element} element The target element.
@@ -1938,6 +1968,13 @@ export declare function getOffset(element: Element): {
1938
1968
  top: number;
1939
1969
  };
1940
1970
 
1971
+ /**
1972
+ * Get the root document node.
1973
+ * @param {Element} element The target element.
1974
+ * @returns {Document|DocumentFragment|null} The document node.
1975
+ */
1976
+ export declare function getRootDocument(element: Element): Document | DocumentFragment | null;
1977
+
1941
1978
  export declare const HAS_POINTER_EVENT: boolean;
1942
1979
 
1943
1980
  export declare const IS_BROWSER: boolean;
@@ -1,4 +1,4 @@
1
- /*! Cropper.js v2.0.0 | (c) 2015-present Chen Fengyuan | MIT */
1
+ /*! Cropper.js v2.1.0 | (c) 2015-present Chen Fengyuan | MIT */
2
2
  const IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined';
3
3
  const WINDOW = IS_BROWSER ? window : {};
4
4
  const IS_TOUCH_DEVICE = IS_BROWSER ? 'ontouchstart' in WINDOW.document.documentElement : false;
@@ -200,6 +200,20 @@ const defaultEventOptions = {
200
200
  function emit(target, type, detail, options) {
201
201
  return target.dispatchEvent(new CustomEvent(type, Object.assign(Object.assign(Object.assign({}, defaultEventOptions), { detail }), options)));
202
202
  }
203
+ /**
204
+ * Get the real event target by checking composed path.
205
+ * This is useful when dealing with events that can cross shadow DOM boundaries.
206
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath}
207
+ * @param {Event} event The event object.
208
+ * @returns {EventTarget | null} The first element in the composed path, or the original event target.
209
+ */
210
+ function getComposedPathTarget(event) {
211
+ if (typeof event.composedPath === 'function') {
212
+ const path = event.composedPath();
213
+ return path.find(isElement) || event.target;
214
+ }
215
+ return event.target;
216
+ }
203
217
  const resolvedPromise = Promise.resolve();
204
218
  /**
205
219
  * Defers the callback to be executed after the next DOM update cycle.
@@ -212,6 +226,23 @@ function nextTick(context, callback) {
212
226
  ? resolvedPromise.then(context ? callback.bind(context) : callback)
213
227
  : resolvedPromise;
214
228
  }
229
+ /**
230
+ * Get the root document node.
231
+ * @param {Element} element The target element.
232
+ * @returns {Document|DocumentFragment|null} The document node.
233
+ */
234
+ function getRootDocument(element) {
235
+ const rootNode = element.getRootNode();
236
+ switch (rootNode.nodeType) {
237
+ case 1:
238
+ return rootNode.ownerDocument;
239
+ case 9:
240
+ return rootNode;
241
+ case 11:
242
+ return rootNode;
243
+ }
244
+ return null;
245
+ }
215
246
  /**
216
247
  * Get the offset base on the document.
217
248
  * @param {Element} element The target element.
@@ -428,12 +459,10 @@ class CropperElement extends HTMLElement {
428
459
  },
429
460
  });
430
461
  });
431
- const shadow = this.attachShadow({
462
+ const shadow = this.shadowRoot || this.attachShadow({
432
463
  mode: this.shadowRootMode || DEFAULT_SHADOW_ROOT_MODE,
433
464
  });
434
- if (!this.shadowRoot) {
435
- shadowRoots.set(this, shadow);
436
- }
465
+ shadowRoots.set(this, shadow);
437
466
  styleSheets.set(this, this.$addStyles(this.$sharedStyle));
438
467
  if (this.$style) {
439
468
  this.$addStyles(this.$style);
@@ -541,7 +570,7 @@ class CropperElement extends HTMLElement {
541
570
  }
542
571
  }
543
572
  }
544
- CropperElement.$version = '2.0.0';
573
+ CropperElement.$version = '2.1.0';
545
574
 
546
575
  var style$7 = `:host{display:block;min-height:100px;min-width:200px;overflow:hidden;position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([background]){background-color:#fff;background-image:repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc),repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc);background-image:repeating-conic-gradient(#ccc 0 25%,#fff 0 50%);background-position:0 0,.5rem .5rem;background-size:1rem 1rem}:host([disabled]){pointer-events:none}:host([disabled]):after{bottom:0;content:"";cursor:not-allowed;display:block;left:0;pointer-events:none;position:absolute;right:0;top:0}`;
547
576
 
@@ -986,7 +1015,7 @@ class CropperCanvas extends CropperElement {
986
1015
  }
987
1016
  }
988
1017
  CropperCanvas.$name = CROPPER_CANVAS;
989
- CropperCanvas.$version = '2.0.0';
1018
+ CropperCanvas.$version = '2.1.0';
990
1019
 
991
1020
  var style$6 = `:host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}`;
992
1021
 
@@ -995,7 +1024,8 @@ const NATIVE_ATTRIBUTES = [
995
1024
  'alt',
996
1025
  'crossorigin',
997
1026
  'decoding',
998
- 'importance',
1027
+ 'elementtiming',
1028
+ 'fetchpriority',
999
1029
  'loading',
1000
1030
  'referrerpolicy',
1001
1031
  'sizes',
@@ -1019,6 +1049,17 @@ class CropperImage extends CropperElement {
1019
1049
  this.skewable = false;
1020
1050
  this.slottable = false;
1021
1051
  this.translatable = false;
1052
+ // Native attributes
1053
+ this.alt = '';
1054
+ this.crossorigin = '';
1055
+ this.decoding = '';
1056
+ this.elementtiming = '';
1057
+ this.fetchpriority = '';
1058
+ this.loading = '';
1059
+ this.referrerpolicy = '';
1060
+ this.sizes = '';
1061
+ this.src = '';
1062
+ this.srcset = '';
1022
1063
  }
1023
1064
  set $canvas(element) {
1024
1065
  canvasCache$3.set(this, element);
@@ -1254,7 +1295,10 @@ class CropperImage extends CropperElement {
1254
1295
  const onLoad = () => {
1255
1296
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
1256
1297
  off($image, EVENT_ERROR, onError);
1257
- resolve($image);
1298
+ // Ensure the image is fully rendered.
1299
+ setTimeout(() => {
1300
+ resolve($image);
1301
+ });
1258
1302
  };
1259
1303
  const onError = () => {
1260
1304
  off($image, EVENT_LOAD, onLoad);
@@ -1533,7 +1577,7 @@ class CropperImage extends CropperElement {
1533
1577
  }
1534
1578
  }
1535
1579
  CropperImage.$name = CROPPER_IMAGE;
1536
- CropperImage.$version = '2.0.0';
1580
+ CropperImage.$version = '2.1.0';
1537
1581
 
1538
1582
  var style$5 = `:host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}`;
1539
1583
 
@@ -1541,9 +1585,9 @@ const canvasCache$2 = new WeakMap();
1541
1585
  class CropperShade extends CropperElement {
1542
1586
  constructor() {
1543
1587
  super(...arguments);
1544
- this.$onCanvasChange = null;
1545
1588
  this.$onCanvasActionEnd = null;
1546
1589
  this.$onCanvasActionStart = null;
1590
+ this.$onSelectionChange = null;
1547
1591
  this.$style = style$5;
1548
1592
  this.x = 0;
1549
1593
  this.y = 0;
@@ -1584,8 +1628,8 @@ class CropperShade extends CropperElement {
1584
1628
  this.hidden = true;
1585
1629
  }
1586
1630
  };
1587
- this.$onCanvasChange = (event) => {
1588
- const { x, y, width, height, } = event.detail;
1631
+ this.$onSelectionChange = (event) => {
1632
+ const { x, y, width, height, } = event.defaultPrevented ? $selection : event.detail;
1589
1633
  this.$change(x, y, width, height);
1590
1634
  if ($selection.hidden || (x === 0 && y === 0 && width === 0 && height === 0)) {
1591
1635
  this.hidden = true;
@@ -1593,7 +1637,7 @@ class CropperShade extends CropperElement {
1593
1637
  };
1594
1638
  on($canvas, EVENT_ACTION_START, this.$onCanvasActionStart);
1595
1639
  on($canvas, EVENT_ACTION_END, this.$onCanvasActionEnd);
1596
- on($canvas, EVENT_CHANGE, this.$onCanvasChange);
1640
+ on($canvas, EVENT_CHANGE, this.$onSelectionChange);
1597
1641
  }
1598
1642
  }
1599
1643
  this.$render();
@@ -1609,9 +1653,9 @@ class CropperShade extends CropperElement {
1609
1653
  off($canvas, EVENT_ACTION_END, this.$onCanvasActionEnd);
1610
1654
  this.$onCanvasActionEnd = null;
1611
1655
  }
1612
- if (this.$onCanvasChange) {
1613
- off($canvas, EVENT_CHANGE, this.$onCanvasChange);
1614
- this.$onCanvasChange = null;
1656
+ if (this.$onSelectionChange) {
1657
+ off($canvas, EVENT_CHANGE, this.$onSelectionChange);
1658
+ this.$onSelectionChange = null;
1615
1659
  }
1616
1660
  }
1617
1661
  super.disconnectedCallback();
@@ -1662,7 +1706,7 @@ class CropperShade extends CropperElement {
1662
1706
  }
1663
1707
  }
1664
1708
  CropperShade.$name = CROPPER_SHADE;
1665
- CropperShade.$version = '2.0.0';
1709
+ CropperShade.$version = '2.1.0';
1666
1710
 
1667
1711
  var style$4 = `:host{background-color:var(--theme-color);display:block}:host([action=move]),:host([action=select]){height:100%;left:0;position:absolute;top:0;width:100%}:host([action=move]){cursor:move}:host([action=select]){cursor:crosshair}:host([action$=-resize]){background-color:transparent;height:15px;position:absolute;width:15px}:host([action$=-resize]):after{background-color:var(--theme-color);content:"";display:block;height:5px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:5px}:host([action=n-resize]),:host([action=s-resize]){cursor:ns-resize;left:50%;transform:translateX(-50%);width:100%}:host([action=n-resize]){top:-8px}:host([action=s-resize]){bottom:-8px}:host([action=e-resize]),:host([action=w-resize]){cursor:ew-resize;height:100%;top:50%;transform:translateY(-50%)}:host([action=e-resize]){right:-8px}:host([action=w-resize]){left:-8px}:host([action=ne-resize]){cursor:nesw-resize;right:-8px;top:-8px}:host([action=nw-resize]){cursor:nwse-resize;left:-8px;top:-8px}:host([action=se-resize]){bottom:-8px;cursor:nwse-resize;right:-8px}:host([action=se-resize]):after{height:15px;width:15px}@media (pointer:coarse){:host([action=se-resize]):after{height:10px;width:10px}}@media (pointer:fine){:host([action=se-resize]):after{height:5px;width:5px}}:host([action=sw-resize]){bottom:-8px;cursor:nesw-resize;left:-8px}:host([plain]){background-color:transparent}`;
1668
1712
 
@@ -1685,7 +1729,7 @@ class CropperHandle extends CropperElement {
1685
1729
  }
1686
1730
  }
1687
1731
  CropperHandle.$name = CROPPER_HANDLE;
1688
- CropperHandle.$version = '2.0.0';
1732
+ CropperHandle.$version = '2.1.0';
1689
1733
 
1690
1734
  var style$3 = `:host{display:block;left:0;position:relative;right:0}:host([outlined]){outline:1px solid var(--theme-color)}:host([multiple]){outline:1px dashed hsla(0,0%,100%,.5)}:host([multiple]):after{bottom:0;content:"";cursor:pointer;display:block;left:0;position:absolute;right:0;top:0}:host([multiple][active]){outline-color:var(--theme-color);z-index:1}:host([multiple])>*{visibility:hidden}:host([multiple][active])>*{visibility:visible}:host([multiple][active]):after{display:none}`;
1691
1735
 
@@ -1971,10 +2015,13 @@ class CropperSelection extends CropperElement {
1971
2015
  }
1972
2016
  const { relatedEvent } = detail;
1973
2017
  let { action } = detail;
2018
+ const relatedTarget = relatedEvent
2019
+ ? getComposedPathTarget(relatedEvent)
2020
+ : null;
1974
2021
  // Switching to another selection
1975
2022
  if (!action && this.multiple) {
1976
2023
  // Get the `action` property from the focusing in selection
1977
- action = this.$action || (relatedEvent === null || relatedEvent === void 0 ? void 0 : relatedEvent.target.action);
2024
+ action = this.$action || (relatedTarget === null || relatedTarget === void 0 ? void 0 : relatedTarget.action);
1978
2025
  this.$action = action;
1979
2026
  }
1980
2027
  if (!action
@@ -1982,9 +2029,9 @@ class CropperSelection extends CropperElement {
1982
2029
  || (this.multiple && !this.active && action !== ACTION_SCALE)) {
1983
2030
  return;
1984
2031
  }
1985
- const moveX = detail.endX - detail.startX;
1986
- const moveY = detail.endY - detail.startY;
1987
2032
  const { width, height } = this;
2033
+ let moveX = detail.endX - detail.startX;
2034
+ let moveY = detail.endY - detail.startY;
1988
2035
  let { aspectRatio } = this;
1989
2036
  // Locking aspect ratio by holding shift key
1990
2037
  if (!isPositiveNumber(aspectRatio) && relatedEvent.shiftKey) {
@@ -1992,7 +2039,14 @@ class CropperSelection extends CropperElement {
1992
2039
  }
1993
2040
  switch (action) {
1994
2041
  case ACTION_SELECT:
1995
- if (moveX !== 0 && moveY !== 0) {
2042
+ if (moveX !== 0 || moveY !== 0) {
2043
+ // Force to create a square selection for better user experience
2044
+ if (moveX === 0) {
2045
+ moveX = moveY;
2046
+ }
2047
+ else if (moveY === 0) {
2048
+ moveY = moveX;
2049
+ }
1996
2050
  const { $canvas } = this;
1997
2051
  const offset = getOffset(currentTarget);
1998
2052
  (this.multiple && !this.hidden ? this.$createSelection() : this).$change(detail.startX - offset.left, detail.startY - offset.top, Math.abs(moveX), Math.abs(moveY), aspectRatio);
@@ -2517,7 +2571,7 @@ class CropperSelection extends CropperElement {
2517
2571
  }
2518
2572
  }
2519
2573
  CropperSelection.$name = CROPPER_SELECTION;
2520
- CropperSelection.$version = '2.0.0';
2574
+ CropperSelection.$version = '2.1.0';
2521
2575
 
2522
2576
  var style$2 = `:host{display:flex;flex-direction:column;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([bordered]){border:1px dashed var(--theme-color)}:host([covered]){bottom:0;left:0;position:absolute;right:0;top:0}:host>span{display:flex;flex:1}:host>span+span{border-top:1px dashed var(--theme-color)}:host>span>span{flex:1}:host>span>span+span{border-left:1px dashed var(--theme-color)}`;
2523
2577
 
@@ -2575,7 +2629,7 @@ class CropperGrid extends CropperElement {
2575
2629
  }
2576
2630
  }
2577
2631
  CropperGrid.$name = CROPPER_GIRD;
2578
- CropperGrid.$version = '2.0.0';
2632
+ CropperGrid.$version = '2.1.0';
2579
2633
 
2580
2634
  var style$1 = `:host{display:inline-block;height:1em;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1em}:host:after,:host:before{background-color:var(--theme-color);content:"";display:block;position:absolute}:host:before{height:1px;left:0;top:50%;transform:translateY(-50%);width:100%}:host:after{height:100%;left:50%;top:0;transform:translateX(-50%);width:1px}:host([centered]){left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}`;
2581
2635
 
@@ -2594,7 +2648,7 @@ class CropperCrosshair extends CropperElement {
2594
2648
  }
2595
2649
  }
2596
2650
  CropperCrosshair.$name = CROPPER_CROSSHAIR;
2597
- CropperCrosshair.$version = '2.0.0';
2651
+ CropperCrosshair.$version = '2.1.0';
2598
2652
 
2599
2653
  var style = `:host{display:block;height:100%;overflow:hidden;position:relative;width:100%}`;
2600
2654
 
@@ -2649,10 +2703,11 @@ class CropperViewer extends CropperElement {
2649
2703
  ]);
2650
2704
  }
2651
2705
  connectedCallback() {
2706
+ var _a, _b;
2652
2707
  super.connectedCallback();
2653
2708
  let $selection = null;
2654
2709
  if (this.selection) {
2655
- $selection = this.ownerDocument.querySelector(this.selection);
2710
+ $selection = (_b = (_a = getRootDocument(this)) === null || _a === void 0 ? void 0 : _a.querySelector(this.selection)) !== null && _b !== void 0 ? _b : null;
2656
2711
  }
2657
2712
  else {
2658
2713
  $selection = this.closest(this.$getTagNameOf(CROPPER_SELECTION));
@@ -2695,7 +2750,7 @@ class CropperViewer extends CropperElement {
2695
2750
  super.disconnectedCallback();
2696
2751
  }
2697
2752
  $handleSelectionChange(event) {
2698
- this.$render(event.detail);
2753
+ this.$render(event.defaultPrevented ? this.$selection : event.detail);
2699
2754
  }
2700
2755
  $handleSourceImageLoad() {
2701
2756
  const { $image, $sourceImage } = this;
@@ -2704,9 +2759,7 @@ class CropperViewer extends CropperElement {
2704
2759
  if (newSrc && newSrc !== oldSrc) {
2705
2760
  $image.setAttribute('src', newSrc);
2706
2761
  $image.$ready(() => {
2707
- setTimeout(() => {
2708
- this.$render();
2709
- }, 50);
2762
+ this.$render();
2710
2763
  });
2711
2764
  }
2712
2765
  }
@@ -2765,7 +2818,10 @@ class CropperViewer extends CropperElement {
2765
2818
  this.$scale = scale;
2766
2819
  this.$setStyles(styles);
2767
2820
  if (this.$sourceImage) {
2768
- this.$transformImageByOffset(matrix !== null && matrix !== void 0 ? matrix : this.$sourceImage.$getTransform(), -x, -y);
2821
+ // Transform the image by the selection offset after the next DOM update cycle
2822
+ setTimeout(() => {
2823
+ this.$transformImageByOffset(matrix !== null && matrix !== void 0 ? matrix : this.$sourceImage.$getTransform(), -x, -y);
2824
+ });
2769
2825
  }
2770
2826
  }
2771
2827
  $transformImageByOffset(matrix, x, y) {
@@ -2787,7 +2843,7 @@ class CropperViewer extends CropperElement {
2787
2843
  }
2788
2844
  }
2789
2845
  CropperViewer.$name = CROPPER_VIEWER;
2790
- CropperViewer.$version = '2.0.0';
2846
+ CropperViewer.$version = '2.1.0';
2791
2847
 
2792
2848
  var DEFAULT_TEMPLATE = ('<cropper-canvas background>'
2793
2849
  + '<cropper-image rotatable scalable skewable translatable></cropper-image>'
@@ -2823,6 +2879,7 @@ CropperShade.$define();
2823
2879
  CropperViewer.$define();
2824
2880
  class Cropper {
2825
2881
  constructor(element, options) {
2882
+ var _a;
2826
2883
  this.options = DEFAULT_OPTIONS;
2827
2884
  if (isString(element)) {
2828
2885
  element = document.querySelector(element);
@@ -2833,11 +2890,10 @@ class Cropper {
2833
2890
  this.element = element;
2834
2891
  options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
2835
2892
  this.options = options;
2836
- const { ownerDocument } = element;
2837
2893
  let { container } = options;
2838
2894
  if (container) {
2839
2895
  if (isString(container)) {
2840
- container = ownerDocument.querySelector(container);
2896
+ container = (_a = getRootDocument(element)) === null || _a === void 0 ? void 0 : _a.querySelector(container);
2841
2897
  }
2842
2898
  if (!isElement(container)) {
2843
2899
  throw new Error('The `container` option must be an element or a valid selector.');
@@ -2848,7 +2904,7 @@ class Cropper {
2848
2904
  container = element.parentElement;
2849
2905
  }
2850
2906
  else {
2851
- container = ownerDocument.body;
2907
+ container = element.ownerDocument.body;
2852
2908
  }
2853
2909
  }
2854
2910
  this.container = container;
@@ -2869,6 +2925,23 @@ class Cropper {
2869
2925
  Array.from(documentFragment.querySelectorAll(CROPPER_IMAGE)).forEach((image) => {
2870
2926
  image.setAttribute('src', src);
2871
2927
  image.setAttribute('alt', element.alt || 'The image to crop');
2928
+ // Inherit additional attributes from HTMLImageElement
2929
+ if (tagName === 'img') {
2930
+ [
2931
+ 'crossorigin',
2932
+ 'decoding',
2933
+ 'elementtiming',
2934
+ 'fetchpriority',
2935
+ 'loading',
2936
+ 'referrerpolicy',
2937
+ 'sizes',
2938
+ 'srcset',
2939
+ ].forEach((attribute) => {
2940
+ if (element.hasAttribute(attribute)) {
2941
+ image.setAttribute(attribute, element.getAttribute(attribute) || '');
2942
+ }
2943
+ });
2944
+ }
2872
2945
  });
2873
2946
  if (element.parentElement) {
2874
2947
  element.style.display = 'none';
@@ -2891,7 +2964,17 @@ class Cropper {
2891
2964
  getCropperSelections() {
2892
2965
  return this.container.querySelectorAll(CROPPER_SELECTION);
2893
2966
  }
2967
+ destroy() {
2968
+ var _a;
2969
+ const cropperCanvas = this.getCropperCanvas();
2970
+ if (cropperCanvas) {
2971
+ (_a = cropperCanvas.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(cropperCanvas);
2972
+ }
2973
+ if (this.element) {
2974
+ this.element.style.display = '';
2975
+ }
2976
+ }
2894
2977
  }
2895
- Cropper.version = '2.0.0';
2978
+ Cropper.version = '2.1.0';
2896
2979
 
2897
- export { ACTION_MOVE, ACTION_NONE, ACTION_RESIZE_EAST, ACTION_RESIZE_NORTH, ACTION_RESIZE_NORTHEAST, ACTION_RESIZE_NORTHWEST, ACTION_RESIZE_SOUTH, ACTION_RESIZE_SOUTHEAST, ACTION_RESIZE_SOUTHWEST, ACTION_RESIZE_WEST, ACTION_ROTATE, ACTION_SCALE, ACTION_SELECT, ACTION_TRANSFORM, ATTRIBUTE_ACTION, CROPPER_CANVAS, CROPPER_CROSSHAIR, CROPPER_GIRD, CROPPER_HANDLE, CROPPER_IMAGE, CROPPER_SELECTION, CROPPER_SHADE, CROPPER_VIEWER, CropperCanvas, CropperCrosshair, CropperElement, CropperGrid, CropperHandle, CropperImage, CropperSelection, CropperShade, CropperViewer, DEFAULT_TEMPLATE, EVENT_ACTION, EVENT_ACTION_END, EVENT_ACTION_MOVE, EVENT_ACTION_START, EVENT_CHANGE, EVENT_ERROR, EVENT_KEYDOWN, EVENT_LOAD, EVENT_POINTER_DOWN, EVENT_POINTER_MOVE, EVENT_POINTER_UP, EVENT_RESIZE, EVENT_TOUCH_END, EVENT_TOUCH_MOVE, EVENT_TOUCH_START, EVENT_TRANSFORM, EVENT_WHEEL, HAS_POINTER_EVENT, IS_BROWSER, IS_TOUCH_DEVICE, NAMESPACE, WINDOW, Cropper as default, emit, getAdjustedSizes, getOffset, isElement, isFunction, isNaN, isNumber, isObject, isPlainObject, isPositiveNumber, isString, isUndefined, multiplyMatrices, nextTick, off, on, once, toAngleInRadian, toCamelCase, toKebabCase };
2980
+ export { ACTION_MOVE, ACTION_NONE, ACTION_RESIZE_EAST, ACTION_RESIZE_NORTH, ACTION_RESIZE_NORTHEAST, ACTION_RESIZE_NORTHWEST, ACTION_RESIZE_SOUTH, ACTION_RESIZE_SOUTHEAST, ACTION_RESIZE_SOUTHWEST, ACTION_RESIZE_WEST, ACTION_ROTATE, ACTION_SCALE, ACTION_SELECT, ACTION_TRANSFORM, ATTRIBUTE_ACTION, CROPPER_CANVAS, CROPPER_CROSSHAIR, CROPPER_GIRD, CROPPER_HANDLE, CROPPER_IMAGE, CROPPER_SELECTION, CROPPER_SHADE, CROPPER_VIEWER, CropperCanvas, CropperCrosshair, CropperElement, CropperGrid, CropperHandle, CropperImage, CropperSelection, CropperShade, CropperViewer, DEFAULT_TEMPLATE, EVENT_ACTION, EVENT_ACTION_END, EVENT_ACTION_MOVE, EVENT_ACTION_START, EVENT_CHANGE, EVENT_ERROR, EVENT_KEYDOWN, EVENT_LOAD, EVENT_POINTER_DOWN, EVENT_POINTER_MOVE, EVENT_POINTER_UP, EVENT_RESIZE, EVENT_TOUCH_END, EVENT_TOUCH_MOVE, EVENT_TOUCH_START, EVENT_TRANSFORM, EVENT_WHEEL, HAS_POINTER_EVENT, IS_BROWSER, IS_TOUCH_DEVICE, NAMESPACE, WINDOW, Cropper as default, emit, getAdjustedSizes, getComposedPathTarget, getOffset, getRootDocument, isElement, isFunction, isNaN, isNumber, isObject, isPlainObject, isPositiveNumber, isString, isUndefined, multiplyMatrices, nextTick, off, on, once, toAngleInRadian, toCamelCase, toKebabCase };