@tailor-cms/ce-file-display 0.1.0 → 2.0.0

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.
@@ -1,7 +1,16 @@
1
- import { Element } from '@tailor-cms/ce-file-manifest';
1
+ import type { Element } from '@tailor-cms/ce-file-manifest';
2
2
  type __VLS_Props = {
3
3
  element: Element;
4
4
  userState: any;
5
5
  };
6
- 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, {}, any>;
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ interaction: (data: {
8
+ downloadedAt: number;
9
+ }) => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ onInteraction?: ((data: {
12
+ downloadedAt: number;
13
+ }) => any) | undefined;
14
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ declare const _default: typeof __VLS_export;
7
16
  export default _default;
package/dist/index.cjs CHANGED
@@ -1,92 +1,94 @@
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");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ require('./index.css');let vue = require("vue");
6
+ //#region ../manifest/dist/index.mjs
5
7
  var type = "FILE";
6
8
  var name = "File";
7
9
  var initState = () => ({
8
- url: null,
9
- name: null,
10
- label: null,
11
- assets: {}
10
+ url: null,
11
+ name: null,
12
+ label: null,
13
+ assets: {}
12
14
  });
13
15
  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
16
+ icon: "mdi-file",
17
+ forceFullWidth: false
19
18
  };
19
+ var isEmpty = (data) => !data.url;
20
20
  var manifest$1 = {
21
- type,
22
- version: "1.0",
23
- name,
24
- ssr: false,
25
- initState,
26
- ui
21
+ type,
22
+ version: "1.0",
23
+ name,
24
+ ssr: false,
25
+ initState,
26
+ isEmpty,
27
+ ui
27
28
  };
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
- element: {},
34
- userState: {}
35
- },
36
- setup(__props) {
37
- const props = __props;
38
- const label = vue.computed(() => {
39
- const { data } = props.element;
40
- return data.label || "Download file";
41
- });
42
- const downloadFile = async () => {
43
- const { data } = props.element;
44
- const { url } = data;
45
- if (!url) return;
46
- const res = await fetch(url);
47
- const blob = await res.blob();
48
- const blobUrl = await URL.createObjectURL(blob);
49
- const link = document.createElement("a");
50
- link.href = blobUrl;
51
- const filename = data.name || data.label || "untitled";
52
- link.setAttribute("download", filename);
53
- document.body.appendChild(link);
54
- link.click();
55
- document.body.removeChild(link);
56
- };
57
- return (_ctx, _cache) => {
58
- const _component_VIcon = vue.resolveComponent("VIcon");
59
- const _component_VBtn = vue.resolveComponent("VBtn");
60
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
61
- vue.createVNode(_component_VBtn, {
62
- color: "primary-darken-2",
63
- variant: "tonal",
64
- onClick: downloadFile
65
- }, {
66
- default: vue.withCtx(() => [
67
- vue.createVNode(_component_VIcon, {
68
- icon: "mdi-file-download",
69
- start: ""
70
- }),
71
- vue.createTextVNode(" " + vue.toDisplayString(label.value), 1)
72
- ]),
73
- _: 1
74
- })
75
- ]);
76
- };
77
- }
29
+ //#endregion
30
+ //#region src/components/Display.vue?vue&type=script&setup=true&lang.ts
31
+ var _hoisted_1 = { class: "tce-file-root" };
32
+ var Display_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
33
+ __name: "Display",
34
+ props: {
35
+ element: {},
36
+ userState: {}
37
+ },
38
+ emits: ["interaction"],
39
+ setup(__props, { emit: __emit }) {
40
+ const props = __props;
41
+ const emit = __emit;
42
+ const downloaded = (0, vue.computed)(() => Boolean(props.userState?.downloadedAt));
43
+ const label = (0, vue.computed)(() => {
44
+ const { data } = props.element;
45
+ return data.label || "Download file";
46
+ });
47
+ const downloadFile = async () => {
48
+ const { data } = props.element;
49
+ const { url } = data;
50
+ if (!url) return;
51
+ const blob = await (await fetch(url)).blob();
52
+ const blobUrl = await URL.createObjectURL(blob);
53
+ const link = document.createElement("a");
54
+ link.href = blobUrl;
55
+ const filename = data.name || data.label || "untitled";
56
+ link.setAttribute("download", filename);
57
+ document.body.appendChild(link);
58
+ link.click();
59
+ document.body.removeChild(link);
60
+ emit("interaction", { downloadedAt: Date.now() });
61
+ };
62
+ return (_ctx, _cache) => {
63
+ const _component_VBtn = (0, vue.resolveComponent)("VBtn");
64
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1, [(0, vue.createVNode)(_component_VBtn, {
65
+ color: downloaded.value ? "success" : "primary",
66
+ "prepend-icon": downloaded.value ? "mdi-check" : "mdi-file-download",
67
+ variant: "tonal",
68
+ onClick: downloadFile
69
+ }, {
70
+ default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(label.value), 1)]),
71
+ _: 1
72
+ }, 8, ["color", "prepend-icon"])]);
73
+ };
74
+ }
78
75
  });
