@paperless/core 2.22.0-alpha.27 → 2.22.0-alpha.29

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 (213) hide show
  1. package/dist/build/index.esm.js +1 -1
  2. package/dist/{paperless/p-84c43a3d.entry.js → build/p-1c17ee9b.entry.js} +1 -1
  3. package/dist/build/p-25961586.entry.js +1 -0
  4. package/dist/{paperless/p-9f51b9dc.entry.js → build/p-260a97c9.entry.js} +1 -1
  5. package/dist/build/{p-44da0b12.entry.js → p-2a37b400.entry.js} +1 -1
  6. package/dist/build/{p-fff6fa7a.entry.js → p-31399606.entry.js} +1 -1
  7. package/dist/build/{p-fa519af0.js → p-5f422b65.js} +1 -1
  8. package/dist/build/p-60923e39.entry.js +1 -0
  9. package/dist/{paperless/p-d24f045f.entry.js → build/p-6aa93bf9.entry.js} +1 -1
  10. package/dist/build/{p-e51c1cd6.entry.js → p-70974f53.entry.js} +1 -1
  11. package/dist/build/p-75ba802e.entry.js +3 -0
  12. package/dist/build/{p-b781e8db.entry.js → p-8c1bf7ea.entry.js} +1 -1
  13. package/dist/{paperless/p-7d018d4d.entry.js → build/p-9e06356b.entry.js} +1 -1
  14. package/dist/build/p-B_lDCj8j.js +1 -0
  15. package/dist/build/p-CeBIrPPx.js +1 -0
  16. package/dist/build/{p-78b15121.entry.js → p-a6369294.entry.js} +1 -1
  17. package/dist/build/p-a9c0aab3.entry.js +1 -0
  18. package/dist/build/p-b85ee4b7.entry.js +1 -0
  19. package/dist/build/{p-76f83633.entry.js → p-ba7ccf80.entry.js} +1 -1
  20. package/dist/build/{p-524eb1cb.entry.js → p-c16870f5.entry.js} +1 -1
  21. package/dist/build/{p-17e598ac.entry.js → p-cf436a7d.entry.js} +1 -1
  22. package/dist/build/{p-0d6f3aa3.entry.js → p-cfbd02e6.entry.js} +1 -1
  23. package/dist/build/{p-cbeb58ba.entry.js → p-e907c9d3.entry.js} +1 -1
  24. package/dist/build/{p-d9b3ace4.entry.js → p-ee7858e4.entry.js} +1 -1
  25. package/dist/build/{p-23cc6b6b.entry.js → p-f1c6f25b.entry.js} +1 -1
  26. package/dist/{paperless/p-5abcc8d2.entry.js → build/p-f5be155f.entry.js} +1 -1
  27. package/dist/build/p-xs4N_Y-0.js +1 -0
  28. package/dist/build/paperless.esm.js +1 -1
  29. package/dist/cjs/{cn-BGmLaIp8.js → cn-Cd68UVBT.js} +30 -274
  30. package/dist/cjs/{floating-ui.dom-33QlkSyu.js → floating-ui.dom-DEq7yeQK.js} +91 -50
  31. package/dist/cjs/index.cjs.js +1 -1
  32. package/dist/cjs/locale-BIZDGOk_.js +75117 -0
  33. package/dist/cjs/p-accordion.cjs.entry.js +1 -1
  34. package/dist/cjs/p-attachment.cjs.entry.js +1 -1
  35. package/dist/cjs/p-badge_3.cjs.entry.js +1 -1
  36. package/dist/cjs/p-button_3.cjs.entry.js +6 -6
  37. package/dist/cjs/p-calendar.cjs.entry.js +75 -302
  38. package/dist/cjs/p-card-container.cjs.entry.js +1 -1
  39. package/dist/cjs/p-checkbox_3.cjs.entry.js +2 -2
  40. package/dist/cjs/p-content-slider.cjs.entry.js +1 -1
  41. package/dist/cjs/p-cropper.cjs.entry.js +88 -32
  42. package/dist/cjs/p-datepicker.cjs.entry.js +41 -2891
  43. package/dist/cjs/p-divider.cjs.entry.js +1 -1
  44. package/dist/cjs/p-dropdown-menu-item_2.cjs.entry.js +1 -1
  45. package/dist/cjs/p-empty-state_8.cjs.entry.js +12 -18
  46. package/dist/cjs/p-field_3.cjs.entry.js +1 -1
  47. package/dist/cjs/p-illustration.cjs.entry.js +1 -1
  48. package/dist/cjs/p-label.cjs.entry.js +1 -1
  49. package/dist/cjs/p-listing.cjs.entry.js +1 -1
  50. package/dist/cjs/p-navigation-item.cjs.entry.js +1 -1
  51. package/dist/cjs/p-pagination_3.cjs.entry.js +2 -2
  52. package/dist/cjs/p-select.cjs.entry.js +1 -1
  53. package/dist/cjs/p-table.cjs.entry.js +1 -1
  54. package/dist/cjs/p-tooltip.cjs.entry.js +1 -1
  55. package/dist/collection/components/atoms/loader/loader.component.js +1 -1
  56. package/dist/collection/components/molecules/button/button.component.js +8 -7
  57. package/dist/collection/components/molecules/calendar/calendar.component.js +1 -2
  58. package/dist/collection/components/molecules/datepicker/datepicker.component.js +2 -2
  59. package/dist/collection/components/molecules/pagination/pages/pagination-pages.component.js +1 -1
  60. package/dist/components/index.js +1 -1
  61. package/dist/components/{p-BtuWYjfq.js → p--JDhF4GL.js} +1 -1
  62. package/dist/components/{p-DW-MndqD.js → p-0y7dmBHx.js} +1 -1
  63. package/dist/components/{p-DxmwiGc9.js → p-B4tCVctO.js} +1 -1
  64. package/dist/components/{p-LfH4pSix.js → p-BA1QFuzs.js} +1 -1
  65. package/dist/components/{p-Bno5n2sV.js → p-BBmuctek.js} +1 -1
  66. package/dist/components/p-BE2DRulM.js +1 -0
  67. package/dist/components/{p-Dbt4VuQm.js → p-BPP8ZYwN.js} +1 -1
  68. package/dist/components/{p-BeiMfpUZ.js → p-BV-h5ALt.js} +1 -1
  69. package/dist/components/{p-C_dax2wr.js → p-BX8yg_1a.js} +1 -1
  70. package/dist/components/{p-CjI4hMLv.js → p-BaXKEl7X.js} +1 -1
  71. package/dist/components/{p-BfJQbKrn.js → p-CCvROjOe.js} +1 -1
  72. package/dist/components/p-CHydrUrt.js +1 -0
  73. package/dist/components/{p-Bi6PK1YV.js → p-CccN0jY7.js} +1 -1
  74. package/dist/components/p-CeBIrPPx.js +1 -0
  75. package/dist/components/{p-BMb-TnTI.js → p-Coxruux_.js} +1 -1
  76. package/dist/components/{p-B9n8mzrj.js → p-DAuzJ_qL.js} +1 -1
  77. package/dist/components/{p-BAIZ48ms.js → p-DZjr9R4d.js} +1 -1
  78. package/dist/components/{p-BBNOzE00.js → p-Djf2rBRX.js} +1 -1
  79. package/dist/components/p-Dl4hxOHI.js +1 -0
  80. package/dist/components/{p-BIQLsxW1.js → p-DuYGcgJi.js} +1 -1
  81. package/dist/components/{p-CFu8cH3m.js → p-DxNTB_Qq.js} +1 -1
  82. package/dist/components/{p-CgOKCXab.js → p-JhZXmipA.js} +1 -1
  83. package/dist/components/{p-ChfXIxTQ.js → p-KuL1SNit.js} +1 -1
  84. package/dist/components/p-accordion.js +1 -1
  85. package/dist/components/p-attachment.js +1 -1
  86. package/dist/components/p-button.js +1 -1
  87. package/dist/components/p-calendar.js +1 -1
  88. package/dist/components/p-card-container.js +1 -1
  89. package/dist/components/p-card-header.js +1 -1
  90. package/dist/components/p-content-slider.js +1 -1
  91. package/dist/components/p-cropper.js +2 -2
  92. package/dist/components/p-datepicker.js +1 -1
  93. package/dist/components/p-divider.js +1 -1
  94. package/dist/components/p-drawer-header.js +1 -1
  95. package/dist/components/p-drawer.js +1 -1
  96. package/dist/components/p-dropdown-menu-item.js +1 -1
  97. package/dist/components/p-dropdown.js +1 -1
  98. package/dist/components/p-empty-state.js +1 -1
  99. package/dist/components/p-field-container.js +1 -1
  100. package/dist/components/p-field.js +1 -1
  101. package/dist/components/p-floating-menu-container.js +1 -1
  102. package/dist/components/p-helper.js +1 -1
  103. package/dist/components/p-illustration.js +1 -1
  104. package/dist/components/p-label.js +1 -1
  105. package/dist/components/p-listing.js +1 -1
  106. package/dist/components/p-modal-footer.js +1 -1
  107. package/dist/components/p-modal-header.js +1 -1
  108. package/dist/components/p-modal.js +1 -1
  109. package/dist/components/p-navbar.js +1 -1
  110. package/dist/components/p-navigation-item.js +1 -1
  111. package/dist/components/p-pagination-pages.js +1 -1
  112. package/dist/components/p-pagination-size.js +1 -1
  113. package/dist/components/p-pagination.js +1 -1
  114. package/dist/components/{p-PFAC3Kay.js → p-prb4IQlb.js} +1 -1
  115. package/dist/components/p-profile.js +1 -1
  116. package/dist/components/p-segment-item.js +1 -1
  117. package/dist/components/p-select.js +1 -1
  118. package/dist/components/{p-CCOwunss.js → p-swqKzLDH.js} +1 -1
  119. package/dist/components/p-tab-container.js +1 -1
  120. package/dist/components/p-table-cell.js +1 -1
  121. package/dist/components/p-table-footer.js +1 -1
  122. package/dist/components/p-table-header.js +1 -1
  123. package/dist/components/p-table-row-actions-container.js +1 -1
  124. package/dist/components/p-table-row.js +1 -1
  125. package/dist/components/p-table.js +1 -1
  126. package/dist/components/p-tooltip.js +1 -1
  127. package/dist/components/p-xs4N_Y-0.js +1 -0
  128. package/dist/esm/{cn-BniKgfyU.js → cn-CsNqHcjL.js} +30 -274
  129. package/dist/esm/{floating-ui.dom-DGLCmOXW.js → floating-ui.dom-CeBIrPPx.js} +91 -50
  130. package/dist/esm/index.js +1 -1
  131. package/dist/esm/locale-B_lDCj8j.js +75114 -0
  132. package/dist/esm/p-accordion.entry.js +1 -1
  133. package/dist/esm/p-attachment.entry.js +1 -1
  134. package/dist/esm/p-badge_3.entry.js +1 -1
  135. package/dist/esm/p-button_3.entry.js +6 -6
  136. package/dist/esm/p-calendar.entry.js +63 -290
  137. package/dist/esm/p-card-container.entry.js +1 -1
  138. package/dist/esm/p-checkbox_3.entry.js +2 -2
  139. package/dist/esm/p-content-slider.entry.js +1 -1
  140. package/dist/esm/p-cropper.entry.js +88 -32
  141. package/dist/esm/p-datepicker.entry.js +37 -2887
  142. package/dist/esm/p-divider.entry.js +1 -1
  143. package/dist/esm/p-dropdown-menu-item_2.entry.js +1 -1
  144. package/dist/esm/p-empty-state_8.entry.js +12 -18
  145. package/dist/esm/p-field_3.entry.js +1 -1
  146. package/dist/esm/p-illustration.entry.js +1 -1
  147. package/dist/esm/p-label.entry.js +1 -1
  148. package/dist/esm/p-listing.entry.js +1 -1
  149. package/dist/esm/p-navigation-item.entry.js +1 -1
  150. package/dist/esm/p-pagination_3.entry.js +2 -2
  151. package/dist/esm/p-select.entry.js +1 -1
  152. package/dist/esm/p-table.entry.js +1 -1
  153. package/dist/esm/p-tooltip.entry.js +1 -1
  154. package/dist/index.html +1 -1
  155. package/dist/paperless/index.esm.js +1 -1
  156. package/dist/{build/p-84c43a3d.entry.js → paperless/p-1c17ee9b.entry.js} +1 -1
  157. package/dist/paperless/p-25961586.entry.js +1 -0
  158. package/dist/{build/p-9f51b9dc.entry.js → paperless/p-260a97c9.entry.js} +1 -1
  159. package/dist/paperless/{p-44da0b12.entry.js → p-2a37b400.entry.js} +1 -1
  160. package/dist/paperless/{p-fff6fa7a.entry.js → p-31399606.entry.js} +1 -1
  161. package/dist/paperless/p-60923e39.entry.js +1 -0
  162. package/dist/{build/p-d24f045f.entry.js → paperless/p-6aa93bf9.entry.js} +1 -1
  163. package/dist/paperless/{p-e51c1cd6.entry.js → p-70974f53.entry.js} +1 -1
  164. package/dist/paperless/p-75ba802e.entry.js +3 -0
  165. package/dist/paperless/{p-b781e8db.entry.js → p-8c1bf7ea.entry.js} +1 -1
  166. package/dist/{build/p-7d018d4d.entry.js → paperless/p-9e06356b.entry.js} +1 -1
  167. package/dist/paperless/p-B_lDCj8j.js +1 -0
  168. package/dist/paperless/p-CeBIrPPx.js +1 -0
  169. package/dist/paperless/{p-78b15121.entry.js → p-a6369294.entry.js} +1 -1
  170. package/dist/paperless/p-a9c0aab3.entry.js +1 -0
  171. package/dist/paperless/p-b85ee4b7.entry.js +1 -0
  172. package/dist/paperless/{p-76f83633.entry.js → p-ba7ccf80.entry.js} +1 -1
  173. package/dist/paperless/{p-524eb1cb.entry.js → p-c16870f5.entry.js} +1 -1
  174. package/dist/paperless/{p-17e598ac.entry.js → p-cf436a7d.entry.js} +1 -1
  175. package/dist/paperless/{p-0d6f3aa3.entry.js → p-cfbd02e6.entry.js} +1 -1
  176. package/dist/paperless/{p-cbeb58ba.entry.js → p-e907c9d3.entry.js} +1 -1
  177. package/dist/paperless/{p-d9b3ace4.entry.js → p-ee7858e4.entry.js} +1 -1
  178. package/dist/paperless/{p-23cc6b6b.entry.js → p-f1c6f25b.entry.js} +1 -1
  179. package/dist/{build/p-5abcc8d2.entry.js → paperless/p-f5be155f.entry.js} +1 -1
  180. package/dist/paperless/p-xs4N_Y-0.js +1 -0
  181. package/dist/paperless/paperless.esm.js +1 -1
  182. package/dist/sw.js +1 -1
  183. package/dist/sw.js.map +1 -1
  184. package/dist/types/components/molecules/button/button.component.d.ts +1 -1
  185. package/dist/types/components.d.ts +3 -1
  186. package/dist/workbox-d13932f0.js +1 -1
  187. package/dist/workbox-d13932f0.js.map +1 -1
  188. package/hydrate/index.js +75313 -6268
  189. package/hydrate/index.mjs +75313 -6268
  190. package/package.json +10 -11
  191. package/dist/build/p-1f7ab568.entry.js +0 -1
  192. package/dist/build/p-20077155.entry.js +0 -1
  193. package/dist/build/p-3452b2f5.entry.js +0 -3
  194. package/dist/build/p-CT54OXR2.js +0 -1
  195. package/dist/build/p-DGLCmOXW.js +0 -1
  196. package/dist/build/p-KEbntKvf.js +0 -1
  197. package/dist/build/p-b090e928.entry.js +0 -1
  198. package/dist/build/p-bafe9297.entry.js +0 -1
  199. package/dist/cjs/index-DG6V15XP.js +0 -2871
  200. package/dist/components/p-CPpl-J0y.js +0 -1
  201. package/dist/components/p-CT54OXR2.js +0 -1
  202. package/dist/components/p-D4bALv5t.js +0 -1
  203. package/dist/components/p-DGLCmOXW.js +0 -1
  204. package/dist/components/p-DeSgaQxj.js +0 -1
  205. package/dist/esm/index-KEbntKvf.js +0 -2839
  206. package/dist/paperless/p-1f7ab568.entry.js +0 -1
  207. package/dist/paperless/p-20077155.entry.js +0 -1
  208. package/dist/paperless/p-3452b2f5.entry.js +0 -3
  209. package/dist/paperless/p-CT54OXR2.js +0 -1
  210. package/dist/paperless/p-DGLCmOXW.js +0 -1
  211. package/dist/paperless/p-KEbntKvf.js +0 -1
  212. package/dist/paperless/p-b090e928.entry.js +0 -1
  213. package/dist/paperless/p-bafe9297.entry.js +0 -1
