Sha256: b68c39dc9621cf42153b8dd4dee1ea635ea28c96046f2d7f4064ddfa97b96a41
Contents?: true
Size: 1.16 KB
Versions: 25
Compression:
Stored size: 1.16 KB
Contents
import { CocoComponent } from "@js/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
25 entries across 25 versions & 1 rubygems