@kingteza/crud-component 1.0.39 → 1.0.42
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/common/button/Button.cjs.js +1 -1
- package/common/button/Button.es.js +19 -20
- package/common/button/CloneButtonTable.cjs.js +1 -1
- package/common/button/CloneButtonTable.es.js +9 -10
- package/common/button/DeleteButtonTable.cjs.js +1 -1
- package/common/button/DeleteButtonTable.es.js +29 -33
- package/common/button/ExportButton.cjs.js +1 -1
- package/common/button/ExportButton.es.js +10 -11
- package/common/button/HideButtonTable.cjs.js +1 -1
- package/common/button/HideButtonTable.es.js +22 -23
- package/common/button/ImportButton.cjs.js +1 -1
- package/common/button/ImportButton.es.js +19 -20
- package/common/button/NewButton.cjs.js +1 -1
- package/common/button/NewButton.es.js +13 -14
- package/common/button/PrintButton.cjs.js +1 -1
- package/common/button/PrintButton.es.js +11 -12
- package/common/button/RefreshButton.cjs.js +1 -1
- package/common/button/RefreshButton.es.js +10 -11
- package/common/button/UnHideButton.cjs.js +1 -1
- package/common/button/UnHideButton.es.js +37 -38
- package/common/button/UpdateButtonTable.cjs.js +1 -1
- package/common/button/UpdateButtonTable.es.js +8 -9
- package/common/button/ViewButtonTable.cjs.js +1 -1
- package/common/button/ViewButtonTable.es.js +10 -11
- package/common/date-picker/DatePicker.cjs.js +1 -1
- package/common/date-picker/DatePicker.es.js +40 -41
- package/common/date-picker/TimePicker.cjs.js +1 -1
- package/common/date-picker/TimePicker.es.js +47 -48
- package/common/loading/LoadingIndicator.cjs.js +1 -1
- package/common/loading/LoadingIndicator.es.js +6 -7
- package/common/picker/ImagePicker.cjs.js +1 -1
- package/common/picker/ImagePicker.es.js +80 -81
- package/common/select/SelectComponent.cjs.js +1 -1
- package/common/select/SelectComponent.es.js +33 -34
- package/common/tag/StatusTag.cjs.js +1 -1
- package/common/tag/StatusTag.es.js +12 -13
- package/common/text-field/NumberField.cjs.js +1 -1
- package/common/text-field/NumberField.es.js +41 -42
- package/common/text-field/TextArea.cjs.js +1 -1
- package/common/text-field/TextArea.es.js +15 -16
- package/common/text-field/TextField.cjs.js +1 -1
- package/common/text-field/TextField.es.js +50 -51
- package/common/wizard/WizardResult.cjs.js +1 -1
- package/common/wizard/WizardResult.es.js +36 -38
- package/crud/CrudComponent.cjs.js +1 -1
- package/crud/CrudComponent.es.js +77 -78
- package/crud/CrudField.cjs.js +1 -1
- package/crud/CrudField.es.js +126 -127
- package/crud/CrudFormWizard.cjs.js +1 -1
- package/crud/CrudFormWizard.es.js +47 -48
- package/crud/FileCrudField.cjs.js +1 -1
- package/crud/FileCrudField.es.js +72 -73
- package/crud/import/CrudImportButton.cjs.js +1 -1
- package/crud/import/CrudImportButton.es.js +10 -11
- package/crud/import/CrudImportComponent.cjs.js +2 -2
- package/crud/import/CrudImportComponent.es.js +56 -57
- package/crud/view/CrudDecListView.cjs.js +1 -1
- package/crud/view/CrudDecListView.es.js +11 -12
- package/crud/view/CrudViewer.cjs.js +1 -1
- package/crud/view/CrudViewer.es.js +120 -121
- package/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/crud/view/CrudViewerUtil.es.js +15 -17
- package/locale/index.cjs.js +1 -1
- package/locale/index.d.ts +8 -4
- package/locale/index.es.js +36 -24
- package/package.json +1 -1
- package/util/ValidationUtil.cjs.js +1 -1
- package/util/ValidationUtil.es.js +26 -23
|
@@ -1,93 +1,92 @@
|
|
|
1
|
-
import { jsx as t, Fragment as
|
|
2
|
-
import { LeftOutlined as
|
|
3
|
-
import { Form as k, Divider as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
function H({
|
|
1
|
+
import { jsx as t, Fragment as v, jsxs as F } from "react/jsx-runtime";
|
|
2
|
+
import { LeftOutlined as w, SaveOutlined as x, RightOutlined as T } from "@ant-design/icons";
|
|
3
|
+
import { Form as k, Divider as W, Row as j, Col as y } from "antd";
|
|
4
|
+
import { useMemo as C, useEffect as z } from "react";
|
|
5
|
+
import { useTranslationLib as B } from "../locale/index.es.js";
|
|
6
|
+
import { CrudFormFields as O } from "./CrudForm.es.js";
|
|
7
|
+
import E from "../common/wizard/WizardViewForm.es.js";
|
|
8
|
+
import S from "../common/button/Button.es.js";
|
|
9
|
+
function I({
|
|
11
10
|
fields: d,
|
|
12
11
|
className: f,
|
|
13
12
|
onDeleteFile: u,
|
|
14
13
|
onUploadFile: l,
|
|
15
14
|
purpose: m,
|
|
16
|
-
wizard:
|
|
15
|
+
wizard: r = [],
|
|
17
16
|
updatingValue: s,
|
|
18
17
|
onSave: h,
|
|
19
18
|
submitting: g
|
|
20
19
|
}) {
|
|
21
|
-
const a =
|
|
22
|
-
let
|
|
20
|
+
const a = C(() => r.map((o) => {
|
|
21
|
+
let e = !0;
|
|
23
22
|
const n = d.filter(
|
|
24
23
|
(i) => o.fields.includes(i.name)
|
|
25
24
|
);
|
|
26
|
-
return n.forEach((i) =>
|
|
25
|
+
return n.forEach((i) => e && (e = i.hidden ?? !1)), {
|
|
27
26
|
...o,
|
|
28
|
-
hidden:
|
|
27
|
+
hidden: e,
|
|
29
28
|
fieldThatShouldShowing: n
|
|
30
29
|
};
|
|
31
|
-
}), [d,
|
|
30
|
+
}), [d, r]), c = C(
|
|
32
31
|
() => a.filter((o) => !o.hidden),
|
|
33
32
|
[a]
|
|
34
33
|
);
|
|
35
|
-
return /* @__PURE__ */ t(
|
|
36
|
-
|
|
34
|
+
return /* @__PURE__ */ t(v, { children: /* @__PURE__ */ t(
|
|
35
|
+
E,
|
|
37
36
|
{
|
|
38
|
-
onSubmit: (o,
|
|
39
|
-
console.log(
|
|
37
|
+
onSubmit: (o, e) => {
|
|
38
|
+
console.log(e), h(e);
|
|
40
39
|
},
|
|
41
40
|
className: f,
|
|
42
41
|
pages: c.map(
|
|
43
|
-
({ title: o, icon:
|
|
42
|
+
({ title: o, icon: e, fieldThatShouldShowing: n, hidden: i }, b) => ({
|
|
44
43
|
title: o,
|
|
45
|
-
icon:
|
|
44
|
+
icon: e,
|
|
46
45
|
hidden: i,
|
|
47
|
-
component: (
|
|
48
|
-
|
|
46
|
+
component: (p) => /* @__PURE__ */ t(
|
|
47
|
+
L,
|
|
49
48
|
{
|
|
50
49
|
fields: n,
|
|
51
50
|
onDeleteFile: u,
|
|
52
51
|
onUploadFile: l,
|
|
53
52
|
purpose: m,
|
|
54
|
-
i:
|
|
53
|
+
i: b,
|
|
55
54
|
updatingValue: s,
|
|
56
|
-
backward:
|
|
57
|
-
forward:
|
|
55
|
+
backward: p.backward,
|
|
56
|
+
forward: p.forward,
|
|
58
57
|
wizard: c,
|
|
59
58
|
submitting: g
|
|
60
59
|
},
|
|
61
|
-
|
|
60
|
+
b
|
|
62
61
|
)
|
|
63
62
|
})
|
|
64
63
|
)
|
|
65
64
|
}
|
|
66
65
|
) });
|
|
67
66
|
}
|
|
68
|
-
function
|
|
67
|
+
function L({
|
|
69
68
|
fields: d,
|
|
70
69
|
onDeleteFile: f,
|
|
71
70
|
onUploadFile: u,
|
|
72
71
|
purpose: l,
|
|
73
72
|
wizard: m = [],
|
|
74
|
-
i:
|
|
73
|
+
i: r,
|
|
75
74
|
forward: s,
|
|
76
75
|
backward: h,
|
|
77
76
|
submitting: g,
|
|
78
77
|
updatingValue: a
|
|
79
78
|
}) {
|
|
80
|
-
const c = m[
|
|
81
|
-
return
|
|
79
|
+
const c = m[r], { t: o } = B(), [e] = k.useForm();
|
|
80
|
+
return z(() => {
|
|
82
81
|
if (a && (l === "update" || l === "clone")) {
|
|
83
82
|
const n = {};
|
|
84
83
|
for (const i of d)
|
|
85
84
|
n[i.name] = a[i.name];
|
|
86
|
-
|
|
85
|
+
e.setFieldsValue(n);
|
|
87
86
|
}
|
|
88
|
-
}, [d,
|
|
87
|
+
}, [d, e, l, a]), /* @__PURE__ */ F(k, { name: String(r), form: e, layout: "vertical", children: [
|
|
89
88
|
/* @__PURE__ */ t(
|
|
90
|
-
|
|
89
|
+
O,
|
|
91
90
|
{
|
|
92
91
|
fields: d,
|
|
93
92
|
formBuilder: c.formBuilder,
|
|
@@ -97,13 +96,13 @@ function N({
|
|
|
97
96
|
purpose: l
|
|
98
97
|
}
|
|
99
98
|
),
|
|
100
|
-
/* @__PURE__ */ t(
|
|
101
|
-
/* @__PURE__ */ F(
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
/* @__PURE__ */ t(W, {}),
|
|
100
|
+
/* @__PURE__ */ F(j, { gutter: [8, 8], children: [
|
|
101
|
+
r > 0 && /* @__PURE__ */ t(y, { md: 12, children: /* @__PURE__ */ t(
|
|
102
|
+
S,
|
|
104
103
|
{
|
|
105
104
|
block: !0,
|
|
106
|
-
icon: /* @__PURE__ */ t(
|
|
105
|
+
icon: /* @__PURE__ */ t(w, {}),
|
|
107
106
|
htmlType: "button",
|
|
108
107
|
type: "default",
|
|
109
108
|
size: "large",
|
|
@@ -111,30 +110,30 @@ function N({
|
|
|
111
110
|
children: o("str.back")
|
|
112
111
|
}
|
|
113
112
|
) }),
|
|
114
|
-
/* @__PURE__ */ t(
|
|
115
|
-
|
|
113
|
+
/* @__PURE__ */ t(y, { md: r > 0 ? 12 : 24, children: /* @__PURE__ */ t(
|
|
114
|
+
S,
|
|
116
115
|
{
|
|
117
116
|
block: !0,
|
|
118
|
-
icon: m.length - 1 ===
|
|
117
|
+
icon: m.length - 1 === r ? /* @__PURE__ */ t(x, {}) : /* @__PURE__ */ t(T, {}),
|
|
119
118
|
htmlType: "submit",
|
|
120
119
|
type: "primary",
|
|
121
120
|
loading: g,
|
|
122
121
|
size: "large",
|
|
123
122
|
onClick: () => {
|
|
124
|
-
|
|
123
|
+
e.validateFields().then((n) => {
|
|
125
124
|
s(
|
|
126
125
|
n,
|
|
127
|
-
m.length - 1 ===
|
|
128
|
-
m.length - 1 ===
|
|
126
|
+
m.length - 1 === r,
|
|
127
|
+
m.length - 1 === r
|
|
129
128
|
);
|
|
130
129
|
});
|
|
131
130
|
},
|
|
132
|
-
children: m.length - 1 ===
|
|
131
|
+
children: m.length - 1 === r ? o("str." + (l === "update" ? "update" : "save")) : o("str.next")
|
|
133
132
|
}
|
|
134
133
|
) })
|
|
135
134
|
] })
|
|
136
135
|
] });
|
|
137
136
|
}
|
|
138
137
|
export {
|
|
139
|
-
|
|
138
|
+
I as default
|
|
140
139
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime");;/* empty css */const d=require("@ant-design/icons"),F=require("antd"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime");;/* empty css */const d=require("@ant-design/icons"),F=require("antd"),k=require("mime"),c=require("react"),B=require("../locale/index.cjs.js"),H=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),z=require("../common/layout/VerticalSpace.cjs.js");function G({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:U,maxCount:O=1,block:_,...$}){const f=F.Form.useFormInstance(),x=F.Form.useWatch(n,f),[b,q]=c.useState(!1),[V,N]=c.useState(!1),A=c.useCallback(async r=>{var i,u;try{const{file:o}=r,g=o.name;q(!0),N(!0),a==null||a(!0);const C=g??"",I=C.split("."),R=I[I.length-1],W=s.generateFileName(C),M=`${await s.getInitialPath()}/${W}.${R}`;console.log({filePath:M});const D=await s.upload({...o,originFileObj:o},M);a==null||a(!1),f.setFieldValue(n,D),(i=r.onSuccess)==null||i.call(r,D)}catch(o){(u=r.onError)==null||u.call(r,o)}finally{q(!1)}},[f,n,a,s]),[w,S]=c.useState([]);c.useEffect(()=>{!V&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const i=k.getType(r),u=r.split("/").pop(),o=await s.getRealUrl(r);return{uid:r,url:o,type:i,name:u}})).then(r=>S(()=>{const i=r.map(({url:u,type:o,uid:g,name:C})=>({uid:g,url:u,type:o,response:g,thumbUrl:u,name:C}));return console.log(i),i}))},[x,V,b,s]);const L=c.useCallback(async r=>{const i=r.response,u=i||f.getFieldValue(n);await s.delete(u),h==null||h(),r&&f.setFieldsValue({[n]:null})},[f,n,h,s]);return t.jsxs(F.Form.Item,{label:e,required:l,name:n,className:j,rules:[...l?H.required(e):[],...U??[]],children:[t.jsx("input",{hidden:!0}),t.jsx(F.Upload,{...$,fileList:w,className:((w==null?void 0:w.length)??0)>=O?"hide-upload":"",maxCount:O,customRequest:A,onRemove:L,listType:"picture",onChange:({fileList:r})=>{S(r)},style:_?{width:"100%"}:void 0,children:t.jsx(p,{loading:b,children:"Upload File"})})]})}const J=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:k.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(E,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},E=({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(d.FileImageOutlined,{});case"pdf":return t.jsx(d.FilePdfOutlined,{});case"word":return t.jsx(d.FileWordOutlined,{});case"text":return t.jsx(d.FileTextOutlined,{});case"excel":return t.jsx(d.FileExcelOutlined,{});case"presentation":return t.jsx(d.FilePptOutlined,{});default:return t.jsx(d.FileOutlined,{})}},[s]),[h,j]=c.useState(!1),{t:P}=B.useTranslationLib();return s!=="file"&&s!=="text"?t.jsxs(t.Fragment,{children:[t.jsx(F.Modal,{open:h,title:l,onCancel:()=>j(!1),footer:t.jsx(t.Fragment,{}),width:"100%",style:{top:"8px",minHeight:"700px"},destroyOnClose:!0,children:t.jsxs(z,{children:[t.jsx(p,{tooltip:l,icon:t.jsx(d.ExportOutlined,{}),target:"_blank",href:n,style:{textDecoration:"none"},children:P("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(p,{tooltip:l,icon:a,shape:"circle",onClick:()=>j(!0)})]}):t.jsx(p,{tooltip:l,icon:a,target:"_blank",href:n,shape:"circle"})};exports.FileCellValue=E;exports.FileCrudCellValue=J;exports.default=G;
|
package/crud/FileCrudField.es.js
CHANGED
|
@@ -1,71 +1,70 @@
|
|
|
1
1
|
import { jsxs as f, jsx as s, Fragment as O } from "react/jsx-runtime";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { FileOutlined as
|
|
3
|
+
import { FileOutlined as J, FilePptOutlined as K, FileExcelOutlined as Q, FileTextOutlined as R, FileWordOutlined as X, FilePdfOutlined as Y, FileImageOutlined as Z, ExportOutlined as v } from "@ant-design/icons";
|
|
4
4
|
import { Form as P, Upload as y, Modal as m } from "antd";
|
|
5
|
-
import
|
|
6
|
-
import { useState as p, useCallback as
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import et from "../util/ValidationUtil.es.js";
|
|
5
|
+
import S from "mime";
|
|
6
|
+
import { useState as p, useCallback as j, useEffect as A, useMemo as N } from "react";
|
|
7
|
+
import { useTranslationLib as T } from "../locale/index.es.js";
|
|
8
|
+
import tt from "../util/ValidationUtil.es.js";
|
|
10
9
|
import C from "../common/button/Button.es.js";
|
|
11
|
-
import
|
|
12
|
-
function
|
|
10
|
+
import et from "../common/layout/VerticalSpace.es.js";
|
|
11
|
+
function ht({
|
|
13
12
|
name: n,
|
|
14
13
|
label: t,
|
|
15
|
-
required:
|
|
14
|
+
required: l,
|
|
16
15
|
provider: e,
|
|
17
16
|
onUploading: a,
|
|
18
17
|
onRemoved: u,
|
|
19
18
|
fieldClassName: w,
|
|
20
|
-
accept:
|
|
21
|
-
rules:
|
|
22
|
-
maxCount:
|
|
23
|
-
block:
|
|
24
|
-
...
|
|
19
|
+
accept: b,
|
|
20
|
+
rules: L,
|
|
21
|
+
maxCount: I = 1,
|
|
22
|
+
block: W,
|
|
23
|
+
..._
|
|
25
24
|
}) {
|
|
26
|
-
const d = P.useFormInstance(), h = P.useWatch(n, d), [
|
|
27
|
-
async (
|
|
25
|
+
const d = P.useFormInstance(), h = P.useWatch(n, d), [V, D] = p(!1), [U, q] = p(!1), B = j(
|
|
26
|
+
async (r) => {
|
|
28
27
|
var c, o;
|
|
29
28
|
try {
|
|
30
|
-
const { file: i } =
|
|
31
|
-
|
|
32
|
-
const g = x ?? "",
|
|
29
|
+
const { file: i } = r, x = i.name;
|
|
30
|
+
D(!0), q(!0), a == null || a(!0);
|
|
31
|
+
const g = x ?? "", E = g.split("."), z = E[E.length - 1], G = e.generateFileName(g), M = `${await e.getInitialPath()}/${G}.${z}`;
|
|
33
32
|
console.log({ filePath: M });
|
|
34
|
-
const
|
|
33
|
+
const $ = await e.upload(
|
|
35
34
|
{ ...i, originFileObj: i },
|
|
36
35
|
M
|
|
37
36
|
);
|
|
38
|
-
a == null || a(!1), d.setFieldValue(n,
|
|
37
|
+
a == null || a(!1), d.setFieldValue(n, $), (c = r.onSuccess) == null || c.call(r, $);
|
|
39
38
|
} catch (i) {
|
|
40
|
-
(o =
|
|
39
|
+
(o = r.onError) == null || o.call(r, i);
|
|
41
40
|
} finally {
|
|
42
|
-
|
|
41
|
+
D(!1);
|
|
43
42
|
}
|
|
44
43
|
},
|
|
45
44
|
[d, n, a, e]
|
|
46
|
-
), [F,
|
|
47
|
-
|
|
48
|
-
!
|
|
45
|
+
), [F, k] = p([]);
|
|
46
|
+
A(() => {
|
|
47
|
+
!U && h && Promise.all(
|
|
49
48
|
(Array.isArray(h) ? h : [h]).map(
|
|
50
|
-
async (
|
|
51
|
-
const c =
|
|
49
|
+
async (r) => {
|
|
50
|
+
const c = S.getType(r), o = r.split("/").pop(), i = await e.getRealUrl(r);
|
|
52
51
|
return {
|
|
53
|
-
uid:
|
|
52
|
+
uid: r,
|
|
54
53
|
url: i,
|
|
55
54
|
type: c,
|
|
56
55
|
name: o
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
58
|
)
|
|
60
|
-
).then((
|
|
61
|
-
const c =
|
|
59
|
+
).then((r) => k(() => {
|
|
60
|
+
const c = r.map(({ url: o, type: i, uid: x, name: g }) => ({ uid: x, url: o, type: i, response: x, thumbUrl: o, name: g }));
|
|
62
61
|
return console.log(c), c;
|
|
63
62
|
}));
|
|
64
|
-
}, [h,
|
|
65
|
-
const H =
|
|
66
|
-
async (
|
|
67
|
-
const c =
|
|
68
|
-
await e.delete(o), u == null || u(),
|
|
63
|
+
}, [h, U, V, e]);
|
|
64
|
+
const H = j(
|
|
65
|
+
async (r) => {
|
|
66
|
+
const c = r.response, o = c || d.getFieldValue(n);
|
|
67
|
+
await e.delete(o), u == null || u(), r && d.setFieldsValue({ [n]: null });
|
|
69
68
|
},
|
|
70
69
|
[d, n, u, e]
|
|
71
70
|
);
|
|
@@ -73,56 +72,56 @@ function wt({
|
|
|
73
72
|
P.Item,
|
|
74
73
|
{
|
|
75
74
|
label: t,
|
|
76
|
-
required:
|
|
75
|
+
required: l,
|
|
77
76
|
name: n,
|
|
78
77
|
className: w,
|
|
79
78
|
rules: [
|
|
80
|
-
...
|
|
81
|
-
...
|
|
79
|
+
...l ? tt.required(t) : [],
|
|
80
|
+
...L ?? []
|
|
82
81
|
],
|
|
83
82
|
children: [
|
|
84
83
|
/* @__PURE__ */ s("input", { hidden: !0 }),
|
|
85
84
|
/* @__PURE__ */ s(
|
|
86
85
|
y,
|
|
87
86
|
{
|
|
88
|
-
...
|
|
87
|
+
..._,
|
|
89
88
|
fileList: F,
|
|
90
|
-
className: ((F == null ? void 0 : F.length) ?? 0) >=
|
|
91
|
-
maxCount:
|
|
89
|
+
className: ((F == null ? void 0 : F.length) ?? 0) >= I ? "hide-upload" : "",
|
|
90
|
+
maxCount: I,
|
|
92
91
|
customRequest: B,
|
|
93
92
|
onRemove: H,
|
|
94
93
|
listType: "picture",
|
|
95
|
-
onChange: ({ fileList:
|
|
96
|
-
|
|
94
|
+
onChange: ({ fileList: r }) => {
|
|
95
|
+
k(r);
|
|
97
96
|
},
|
|
98
|
-
style:
|
|
99
|
-
children: /* @__PURE__ */ s(C, { loading:
|
|
97
|
+
style: W ? { width: "100%" } : void 0,
|
|
98
|
+
children: /* @__PURE__ */ s(C, { loading: V, children: "Upload File" })
|
|
100
99
|
}
|
|
101
100
|
)
|
|
102
101
|
]
|
|
103
102
|
}
|
|
104
103
|
);
|
|
105
104
|
}
|
|
106
|
-
const
|
|
107
|
-
const [
|
|
108
|
-
return
|
|
105
|
+
const pt = ({ provider: n, value: t }) => {
|
|
106
|
+
const [l, e] = p();
|
|
107
|
+
return A(() => {
|
|
109
108
|
t && n.getRealUrl(t).then((a) => {
|
|
110
109
|
e({
|
|
111
|
-
mimeType:
|
|
110
|
+
mimeType: S.getType(t),
|
|
112
111
|
url: a,
|
|
113
112
|
fileName: t.split("/").pop() ?? t
|
|
114
113
|
});
|
|
115
114
|
});
|
|
116
|
-
}, [n, t]),
|
|
117
|
-
|
|
115
|
+
}, [n, t]), l ? /* @__PURE__ */ s(
|
|
116
|
+
st,
|
|
118
117
|
{
|
|
119
|
-
fileName:
|
|
120
|
-
url:
|
|
121
|
-
mimeType:
|
|
118
|
+
fileName: l.fileName,
|
|
119
|
+
url: l == null ? void 0 : l.url,
|
|
120
|
+
mimeType: l == null ? void 0 : l.mimeType
|
|
122
121
|
}
|
|
123
122
|
) : /* @__PURE__ */ s(O, {});
|
|
124
|
-
},
|
|
125
|
-
const e =
|
|
123
|
+
}, st = ({ url: n, mimeType: t = "", fileName: l }) => {
|
|
124
|
+
const e = N(() => 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]), a = N(() => {
|
|
126
125
|
switch (e) {
|
|
127
126
|
case "image":
|
|
128
127
|
return /* @__PURE__ */ s(Z, {});
|
|
@@ -131,46 +130,46 @@ const Ft = ({ provider: n, value: t }) => {
|
|
|
131
130
|
case "word":
|
|
132
131
|
return /* @__PURE__ */ s(X, {});
|
|
133
132
|
case "text":
|
|
134
|
-
return /* @__PURE__ */ s(
|
|
133
|
+
return /* @__PURE__ */ s(R, {});
|
|
135
134
|
case "excel":
|
|
136
|
-
return /* @__PURE__ */ s(
|
|
135
|
+
return /* @__PURE__ */ s(Q, {});
|
|
137
136
|
case "presentation":
|
|
138
|
-
return /* @__PURE__ */ s(
|
|
137
|
+
return /* @__PURE__ */ s(K, {});
|
|
139
138
|
default:
|
|
140
|
-
return /* @__PURE__ */ s(
|
|
139
|
+
return /* @__PURE__ */ s(J, {});
|
|
141
140
|
}
|
|
142
|
-
}, [e]), [u, w] = p(!1), { t:
|
|
141
|
+
}, [e]), [u, w] = p(!1), { t: b } = T();
|
|
143
142
|
return e !== "file" && e !== "text" ? /* @__PURE__ */ f(O, { children: [
|
|
144
143
|
/* @__PURE__ */ s(
|
|
145
144
|
m,
|
|
146
145
|
{
|
|
147
146
|
open: u,
|
|
148
|
-
title:
|
|
147
|
+
title: l,
|
|
149
148
|
onCancel: () => w(!1),
|
|
150
149
|
footer: /* @__PURE__ */ s(O, {}),
|
|
151
150
|
width: "100%",
|
|
152
151
|
style: { top: "8px", minHeight: "700px" },
|
|
153
152
|
destroyOnClose: !0,
|
|
154
|
-
children: /* @__PURE__ */ f(
|
|
153
|
+
children: /* @__PURE__ */ f(et, { children: [
|
|
155
154
|
/* @__PURE__ */ s(
|
|
156
155
|
C,
|
|
157
156
|
{
|
|
158
|
-
tooltip:
|
|
157
|
+
tooltip: l,
|
|
159
158
|
icon: /* @__PURE__ */ s(v, {}),
|
|
160
159
|
target: "_blank",
|
|
161
160
|
href: n,
|
|
162
161
|
style: { textDecoration: "none" },
|
|
163
|
-
children:
|
|
162
|
+
children: b("str.openInNewTab")
|
|
164
163
|
}
|
|
165
164
|
),
|
|
166
|
-
e === "image" ? /* @__PURE__ */ s("img", { src: n, alt:
|
|
165
|
+
e === "image" ? /* @__PURE__ */ s("img", { src: n, alt: l, style: { width: "100%" } }) : e === "pdf" ? /* @__PURE__ */ f("iframe", { title: l, src: n, width: "100%", height: "700px", children: [
|
|
167
166
|
"This browser does not support PDFs. Please download the PDF to view it:",
|
|
168
167
|
/* @__PURE__ */ s("a", { href: n, children: "Download PDF" }),
|
|
169
168
|
"."
|
|
170
169
|
] }) : /* @__PURE__ */ f(
|
|
171
170
|
"iframe",
|
|
172
171
|
{
|
|
173
|
-
title:
|
|
172
|
+
title: l,
|
|
174
173
|
src: `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
|
|
175
174
|
n
|
|
176
175
|
)}`,
|
|
@@ -196,7 +195,7 @@ const Ft = ({ provider: n, value: t }) => {
|
|
|
196
195
|
/* @__PURE__ */ s(
|
|
197
196
|
C,
|
|
198
197
|
{
|
|
199
|
-
tooltip:
|
|
198
|
+
tooltip: l,
|
|
200
199
|
icon: a,
|
|
201
200
|
shape: "circle",
|
|
202
201
|
onClick: () => w(!0)
|
|
@@ -205,7 +204,7 @@ const Ft = ({ provider: n, value: t }) => {
|
|
|
205
204
|
] }) : /* @__PURE__ */ s(
|
|
206
205
|
C,
|
|
207
206
|
{
|
|
208
|
-
tooltip:
|
|
207
|
+
tooltip: l,
|
|
209
208
|
icon: a,
|
|
210
209
|
target: "_blank",
|
|
211
210
|
href: n,
|
|
@@ -214,7 +213,7 @@ const Ft = ({ provider: n, value: t }) => {
|
|
|
214
213
|
);
|
|
215
214
|
};
|
|
216
215
|
export {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
st as FileCellValue,
|
|
217
|
+
pt as FileCrudCellValue,
|
|
218
|
+
ht as default
|
|
220
219
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),s=require("@ant-design/icons"),i=require("react"),u=require("
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),s=require("@ant-design/icons"),i=require("react"),u=require("../../locale/index.cjs.js"),c=require("./CrudImportComponent.cjs.js"),p=require("../../common/button/Button.cjs.js");function m(n){const{t:r}=u.useTranslationLib(),[o,e]=i.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx(c,{open:o,onCloseMethod:e,...n}),t.jsx(p,{icon:t.jsx(s.ImportOutlined,{}),onClick:()=>e(!0),children:r("str.import")})]})}module.exports=m;
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { jsxs as e, Fragment as p, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { ImportOutlined as i } from "@ant-design/icons";
|
|
3
3
|
import { useState as s } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import l from "
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { t: m } = u(f), [n, t] = s(!1);
|
|
4
|
+
import { useTranslationLib as u } from "../../locale/index.es.js";
|
|
5
|
+
import f from "./CrudImportComponent.es.js";
|
|
6
|
+
import l from "../../common/button/Button.es.js";
|
|
7
|
+
function x(r) {
|
|
8
|
+
const { t: n } = u(), [m, t] = s(!1);
|
|
10
9
|
return /* @__PURE__ */ e(p, { children: [
|
|
11
10
|
/* @__PURE__ */ o(
|
|
12
|
-
|
|
11
|
+
f,
|
|
13
12
|
{
|
|
14
|
-
open:
|
|
13
|
+
open: m,
|
|
15
14
|
onCloseMethod: t,
|
|
16
15
|
...r
|
|
17
16
|
}
|
|
18
17
|
),
|
|
19
18
|
/* @__PURE__ */ o(
|
|
20
|
-
|
|
19
|
+
l,
|
|
21
20
|
{
|
|
22
21
|
icon: /* @__PURE__ */ o(i, {}),
|
|
23
22
|
onClick: () => t(!0),
|
|
24
|
-
children:
|
|
23
|
+
children: n("str.import")
|
|
25
24
|
}
|
|
26
25
|
)
|
|
27
26
|
] });
|
|
28
27
|
}
|
|
29
28
|
export {
|
|
30
|
-
|
|
29
|
+
x as default
|
|
31
30
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),q=require("@ant-design/icons"),
|
|
2
|
-
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),q=require("@ant-design/icons"),V=require("papaparse"),d=require("antd"),W=require("file-saver"),a=require("react"),O=require("../../locale/index.cjs.js"),L=require("../view/CrudViewer.cjs.js"),R=require("../../util/DateUtil.cjs.js"),z=require("../../common/button/Button.cjs.js"),$=require("../../common/button/ImportButton.cjs.js");function U({onCloseMethod:w,open:y,fields:T,importProps:o}){const[u,v]=a.useState([]),[C,k]=a.useState(!1),[A,D]=a.useState(0);a.useEffect(()=>{y||(v([]),k(!1))},[y]);const p=a.useMemo(()=>new Map(T.filter(e=>{var t;return!e.hidden&&!((t=e.importProps)!=null&&t.hidden)&&!e.readonly}).map(e=>[e.name,e])),[T]),S=a.useMemo(()=>Array.from(p.values()).flatMap(e=>{var t;return[e.name,...((t=e.importProps)==null?void 0:t.extraFields)??[]]}),[p]),E=a.useCallback(async function(){const e=`${S.join(",")}
|
|
2
|
+
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});W.saveAs(t,(o==null?void 0:o.name)+" - "+R.formatDateTimeWithSecond(new Date).replaceAll(":","-")+".csv")},[S,o==null?void 0:o.name]),{t:i}=O.useTranslationLib(),B=a.useCallback(async e=>{const t=new FileReader;t.onerror=console.error,t.onload=async r=>{var s;const c=(s=r==null?void 0:r.target)==null?void 0:s.result,l=V.parse(c,{header:!0});v(l.data)},t.readAsText(e)},[]),g=a.useMemo(()=>{var t,r,c;let e=!1;for(const l of u)for(const[s,f]of p.entries()){const h=l[s],m=h||!isNaN(h);if(f.required&&!m)if((r=(t=f.importProps)==null?void 0:t.extraFields)!=null&&r.length)for(const j of((c=f.importProps)==null?void 0:c.extraFields)??[])if(l[j]||!isNaN(l[j])){e=!1;break}else return!0;else return!0}return e},[u,p]),x=a.useCallback(e=>(t,r)=>{var l,s,f;const c=t||!isNaN(t);if(e.required&&!c){let h=i("err.validation.required");if((s=(l=e.importProps)==null?void 0:l.extraFields)!=null&&s.length){const m=(f=e.importProps)==null?void 0:f.extraFields;(m==null?void 0:m.find(N=>!r[N]))&&(h="Either one of these fields is required: "+[e.name,...m].join(", "))}return n.jsxs(d.Tooltip,{className:"d-flex",title:h,children:[n.jsx(q.WarningTwoTone,{twoToneColor:"#ee9702"}),t]})}return t},[i]),F=a.useCallback(async e=>{D(e)},[]),b=a.useCallback(async()=>{try{k(!0),await o.onClickImport(u,F),w(!1)}finally{k(!1),D(0)}},[u,o,w,F]),{modal:I}=d.App.useApp(),M=a.useCallback(async()=>{g?I.warning?I.warning({title:i("str.warning"),content:i("qus.importWithIssues"),okText:i("str.import"),onOk:b,okCancel:!0,closable:!0}):(console.error("You must wrap your react app with App component. https://ant.design/components/app"),window.confirm(i("qus.importWithIssues"))&&b()):b()},[g,b,i]);return n.jsxs(d.Modal,{title:[i("str.import"),o==null?void 0:o.name].filter(Boolean).join(" "),width:"100%",open:y,onOk:M,destroyOnClose:!0,onCancel:()=>w(!1),okText:i("str.import"),confirmLoading:C,okButtonProps:{disabled:!(u!=null&&u.length)},footer:(e,{OkBtn:t,CancelBtn:r})=>n.jsxs(d.Space,{children:[n.jsx(r,{}),n.jsx(t,{}),g&&n.jsx(d.Tooltip,{className:"d-flex",title:"Some fields have issue. Please review before submit.",children:n.jsx(q.WarningTwoTone,{twoToneColor:"#ee9702"})})]}),children:[n.jsxs(d.Space,{children:[n.jsx(z,{onClick:E,icon:n.jsx(q.DownloadOutlined,{}),children:i("str.downloadCsvTemplate")}),n.jsx($.ImportButton,{disabled:C,type:"default",onClick:B,accept:".csv",children:i("str.importCsvFile")})]}),n.jsx(d.Spin,{spinning:C,indicator:A?n.jsx(d.Progress,{type:"circle",percent:A*100,size:50,format:e=>`${parseInt(e)}%`}):void 0,children:n.jsx(L,{data:u,bordered:!0,size:"small",fields:Array.from(p.values()).flatMap(e=>{var t,r,c,l;return e.type==="text"?[{...e,label:e.name,render:x(e)},...((r=(t=e.importProps)==null?void 0:t.extraFields)==null?void 0:r.map(s=>({...e,name:s,label:s,render:x(e)})))??[]]:e.type==="select"?[{...e,label:e.name,type:"text",render:x(e)},...((l=(c=e.importProps)==null?void 0:c.extraFields)==null?void 0:l.map(s=>({...e,name:s,label:s,type:"text",render:x(e)})))??[]]:[{...e,label:e.name,render:x(e)}]})})})]})}module.exports=U;
|