1import { Controller } from "@hotwired/stimulus"; 2import Cropper from "cropperjs"; 3var CropperController = class extends Controller { 4 connect() { 5 const img = document.createElement("img"); 6 img.classList.add("cropperjs-image"); 7 img.src = this.publicUrlValue; 8 const parent = this.element.parentNode; 9 if (!parent) throw new Error("Missing parent node for Cropperjs"); 10 parent.appendChild(img); 11 const options = this.optionsValue; 12 this.dispatchEvent("pre-connect", { 13 options, 14 img 15 }); 16 const cropper = new Cropper(img, options); 17 img.addEventListener("crop", (event) => { 18 this.element.value = JSON.stringify(event.detail); 19 }); 20 this.dispatchEvent("connect", { 21 cropper, 22 options, 23 img 24 }); 25 } 26 dispatchEvent(name, payload) { 27 this.dispatch(name, { 28 detail: payload, 29 prefix: "cropperjs" 30 }); 31 } 32}; 33CropperController.values = { 34 publicUrl: String, 35 options: Object 36}; 37export { CropperController as default };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.