Sha256: 076e6f668fd5d947e9dd4ea71d8dc955e1d8b5adb40dd4b80a53f07b9b4e9938
Contents?: true
Size: 1.17 KB
Versions: 22
Compression:
Stored size: 1.17 KB
Contents
import { CocoComponent } from "@assets/js/coco/component"; import { getComponent } from "@helpers/alpine"; import { basename } from "@helpers/path"; export default CocoComponent("imagePicker", ({ src }) => { return { image: { name: basename(src), file: null, data: src, }, get name() { return this.image.name; }, get src() { return this.image.data; }, get hasImage() { return !!this.src; }, get uploader() { return getComponent(this.$refs.uploader.firstElementChild); }, setImage(file, silent = false) { this.image = { file: file.file, name: file.name, data: file.data, }; this.uploader.setFile(file); if (silent === false) { this.$dispatch("image-picker:select", { image: this.image }); } }, clearImage(silent = false) { this.uploader.clear(); this.image = { name: null, data: null, file: null }; if (silent === false) { this.$dispatch("image-picker:clear"); } }, browseFiles() { this.uploader.openPicker(); }, replaceImage() { this.uploader.openPicker(); }, }; });
Version data entries
22 entries across 22 versions & 1 rubygems