@kingteza/crud-component 1.45.0 → 1.46.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.
- package/dist/_virtual/index.cjs.js +1 -1
- package/dist/_virtual/index.cjs2.js +1 -1
- package/dist/_virtual/index.cjs3.js +1 -1
- package/dist/_virtual/index.es.js +5 -2
- package/dist/_virtual/index.es2.js +5 -5
- package/dist/_virtual/index.es3.js +2 -5
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +103 -101
- package/dist/crud/FileCrudField.cjs.js +1 -1
- package/dist/crud/FileCrudField.d.ts +2 -1
- package/dist/crud/FileCrudField.es.js +133 -132
- package/dist/crud/ImageCrudField.cjs.js +1 -1
- package/dist/crud/ImageCrudField.d.ts +1 -0
- package/dist/crud/ImageCrudField.es.js +114 -103
- package/dist/node_modules/.pnpm/input-format@0.3.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/input-format/modules/react/Input.cjs.js +1 -1
- package/dist/node_modules/.pnpm/input-format@0.3.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/input-format/modules/react/Input.es.js +1 -1
- package/dist/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.cjs.js +1 -1
- package/dist/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.es.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/CountryIcon.cjs.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/CountryIcon.es.js +2 -2
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/CountrySelect.cjs.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/CountrySelect.es.js +2 -2
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/Flag.cjs.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/Flag.es.js +2 -2
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InputBasic.cjs.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InputBasic.es.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InputSmart.cjs.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InputSmart.es.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InternationalIcon.cjs.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InternationalIcon.es.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/PhoneInputWithCountry.cjs.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/PhoneInputWithCountry.es.js +2 -2
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/PropTypes.cjs.js +1 -1
- package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/PropTypes.es.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),o=require("@ant-design/icons"),w=require("antd"),E=require("mime"),c=require("react"),Z=require("../locale/index.cjs.js"),U=require("../util/ValidationUtil.cjs.js"),b=require("../common/button/Button.cjs.js"),B=require("../common/layout/VerticalSpace.cjs.js"),p=require("../util/CrudUtil.cjs.js"),v=require("../util/ImageUtil.cjs.js");function y({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,onUploadComplete:f,fieldClassName:q,accept:$,rules:H,maxCount:V=1,block:R,fieldHelper:z,formLayoutProps:A,preprocessBeforeUpload:F,...L}){const x=w.Form.useFormInstance(),W=p.getRealName(n,"upsertFieldName"),j=w.Form.useWatch(W,x),[S,M]=c.useState(!1),[k,G]=c.useState(!1),J=c.useCallback(async r=>{var d,u;try{const{file:i}=r,O=i.name;M(!0),G(!0),a==null||a(!0);const P=O??"",N=P.split("."),Q=N[N.length-1],X=s.generateFileName(P),Y=`${await s.getInitialPath()}/${X}.${Q}`;let C=i;F&&(typeof F=="function"?C=await F(i):F.compressImage&&(C=await v.resizeImage(i)));const I=await s.upload({...i,originFileObj:C},Y);f==null||f(I),a==null||a(!1),x.setFieldValue(n,I),(d=r.onSuccess)==null||d.call(r,I)}catch(i){(u=r.onError)==null||u.call(r,i)}finally{M(!1)}},[x,n,f,a,F,s]),[g,D]=c.useState([]);c.useEffect(()=>{!k&&j&&Promise.all((Array.isArray(j)?j:[j]).map(async r=>{const d=E.getType(r),u=r.split("/").pop(),i=await s.getRealUrl(r);return{uid:r,url:i,type:d,name:u}})).then(r=>D(()=>r.map(({url:u,type:i,uid:O,name:P})=>({uid:O,url:u,type:i,response:O,thumbUrl:u,name:P}))))},[j,k,S,s]);const K=c.useCallback(async r=>{const d=r.response,u=d||x.getFieldValue(n);await s.delete(u),h==null||h(),r&&x.setFieldsValue({[n]:null})},[x,n,h,s]);return t.jsxs(w.Form.Item,{label:e,required:l,name:n,...A,className:q,rules:[...l?U.required(e):[],...H??[]],help:z,children:[t.jsx("input",{hidden:!0}),t.jsx(w.Upload,{...L,fileList:g,className:((g==null?void 0:g.length)??0)>=V?"hide-upload":"",maxCount:V,customRequest:J,onRemove:K,listType:"picture",onChange:({fileList:r})=>{D(r)},accept:$,style:R?{width:"100%"}:void 0,children:t.jsx(b,{icon:t.jsx(o.UploadOutlined,{}),block:!0,size:"large",loading:S,children:"Upload File"})})]})}const T=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:E.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(_,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},_=({url:n,mimeType:e="",fileName:l})=>{const s=c.useMemo(()=>e!=null&&e.includes("image")?"image":e!=null&&e.includes("pdf")?"pdf":e!=null&&e.includes("word")?"word":e!=null&&e.includes("text")?"text":e!=null&&e.includes("presentation")?"presentation":e!=null&&e.includes("excel")||e!=null&&e.includes("spreadsheet")?"excel":"file",[e]),a=c.useMemo(()=>{switch(s){case"image":return t.jsx(o.FileImageOutlined,{});case"pdf":return t.jsx(o.FilePdfOutlined,{});case"word":return t.jsx(o.FileWordOutlined,{});case"text":return t.jsx(o.FileTextOutlined,{});case"excel":return t.jsx(o.FileExcelOutlined,{});case"presentation":return t.jsx(o.FilePptOutlined,{});default:return t.jsx(o.FileOutlined,{})}},[s]),[h,f]=c.useState(!1),{t:q}=Z.useTranslationLib();return s!=="file"&&s!=="text"?t.jsxs(t.Fragment,{children:[t.jsx(w.Modal,{open:h,title:l,onCancel:()=>f(!1),footer:t.jsx(t.Fragment,{}),width:"100%",style:{top:"8px",minHeight:"700px"},destroyOnHidden:!0,children:t.jsxs(B,{children:[t.jsx(b,{tooltip:l,icon:t.jsx(o.ExportOutlined,{}),target:"_blank",href:n,style:{textDecoration:"none"},children:q("str.openInNewTab")}),s==="image"?t.jsx("img",{src:n,alt:l,style:{width:"100%"}}):s==="pdf"?t.jsxs("iframe",{title:l,src:n,width:"100%",height:"700px",children:["This browser does not support PDFs. Please download the PDF to view it:",t.jsx("a",{href:n,children:"Download PDF"})]}):t.jsxs("iframe",{title:l,src:`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(n)}`,width:"100%",height:"700px",children:["This browser does not support open ",s.toUpperCase(),". Please download the",s.toUpperCase()," to view it:",t.jsxs("a",{href:n,children:["Download ",s.toUpperCase()]}),"."]})]})}),t.jsx(b,{tooltip:l,icon:a,shape:"circle",onClick:()=>f(!0)})]}):t.jsx(b,{tooltip:l,icon:a,target:"_blank",href:n,shape:"circle"})};exports.FileCellValue=_;exports.FileCrudCellValue=T;exports.default=y;
|
|
@@ -12,13 +12,14 @@ export interface _FileCrudField<T> extends InitialCrudField<T> {
|
|
|
12
12
|
compressImage?: boolean;
|
|
13
13
|
} | ((file: RcFile) => Promise<RcFile>);
|
|
14
14
|
onRemoved?: () => void;
|
|
15
|
+
onUploadComplete?: (finalPath: string) => void;
|
|
15
16
|
fieldClassName?: string;
|
|
16
17
|
accept?: string;
|
|
17
18
|
maxCount?: number;
|
|
18
19
|
block?: boolean;
|
|
19
20
|
help?: ReactNode;
|
|
20
21
|
}
|
|
21
|
-
export default function FileCrudFieldComponent<T>({ name, label, required, provider, onUploading, onRemoved, fieldClassName, accept, rules, maxCount, block, fieldHelper: help, formLayoutProps, preprocessBeforeUpload, ...props }: Readonly<_FileCrudField<T>>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default function FileCrudFieldComponent<T>({ name, label, required, provider, onUploading, onRemoved, onUploadComplete, fieldClassName, accept, rules, maxCount, block, fieldHelper: help, formLayoutProps, preprocessBeforeUpload, ...props }: Readonly<_FileCrudField<T>>): import("react/jsx-runtime").JSX.Element;
|
|
22
23
|
export declare const FileCrudCellValue: FC<{
|
|
23
24
|
value: string;
|
|
24
25
|
provider: FileDownloadProvider;
|
|
@@ -1,179 +1,180 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { FileOutlined as
|
|
3
|
-
import { Form as
|
|
4
|
-
import
|
|
5
|
-
import { useState as
|
|
6
|
-
import { useTranslationLib as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
function
|
|
1
|
+
import { jsxs as h, jsx as e, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import { UploadOutlined as B, FileOutlined as v, FilePptOutlined as y, FileExcelOutlined as m, FileTextOutlined as T, FileWordOutlined as tt, FilePdfOutlined as et, FileImageOutlined as st, ExportOutlined as rt } from "@ant-design/icons";
|
|
3
|
+
import { Form as V, Upload as lt, Modal as nt } from "antd";
|
|
4
|
+
import z from "mime";
|
|
5
|
+
import { useState as g, useCallback as H, useEffect as A, useMemo as S } from "react";
|
|
6
|
+
import { useTranslationLib as it } from "../locale/index.es.js";
|
|
7
|
+
import at from "../util/ValidationUtil.es.js";
|
|
8
|
+
import I from "../common/button/Button.es.js";
|
|
9
|
+
import ct from "../common/layout/VerticalSpace.es.js";
|
|
10
|
+
import ot from "../util/CrudUtil.es.js";
|
|
11
|
+
import ut from "../util/ImageUtil.es.js";
|
|
12
|
+
function pt({
|
|
13
13
|
name: n,
|
|
14
14
|
label: t,
|
|
15
|
-
required:
|
|
16
|
-
provider:
|
|
17
|
-
onUploading:
|
|
18
|
-
onRemoved:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
required: r,
|
|
16
|
+
provider: s,
|
|
17
|
+
onUploading: i,
|
|
18
|
+
onRemoved: f,
|
|
19
|
+
onUploadComplete: u,
|
|
20
|
+
fieldClassName: b,
|
|
21
|
+
accept: L,
|
|
22
|
+
rules: W,
|
|
23
|
+
maxCount: N = 1,
|
|
24
|
+
block: _,
|
|
25
|
+
fieldHelper: q,
|
|
26
|
+
formLayoutProps: R,
|
|
27
|
+
preprocessBeforeUpload: w,
|
|
28
|
+
...G
|
|
28
29
|
}) {
|
|
29
|
-
const d =
|
|
30
|
-
async (
|
|
30
|
+
const d = V.useFormInstance(), J = ot.getRealName(n, "upsertFieldName"), F = V.useWatch(J, d), [k, E] = g(!1), [M, K] = g(!1), Q = H(
|
|
31
|
+
async (l) => {
|
|
31
32
|
var o, c;
|
|
32
33
|
try {
|
|
33
|
-
const { file:
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
{ ...
|
|
40
|
-
|
|
34
|
+
const { file: a } = l, O = a.name;
|
|
35
|
+
E(!0), K(!0), i == null || i(!0);
|
|
36
|
+
const P = O ?? "", j = P.split("."), Y = j[j.length - 1], Z = s.generateFileName(P), U = `${await s.getInitialPath()}/${Z}.${Y}`;
|
|
37
|
+
let C = a;
|
|
38
|
+
w && (typeof w == "function" ? C = await w(a) : w.compressImage && (C = await ut.resizeImage(a)));
|
|
39
|
+
const p = await s.upload(
|
|
40
|
+
{ ...a, originFileObj: C },
|
|
41
|
+
U
|
|
41
42
|
);
|
|
42
|
-
|
|
43
|
-
} catch (
|
|
44
|
-
(c =
|
|
43
|
+
u == null || u(p), i == null || i(!1), d.setFieldValue(n, p), (o = l.onSuccess) == null || o.call(l, p);
|
|
44
|
+
} catch (a) {
|
|
45
|
+
(c = l.onError) == null || c.call(l, a);
|
|
45
46
|
} finally {
|
|
46
|
-
|
|
47
|
+
E(!1);
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
|
-
[d, n,
|
|
50
|
-
), [
|
|
50
|
+
[d, n, u, i, w, s]
|
|
51
|
+
), [x, $] = g([]);
|
|
51
52
|
A(() => {
|
|
52
|
-
!
|
|
53
|
-
(Array.isArray(
|
|
54
|
-
async (
|
|
55
|
-
const o =
|
|
53
|
+
!M && F && Promise.all(
|
|
54
|
+
(Array.isArray(F) ? F : [F]).map(
|
|
55
|
+
async (l) => {
|
|
56
|
+
const o = z.getType(l), c = l.split("/").pop(), a = await s.getRealUrl(l);
|
|
56
57
|
return {
|
|
57
|
-
uid:
|
|
58
|
-
url:
|
|
58
|
+
uid: l,
|
|
59
|
+
url: a,
|
|
59
60
|
type: o,
|
|
60
61
|
name: c
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
)
|
|
64
|
-
).then((
|
|
65
|
-
}, [
|
|
66
|
-
const
|
|
67
|
-
async (
|
|
68
|
-
const o =
|
|
69
|
-
await
|
|
65
|
+
).then((l) => $(() => l.map(({ url: c, type: a, uid: O, name: P }) => ({ uid: O, url: c, type: a, response: O, thumbUrl: c, name: P }))));
|
|
66
|
+
}, [F, M, k, s]);
|
|
67
|
+
const X = H(
|
|
68
|
+
async (l) => {
|
|
69
|
+
const o = l.response, c = o || d.getFieldValue(n);
|
|
70
|
+
await s.delete(c), f == null || f(), l && d.setFieldsValue({ [n]: null });
|
|
70
71
|
},
|
|
71
|
-
[d, n,
|
|
72
|
+
[d, n, f, s]
|
|
72
73
|
);
|
|
73
|
-
return /* @__PURE__ */
|
|
74
|
-
|
|
74
|
+
return /* @__PURE__ */ h(
|
|
75
|
+
V.Item,
|
|
75
76
|
{
|
|
76
77
|
label: t,
|
|
77
|
-
required:
|
|
78
|
+
required: r,
|
|
78
79
|
name: n,
|
|
79
|
-
...
|
|
80
|
-
className:
|
|
80
|
+
...R,
|
|
81
|
+
className: b,
|
|
81
82
|
rules: [
|
|
82
|
-
...
|
|
83
|
-
...
|
|
83
|
+
...r ? at.required(t) : [],
|
|
84
|
+
...W ?? []
|
|
84
85
|
],
|
|
85
|
-
help:
|
|
86
|
+
help: q,
|
|
86
87
|
children: [
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
|
|
88
|
+
/* @__PURE__ */ e("input", { hidden: !0 }),
|
|
89
|
+
/* @__PURE__ */ e(
|
|
90
|
+
lt,
|
|
90
91
|
{
|
|
91
|
-
...
|
|
92
|
-
fileList:
|
|
93
|
-
className: ((
|
|
94
|
-
maxCount:
|
|
95
|
-
customRequest:
|
|
96
|
-
onRemove:
|
|
92
|
+
...G,
|
|
93
|
+
fileList: x,
|
|
94
|
+
className: ((x == null ? void 0 : x.length) ?? 0) >= N ? "hide-upload" : "",
|
|
95
|
+
maxCount: N,
|
|
96
|
+
customRequest: Q,
|
|
97
|
+
onRemove: X,
|
|
97
98
|
listType: "picture",
|
|
98
|
-
onChange: ({ fileList:
|
|
99
|
-
|
|
99
|
+
onChange: ({ fileList: l }) => {
|
|
100
|
+
$(l);
|
|
100
101
|
},
|
|
101
|
-
accept:
|
|
102
|
-
style:
|
|
103
|
-
children: /* @__PURE__ */
|
|
102
|
+
accept: L,
|
|
103
|
+
style: _ ? { width: "100%" } : void 0,
|
|
104
|
+
children: /* @__PURE__ */ e(I, { icon: /* @__PURE__ */ e(B, {}), block: !0, size: "large", loading: k, children: "Upload File" })
|
|
104
105
|
}
|
|
105
106
|
)
|
|
106
107
|
]
|
|
107
108
|
}
|
|
108
109
|
);
|
|
109
110
|
}
|
|
110
|
-
const
|
|
111
|
-
const [
|
|
111
|
+
const Vt = ({ provider: n, value: t }) => {
|
|
112
|
+
const [r, s] = g();
|
|
112
113
|
return A(() => {
|
|
113
|
-
t && n.getRealUrl(t).then((
|
|
114
|
-
|
|
115
|
-
mimeType:
|
|
116
|
-
url:
|
|
114
|
+
t && n.getRealUrl(t).then((i) => {
|
|
115
|
+
s({
|
|
116
|
+
mimeType: z.getType(t),
|
|
117
|
+
url: i,
|
|
117
118
|
fileName: t.split("/").pop() ?? t
|
|
118
119
|
});
|
|
119
120
|
});
|
|
120
|
-
}, [n, t]),
|
|
121
|
-
|
|
121
|
+
}, [n, t]), r ? /* @__PURE__ */ e(
|
|
122
|
+
ft,
|
|
122
123
|
{
|
|
123
|
-
fileName:
|
|
124
|
-
url:
|
|
125
|
-
mimeType:
|
|
124
|
+
fileName: r.fileName,
|
|
125
|
+
url: r == null ? void 0 : r.url,
|
|
126
|
+
mimeType: r == null ? void 0 : r.mimeType
|
|
126
127
|
}
|
|
127
|
-
) : /* @__PURE__ */
|
|
128
|
-
},
|
|
129
|
-
const
|
|
130
|
-
switch (
|
|
128
|
+
) : /* @__PURE__ */ e(D, {});
|
|
129
|
+
}, ft = ({ url: n, mimeType: t = "", fileName: r }) => {
|
|
130
|
+
const s = S(() => t != null && t.includes("image") ? "image" : t != null && t.includes("pdf") ? "pdf" : t != null && t.includes("word") ? "word" : t != null && t.includes("text") ? "text" : t != null && t.includes("presentation") ? "presentation" : t != null && t.includes("excel") || t != null && t.includes("spreadsheet") ? "excel" : "file", [t]), i = S(() => {
|
|
131
|
+
switch (s) {
|
|
131
132
|
case "image":
|
|
132
|
-
return /* @__PURE__ */
|
|
133
|
+
return /* @__PURE__ */ e(st, {});
|
|
133
134
|
case "pdf":
|
|
134
|
-
return /* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ e(et, {});
|
|
135
136
|
case "word":
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
+
return /* @__PURE__ */ e(tt, {});
|
|
137
138
|
case "text":
|
|
138
|
-
return /* @__PURE__ */
|
|
139
|
+
return /* @__PURE__ */ e(T, {});
|
|
139
140
|
case "excel":
|
|
140
|
-
return /* @__PURE__ */
|
|
141
|
+
return /* @__PURE__ */ e(m, {});
|
|
141
142
|
case "presentation":
|
|
142
|
-
return /* @__PURE__ */
|
|
143
|
+
return /* @__PURE__ */ e(y, {});
|
|
143
144
|
default:
|
|
144
|
-
return /* @__PURE__ */
|
|
145
|
+
return /* @__PURE__ */ e(v, {});
|
|
145
146
|
}
|
|
146
|
-
}, [
|
|
147
|
-
return
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
|
|
147
|
+
}, [s]), [f, u] = g(!1), { t: b } = it();
|
|
148
|
+
return s !== "file" && s !== "text" ? /* @__PURE__ */ h(D, { children: [
|
|
149
|
+
/* @__PURE__ */ e(
|
|
150
|
+
nt,
|
|
150
151
|
{
|
|
151
|
-
open:
|
|
152
|
-
title:
|
|
153
|
-
onCancel: () =>
|
|
154
|
-
footer: /* @__PURE__ */
|
|
152
|
+
open: f,
|
|
153
|
+
title: r,
|
|
154
|
+
onCancel: () => u(!1),
|
|
155
|
+
footer: /* @__PURE__ */ e(D, {}),
|
|
155
156
|
width: "100%",
|
|
156
157
|
style: { top: "8px", minHeight: "700px" },
|
|
157
158
|
destroyOnHidden: !0,
|
|
158
|
-
children: /* @__PURE__ */
|
|
159
|
-
/* @__PURE__ */
|
|
160
|
-
|
|
159
|
+
children: /* @__PURE__ */ h(ct, { children: [
|
|
160
|
+
/* @__PURE__ */ e(
|
|
161
|
+
I,
|
|
161
162
|
{
|
|
162
|
-
tooltip:
|
|
163
|
-
icon: /* @__PURE__ */
|
|
163
|
+
tooltip: r,
|
|
164
|
+
icon: /* @__PURE__ */ e(rt, {}),
|
|
164
165
|
target: "_blank",
|
|
165
166
|
href: n,
|
|
166
167
|
style: { textDecoration: "none" },
|
|
167
|
-
children:
|
|
168
|
+
children: b("str.openInNewTab")
|
|
168
169
|
}
|
|
169
170
|
),
|
|
170
|
-
|
|
171
|
+
s === "image" ? /* @__PURE__ */ e("img", { src: n, alt: r, style: { width: "100%" } }) : s === "pdf" ? /* @__PURE__ */ h("iframe", { title: r, src: n, width: "100%", height: "700px", children: [
|
|
171
172
|
"This browser does not support PDFs. Please download the PDF to view it:",
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
] }) : /* @__PURE__ */
|
|
173
|
+
/* @__PURE__ */ e("a", { href: n, children: "Download PDF" })
|
|
174
|
+
] }) : /* @__PURE__ */ h(
|
|
174
175
|
"iframe",
|
|
175
176
|
{
|
|
176
|
-
title:
|
|
177
|
+
title: r,
|
|
177
178
|
src: `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
|
|
178
179
|
n
|
|
179
180
|
)}`,
|
|
@@ -181,13 +182,13 @@ const Ot = ({ provider: n, value: t }) => {
|
|
|
181
182
|
height: "700px",
|
|
182
183
|
children: [
|
|
183
184
|
"This browser does not support open ",
|
|
184
|
-
|
|
185
|
+
s.toUpperCase(),
|
|
185
186
|
". Please download the",
|
|
186
|
-
|
|
187
|
+
s.toUpperCase(),
|
|
187
188
|
" to view it:",
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ h("a", { href: n, children: [
|
|
189
190
|
"Download ",
|
|
190
|
-
|
|
191
|
+
s.toUpperCase()
|
|
191
192
|
] }),
|
|
192
193
|
"."
|
|
193
194
|
]
|
|
@@ -196,20 +197,20 @@ const Ot = ({ provider: n, value: t }) => {
|
|
|
196
197
|
] })
|
|
197
198
|
}
|
|
198
199
|
),
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
|
|
200
|
+
/* @__PURE__ */ e(
|
|
201
|
+
I,
|
|
201
202
|
{
|
|
202
|
-
tooltip:
|
|
203
|
-
icon:
|
|
203
|
+
tooltip: r,
|
|
204
|
+
icon: i,
|
|
204
205
|
shape: "circle",
|
|
205
|
-
onClick: () =>
|
|
206
|
+
onClick: () => u(!0)
|
|
206
207
|
}
|
|
207
208
|
)
|
|
208
|
-
] }) : /* @__PURE__ */
|
|
209
|
-
|
|
209
|
+
] }) : /* @__PURE__ */ e(
|
|
210
|
+
I,
|
|
210
211
|
{
|
|
211
|
-
tooltip:
|
|
212
|
-
icon:
|
|
212
|
+
tooltip: r,
|
|
213
|
+
icon: i,
|
|
213
214
|
target: "_blank",
|
|
214
215
|
href: n,
|
|
215
216
|
shape: "circle"
|
|
@@ -217,7 +218,7 @@ const Ot = ({ provider: n, value: t }) => {
|
|
|
217
218
|
);
|
|
218
219
|
};
|
|
219
220
|
export {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
ft as FileCellValue,
|
|
222
|
+
Vt as FileCrudCellValue,
|
|
223
|
+
pt as default
|
|
223
224
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var G=Object.defineProperty;var J=(s,e,t)=>e in s?G(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var A=(s,e,t)=>J(s,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),K=require("@ant-design/icons"),F=require("antd"),b=require("path-browserify"),h=require("react"),L=require("../util/NumberUtil.cjs.js"),Q=require("../util/ValidationUtil.cjs.js"),X=require("uuid"),Y=require("../common/picker/ImagePicker.cjs.js"),Z=require("../util/ImageUtil.cjs.js");class ${}class p extends ${constructor(t="",l=""){super();A(this,"rootPath");A(this,"subPath");this.rootPath=t,this.subPath=l}cloneFilePath(t){const l=b.parse(t),r=`${l.name}_cloned_${L.default.randInt(1e5)}`;return b.format({dir:l.dir,ext:l.ext,name:r})}generateFileName(t){return`${t.split(".")[0]}_${X.v4().replace("-","")}`}}function R({formLayoutProps:s,name:e,label:t,required:l,provider:r,onUploading:i,aspectRatio:O,onRemoved:m,onUploadComplete:g,fieldClassName:x,hideLabel:S=!1,listType:_,fieldHelper:B,showSkipCropButton:M=!1,skipCrop:z=!1,skipResize:D=!1,asyncUpload:E=!1,maxCount:d=1},H){const o=F.Form.useFormInstance(),f=e,y=F.Form.useWatch(f,o),T=h.useCallback(a=>r.getRealUrl(a),[r]),P=h.useCallback(async(a,I)=>{if(I){i==null||i(!0);try{const u=a.name,c=u.split("."),N=c[c.length-1],V=r.generateFileName(u),q=`${await r.getInitialPath()}/${V}.${N}`,w=await r.upload(a,q);g==null||g(w);const j=o.getFieldValue(f);if(d>1){const C=Array.isArray(j)?j:j?[j]:[];o.setFieldValue(f,[...C,w].filter(Boolean))}else o.setFieldValue(f,w);return w}finally{i==null||i(!1)}}else{const u=o.getFieldValue(f);if(d>1){const c=a.response??(typeof a.uid=="string"?a.uid:void 0);if(!c)return;await r.delete(c),m==null||m();const V=(Array.isArray(u)?u:u?[u]:[]).filter(q=>q!==c);o.setFieldValue(f,V.length?V:null)}else{const c=await r.delete(u);m==null||m(),c&&o.setFieldValue(f,null)}}},[o,d,f,m,g,i,r]);h.useImperativeHandle(H,()=>({async uploadBlob(a,I){const u=await Z.getBase64(a),c={name:I,uid:I+Math.random().toString(36).substring(2,15),url:u,originFileObj:a};await P(c,!0)}}),[P]);const W=h.useMemo(()=>y?(Array.isArray(y),y):d>1?[]:void 0,[y,d]);return n.jsxs(F.Form.Item,{rules:l?Q.required(t):[],label:S?null:t,required:l,name:f,help:B,...s,className:x,children:[n.jsx(Y.default,{noStyle:!0,asyncUpload:E,listType:_,aspectRatio:O,values:W,getRealUrl:T,onRemove:a=>{a&&P(a,!1)},onAdd:async a=>{if(a)return P(a,!0)},className:x,showSkipCropButton:M,skipCrop:z,skipResize:D,maxCount:d}),n.jsx(F.Input,{hidden:!0})]})}const U=h.forwardRef(R),v=({provider:s,value:e})=>{const[t,l]=h.useState([]);return h.useEffect(()=>{if(!e){l([]);return}const r=Array.isArray(e)?e:[e];Promise.all(r.filter(Boolean).map(i=>s.getRealUrl(i))).then(l)},[s,e]),t.length?n.jsx(n.Fragment,{children:t.map(r=>n.jsx(k,{url:r},r))}):n.jsx(n.Fragment,{})},k=({url:s})=>n.jsx(F.Avatar,{className:"p-0",children:n.jsx(F.Image,{className:"m-0 p-0 position-relative",src:s,preview:{mask:n.jsx(K.EyeOutlined,{})}})});exports.FileDownloadProvider=$;exports.FileUploadProvider=p;exports.ImageCellValue=k;exports.ImageCrudCellValue=v;exports.default=U;
|
|
@@ -6,6 +6,7 @@ export interface _ImageCrudField<T> extends InitialCrudField<T> {
|
|
|
6
6
|
provider: FileUploadProvider;
|
|
7
7
|
onUploading?: (isUploading: boolean) => void;
|
|
8
8
|
onRemoved?: () => void;
|
|
9
|
+
onUploadComplete?: (finalPath: string) => void;
|
|
9
10
|
aspectRatio?: number;
|
|
10
11
|
fieldClassName?: string;
|
|
11
12
|
listType?: UploadListType;
|