@aplus-frontend/ui 7.10.6 → 7.11.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.
Files changed (113) hide show
  1. package/es/index.mjs +93 -91
  2. package/es/src/ag-grid/editable/form-item.vue.mjs +75 -63
  3. package/es/src/ag-grid/editable/index.vue.mjs +80 -72
  4. package/es/src/ag-grid/editable/interface.d.ts +2 -1
  5. package/es/src/ag-grid/editable/utils.d.ts +7 -0
  6. package/es/src/ag-grid/editable/utils.mjs +32 -17
  7. package/es/src/ap-form/ap-form.vue2.mjs +144 -153
  8. package/es/src/ap-form/utils/transform.d.ts +6 -0
  9. package/es/src/ap-form/utils/transform.mjs +30 -0
  10. package/es/src/ap-pro-card/components/card/index.vue.d.ts +1 -1
  11. package/es/src/business/ap-appendix/ap-appendix.vue2.mjs +129 -93
  12. package/es/src/business/ap-appendix/interface.d.ts +4 -0
  13. package/es/src/business/ap-appendix/style/index.mjs +56 -34
  14. package/es/src/business/ap-attachment/ApAttachment.mjs +112 -89
  15. package/es/src/business/ap-attachment/style/index.mjs +21 -7
  16. package/es/src/business/ap-download/ap-download.vue.d.ts +1 -0
  17. package/es/src/business/ap-download/ap-download.vue.mjs +86 -45
  18. package/es/src/business/ap-download/interface.d.ts +4 -0
  19. package/es/src/business/ap-download/style/index.mjs +8 -4
  20. package/es/src/business/ap-file-preview/ap-file-preview.vue.d.ts +4 -0
  21. package/es/src/business/ap-file-preview/ap-file-preview.vue.mjs +4 -0
  22. package/es/src/business/ap-file-preview/ap-file-preview.vue2.mjs +104 -0
  23. package/es/src/business/ap-file-preview/components/error-result/index.vue.d.ts +6 -0
  24. package/es/src/business/ap-file-preview/components/error-result/index.vue.mjs +4 -0
  25. package/es/src/business/ap-file-preview/components/error-result/index.vue2.mjs +40 -0
  26. package/es/src/business/ap-file-preview/icons/not-exist-icon.vue.d.ts +3 -0
  27. package/es/src/business/ap-file-preview/icons/not-exist-icon.vue.mjs +20 -0
  28. package/es/src/business/ap-file-preview/icons/not-preview-icon.vue.d.ts +3 -0
  29. package/es/src/business/ap-file-preview/icons/not-preview-icon.vue.mjs +20 -0
  30. package/es/src/business/ap-file-preview/index.d.ts +7 -0
  31. package/es/src/business/ap-file-preview/index.mjs +8 -0
  32. package/es/src/business/ap-file-preview/interface.d.ts +45 -0
  33. package/es/src/business/ap-file-preview/style/index.d.ts +5 -0
  34. package/es/src/business/ap-file-preview/style/index.mjs +46 -0
  35. package/es/src/business/ap-file-preview/utils/create-file-preview-modal.d.ts +2 -0
  36. package/es/src/business/ap-file-preview/utils/create-file-preview-modal.mjs +18 -0
  37. package/es/src/business/ap-file-preview/utils/default-parser-plugin.d.ts +4 -0
  38. package/es/src/business/ap-file-preview/utils/default-parser-plugin.mjs +48 -0
  39. package/es/src/business/ap-image/ApImage.vue2.mjs +16 -16
  40. package/es/src/business/ap-upload/apUpload.vue.d.ts +1 -1
  41. package/es/src/business/ap-upload/apUploadTypes.d.ts +2 -2
  42. package/es/src/business/ap-upload/components/MultipleFile.vue2.mjs +94 -82
  43. package/es/src/business/ap-upload/style/multiple-file.mjs +6 -3
  44. package/es/src/business/index.d.ts +1 -0
  45. package/es/src/business/index.mjs +16 -14
  46. package/es/src/config-provider/config-provider-props.d.ts +6 -0
  47. package/es/src/config-provider/config-provider-props.mjs +6 -2
  48. package/es/src/config-provider/config-provider.d.ts +17 -1
  49. package/es/src/config-provider/config-provider.mjs +24 -23
  50. package/es/src/config-provider/hooks/use-global-config.d.ts +7 -0
  51. package/es/src/config-provider/index.d.ts +31 -3
  52. package/es/src/index.mjs +74 -72
  53. package/es/src/locale/lang/en.mjs +5 -0
  54. package/es/src/locale/lang/zh-cn.mjs +5 -0
  55. package/es/src/version.d.ts +1 -1
  56. package/es/src/version.mjs +1 -1
  57. package/lib/index.js +1 -1
  58. package/lib/src/ag-grid/editable/form-item.vue.js +1 -1
  59. package/lib/src/ag-grid/editable/index.vue.js +1 -1
  60. package/lib/src/ag-grid/editable/interface.d.ts +2 -1
  61. package/lib/src/ag-grid/editable/utils.d.ts +7 -0
  62. package/lib/src/ag-grid/editable/utils.js +1 -1
  63. package/lib/src/ap-form/ap-form.vue2.js +1 -1
  64. package/lib/src/ap-form/utils/transform.d.ts +6 -0
  65. package/lib/src/ap-form/utils/transform.js +1 -0
  66. package/lib/src/ap-pro-card/components/card/index.vue.d.ts +1 -1
  67. package/lib/src/business/ap-appendix/ap-appendix.vue2.js +1 -1
  68. package/lib/src/business/ap-appendix/interface.d.ts +4 -0
  69. package/lib/src/business/ap-appendix/style/index.js +1 -1
  70. package/lib/src/business/ap-attachment/ApAttachment.js +1 -1
  71. package/lib/src/business/ap-attachment/style/index.js +1 -1
  72. package/lib/src/business/ap-download/ap-download.vue.d.ts +1 -0
  73. package/lib/src/business/ap-download/ap-download.vue.js +1 -1
  74. package/lib/src/business/ap-download/interface.d.ts +4 -0
  75. package/lib/src/business/ap-download/style/index.js +1 -1
  76. package/lib/src/business/ap-file-preview/ap-file-preview.vue.d.ts +4 -0
  77. package/lib/src/business/ap-file-preview/ap-file-preview.vue.js +1 -0
  78. package/lib/src/business/ap-file-preview/ap-file-preview.vue2.js +1 -0
  79. package/lib/src/business/ap-file-preview/components/error-result/index.vue.d.ts +6 -0
  80. package/lib/src/business/ap-file-preview/components/error-result/index.vue.js +1 -0
  81. package/lib/src/business/ap-file-preview/components/error-result/index.vue2.js +1 -0
  82. package/lib/src/business/ap-file-preview/icons/not-exist-icon.vue.d.ts +3 -0
  83. package/lib/src/business/ap-file-preview/icons/not-exist-icon.vue.js +1 -0
  84. package/lib/src/business/ap-file-preview/icons/not-preview-icon.vue.d.ts +3 -0
  85. package/lib/src/business/ap-file-preview/icons/not-preview-icon.vue.js +1 -0
  86. package/lib/src/business/ap-file-preview/index.d.ts +7 -0
  87. package/lib/src/business/ap-file-preview/index.js +1 -0
  88. package/lib/src/business/ap-file-preview/interface.d.ts +45 -0
  89. package/lib/src/business/ap-file-preview/style/index.d.ts +5 -0
  90. package/lib/src/business/ap-file-preview/style/index.js +1 -0
  91. package/lib/src/business/ap-file-preview/utils/create-file-preview-modal.d.ts +2 -0
  92. package/lib/src/business/ap-file-preview/utils/create-file-preview-modal.js +1 -0
  93. package/lib/src/business/ap-file-preview/utils/default-parser-plugin.d.ts +4 -0
  94. package/lib/src/business/ap-file-preview/utils/default-parser-plugin.js +1 -0
  95. package/lib/src/business/ap-image/ApImage.vue2.js +1 -1
  96. package/lib/src/business/ap-upload/apUpload.vue.d.ts +1 -1
  97. package/lib/src/business/ap-upload/apUploadTypes.d.ts +2 -2
  98. package/lib/src/business/ap-upload/components/MultipleFile.vue2.js +1 -1
  99. package/lib/src/business/ap-upload/style/multiple-file.js +1 -1
  100. package/lib/src/business/index.d.ts +1 -0
  101. package/lib/src/business/index.js +1 -1
  102. package/lib/src/config-provider/config-provider-props.d.ts +6 -0
  103. package/lib/src/config-provider/config-provider-props.js +1 -1
  104. package/lib/src/config-provider/config-provider.d.ts +17 -1
  105. package/lib/src/config-provider/config-provider.js +1 -1
  106. package/lib/src/config-provider/hooks/use-global-config.d.ts +7 -0
  107. package/lib/src/config-provider/index.d.ts +31 -3
  108. package/lib/src/index.js +1 -1
  109. package/lib/src/locale/lang/en.js +1 -1
  110. package/lib/src/locale/lang/zh-cn.js +1 -1
  111. package/lib/src/version.d.ts +1 -1
  112. package/lib/src/version.js +1 -1
  113. package/package.json +1 -1
