@tailor-cms/ce-file-display 0.0.1

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/README.md ADDED
@@ -0,0 +1 @@
1
+ # Content element `Display` component
@@ -0,0 +1,8 @@
1
+ import { ElementData } from '@tailor-cms/ce-file-manifest';
2
+ type __VLS_Props = {
3
+ id: number;
4
+ data: ElementData;
5
+ userState: any;
6
+ };
7
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, HTMLDivElement>;
8
+ export default _default;
package/dist/index.cjs ADDED
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var import_index = require("./index.css");
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
4
+ const vue = require("vue");
5
+ var type = "FILE";
6
+ var name = "File";
7
+ var initState = () => ({
8
+ url: null,
9
+ name: null,
10
+ label: null,
11
+ assets: {}
12
+ });
13
+ var ui = {
14
+ // Display icon, https://pictogrammers.com/library/mdi/
15
+ icon: "mdi-file",
16
+ // Does element support only full width or can be used within layouts
17
+ // (e.g. 50/50 layout)
18
+ forceFullWidth: false
19
+ };
20
+ var manifest$1 = {
21
+ type,
22
+ version: "1.0",
23
+ name,
24
+ ssr: false,
25
+ initState,
26
+ ui
27
+ };
28
+ var index_default = manifest$1;
29
+ const _hoisted_1 = { class: "tce-file-root" };
30
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31
+ __name: "Display",
32
+ props: {
33
+ id: {},
34
+ data: {},
35
+ userState: {}
36
+ },
37
+ setup(__props) {
38
+ const props = __props;
39
+ const label = vue.computed(() => {
40
+ const { data } = props;
41
+ return data.label || "Download file";
42
+ });
43
+ const downloadFile = async () => {
44
+ const { data } = props;
45
+ const { url } = data;
46
+ if (!url) return;
47
+ const res = await fetch(url);
48
+ const blob = await res.blob();
49
+ const blobUrl = await URL.createObjectURL(blob);
50
+ const link = document.createElement("a");
51
+ link.href = blobUrl;
52
+ const filename = data.name || data.label || "untitled";
53
+ link.setAttribute("download", filename);
54
+ document.body.appendChild(link);
55
+ link.click();
56
+ document.body.removeChild(link);
57
+ };
58
+ return (_ctx, _cache) => {
59
+ const _component_VIcon = vue.resolveComponent("VIcon");
60
+ const _component_VBtn = vue.resolveComponent("VBtn");
61
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
62
+ vue.createVNode(_component_VBtn, {
63
+ color: "primary-darken-2",
64
+ variant: "tonal",
65
+ onClick: downloadFile
66
+ }, {
67
+ default: vue.withCtx(() => [
68
+ vue.createVNode(_component_VIcon, {
69
+ icon: "mdi-file-download",
70
+ start: ""
71
+ }),
72
+ vue.createTextVNode(" " + vue.toDisplayString(label.value), 1)
73
+ ]),
74
+ _: 1
75
+ })
76
+ ]);
77
+ };
78
+ }
79
+ });
80
+ const _export_sfc = (sfc, props) => {
81
+ const target = sfc.__vccOpts || sfc;
82
+ for (const [key, val] of props) {
83
+ target[key] = val;
84
+ }
85
+ return target;
86
+ };
87
+ const Display = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7501f8a1"]]);
88
+ const manifest = {
89
+ ...index_default,
90
+ Display
91
+ };
92
+ exports.Display = Display;
93
+ exports.default = manifest;
package/dist/index.css ADDED
@@ -0,0 +1,7 @@
1
+
2
+ .tce-file-root[data-v-7501f8a1] {
3
+ background-color: transparent;
4
+ margin: 1rem;
5
+ padding: 1.5rem;
6
+ text-align: center;
7
+ }
@@ -0,0 +1,5 @@
1
+ import type { ElementManifest } from '@tailor-cms/ce-file-manifest';
2
+ import Display from './components/Display.vue';
3
+ declare const manifest: ElementManifest;
4
+ export default manifest;
5
+ export { Display };
package/dist/index.js ADDED
@@ -0,0 +1,93 @@
1
+ import "./index.css";
2
+ import { defineComponent, computed, resolveComponent, createElementBlock, openBlock, createVNode, withCtx, createTextVNode, toDisplayString } from "vue";
3
+ var type = "FILE";
4
+ var name = "File";
5
+ var initState = () => ({
6
+ url: null,
7
+ name: null,
8
+ label: null,
9
+ assets: {}
10
+ });
11
+ var ui = {
12
+ // Display icon, https://pictogrammers.com/library/mdi/
13
+ icon: "mdi-file",
14
+ // Does element support only full width or can be used within layouts
15
+ // (e.g. 50/50 layout)
16
+ forceFullWidth: false
17
+ };
18
+ var manifest$1 = {
19
+ type,
20
+ version: "1.0",
21
+ name,
22
+ ssr: false,
23
+ initState,
24
+ ui
25
+ };
26
+ var index_default = manifest$1;
27
+ const _hoisted_1 = { class: "tce-file-root" };
28
+ const _sfc_main = /* @__PURE__ */ defineComponent({
29
+ __name: "Display",
30
+ props: {
31
+ id: {},
32
+ data: {},
33
+ userState: {}
34
+ },
35
+ setup(__props) {
36
+ const props = __props;
37
+ const label = computed(() => {
38
+ const { data } = props;
39
+ return data.label || "Download file";
40
+ });
41
+ const downloadFile = async () => {
42
+ const { data } = props;
43
+ const { url } = data;
44
+ if (!url) return;
45
+ const res = await fetch(url);
46
+ const blob = await res.blob();
47
+ const blobUrl = await URL.createObjectURL(blob);
48
+ const link = document.createElement("a");
49
+ link.href = blobUrl;
50
+ const filename = data.name || data.label || "untitled";
51
+ link.setAttribute("download", filename);
52
+ document.body.appendChild(link);
53
+ link.click();
54
+ document.body.removeChild(link);
55
+ };
56
+ return (_ctx, _cache) => {
57
+ const _component_VIcon = resolveComponent("VIcon");
58
+ const _component_VBtn = resolveComponent("VBtn");
59
+ return openBlock(), createElementBlock("div", _hoisted_1, [
60
+ createVNode(_component_VBtn, {
61
+ color: "primary-darken-2",
62
+ variant: "tonal",
63
+ onClick: downloadFile
64
+ }, {
65
+ default: withCtx(() => [
66
+ createVNode(_component_VIcon, {
67
+ icon: "mdi-file-download",
68
+ start: ""
69
+ }),
70
+ createTextVNode(" " + toDisplayString(label.value), 1)
71
+ ]),
72
+ _: 1
73
+ })
74
+ ]);
75
+ };
76
+ }
77
+ });
78
+ const _export_sfc = (sfc, props) => {
79
+ const target = sfc.__vccOpts || sfc;
80
+ for (const [key, val] of props) {
81
+ target[key] = val;
82
+ }
83
+ return target;
84
+ };
85
+ const Display = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7501f8a1"]]);
86
+ const manifest = {
87
+ ...index_default,
88
+ Display
89
+ };
90
+ export {
91
+ Display,
92
+ manifest as default
93
+ };
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@tailor-cms/ce-file-display",
3
+ "description": "Tailor CMS file end-user component",
4
+ "author": "Studion <info@gostudion.com> (https://github.com/tailor-cms)",
5
+ "type": "module",
6
+ "version": "0.0.1",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.cjs"
11
+ }
12
+ },
13
+ "main": "./dist/index.cjs",
14
+ "types": "./types/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "peerDependencies": {
19
+ "vue": "^3.5.13"
20
+ },
21
+ "devDependencies": {
22
+ "@tailor-cms/eslint-config": "0.0.2",
23
+ "@vitejs/plugin-vue": "^5.2.1",
24
+ "typescript": "^5.7.3",
25
+ "vite": "^6.1.0",
26
+ "vue-tsc": "^2.2.0",
27
+ "@tailor-cms/ce-file-manifest": "0.0.1"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "dev": "vite build --watch",
34
+ "build": "vue-tsc && vite build",
35
+ "lint": "eslint --ext .js,.ts,.vue ./src",
36
+ "lint:fix": "pnpm lint --fix"
37
+ }
38
+ }