Sha256: 5632827a5c336d51ed3175f0454d6db28cb0ad783bde15c7e6ebb1924d30eccf
Contents?: true
Size: 1.17 KB
Versions: 7
Compression:
Stored size: 1.17 KB
Contents
import { CocoComponent } from "@assets/js/shared/coco"; import { getComponent } from "@helpers/alpine"; import { basename } from "@helpers/path"; export default CocoComponent("appImagePicker", ({ 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
7 entries across 7 versions & 1 rubygems