@dnncommunity/dnn-elements 0.15.0-beta.7 → 0.15.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.
- package/dist/cjs/dnn-button_17.cjs.entry.js +1 -1
- package/dist/cjs/dnn-button_17.cjs.entry.js.map +1 -1
- package/dist/cjs/dnn.cjs.js +4 -116
- package/dist/cjs/dnn.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -18
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/collection/components/dnn-tabs/dnn-tabs.css +0 -1
- package/dist/collection/components/dnn-tabs/dnn-tabs.stories.js +5 -0
- package/dist/collection/components/dnn-tabs/dnn-tabs.stories.js.map +1 -1
- package/dist/dnn/dnn.esm.js +1 -130
- package/dist/dnn/dnn.esm.js.map +1 -1
- package/dist/dnn/dnn.js +1 -1
- package/dist/dnn/index.esm.js +1 -46
- package/dist/dnn/index.esm.js.map +1 -1
- package/dist/dnn/{p-c222c8b7.entry.js → p-058a3145.entry.js} +2 -2
- package/dist/dnn/{p-c222c8b7.entry.js.map → p-058a3145.entry.js.map} +1 -1
- package/dist/dnn/{p-31dc68a7.system.entry.js → p-1893c229.system.entry.js} +2 -2
- package/dist/dnn/{p-31dc68a7.system.entry.js.map → p-1893c229.system.entry.js.map} +1 -1
- package/dist/dnn/p-5bcf3629.system.js +1 -1
- package/dist/esm/dnn-button_17.entry.js +1 -1
- package/dist/esm/dnn-button_17.entry.js.map +1 -1
- package/dist/esm/dnn.js +4 -116
- package/dist/esm/dnn.js.map +1 -1
- package/dist/esm/loader.js +2 -18
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm-es5/dnn-button_17.entry.js +1 -1
- package/dist/esm-es5/dnn-button_17.entry.js.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -3
- package/dist/cjs/app-globals-3a1e7e63.js +0 -7
- package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
- package/dist/cjs/css-shim-aaf4fec9.js +0 -8
- package/dist/cjs/css-shim-aaf4fec9.js.map +0 -1
- package/dist/cjs/dnn-button.cjs.entry.js +0 -92
- package/dist/cjs/dnn-button.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-checkbox.cjs.entry.js +0 -58
- package/dist/cjs/dnn-checkbox.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-chevron.cjs.entry.js +0 -34
- package/dist/cjs/dnn-chevron.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-collapsible.cjs.entry.js +0 -69
- package/dist/cjs/dnn-collapsible.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-color-picker.cjs.entry.js +0 -508
- package/dist/cjs/dnn-color-picker.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-dropzone.cjs.entry.js +0 -153
- package/dist/cjs/dnn-dropzone.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-image-cropper.cjs.entry.js +0 -408
- package/dist/cjs/dnn-image-cropper.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-modal.cjs.entry.js +0 -65
- package/dist/cjs/dnn-modal.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-permissions-grid.cjs.entry.js +0 -320
- package/dist/cjs/dnn-permissions-grid.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-searchbox.cjs.entry.js +0 -66
- package/dist/cjs/dnn-searchbox.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-sort-icon.cjs.entry.js +0 -43
- package/dist/cjs/dnn-sort-icon.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-tab.cjs.entry.js +0 -31
- package/dist/cjs/dnn-tab.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-tabs.cjs.entry.js +0 -52
- package/dist/cjs/dnn-tabs.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-toggle.cjs.entry.js +0 -37
- package/dist/cjs/dnn-toggle.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-treeview-item.cjs.entry.js +0 -68
- package/dist/cjs/dnn-treeview-item.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-vertical-overflow-menu.cjs.entry.js +0 -124
- package/dist/cjs/dnn-vertical-overflow-menu.cjs.entry.js.map +0 -1
- package/dist/cjs/dnn-vertical-splitview.cjs.entry.js +0 -133
- package/dist/cjs/dnn-vertical-splitview.cjs.entry.js.map +0 -1
- package/dist/cjs/dom-14886762.js +0 -77
- package/dist/cjs/dom-14886762.js.map +0 -1
- package/dist/cjs/index-d53702a3.js +0 -3095
- package/dist/cjs/index-d53702a3.js.map +0 -1
- package/dist/cjs/mouseUtilities-ecd5ecf7.js +0 -25
- package/dist/cjs/mouseUtilities-ecd5ecf7.js.map +0 -1
- package/dist/cjs/shadow-css-c44ea13a.js +0 -392
- package/dist/cjs/shadow-css-c44ea13a.js.map +0 -1
- package/dist/dnn/app-globals-0f993ce5.js +0 -5
- package/dist/dnn/app-globals-0f993ce5.js.map +0 -1
- package/dist/dnn/app-globals-497eb362.system.js +0 -2
- package/dist/dnn/app-globals-497eb362.system.js.map +0 -1
- package/dist/dnn/css-shim-091f949f.js +0 -6
- package/dist/dnn/css-shim-091f949f.js.map +0 -1
- package/dist/dnn/css-shim-c5bffe6b.system.js +0 -2
- package/dist/dnn/css-shim-c5bffe6b.system.js.map +0 -1
- package/dist/dnn/debounce-6be67abd.js +0 -22
- package/dist/dnn/debounce-6be67abd.js.map +0 -1
- package/dist/dnn/debounce-db438a09.system.js +0 -2
- package/dist/dnn/debounce-db438a09.system.js.map +0 -1
- package/dist/dnn/dnn-button.entry.js +0 -88
- package/dist/dnn/dnn-button.entry.js.map +0 -1
- package/dist/dnn/dnn-button.system.entry.js +0 -2
- package/dist/dnn/dnn-button.system.entry.js.map +0 -1
- package/dist/dnn/dnn-checkbox.entry.js +0 -54
- package/dist/dnn/dnn-checkbox.entry.js.map +0 -1
- package/dist/dnn/dnn-checkbox.system.entry.js +0 -2
- package/dist/dnn/dnn-checkbox.system.entry.js.map +0 -1
- package/dist/dnn/dnn-chevron.entry.js +0 -30
- package/dist/dnn/dnn-chevron.entry.js.map +0 -1
- package/dist/dnn/dnn-chevron.system.entry.js +0 -2
- package/dist/dnn/dnn-chevron.system.entry.js.map +0 -1
- package/dist/dnn/dnn-collapsible.entry.js +0 -65
- package/dist/dnn/dnn-collapsible.entry.js.map +0 -1
- package/dist/dnn/dnn-collapsible.system.entry.js +0 -2
- package/dist/dnn/dnn-collapsible.system.entry.js.map +0 -1
- package/dist/dnn/dnn-color-picker.entry.js +0 -504
- package/dist/dnn/dnn-color-picker.entry.js.map +0 -1
- package/dist/dnn/dnn-color-picker.system.entry.js +0 -12
- package/dist/dnn/dnn-color-picker.system.entry.js.map +0 -1
- package/dist/dnn/dnn-dropzone.entry.js +0 -149
- package/dist/dnn/dnn-dropzone.entry.js.map +0 -1
- package/dist/dnn/dnn-dropzone.system.entry.js +0 -2
- package/dist/dnn/dnn-dropzone.system.entry.js.map +0 -1
- package/dist/dnn/dnn-image-cropper.entry.js +0 -404
- package/dist/dnn/dnn-image-cropper.entry.js.map +0 -1
- package/dist/dnn/dnn-image-cropper.system.entry.js +0 -2
- package/dist/dnn/dnn-image-cropper.system.entry.js.map +0 -1
- package/dist/dnn/dnn-modal.entry.js +0 -61
- package/dist/dnn/dnn-modal.entry.js.map +0 -1
- package/dist/dnn/dnn-modal.system.entry.js +0 -2
- package/dist/dnn/dnn-modal.system.entry.js.map +0 -1
- package/dist/dnn/dnn-permissions-grid.entry.js +0 -316
- package/dist/dnn/dnn-permissions-grid.entry.js.map +0 -1
- package/dist/dnn/dnn-permissions-grid.system.entry.js +0 -2
- package/dist/dnn/dnn-permissions-grid.system.entry.js.map +0 -1
- package/dist/dnn/dnn-searchbox.entry.js +0 -62
- package/dist/dnn/dnn-searchbox.entry.js.map +0 -1
- package/dist/dnn/dnn-searchbox.system.entry.js +0 -2
- package/dist/dnn/dnn-searchbox.system.entry.js.map +0 -1
- package/dist/dnn/dnn-sort-icon.entry.js +0 -39
- package/dist/dnn/dnn-sort-icon.entry.js.map +0 -1
- package/dist/dnn/dnn-sort-icon.system.entry.js +0 -2
- package/dist/dnn/dnn-sort-icon.system.entry.js.map +0 -1
- package/dist/dnn/dnn-tab.entry.js +0 -27
- package/dist/dnn/dnn-tab.entry.js.map +0 -1
- package/dist/dnn/dnn-tab.system.entry.js +0 -2
- package/dist/dnn/dnn-tab.system.entry.js.map +0 -1
- package/dist/dnn/dnn-tabs.entry.js +0 -48
- package/dist/dnn/dnn-tabs.entry.js.map +0 -1
- package/dist/dnn/dnn-tabs.system.entry.js +0 -2
- package/dist/dnn/dnn-tabs.system.entry.js.map +0 -1
- package/dist/dnn/dnn-toggle.entry.js +0 -33
- package/dist/dnn/dnn-toggle.entry.js.map +0 -1
- package/dist/dnn/dnn-toggle.system.entry.js +0 -2
- package/dist/dnn/dnn-toggle.system.entry.js.map +0 -1
- package/dist/dnn/dnn-treeview-item.entry.js +0 -64
- package/dist/dnn/dnn-treeview-item.entry.js.map +0 -1
- package/dist/dnn/dnn-treeview-item.system.entry.js +0 -2
- package/dist/dnn/dnn-treeview-item.system.entry.js.map +0 -1
- package/dist/dnn/dnn-vertical-overflow-menu.entry.js +0 -120
- package/dist/dnn/dnn-vertical-overflow-menu.entry.js.map +0 -1
- package/dist/dnn/dnn-vertical-overflow-menu.system.entry.js +0 -2
- package/dist/dnn/dnn-vertical-overflow-menu.system.entry.js.map +0 -1
- package/dist/dnn/dnn-vertical-splitview.entry.js +0 -129
- package/dist/dnn/dnn-vertical-splitview.entry.js.map +0 -1
- package/dist/dnn/dnn-vertical-splitview.system.entry.js +0 -2
- package/dist/dnn/dnn-vertical-splitview.system.entry.js.map +0 -1
- package/dist/dnn/dnn.system.js +0 -2
- package/dist/dnn/dnn.system.js.map +0 -1
- package/dist/dnn/dom-99eb7b76.system.js +0 -22
- package/dist/dnn/dom-99eb7b76.system.js.map +0 -1
- package/dist/dnn/dom-a385e381.js +0 -75
- package/dist/dnn/dom-a385e381.js.map +0 -1
- package/dist/dnn/index-20e42ad7.js +0 -3059
- package/dist/dnn/index-20e42ad7.js.map +0 -1
- package/dist/dnn/index-c3cc3b5b.system.js +0 -2
- package/dist/dnn/index-c3cc3b5b.system.js.map +0 -1
- package/dist/dnn/index.system.js +0 -2
- package/dist/dnn/index.system.js.map +0 -1
- package/dist/dnn/mouseUtilities-233ad7e3.system.js +0 -2
- package/dist/dnn/mouseUtilities-233ad7e3.system.js.map +0 -1
- package/dist/dnn/mouseUtilities-b261ca4f.js +0 -23
- package/dist/dnn/mouseUtilities-b261ca4f.js.map +0 -1
- package/dist/dnn/shadow-css-27708fdd.system.js +0 -14
- package/dist/dnn/shadow-css-27708fdd.system.js.map +0 -1
- package/dist/dnn/shadow-css-ef431969.js +0 -390
- package/dist/dnn/shadow-css-ef431969.js.map +0 -1
- package/dist/esm/app-globals-0f993ce5.js +0 -5
- package/dist/esm/app-globals-0f993ce5.js.map +0 -1
- package/dist/esm/css-shim-091f949f.js +0 -6
- package/dist/esm/css-shim-091f949f.js.map +0 -1
- package/dist/esm/dnn-button.entry.js +0 -88
- package/dist/esm/dnn-button.entry.js.map +0 -1
- package/dist/esm/dnn-checkbox.entry.js +0 -54
- package/dist/esm/dnn-checkbox.entry.js.map +0 -1
- package/dist/esm/dnn-chevron.entry.js +0 -30
- package/dist/esm/dnn-chevron.entry.js.map +0 -1
- package/dist/esm/dnn-collapsible.entry.js +0 -65
- package/dist/esm/dnn-collapsible.entry.js.map +0 -1
- package/dist/esm/dnn-color-picker.entry.js +0 -504
- package/dist/esm/dnn-color-picker.entry.js.map +0 -1
- package/dist/esm/dnn-dropzone.entry.js +0 -149
- package/dist/esm/dnn-dropzone.entry.js.map +0 -1
- package/dist/esm/dnn-image-cropper.entry.js +0 -404
- package/dist/esm/dnn-image-cropper.entry.js.map +0 -1
- package/dist/esm/dnn-modal.entry.js +0 -61
- package/dist/esm/dnn-modal.entry.js.map +0 -1
- package/dist/esm/dnn-permissions-grid.entry.js +0 -316
- package/dist/esm/dnn-permissions-grid.entry.js.map +0 -1
- package/dist/esm/dnn-searchbox.entry.js +0 -62
- package/dist/esm/dnn-searchbox.entry.js.map +0 -1
- package/dist/esm/dnn-sort-icon.entry.js +0 -39
- package/dist/esm/dnn-sort-icon.entry.js.map +0 -1
- package/dist/esm/dnn-tab.entry.js +0 -27
- package/dist/esm/dnn-tab.entry.js.map +0 -1
- package/dist/esm/dnn-tabs.entry.js +0 -48
- package/dist/esm/dnn-tabs.entry.js.map +0 -1
- package/dist/esm/dnn-toggle.entry.js +0 -33
- package/dist/esm/dnn-toggle.entry.js.map +0 -1
- package/dist/esm/dnn-treeview-item.entry.js +0 -64
- package/dist/esm/dnn-treeview-item.entry.js.map +0 -1
- package/dist/esm/dnn-vertical-overflow-menu.entry.js +0 -120
- package/dist/esm/dnn-vertical-overflow-menu.entry.js.map +0 -1
- package/dist/esm/dnn-vertical-splitview.entry.js +0 -129
- package/dist/esm/dnn-vertical-splitview.entry.js.map +0 -1
- package/dist/esm/dom-a385e381.js +0 -75
- package/dist/esm/dom-a385e381.js.map +0 -1
- package/dist/esm/index-20e42ad7.js +0 -3059
- package/dist/esm/index-20e42ad7.js.map +0 -1
- package/dist/esm/mouseUtilities-b261ca4f.js +0 -23
- package/dist/esm/mouseUtilities-b261ca4f.js.map +0 -1
- package/dist/esm/shadow-css-ef431969.js +0 -390
- package/dist/esm/shadow-css-ef431969.js.map +0 -1
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, e as createEvent, h, f as Host } from './index-20e42ad7.js';
|
|
2
|
-
import { g as getMovementFromEvent } from './mouseUtilities-b261ca4f.js';
|
|
3
|
-
|
|
4
|
-
var CornerType;
|
|
5
|
-
(function (CornerType) {
|
|
6
|
-
CornerType[CornerType["nw"] = 0] = "nw";
|
|
7
|
-
CornerType[CornerType["ne"] = 1] = "ne";
|
|
8
|
-
CornerType[CornerType["se"] = 2] = "se";
|
|
9
|
-
CornerType[CornerType["sw"] = 3] = "sw";
|
|
10
|
-
})(CornerType || (CornerType = {}));
|
|
11
|
-
;
|
|
12
|
-
|
|
13
|
-
const dnnImageCropperCss = ":host{display:block}canvas{display:none}.view{visibility:hidden;opacity:0;height:0;overflow:hidden;-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out}.view.visible{visibility:visible;opacity:1;height:initial;overflow:visible}.view .cropper{position:relative;width:100%}.view .cropper img{width:100%;display:block;margin:0 auto}.view .cropper .backdrop{-webkit-backdrop-filter:saturate(0.5);backdrop-filter:saturate(0.5);-webkit-backdrop-filter:brightness(0.5);backdrop-filter:brightness(0.5);position:absolute;left:0;top:0;width:100%;height:100%}.view .cropper .crop{position:absolute;top:0;left:0;width:100%;height:100%;outline:2px dashed white;-webkit-box-shadow:black 0 0 0px 2px;box-shadow:black 0 0 0px 2px;-webkit-backdrop-filter:saturate(2);backdrop-filter:saturate(2);-webkit-backdrop-filter:brightness(2);backdrop-filter:brightness(2);cursor:move}.view .cropper .crop>div{width:20px;height:20px;background-color:white;border:2px solid rgba(0, 0, 0, 0.5);position:absolute}.view .cropper .crop>div.nw,.view .cropper .crop>div.ne{top:-17px}.view .cropper .crop>div.ne,.view .cropper .crop>div.se{right:-17px}.view .cropper .crop>div.se,.view .cropper .crop>div.sw{bottom:-17px}.view .cropper .crop>div.sw,.view .cropper .crop>div.nw{left:-17px}.view .cropper .crop>div.nw,.view .cropper .crop>div.se{cursor:nwse-resize}.view .cropper .crop>div.ne,.view .cropper .crop>div.sw{cursor:nesw-resize}dnn-modal{--max-width:512px}";
|
|
14
|
-
|
|
15
|
-
const DnnImageCropper = class {
|
|
16
|
-
constructor(hostRef) {
|
|
17
|
-
registerInstance(this, hostRef);
|
|
18
|
-
this.imageCropChanged = createEvent(this, "imageCropChanged", 7);
|
|
19
|
-
/** Sets the desired final image width. */
|
|
20
|
-
this.width = 600;
|
|
21
|
-
/** Sets the desired final image height. */
|
|
22
|
-
this.height = 600;
|
|
23
|
-
/** Can be used to customize controls text.
|
|
24
|
-
* Some values support tokens, see default values for examples.
|
|
25
|
-
*/
|
|
26
|
-
this.resx = {
|
|
27
|
-
capture: "Capture",
|
|
28
|
-
dragAndDropFile: "Drag and drop an image",
|
|
29
|
-
or: "or",
|
|
30
|
-
takePicture: "Take a picture",
|
|
31
|
-
uploadFile: "Upload an image",
|
|
32
|
-
imageTooSmall: "The image you are attempting to upload does not meet the minimum size requirement of {width} pixels by {height} pixels. Please upload a larger image.",
|
|
33
|
-
modalCloseText: "Close",
|
|
34
|
-
};
|
|
35
|
-
/** Sets the output quality of the corpped image (number between 0 and 1). */
|
|
36
|
-
this.quality = 0.8;
|
|
37
|
-
/** When set to true, prevents cropping an image smaller than the required size, which would blow pixel and make the final picture look blurry. */
|
|
38
|
-
this.preventUndersized = false;
|
|
39
|
-
this.handleCropMouseDown = (event) => {
|
|
40
|
-
event.stopPropagation();
|
|
41
|
-
event.preventDefault();
|
|
42
|
-
const element = event.target;
|
|
43
|
-
const className = element.classList[0];
|
|
44
|
-
document.addEventListener("mouseup", this.handleImageCropFinished, false);
|
|
45
|
-
document.addEventListener("touchend", this.handleImageCropFinished, false);
|
|
46
|
-
switch (className) {
|
|
47
|
-
case "crop":
|
|
48
|
-
document.addEventListener("mousemove", this.handleCropDrag, false);
|
|
49
|
-
document.addEventListener("touchmove", this.handleCropDrag, false);
|
|
50
|
-
document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleCropDrag));
|
|
51
|
-
document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleCropDrag));
|
|
52
|
-
break;
|
|
53
|
-
case "nw":
|
|
54
|
-
document.addEventListener("mousemove", this.handleNwMouseMove, false);
|
|
55
|
-
document.addEventListener("touchmove", this.handleNwMouseMove, false);
|
|
56
|
-
document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleNwMouseMove));
|
|
57
|
-
document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleNwMouseMove));
|
|
58
|
-
break;
|
|
59
|
-
case "ne":
|
|
60
|
-
document.addEventListener("mousemove", this.handleNeMouseMove, false);
|
|
61
|
-
document.addEventListener("touchmove", this.handleNeMouseMove, false);
|
|
62
|
-
document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleNeMouseMove));
|
|
63
|
-
document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleNeMouseMove));
|
|
64
|
-
break;
|
|
65
|
-
case "se":
|
|
66
|
-
document.addEventListener("mousemove", this.handleSeMouseMove, false);
|
|
67
|
-
document.addEventListener("touchmove", this.handleSeMouseMove, false);
|
|
68
|
-
document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleSeMouseMove));
|
|
69
|
-
document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleSeMouseMove));
|
|
70
|
-
break;
|
|
71
|
-
case "sw":
|
|
72
|
-
document.addEventListener("mousemove", this.handleSwMouseMove, false);
|
|
73
|
-
document.addEventListener("touchmove", this.handleSwMouseMove, false);
|
|
74
|
-
document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleSwMouseMove));
|
|
75
|
-
document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleSwMouseMove));
|
|
76
|
-
break;
|
|
77
|
-
default:
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
this.handleImageCropFinished = (_ev) => {
|
|
82
|
-
this.emitImage();
|
|
83
|
-
document.removeEventListener("mouseup", this.handleImageCropFinished);
|
|
84
|
-
this.previousTouch = undefined;
|
|
85
|
-
};
|
|
86
|
-
this.handleNwMouseMove = (event) => {
|
|
87
|
-
this.handleCornerDrag(event, CornerType.nw);
|
|
88
|
-
};
|
|
89
|
-
this.handleNeMouseMove = (event) => {
|
|
90
|
-
this.handleCornerDrag(event, CornerType.ne);
|
|
91
|
-
};
|
|
92
|
-
this.handleSeMouseMove = (event) => {
|
|
93
|
-
this.handleCornerDrag(event, CornerType.se);
|
|
94
|
-
};
|
|
95
|
-
this.handleSwMouseMove = (event) => {
|
|
96
|
-
this.handleCornerDrag(event, CornerType.sw);
|
|
97
|
-
};
|
|
98
|
-
this.handleCornerDrag = (event, corner) => {
|
|
99
|
-
if (!this.isMouseStillInTarget(event)) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
let { left, top } = this.getCornerLeftTop(corner);
|
|
103
|
-
let newWidth = 0;
|
|
104
|
-
let newHeight = 0;
|
|
105
|
-
let orientation = "horizontal";
|
|
106
|
-
const wantedRatio = this.width / this.height;
|
|
107
|
-
const cropRect = this.crop.getBoundingClientRect();
|
|
108
|
-
const imageRect = this.image.getBoundingClientRect();
|
|
109
|
-
let { movementX, movementY } = getMovementFromEvent(event, this.previousTouch);
|
|
110
|
-
if (Math.abs(movementX) < Math.abs(movementY)) {
|
|
111
|
-
orientation = "vertical";
|
|
112
|
-
}
|
|
113
|
-
if (orientation == "horizontal") {
|
|
114
|
-
switch (corner) {
|
|
115
|
-
case CornerType.nw:
|
|
116
|
-
case CornerType.sw:
|
|
117
|
-
newWidth = cropRect.width - movementX;
|
|
118
|
-
newHeight = newWidth / wantedRatio;
|
|
119
|
-
break;
|
|
120
|
-
case CornerType.ne:
|
|
121
|
-
case CornerType.se:
|
|
122
|
-
newWidth = cropRect.width + movementX;
|
|
123
|
-
newHeight = newWidth / wantedRatio;
|
|
124
|
-
break;
|
|
125
|
-
default:
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
switch (corner) {
|
|
131
|
-
case CornerType.nw:
|
|
132
|
-
case CornerType.ne:
|
|
133
|
-
newHeight = cropRect.height - movementY;
|
|
134
|
-
newWidth = newHeight * wantedRatio;
|
|
135
|
-
break;
|
|
136
|
-
case CornerType.se:
|
|
137
|
-
case CornerType.sw:
|
|
138
|
-
newHeight = cropRect.height + movementY;
|
|
139
|
-
newWidth = newHeight * wantedRatio;
|
|
140
|
-
break;
|
|
141
|
-
default:
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
switch (corner) {
|
|
146
|
-
case CornerType.ne:
|
|
147
|
-
case CornerType.nw:
|
|
148
|
-
const topOffset = cropRect.height - newHeight;
|
|
149
|
-
top = this.crop.offsetTop + topOffset;
|
|
150
|
-
default:
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
switch (corner) {
|
|
154
|
-
case CornerType.nw:
|
|
155
|
-
case CornerType.sw:
|
|
156
|
-
const leftOffset = cropRect.width - newWidth;
|
|
157
|
-
left = this.crop.offsetLeft + leftOffset;
|
|
158
|
-
if (left < 0)
|
|
159
|
-
left = 0;
|
|
160
|
-
if (left > imageRect.width)
|
|
161
|
-
left = imageRect.width;
|
|
162
|
-
if (top < 0)
|
|
163
|
-
top = 0;
|
|
164
|
-
if (top > imageRect.height)
|
|
165
|
-
top = imageRect.height;
|
|
166
|
-
if (left + newWidth > imageRect.width)
|
|
167
|
-
newWidth = imageRect.width - left;
|
|
168
|
-
if (top + newHeight > imageRect.height)
|
|
169
|
-
newHeight = imageRect.height - top;
|
|
170
|
-
break;
|
|
171
|
-
case CornerType.ne:
|
|
172
|
-
case CornerType.se:
|
|
173
|
-
if (top < 0)
|
|
174
|
-
top = 0;
|
|
175
|
-
if (top > imageRect.height)
|
|
176
|
-
top = imageRect.height;
|
|
177
|
-
if (left + newWidth > imageRect.width)
|
|
178
|
-
newWidth = imageRect.width - left;
|
|
179
|
-
if (top + newHeight > imageRect.height)
|
|
180
|
-
newHeight = imageRect.height - top;
|
|
181
|
-
break;
|
|
182
|
-
default:
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
if (newWidth / newHeight != wantedRatio) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (this.preventUndersized) {
|
|
189
|
-
const zoomRatio = this.image.width / this.image.naturalWidth;
|
|
190
|
-
if (newWidth / zoomRatio < this.width || newHeight / zoomRatio < this.height) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
switch (corner) {
|
|
195
|
-
case CornerType.ne:
|
|
196
|
-
this.crop.style.top = `${top}px`;
|
|
197
|
-
this.crop.style.width = `${newWidth}px`;
|
|
198
|
-
this.crop.style.height = `${newHeight}px`;
|
|
199
|
-
break;
|
|
200
|
-
case CornerType.nw:
|
|
201
|
-
this.crop.style.left = `${left}px`;
|
|
202
|
-
this.crop.style.top = `${top}px`;
|
|
203
|
-
this.crop.style.width = `${newWidth}px`;
|
|
204
|
-
this.crop.style.height = `${newHeight}px`;
|
|
205
|
-
break;
|
|
206
|
-
case CornerType.se:
|
|
207
|
-
this.crop.style.width = `${newWidth}px`;
|
|
208
|
-
this.crop.style.height = `${newHeight}px`;
|
|
209
|
-
break;
|
|
210
|
-
case CornerType.sw:
|
|
211
|
-
this.crop.style.left = `${left}px`;
|
|
212
|
-
this.crop.style.width = `${newWidth}px`;
|
|
213
|
-
this.crop.style.height = `${newHeight}px`;
|
|
214
|
-
break;
|
|
215
|
-
default:
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
this.handleCropDrag = (ev) => {
|
|
220
|
-
if (!this.isMouseStillInTarget(ev)) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
let { movementX, movementY } = getMovementFromEvent(ev, this.previousTouch);
|
|
224
|
-
let newLeft = this.crop.offsetLeft + movementX;
|
|
225
|
-
let newTop = this.crop.offsetTop + movementY;
|
|
226
|
-
var imageRect = this.image.getBoundingClientRect();
|
|
227
|
-
var cropRect = this.crop.getBoundingClientRect();
|
|
228
|
-
if (newLeft < 0) {
|
|
229
|
-
newLeft = 0;
|
|
230
|
-
}
|
|
231
|
-
if (newTop < 0) {
|
|
232
|
-
newTop = 0;
|
|
233
|
-
}
|
|
234
|
-
if (newLeft + cropRect.width > imageRect.width) {
|
|
235
|
-
newLeft = this.crop.offsetLeft;
|
|
236
|
-
}
|
|
237
|
-
if (newTop + cropRect.height > imageRect.height) {
|
|
238
|
-
newTop = this.crop.offsetTop;
|
|
239
|
-
}
|
|
240
|
-
this.crop.style.left = newLeft + "px";
|
|
241
|
-
this.crop.style.top = newTop + "px";
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
componentDidLoad() {
|
|
245
|
-
requestAnimationFrame(() => {
|
|
246
|
-
this.setView("noPictureView");
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
setView(newView) {
|
|
250
|
-
const views = this.host.shadowRoot.querySelectorAll(".view");
|
|
251
|
-
views.forEach(v => v.classList.remove("visible"));
|
|
252
|
-
switch (newView) {
|
|
253
|
-
case "noPictureView":
|
|
254
|
-
this.noPictureView.classList.add("visible");
|
|
255
|
-
break;
|
|
256
|
-
case "hasPictureView":
|
|
257
|
-
this.hasPictureView.classList.add("visible");
|
|
258
|
-
break;
|
|
259
|
-
default:
|
|
260
|
-
break;
|
|
261
|
-
}
|
|
262
|
-
this.view = newView;
|
|
263
|
-
}
|
|
264
|
-
initCrop() {
|
|
265
|
-
var wantedRatio = this.width / this.height;
|
|
266
|
-
var imageRect = this.image.getBoundingClientRect();
|
|
267
|
-
var imageRatio = imageRect.width / imageRect.height;
|
|
268
|
-
if (wantedRatio > imageRatio) {
|
|
269
|
-
var wantedHeight = imageRect.width / wantedRatio;
|
|
270
|
-
var diff = imageRect.height - wantedHeight;
|
|
271
|
-
this.crop.style.top = Math.round(diff / 2).toString() + "px";
|
|
272
|
-
this.crop.style.height = Math.round(wantedHeight).toString() + "px";
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
var wantedWidth = imageRect.height * wantedRatio;
|
|
276
|
-
var diff = imageRect.width - wantedWidth;
|
|
277
|
-
this.crop.style.left = Math.round(diff / 2).toString() + "px";
|
|
278
|
-
this.crop.style.width = Math.round(wantedWidth).toString() + "px";
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
setImage() {
|
|
282
|
-
this.image.addEventListener('load', () => {
|
|
283
|
-
this.initCrop();
|
|
284
|
-
this.emitImage();
|
|
285
|
-
});
|
|
286
|
-
this.image.src = this.canvas.toDataURL();
|
|
287
|
-
}
|
|
288
|
-
handleNewFile(file) {
|
|
289
|
-
if (file.type.split('/')[0] != "image") {
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
var reader = new FileReader();
|
|
293
|
-
reader.onload = readerLoadEvent => {
|
|
294
|
-
var img = new Image();
|
|
295
|
-
img.onload = () => {
|
|
296
|
-
this.canvas.width = img.width;
|
|
297
|
-
this.canvas.height = img.height;
|
|
298
|
-
if (this.preventUndersized && (img.width < this.width || img.height < this.height)) {
|
|
299
|
-
this.imageTooSmallModal.show();
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
var ctx = this.canvas.getContext("2d");
|
|
303
|
-
ctx.drawImage(img, 0, 0);
|
|
304
|
-
this.setView("hasPictureView");
|
|
305
|
-
this.setImage();
|
|
306
|
-
};
|
|
307
|
-
img.src = readerLoadEvent.target.result.toString();
|
|
308
|
-
};
|
|
309
|
-
reader.readAsDataURL(file);
|
|
310
|
-
}
|
|
311
|
-
emitImage() {
|
|
312
|
-
var x = this.crop.offsetLeft / this.image.width * this.image.naturalWidth;
|
|
313
|
-
var y = this.crop.offsetTop / this.image.height * this.image.naturalHeight;
|
|
314
|
-
var cropRect = this.crop.getBoundingClientRect();
|
|
315
|
-
var width = cropRect.width / this.image.width * this.image.naturalWidth;
|
|
316
|
-
var height = cropRect.height / this.image.height * this.image.naturalHeight;
|
|
317
|
-
if (x < 0)
|
|
318
|
-
x = 0;
|
|
319
|
-
if (x > this.image.naturalWidth)
|
|
320
|
-
x = this.image.naturalWidth;
|
|
321
|
-
if (y < 0)
|
|
322
|
-
y = 0;
|
|
323
|
-
if (y > this.image.naturalWidth)
|
|
324
|
-
y = this.image.naturalWidth;
|
|
325
|
-
if (width > this.image.naturalWidth)
|
|
326
|
-
width = this.image.naturalWidth;
|
|
327
|
-
if (height > this.image.naturalHeight)
|
|
328
|
-
height = this.image.naturalHeight;
|
|
329
|
-
var dataUrl = this.generateCroppedImage(x, y, width, height, this.width, this.height);
|
|
330
|
-
this.imageCropChanged.emit(dataUrl);
|
|
331
|
-
}
|
|
332
|
-
generateCroppedImage(x, y, width, height, desiredWidth, desiredHeight) {
|
|
333
|
-
this.canvas.width = desiredWidth;
|
|
334
|
-
this.canvas.height = desiredHeight;
|
|
335
|
-
const context = this.canvas.getContext("2d");
|
|
336
|
-
context.clearRect(0, 0, desiredWidth, desiredHeight);
|
|
337
|
-
context.drawImage(this.image, x, y, width, height, 0, 0, desiredWidth, desiredHeight);
|
|
338
|
-
return this.canvas.toDataURL("image/jpeg", this.quality);
|
|
339
|
-
}
|
|
340
|
-
getCornerLeftTop(corner) {
|
|
341
|
-
let left = 0;
|
|
342
|
-
let top = 0;
|
|
343
|
-
switch (corner) {
|
|
344
|
-
case CornerType.se:
|
|
345
|
-
left = this.crop.offsetLeft;
|
|
346
|
-
top = this.crop.offsetTop;
|
|
347
|
-
break;
|
|
348
|
-
case CornerType.sw:
|
|
349
|
-
top = this.crop.offsetTop;
|
|
350
|
-
break;
|
|
351
|
-
default:
|
|
352
|
-
break;
|
|
353
|
-
}
|
|
354
|
-
return { top, left };
|
|
355
|
-
}
|
|
356
|
-
isMouseStillInTarget(event) {
|
|
357
|
-
var inside = false;
|
|
358
|
-
let mouseX;
|
|
359
|
-
let mouseY;
|
|
360
|
-
const imageRect = this.image.getBoundingClientRect();
|
|
361
|
-
if (event instanceof MouseEvent) {
|
|
362
|
-
mouseX = event.clientX;
|
|
363
|
-
mouseY = event.clientY;
|
|
364
|
-
}
|
|
365
|
-
if (typeof TouchEvent !== "undefined") {
|
|
366
|
-
if (event instanceof TouchEvent) {
|
|
367
|
-
var touch = event.touches[0];
|
|
368
|
-
mouseX = touch.clientX;
|
|
369
|
-
mouseY = touch.clientY;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
if (mouseX >= imageRect.x &&
|
|
373
|
-
mouseY >= imageRect.y &&
|
|
374
|
-
mouseX <= imageRect.left + imageRect.width &&
|
|
375
|
-
mouseY <= imageRect.top + imageRect.height) {
|
|
376
|
-
inside = true;
|
|
377
|
-
}
|
|
378
|
-
var corners = this.crop.querySelectorAll("div");
|
|
379
|
-
corners.forEach(corner => {
|
|
380
|
-
var cornerRect = corner.getBoundingClientRect();
|
|
381
|
-
if (mouseX >= cornerRect.x &&
|
|
382
|
-
mouseY >= cornerRect.y &&
|
|
383
|
-
mouseX <= cornerRect.left + cornerRect.width &&
|
|
384
|
-
mouseY <= cornerRect.top + cornerRect.height) {
|
|
385
|
-
inside = true;
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
return inside;
|
|
389
|
-
}
|
|
390
|
-
render() {
|
|
391
|
-
return (h(Host, { ref: el => this.host = el }, h("canvas", { ref: el => this.canvas = el }), h("div", { class: "view", ref: el => this.hasPictureView = el }, h("div", { class: "cropper" }, h("img", { ref: el => this.image = el }), h("div", { class: "backdrop" }), h("div", { class: "crop", ref: e => this.crop = e, onMouseDown: this.handleCropMouseDown, onTouchStart: this.handleCropMouseDown }, h("div", { class: "nw" }), h("div", { class: "ne" }), h("div", { class: "se" }), h("div", { class: "sw" })))), h("div", { class: "view", ref: el => this.noPictureView = el }, h("dnn-dropzone", { allowCameraMode: true, onFilesSelected: e => this.handleNewFile(e.detail[0]), resx: {
|
|
392
|
-
capture: this.resx.capture,
|
|
393
|
-
dragAndDropFile: this.resx.dragAndDropFile,
|
|
394
|
-
or: this.resx.or,
|
|
395
|
-
takePicture: this.resx.takePicture,
|
|
396
|
-
uploadFile: this.resx.uploadFile,
|
|
397
|
-
} })), h("dnn-modal", { ref: el => this.imageTooSmallModal = el, "close-text": this.resx.modalCloseText }, h("p", null, this.resx.imageTooSmall.replace("{width}", this.width.toString()).replace("{height}", this.height.toString())))));
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
DnnImageCropper.style = dnnImageCropperCss;
|
|
401
|
-
|
|
402
|
-
export { DnnImageCropper as dnn_image_cropper };
|
|
403
|
-
|
|
404
|
-
//# sourceMappingURL=dnn-image-cropper.entry.js.map
|
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,EAAE,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACrD,IAAI,EACF;QACE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO;QAC1B,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe;QAC1C,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;QAChB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW;QAClC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU;OACjC,GAEH,CACA,EACN,iBAAW,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,kBAAkB,GAAG,EAAE,gBAAc,IAAI,CAAC,IAAI,CAAC,cAAc,IACtF,aAAI,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAK,CAC5G,CACP,EACP;GACH;;;;;;","names":[],"sources":["./src/components/dnn-image-cropper/CornerType.ts","./src/components/dnn-image-cropper/dnn-image-cropper.scss?tag=dnn-image-cropper&encapsulation=shadow","./src/components/dnn-image-cropper/dnn-image-cropper.tsx"],"sourcesContent":["export enum CornerType {\r\n \"nw\",\r\n \"ne\",\r\n \"se\",\r\n \"sw\",\r\n};",":host {\n display: block;\n}\ncanvas {\n display: none;\n}\n.view{\n visibility: hidden;\n opacity: 0;\n height: 0;\n overflow: hidden;\n transition: all 300ms ease-in-out;\n &.visible{\n visibility: visible;\n opacity: 1;\n height: initial;\n overflow: visible;\n }\n .cropper{\n position: relative;\n width: 100%;\n img{\n width: 100%;\n display: block;\n margin: 0 auto;\n }\n .backdrop{\n backdrop-filter: saturate(0.5);\n backdrop-filter: brightness(0.5);\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n }\n .crop{\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n outline: 2px dashed white;\n box-shadow: black 0 0 0px 2px;\n backdrop-filter: saturate(2);\n backdrop-filter: brightness(2);\n cursor: move;\n >div{\n width: 20px;\n height: 20px;\n background-color: white;\n border: 2px solid rgba(0,0,0,0.5);\n position: absolute;\n &.nw, &.ne{\n top: -17px;\n }\n &.ne, &.se{\n right: -17px;\n }\n &.se, &.sw{\n bottom: -17px;\n }\n &.sw, &.nw{\n left: -17px;\n }\n &.nw, &.se{\n cursor: nwse-resize;\n }\n &.ne, &.sw{\n cursor: nesw-resize;\n }\n }\n }\n }\n}\ndnn-modal{\n --max-width: 512px;\n}","import { Component, Host, h, State, Prop, Event, EventEmitter } from '@stencil/core';\nimport { CornerType } from './CornerType';\nimport { getMovementFromEvent } from \"../../utilities/mouseUtilities\";\n\n/**\n * Allows cropping an image in-browser with the option to enforce a specific final size.\n * All computation happens in the browser and the final image is emmited\n * in an event that has a data-url of the image.\n */\n@Component({\n tag: 'dnn-image-cropper',\n styleUrl: 'dnn-image-cropper.scss',\n shadow: true,\n})\nexport class DnnImageCropper {\n /** Sets the desired final image width. */\n @Prop() width: number = 600;\n\n /** Sets the desired final image height. */\n @Prop() height: number = 600;\n\n /** Can be used to customize controls text.\n * Some values support tokens, see default values for examples.\n */\n @Prop() resx: {\n capture: string;\n dragAndDropFile: string;\n or: string;\n takePicture: string;\n uploadFile: string;\n imageTooSmall: string;\n modalCloseText: string;\n } = {\n capture: \"Capture\",\n dragAndDropFile: \"Drag and drop an image\",\n or: \"or\",\n takePicture: \"Take a picture\",\n uploadFile: \"Upload an image\",\n imageTooSmall: \"The image you are attempting to upload does not meet the minimum size requirement of {width} pixels by {height} pixels. Please upload a larger image.\",\n modalCloseText: \"Close\",\n }\n\n /** Sets the output quality of the corpped image (number between 0 and 1). */\n @Prop() quality: number = 0.8;\n\n /** When set to true, prevents cropping an image smaller than the required size, which would blow pixel and make the final picture look blurry. */\n @Prop() preventUndersized: boolean = false;\n\n /** When the image crop changes, emits the dataurl for the new cropped image. */\n @Event() imageCropChanged: EventEmitter<string>;\n\n @State() view: IComponentInterfaces[\"View\"];\n \n private host: HTMLElement;\n private hasPictureView: HTMLDivElement;\n private noPictureView: HTMLDivElement;\n private canvas: HTMLCanvasElement;\n private image: HTMLImageElement;\n private crop: HTMLDivElement;\n private previousTouch: Touch;\n private imageTooSmallModal!: HTMLDnnModalElement;\n\n componentDidLoad() {\n requestAnimationFrame(() => {\n this.setView(\"noPictureView\");\n })\n }\n\n private setView(newView: IComponentInterfaces[\"View\"]){\n const views = this.host.shadowRoot.querySelectorAll(\".view\");\n views.forEach(v =>\n v.classList.remove(\"visible\"));\n switch (newView) {\n case \"noPictureView\":\n this.noPictureView.classList.add(\"visible\");\n break;\n case \"hasPictureView\":\n this.hasPictureView.classList.add(\"visible\");\n break;\n default:\n break;\n }\n this.view = newView;\n }\n\n private initCrop(){\n var wantedRatio = this.width / this.height;\n var imageRect = this.image.getBoundingClientRect();\n var imageRatio = imageRect.width / imageRect.height;\n \n if (wantedRatio > imageRatio){\n var wantedHeight = imageRect.width / wantedRatio;\n var diff = imageRect.height - wantedHeight;\n this.crop.style.top = Math.round(diff/2).toString() + \"px\";\n this.crop.style.height = Math.round(wantedHeight).toString() + \"px\";\n }\n else{\n var wantedWidth = imageRect.height * wantedRatio;\n var diff = imageRect.width - wantedWidth;\n this.crop.style.left = Math.round(diff/2).toString() + \"px\";\n this.crop.style.width = Math.round(wantedWidth).toString() + \"px\";\n }\n }\n\n private setImage(){\n this.image.addEventListener('load', () => {\n this.initCrop();\n this.emitImage();\n })\n this.image.src = this.canvas.toDataURL();\n }\n\n private handleNewFile(file: File): void {\n if (file.type.split('/')[0] != \"image\"){\n return;\n }\n \n var reader = new FileReader();\n reader.onload = readerLoadEvent => {\n var img = new Image();\n img.onload = () => {\n this.canvas.width = img.width;\n this.canvas.height = img.height;\n if (this.preventUndersized && (img.width < this.width || img.height< this.height)){\n this.imageTooSmallModal.show();\n return;\n }\n var ctx = this.canvas.getContext(\"2d\");\n ctx.drawImage(img,0,0);\n this.setView(\"hasPictureView\");\n this.setImage();\n }\n img.src = readerLoadEvent.target.result.toString();\n }\n reader.readAsDataURL(file);\n }\n\n private handleCropMouseDown = (event: MouseEvent | TouchEvent) => {\n event.stopPropagation();\n event.preventDefault();\n const element = event.target as HTMLElement;\n const className = element.classList[0];\n\n document.addEventListener(\"mouseup\", this.handleImageCropFinished, false);\n document.addEventListener(\"touchend\", this.handleImageCropFinished, false);\n switch (className) {\n case \"crop\":\n document.addEventListener(\"mousemove\", this.handleCropDrag, false);\n document.addEventListener(\"touchmove\", this.handleCropDrag, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleCropDrag));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleCropDrag));\n break;\n case \"nw\":\n document.addEventListener(\"mousemove\", this.handleNwMouseMove, false);\n document.addEventListener(\"touchmove\", this.handleNwMouseMove, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleNwMouseMove));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleNwMouseMove));\n break;\n case \"ne\":\n document.addEventListener(\"mousemove\", this.handleNeMouseMove, false);\n document.addEventListener(\"touchmove\", this.handleNeMouseMove, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleNeMouseMove));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleNeMouseMove));\n break\n case \"se\":\n document.addEventListener(\"mousemove\", this.handleSeMouseMove, false);\n document.addEventListener(\"touchmove\", this.handleSeMouseMove, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleSeMouseMove));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleSeMouseMove));\n break;\n case \"sw\":\n document.addEventListener(\"mousemove\", this.handleSwMouseMove, false);\n document.addEventListener(\"touchmove\", this.handleSwMouseMove, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleSwMouseMove));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleSwMouseMove));\n break;\n default:\n break;\n }\n };\n\n private handleImageCropFinished = (_ev: MouseEvent) => {\n this.emitImage();\n document.removeEventListener(\"mouseup\", this.handleImageCropFinished);\n this.previousTouch = undefined;\n }\n\n private emitImage() {\n var x = this.crop.offsetLeft / this.image.width * this.image.naturalWidth;\n var y = this.crop.offsetTop / this.image.height * this.image.naturalHeight;\n\n var cropRect = this.crop.getBoundingClientRect();\n var width = cropRect.width / this.image.width * this.image.naturalWidth;\n var height = cropRect.height / this.image.height * this.image.naturalHeight;\n\n if (x < 0)\n x = 0;\n if (x > this.image.naturalWidth)\n x = this.image.naturalWidth;\n if (y < 0)\n y = 0;\n if (y > this.image.naturalWidth)\n y = this.image.naturalWidth;\n if (width > this.image.naturalWidth)\n width = this.image.naturalWidth;\n if (height > this.image.naturalHeight)\n height = this.image.naturalHeight;\n\n var dataUrl = this.generateCroppedImage(x, y, width, height, this.width, this.height);\n this.imageCropChanged.emit(dataUrl);\n }\n\n private generateCroppedImage(x: number, y: number, width: number, height: number, desiredWidth: number, desiredHeight: number) {\n this.canvas.width = desiredWidth;\n this.canvas.height = desiredHeight;\n const context = this.canvas.getContext(\"2d\");\n context.clearRect(0, 0, desiredWidth, desiredHeight);\n context.drawImage(this.image, x, y, width, height, 0, 0, desiredWidth, desiredHeight);\n\n return this.canvas.toDataURL(\"image/jpeg\", this.quality);\n }\n\n private handleNwMouseMove = (event: MouseEvent | TouchEvent) => {\n this.handleCornerDrag(event, CornerType.nw);\n }\n\n private handleNeMouseMove = (event: MouseEvent | TouchEvent) => {\n this.handleCornerDrag(event, CornerType.ne);\n }\n\n private handleSeMouseMove = (event: MouseEvent | TouchEvent) => {\n this.handleCornerDrag(event, CornerType.se);\n }\n\n private handleSwMouseMove = (event: MouseEvent | TouchEvent) => {\n this.handleCornerDrag(event, CornerType.sw);\n }\n\n private handleCornerDrag = (event: MouseEvent | TouchEvent, corner: CornerType) => {\n if (!this.isMouseStillInTarget(event)){\n return;\n }\n \n let {left, top} = this.getCornerLeftTop(corner);\n let newWidth = 0;\n let newHeight = 0;\n let orientation: \"horizontal\" | \"vertical\" = \"horizontal\";\n const wantedRatio = this.width / this.height;\n const cropRect = this.crop.getBoundingClientRect();\n const imageRect = this.image.getBoundingClientRect();\n let { movementX, movementY } = getMovementFromEvent(event, this.previousTouch);\n if (Math.abs(movementX) < Math.abs(movementY)){\n orientation = \"vertical\";\n }\n\n if (orientation == \"horizontal\"){\n switch (corner) {\n case CornerType.nw:\n case CornerType.sw:\n newWidth = cropRect.width - movementX;\n newHeight = newWidth / wantedRatio;\n break;\n case CornerType.ne:\n case CornerType.se:\n newWidth = cropRect.width + movementX;\n newHeight = newWidth / wantedRatio;\n break;\n default:\n break;\n }\n } else{\n switch (corner) {\n case CornerType.nw:\n case CornerType.ne:\n newHeight = cropRect.height - movementY;\n newWidth = newHeight * wantedRatio;\n break;\n case CornerType.se:\n case CornerType.sw:\n newHeight = cropRect.height + movementY;\n newWidth = newHeight * wantedRatio;\n break;\n default:\n break;\n }\n }\n\n switch (corner) {\n case CornerType.ne:\n case CornerType.nw:\n const topOffset = cropRect.height - newHeight;\n top = this.crop.offsetTop + topOffset;\n default:\n break;\n }\n\n switch (corner) {\n case CornerType.nw:\n case CornerType.sw:\n const leftOffset = cropRect.width - newWidth;\n left = this.crop.offsetLeft + leftOffset;\n if (left < 0) left = 0;\n if (left > imageRect.width) left = imageRect.width;\n if (top < 0) top = 0;\n if (top > imageRect.height) top = imageRect.height;\n if (left + newWidth > imageRect.width) newWidth = imageRect.width - left;\n if (top + newHeight > imageRect.height) newHeight = imageRect.height - top;\n break;\n case CornerType.ne:\n case CornerType.se:\n if (top < 0) top = 0;\n if (top > imageRect.height) top = imageRect.height;\n if (left + newWidth > imageRect.width) newWidth = imageRect.width - left;\n if (top + newHeight > imageRect.height) newHeight = imageRect.height - top;\n break;\n default:\n break;\n }\n\n if (newWidth / newHeight != wantedRatio){\n return;\n }\n\n if (this.preventUndersized){\n const zoomRatio = this.image.width / this.image.naturalWidth;\n if (newWidth / zoomRatio < this.width || newHeight / zoomRatio < this.height){\n return;\n }\n }\n\n switch (corner) {\n case CornerType.ne:\n this.crop.style.top = `${top}px`;\n this.crop.style.width = `${newWidth}px`;\n this.crop.style.height = `${newHeight}px`;\n break;\n case CornerType.nw:\n this.crop.style.left = `${left}px`;\n this.crop.style.top = `${top}px`;\n this.crop.style.width = `${newWidth}px`;\n this.crop.style.height = `${newHeight}px`;\n break;\n case CornerType.se:\n this.crop.style.width = `${newWidth}px`;\n this.crop.style.height = `${newHeight}px`;\n break;\n case CornerType.sw:\n this.crop.style.left = `${left}px`;\n this.crop.style.width = `${newWidth}px`;\n this.crop.style.height = `${newHeight}px`;\n break;\n default:\n break;\n }\n }\n\n private getCornerLeftTop(corner: CornerType): { left: number; top: number; } {\n let left = 0;\n let top = 0;\n switch (corner) {\n case CornerType.se:\n left = this.crop.offsetLeft;\n top = this.crop.offsetTop;\n break;\n case CornerType.sw:\n top = this.crop.offsetTop;\n break;\n default:\n break;\n }\n return {top, left};\n }\n\n private handleCropDrag = (ev: MouseEvent | TouchEvent) => {\n if (!this.isMouseStillInTarget(ev)){\n return;\n }\n let {movementX, movementY} = getMovementFromEvent(ev, this.previousTouch);\n let newLeft = this.crop.offsetLeft + movementX;\n let newTop = this.crop.offsetTop + movementY;\n var imageRect = this.image.getBoundingClientRect();\n var cropRect = this.crop.getBoundingClientRect();\n if (newLeft < 0){\n newLeft = 0;\n }\n if (newTop < 0){\n newTop = 0;\n }\n if (newLeft + cropRect.width > imageRect.width){\n newLeft = this.crop.offsetLeft;\n }\n if (newTop + cropRect.height > imageRect.height){\n newTop = this.crop.offsetTop;\n }\n this.crop.style.left = newLeft + \"px\";\n this.crop.style.top = newTop + \"px\";\n };\n\n private isMouseStillInTarget(event: MouseEvent | TouchEvent) {\n var inside = false;\n let mouseX: number;\n let mouseY: number;\n const imageRect = this.image.getBoundingClientRect();\n \n if (event instanceof MouseEvent){\n mouseX = event.clientX;\n mouseY = event.clientY;\n }\n\n if (typeof TouchEvent !== \"undefined\"){\n if (event instanceof TouchEvent){\n var touch = event.touches[0];\n mouseX = touch.clientX;\n mouseY = touch.clientY;\n }\n }\n \n if (\n mouseX >= imageRect.x &&\n mouseY >= imageRect.y &&\n mouseX <= imageRect.left + imageRect.width &&\n mouseY <= imageRect.top + imageRect.height)\n {\n inside = true;\n }\n\n var corners = this.crop.querySelectorAll(\"div\");\n corners.forEach(corner =>{\n var cornerRect = corner.getBoundingClientRect();\n if (\n mouseX >= cornerRect.x &&\n mouseY >= cornerRect.y &&\n mouseX <= cornerRect.left + cornerRect.width &&\n mouseY <= cornerRect.top + cornerRect.height)\n {\n inside = true;\n }\n })\n\n return inside;\n }\n\n render() {\n return (\n <Host ref={el => this.host = el}>\n <canvas ref={el => this.canvas = el} />\n <div\n class=\"view\"\n ref={el => this.hasPictureView = el}\n >\n <div class=\"cropper\">\n <img ref={el => this.image = el} />\n <div class=\"backdrop\" />\n <div\n class=\"crop\"\n ref={e => this.crop = e}\n onMouseDown={this.handleCropMouseDown}\n onTouchStart={this.handleCropMouseDown}\n >\n <div class=\"nw\" />\n <div class=\"ne\" />\n <div class=\"se\" />\n <div class=\"sw\" />\n </div>\n </div>\n </div>\n <div\n class=\"view\"\n ref={el => this.noPictureView = el}>\n <dnn-dropzone\n allowCameraMode\n onFilesSelected={e => this.handleNewFile(e.detail[0])}\n resx={\n {\n capture: this.resx.capture,\n dragAndDropFile: this.resx.dragAndDropFile,\n or: this.resx.or,\n takePicture: this.resx.takePicture,\n uploadFile: this.resx.uploadFile,\n }\n }\n />\n </div>\n <dnn-modal ref={el => this.imageTooSmallModal = el} close-text={this.resx.modalCloseText}>\n <p>{this.resx.imageTooSmall.replace(\"{width}\", this.width.toString()).replace(\"{height}\", this.height.toString())}</p>\n </dnn-modal>\n </Host>\n );\n }\n}\n\ninterface IComponentInterfaces\n{\n View: \"noPictureView\" | \"takingPictureView\" | \"hasPictureView\" | \"hasCroppedPictureView\";\n}"],"version":3}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
System.register(["./index-c3cc3b5b.system.js","./mouseUtilities-233ad7e3.system.js"],(function(e){"use strict";var t,i,o,r,n;return{setters:[function(e){t=e.r;i=e.e;o=e.h;r=e.f},function(e){n=e.g}],execute:function(){var a;(function(e){e[e["nw"]=0]="nw";e[e["ne"]=1]="ne";e[e["se"]=2]="se";e[e["sw"]=3]="sw"})(a||(a={}));var s=":host{display:block}canvas{display:none}.view{visibility:hidden;opacity:0;height:0;overflow:hidden;-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out}.view.visible{visibility:visible;opacity:1;height:initial;overflow:visible}.view .cropper{position:relative;width:100%}.view .cropper img{width:100%;display:block;margin:0 auto}.view .cropper .backdrop{-webkit-backdrop-filter:saturate(0.5);backdrop-filter:saturate(0.5);-webkit-backdrop-filter:brightness(0.5);backdrop-filter:brightness(0.5);position:absolute;left:0;top:0;width:100%;height:100%}.view .cropper .crop{position:absolute;top:0;left:0;width:100%;height:100%;outline:2px dashed white;-webkit-box-shadow:black 0 0 0px 2px;box-shadow:black 0 0 0px 2px;-webkit-backdrop-filter:saturate(2);backdrop-filter:saturate(2);-webkit-backdrop-filter:brightness(2);backdrop-filter:brightness(2);cursor:move}.view .cropper .crop>div{width:20px;height:20px;background-color:white;border:2px solid rgba(0, 0, 0, 0.5);position:absolute}.view .cropper .crop>div.nw,.view .cropper .crop>div.ne{top:-17px}.view .cropper .crop>div.ne,.view .cropper .crop>div.se{right:-17px}.view .cropper .crop>div.se,.view .cropper .crop>div.sw{bottom:-17px}.view .cropper .crop>div.sw,.view .cropper .crop>div.nw{left:-17px}.view .cropper .crop>div.nw,.view .cropper .crop>div.se{cursor:nwse-resize}.view .cropper .crop>div.ne,.view .cropper .crop>div.sw{cursor:nesw-resize}dnn-modal{--max-width:512px}";var h=e("dnn_image_cropper",function(){function e(e){var o=this;t(this,e);this.imageCropChanged=i(this,"imageCropChanged",7);this.width=600;this.height=600;this.resx={capture:"Capture",dragAndDropFile:"Drag and drop an image",or:"or",takePicture:"Take a picture",uploadFile:"Upload an image",imageTooSmall:"The image you are attempting to upload does not meet the minimum size requirement of {width} pixels by {height} pixels. Please upload a larger image.",modalCloseText:"Close"};this.quality=.8;this.preventUndersized=false;this.handleCropMouseDown=function(e){e.stopPropagation();e.preventDefault();var t=e.target;var i=t.classList[0];document.addEventListener("mouseup",o.handleImageCropFinished,false);document.addEventListener("touchend",o.handleImageCropFinished,false);switch(i){case"crop":document.addEventListener("mousemove",o.handleCropDrag,false);document.addEventListener("touchmove",o.handleCropDrag,false);document.addEventListener("mouseup",(function(){return document.removeEventListener("mousemove",o.handleCropDrag)}));document.addEventListener("touchend",(function(){return document.removeEventListener("touchmove",o.handleCropDrag)}));break;case"nw":document.addEventListener("mousemove",o.handleNwMouseMove,false);document.addEventListener("touchmove",o.handleNwMouseMove,false);document.addEventListener("mouseup",(function(){return document.removeEventListener("mousemove",o.handleNwMouseMove)}));document.addEventListener("touchend",(function(){return document.removeEventListener("touchmove",o.handleNwMouseMove)}));break;case"ne":document.addEventListener("mousemove",o.handleNeMouseMove,false);document.addEventListener("touchmove",o.handleNeMouseMove,false);document.addEventListener("mouseup",(function(){return document.removeEventListener("mousemove",o.handleNeMouseMove)}));document.addEventListener("touchend",(function(){return document.removeEventListener("touchmove",o.handleNeMouseMove)}));break;case"se":document.addEventListener("mousemove",o.handleSeMouseMove,false);document.addEventListener("touchmove",o.handleSeMouseMove,false);document.addEventListener("mouseup",(function(){return document.removeEventListener("mousemove",o.handleSeMouseMove)}));document.addEventListener("touchend",(function(){return document.removeEventListener("touchmove",o.handleSeMouseMove)}));break;case"sw":document.addEventListener("mousemove",o.handleSwMouseMove,false);document.addEventListener("touchmove",o.handleSwMouseMove,false);document.addEventListener("mouseup",(function(){return document.removeEventListener("mousemove",o.handleSwMouseMove)}));document.addEventListener("touchend",(function(){return document.removeEventListener("touchmove",o.handleSwMouseMove)}));break;default:break}};this.handleImageCropFinished=function(e){o.emitImage();document.removeEventListener("mouseup",o.handleImageCropFinished);o.previousTouch=undefined};this.handleNwMouseMove=function(e){o.handleCornerDrag(e,a.nw)};this.handleNeMouseMove=function(e){o.handleCornerDrag(e,a.ne)};this.handleSeMouseMove=function(e){o.handleCornerDrag(e,a.se)};this.handleSwMouseMove=function(e){o.handleCornerDrag(e,a.sw)};this.handleCornerDrag=function(e,t){if(!o.isMouseStillInTarget(e)){return}var i=o.getCornerLeftTop(t),r=i.left,s=i.top;var h=0;var c=0;var d="horizontal";var u=o.width/o.height;var p=o.crop.getBoundingClientRect();var l=o.image.getBoundingClientRect();var v=n(e,o.previousTouch),m=v.movementX,f=v.movementY;if(Math.abs(m)<Math.abs(f)){d="vertical"}if(d=="horizontal"){switch(t){case a.nw:case a.sw:h=p.width-m;c=h/u;break;case a.ne:case a.se:h=p.width+m;c=h/u;break;default:break}}else{switch(t){case a.nw:case a.ne:c=p.height-f;h=c*u;break;case a.se:case a.sw:c=p.height+f;h=c*u;break;default:break}}switch(t){case a.ne:case a.nw:var g=p.height-c;s=o.crop.offsetTop+g;default:break}switch(t){case a.nw:case a.sw:var w=p.width-h;r=o.crop.offsetLeft+w;if(r<0)r=0;if(r>l.width)r=l.width;if(s<0)s=0;if(s>l.height)s=l.height;if(r+h>l.width)h=l.width-r;if(s+c>l.height)c=l.height-s;break;case a.ne:case a.se:if(s<0)s=0;if(s>l.height)s=l.height;if(r+h>l.width)h=l.width-r;if(s+c>l.height)c=l.height-s;break;default:break}if(h/c!=u){return}if(o.preventUndersized){var b=o.image.width/o.image.naturalWidth;if(h/b<o.width||c/b<o.height){return}}switch(t){case a.ne:o.crop.style.top="".concat(s,"px");o.crop.style.width="".concat(h,"px");o.crop.style.height="".concat(c,"px");break;case a.nw:o.crop.style.left="".concat(r,"px");o.crop.style.top="".concat(s,"px");o.crop.style.width="".concat(h,"px");o.crop.style.height="".concat(c,"px");break;case a.se:o.crop.style.width="".concat(h,"px");o.crop.style.height="".concat(c,"px");break;case a.sw:o.crop.style.left="".concat(r,"px");o.crop.style.width="".concat(h,"px");o.crop.style.height="".concat(c,"px");break;default:break}};this.handleCropDrag=function(e){if(!o.isMouseStillInTarget(e)){return}var t=n(e,o.previousTouch),i=t.movementX,r=t.movementY;var a=o.crop.offsetLeft+i;var s=o.crop.offsetTop+r;var h=o.image.getBoundingClientRect();var c=o.crop.getBoundingClientRect();if(a<0){a=0}if(s<0){s=0}if(a+c.width>h.width){a=o.crop.offsetLeft}if(s+c.height>h.height){s=o.crop.offsetTop}o.crop.style.left=a+"px";o.crop.style.top=s+"px"}}e.prototype.componentDidLoad=function(){var e=this;requestAnimationFrame((function(){e.setView("noPictureView")}))};e.prototype.setView=function(e){var t=this.host.shadowRoot.querySelectorAll(".view");t.forEach((function(e){return e.classList.remove("visible")}));switch(e){case"noPictureView":this.noPictureView.classList.add("visible");break;case"hasPictureView":this.hasPictureView.classList.add("visible");break;default:break}this.view=e};e.prototype.initCrop=function(){var e=this.width/this.height;var t=this.image.getBoundingClientRect();var i=t.width/t.height;if(e>i){var o=t.width/e;var r=t.height-o;this.crop.style.top=Math.round(r/2).toString()+"px";this.crop.style.height=Math.round(o).toString()+"px"}else{var n=t.height*e;var r=t.width-n;this.crop.style.left=Math.round(r/2).toString()+"px";this.crop.style.width=Math.round(n).toString()+"px"}};e.prototype.setImage=function(){var e=this;this.image.addEventListener("load",(function(){e.initCrop();e.emitImage()}));this.image.src=this.canvas.toDataURL()};e.prototype.handleNewFile=function(e){var t=this;if(e.type.split("/")[0]!="image"){return}var i=new FileReader;i.onload=function(e){var i=new Image;i.onload=function(){t.canvas.width=i.width;t.canvas.height=i.height;if(t.preventUndersized&&(i.width<t.width||i.height<t.height)){t.imageTooSmallModal.show();return}var e=t.canvas.getContext("2d");e.drawImage(i,0,0);t.setView("hasPictureView");t.setImage()};i.src=e.target.result.toString()};i.readAsDataURL(e)};e.prototype.emitImage=function(){var e=this.crop.offsetLeft/this.image.width*this.image.naturalWidth;var t=this.crop.offsetTop/this.image.height*this.image.naturalHeight;var i=this.crop.getBoundingClientRect();var o=i.width/this.image.width*this.image.naturalWidth;var r=i.height/this.image.height*this.image.naturalHeight;if(e<0)e=0;if(e>this.image.naturalWidth)e=this.image.naturalWidth;if(t<0)t=0;if(t>this.image.naturalWidth)t=this.image.naturalWidth;if(o>this.image.naturalWidth)o=this.image.naturalWidth;if(r>this.image.naturalHeight)r=this.image.naturalHeight;var n=this.generateCroppedImage(e,t,o,r,this.width,this.height);this.imageCropChanged.emit(n)};e.prototype.generateCroppedImage=function(e,t,i,o,r,n){this.canvas.width=r;this.canvas.height=n;var a=this.canvas.getContext("2d");a.clearRect(0,0,r,n);a.drawImage(this.image,e,t,i,o,0,0,r,n);return this.canvas.toDataURL("image/jpeg",this.quality)};e.prototype.getCornerLeftTop=function(e){var t=0;var i=0;switch(e){case a.se:t=this.crop.offsetLeft;i=this.crop.offsetTop;break;case a.sw:i=this.crop.offsetTop;break;default:break}return{top:i,left:t}};e.prototype.isMouseStillInTarget=function(e){var t=false;var i;var o;var r=this.image.getBoundingClientRect();if(e instanceof MouseEvent){i=e.clientX;o=e.clientY}if(typeof TouchEvent!=="undefined"){if(e instanceof TouchEvent){var n=e.touches[0];i=n.clientX;o=n.clientY}}if(i>=r.x&&o>=r.y&&i<=r.left+r.width&&o<=r.top+r.height){t=true}var a=this.crop.querySelectorAll("div");a.forEach((function(e){var r=e.getBoundingClientRect();if(i>=r.x&&o>=r.y&&i<=r.left+r.width&&o<=r.top+r.height){t=true}}));return t};e.prototype.render=function(){var e=this;return o(r,{ref:function(t){return e.host=t}},o("canvas",{ref:function(t){return e.canvas=t}}),o("div",{class:"view",ref:function(t){return e.hasPictureView=t}},o("div",{class:"cropper"},o("img",{ref:function(t){return e.image=t}}),o("div",{class:"backdrop"}),o("div",{class:"crop",ref:function(t){return e.crop=t},onMouseDown:this.handleCropMouseDown,onTouchStart:this.handleCropMouseDown},o("div",{class:"nw"}),o("div",{class:"ne"}),o("div",{class:"se"}),o("div",{class:"sw"})))),o("div",{class:"view",ref:function(t){return e.noPictureView=t}},o("dnn-dropzone",{allowCameraMode:true,onFilesSelected:function(t){return e.handleNewFile(t.detail[0])},resx:{capture:this.resx.capture,dragAndDropFile:this.resx.dragAndDropFile,or:this.resx.or,takePicture:this.resx.takePicture,uploadFile:this.resx.uploadFile}})),o("dnn-modal",{ref:function(t){return e.imageTooSmallModal=t},"close-text":this.resx.modalCloseText},o("p",null,this.resx.imageTooSmall.replace("{width}",this.width.toString()).replace("{height}",this.height.toString()))))};return e}());h.style=s}}}));
|
|
2
|
-
//# sourceMappingURL=dnn-image-cropper.system.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["src/components/dnn-image-cropper/CornerType.ts","src/components/dnn-image-cropper/dnn-image-cropper.scss?tag=dnn-image-cropper&encapsulation=shadow","src/components/dnn-image-cropper/dnn-image-cropper.tsx"],"names":["CornerType","dnnImageCropperCss","DnnImageCropper","exports","class_1","hostRef","_this","this","width","height","resx","capture","dragAndDropFile","or","takePicture","uploadFile","imageTooSmall","modalCloseText","quality","preventUndersized","handleCropMouseDown","event","stopPropagation","preventDefault","element","target","className","classList","document","addEventListener","handleImageCropFinished","handleCropDrag","removeEventListener","handleNwMouseMove","handleNeMouseMove","handleSeMouseMove","handleSwMouseMove","_ev","emitImage","previousTouch","undefined","handleCornerDrag","nw","ne","se","sw","corner","isMouseStillInTarget","_a","getCornerLeftTop","left","top","newWidth","newHeight","orientation","wantedRatio","cropRect","crop","getBoundingClientRect","imageRect","image","_b","getMovementFromEvent","movementX","movementY","Math","abs","topOffset","offsetTop","leftOffset","offsetLeft","zoomRatio","naturalWidth","style","concat","ev","newLeft","newTop","prototype","componentDidLoad","requestAnimationFrame","setView","newView","views","host","shadowRoot","querySelectorAll","forEach","v","remove","noPictureView","add","hasPictureView","view","initCrop","imageRatio","wantedHeight","diff","round","toString","wantedWidth","setImage","src","canvas","toDataURL","handleNewFile","file","type","split","reader","FileReader","onload","readerLoadEvent","img","Image","imageTooSmallModal","show","ctx","getContext","drawImage","result","readAsDataURL","x","y","naturalHeight","dataUrl","generateCroppedImage","imageCropChanged","emit","desiredWidth","desiredHeight","context","clearRect","inside","mouseX","mouseY","MouseEvent","clientX","clientY","TouchEvent","touch","touches","corners","cornerRect","render","h","Host","ref","el","class","e","onMouseDown","onTouchStart","allowCameraMode","onFilesSelected","detail","close-text","replace"],"mappings":"yNAAA,IAAYA,GAAZ,SAAYA,GACRA,EAAAA,EAAA,MAAA,GAAA,KACAA,EAAAA,EAAA,MAAA,GAAA,KACAA,EAAAA,EAAA,MAAA,GAAA,KACAA,EAAAA,EAAA,MAAA,GAAA,MAJJ,CAAYA,IAAAA,EAAU,KCAtB,IAAMC,EAAqB,m7CCcdC,EAAeC,EAAA,oBAAA,WAL5B,SAAAC,EAAAC,GAAA,IAAAC,EAAAC,kEAOUA,KAAAC,MAAgB,IAGhBD,KAAAE,OAAiB,IAKjBF,KAAAG,KAQJ,CACFC,QAAS,UACTC,gBAAiB,yBACjBC,GAAI,KACJC,YAAa,iBACbC,WAAY,kBACZC,cAAe,wJACfC,eAAgB,SAIVV,KAAAW,QAAkB,GAGlBX,KAAAY,kBAA6B,MA2F7BZ,KAAAa,oBAAsB,SAACC,GAC7BA,EAAMC,kBACND,EAAME,iBACN,IAAMC,EAAUH,EAAMI,OACtB,IAAMC,EAAYF,EAAQG,UAAU,GAEpCC,SAASC,iBAAiB,UAAWvB,EAAKwB,wBAAyB,OACnEF,SAASC,iBAAiB,WAAYvB,EAAKwB,wBAAyB,OACpE,OAAQJ,GACN,IAAK,OACHE,SAASC,iBAAiB,YAAavB,EAAKyB,eAAgB,OAC5DH,SAASC,iBAAiB,YAAavB,EAAKyB,eAAgB,OAC5DH,SAASC,iBAAiB,WAAW,WAAM,OAAA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,EAAA,MAAA,CACEI,MAAM,OACNF,IAAK,SAAAG,GAAK,OAAAhJ,EAAKmD,KAAO6F,GACtBC,YAAahJ,KAAKa,oBAClBoI,aAAcjJ,KAAKa,qBAEnB6H,EAAA,MAAA,CAAKI,MAAM,OACXJ,EAAA,MAAA,CAAKI,MAAM,OACXJ,EAAA,MAAA,CAAKI,MAAM,OACXJ,EAAA,MAAA,CAAKI,MAAM,UAIjBJ,EAAA,MAAA,CACEI,MAAM,OACNF,IAAK,SAAAC,GAAM,OAAA9I,EAAKoF,cAAgB0D,IAC9BH,EAAA,eAAA,CACEQ,gBAAe,KACfC,gBAAiB,SAAAJ,GAAK,OAAAhJ,EAAKmG,cAAc6C,EAAEK,OAAO,KAClDjJ,KACE,CACEC,QAASJ,KAAKG,KAAKC,QACnBC,gBAAiBL,KAAKG,KAAKE,gBAC3BC,GAAIN,KAAKG,KAAKG,GACdC,YAAaP,KAAKG,KAAKI,YACvBC,WAAYR,KAAKG,KAAKK,eAKhCkI,EAAA,YAAA,CAAWE,IAAK,SAAAC,GAAM,OAAA9I,EAAK6G,mBAAqBiC,GAAEQ,aAAcrJ,KAAKG,KAAKO,gBACxEgI,EAAA,IAAA,KAAI1I,KAAKG,KAAKM,cAAc6I,QAAQ,UAAWtJ,KAAKC,MAAM2F,YAAY0D,QAAQ,WAAYtJ,KAAKE,OAAO0F,yBAtdpF","sourcesContent":["export enum CornerType {\r\n \"nw\",\r\n \"ne\",\r\n \"se\",\r\n \"sw\",\r\n};",":host {\n display: block;\n}\ncanvas {\n display: none;\n}\n.view{\n visibility: hidden;\n opacity: 0;\n height: 0;\n overflow: hidden;\n transition: all 300ms ease-in-out;\n &.visible{\n visibility: visible;\n opacity: 1;\n height: initial;\n overflow: visible;\n }\n .cropper{\n position: relative;\n width: 100%;\n img{\n width: 100%;\n display: block;\n margin: 0 auto;\n }\n .backdrop{\n backdrop-filter: saturate(0.5);\n backdrop-filter: brightness(0.5);\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n }\n .crop{\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n outline: 2px dashed white;\n box-shadow: black 0 0 0px 2px;\n backdrop-filter: saturate(2);\n backdrop-filter: brightness(2);\n cursor: move;\n >div{\n width: 20px;\n height: 20px;\n background-color: white;\n border: 2px solid rgba(0,0,0,0.5);\n position: absolute;\n &.nw, &.ne{\n top: -17px;\n }\n &.ne, &.se{\n right: -17px;\n }\n &.se, &.sw{\n bottom: -17px;\n }\n &.sw, &.nw{\n left: -17px;\n }\n &.nw, &.se{\n cursor: nwse-resize;\n }\n &.ne, &.sw{\n cursor: nesw-resize;\n }\n }\n }\n }\n}\ndnn-modal{\n --max-width: 512px;\n}","import { Component, Host, h, State, Prop, Event, EventEmitter } from '@stencil/core';\nimport { CornerType } from './CornerType';\nimport { getMovementFromEvent } from \"../../utilities/mouseUtilities\";\n\n/**\n * Allows cropping an image in-browser with the option to enforce a specific final size.\n * All computation happens in the browser and the final image is emmited\n * in an event that has a data-url of the image.\n */\n@Component({\n tag: 'dnn-image-cropper',\n styleUrl: 'dnn-image-cropper.scss',\n shadow: true,\n})\nexport class DnnImageCropper {\n /** Sets the desired final image width. */\n @Prop() width: number = 600;\n\n /** Sets the desired final image height. */\n @Prop() height: number = 600;\n\n /** Can be used to customize controls text.\n * Some values support tokens, see default values for examples.\n */\n @Prop() resx: {\n capture: string;\n dragAndDropFile: string;\n or: string;\n takePicture: string;\n uploadFile: string;\n imageTooSmall: string;\n modalCloseText: string;\n } = {\n capture: \"Capture\",\n dragAndDropFile: \"Drag and drop an image\",\n or: \"or\",\n takePicture: \"Take a picture\",\n uploadFile: \"Upload an image\",\n imageTooSmall: \"The image you are attempting to upload does not meet the minimum size requirement of {width} pixels by {height} pixels. Please upload a larger image.\",\n modalCloseText: \"Close\",\n }\n\n /** Sets the output quality of the corpped image (number between 0 and 1). */\n @Prop() quality: number = 0.8;\n\n /** When set to true, prevents cropping an image smaller than the required size, which would blow pixel and make the final picture look blurry. */\n @Prop() preventUndersized: boolean = false;\n\n /** When the image crop changes, emits the dataurl for the new cropped image. */\n @Event() imageCropChanged: EventEmitter<string>;\n\n @State() view: IComponentInterfaces[\"View\"];\n \n private host: HTMLElement;\n private hasPictureView: HTMLDivElement;\n private noPictureView: HTMLDivElement;\n private canvas: HTMLCanvasElement;\n private image: HTMLImageElement;\n private crop: HTMLDivElement;\n private previousTouch: Touch;\n private imageTooSmallModal!: HTMLDnnModalElement;\n\n componentDidLoad() {\n requestAnimationFrame(() => {\n this.setView(\"noPictureView\");\n })\n }\n\n private setView(newView: IComponentInterfaces[\"View\"]){\n const views = this.host.shadowRoot.querySelectorAll(\".view\");\n views.forEach(v =>\n v.classList.remove(\"visible\"));\n switch (newView) {\n case \"noPictureView\":\n this.noPictureView.classList.add(\"visible\");\n break;\n case \"hasPictureView\":\n this.hasPictureView.classList.add(\"visible\");\n break;\n default:\n break;\n }\n this.view = newView;\n }\n\n private initCrop(){\n var wantedRatio = this.width / this.height;\n var imageRect = this.image.getBoundingClientRect();\n var imageRatio = imageRect.width / imageRect.height;\n \n if (wantedRatio > imageRatio){\n var wantedHeight = imageRect.width / wantedRatio;\n var diff = imageRect.height - wantedHeight;\n this.crop.style.top = Math.round(diff/2).toString() + \"px\";\n this.crop.style.height = Math.round(wantedHeight).toString() + \"px\";\n }\n else{\n var wantedWidth = imageRect.height * wantedRatio;\n var diff = imageRect.width - wantedWidth;\n this.crop.style.left = Math.round(diff/2).toString() + \"px\";\n this.crop.style.width = Math.round(wantedWidth).toString() + \"px\";\n }\n }\n\n private setImage(){\n this.image.addEventListener('load', () => {\n this.initCrop();\n this.emitImage();\n })\n this.image.src = this.canvas.toDataURL();\n }\n\n private handleNewFile(file: File): void {\n if (file.type.split('/')[0] != \"image\"){\n return;\n }\n \n var reader = new FileReader();\n reader.onload = readerLoadEvent => {\n var img = new Image();\n img.onload = () => {\n this.canvas.width = img.width;\n this.canvas.height = img.height;\n if (this.preventUndersized && (img.width < this.width || img.height< this.height)){\n this.imageTooSmallModal.show();\n return;\n }\n var ctx = this.canvas.getContext(\"2d\");\n ctx.drawImage(img,0,0);\n this.setView(\"hasPictureView\");\n this.setImage();\n }\n img.src = readerLoadEvent.target.result.toString();\n }\n reader.readAsDataURL(file);\n }\n\n private handleCropMouseDown = (event: MouseEvent | TouchEvent) => {\n event.stopPropagation();\n event.preventDefault();\n const element = event.target as HTMLElement;\n const className = element.classList[0];\n\n document.addEventListener(\"mouseup\", this.handleImageCropFinished, false);\n document.addEventListener(\"touchend\", this.handleImageCropFinished, false);\n switch (className) {\n case \"crop\":\n document.addEventListener(\"mousemove\", this.handleCropDrag, false);\n document.addEventListener(\"touchmove\", this.handleCropDrag, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleCropDrag));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleCropDrag));\n break;\n case \"nw\":\n document.addEventListener(\"mousemove\", this.handleNwMouseMove, false);\n document.addEventListener(\"touchmove\", this.handleNwMouseMove, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleNwMouseMove));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleNwMouseMove));\n break;\n case \"ne\":\n document.addEventListener(\"mousemove\", this.handleNeMouseMove, false);\n document.addEventListener(\"touchmove\", this.handleNeMouseMove, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleNeMouseMove));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleNeMouseMove));\n break\n case \"se\":\n document.addEventListener(\"mousemove\", this.handleSeMouseMove, false);\n document.addEventListener(\"touchmove\", this.handleSeMouseMove, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleSeMouseMove));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleSeMouseMove));\n break;\n case \"sw\":\n document.addEventListener(\"mousemove\", this.handleSwMouseMove, false);\n document.addEventListener(\"touchmove\", this.handleSwMouseMove, false)\n document.addEventListener(\"mouseup\", () => document.removeEventListener(\"mousemove\", this.handleSwMouseMove));\n document.addEventListener(\"touchend\", () => document.removeEventListener(\"touchmove\", this.handleSwMouseMove));\n break;\n default:\n break;\n }\n };\n\n private handleImageCropFinished = (_ev: MouseEvent) => {\n this.emitImage();\n document.removeEventListener(\"mouseup\", this.handleImageCropFinished);\n this.previousTouch = undefined;\n }\n\n private emitImage() {\n var x = this.crop.offsetLeft / this.image.width * this.image.naturalWidth;\n var y = this.crop.offsetTop / this.image.height * this.image.naturalHeight;\n\n var cropRect = this.crop.getBoundingClientRect();\n var width = cropRect.width / this.image.width * this.image.naturalWidth;\n var height = cropRect.height / this.image.height * this.image.naturalHeight;\n\n if (x < 0)\n x = 0;\n if (x > this.image.naturalWidth)\n x = this.image.naturalWidth;\n if (y < 0)\n y = 0;\n if (y > this.image.naturalWidth)\n y = this.image.naturalWidth;\n if (width > this.image.naturalWidth)\n width = this.image.naturalWidth;\n if (height > this.image.naturalHeight)\n height = this.image.naturalHeight;\n\n var dataUrl = this.generateCroppedImage(x, y, width, height, this.width, this.height);\n this.imageCropChanged.emit(dataUrl);\n }\n\n private generateCroppedImage(x: number, y: number, width: number, height: number, desiredWidth: number, desiredHeight: number) {\n this.canvas.width = desiredWidth;\n this.canvas.height = desiredHeight;\n const context = this.canvas.getContext(\"2d\");\n context.clearRect(0, 0, desiredWidth, desiredHeight);\n context.drawImage(this.image, x, y, width, height, 0, 0, desiredWidth, desiredHeight);\n\n return this.canvas.toDataURL(\"image/jpeg\", this.quality);\n }\n\n private handleNwMouseMove = (event: MouseEvent | TouchEvent) => {\n this.handleCornerDrag(event, CornerType.nw);\n }\n\n private handleNeMouseMove = (event: MouseEvent | TouchEvent) => {\n this.handleCornerDrag(event, CornerType.ne);\n }\n\n private handleSeMouseMove = (event: MouseEvent | TouchEvent) => {\n this.handleCornerDrag(event, CornerType.se);\n }\n\n private handleSwMouseMove = (event: MouseEvent | TouchEvent) => {\n this.handleCornerDrag(event, CornerType.sw);\n }\n\n private handleCornerDrag = (event: MouseEvent | TouchEvent, corner: CornerType) => {\n if (!this.isMouseStillInTarget(event)){\n return;\n }\n \n let {left, top} = this.getCornerLeftTop(corner);\n let newWidth = 0;\n let newHeight = 0;\n let orientation: \"horizontal\" | \"vertical\" = \"horizontal\";\n const wantedRatio = this.width / this.height;\n const cropRect = this.crop.getBoundingClientRect();\n const imageRect = this.image.getBoundingClientRect();\n let { movementX, movementY } = getMovementFromEvent(event, this.previousTouch);\n if (Math.abs(movementX) < Math.abs(movementY)){\n orientation = \"vertical\";\n }\n\n if (orientation == \"horizontal\"){\n switch (corner) {\n case CornerType.nw:\n case CornerType.sw:\n newWidth = cropRect.width - movementX;\n newHeight = newWidth / wantedRatio;\n break;\n case CornerType.ne:\n case CornerType.se:\n newWidth = cropRect.width + movementX;\n newHeight = newWidth / wantedRatio;\n break;\n default:\n break;\n }\n } else{\n switch (corner) {\n case CornerType.nw:\n case CornerType.ne:\n newHeight = cropRect.height - movementY;\n newWidth = newHeight * wantedRatio;\n break;\n case CornerType.se:\n case CornerType.sw:\n newHeight = cropRect.height + movementY;\n newWidth = newHeight * wantedRatio;\n break;\n default:\n break;\n }\n }\n\n switch (corner) {\n case CornerType.ne:\n case CornerType.nw:\n const topOffset = cropRect.height - newHeight;\n top = this.crop.offsetTop + topOffset;\n default:\n break;\n }\n\n switch (corner) {\n case CornerType.nw:\n case CornerType.sw:\n const leftOffset = cropRect.width - newWidth;\n left = this.crop.offsetLeft + leftOffset;\n if (left < 0) left = 0;\n if (left > imageRect.width) left = imageRect.width;\n if (top < 0) top = 0;\n if (top > imageRect.height) top = imageRect.height;\n if (left + newWidth > imageRect.width) newWidth = imageRect.width - left;\n if (top + newHeight > imageRect.height) newHeight = imageRect.height - top;\n break;\n case CornerType.ne:\n case CornerType.se:\n if (top < 0) top = 0;\n if (top > imageRect.height) top = imageRect.height;\n if (left + newWidth > imageRect.width) newWidth = imageRect.width - left;\n if (top + newHeight > imageRect.height) newHeight = imageRect.height - top;\n break;\n default:\n break;\n }\n\n if (newWidth / newHeight != wantedRatio){\n return;\n }\n\n if (this.preventUndersized){\n const zoomRatio = this.image.width / this.image.naturalWidth;\n if (newWidth / zoomRatio < this.width || newHeight / zoomRatio < this.height){\n return;\n }\n }\n\n switch (corner) {\n case CornerType.ne:\n this.crop.style.top = `${top}px`;\n this.crop.style.width = `${newWidth}px`;\n this.crop.style.height = `${newHeight}px`;\n break;\n case CornerType.nw:\n this.crop.style.left = `${left}px`;\n this.crop.style.top = `${top}px`;\n this.crop.style.width = `${newWidth}px`;\n this.crop.style.height = `${newHeight}px`;\n break;\n case CornerType.se:\n this.crop.style.width = `${newWidth}px`;\n this.crop.style.height = `${newHeight}px`;\n break;\n case CornerType.sw:\n this.crop.style.left = `${left}px`;\n this.crop.style.width = `${newWidth}px`;\n this.crop.style.height = `${newHeight}px`;\n break;\n default:\n break;\n }\n }\n\n private getCornerLeftTop(corner: CornerType): { left: number; top: number; } {\n let left = 0;\n let top = 0;\n switch (corner) {\n case CornerType.se:\n left = this.crop.offsetLeft;\n top = this.crop.offsetTop;\n break;\n case CornerType.sw:\n top = this.crop.offsetTop;\n break;\n default:\n break;\n }\n return {top, left};\n }\n\n private handleCropDrag = (ev: MouseEvent | TouchEvent) => {\n if (!this.isMouseStillInTarget(ev)){\n return;\n }\n let {movementX, movementY} = getMovementFromEvent(ev, this.previousTouch);\n let newLeft = this.crop.offsetLeft + movementX;\n let newTop = this.crop.offsetTop + movementY;\n var imageRect = this.image.getBoundingClientRect();\n var cropRect = this.crop.getBoundingClientRect();\n if (newLeft < 0){\n newLeft = 0;\n }\n if (newTop < 0){\n newTop = 0;\n }\n if (newLeft + cropRect.width > imageRect.width){\n newLeft = this.crop.offsetLeft;\n }\n if (newTop + cropRect.height > imageRect.height){\n newTop = this.crop.offsetTop;\n }\n this.crop.style.left = newLeft + \"px\";\n this.crop.style.top = newTop + \"px\";\n };\n\n private isMouseStillInTarget(event: MouseEvent | TouchEvent) {\n var inside = false;\n let mouseX: number;\n let mouseY: number;\n const imageRect = this.image.getBoundingClientRect();\n \n if (event instanceof MouseEvent){\n mouseX = event.clientX;\n mouseY = event.clientY;\n }\n\n if (typeof TouchEvent !== \"undefined\"){\n if (event instanceof TouchEvent){\n var touch = event.touches[0];\n mouseX = touch.clientX;\n mouseY = touch.clientY;\n }\n }\n \n if (\n mouseX >= imageRect.x &&\n mouseY >= imageRect.y &&\n mouseX <= imageRect.left + imageRect.width &&\n mouseY <= imageRect.top + imageRect.height)\n {\n inside = true;\n }\n\n var corners = this.crop.querySelectorAll(\"div\");\n corners.forEach(corner =>{\n var cornerRect = corner.getBoundingClientRect();\n if (\n mouseX >= cornerRect.x &&\n mouseY >= cornerRect.y &&\n mouseX <= cornerRect.left + cornerRect.width &&\n mouseY <= cornerRect.top + cornerRect.height)\n {\n inside = true;\n }\n })\n\n return inside;\n }\n\n render() {\n return (\n <Host ref={el => this.host = el}>\n <canvas ref={el => this.canvas = el} />\n <div\n class=\"view\"\n ref={el => this.hasPictureView = el}\n >\n <div class=\"cropper\">\n <img ref={el => this.image = el} />\n <div class=\"backdrop\" />\n <div\n class=\"crop\"\n ref={e => this.crop = e}\n onMouseDown={this.handleCropMouseDown}\n onTouchStart={this.handleCropMouseDown}\n >\n <div class=\"nw\" />\n <div class=\"ne\" />\n <div class=\"se\" />\n <div class=\"sw\" />\n </div>\n </div>\n </div>\n <div\n class=\"view\"\n ref={el => this.noPictureView = el}>\n <dnn-dropzone\n allowCameraMode\n onFilesSelected={e => this.handleNewFile(e.detail[0])}\n resx={\n {\n capture: this.resx.capture,\n dragAndDropFile: this.resx.dragAndDropFile,\n or: this.resx.or,\n takePicture: this.resx.takePicture,\n uploadFile: this.resx.uploadFile,\n }\n }\n />\n </div>\n <dnn-modal ref={el => this.imageTooSmallModal = el} close-text={this.resx.modalCloseText}>\n <p>{this.resx.imageTooSmall.replace(\"{width}\", this.width.toString()).replace(\"{height}\", this.height.toString())}</p>\n </dnn-modal>\n </Host>\n );\n }\n}\n\ninterface IComponentInterfaces\n{\n View: \"noPictureView\" | \"takingPictureView\" | \"hasPictureView\" | \"hasCroppedPictureView\";\n}"]}
|