@kingteza/crud-component 1.0.56 → 1.0.58
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/App.d.ts +5 -0
- package/common/button/Button.cjs.js +1 -1
- package/common/button/Button.d.ts +2 -3
- package/common/button/Button.es.js +54 -61
- package/crud/CrudComponent.cjs.js +1 -1
- package/crud/CrudComponent.d.ts +5 -1
- package/crud/CrudComponent.es.js +138 -137
- package/crud/CrudField.cjs.js +1 -1
- package/crud/CrudField.es.js +160 -159
- package/crud/CrudForm.cjs.js +1 -1
- package/crud/CrudForm.es.js +57 -56
- package/crud/CrudFormWizard.cjs.js +1 -1
- package/crud/CrudFormWizard.es.js +53 -52
- package/crud/CrudSearchComponent.cjs.js +1 -1
- package/crud/CrudSearchComponent.es.js +39 -38
- package/crud/CrudTextAreaComponent.cjs.js +1 -1
- package/crud/CrudTextAreaComponent.es.js +29 -28
- package/crud/FileCrudField.cjs.js +1 -1
- package/crud/FileCrudField.es.js +70 -69
- package/crud/view/CrudDecListView.cjs.js +1 -1
- package/crud/view/CrudDecListView.es.js +29 -25
- package/crud/view/CrudViewer.cjs.js +1 -1
- package/crud/view/CrudViewer.es.js +137 -133
- package/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/crud/view/CrudViewerUtil.es.js +51 -48
- package/hooks/NavigatorHooks.cjs.js +1 -1
- package/hooks/NavigatorHooks.d.ts +1 -1
- package/hooks/NavigatorHooks.es.js +4 -3
- package/package.json +2 -2
- package/util/CrudUtil.cjs.js +1 -0
- package/util/CrudUtil.d.ts +5 -0
- package/util/CrudUtil.es.js +8 -0
package/crud/CrudForm.es.js
CHANGED
|
@@ -1,101 +1,102 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { Form as
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsx as a, Fragment as y, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
import S, { useMemo as N, createElement as p, useCallback as j } from "react";
|
|
3
|
+
import { Form as k, Col as w, Input as A, Row as H } from "antd";
|
|
4
|
+
import l from "./CrudField.es.js";
|
|
5
|
+
import C from "../util/CrudUtil.es.js";
|
|
6
|
+
function z({
|
|
7
|
+
form: d,
|
|
8
|
+
purpose: g = "new",
|
|
9
|
+
...u
|
|
9
10
|
}) {
|
|
10
|
-
return /* @__PURE__ */
|
|
11
|
+
return /* @__PURE__ */ a(k, { form: d, layout: "vertical", children: /* @__PURE__ */ a(I, { ...u, purpose: g }) });
|
|
11
12
|
}
|
|
12
13
|
function I({
|
|
13
|
-
fields:
|
|
14
|
-
formBuilder:
|
|
15
|
-
grid:
|
|
14
|
+
fields: d,
|
|
15
|
+
formBuilder: g,
|
|
16
|
+
grid: u,
|
|
16
17
|
onDeleteFile: m,
|
|
17
|
-
onUploadFile:
|
|
18
|
-
purpose:
|
|
18
|
+
onUploadFile: e,
|
|
19
|
+
purpose: c
|
|
19
20
|
}) {
|
|
20
|
-
const h =
|
|
21
|
-
() =>
|
|
21
|
+
const h = N(
|
|
22
|
+
() => d.filter((r) => !r.readonly).map((r) => {
|
|
22
23
|
const i = {
|
|
23
|
-
onUploading: r.type === "image" || r.type === "file" ? (
|
|
24
|
-
var
|
|
25
|
-
r.onUploading && ((
|
|
24
|
+
onUploading: r.type === "image" || r.type === "file" ? (t) => {
|
|
25
|
+
var n;
|
|
26
|
+
r.onUploading && ((n = r.onUploading) == null || n.call(r, t)), e == null || e(t);
|
|
26
27
|
} : void 0,
|
|
27
|
-
onDelete: r.type === "image" || r.type === "file" ? (
|
|
28
|
-
var
|
|
29
|
-
r.onUploading && ((
|
|
28
|
+
onDelete: r.type === "image" || r.type === "file" ? (t) => {
|
|
29
|
+
var n;
|
|
30
|
+
r.onUploading && ((n = r.onDelete) == null || n.call(r, t)), m == null || m(t);
|
|
30
31
|
} : void 0
|
|
31
32
|
};
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
|
|
33
|
+
return /* @__PURE__ */ a(S.Fragment, { children: r.grid && u ? /* @__PURE__ */ a(w, { ...r.grid, children: /* @__PURE__ */ p(
|
|
34
|
+
l,
|
|
34
35
|
{
|
|
35
36
|
...r,
|
|
36
37
|
...i,
|
|
37
38
|
key: typeof r.name == "string" ? r.name : String(r.name),
|
|
38
|
-
updatable:
|
|
39
|
+
updatable: c !== "update" ? !0 : r.updatable
|
|
39
40
|
}
|
|
40
|
-
) }) : /* @__PURE__ */
|
|
41
|
-
|
|
41
|
+
) }) : /* @__PURE__ */ p(
|
|
42
|
+
l,
|
|
42
43
|
{
|
|
43
44
|
...r,
|
|
44
45
|
...i,
|
|
45
46
|
key: typeof r.name == "string" ? r.name : String(r.name),
|
|
46
|
-
updatable:
|
|
47
|
+
updatable: c !== "update" ? !0 : r.updatable
|
|
47
48
|
}
|
|
48
49
|
) }, r.name);
|
|
49
50
|
}),
|
|
50
|
-
[
|
|
51
|
-
),
|
|
51
|
+
[d, u, m, e, c]
|
|
52
|
+
), R = j(
|
|
52
53
|
(r, i = {}) => {
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
if (
|
|
56
|
-
const
|
|
57
|
-
onUploading:
|
|
54
|
+
const t = d.find((n) => C.getRealName(n.name) === r);
|
|
55
|
+
if (t != null && t.hidden) return /* @__PURE__ */ a(y, {});
|
|
56
|
+
if (t) {
|
|
57
|
+
const n = {
|
|
58
|
+
onUploading: t.type === "image" || t.type === "file" ? (o) => {
|
|
58
59
|
var f;
|
|
59
|
-
|
|
60
|
+
t.onUploading && ((f = t.onUploading) == null || f.call(t, o)), e == null || e(o);
|
|
60
61
|
} : void 0,
|
|
61
|
-
onDelete:
|
|
62
|
+
onDelete: t.type === "image" || t.type === "file" ? (o) => {
|
|
62
63
|
var f;
|
|
63
|
-
|
|
64
|
+
t.onUploading && ((f = t.onDelete) == null || f.call(t, o)), m == null || m(o);
|
|
64
65
|
} : void 0
|
|
65
|
-
},
|
|
66
|
-
|
|
66
|
+
}, s = C.getRealName(t.name), b = /* @__PURE__ */ p(
|
|
67
|
+
l,
|
|
67
68
|
{
|
|
68
|
-
...n,
|
|
69
|
-
...i,
|
|
70
69
|
...t,
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
...i,
|
|
71
|
+
...n,
|
|
72
|
+
key: typeof s == "string" ? s : String(s),
|
|
73
|
+
updatable: c !== "update" ? !0 : t.updatable
|
|
73
74
|
}
|
|
74
75
|
);
|
|
75
|
-
return i.render ? i.render(
|
|
76
|
+
return i.render ? i.render(b) : b;
|
|
76
77
|
}
|
|
77
|
-
return /* @__PURE__ */
|
|
78
|
+
return /* @__PURE__ */ a(y, {});
|
|
78
79
|
},
|
|
79
|
-
[
|
|
80
|
+
[d, c]
|
|
80
81
|
);
|
|
81
|
-
return /* @__PURE__ */
|
|
82
|
-
|
|
82
|
+
return /* @__PURE__ */ a(y, { children: g ? /* @__PURE__ */ v(y, { children: [
|
|
83
|
+
g(R, {
|
|
83
84
|
isAnyFieldHidden(...r) {
|
|
84
85
|
const i = Array.isArray(r) ? r : [r];
|
|
85
|
-
return
|
|
86
|
+
return d.filter((n) => i.includes(n.name)).some((n) => n.hidden);
|
|
86
87
|
},
|
|
87
88
|
isAllFieldsHidden(...r) {
|
|
88
89
|
const i = Array.isArray(r) ? r : [r];
|
|
89
|
-
return
|
|
90
|
+
return d.filter((n) => i.includes(n.name)).every((n) => n.hidden);
|
|
90
91
|
}
|
|
91
92
|
}),
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ v(k.Item, { hidden: !0, noStyle: !0, children: [
|
|
94
|
+
/* @__PURE__ */ a(A, { name: "id" }),
|
|
95
|
+
/* @__PURE__ */ a(A, {})
|
|
95
96
|
] })
|
|
96
|
-
] }) :
|
|
97
|
+
] }) : u ? /* @__PURE__ */ a(H, { gutter: [8, 8], children: h }) : h });
|
|
97
98
|
}
|
|
98
99
|
export {
|
|
99
|
-
|
|
100
|
+
z as CrudForm,
|
|
100
101
|
I as CrudFormFields
|
|
101
102
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),j=require("@ant-design/icons"),u=require("antd"),F=require("react"),y=require("../locale/index.cjs.js"),R=require("./CrudForm.cjs.js"),S=require("../common/wizard/WizardViewForm.cjs.js"),b=require("../util/CrudUtil.cjs.js"),C=require("../common/button/Button.cjs.js");function v({fields:d,className:m,onDeleteFile:h,onUploadFile:i,purpose:l,wizard:r=[],updatingValue:f,onSave:x,submitting:g}){const c=F.useMemo(()=>r.map(n=>{let t=!0;const o=d.filter(s=>n.fields.includes(b.getRealName(s.name)));return o.forEach(s=>t&&(t=s.hidden??!1)),{...n,hidden:t,fieldThatShouldShowing:o}}),[d,r]),a=F.useMemo(()=>c.filter(n=>!n.hidden),[c]);return e.jsx(S,{onSubmit:(n,t)=>{console.log(t),x(t)},className:m,pages:a.map(({title:n,icon:t,fieldThatShouldShowing:o,hidden:s},q)=>({title:n,icon:t,hidden:s,component:k=>e.jsx(N,{fields:o,onDeleteFile:h,onUploadFile:i,purpose:l,i:q,updatingValue:f,backward:k.backward,forward:k.forward,wizard:a,submitting:g},q)}))})}function N({fields:d,onDeleteFile:m,onUploadFile:h,purpose:i,wizard:l=[],i:r,forward:f,backward:x,submitting:g,updatingValue:c}){const a=l[r],{t:n}=y.useTranslationLib(),[t]=u.Form.useForm();return F.useEffect(()=>{if(c&&(i==="update"||i==="clone")){const o={};for(const s of d)o[b.getRealName(s.name,"upsertFieldName")]=c[b.getRealName(s.name,"upsertFieldName")];t.setFieldsValue(o)}},[d,t,i,c]),e.jsxs(u.Form,{name:String(r),form:t,layout:"vertical",children:[e.jsx(R.CrudFormFields,{fields:d,formBuilder:a.formBuilder,grid:a.grid,onDeleteFile:m,onUploadFile:h,purpose:i}),e.jsx(u.Divider,{}),e.jsxs(u.Row,{gutter:[8,8],children:[r>0&&e.jsx(u.Col,{md:12,children:e.jsx(C,{block:!0,icon:e.jsx(j.LeftOutlined,{}),htmlType:"button",type:"default",size:"large",onClick:()=>x(),children:n("str.back")})}),e.jsx(u.Col,{md:r>0?12:24,children:e.jsx(C,{block:!0,icon:l.length-1===r?e.jsx(j.SaveOutlined,{}):e.jsx(j.RightOutlined,{}),htmlType:"submit",type:"primary",loading:g,size:"large",onClick:()=>{t.validateFields().then(o=>{f(o,l.length-1===r,l.length-1===r)})},children:l.length-1===r?n("str."+(i==="update"?"update":"save")):n("str.next")})})]})]})}module.exports=v;
|
|
@@ -1,59 +1,60 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import { LeftOutlined as
|
|
3
|
-
import { Form as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { useTranslationLib as
|
|
6
|
-
import { CrudFormFields as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { jsx as o, jsxs as k } from "react/jsx-runtime";
|
|
2
|
+
import { LeftOutlined as N, SaveOutlined as R, RightOutlined as w } from "@ant-design/icons";
|
|
3
|
+
import { Form as y, Divider as x, Row as T, Col as C } from "antd";
|
|
4
|
+
import { useMemo as S, useEffect as W } from "react";
|
|
5
|
+
import { useTranslationLib as j } from "../locale/index.es.js";
|
|
6
|
+
import { CrudFormFields as z } from "./CrudForm.es.js";
|
|
7
|
+
import B from "../common/wizard/WizardViewForm.es.js";
|
|
8
|
+
import p from "../util/CrudUtil.es.js";
|
|
9
|
+
import v from "../common/button/Button.es.js";
|
|
9
10
|
function H({
|
|
10
11
|
fields: d,
|
|
11
|
-
className:
|
|
12
|
-
onDeleteFile:
|
|
12
|
+
className: u,
|
|
13
|
+
onDeleteFile: f,
|
|
13
14
|
onUploadFile: l,
|
|
14
15
|
purpose: m,
|
|
15
|
-
wizard:
|
|
16
|
+
wizard: t = [],
|
|
16
17
|
updatingValue: s,
|
|
17
18
|
onSave: h,
|
|
18
19
|
submitting: g
|
|
19
20
|
}) {
|
|
20
|
-
const a =
|
|
21
|
-
let
|
|
21
|
+
const a = S(() => t.map((r) => {
|
|
22
|
+
let e = !0;
|
|
22
23
|
const n = d.filter(
|
|
23
|
-
(i) => r.fields.includes(i.name)
|
|
24
|
+
(i) => r.fields.includes(p.getRealName(i.name))
|
|
24
25
|
);
|
|
25
|
-
return n.forEach((i) =>
|
|
26
|
+
return n.forEach((i) => e && (e = i.hidden ?? !1)), {
|
|
26
27
|
...r,
|
|
27
|
-
hidden:
|
|
28
|
+
hidden: e,
|
|
28
29
|
fieldThatShouldShowing: n
|
|
29
30
|
};
|
|
30
|
-
}), [d,
|
|
31
|
+
}), [d, t]), c = S(
|
|
31
32
|
() => a.filter((r) => !r.hidden),
|
|
32
33
|
[a]
|
|
33
34
|
);
|
|
34
35
|
return /* @__PURE__ */ o(
|
|
35
|
-
|
|
36
|
+
B,
|
|
36
37
|
{
|
|
37
|
-
onSubmit: (r,
|
|
38
|
-
console.log(
|
|
38
|
+
onSubmit: (r, e) => {
|
|
39
|
+
console.log(e), h(e);
|
|
39
40
|
},
|
|
40
|
-
className:
|
|
41
|
+
className: u,
|
|
41
42
|
pages: c.map(
|
|
42
|
-
({ title: r, icon:
|
|
43
|
+
({ title: r, icon: e, fieldThatShouldShowing: n, hidden: i }, b) => ({
|
|
43
44
|
title: r,
|
|
44
|
-
icon:
|
|
45
|
+
icon: e,
|
|
45
46
|
hidden: i,
|
|
46
|
-
component: (
|
|
47
|
-
|
|
47
|
+
component: (F) => /* @__PURE__ */ o(
|
|
48
|
+
O,
|
|
48
49
|
{
|
|
49
50
|
fields: n,
|
|
50
|
-
onDeleteFile:
|
|
51
|
+
onDeleteFile: f,
|
|
51
52
|
onUploadFile: l,
|
|
52
53
|
purpose: m,
|
|
53
54
|
i: b,
|
|
54
55
|
updatingValue: s,
|
|
55
|
-
backward:
|
|
56
|
-
forward:
|
|
56
|
+
backward: F.backward,
|
|
57
|
+
forward: F.forward,
|
|
57
58
|
wizard: c,
|
|
58
59
|
submitting: g
|
|
59
60
|
},
|
|
@@ -64,45 +65,45 @@ function H({
|
|
|
64
65
|
}
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
+
function O({
|
|
68
69
|
fields: d,
|
|
69
|
-
onDeleteFile:
|
|
70
|
-
onUploadFile:
|
|
70
|
+
onDeleteFile: u,
|
|
71
|
+
onUploadFile: f,
|
|
71
72
|
purpose: l,
|
|
72
73
|
wizard: m = [],
|
|
73
|
-
i:
|
|
74
|
+
i: t,
|
|
74
75
|
forward: s,
|
|
75
76
|
backward: h,
|
|
76
77
|
submitting: g,
|
|
77
78
|
updatingValue: a
|
|
78
79
|
}) {
|
|
79
|
-
const c = m[
|
|
80
|
-
return
|
|
80
|
+
const c = m[t], { t: r } = j(), [e] = y.useForm();
|
|
81
|
+
return W(() => {
|
|
81
82
|
if (a && (l === "update" || l === "clone")) {
|
|
82
83
|
const n = {};
|
|
83
84
|
for (const i of d)
|
|
84
|
-
n[i.name] = a[i.name];
|
|
85
|
-
|
|
85
|
+
n[p.getRealName(i.name, "upsertFieldName")] = a[p.getRealName(i.name, "upsertFieldName")];
|
|
86
|
+
e.setFieldsValue(n);
|
|
86
87
|
}
|
|
87
|
-
}, [d,
|
|
88
|
+
}, [d, e, l, a]), /* @__PURE__ */ k(y, { name: String(t), form: e, layout: "vertical", children: [
|
|
88
89
|
/* @__PURE__ */ o(
|
|
89
|
-
|
|
90
|
+
z,
|
|
90
91
|
{
|
|
91
92
|
fields: d,
|
|
92
93
|
formBuilder: c.formBuilder,
|
|
93
94
|
grid: c.grid,
|
|
94
|
-
onDeleteFile:
|
|
95
|
-
onUploadFile:
|
|
95
|
+
onDeleteFile: u,
|
|
96
|
+
onUploadFile: f,
|
|
96
97
|
purpose: l
|
|
97
98
|
}
|
|
98
99
|
),
|
|
99
|
-
/* @__PURE__ */ o(
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
/* @__PURE__ */ o(x, {}),
|
|
101
|
+
/* @__PURE__ */ k(T, { gutter: [8, 8], children: [
|
|
102
|
+
t > 0 && /* @__PURE__ */ o(C, { md: 12, children: /* @__PURE__ */ o(
|
|
103
|
+
v,
|
|
103
104
|
{
|
|
104
105
|
block: !0,
|
|
105
|
-
icon: /* @__PURE__ */ o(
|
|
106
|
+
icon: /* @__PURE__ */ o(N, {}),
|
|
106
107
|
htmlType: "button",
|
|
107
108
|
type: "default",
|
|
108
109
|
size: "large",
|
|
@@ -110,25 +111,25 @@ function E({
|
|
|
110
111
|
children: r("str.back")
|
|
111
112
|
}
|
|
112
113
|
) }),
|
|
113
|
-
/* @__PURE__ */ o(
|
|
114
|
-
|
|
114
|
+
/* @__PURE__ */ o(C, { md: t > 0 ? 12 : 24, children: /* @__PURE__ */ o(
|
|
115
|
+
v,
|
|
115
116
|
{
|
|
116
117
|
block: !0,
|
|
117
|
-
icon: m.length - 1 ===
|
|
118
|
+
icon: m.length - 1 === t ? /* @__PURE__ */ o(R, {}) : /* @__PURE__ */ o(w, {}),
|
|
118
119
|
htmlType: "submit",
|
|
119
120
|
type: "primary",
|
|
120
121
|
loading: g,
|
|
121
122
|
size: "large",
|
|
122
123
|
onClick: () => {
|
|
123
|
-
|
|
124
|
+
e.validateFields().then((n) => {
|
|
124
125
|
s(
|
|
125
126
|
n,
|
|
126
|
-
m.length - 1 ===
|
|
127
|
-
m.length - 1 ===
|
|
127
|
+
m.length - 1 === t,
|
|
128
|
+
m.length - 1 === t
|
|
128
129
|
);
|
|
129
130
|
});
|
|
130
131
|
},
|
|
131
|
-
children: m.length - 1 ===
|
|
132
|
+
children: m.length - 1 === t ? r("str." + (l === "update" ? "update" : "save")) : r("str.next")
|
|
132
133
|
}
|
|
133
134
|
) })
|
|
134
135
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),o=require("react"),
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),p=require("@ant-design/icons"),l=require("antd"),N=require("./CrudField.cjs.js"),w=require("../util/CrudUtil.cjs.js"),M=require("../common/button/Button.cjs.js");function R({searchFields:t=[],fields:g,searchOnChange:y,onSearch:m,searchDefaultValues:b,searchFieldsCustomColumnProps:r}){const c=o.useMemo(()=>t.map(n=>typeof n=="string"?{...g.find(x=>n===x.name),required:!1}:{...g.find(i=>(n==null?void 0:n.name)===i.name),...n}).filter(n=>n&&!(n!=null&&n.hidden)),[t,g]),j=o.useMemo(()=>t.length===1?{field:22,button:2}:t.length===2?{field:11,button:2}:t.length===3?{field:6,button:6}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),q=o.useMemo(()=>t.length===1?{field:22,button:2}:t.length===2?{field:11,button:2}:t.length===3?{field:6,button:6}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),a=o.useMemo(()=>t.length===1?{field:21,button:3}:t.length===2?{field:11,button:2}:t.length===3?{field:24,button:24}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),[u]=l.Form.useForm(),d=o.useCallback(async n=>{if((n||y)&&m){const f=await u.validateFields();m(f)}},[u,m,y]);return o.useEffect(()=>{b&&(u.setFieldsValue(b),d(!0))},[u,b]),t!=null&&t.length?e.jsx(l.Form,{form:u,onFinish:()=>d(!0),layout:"vertical",className:"mb-2",onChange:()=>d(!1),children:e.jsxs(l.Row,{gutter:[4,8],className:"w-100",children:[c.map((n,f)=>{const i=(r==null?void 0:r[f])??{md:j.field,sm:q.field,xs:a.field},x=w.getRealName(n.name);return o.createElement(l.Col,{...i,key:`search_field_${String(x)}`,className:"align-self-end"},e.jsx(N.default,{...n,readonly:!1,fieldClassName:"mb-0"}))}),e.jsx(l.Col,{md:j.button,sm:q.button,xs:a.button,style:{alignSelf:"end"},children:e.jsx(M,{type:"primary",htmlType:"submit",block:!0,icon:e.jsx(p.SearchOutlined,{})})})]})}):e.jsx(e.Fragment,{})}module.exports=R;
|
|
@@ -1,87 +1,88 @@
|
|
|
1
1
|
import { jsx as o, Fragment as j, jsxs as v } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { SearchOutlined as
|
|
4
|
-
import { Form as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
2
|
+
import { useMemo as l, useCallback as E, useEffect as R, createElement as S } from "react";
|
|
3
|
+
import { SearchOutlined as _ } from "@ant-design/icons";
|
|
4
|
+
import { Form as N, Row as q, Col as w } from "antd";
|
|
5
|
+
import B from "./CrudField.es.js";
|
|
6
|
+
import M from "../util/CrudUtil.es.js";
|
|
7
|
+
import T from "../common/button/Button.es.js";
|
|
7
8
|
function I({
|
|
8
9
|
searchFields: t = [],
|
|
9
|
-
fields:
|
|
10
|
-
searchOnChange:
|
|
11
|
-
onSearch:
|
|
10
|
+
fields: u,
|
|
11
|
+
searchOnChange: d,
|
|
12
|
+
onSearch: i,
|
|
12
13
|
searchDefaultValues: g,
|
|
13
|
-
searchFieldsCustomColumnProps:
|
|
14
|
+
searchFieldsCustomColumnProps: b
|
|
14
15
|
}) {
|
|
15
|
-
const k =
|
|
16
|
+
const k = l(
|
|
16
17
|
() => t.map((n) => typeof n == "string" ? {
|
|
17
|
-
...
|
|
18
|
+
...u.find((p) => n === p.name),
|
|
18
19
|
required: !1
|
|
19
20
|
} : {
|
|
20
|
-
...
|
|
21
|
-
(
|
|
21
|
+
...u.find(
|
|
22
|
+
(e) => (n == null ? void 0 : n.name) === e.name
|
|
22
23
|
),
|
|
23
24
|
...n
|
|
24
25
|
}).filter((n) => n && !(n != null && n.hidden)),
|
|
25
|
-
[t,
|
|
26
|
-
),
|
|
26
|
+
[t, u]
|
|
27
|
+
), y = l(
|
|
27
28
|
() => t.length === 1 ? { field: 22, button: 2 } : t.length === 2 ? { field: 11, button: 2 } : t.length === 3 ? { field: 6, button: 6 } : t.length === 4 ? { field: 5, button: 4 } : t.length === 5 ? { field: 4, button: 4 } : { field: 4, button: 4 },
|
|
28
29
|
[t.length]
|
|
29
|
-
),
|
|
30
|
+
), a = l(
|
|
30
31
|
() => t.length === 1 ? { field: 22, button: 2 } : t.length === 2 ? { field: 11, button: 2 } : t.length === 3 ? { field: 6, button: 6 } : t.length === 4 ? { field: 5, button: 4 } : t.length === 5 ? { field: 4, button: 4 } : { field: 4, button: 4 },
|
|
31
32
|
[t.length]
|
|
32
|
-
), x =
|
|
33
|
+
), x = l(
|
|
33
34
|
() => t.length === 1 ? { field: 21, button: 3 } : t.length === 2 ? { field: 11, button: 2 } : t.length === 3 ? { field: 24, button: 24 } : t.length === 4 ? { field: 5, button: 4 } : t.length === 5 ? { field: 4, button: 4 } : { field: 4, button: 4 },
|
|
34
35
|
[t.length]
|
|
35
|
-
), [f] =
|
|
36
|
+
), [f] = N.useForm(), r = E(
|
|
36
37
|
async (n) => {
|
|
37
|
-
if ((n ||
|
|
38
|
+
if ((n || d) && i) {
|
|
38
39
|
const m = await f.validateFields();
|
|
39
|
-
|
|
40
|
+
i(m);
|
|
40
41
|
}
|
|
41
42
|
},
|
|
42
|
-
[f,
|
|
43
|
+
[f, i, d]
|
|
43
44
|
);
|
|
44
|
-
return
|
|
45
|
+
return R(() => {
|
|
45
46
|
g && (f.setFieldsValue(g), r(!0));
|
|
46
47
|
}, [f, g]), t != null && t.length ? /* @__PURE__ */ o(
|
|
47
|
-
|
|
48
|
+
N,
|
|
48
49
|
{
|
|
49
50
|
form: f,
|
|
50
51
|
onFinish: () => r(!0),
|
|
51
52
|
layout: "vertical",
|
|
52
53
|
className: "mb-2",
|
|
53
54
|
onChange: () => r(!1),
|
|
54
|
-
children: /* @__PURE__ */ v(
|
|
55
|
+
children: /* @__PURE__ */ v(q, { gutter: [4, 8], className: "w-100", children: [
|
|
55
56
|
k.map((n, m) => {
|
|
56
|
-
const
|
|
57
|
-
md:
|
|
58
|
-
sm:
|
|
57
|
+
const e = (b == null ? void 0 : b[m]) ?? {
|
|
58
|
+
md: y.field,
|
|
59
|
+
sm: a.field,
|
|
59
60
|
xs: x.field
|
|
60
|
-
};
|
|
61
|
-
return /* @__PURE__ */
|
|
62
|
-
|
|
61
|
+
}, p = M.getRealName(n.name);
|
|
62
|
+
return /* @__PURE__ */ S(
|
|
63
|
+
w,
|
|
63
64
|
{
|
|
64
|
-
...
|
|
65
|
-
key: `search_field_${String(
|
|
65
|
+
...e,
|
|
66
|
+
key: `search_field_${String(p)}`,
|
|
66
67
|
className: "align-self-end"
|
|
67
68
|
},
|
|
68
|
-
/* @__PURE__ */ o(
|
|
69
|
+
/* @__PURE__ */ o(B, { ...n, readonly: !1, fieldClassName: "mb-0" })
|
|
69
70
|
);
|
|
70
71
|
}),
|
|
71
72
|
/* @__PURE__ */ o(
|
|
72
|
-
|
|
73
|
+
w,
|
|
73
74
|
{
|
|
74
|
-
md:
|
|
75
|
-
sm:
|
|
75
|
+
md: y.button,
|
|
76
|
+
sm: a.button,
|
|
76
77
|
xs: x.button,
|
|
77
78
|
style: { alignSelf: "end" },
|
|
78
79
|
children: /* @__PURE__ */ o(
|
|
79
|
-
|
|
80
|
+
T,
|
|
80
81
|
{
|
|
81
82
|
type: "primary",
|
|
82
83
|
htmlType: "submit",
|
|
83
84
|
block: !0,
|
|
84
|
-
icon: /* @__PURE__ */ o(
|
|
85
|
+
icon: /* @__PURE__ */ o(_, {})
|
|
85
86
|
}
|
|
86
87
|
)
|
|
87
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const u=require("react/jsx-runtime"),C=require("../common/text-field/TextArea.cjs.js"),T=require("../common/rich/index.cjs.js"),h=require("antd"),j=require("../util/CrudUtil.cjs.js"),p=({onChange:t,label:r,required:s,rules:o,name:i,updatable:n=!0,...c})=>{const a=h.Form.useFormInstance(),l=j.getRealName(i,"upsertFieldName");if(c.rich)return u.jsx(T.RichTextEditor,{name:l,label:r,required:s,rules:o,disabled:!n});{const{placeholder:m,rows:x,cols:f,fieldClassName:N,fieldTooltip:q}=c;return u.jsx(C.default,{rules:o,placeholder:m,onChange:t?e=>{var d;return t((d=e==null?void 0:e.target)==null?void 0:d.value,a)}:void 0,tooltip:q,required:s,disabled:!n,name:i,label:r,className:N,rows:x,cols:f})}};module.exports=p;
|
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import N from "../common/text-field/TextArea.es.js";
|
|
3
3
|
import { RichTextEditor as T } from "../common/rich/index.es.js";
|
|
4
4
|
import { Form as h } from "antd";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import F from "../util/CrudUtil.es.js";
|
|
6
|
+
const E = ({
|
|
7
|
+
onChange: e,
|
|
8
|
+
label: t,
|
|
9
|
+
required: r,
|
|
10
|
+
rules: m,
|
|
11
|
+
name: i,
|
|
11
12
|
updatable: s = !0,
|
|
12
|
-
...
|
|
13
|
+
...a
|
|
13
14
|
}) => {
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
15
|
+
const c = h.useFormInstance(), f = F.getRealName(i, "upsertFieldName");
|
|
16
|
+
if (a.rich)
|
|
16
17
|
return /* @__PURE__ */ d(
|
|
17
18
|
T,
|
|
18
19
|
{
|
|
19
|
-
name:
|
|
20
|
-
label:
|
|
21
|
-
required:
|
|
22
|
-
rules:
|
|
20
|
+
name: f,
|
|
21
|
+
label: t,
|
|
22
|
+
required: r,
|
|
23
|
+
rules: m,
|
|
23
24
|
disabled: !s
|
|
24
25
|
}
|
|
25
26
|
);
|
|
26
27
|
{
|
|
27
|
-
const { placeholder:
|
|
28
|
+
const { placeholder: l, rows: p, cols: u, fieldClassName: x, fieldTooltip: C } = a;
|
|
28
29
|
return /* @__PURE__ */ d(
|
|
29
|
-
|
|
30
|
+
N,
|
|
30
31
|
{
|
|
31
|
-
rules:
|
|
32
|
-
placeholder:
|
|
33
|
-
onChange:
|
|
34
|
-
var
|
|
35
|
-
return
|
|
32
|
+
rules: m,
|
|
33
|
+
placeholder: l,
|
|
34
|
+
onChange: e ? (o) => {
|
|
35
|
+
var n;
|
|
36
|
+
return e((n = o == null ? void 0 : o.target) == null ? void 0 : n.value, c);
|
|
36
37
|
} : void 0,
|
|
37
|
-
tooltip:
|
|
38
|
-
required:
|
|
38
|
+
tooltip: C,
|
|
39
|
+
required: r,
|
|
39
40
|
disabled: !s,
|
|
40
|
-
name:
|
|
41
|
-
label:
|
|
41
|
+
name: i,
|
|
42
|
+
label: t,
|
|
42
43
|
className: x,
|
|
43
|
-
rows:
|
|
44
|
-
cols:
|
|
44
|
+
rows: p,
|
|
45
|
+
cols: u
|
|
45
46
|
}
|
|
46
47
|
);
|
|
47
48
|
}
|
|
48
49
|
};
|
|
49
50
|
export {
|
|
50
|
-
|
|
51
|
+
E as default
|
|
51
52
|
};
|
|
@@ -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"),N=require("mime"),c=require("react"),B=require("../locale/index.cjs.js"),z=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),G=require("../common/layout/VerticalSpace.cjs.js"),J=require("../util/CrudUtil.cjs.js");function K({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:k,maxCount:q=1,block:E,..._}){const f=F.Form.useFormInstance(),$=J.getRealName(n,"upsertFieldName"),x=F.Form.useWatch($,f),[O,b]=c.useState(!1),[V,R]=c.useState(!1),A=c.useCallback(async r=>{var i,u;try{const{file:o}=r,g=o.name;b(!0),R(!0),a==null||a(!0);const C=g??"",S=C.split("."),L=S[S.length-1],W=s.generateFileName(C),M=`${await s.getInitialPath()}/${W}.${L}`;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{b(!1)}},[f,n,a,s]),[w,I]=c.useState([]);c.useEffect(()=>{!V&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const i=N.getType(r),u=r.split("/").pop(),o=await s.getRealUrl(r);return{uid:r,url:o,type:i,name:u}})).then(r=>I(()=>{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,O,s]);const H=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?z.required(e):[],...k??[]],children:[t.jsx("input",{hidden:!0}),t.jsx(F.Upload,{..._,fileList:w,className:((w==null?void 0:w.length)??0)>=q?"hide-upload":"",maxCount:q,customRequest:A,onRemove:H,listType:"picture",onChange:({fileList:r})=>{I(r)},style:E?{width:"100%"}:void 0,children:t.jsx(p,{loading:O,children:"Upload File"})})]})}const Q=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:N.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(U,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},U=({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"},destroyOnHidden:!0,children:t.jsxs(G,{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=U;exports.FileCrudCellValue=Q;exports.default=K;
|