@@ -1,121 +1,144 @@
1
- import { defineComponent as U, ref as k, useSlots as W, computed as o, cloneVNode as _, toRaw as g, unref as j, createVNode as t, createTextVNode as R } from "vue";
2
- import { LoadingOutlined as p } from "@ant-design/icons-vue";
3
- import { Tooltip as B, Popover as G } from "@aplus-frontend/antdv";
4
- import { debounce as H, isArray as M } from "lodash-unified";
5
- import { useToken as q } from "../../config-provider/hooks/use-token.mjs";
6
- import { warning as D } from "../../utils/warning.mjs";
1
+ import { defineComponent as j, ref as g, useSlots as M, computed as i, cloneVNode as R, toRaw as w, unref as B, createVNode as e, createTextVNode as D } from "vue";
2
+ import { LoadingOutlined as N } from "@ant-design/icons-vue";
3
+ import { Tooltip as A, Popover as G } from "@aplus-frontend/antdv";
4
+ import { IconApAdLineDownload as H } from "@aplus-frontend/icon";
5
+ import { debounce as q, isArray as E } from "lodash-unified";
6
+ import { useToken as J } from "../../config-provider/hooks/use-token.mjs";
7
+ import { warning as Q } from "../../utils/warning.mjs";
7
8
  import "../../config-provider/index.mjs";
