@kingteza/crud-component 1.27.3 → 1.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/rich/index.d.ts +2 -1
- package/dist/common/text-field/NumberField.cjs.js +1 -1
- package/dist/common/text-field/NumberField.es.js +17 -18
- package/dist/crud/CrudComponent.cjs.js +1 -1
- package/dist/crud/CrudComponent.d.ts +20 -9
- package/dist/crud/CrudComponent.es.js +73 -69
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +302 -286
- package/dist/crud/CrudForm.d.ts +2 -2
- package/dist/crud/CrudFormWizard.cjs.js +1 -1
- package/dist/crud/CrudFormWizard.d.ts +2 -2
- package/dist/crud/CrudFormWizard.es.js +82 -78
- package/dist/crud/CrudReportComponent.d.ts +5 -5
- package/dist/crud/CrudSearchComponent.d.ts +2 -2
- package/dist/crud/actions/index.cjs.js +1 -1
- package/dist/crud/actions/index.d.ts +3 -1
- package/dist/crud/actions/index.es.js +63 -61
- package/dist/crud/import/CrudImportComponent.d.ts +2 -2
- package/dist/crud/index.d.ts +1 -1
- package/dist/crud/modal/index.cjs.js +1 -1
- package/dist/crud/modal/index.d.ts +2 -2
- package/dist/crud/modal/index.es.js +101 -96
- package/dist/crud/view/CrudDecListView.cjs.js +1 -1
- package/dist/crud/view/CrudDecListView.d.ts +2 -2
- package/dist/crud/view/CrudDecListView.es.js +31 -30
- package/dist/crud/view/CrudViewer.cjs.js +1 -1
- package/dist/crud/view/CrudViewer.d.ts +3 -3
- package/dist/crud/view/CrudViewer.es.js +190 -182
- package/dist/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/dist/crud/view/CrudViewerUtil.es.js +39 -38
- package/dist/util/CrudUtil.d.ts +1 -1
- package/dist/util/ObjectUtil.cjs.js +1 -0
- package/dist/util/ObjectUtil.d.ts +2 -0
- package/dist/util/ObjectUtil.es.js +10 -0
- package/package.json +1 -1
- package/dist/locale/index.d.ts +0 -86
|
@@ -1,149 +1,154 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Form as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { CrudForm as
|
|
5
|
-
import
|
|
6
|
-
import { useTranslationLib as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
1
|
+
import { jsx as P, jsxs as K } from "react/jsx-runtime";
|
|
2
|
+
import { Form as Q, Modal as X, Spin as Y } from "antd";
|
|
3
|
+
import { forwardRef as Z, useState as u, useCallback as F, useImperativeHandle as z, useEffect as ee } from "react";
|
|
4
|
+
import { CrudForm as te } from "../CrudForm.es.js";
|
|
5
|
+
import oe from "../CrudFormWizard.es.js";
|
|
6
|
+
import { useTranslationLib as ne } from "../../locale/index.es.js";
|
|
7
|
+
import T from "../../util/CrudUtil.es.js";
|
|
8
|
+
import se from "dayjs";
|
|
9
|
+
import { setValueByPath as p, getValueByPath as ae } from "../../util/ObjectUtil.es.js";
|
|
10
|
+
const le = ({
|
|
10
11
|
fields: c,
|
|
11
|
-
wizard:
|
|
12
|
-
grid:
|
|
13
|
-
fullWidthModal:
|
|
14
|
-
isCreating:
|
|
15
|
-
isUpdating:
|
|
16
|
-
onCreate:
|
|
17
|
-
onUpdate:
|
|
18
|
-
idField:
|
|
19
|
-
formBuilder:
|
|
20
|
-
onValuesChange:
|
|
21
|
-
},
|
|
22
|
-
const [t] =
|
|
12
|
+
wizard: a,
|
|
13
|
+
grid: W,
|
|
14
|
+
fullWidthModal: _,
|
|
15
|
+
isCreating: S,
|
|
16
|
+
isUpdating: x,
|
|
17
|
+
onCreate: b,
|
|
18
|
+
onUpdate: B,
|
|
19
|
+
idField: h = "id",
|
|
20
|
+
formBuilder: A,
|
|
21
|
+
onValuesChange: C
|
|
22
|
+
}, L) => {
|
|
23
|
+
const [t] = Q.useForm(), { t: k } = ne(), [V, y] = u(!1), [f, j] = u("new"), [m, g] = u(), [E, v] = u(), [$, U] = u(!1), [q, N] = u(!1), [w, O] = u(!1), D = F(
|
|
23
24
|
async (i) => {
|
|
24
25
|
var o;
|
|
25
|
-
const d =
|
|
26
|
-
for (const s of
|
|
27
|
-
const e =
|
|
28
|
-
|
|
26
|
+
const d = a ? i : await t.validateFields(), l = c.filter((s) => s.type === "color"), n = {};
|
|
27
|
+
for (const s of l) {
|
|
28
|
+
const e = T.getRealName(s.name, "upsertFieldName"), r = t.getFieldValue(e);
|
|
29
|
+
p(
|
|
30
|
+
n,
|
|
31
|
+
e,
|
|
32
|
+
typeof r == "string" ? r : (o = r == null ? void 0 : r.toHexString()) == null ? void 0 : o.toUpperCase()
|
|
33
|
+
);
|
|
29
34
|
}
|
|
30
|
-
Object.assign(d, n),
|
|
35
|
+
Object.assign(d, n), m && B ? (await B({
|
|
31
36
|
...d,
|
|
32
|
-
[
|
|
33
|
-
}),
|
|
37
|
+
[h]: m[h]
|
|
38
|
+
}), g(void 0)) : !m && b && await b(d), v(void 0), t.resetFields(), y(!1);
|
|
34
39
|
},
|
|
35
|
-
[c, t,
|
|
36
|
-
),
|
|
37
|
-
|
|
38
|
-
}, []),
|
|
40
|
+
[c, t, h, b, B, m, a]
|
|
41
|
+
), H = F(async (i) => {
|
|
42
|
+
U(i), N(!0);
|
|
43
|
+
}, []), I = F(async () => {
|
|
39
44
|
N(!0);
|
|
40
|
-
}, []),
|
|
41
|
-
|
|
42
|
-
}, [t]),
|
|
43
|
-
async (i, d = !0,
|
|
45
|
+
}, []), M = F(() => {
|
|
46
|
+
y(!0), j("new"), t.resetFields(), g(void 0), v(void 0);
|
|
47
|
+
}, [t]), R = F(
|
|
48
|
+
async (i, d = !0, l = !1) => {
|
|
44
49
|
try {
|
|
45
|
-
|
|
50
|
+
O(!0), y(!0), j(l ? "clone" : "update");
|
|
46
51
|
const n = {};
|
|
47
52
|
for (const o of c) {
|
|
48
|
-
const s =
|
|
53
|
+
const s = T.getRealName(
|
|
49
54
|
o.name,
|
|
50
55
|
"upsertFieldName"
|
|
51
|
-
), e = i
|
|
52
|
-
if (
|
|
56
|
+
), e = ae(i, s);
|
|
57
|
+
if (l && o.type === "image") {
|
|
53
58
|
const r = e;
|
|
54
59
|
try {
|
|
55
|
-
const
|
|
56
|
-
n
|
|
60
|
+
const J = await o.provider.clone(r);
|
|
61
|
+
p(n, s, J);
|
|
57
62
|
continue;
|
|
58
63
|
} catch {
|
|
59
64
|
continue;
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
|
-
o.type === "date" || o.type === "time" ? e && (n
|
|
67
|
+
o.type === "date" || o.type === "time" ? e && p(n, s, se(e)) : o.type === "select" ? o.multiple && Array.isArray(e) ? p(n, s, e.map(
|
|
63
68
|
(r) => r[o.innerFieldId ?? "id"]
|
|
64
|
-
) : e && typeof e == "object" ? n
|
|
69
|
+
)) : e && typeof e == "object" ? p(n, s, e[o.innerFieldId ?? "id"]) : (e && typeof e == "string" || typeof e == "number") && p(n, s, e) : p(n, s, e);
|
|
65
70
|
}
|
|
66
|
-
t.setFieldsValue(n),
|
|
71
|
+
t.setFieldsValue(n), v(n), d && g(i);
|
|
67
72
|
} finally {
|
|
68
|
-
|
|
73
|
+
O(!1);
|
|
69
74
|
}
|
|
70
75
|
},
|
|
71
76
|
[c, t]
|
|
72
77
|
);
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
z(
|
|
79
|
+
L,
|
|
75
80
|
() => ({
|
|
76
|
-
create:
|
|
77
|
-
update:
|
|
81
|
+
create: M,
|
|
82
|
+
update: R
|
|
78
83
|
}),
|
|
79
|
-
[
|
|
80
|
-
),
|
|
81
|
-
|
|
82
|
-
}, [
|
|
83
|
-
const
|
|
84
|
+
[M, R]
|
|
85
|
+
), ee(() => {
|
|
86
|
+
V && (U(!1), N(!1));
|
|
87
|
+
}, [V]);
|
|
88
|
+
const G = F(async () => {
|
|
84
89
|
try {
|
|
85
|
-
if (
|
|
86
|
-
const i =
|
|
87
|
-
for (const
|
|
88
|
-
i[
|
|
90
|
+
if (f === "clone") {
|
|
91
|
+
const i = a ? m : t.getFieldsValue(), d = c.filter((l) => l.type === "image");
|
|
92
|
+
for (const l of d)
|
|
93
|
+
i[l.name] && l.provider.delete(i[l.name]);
|
|
89
94
|
}
|
|
90
95
|
} finally {
|
|
91
96
|
}
|
|
92
|
-
|
|
93
|
-
}, [
|
|
94
|
-
return /* @__PURE__ */
|
|
95
|
-
|
|
97
|
+
a || t.resetFields(), v(void 0), g(void 0), y(!1);
|
|
98
|
+
}, [f, a, t, m, c]);
|
|
99
|
+
return /* @__PURE__ */ P(
|
|
100
|
+
X,
|
|
96
101
|
{
|
|
97
|
-
width:
|
|
98
|
-
title:
|
|
99
|
-
open:
|
|
100
|
-
confirmLoading:
|
|
101
|
-
okText:
|
|
102
|
-
cancelText:
|
|
102
|
+
width: _ ? "100%" : void 0,
|
|
103
|
+
title: k("str." + (f ?? "new")),
|
|
104
|
+
open: V,
|
|
105
|
+
confirmLoading: S || x,
|
|
106
|
+
okText: k("str." + (f === "update" ? "update" : "save")),
|
|
107
|
+
cancelText: k("str.cancel"),
|
|
103
108
|
cancelButtonProps: {
|
|
104
|
-
disabled:
|
|
105
|
-
hidden: !!
|
|
109
|
+
disabled: q,
|
|
110
|
+
hidden: !!a
|
|
106
111
|
},
|
|
107
112
|
okButtonProps: {
|
|
108
|
-
disabled:
|
|
109
|
-
hidden: !!
|
|
113
|
+
disabled: $,
|
|
114
|
+
hidden: !!a
|
|
110
115
|
},
|
|
111
|
-
onCancel:
|
|
112
|
-
onOk: () =>
|
|
116
|
+
onCancel: G,
|
|
117
|
+
onOk: () => D(),
|
|
113
118
|
destroyOnHidden: !0,
|
|
114
|
-
children: /* @__PURE__ */
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
children: /* @__PURE__ */ K(Y, { spinning: w, children: [
|
|
120
|
+
a ? null : /* @__PURE__ */ P(
|
|
121
|
+
te,
|
|
117
122
|
{
|
|
118
|
-
purpose:
|
|
123
|
+
purpose: f,
|
|
119
124
|
fields: c,
|
|
120
125
|
form: t,
|
|
121
|
-
formBuilder:
|
|
122
|
-
grid:
|
|
123
|
-
onDeleteFile:
|
|
124
|
-
onUploadFile:
|
|
125
|
-
onValuesChange:
|
|
126
|
+
formBuilder: A,
|
|
127
|
+
grid: W,
|
|
128
|
+
onDeleteFile: I,
|
|
129
|
+
onUploadFile: H,
|
|
130
|
+
onValuesChange: C
|
|
126
131
|
}
|
|
127
132
|
),
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
a && /* @__PURE__ */ P(
|
|
134
|
+
oe,
|
|
130
135
|
{
|
|
131
|
-
submitting:
|
|
136
|
+
submitting: S || x,
|
|
132
137
|
className: "mt-2",
|
|
133
|
-
onSave:
|
|
134
|
-
updatingValue:
|
|
138
|
+
onSave: D,
|
|
139
|
+
updatingValue: E,
|
|
135
140
|
fields: c,
|
|
136
|
-
onDeleteFile:
|
|
137
|
-
onUploadFile:
|
|
138
|
-
purpose:
|
|
139
|
-
wizard:
|
|
140
|
-
onValuesChange:
|
|
141
|
+
onDeleteFile: I,
|
|
142
|
+
onUploadFile: H,
|
|
143
|
+
purpose: f,
|
|
144
|
+
wizard: a,
|
|
145
|
+
onValuesChange: C
|
|
141
146
|
}
|
|
142
147
|
)
|
|
143
148
|
] })
|
|
144
149
|
}
|
|
145
150
|
);
|
|
146
|
-
},
|
|
151
|
+
}, ye = Z(le);
|
|
147
152
|
export {
|
|
148
|
-
|
|
153
|
+
ye as default
|
|
149
154
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),x=require("../../common/description/DescList.cjs.js"),j=require("react"),C=require("../../locale/index.cjs.js"),V=require("./CrudViewerUtil.cjs.js"),v=require("../../util/CrudUtil.cjs.js"),f=require("../actions/index.cjs.js"),p=require("../../util/ObjectUtil.cjs.js");function w({className:m,fields:i,data:e,descListColumn:a={xs:1,md:3,sm:2,lg:4},layout:d,keepEmptyValues:b,inBuiltModalProps:u,...s}){const{t:o}=C.useTranslationLib(),g=j.useMemo(()=>{const l=i.filter(({hidden:t,hideInDescList:n})=>!t&&!n).map((t,n)=>{const q=v.getRealName(t.name);return{label:t.label,noFormatting:!0,value:V.getRendererValueCrudViewer(t)(p.getValueByPath(e,q),e,n)}}),c=e?r.jsx(f,{data:e,...s,inBuiltModalProps:u?{...u,fields:i}:void 0}):void 0;return c&&l.push({label:o("str.action"),value:c}),l},[e,i,o,s]);return e?r.jsx(x,{keepEmptyValues:b,bordered:!0,column:a,className:m,layout:d,list:g}):r.jsx(r.Fragment,{})}exports.CrudDecListView=w;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Breakpoint } from 'antd';
|
|
2
|
-
import {
|
|
2
|
+
import { ReadonlyCrudFields } from '../CrudComponent';
|
|
3
3
|
import { CrudActionsProps } from '../actions';
|
|
4
4
|
import { CrudModalProps } from '../modal';
|
|
5
5
|
export type DescListColumn = number | Partial<Record<Breakpoint, number>> | undefined;
|
|
6
6
|
export interface CrudDecListViewProps<T, FormType = T> extends Omit<CrudActionsProps<T, FormType>, "inBuiltModalProps"> {
|
|
7
|
-
fields:
|
|
7
|
+
fields: ReadonlyCrudFields<T>;
|
|
8
8
|
data: T | undefined;
|
|
9
9
|
className?: string;
|
|
10
10
|
descListColumn?: DescListColumn;
|
|
@@ -1,57 +1,58 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { useTranslationLib as
|
|
5
|
-
import { getRendererValueCrudViewer as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
1
|
+
import { jsx as m, Fragment as C } from "react/jsx-runtime";
|
|
2
|
+
import d from "../../common/description/DescList.es.js";
|
|
3
|
+
import { useMemo as v } from "react";
|
|
4
|
+
import { useTranslationLib as V } from "../../locale/index.es.js";
|
|
5
|
+
import { getRendererValueCrudViewer as x } from "./CrudViewerUtil.es.js";
|
|
6
|
+
import F from "../../util/CrudUtil.es.js";
|
|
7
|
+
import L from "../actions/index.es.js";
|
|
8
|
+
import { getValueByPath as h } from "../../util/ObjectUtil.es.js";
|
|
9
|
+
function T({
|
|
9
10
|
className: p,
|
|
10
|
-
fields:
|
|
11
|
+
fields: t,
|
|
11
12
|
data: r,
|
|
12
|
-
descListColumn:
|
|
13
|
-
layout:
|
|
14
|
-
keepEmptyValues:
|
|
15
|
-
inBuiltModalProps:
|
|
13
|
+
descListColumn: f = { xs: 1, md: 3, sm: 2, lg: 4 },
|
|
14
|
+
layout: c,
|
|
15
|
+
keepEmptyValues: a,
|
|
16
|
+
inBuiltModalProps: i,
|
|
16
17
|
...n
|
|
17
18
|
}) {
|
|
18
|
-
const { t: u } =
|
|
19
|
-
const l =
|
|
20
|
-
const
|
|
19
|
+
const { t: u } = V(), g = v(() => {
|
|
20
|
+
const l = t.filter(({ hidden: e, hideInDescList: o }) => !e && !o).map((e, o) => {
|
|
21
|
+
const b = F.getRealName(e.name);
|
|
21
22
|
return {
|
|
22
23
|
label: e.label,
|
|
23
24
|
noFormatting: !0,
|
|
24
|
-
value:
|
|
25
|
-
r
|
|
25
|
+
value: x(e)(
|
|
26
|
+
h(r, b),
|
|
26
27
|
r,
|
|
27
|
-
|
|
28
|
+
o
|
|
28
29
|
)
|
|
29
30
|
};
|
|
30
|
-
}), s = r ? /* @__PURE__ */
|
|
31
|
-
|
|
31
|
+
}), s = r ? /* @__PURE__ */ m(
|
|
32
|
+
L,
|
|
32
33
|
{
|
|
33
34
|
data: r,
|
|
34
35
|
...n,
|
|
35
|
-
inBuiltModalProps:
|
|
36
|
+
inBuiltModalProps: i ? { ...i, fields: t } : void 0
|
|
36
37
|
}
|
|
37
38
|
) : void 0;
|
|
38
39
|
return s && l.push({
|
|
39
40
|
label: u("str.action"),
|
|
40
41
|
value: s
|
|
41
42
|
}), l;
|
|
42
|
-
}, [r,
|
|
43
|
-
return r ? /* @__PURE__ */
|
|
44
|
-
|
|
43
|
+
}, [r, t, u, n]);
|
|
44
|
+
return r ? /* @__PURE__ */ m(
|
|
45
|
+
d,
|
|
45
46
|
{
|
|
46
|
-
keepEmptyValues:
|
|
47
|
+
keepEmptyValues: a,
|
|
47
48
|
bordered: !0,
|
|
48
|
-
column:
|
|
49
|
+
column: f,
|
|
49
50
|
className: p,
|
|
50
|
-
layout:
|
|
51
|
+
layout: c,
|
|
51
52
|
list: g
|
|
52
53
|
}
|
|
53
|
-
) : /* @__PURE__ */
|
|
54
|
+
) : /* @__PURE__ */ m(C, {});
|
|
54
55
|
}
|
|
55
56
|
export {
|
|
56
|
-
|
|
57
|
+
T as CrudDecListView
|
|
57
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),qt=require("antd"),Ct=require("@dnd-kit/core"),St=require("@dnd-kit/modifiers"),It=require("@dnd-kit/utilities"),T=require("@dnd-kit/sortable"),Rt=require("../../common/button/Button.cjs.js"),lt=require("../../common/button/RefreshButton.cjs.js"),Mt=require("../../common/button/ViewButtonTable.cjs.js"),dt=require("../actions/index.cjs.js"),Tt=require("../../common/table/table.cjs.js"),s=require("react"),Vt=require("../../locale/index.cjs.js"),Bt=require("../CrudSearchComponent.cjs.js"),Dt=require("./CrudDecListView.cjs.js"),st=require("./CrudViewerUtil.cjs.js"),Ot=require("@ant-design/icons"),rt=require("../../util/CrudUtil.cjs.js"),Nt=require("../../common/layout/VerticalSpace.cjs.js"),kt=s.memo(Tt);function Et({summary:j,idField:o="id",loadingData:q,fields:h,isDeleting:l,isHiding:V,viewable:c=!1,paginateProps:f,onDelete:S,deletable:M,updatable:k,onHide:z,onUpdate:B,data:I=[],extraAction:D,onClickUpdate:O,minusHeight:E,scroll:$,onClickClone:A,className:_,expandable:G,size:J,bordered:K,descListColumn:ut,extraView:L,decListLayout:it,scrollToTop:zt,onClickRefresh:Q,closeViewOnClickUpdate:X,onExport:Y,confirmHiding:Z,confirmDeleting:W,rowClassName:P,actionWidth:H=190,draggable:t,rowSelection:U,...ft}){const{t:w}=Vt.useTranslationLib(),p=s.useMemo(()=>h.map(({hideInTable:e,hidden:r,width:u,label:m,halign:R,...C})=>{const N=rt.getRealName(C.name);return{title:m,width:u,key:N,dataIndex:N,hidden:e||r,align:R??(C.type==="number"?"right":void 0),render:st.getRendererValueCrudViewer(C),sorter:C.sorter,defaultSortOrder:C.defaultSortOrder}}),[h]),[i,d]=s.useState(),[F,a]=s.useState(),[y,b]=s.useState([]),mt=s.useCallback(e=>{d(e)},[]);s.useEffect(()=>{I&&b(I)},[I]),s.useEffect(()=>{I&&d(e=>{if(e)return I.find(r=>r[o]===e[o])})},[I,o,i]);const g=s.useCallback(e=>{var m;const{active:r,over:u}=e;if(t!=null&&t.onDragEnd&&(t==null||t.onDragEnd(e)),r.id!==(u==null?void 0:u.id)){const R=y.findIndex(x=>x[o]===r.id),C=y.findIndex(x=>x[o]===(u==null?void 0:u.id)),N=T.arrayMove(y,R,C);b(x=>{const ht=x.findIndex(v=>v[o]===(r==null?void 0:r.id)),yt=x.findIndex(v=>v[o]===(u==null?void 0:u.id));return T.arrayMove(x,ht,yt)}),(m=t==null?void 0:t.onDrag)==null||m.call(t,{newOrder:N.map(x=>x[o])})}},[y,o,t]),xt=s.useMemo(()=>{let e=typeof c=="string"?i==null?void 0:i[c]:void 0;if(typeof e=="object"){const r=h.find(u=>rt.getRealName(u.name)===c);e=st.getRendererValueCrudViewer(r)(e,i,0)}return e},[c,i,h]),tt=s.useMemo(()=>({rowSelection:U,rowClassName:P,className:_,scroll:$??(E?{y:`calc(100vh - ${E})`}:void 0),id:"crud-table",bordered:K,size:J,expandable:G}),[U,P,_,$,E,K,J,G]),et=s.useMemo(()=>f?{...f,total:f.count,onChange:f.setPage,current:f.page,pageSize:f.pageSize}:void 0,[f]),nt=s.useMemo(()=>{const e=B||O||S||D||c,r=[];return t&&r.push({key:"key",align:"center",width:5,title:t==null?void 0:t.columnLabel,render:()=>n.jsx(Lt,{tooltip:t==null?void 0:t.tooltip})}),r.push(...p),e&&e&&r.push({title:w("str.action"),fixed:"right",width:H,render:(u,m)=>n.jsxs(n.Fragment,{children:[c&&n.jsx(Mt,{value:m,onClick:typeof c=="object"?()=>{var R;return(R=c.onClick)==null?void 0:R.call(c,m)}:mt}),n.jsx(dt,{data:m,idField:o,extraAction:D,onUpdate:B,onClickUpdate:O,onClickClone:A,onDelete:S,deletable:M,updatable:k,onHide:z,onExport:Y,isHiding:V,isDeleting:l,confirmHiding:Z,confirmDeleting:W,closeViewOnClickUpdate:X,recentUpdateOrDeleteId:F,setRecentUpdateOrDeleteId:a,setOpenView:d})]})}),r},[p,B,O,S,M,k,D,c,w,H]),ot=s.useMemo(()=>y.map(e=>e[o]),[y,o]),jt=s.useCallback(()=>{const e=n.jsx(kt,{...tt,summary:j,dataSource:y,loading:q,components:t?{body:{row:vt}}:void 0,pagination:et,columns:nt});return t?n.jsx(Ct.DndContext,{modifiers:[St.restrictToVerticalAxis],onDragEnd:g,children:n.jsx(T.SortableContext,{items:ot,strategy:T.verticalListSortingStrategy,children:e})}):e},[tt,y,q,et,nt,j,t,ot,g]);return n.jsxs("div",{children:[(typeof c=="boolean"||typeof c=="string")&&n.jsx(qt.Modal,{width:"100%",open:!!i,title:xt??n.jsx("div",{children:" "}),footer:n.jsx(n.Fragment,{}),closable:!0,onCancel:()=>d(void 0),children:!!i&&n.jsxs("div",{children:[n.jsx(Dt.CrudDecListView,{layout:it,descListColumn:ut,data:i,fields:h,idField:o,extraAction:D,onUpdate:B,onClickUpdate:O,onClickClone:A,onDelete:S,deletable:M,updatable:k,onHide:z,onExport:Y,isHiding:V,isDeleting:l,confirmHiding:Z,confirmDeleting:W,closeViewOnClickUpdate:X,recentUpdateOrDeleteId:F,setRecentUpdateOrDeleteId:a,setOpenView:d}),L==null?void 0:L(i)]},i==null?void 0:i[o])}),n.jsx(Bt,{fields:h,...ft}),n.jsxs(Nt,{children:[!!Q&&n.jsx(lt.RefreshButton,{onClick:Q}),jt()]})]})}const ct=s.createContext({}),Lt=({tooltip:j})=>{const{setActivatorNodeRef:o,listeners:q}=s.useContext(ct);return n.jsx(Rt,{type:"text",size:"small",tooltip:j,icon:n.jsx(Ot.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:o,...q})},vt=j=>{const{attributes:o,listeners:q,setNodeRef:h,setActivatorNodeRef:l,transform:V,transition:c,isDragging:f}=T.useSortable({id:j["data-row-key"]}),S={...j.style,transform:It.CSS.Translate.toString(V),transition:c,...f?{position:"relative",zIndex:9999}:{}},M=s.useMemo(()=>({setActivatorNodeRef:l,listeners:q}),[l,q]);return n.jsx(ct.Provider,{value:M,children:n.jsx("tr",{...j,ref:h,style:S,...o})})};module.exports=Et;
|
|
@@ -4,7 +4,7 @@ import { DragEndEvent } from '@dnd-kit/core';
|
|
|
4
4
|
import { TableProps } from 'antd/lib';
|
|
5
5
|
import { CrudActionsProps } from '../actions';
|
|
6
6
|
import { default as React } from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { CrudPaginateProps, ReadonlyCrudFields } from '../CrudComponent';
|
|
8
8
|
import { CrudSearchComponentProps } from '../CrudSearchComponent';
|
|
9
9
|
import { DescListColumn } from './CrudDecListView';
|
|
10
10
|
type TableRowSelection<T> = TableProps<T>["rowSelection"];
|
|
@@ -21,7 +21,7 @@ export type CrudViewableProps<T> = boolean | keyof T | {
|
|
|
21
21
|
};
|
|
22
22
|
export type CrudViewerProps<T, FormType> = {
|
|
23
23
|
summary?: TableProps<T>["summary"];
|
|
24
|
-
fields:
|
|
24
|
+
fields: ReadonlyCrudFields<T>;
|
|
25
25
|
decListLayout?: "horizontal" | "vertical";
|
|
26
26
|
viewable?: CrudViewableProps<T>;
|
|
27
27
|
paginateProps?: CrudPaginateProps;
|
|
@@ -42,5 +42,5 @@ export type CrudViewerProps<T, FormType> = {
|
|
|
42
42
|
actionWidth?: string | number;
|
|
43
43
|
draggable?: CrudDragableProps<T>;
|
|
44
44
|
} & CrudActionsProps<T, FormType> & CrudSearchComponentProps<T, FormType>;
|
|
45
|
-
declare function CrudViewer<T, FormType = T>({ summary, idField, loadingData, fields, isDeleting, isHiding, viewable, paginateProps, onDelete, onHide, onUpdate, data, extraAction, onClickUpdate, minusHeight, scroll, onClickClone, className, expandable, size, bordered, descListColumn, extraView, decListLayout, scrollToTop, onClickRefresh, closeViewOnClickUpdate, onExport, confirmHiding, confirmDeleting, rowClassName, actionWidth, draggable, rowSelection, ...props }: CrudViewerProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
declare function CrudViewer<T, FormType = T>({ summary, idField, loadingData, fields, isDeleting, isHiding, viewable, paginateProps, onDelete, deletable, updatable, onHide, onUpdate, data, extraAction, onClickUpdate, minusHeight, scroll, onClickClone, className, expandable, size, bordered, descListColumn, extraView, decListLayout, scrollToTop, onClickRefresh, closeViewOnClickUpdate, onExport, confirmHiding, confirmDeleting, rowClassName, actionWidth, draggable, rowSelection, ...props }: CrudViewerProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
|
|
46
46
|
export default CrudViewer;
|