79
- const _export_sfc = (sfc, props) => {
80
- const target = sfc.__vccOpts || sfc;
81
- for (const [key, val] of props) {
82
- target[key] = val;
83
- }
84
- return target;
76
+ //#endregion
77
+ //#region \0plugin-vue:export-helper
78
+ var _plugin_vue_export_helper_default = (sfc, props) => {
79
+ const target = sfc.__vccOpts || sfc;
80
+ for (const [key, val] of props) target[key] = val;
81
+ return target;
85
82
  };
86
- const Display = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7fce0cc6"]]);
87
- const manifest = {
88
- ...index_default,
89
- Display
83
+ //#endregion
84
+ //#region src/components/Display.vue
85
+ var Display_default = /* @__PURE__ */ _plugin_vue_export_helper_default(Display_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-68a14cd9"]]);
86
+ //#endregion
87
+ //#region src/index.ts
88
+ var manifest = {
89
+ ...manifest$1,
90
+ Display: Display_default
90
91
  };
91
- exports.Display = Display;
92
+ //#endregion
93
+ exports.Display = Display_default;
92
94
  exports.default = manifest;
package/dist/index.css CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
- .tce-file-root[data-v-7fce0cc6] {
3
- background-color: transparent;
2
+ .tce-file-root[data-v-68a14cd9] {
3
+ background: transparent;
4
4
  margin: 1rem;
5
5
  padding: 1.5rem;
6
6
  text-align: center;
package/dist/index.js CHANGED
@@ -1,92 +1,89 @@
1
- import "./index.css";
2
- import { defineComponent, computed, resolveComponent, createElementBlock, openBlock, createVNode, withCtx, createTextVNode, toDisplayString } from "vue";
1
+ import { computed, createElementBlock, createTextVNode, createVNode, defineComponent, openBlock, resolveComponent, toDisplayString, withCtx } from "vue";
2
+ import './index.css';//#region ../manifest/dist/index.mjs
3
3
  var type = "FILE";
4
4
  var name = "File";
5
5
  var initState = () => ({
6
- url: null,
7
- name: null,
8
- label: null,
9
- assets: {}
6
+ url: null,
7
+ name: null,
8
+ label: null,
9
+ assets: {}
10
10
  });
11
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
12
+ icon: "mdi-file",
13
+ forceFullWidth: false
17
14
  };
15
+ var isEmpty = (data) => !data.url;
18
16
  var manifest$1 = {
19
- type,
20
- version: "1.0",
21
- name,
22
- ssr: false,
23
- initState,
24
- ui
17
+ type,
18
+ version: "1.0",
19
+ name,
20
+ ssr: false,
21
+ initState,
22
+ isEmpty,
23
+ ui
25
24
  };
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
- element: {},
32
- userState: {}
33
- },
34
- setup(__props) {
35
- const props = __props;
36
- const label = computed(() => {
37
- const { data } = props.element;
38
- return data.label || "Download file";
39
- });
40
- const downloadFile = async () => {
41
- const { data } = props.element;
42
- const { url } = data;
43
- if (!url) return;
44
- const res = await fetch(url);
45
- const blob = await res.blob();
46
- const blobUrl = await URL.createObjectURL(blob);
47
- const link = document.createElement("a");
48
- link.href = blobUrl;
49
- const filename = data.name || data.label || "untitled";
50
- link.setAttribute("download", filename);
51
- document.body.appendChild(link);
52
- link.click();
53
- document.body.removeChild(link);
54
- };
55
- return (_ctx, _cache) => {
56
- const _component_VIcon = resolveComponent("VIcon");
57
- const _component_VBtn = resolveComponent("VBtn");
58
- return openBlock(), createElementBlock("div", _hoisted_1, [
59
- createVNode(_component_VBtn, {
60
- color: "primary-darken-2",
61
- variant: "tonal",
62
- onClick: downloadFile
63
- }, {
64
- default: withCtx(() => [
65
- createVNode(_component_VIcon, {
66
- icon: "mdi-file-download",
67
- start: ""
68
- }),
69
- createTextVNode(" " + toDisplayString(label.value), 1)
70
- ]),
71
- _: 1
72
- })
73
- ]);
74
- };
75
- }
25
+ //#endregion
26
+ //#region src/components/Display.vue?vue&type=script&setup=true&lang.ts
27
+ var _hoisted_1 = { class: "tce-file-root" };
28
+ var Display_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
29
+ __name: "Display",
30
+ props: {
31
+ element: {},
32
+ userState: {}
33
+ },
34
+ emits: ["interaction"],
35
+ setup(__props, { emit: __emit }) {
36
+ const props = __props;
37
+ const emit = __emit;
38
+ const downloaded = computed(() => Boolean(props.userState?.downloadedAt));
39
+ const label = computed(() => {
40
+ const { data } = props.element;
41
+ return data.label || "Download file";
42
+ });
43
+ const downloadFile = async () => {
44
+ const { data } = props.element;
45
+ const { url } = data;
46
+ if (!url) return;
47
+ const blob = await (await fetch(url)).blob();
48
+ const blobUrl = await URL.createObjectURL(blob);
49
+ const link = document.createElement("a");
50
+ link.href = blobUrl;
51
+ const filename = data.name || data.label || "untitled";
52
+ link.setAttribute("download", filename);
53
+ document.body.appendChild(link);
54
+ link.click();
55
+ document.body.removeChild(link);
56
+ emit("interaction", { downloadedAt: Date.now() });
57
+ };
58
+ return (_ctx, _cache) => {
59
+ const _component_VBtn = resolveComponent("VBtn");
60
+ return openBlock(), createElementBlock("div", _hoisted_1, [createVNode(_component_VBtn, {
61
+ color: downloaded.value ? "success" : "primary",
62
+ "prepend-icon": downloaded.value ? "mdi-check" : "mdi-file-download",
63
+ variant: "tonal",
64
+ onClick: downloadFile
65
+ }, {
66
+ default: withCtx(() => [createTextVNode(toDisplayString(label.value), 1)]),
67
+ _: 1
68
+ }, 8, ["color", "prepend-icon"])]);
69
+ };
70
+ }
76
71
  });
77
- const _export_sfc = (sfc, props) => {
78
- const target = sfc.__vccOpts || sfc;
79
- for (const [key, val] of props) {
80
- target[key] = val;
81
- }
82
- return target;
72
+ //#endregion
73
+ //#region \0plugin-vue:export-helper
74
+ var _plugin_vue_export_helper_default = (sfc, props) => {
75
+ const target = sfc.__vccOpts || sfc;
76
+ for (const [key, val] of props) target[key] = val;
77
+ return target;
83
78
  };
84
- const Display = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7fce0cc6"]]);
85
- const manifest = {
86
- ...index_default,
87
- Display
88
- };
89
- export {
90
- Display,
91
- manifest as default
79
+ //#endregion
80
+ //#region src/components/Display.vue
81
+ var Display_default = /* @__PURE__ */ _plugin_vue_export_helper_default(Display_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-68a14cd9"]]);
82
+ //#endregion
83
+ //#region src/index.ts
84
+ var manifest = {
85
+ ...manifest$1,
86
+ Display: Display_default
92
87
  };
88
+ //#endregion
89
+ export { Display_default as Display, manifest as default };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Tailor CMS file end-user component",
4
4
  "author": "Studion <info@gostudion.com> (https://github.com/tailor-cms)",
5
5
  "type": "module",
6
- "version": "0.1.0",
6
+ "version": "2.0.0",
7
7
  "exports": {
8
8
  ".": {
9
9
  "import": "./dist/index.js",
@@ -16,19 +16,24 @@
16
16
  "dist"
17
17
  ],
18
18
  "peerDependencies": {
19
- "vue": "^3.5.13"
19
+ "vue": "^3.5.29"
20
20
  },
21
21
  "devDependencies": {
22
- "@tailor-cms/eslint-config": "1.1.2",
23
- "@vitejs/plugin-vue": "^6.0.0",
24
- "typescript": "^5.8.3",
25
- "vite": "^7.0.3",
26
- "vue-tsc": "^3.0.1",
27
- "@tailor-cms/ce-file-manifest": "0.1.0"
22
+ "@tailor-cms/eslint-config": "2.0.1",
23
+ "@vitejs/plugin-vue": "^6.0.6",
24
+ "typescript": "^6.0.3",
25
+ "vite": "^8.0.10",
26
+ "vite-plugin-lib-inject-css": "^2.2.2",
27
+ "vue-tsc": "^3.2.7",
28
+ "vuetify": "^4.0.6",
29
+ "@tailor-cms/ce-file-manifest": "2.0.0"
28
30
  },
29
31
  "publishConfig": {
30
32
  "access": "public"
31
33
  },
34
+ "engines": {
35
+ "node": ">=24"
36
+ },
32
37
  "scripts": {
33
38
  "dev": "vite build --watch",
34
39
  "build": "pnpm nuke:dist && vue-tsc && vite build",