8
- import { useOssInit as E } from "../ap-download/hooks/index.mjs";
9
- import { getHexWithOpacity as J, getFileInfo as F } from "../ap-download/utils/getFileInfo.mjs";
10
- import { ApAttachmentProps as Q } from "./constans.mjs";
11
- import X from "./style/index.mjs";
12
- import { useNamespace as Y } from "../../config-provider/hooks/use-namespace.mjs";
9
+ import { useOssInit as X } from "../ap-download/hooks/index.mjs";
10
+ import { getHexWithOpacity as Y, getFileInfo as L } from "../ap-download/utils/getFileInfo.mjs";
11
+ import { ApFilePreview as Z } from "../ap-file-preview/index.mjs";
12
+ import { ApAttachmentProps as $ } from "./constans.mjs";
13
+ import ee from "./style/index.mjs";
14
+ import { useNamespace as te } from "../../config-provider/hooks/use-namespace.mjs";
13
15
  import { useGlobalConfig as T } from "../../config-provider/hooks/use-global-config.mjs";
14
- import { useLocale as Z } from "../../config-provider/hooks/use-locale.mjs";
15
- const fe = /* @__PURE__ */ U({
16
+ import { useLocale as ae } from "../../config-provider/hooks/use-locale.mjs";
17
+ const Ne = /* @__PURE__ */ j({
16
18
  name: "ApAttachment",
17
- props: Q(),
18
- setup(e, {
19
- emit: N
19
+ props: $(),
20
+ setup(t, {
21
+ emit: y
20
22
  }) {
21
23
  const {
22
- b: x,
23
- e: a
24
- } = Y("ap-attachment"), y = X("ap-attachment"), r = T("apUpload"), L = T("downloadCenterTriggerConfig"), {
25
- token: C
26
- } = q(), {
27
- lang: O,
28
- t: d
29
- } = Z(), i = k(!1), c = k(""), f = W(), K = o(() => O.value === "zh-cn" ? "zh_CN" : "en_US"), s = o(() => e.needName ?? (r?.value?.needName === !0 ? {
24
+ b: P,
25
+ e: l
26
+ } = te("ap-attachment"), C = ee("ap-attachment"), d = T("apUpload"), F = T("downloadCenterTriggerConfig"), {
27
+ token: x
28
+ } = J(), {
29
+ lang: I,
30
+ t: c
31
+ } = ae(), r = g(!1), u = g(""), f = M(), K = i(() => I.value === "zh-cn" ? "zh_CN" : "en_US"), s = i(() => t.needName ?? (d?.value?.needName === !0 ? {
30
32
  nameKey: "fileName",
31
33
  pathKey: "path"
32
- } : r?.value?.needName ?? {
34
+ } : d?.value?.needName ?? {
33
35
  nameKey: "fileName",
34
36
  pathKey: "filePath"
35
- })), v = o(() => e.attachmentList.length === 1), w = o(() => s.value ? e.attachmentList.length > 0 && s.value && s.value?.nameKey ? e.attachmentList[0][s.value.nameKey] : "" : e.attachmentList.length > 0 ? e.attachmentList[0].fileName : ""), P = o(() => v.value ? w.value : d("ap.apAttachment.downloadall")), A = o(() => ({
36
- "--download-main-color": C.value?.colorLink,
37
- "--download-main-color-opacity": J(C.value?.colorLink, 0.6)
38
- })), I = o(() => e.getOssAccess || r.value?.getOssAccess), S = o(() => {
39
- const l = f.default ? f.default()[0] : null;
40
- return l ? _(l, {
37
+ })), p = i(() => t.attachmentList.length === 1), b = i(() => s.value ? t.attachmentList.length > 0 && s.value && s.value?.nameKey ? t.attachmentList[0][s.value.nameKey] : "" : t.attachmentList.length > 0 ? t.attachmentList[0].fileName : ""), S = i(() => p.value ? b.value : c("ap.apAttachment.downloadall")), k = i(() => ({
38
+ "--download-main-color": x.value?.colorLink,
39
+ "--download-main-color-opacity": Y(x.value?.colorLink, 0.6)
40
+ })), U = i(() => t.getOssAccess || d.value?.getOssAccess), V = i(() => {
41
+ const a = f.default ? f.default()[0] : null;
42
+ return a ? R(a, {
41
43
  style: {
42
44
  "font-size": "16px"
43
45
  }
44
46
  }) : null;
45
- }), h = H(async (l, u) => {
46
- if (!e.disabled) {
47
- i.value = !0, u && (c.value = u);
47
+ }), v = g(!1), h = q(async (a, n) => {
48
+ if (!t.disabled) {
49
+ r.value = !0, n && (u.value = n);
48
50
  try {
49
- const n = M(g(l)) ? g(l) : [g(l)];
50
- if (L.value?.trigger) {
51
- const m = F(s.value, n).map((b) => ({
52
- objectName: b.path,
53
- fileName: b.fileName
51
+ const o = E(w(a)) ? w(a) : [w(a)];
52
+ if (F.value?.trigger) {
53
+ const m = L(s.value, o).map((O) => ({
54
+ objectName: O.path,
55
+ fileName: O.fileName
54
56
  }));
55
- L.value?.trigger(m), N("downloadCallback", m);
57
+ F.value?.trigger(m), y("downloadCallback", m);
56
58
  } else {
57
- const m = await (await E(I.value, j(K))).downloadFile(F(e.needName, n));
58
- N("downloadCallback", m);
59
+ const m = await (await X(U.value, B(K))).downloadFile(L(s.value, o));
60
+ y("downloadCallback", m);
59
61
  }
60
- } catch (n) {
61
- D(!1, n);
62
+ } catch (o) {
63
+ Q(!1, o);
62
64
  } finally {
63
- i.value = !1, c.value = "";
65
+ r.value = !1, u.value = "";
64
66
  }
65
67
  }
66
- }, 500), V = (l) => l && l.length > 0 ? t("ul", {
67
- class: [a("file-list"), y.value],
68
- style: A.value
69
- }, [l.map((u, n) => t("li", {
70
- key: n,
71
- class: [a("file-item")],
72
- onClick: () => h(u, n + 1)
73
- }, [i.value && c.value === n + 1 ? t("span", {
74
- class: [a("spin")]
75
- }, [t(p, {
68
+ }, 500), z = (a) => {
69
+ const n = L(s.value, a)?.[0];
70
+ Z.createFilePreviewModal({
71
+ src: n.path,
72
+ fileName: n.fileName
73
+ }), v.value = !1;
74
+ }, W = (a) => a && a.length > 0 ? e("ul", {
75
+ class: [l("file-list"), C.value],
76
+ style: k.value
77
+ }, [a.map((n, o) => e("li", {
78
+ key: o,
79
+ class: [l("file-item")]
80
+ }, [r.value && u.value === o + 1 ? e("span", {
81
+ class: [l("spin")]
82
+ }, [e(N, {
76
83
  spin: !0
77
- }, null)]) : null, u.fileName])), t("li", {
78
- class: [a("download-all")],
79
- onClick: () => h(e.attachmentList, "all")
80
- }, [i.value && c.value === "all" ? t("span", {
81
- class: [a("spin")]
82
- }, [t(p, {
84
+ }, null)]) : null, e(A, {
85
+ title: c("ap.apAppendix.previewFile")
86
+ }, {
87
+ default: () => [e("span", {
88
+ class: [l("file-item-text")],
89
+ onClick: () => z(n)
90
+ }, [n.fileName])]
91
+ }), e(A, {
92
+ title: c("ap.apAppendix.downloadFile")
93
+ }, {
94
+ default: () => [e("span", {
95
+ class: [l("file-item-download")],
96
+ onClick: () => h(n, o + 1)
97
+ }, [e(H, null, null)])]
98
+ })])), e("li", {
99
+ class: [l("download-all")],
100
+ onClick: () => h(t.attachmentList, "all")
101
+ }, [r.value && u.value === "all" ? e("span", {
102
+ class: [l("spin")]
103
+ }, [e(N, {
83
104
  spin: !0
84
- }, null)]) : null, d("ap.apAttachment.downloadall")])]) : null;
85
- return () => e.attachmentList?.length > 0 && t("div", {
86
- class: [x(), y.value],
87
- style: [A.value]
88
- }, [t(B, {
89
- title: P.value,
90
- placement: e.textToolTipPlacement,
91
- color: e.toolTipBgColor
105
+ }, null)]) : null, c("ap.apAttachment.downloadall")])]) : null;
106
+ return () => t.attachmentList?.length > 0 && e("div", {
107
+ class: [P(), C.value],
108
+ style: [k.value]
109
+ }, [e(A, {
110
+ title: S.value,
111
+ placement: t.textToolTipPlacement,
112
+ color: t.toolTipBgColor
92
113
  }, {
93
- default: () => [t("div", {
94
- class: [a("content")],
95
- onClick: () => h(v.value ? e.attachmentList[0] : e.attachmentList, "global")
96
- }, [i.value && c.value === "global" ? t("div", {
97
- class: [a("spin")]
98
- }, [t(p, {
114
+ default: () => [e("div", {
115
+ class: [l("content")],
116
+ onClick: () => h(p.value ? t.attachmentList[0] : t.attachmentList, "global")
117
+ }, [r.value && u.value === "global" ? e("div", {
118
+ class: [l("spin")]
119
+ }, [e(N, {
99
120
  spin: !0
100
- }, null)]) : null, f.default ? t("div", {
101
- class: [a("text-render")]
102
- }, [S.value, R(" ")]) : null, t("div", {
103
- class: [a("text-inner")],
121
+ }, null)]) : null, f.default ? e("div", {
122
+ class: [l("text-render")]
123
+ }, [V.value, D(" ")]) : null, e("div", {
124
+ class: [l("text-inner")],
104
125
  style: {
105
- "max-width": e.maxWidth ? e.maxWidth + "px" : "auto"
126
+ "max-width": t.maxWidth ? t.maxWidth + "px" : "auto"
106
127
  }
107
- }, [w.value])])]
108
- }), t(G, {
109
- content: V(e.attachmentList),
110
- placement: e.fileMorePopoverPlacement,
111
- color: "#fff"
128
+ }, [b.value])])]
129
+ }), e(G, {
130
+ content: W(t.attachmentList),
131
+ placement: t.fileMorePopoverPlacement,
132
+ color: "#fff",
133
+ open: v.value,
134
+ "onUpdate:open": (a) => v.value = a
112
135
  }, {
113
- default: () => [!v.value && t("div", {
114
- class: [a("more")]
115
- }, [d("ap.apAttachment.more")])]
136
+ default: () => [!p.value && e("div", {
137
+ class: [l("more")]
138
+ }, [c("ap.apAttachment.more")])]
116
139
  })]);
117
140
  }
118
141
  });
119
142
  export {
120
- fe as default
143
+ Ne as default
121
144
  };
@@ -1,5 +1,5 @@
1
1
  import { genComponentStyleHook as e } from "../../../utils/cssinjs/index.mjs";
2
- const n = (o) => {
2
+ const a = (o) => {
3
3
  const { componentCls: r } = o;
4
4
  return {
5
5
  [r]: {
@@ -59,10 +59,24 @@ const n = (o) => {
59
59
  wordWrap: "break-word",
60
60
  marginBlockEnd: o.spaceLG,
61
61
  fontSize: o.fontSize,
62
- color: "#000",
63
- cursor: "pointer",
62
+ color: o.textColor1,
64
63
  "&:hover": {
65
- color: "var(--download-main-color)"
64
+ [`${r}__file-item-download`]: {
65
+ opacity: 1
66
+ }
67
+ },
68
+ "&-text": {
69
+ cursor: "pointer",
70
+ "&:hover": {
71
+ color: "var(--download-main-color)"
72
+ }
73
+ },
74
+ "&-download": {
75
+ cursor: "pointer",
76
+ color: "var(--download-main-color)",
77
+ marginLeft: o.space,
78
+ opacity: 0,
79
+ fontSize: o.fontSizeXL
66
80
  }
67
81
  },
68
82
  [`${r}__download-all`]: {
@@ -76,13 +90,13 @@ const n = (o) => {
76
90
  }
77
91
  }
78
92
  };
79
- }, i = e(
93
+ }, n = e(
80
94
  "ApAttachment",
81
- (o) => [n(o)],
95
+ (o) => [a(o)],
82
96
  {
83
97
  apAttachmentListMaxWidth: 312
84
98
  }
85
99
  );
86
100
  export {
87
- i as default
101
+ n as default
88
102
  };
@@ -19,6 +19,7 @@ declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, Comp
19
19
  size: "small" | "large" | "middle";
20
20
  type: ButtonType;
21
21
  disabled: boolean;
22
+ preview: boolean;
22
23
  needName: ApDownLoadNeedNameModel;
23
24
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
24
25
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -1,20 +1,22 @@
1
- import { defineComponent as O, ref as z, useSlots as A, computed as s, unref as t, createBlock as L, openBlock as i, mergeProps as S, withCtx as x, createElementVNode as m, normalizeClass as j, createElementBlock as f, createCommentVNode as u, createVNode as I, renderSlot as F, toDisplayString as T } from "vue";
2
- import { LoadingOutlined as U } from "@ant-design/icons-vue";
3
- import { Button as V } from "@aplus-frontend/antdv";
4
- import { omit as D } from "lodash-unified";
1
+ import { defineComponent as I, ref as P, useSlots as T, computed as l, unref as t, createBlock as j, openBlock as n, mergeProps as V, withCtx as s, createElementVNode as C, normalizeClass as D, createElementBlock as p, createCommentVNode as m, createVNode as r, renderSlot as M, createSlots as U, toDisplayString as b, createTextVNode as E, withModifiers as G } from "vue";
2
+ import { LoadingOutlined as R } from "@ant-design/icons-vue";
3
+ import { Button as W, Tooltip as k } from "@aplus-frontend/antdv";
4
+ import { IconApAdLineDownload as $ } from "@aplus-frontend/icon";
5
+ import { isArray as q, omit as H } from "lodash-unified";
5
6
  import "../../config-provider/index.mjs";
6
- import { useOssInit as E } from "./hooks/index.mjs";
7
- import { useStyle as P } from "./hooks/useStyle.mjs";
8
- import { getFileInfo as g } from "./utils/getFileInfo.mjs";
9
- import { useLocale as G } from "../../config-provider/hooks/use-locale.mjs";
10
- import { useGlobalConfig as y } from "../../config-provider/hooks/use-global-config.mjs";
11
- const M = {
7
+ import { ApFilePreview as J } from "../ap-file-preview/index.mjs";
8
+ import { useOssInit as K } from "./hooks/index.mjs";
9
+ import { useStyle as Q } from "./hooks/useStyle.mjs";
10
+ import { getFileInfo as f } from "./utils/getFileInfo.mjs";
11
+ import { useLocale as X } from "../../config-provider/hooks/use-locale.mjs";
12
+ import { useGlobalConfig as h } from "../../config-provider/hooks/use-global-config.mjs";
13
+ const Y = {
12
14
  key: 0,
13
15
  class: "spin"
14
- }, R = {
16
+ }, Z = {
15
17
  key: 1,
16
18
  class: "icon"
17
- }, W = { class: "text" }, oe = /* @__PURE__ */ O({
19
+ }, ee = { class: "text" }, fe = /* @__PURE__ */ I({
18
20
  name: "ApDownload",
19
21
  __name: "ap-download",
20
22
  props: {
@@ -41,61 +43,100 @@ const M = {
41
43
  text: {},
42
44
  fileName: {},
43
45
  needName: { type: [Boolean, Object], default: void 0 },
44
- getOssAccess: {}
46
+ getOssAccess: {},
47
+ preview: { type: Boolean, default: !1 }
45
48
  },
46
49
  emits: ["downloadCallback"],
47
- setup(C, { emit: N }) {
48
- const r = N, l = z(!1), { lang: b } = G(), v = A(), w = s(() => b.value === "zh-cn" ? "zh_CN" : "en_US"), e = C, n = y("apUpload"), c = y(
50
+ setup(_, { emit: A }) {
51
+ const u = A, c = P(!1), { lang: B, t: g } = X(), O = T(), z = l(() => B.value === "zh-cn" ? "zh_CN" : "en_US"), e = _, i = h("apUpload"), v = h(
49
52
  "downloadCenterTriggerConfig"
50
- ), d = s(() => e.disabled), h = s(() => e.size), { getInnerWrapperClass: _ } = P(h, d), k = s(() => e.getOssAccess || n.value?.getOssAccess), B = async () => {
53
+ ), w = l(() => e.disabled), x = l(() => e.size), d = l(
54
+ () => e.preview && (q(e.fileName) ? e.fileName.length === 1 : !0)
55
+ ), { getInnerWrapperClass: F } = Q(x, w), L = l(() => e.getOssAccess || i.value?.getOssAccess), S = () => {
56
+ const o = f(
57
+ e.needName ?? i?.value?.needName,
58
+ e.fileName
59
+ )?.[0];
60
+ J.createFilePreviewModal({
61
+ src: o.path,
62
+ fileName: o.fileName
63
+ });
64
+ }, N = async () => {
51
65
  if (!e.disabled) {
52
- l.value = !0;
66
+ c.value = !0;
53
67
  try {
54
- if (c.value?.trigger) {
55
- let a = g(
56
- e.needName ?? n?.value?.needName,
68
+ if (v.value?.trigger) {
69
+ let a = f(
70
+ e.needName ?? i?.value?.needName,
57
71
  e.fileName
58
- ).map((p) => ({
59
- objectName: p.path,
60
- fileName: p.fileName
72
+ ).map((y) => ({
73
+ objectName: y.path,
74
+ fileName: y.fileName
61
75
  }));
62
- await c.value?.trigger(a), r("downloadCallback", a);
76
+ await v.value?.trigger(a), u("downloadCallback", a);
63
77
  } else {
64
- const a = await (await E(
65
- k.value,
66
- t(w)
78
+ const a = await (await K(
79
+ L.value,
80
+ t(z)
67
81
  )).downloadFile(
68
- g(
69
- e.needName ?? n?.value?.needName,
82
+ f(
83
+ e.needName ?? i?.value?.needName,
70
84
  e.fileName
71
85
  )
72
86
  );
73
- r("downloadCallback", a);
87
+ u("downloadCallback", a);
74
88
  }
75
89
  } catch (o) {
76
90
  console.error(o);
77
91
  } finally {
78
- l.value = !1;
92
+ c.value = !1;
79
93
  }
80
94
  }
81
95
  };
82
- return (o, a) => (i(), L(t(V), S(t(D)(e, ["getOssAccess", "fileName", "needName"]), {
96
+ return (o, a) => (n(), j(t(W), V(t(H)(e, ["getOssAccess", "fileName", "needName"]), {
83
97
  type: e.type,
84
98
  size: e.size,
85
- disabled: d.value,
86
- onClick: B
99
+ disabled: w.value,
100
+ onClick: a[0] || (a[0] = () => (d.value ? S : N)())
87
101
  }), {
88
- default: x(() => [
89
- m("div", {
90
- class: j(t(_))
102
+ default: s(() => [
103
+ C("div", {
104
+ class: D(t(F))
91
105
  }, [
92
- l.value ? (i(), f("span", M, [
93
- I(t(U), { spin: !0 })
94
- ])) : u("", !0),
95
- t(v).icon ? (i(), f("span", R, [
96
- F(o.$slots, "icon")
97
- ])) : u("", !0),
98
- m("span", W, T(o.text), 1)
106
+ c.value ? (n(), p("span", Y, [
107
+ r(t(R), { spin: !0 })
108
+ ])) : m("", !0),
109
+ t(O).icon ? (n(), p("span", Z, [
110
+ M(o.$slots, "icon")
111
+ ])) : m("", !0),
112
+ r(t(k), null, U({
113
+ default: s(() => [
114
+ C("span", ee, b(o.text), 1)
115
+ ]),
116
+ _: 2
117
+ }, [
118
+ d.value ? {
119
+ name: "title",
120
+ fn: s(() => [
121
+ E(b(t(g)("ap.apAppendix.previewFile")), 1)
122
+ ]),
123
+ key: "0"
124
+ } : void 0
125
+ ]), 1024),
126
+ d.value ? (n(), p("span", {
127
+ key: 2,
128
+ class: "preview-icon",
129
+ onClick: G(N, ["stop"])
130
+ }, [
131
+ r(t(k), {
132
+ title: t(g)("ap.apAppendix.downloadFile")
133
+ }, {
134
+ default: s(() => [
135
+ r(t($))
136
+ ]),
137
+ _: 1
138
+ }, 8, ["title"])
139
+ ])) : m("", !0)
99
140
  ], 2)
100
141
  ]),
101
142
  _: 3
@@ -103,5 +144,5 @@ const M = {
103
144
  }
104
145
  });
105
146
  export {
106
- oe as default
147
+ fe as default
107
148
  };
@@ -22,6 +22,10 @@ export type ApDownLoadProps<FileNameType = any> = ButtonProps & {
22
22
  */
23
23
  needName?: ApDownLoadNeedNameModel;
24
24
  getOssAccess?: () => Promise<accessCreate>;
25
+ /**
26
+ * 是否开启预览,多文件时配置无效
27
+ */
28
+ preview?: boolean;
25
29
  };
26
30
  /**
27
31
  * 别名配置项
@@ -1,6 +1,6 @@
1
1
  import { genComponentStyleHook as l } from "../../../utils/cssinjs/index.mjs";
2
2
  const r = (o) => {
3
- const { componentCls: e, textColor3: n } = o, i = `${e}-inner-wrapper`;
3
+ const { componentCls: e, textColor3: i } = o, n = `${e}-inner-wrapper`;
4
4
  return {
5
5
  [e]: {
6
6
  "&-wrapper": {
@@ -8,7 +8,7 @@ const r = (o) => {
8
8
  display: "inline-block"
9
9
  }
10
10
  },
11
- [i]: {
11
+ [n]: {
12
12
  display: "flex",
13
13
  color: "var(--download-main-color)",
14
14
  cursor: "pointer",
@@ -24,6 +24,10 @@ const r = (o) => {
24
24
  ".text": {
25
25
  color: "var(--download-main-color)"
26
26
  },
27
+ ".preview-icon": {
28
+ fontSize: o.fontSizeXL,
29
+ marginLeft: o.space
30
+ },
27
31
  "&:hover": {
28
32
  color: "var(--download-main-color-opacity)"
29
33
  },
@@ -40,10 +44,10 @@ const r = (o) => {
40
44
  fontSize: o.fontSizeSM
41
45
  },
42
46
  "&--disabled": {
43
- color: n,
47
+ color: i,
44
48
  cursor: "not-allowed",
45
49
  "&:hover": {
46
- color: n
50
+ color: i
47
51
  }
48
52
  }
49
53
  }
@@ -0,0 +1,4 @@
1
+ import { ApFilePreviewProps } from './interface';
2
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ declare const _default: DefineComponent<ApFilePreviewProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ApFilePreviewProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
4
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import f from "./ap-file-preview.vue2.mjs";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,104 @@
1
+ import { defineComponent as E, ref as w, computed as c, watch as L, createElementBlock as m, openBlock as r, normalizeClass as C, unref as l, createBlock as i, Fragment as p, createCommentVNode as x, resolveDynamicComponent as B, h as R } from "vue";
2
+ import { Spin as W } from "@aplus-frontend/antdv";
3
+ import { createOssInstance as I } from "@aplus-frontend/oss";
4
+ import "../../config-provider/index.mjs";
5
+ import "./components/error-result/index.vue.mjs";
6
+ import $ from "./style/index.mjs";
7
+ import { defaultParserPlugins as j } from "./utils/default-parser-plugin.mjs";
8
+ import { useGlobalConfig as _ } from "../../config-provider/hooks/use-global-config.mjs";
9
+ import { useNamespace as D } from "../../config-provider/hooks/use-namespace.mjs";
10
+ import { useLocale as G } from "../../config-provider/hooks/use-locale.mjs";
11
+ import b from "./components/error-result/index.vue2.mjs";
12
+ const ee = /* @__PURE__ */ E({
13
+ __name: "ap-file-preview",
14
+ props: {
15
+ src: {},
16
+ fileName: {},
17
+ format: {},
18
+ parserPlugin: {},
19
+ getOssAccess: { type: Function }
20
+ },
21
+ setup(k) {
22
+ const e = k, P = _("apUpload"), N = _("apFilePreview"), { b: f } = D("ap-file-preview"), O = $("ap-file-preview"), { lang: S } = G(), U = {
23
+ "zh-cn": "zh_CN",
24
+ en: "en_US"
25
+ }, t = w(), o = w(!1), v = c(
26
+ () => e.getOssAccess || P.value?.getOssAccess
27
+ ), s = c(() => e?.format ?? e?.src?.split(".").pop()), A = c(() => [
28
+ ...j,
29
+ ...N.value?.parserPlugin ?? [],
30
+ ...e?.parserPlugin ?? []
31
+ ]), g = c(() => s.value ? A.value?.findLast(
32
+ (a) => s.value && a.format.includes(s.value)
33
+ ) : void 0), F = async () => {
34
+ try {
35
+ if (o.value = !0, t.value = void 0, !e?.src)
36
+ return;
37
+ if (e.src?.startsWith("http") || e.src?.startsWith("data:") || e.src?.startsWith("blob:")) {
38
+ t.value = e.src;
39
+ return;
40
+ }
41
+ const a = e.src?.match(/^([^:]+):(.*)$/), u = a?.[1], h = a?.[2] ?? e.src, d = I();
42
+ await d.initOssClient({
43
+ getOssAccess: () => u ? v.value?.(u) : v.value?.(),
44
+ locale: U[S.value] ?? "zh_CN",
45
+ onFailure: (n) => {
46
+ throw new Error(
47
+ typeof n?.message == "string" ? n.message : "oss create error"
48
+ );
49
+ }
50
+ });
51
+ const y = await d.getSignatureUrl(
52
+ h,
53
+ 3600,
54
+ e?.fileName ?? h
55
+ );
56
+ if (y) {
57
+ const n = await fetch(y).then((z) => z.blob());
58
+ t.value = URL.createObjectURL(n);
59
+ } else
60
+ throw new Error("oss getSignatureUrl error");
61
+ } finally {
62
+ o.value = !1;
63
+ }
64
+ };
65
+ return L(
66
+ () => [e.src],
67
+ () => {
68
+ F();
69
+ },
70
+ {
71
+ immediate: !0
72
+ }
73
+ ), (a, u) => (r(), m("div", {
74
+ class: C([l(f)(), l(O)])
75
+ }, [
76
+ o.value ? (r(), i(l(W), {
77
+ key: 0,
78
+ class: C([l(f)("spin")])
79
+ }, null, 8, ["class"])) : !o.value && t.value && e.src ? (r(), m(p, { key: 1 }, [
80
+ g.value && s.value ? (r(), m(p, { key: 0 }, [
81
+ t.value ? (r(), i(B(
82
+ R(p, [
83
+ g.value?.parser?.({
84
+ src: t.value,
85
+ originalSrc: e.src,
86
+ format: s.value,
87
+ fileName: e.fileName
88
+ })
89
+ ])
90
+ ), { key: 0 })) : x("", !0)
91
+ ], 64)) : (r(), i(b, {
92
+ key: 1,
93
+ type: "notPreview"
94
+ }))
95
+ ], 64)) : (r(), i(b, {
96
+ key: 2,
97
+ type: "notExist"
98
+ }))
99
+ ], 2));
100
+ }
101
+ });
102
+ export {
103
+ ee as default
104
+ };
@@ -0,0 +1,6 @@
1
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
2
+ type __VLS_Props = {
3
+ type?: 'notExist' | 'notPreview';
4
+ };
5
+ declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
6
+ export default _default;