@@ -204,6 +204,20 @@ const defaultEventOptions = {
204
204
  function emit(target, type, detail, options) {
205
205
  return target.dispatchEvent(new CustomEvent(type, Object.assign(Object.assign(Object.assign({}, defaultEventOptions), { detail }), options)));
206
206
  }
207
+ /**
208
+ * Get the real event target by checking composed path.
209
+ * This is useful when dealing with events that can cross shadow DOM boundaries.
210
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath}
211
+ * @param {Event} event The event object.
212
+ * @returns {EventTarget | null} The first element in the composed path, or the original event target.
213
+ */
214
+ function getComposedPathTarget(event) {
215
+ if (typeof event.composedPath === 'function') {
216
+ const path = event.composedPath();
217
+ return path.find(isElement) || event.target;
218
+ }
219
+ return event.target;
220
+ }
207
221
  const resolvedPromise = Promise.resolve();
208
222
  /**
209
223
  * Defers the callback to be executed after the next DOM update cycle.
@@ -216,6 +230,23 @@ function nextTick(context, callback) {
216
230
  ? resolvedPromise.then(context ? callback.bind(context) : callback)
217
231
  : resolvedPromise;
218
232
  }
233
+ /**
234
+ * Get the root document node.
235
+ * @param {Element} element The target element.
236
+ * @returns {Document|DocumentFragment|null} The document node.
237
+ */
238
+ function getRootDocument(element) {
239
+ const rootNode = element.getRootNode();
240
+ switch (rootNode.nodeType) {
241
+ case 1:
242
+ return rootNode.ownerDocument;
243
+ case 9:
244
+ return rootNode;
245
+ case 11:
246
+ return rootNode;
247
+ }
248
+ return null;
249
+ }
219
250
  /**
220
251
  * Get the offset base on the document.
221
252
  * @param {Element} element The target element.
@@ -432,12 +463,10 @@ class CropperElement extends HTMLElement {
432
463
  },
433
464
  });
434
465
  });
435
- const shadow = this.attachShadow({
466
+ const shadow = this.shadowRoot || this.attachShadow({
436
467
  mode: this.shadowRootMode || DEFAULT_SHADOW_ROOT_MODE,
437
468
  });
438
- if (!this.shadowRoot) {
439
- shadowRoots.set(this, shadow);
440
- }
469
+ shadowRoots.set(this, shadow);
441
470
  styleSheets.set(this, this.$addStyles(this.$sharedStyle));
442
471
  if (this.$style) {
443
472
  this.$addStyles(this.$style);
@@ -545,7 +574,7 @@ class CropperElement extends HTMLElement {
545
574
  }
546
575
  }
547
576
  }
548
- CropperElement.$version = '2.0.0';
577
+ CropperElement.$version = '2.1.0';
549
578
 
550
579
  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}`;
551
580
 
@@ -990,7 +1019,7 @@ class CropperCanvas extends CropperElement {
990
1019
  }
991
1020
  }
992
1021
  CropperCanvas.$name = CROPPER_CANVAS;
993
- CropperCanvas.$version = '2.0.0';
1022
+ CropperCanvas.$version = '2.1.0';
994
1023
 
995
1024
  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%}`;
996
1025
 
@@ -999,7 +1028,8 @@ const NATIVE_ATTRIBUTES = [
999
1028
  'alt',
1000
1029
  'crossorigin',
1001
1030
  'decoding',
1002
- 'importance',
1031
+ 'elementtiming',
1032
+ 'fetchpriority',
1003
1033
  'loading',
1004
1034
  'referrerpolicy',
1005
1035
  'sizes',
@@ -1023,6 +1053,17 @@ class CropperImage extends CropperElement {
1023
1053
  this.skewable = false;
1024
1054
  this.slottable = false;
1025
1055
  this.translatable = false;
1056
+ // Native attributes
1057
+ this.alt = '';
1058
+ this.crossorigin = '';
1059
+ this.decoding = '';
1060
+ this.elementtiming = '';
1061
+ this.fetchpriority = '';
1062
+ this.loading = '';
1063
+ this.referrerpolicy = '';
1064
+ this.sizes = '';
1065
+ this.src = '';
1066
+ this.srcset = '';
1026
1067
  }
1027
1068
  set $canvas(element) {
1028
1069
  canvasCache$3.set(this, element);
@@ -1258,7 +1299,10 @@ class CropperImage extends CropperElement {
1258
1299
  const onLoad = () => {
1259
1300
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
1260
1301
  off($image, EVENT_ERROR, onError);
1261
- resolve($image);
1302
+ // Ensure the image is fully rendered.
1303
+ setTimeout(() => {
1304
+ resolve($image);
1305
+ });
1262
1306
  };
1263
1307
  const onError = () => {
1264
1308
  off($image, EVENT_LOAD, onLoad);
@@ -1537,7 +1581,7 @@ class CropperImage extends CropperElement {
1537
1581
  }
1538
1582
  }
1539
1583
  CropperImage.$name = CROPPER_IMAGE;
1540
- CropperImage.$version = '2.0.0';
1584
+ CropperImage.$version = '2.1.0';
1541
1585
 
1542
1586
  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}`;
1543
1587
 
@@ -1545,9 +1589,9 @@ const canvasCache$2 = new WeakMap();
1545
1589
  class CropperShade extends CropperElement {
1546
1590
  constructor() {
1547
1591
  super(...arguments);
1548
- this.$onCanvasChange = null;
1549
1592
  this.$onCanvasActionEnd = null;
1550
1593
  this.$onCanvasActionStart = null;
1594
+ this.$onSelectionChange = null;
1551
1595
  this.$style = style$5;
1552
1596
  this.x = 0;
1553
1597
  this.y = 0;
@@ -1588,8 +1632,8 @@ class CropperShade extends CropperElement {
1588
1632
  this.hidden = true;
1589
1633
  }
1590
1634
  };
1591
- this.$onCanvasChange = (event) => {
1592
- const { x, y, width, height, } = event.detail;
1635
+ this.$onSelectionChange = (event) => {
1636
+ const { x, y, width, height, } = event.defaultPrevented ? $selection : event.detail;
1593
1637
  this.$change(x, y, width, height);
1594
1638
  if ($selection.hidden || (x === 0 && y === 0 && width === 0 && height === 0)) {
1595
1639
  this.hidden = true;
@@ -1597,7 +1641,7 @@ class CropperShade extends CropperElement {
1597
1641
  };
1598
1642
  on($canvas, EVENT_ACTION_START, this.$onCanvasActionStart);
1599
1643
  on($canvas, EVENT_ACTION_END, this.$onCanvasActionEnd);
1600
- on($canvas, EVENT_CHANGE, this.$onCanvasChange);
1644
+ on($canvas, EVENT_CHANGE, this.$onSelectionChange);
1601
1645
  }
1602
1646
  }
1603
1647
  this.$render();
@@ -1613,9 +1657,9 @@ class CropperShade extends CropperElement {
1613
1657
  off($canvas, EVENT_ACTION_END, this.$onCanvasActionEnd);
1614
1658
  this.$onCanvasActionEnd = null;
1615
1659
  }
1616
- if (this.$onCanvasChange) {
1617
- off($canvas, EVENT_CHANGE, this.$onCanvasChange);
1618
- this.$onCanvasChange = null;
1660
+ if (this.$onSelectionChange) {
1661
+ off($canvas, EVENT_CHANGE, this.$onSelectionChange);
1662
+ this.$onSelectionChange = null;
1619
1663
  }
1620
1664
  }
1621
1665
  super.disconnectedCallback();
@@ -1666,7 +1710,7 @@ class CropperShade extends CropperElement {
1666
1710
  }
1667
1711
  }
1668
1712
  CropperShade.$name = CROPPER_SHADE;
1669
- CropperShade.$version = '2.0.0';
1713
+ CropperShade.$version = '2.1.0';
1670
1714
 
1671
1715
  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}`;
1672
1716
 
@@ -1689,7 +1733,7 @@ class CropperHandle extends CropperElement {
1689
1733
  }
1690
1734
  }
1691
1735
  CropperHandle.$name = CROPPER_HANDLE;
1692
- CropperHandle.$version = '2.0.0';
1736
+ CropperHandle.$version = '2.1.0';
1693
1737
 
1694
1738
  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}`;
1695
1739
 
@@ -1975,10 +2019,13 @@ class CropperSelection extends CropperElement {
1975
2019
  }
1976
2020
  const { relatedEvent } = detail;
1977
2021
  let { action } = detail;
2022
+ const relatedTarget = relatedEvent
2023
+ ? getComposedPathTarget(relatedEvent)
2024
+ : null;
1978
2025
  // Switching to another selection
1979
2026
  if (!action && this.multiple) {
1980
2027
  // Get the `action` property from the focusing in selection
1981
- action = this.$action || (relatedEvent === null || relatedEvent === void 0 ? void 0 : relatedEvent.target.action);
2028
+ action = this.$action || (relatedTarget === null || relatedTarget === void 0 ? void 0 : relatedTarget.action);
1982
2029
  this.$action = action;
1983
2030
  }
1984
2031
  if (!action
@@ -1986,9 +2033,9 @@ class CropperSelection extends CropperElement {
1986
2033
  || (this.multiple && !this.active && action !== ACTION_SCALE)) {
1987
2034
  return;
1988
2035
  }
1989
- const moveX = detail.endX - detail.startX;
1990
- const moveY = detail.endY - detail.startY;
1991
2036
  const { width, height } = this;
2037
+ let moveX = detail.endX - detail.startX;
2038
+ let moveY = detail.endY - detail.startY;
1992
2039
  let { aspectRatio } = this;
1993
2040
  // Locking aspect ratio by holding shift key
1994
2041
  if (!isPositiveNumber(aspectRatio) && relatedEvent.shiftKey) {
@@ -1996,7 +2043,14 @@ class CropperSelection extends CropperElement {
1996
2043
  }
1997
2044
  switch (action) {
1998
2045
  case ACTION_SELECT:
1999
- if (moveX !== 0 && moveY !== 0) {
2046
+ if (moveX !== 0 || moveY !== 0) {
2047
+ // Force to create a square selection for better user experience
2048
+ if (moveX === 0) {
2049
+ moveX = moveY;
2050
+ }
2051
+ else if (moveY === 0) {
2052
+ moveY = moveX;
2053
+ }
2000
2054
  const { $canvas } = this;
2001
2055
  const offset = getOffset(currentTarget);
2002
2056
  (this.multiple && !this.hidden ? this.$createSelection() : this).$change(detail.startX - offset.left, detail.startY - offset.top, Math.abs(moveX), Math.abs(moveY), aspectRatio);
@@ -2521,7 +2575,7 @@ class CropperSelection extends CropperElement {
2521
2575
  }
2522
2576
  }
2523
2577
  CropperSelection.$name = CROPPER_SELECTION;
2524
- CropperSelection.$version = '2.0.0';
2578
+ CropperSelection.$version = '2.1.0';
2525
2579
 
2526
2580
  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)}`;
2527
2581
 
@@ -2579,7 +2633,7 @@ class CropperGrid extends CropperElement {
2579
2633
  }
2580
2634
  }
2581
2635
  CropperGrid.$name = CROPPER_GIRD;
2582
- CropperGrid.$version = '2.0.0';
2636
+ CropperGrid.$version = '2.1.0';
2583
2637
 
2584
2638
  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%)}`;
2585
2639
 
@@ -2598,7 +2652,7 @@ class CropperCrosshair extends CropperElement {
2598
2652
  }
2599
2653
  }
2600
2654
  CropperCrosshair.$name = CROPPER_CROSSHAIR;
2601
- CropperCrosshair.$version = '2.0.0';
2655
+ CropperCrosshair.$version = '2.1.0';
2602
2656
 
2603
2657
  var style = `:host{display:block;height:100%;overflow:hidden;position:relative;width:100%}`;
2604
2658
 
@@ -2653,10 +2707,11 @@ class CropperViewer extends CropperElement {
2653
2707
  ]);
2654
2708
  }
2655
2709
  connectedCallback() {
2710
+ var _a, _b;
2656
2711
  super.connectedCallback();
2657
2712
  let $selection = null;
2658
2713
  if (this.selection) {
2659
- $selection = this.ownerDocument.querySelector(this.selection);
2714
+ $selection = (_b = (_a = getRootDocument(this)) === null || _a === void 0 ? void 0 : _a.querySelector(this.selection)) !== null && _b !== void 0 ? _b : null;
2660
2715
  }
2661
2716
  else {
2662
2717
  $selection = this.closest(this.$getTagNameOf(CROPPER_SELECTION));
@@ -2699,7 +2754,7 @@ class CropperViewer extends CropperElement {
2699
2754
  super.disconnectedCallback();
2700
2755
  }
2701
2756
  $handleSelectionChange(event) {
2702
- this.$render(event.detail);
2757
+ this.$render(event.defaultPrevented ? this.$selection : event.detail);
2703
2758
  }
2704
2759
  $handleSourceImageLoad() {
2705
2760
  const { $image, $sourceImage } = this;
@@ -2708,9 +2763,7 @@ class CropperViewer extends CropperElement {
2708
2763
  if (newSrc && newSrc !== oldSrc) {
2709
2764
  $image.setAttribute('src', newSrc);
2710
2765
  $image.$ready(() => {
2711
- setTimeout(() => {
2712
- this.$render();
2713
- }, 50);
2766
+ this.$render();
2714
2767
  });
2715
2768
  }
2716
2769
  }
@@ -2769,7 +2822,10 @@ class CropperViewer extends CropperElement {
2769
2822
  this.$scale = scale;
2770
2823
  this.$setStyles(styles);
2771
2824
  if (this.$sourceImage) {
2772
- this.$transformImageByOffset(matrix !== null && matrix !== void 0 ? matrix : this.$sourceImage.$getTransform(), -x, -y);
2825
+ // Transform the image by the selection offset after the next DOM update cycle
2826
+ setTimeout(() => {
2827
+ this.$transformImageByOffset(matrix !== null && matrix !== void 0 ? matrix : this.$sourceImage.$getTransform(), -x, -y);
2828
+ });
2773
2829
  }
2774
2830
  }
2775
2831
  $transformImageByOffset(matrix, x, y) {
@@ -2791,7 +2847,7 @@ class CropperViewer extends CropperElement {
2791
2847
  }
2792
2848
  }
2793
2849
  CropperViewer.$name = CROPPER_VIEWER;
2794
- CropperViewer.$version = '2.0.0';
2850
+ CropperViewer.$version = '2.1.0';
2795
2851
 
2796
2852
  /*! Cropper.js v2.0.0 | (c) 2015-present Chen Fengyuan | MIT */
2797
2853
  CropperCanvas.$define();