@kingteza/crud-component 1.0.55 → 1.0.57
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 -0
- package/hooks/NavigatorHooks.d.ts +1 -0
- package/hooks/NavigatorHooks.es.js +9 -0
- package/icons/FlipHIcon.cjs.js +1 -0
- package/icons/FlipHIcon.d.ts +3 -0
- package/icons/FlipHIcon.es.js +28 -0
- package/icons/FlipVIcon.cjs.js +1 -0
- package/icons/FlipVIcon.d.ts +3 -0
- package/icons/FlipVIcon.es.js +28 -0
- package/package.json +3 -2
- package/util/CrudUtil.cjs.js +1 -0
- package/util/CrudUtil.d.ts +5 -0
- package/util/CrudUtil.es.js +8 -0
package/crud/FileCrudField.es.js
CHANGED
|
@@ -1,70 +1,71 @@
|
|
|
1
1
|
import { jsxs as f, jsx as s, Fragment as O } from "react/jsx-runtime";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { FileOutlined as J, FilePptOutlined as K, FileExcelOutlined as Q, FileTextOutlined as
|
|
4
|
-
import { Form as P, Upload as
|
|
3
|
+
import { FileOutlined as J, FilePptOutlined as K, FileExcelOutlined as Q, FileTextOutlined as X, FileWordOutlined as Y, FilePdfOutlined as Z, FileImageOutlined as v, ExportOutlined as y } from "@ant-design/icons";
|
|
4
|
+
import { Form as P, Upload as m, Modal as T } from "antd";
|
|
5
5
|
import S from "mime";
|
|
6
|
-
import { useState as p, useCallback as
|
|
7
|
-
import { useTranslationLib as
|
|
8
|
-
import
|
|
6
|
+
import { useState as p, useCallback as $, useEffect as A, useMemo as j } from "react";
|
|
7
|
+
import { useTranslationLib as tt } from "../locale/index.es.js";
|
|
8
|
+
import et from "../util/ValidationUtil.es.js";
|
|
9
9
|
import C from "../common/button/Button.es.js";
|
|
10
|
-
import
|
|
11
|
-
|
|
10
|
+
import st from "../common/layout/VerticalSpace.es.js";
|
|
11
|
+
import rt from "../util/CrudUtil.es.js";
|
|
12
|
+
function wt({
|
|
12
13
|
name: n,
|
|
13
14
|
label: t,
|
|
14
|
-
required:
|
|
15
|
+
required: r,
|
|
15
16
|
provider: e,
|
|
16
17
|
onUploading: a,
|
|
17
18
|
onRemoved: u,
|
|
18
|
-
fieldClassName:
|
|
19
|
+
fieldClassName: F,
|
|
19
20
|
accept: b,
|
|
20
21
|
rules: H,
|
|
21
22
|
maxCount: I = 1,
|
|
22
23
|
block: L,
|
|
23
24
|
...W
|
|
24
25
|
}) {
|
|
25
|
-
const d = P.useFormInstance(), h = P.useWatch(
|
|
26
|
-
async (
|
|
26
|
+
const d = P.useFormInstance(), _ = rt.getRealName(n, "upsertFieldName"), h = P.useWatch(_, d), [V, D] = p(!1), [N, q] = p(!1), B = $(
|
|
27
|
+
async (l) => {
|
|
27
28
|
var c, i;
|
|
28
29
|
try {
|
|
29
|
-
const { file: o } =
|
|
30
|
-
D(!0),
|
|
31
|
-
const
|
|
32
|
-
console.log({ filePath:
|
|
33
|
-
const
|
|
30
|
+
const { file: o } = l, g = o.name;
|
|
31
|
+
D(!0), q(!0), a == null || a(!0);
|
|
32
|
+
const x = g ?? "", k = x.split("."), z = k[k.length - 1], G = e.generateFileName(x), E = `${await e.getInitialPath()}/${G}.${z}`;
|
|
33
|
+
console.log({ filePath: E });
|
|
34
|
+
const M = await e.upload(
|
|
34
35
|
{ ...o, originFileObj: o },
|
|
35
|
-
|
|
36
|
+
E
|
|
36
37
|
);
|
|
37
|
-
a == null || a(!1), d.setFieldValue(n,
|
|
38
|
+
a == null || a(!1), d.setFieldValue(n, M), (c = l.onSuccess) == null || c.call(l, M);
|
|
38
39
|
} catch (o) {
|
|
39
|
-
(i =
|
|
40
|
+
(i = l.onError) == null || i.call(l, o);
|
|
40
41
|
} finally {
|
|
41
42
|
D(!1);
|
|
42
43
|
}
|
|
43
44
|
},
|
|
44
45
|
[d, n, a, e]
|
|
45
|
-
), [
|
|
46
|
+
), [w, U] = p([]);
|
|
46
47
|
A(() => {
|
|
47
|
-
!
|
|
48
|
+
!N && h && Promise.all(
|
|
48
49
|
(Array.isArray(h) ? h : [h]).map(
|
|
49
|
-
async (
|
|
50
|
-
const c = S.getType(
|
|
50
|
+
async (l) => {
|
|
51
|
+
const c = S.getType(l), i = l.split("/").pop(), o = await e.getRealUrl(l);
|
|
51
52
|
return {
|
|
52
|
-
uid:
|
|
53
|
+
uid: l,
|
|
53
54
|
url: o,
|
|
54
55
|
type: c,
|
|
55
56
|
name: i
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
)
|
|
59
|
-
).then((
|
|
60
|
-
const c =
|
|
60
|
+
).then((l) => U(() => {
|
|
61
|
+
const c = l.map(({ url: i, type: o, uid: g, name: x }) => ({ uid: g, url: i, type: o, response: g, thumbUrl: i, name: x }));
|
|
61
62
|
return console.log(c), c;
|
|
62
63
|
}));
|
|
63
|
-
}, [h,
|
|
64
|
-
const
|
|
65
|
-
async (
|
|
66
|
-
const c =
|
|
67
|
-
await e.delete(i), u == null || u(),
|
|
64
|
+
}, [h, N, V, e]);
|
|
65
|
+
const R = $(
|
|
66
|
+
async (l) => {
|
|
67
|
+
const c = l.response, i = c || d.getFieldValue(n);
|
|
68
|
+
await e.delete(i), u == null || u(), l && d.setFieldsValue({ [n]: null });
|
|
68
69
|
},
|
|
69
70
|
[d, n, u, e]
|
|
70
71
|
);
|
|
@@ -72,27 +73,27 @@ function ht({
|
|
|
72
73
|
P.Item,
|
|
73
74
|
{
|
|
74
75
|
label: t,
|
|
75
|
-
required:
|
|
76
|
+
required: r,
|
|
76
77
|
name: n,
|
|
77
|
-
className:
|
|
78
|
+
className: F,
|
|
78
79
|
rules: [
|
|
79
|
-
...
|
|
80
|
+
...r ? et.required(t) : [],
|
|
80
81
|
...H ?? []
|
|
81
82
|
],
|
|
82
83
|
children: [
|
|
83
84
|
/* @__PURE__ */ s("input", { hidden: !0 }),
|
|
84
85
|
/* @__PURE__ */ s(
|
|
85
|
-
|
|
86
|
+
m,
|
|
86
87
|
{
|
|
87
88
|
...W,
|
|
88
|
-
fileList:
|
|
89
|
-
className: ((
|
|
89
|
+
fileList: w,
|
|
90
|
+
className: ((w == null ? void 0 : w.length) ?? 0) >= I ? "hide-upload" : "",
|
|
90
91
|
maxCount: I,
|
|
91
|
-
customRequest:
|
|
92
|
-
onRemove:
|
|
92
|
+
customRequest: B,
|
|
93
|
+
onRemove: R,
|
|
93
94
|
listType: "picture",
|
|
94
|
-
onChange: ({ fileList:
|
|
95
|
-
|
|
95
|
+
onChange: ({ fileList: l }) => {
|
|
96
|
+
U(l);
|
|
96
97
|
},
|
|
97
98
|
style: L ? { width: "100%" } : void 0,
|
|
98
99
|
children: /* @__PURE__ */ s(C, { loading: V, children: "Upload File" })
|
|
@@ -102,8 +103,8 @@ function ht({
|
|
|
102
103
|
}
|
|
103
104
|
);
|
|
104
105
|
}
|
|
105
|
-
const
|
|
106
|
-
const [
|
|
106
|
+
const gt = ({ provider: n, value: t }) => {
|
|
107
|
+
const [r, e] = p();
|
|
107
108
|
return A(() => {
|
|
108
109
|
t && n.getRealUrl(t).then((a) => {
|
|
109
110
|
e({
|
|
@@ -112,25 +113,25 @@ const pt = ({ provider: n, value: t }) => {
|
|
|
112
113
|
fileName: t.split("/").pop() ?? t
|
|
113
114
|
});
|
|
114
115
|
});
|
|
115
|
-
}, [n, t]),
|
|
116
|
-
|
|
116
|
+
}, [n, t]), r ? /* @__PURE__ */ s(
|
|
117
|
+
lt,
|
|
117
118
|
{
|
|
118
|
-
fileName:
|
|
119
|
-
url:
|
|
120
|
-
mimeType:
|
|
119
|
+
fileName: r.fileName,
|
|
120
|
+
url: r == null ? void 0 : r.url,
|
|
121
|
+
mimeType: r == null ? void 0 : r.mimeType
|
|
121
122
|
}
|
|
122
123
|
) : /* @__PURE__ */ s(O, {});
|
|
123
|
-
},
|
|
124
|
-
const e =
|
|
124
|
+
}, lt = ({ url: n, mimeType: t = "", fileName: r }) => {
|
|
125
|
+
const e = j(() => 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 = j(() => {
|
|
125
126
|
switch (e) {
|
|
126
127
|
case "image":
|
|
127
|
-
return /* @__PURE__ */ s(
|
|
128
|
+
return /* @__PURE__ */ s(v, {});
|
|
128
129
|
case "pdf":
|
|
129
|
-
return /* @__PURE__ */ s(
|
|
130
|
+
return /* @__PURE__ */ s(Z, {});
|
|
130
131
|
case "word":
|
|
131
|
-
return /* @__PURE__ */ s(
|
|
132
|
+
return /* @__PURE__ */ s(Y, {});
|
|
132
133
|
case "text":
|
|
133
|
-
return /* @__PURE__ */ s(
|
|
134
|
+
return /* @__PURE__ */ s(X, {});
|
|
134
135
|
case "excel":
|
|
135
136
|
return /* @__PURE__ */ s(Q, {});
|
|
136
137
|
case "presentation":
|
|
@@ -138,37 +139,37 @@ const pt = ({ provider: n, value: t }) => {
|
|
|
138
139
|
default:
|
|
139
140
|
return /* @__PURE__ */ s(J, {});
|
|
140
141
|
}
|
|
141
|
-
}, [e]), [u,
|
|
142
|
+
}, [e]), [u, F] = p(!1), { t: b } = tt();
|
|
142
143
|
return e !== "file" && e !== "text" ? /* @__PURE__ */ f(O, { children: [
|
|
143
144
|
/* @__PURE__ */ s(
|
|
144
|
-
|
|
145
|
+
T,
|
|
145
146
|
{
|
|
146
147
|
open: u,
|
|
147
|
-
title:
|
|
148
|
-
onCancel: () =>
|
|
148
|
+
title: r,
|
|
149
|
+
onCancel: () => F(!1),
|
|
149
150
|
footer: /* @__PURE__ */ s(O, {}),
|
|
150
151
|
width: "100%",
|
|
151
152
|
style: { top: "8px", minHeight: "700px" },
|
|
152
153
|
destroyOnHidden: !0,
|
|
153
|
-
children: /* @__PURE__ */ f(
|
|
154
|
+
children: /* @__PURE__ */ f(st, { children: [
|
|
154
155
|
/* @__PURE__ */ s(
|
|
155
156
|
C,
|
|
156
157
|
{
|
|
157
|
-
tooltip:
|
|
158
|
-
icon: /* @__PURE__ */ s(
|
|
158
|
+
tooltip: r,
|
|
159
|
+
icon: /* @__PURE__ */ s(y, {}),
|
|
159
160
|
target: "_blank",
|
|
160
161
|
href: n,
|
|
161
162
|
style: { textDecoration: "none" },
|
|
162
163
|
children: b("str.openInNewTab")
|
|
163
164
|
}
|
|
164
165
|
),
|
|
165
|
-
e === "image" ? /* @__PURE__ */ s("img", { src: n, alt:
|
|
166
|
+
e === "image" ? /* @__PURE__ */ s("img", { src: n, alt: r, style: { width: "100%" } }) : e === "pdf" ? /* @__PURE__ */ f("iframe", { title: r, src: n, width: "100%", height: "700px", children: [
|
|
166
167
|
"This browser does not support PDFs. Please download the PDF to view it:",
|
|
167
168
|
/* @__PURE__ */ s("a", { href: n, children: "Download PDF" })
|
|
168
169
|
] }) : /* @__PURE__ */ f(
|
|
169
170
|
"iframe",
|
|
170
171
|
{
|
|
171
|
-
title:
|
|
172
|
+
title: r,
|
|
172
173
|
src: `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
|
|
173
174
|
n
|
|
174
175
|
)}`,
|
|
@@ -194,16 +195,16 @@ const pt = ({ provider: n, value: t }) => {
|
|
|
194
195
|
/* @__PURE__ */ s(
|
|
195
196
|
C,
|
|
196
197
|
{
|
|
197
|
-
tooltip:
|
|
198
|
+
tooltip: r,
|
|
198
199
|
icon: a,
|
|
199
200
|
shape: "circle",
|
|
200
|
-
onClick: () =>
|
|
201
|
+
onClick: () => F(!0)
|
|
201
202
|
}
|
|
202
203
|
)
|
|
203
204
|
] }) : /* @__PURE__ */ s(
|
|
204
205
|
C,
|
|
205
206
|
{
|
|
206
|
-
tooltip:
|
|
207
|
+
tooltip: r,
|
|
207
208
|
icon: a,
|
|
208
209
|
target: "_blank",
|
|
209
210
|
href: n,
|
|
@@ -212,7 +213,7 @@ const pt = ({ provider: n, value: t }) => {
|
|
|
212
213
|
);
|
|
213
214
|
};
|
|
214
215
|
export {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
lt as FileCellValue,
|
|
217
|
+
gt as FileCrudCellValue,
|
|
218
|
+
wt as default
|
|
218
219
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),q=require("../../common/description/DescList.cjs.js"),f=require("react"),x=require("../../locale/index.cjs.js"),C=require("./CrudViewerUtil.cjs.js"),V=require("../../util/CrudUtil.cjs.js");function j({className:o,fields:s,data:e,descListColumn:c={xs:1,md:3,sm:2,lg:4},layout:m,action:t,keepEmptyValues:b}){const{t:n}=x.useTranslationLib(),g=f.useMemo(()=>{const l=s.filter(({hidden:r,hideInDescList:u})=>!r&&!u).map((r,u)=>{const d=V.getRealName(r.name);return{label:r.label,noFormatting:!0,value:C.getRendererValueCrudViewer(r)(e==null?void 0:e[d],e,u)}});return t&&l.push({label:n("str.action"),value:t}),l},[t,e,s,n]);return e?i.jsx(q,{keepEmptyValues:b,bordered:!0,column:c,className:o,layout:m,list:g}):i.jsx(i.Fragment,{})}exports.CrudDecListView=j;
|
|
@@ -1,40 +1,44 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { useTranslationLib as
|
|
5
|
-
import { getRendererValueCrudViewer as
|
|
1
|
+
import { jsx as s, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import x from "../../common/description/DescList.es.js";
|
|
3
|
+
import { useMemo as C } from "react";
|
|
4
|
+
import { useTranslationLib as F } from "../../locale/index.es.js";
|
|
5
|
+
import { getRendererValueCrudViewer as L } from "./CrudViewerUtil.es.js";
|
|
6
|
+
import V from "../../util/CrudUtil.es.js";
|
|
6
7
|
function h({
|
|
7
|
-
className:
|
|
8
|
+
className: u,
|
|
8
9
|
fields: m,
|
|
9
10
|
data: r,
|
|
10
|
-
descListColumn:
|
|
11
|
+
descListColumn: n = { xs: 1, md: 3, sm: 2, lg: 4 },
|
|
11
12
|
layout: f,
|
|
12
|
-
action:
|
|
13
|
+
action: t,
|
|
13
14
|
keepEmptyValues: p
|
|
14
15
|
}) {
|
|
15
|
-
const { t: i } =
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
const { t: i } = F(), c = C(() => {
|
|
17
|
+
const l = m.filter(({ hidden: e, hideInDescList: o }) => !e && !o).map((e, o) => {
|
|
18
|
+
const b = V.getRealName(e.name);
|
|
19
|
+
return {
|
|
20
|
+
label: e.label,
|
|
21
|
+
noFormatting: !0,
|
|
22
|
+
value: L(e)(
|
|
23
|
+
r == null ? void 0 : r[b],
|
|
24
|
+
r,
|
|
25
|
+
o
|
|
26
|
+
)
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
return t && l.push({ label: i("str.action"), value: t }), l;
|
|
30
|
+
}, [t, r, m, i]);
|
|
31
|
+
return r ? /* @__PURE__ */ s(
|
|
32
|
+
x,
|
|
29
33
|
{
|
|
30
34
|
keepEmptyValues: p,
|
|
31
35
|
bordered: !0,
|
|
32
|
-
column:
|
|
33
|
-
className:
|
|
36
|
+
column: n,
|
|
37
|
+
className: u,
|
|
34
38
|
layout: f,
|
|
35
39
|
list: c
|
|
36
40
|
}
|
|
37
|
-
) : /* @__PURE__ */
|
|
41
|
+
) : /* @__PURE__ */ s(g, {});
|
|
38
42
|
}
|
|
39
43
|
export {
|
|
40
44
|
h as CrudDecListView
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),xt=require("antd"),
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),xt=require("antd"),jt=require("@dnd-kit/core"),lt=require("@dnd-kit/modifiers"),ht=require("@dnd-kit/utilities"),M=require("@dnd-kit/sortable"),qt=require("../../common/button/Button.cjs.js"),yt=require("../../common/button/CloneButtonTable.cjs.js"),vt=require("../../common/button/DeleteButtonTable.cjs.js"),St=require("../../common/button/ExportButton.cjs.js"),Bt=require("../../common/button/HideButtonTable.cjs.js"),Ct=require("../../common/button/RefreshButton.cjs.js"),It=require("../../common/button/UpdateButtonTable.cjs.js"),Tt=require("../../common/button/ViewButtonTable.cjs.js"),Rt=require("../../common/table/table.cjs.js"),u=require("react"),Mt=require("../../locale/index.cjs.js"),Vt=require("../CrudSearchComponent.cjs.js"),Et=require("./CrudDecListView.cjs.js"),et=require("./CrudViewerUtil.cjs.js"),Nt=require("@ant-design/icons"),nt=require("../../util/CrudUtil.cjs.js"),wt=require("../../common/layout/VerticalSpace.cjs.js"),Dt=u.memo(Rt);function Lt({idField:e="id",loadingData:v,fields:m,isDeleting:I,isHiding:S,viewable:f=!1,paginateProps:j,onDelete:l,onHide:T,onUpdate:y,data:B=[],extraAction:C,onClickUpdate:h,minusHeight:w,scroll:G,onClickClone:V,className:J,expandable:K,size:Q,bordered:X,descListColumn:ot,extraView:D,decListLayout:rt,scrollToTop:_t,onClickRefresh:Y,closeViewOnClickUpdate:Z,onExport:L,confirmHiding:A,confirmDeleting:P,rowClassName:W,actionWidth:a=190,draggable:o,...ut}){const{t:H}=Mt.useTranslationLib(),p=u.useMemo(()=>m.map(({hideInTable:t,hidden:s,width:c,label:r,halign:$,...R})=>{const N=nt.getRealName(R.name);return{title:r,width:c,key:N,dataIndex:N,hidden:t||s,align:$??(R.type==="number"?"right":void 0),render:et.getRendererValueCrudViewer(R)}}),[m]),[i,E]=u.useState(),[O,z]=u.useState(),[q,U]=u.useState([]);u.useEffect(()=>{B&&U(B)},[B]),u.useEffect(()=>{B&&E(t=>{if(t)return B.find(s=>s[e]===t[e])})},[B,e,i]);const _=u.useCallback(t=>{var c;const s=C==null?void 0:C(t);return(Array.isArray(s)?(c=s==null?void 0:s.filter(Boolean))!=null&&c.length:s)||y||h||V||l?n.jsxs(n.Fragment,{children:[s,(y||h)&&n.jsx(It,{value:t,onClick:r=>{z(r[e]),h==null||h(t),Z&&E(void 0)}}),V&&n.jsx(yt,{value:t,onClick:r=>V(r)}),L&&n.jsx(St.ExportButton,{value:t,onClick:async r=>await L(r)}),T&&n.jsx(Bt,{value:t,disabled:S,shouldConfirm:A,loading:S&&t[e]===O,onClick:async r=>{z(r[e]),await T({[e]:r[e]})}}),l&&n.jsx(vt,{value:t,disabled:I,shouldConfirm:P,loading:I&&t[e]===O,onClick:async r=>{z(r[e]),await l({[e]:r[e]})}})]}):void 0},[Z,P,A,C,e,I,S,V,h,l,L,T,y,O]),d=u.useCallback(t=>{var r;const{active:s,over:c}=t;if(o!=null&&o.onDragEnd&&(o==null||o.onDragEnd(t)),s.id!==(c==null?void 0:c.id)){const $=q.findIndex(x=>x[e]===s.id),R=q.findIndex(x=>x[e]===(c==null?void 0:c.id)),N=M.arrayMove(q,$,R);U(x=>{const mt=x.findIndex(k=>k[e]===(s==null?void 0:s.id)),ft=x.findIndex(k=>k[e]===(c==null?void 0:c.id));return M.arrayMove(x,mt,ft)}),(r=o==null?void 0:o.onDrag)==null||r.call(o,{newOrder:N.map(x=>x[e])})}},[q,e,o]),ct=u.useMemo(()=>{let t=typeof f=="string"?i==null?void 0:i[f]:void 0;if(typeof t=="object"){const s=m.find(c=>nt.getRealName(c.name)===f);t=et.getRendererValueCrudViewer(s)(t,i,0)}return t},[f,i,m]),b=u.useMemo(()=>({rowClassName:W,className:J,scroll:G??(w?{y:`calc(100vh - ${w})`}:void 0),id:"crud-table",bordered:X,size:Q,expandable:K}),[W,J,G,w,X,Q,K]),F=u.useMemo(()=>j?{total:j.count,onChange:j.setPage,current:j.page,pageSize:j.pageSize}:void 0,[j]),g=u.useMemo(()=>{const t=y||h||l||C||f,s=[];return o&&s.push({key:"key",align:"center",width:5,title:o==null?void 0:o.columnLabel,render:()=>n.jsx(Ot,{tooltip:o==null?void 0:o.tooltip})}),s.push(...p),t&&t&&s.push({title:H("str.action"),fixed:"right",width:a,render:(c,r)=>n.jsxs(n.Fragment,{children:[f&&n.jsx(Tt,{value:r,onClick:E}),_(r)]})}),s},[p,y,h,l,C,f,H,a,_]),tt=u.useMemo(()=>q.map(t=>t[e]),[q,e]),it=u.useCallback(()=>{const t=n.jsx(Dt,{...b,dataSource:q,loading:v,components:o?{body:{row:zt}}:void 0,pagination:F,columns:g});return o?n.jsx(jt.DndContext,{modifiers:[lt.restrictToVerticalAxis],onDragEnd:d,children:n.jsx(M.SortableContext,{items:tt,strategy:M.verticalListSortingStrategy,children:t})}):t},[b,q,v,F,g,o,tt,d]);return n.jsxs("div",{children:[f&&n.jsx(xt.Modal,{width:"100%",open:!!i,title:ct??n.jsx("div",{children:" "}),footer:n.jsx(n.Fragment,{}),closable:!0,onCancel:()=>E(void 0),children:!!i&&n.jsxs("div",{children:[n.jsx(Et.CrudDecListView,{layout:rt,descListColumn:ot,data:i,fields:m,action:_(i)}),D==null?void 0:D(i)]},i==null?void 0:i[e])}),n.jsx(Vt,{fields:m,...ut}),n.jsxs(wt,{children:[!!Y&&n.jsx(Ct.RefreshButton,{onClick:Y}),it()]})]})}const st=u.createContext({}),Ot=({tooltip:e})=>{const{setActivatorNodeRef:v,listeners:m}=u.useContext(st);return n.jsx(qt,{type:"text",size:"small",tooltip:e,icon:n.jsx(Nt.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:v,...m})},zt=e=>{const{attributes:v,listeners:m,setNodeRef:I,setActivatorNodeRef:S,transform:f,transition:j,isDragging:l}=M.useSortable({id:e["data-row-key"]}),T={...e.style,transform:ht.CSS.Translate.toString(f),transition:j,...l?{position:"relative",zIndex:9999}:{}},y=u.useMemo(()=>({setActivatorNodeRef:S,listeners:m}),[S,m]);return n.jsx(st.Provider,{value:y,children:n.jsx("tr",{...e,ref:I,style:T,...v})})};module.exports=Lt;
|