@kingteza/crud-component 1.29.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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.d.ts +7 -5
- 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/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 +127 -105
- 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.d.ts +2 -2
- 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,171 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { jsx as x, jsxs as Z } from "react/jsx-runtime";
|
|
2
|
+
import { Form as z, Modal as ee, Spin as te } from "antd";
|
|
3
|
+
import { forwardRef as oe, useState as c, useCallback as m, useMemo as ae, useImperativeHandle as ne, useEffect as le } from "react";
|
|
4
|
+
import { CrudForm as se } from "../CrudForm.es.js";
|
|
5
|
+
import ie from "../CrudFormWizard.es.js";
|
|
6
|
+
import { useTranslationLib as re } from "../../locale/index.es.js";
|
|
7
|
+
import v from "../../util/CrudUtil.es.js";
|
|
8
|
+
import ce from "dayjs";
|
|
9
|
+
import { setValueByPath as d, getValueByPath as ue } from "../../util/ObjectUtil.es.js";
|
|
10
|
+
const de = ({
|
|
11
|
+
fields: n,
|
|
12
|
+
wizard: s,
|
|
13
|
+
grid: A,
|
|
14
|
+
fullWidthModal: L,
|
|
15
|
+
isCreating: C,
|
|
16
|
+
isUpdating: j,
|
|
17
|
+
onCreate: B,
|
|
18
|
+
onUpdate: V,
|
|
19
|
+
idField: h = "id",
|
|
20
|
+
formBuilder: E,
|
|
21
|
+
onValuesChange: R
|
|
22
|
+
}, $) => {
|
|
23
|
+
const [a] = z.useForm(), { t: N } = re(), [k, y] = c(!1), [p, w] = c("new"), [f, g] = c(), [q, b] = c(), [G, O] = c(!1), [J, M] = c(!1), [K, W] = c(!1), D = m(
|
|
24
|
+
async (o) => {
|
|
25
|
+
var F;
|
|
26
|
+
const u = s ? o : await a.validateFields(), i = n.filter((t) => t.type === "color"), l = {};
|
|
27
|
+
for (const t of i) {
|
|
28
|
+
const r = v.getRealName(t.name, "upsertFieldName"), e = a.getFieldValue(r);
|
|
29
|
+
d(
|
|
30
|
+
l,
|
|
31
|
+
r,
|
|
32
|
+
typeof e == "string" ? e : (F = e == null ? void 0 : e.toHexString()) == null ? void 0 : F.toUpperCase()
|
|
33
|
+
);
|
|
29
34
|
}
|
|
30
|
-
Object.assign(
|
|
31
|
-
...
|
|
32
|
-
[
|
|
33
|
-
}),
|
|
35
|
+
Object.assign(u, l), f && V ? (await V({
|
|
36
|
+
...u,
|
|
37
|
+
[h]: f[h]
|
|
38
|
+
}), g(void 0)) : !f && B && await B(u), b(void 0), S(/* @__PURE__ */ new Map()), a.resetFields(), y(!1);
|
|
34
39
|
},
|
|
35
|
-
[
|
|
36
|
-
),
|
|
37
|
-
|
|
38
|
-
}, []),
|
|
39
|
-
|
|
40
|
-
}, []),
|
|
41
|
-
|
|
42
|
-
}, [
|
|
43
|
-
|
|
40
|
+
[n, a, h, B, V, f, s]
|
|
41
|
+
), H = m(async (o) => {
|
|
42
|
+
O(o), M(!0);
|
|
43
|
+
}, []), I = m(async () => {
|
|
44
|
+
M(!0);
|
|
45
|
+
}, []), T = m(() => {
|
|
46
|
+
y(!0), w("new"), a.resetFields(), g(void 0), b(void 0);
|
|
47
|
+
}, [a]), [P, S] = c(/* @__PURE__ */ new Map()), Q = ae(() => P.size === 0 ? n : n.map((o) => typeof o.updatable == "function" ? {
|
|
48
|
+
...o,
|
|
49
|
+
updatable: P.get(v.getRealName(o.name, "name")) ?? o.updatable
|
|
50
|
+
} : o), [n, P]), _ = m(
|
|
51
|
+
async (o, u = !0, i = !1) => {
|
|
44
52
|
try {
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
for (const
|
|
48
|
-
const
|
|
49
|
-
|
|
53
|
+
W(!0), y(!0), w(i ? "clone" : "update");
|
|
54
|
+
const l = {};
|
|
55
|
+
for (const t of n) {
|
|
56
|
+
const r = v.getRealName(
|
|
57
|
+
t.name,
|
|
50
58
|
"upsertFieldName"
|
|
51
|
-
), e =
|
|
52
|
-
if (
|
|
53
|
-
const
|
|
59
|
+
), e = ue(o, r);
|
|
60
|
+
if (i && t.type === "image") {
|
|
61
|
+
const U = e;
|
|
54
62
|
try {
|
|
55
|
-
const
|
|
56
|
-
|
|
63
|
+
const Y = await t.provider.clone(U);
|
|
64
|
+
d(l, r, Y);
|
|
57
65
|
continue;
|
|
58
66
|
} catch {
|
|
59
67
|
continue;
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
t.type === "date" || t.type === "time" ? e && d(l, r, ce(e)) : t.type === "select" ? t.multiple && Array.isArray(e) ? d(
|
|
71
|
+
l,
|
|
72
|
+
r,
|
|
73
|
+
e.map((U) => U[t.innerFieldId ?? "id"])
|
|
74
|
+
) : e && typeof e == "object" ? d(
|
|
75
|
+
l,
|
|
76
|
+
r,
|
|
77
|
+
e[t.innerFieldId ?? "id"]
|
|
78
|
+
) : (e && typeof e == "string" || typeof e == "number") && d(l, r, e) : d(l, r, e);
|
|
65
79
|
}
|
|
66
|
-
|
|
80
|
+
a.setFieldsValue(l);
|
|
81
|
+
const F = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const t of n)
|
|
83
|
+
typeof t.updatable == "function" && F.set(
|
|
84
|
+
v.getRealName(t.name, "name"),
|
|
85
|
+
t.updatable(o)
|
|
86
|
+
);
|
|
87
|
+
S(F), b(l), u && g(o);
|
|
67
88
|
} finally {
|
|
68
|
-
|
|
89
|
+
W(!1);
|
|
69
90
|
}
|
|
70
91
|
},
|
|
71
|
-
[
|
|
92
|
+
[n, a]
|
|
72
93
|
);
|
|
73
|
-
|
|
74
|
-
|
|
94
|
+
ne(
|
|
95
|
+
$,
|
|
75
96
|
() => ({
|
|
76
|
-
create:
|
|
77
|
-
update:
|
|
97
|
+
create: T,
|
|
98
|
+
update: _
|
|
78
99
|
}),
|
|
79
|
-
[
|
|
80
|
-
),
|
|
81
|
-
k && (
|
|
100
|
+
[T, _]
|
|
101
|
+
), le(() => {
|
|
102
|
+
k && (O(!1), M(!1));
|
|
82
103
|
}, [k]);
|
|
83
|
-
const
|
|
104
|
+
const X = m(async () => {
|
|
105
|
+
S(/* @__PURE__ */ new Map());
|
|
84
106
|
try {
|
|
85
107
|
if (p === "clone") {
|
|
86
|
-
const
|
|
87
|
-
for (const
|
|
88
|
-
i
|
|
108
|
+
const o = s ? f : a.getFieldsValue(), u = n.filter((i) => i.type === "image");
|
|
109
|
+
for (const i of u)
|
|
110
|
+
o[i.name] && i.provider.delete(o[i.name]);
|
|
89
111
|
}
|
|
90
112
|
} finally {
|
|
91
113
|
}
|
|
92
|
-
|
|
93
|
-
}, [p,
|
|
94
|
-
return /* @__PURE__ */
|
|
95
|
-
|
|
114
|
+
s || a.resetFields(), b(void 0), g(void 0), y(!1);
|
|
115
|
+
}, [p, s, a, f, n]);
|
|
116
|
+
return /* @__PURE__ */ x(
|
|
117
|
+
ee,
|
|
96
118
|
{
|
|
97
|
-
width:
|
|
98
|
-
title:
|
|
119
|
+
width: L ? "100%" : void 0,
|
|
120
|
+
title: N("str." + (p ?? "new")),
|
|
99
121
|
open: k,
|
|
100
|
-
confirmLoading:
|
|
101
|
-
okText:
|
|
102
|
-
cancelText:
|
|
122
|
+
confirmLoading: C || j,
|
|
123
|
+
okText: N("str." + (p === "update" ? "update" : "save")),
|
|
124
|
+
cancelText: N("str.cancel"),
|
|
103
125
|
cancelButtonProps: {
|
|
104
|
-
disabled:
|
|
105
|
-
hidden: !!
|
|
126
|
+
disabled: J,
|
|
127
|
+
hidden: !!s
|
|
106
128
|
},
|
|
107
129
|
okButtonProps: {
|
|
108
|
-
disabled:
|
|
109
|
-
hidden: !!
|
|
130
|
+
disabled: G,
|
|
131
|
+
hidden: !!s
|
|
110
132
|
},
|
|
111
|
-
onCancel:
|
|
112
|
-
onOk: () =>
|
|
133
|
+
onCancel: X,
|
|
134
|
+
onOk: () => D(),
|
|
113
135
|
destroyOnHidden: !0,
|
|
114
|
-
children: /* @__PURE__ */
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
children: /* @__PURE__ */ Z(te, { spinning: K, children: [
|
|
137
|
+
s ? null : /* @__PURE__ */ x(
|
|
138
|
+
se,
|
|
117
139
|
{
|
|
118
140
|
purpose: p,
|
|
119
|
-
fields:
|
|
120
|
-
form:
|
|
121
|
-
formBuilder:
|
|
122
|
-
grid:
|
|
123
|
-
onDeleteFile:
|
|
124
|
-
onUploadFile:
|
|
125
|
-
onValuesChange:
|
|
141
|
+
fields: Q,
|
|
142
|
+
form: a,
|
|
143
|
+
formBuilder: E,
|
|
144
|
+
grid: A,
|
|
145
|
+
onDeleteFile: I,
|
|
146
|
+
onUploadFile: H,
|
|
147
|
+
onValuesChange: R
|
|
126
148
|
}
|
|
127
149
|
),
|
|
128
|
-
|
|
129
|
-
|
|
150
|
+
s && /* @__PURE__ */ x(
|
|
151
|
+
ie,
|
|
130
152
|
{
|
|
131
|
-
submitting:
|
|
153
|
+
submitting: C || j,
|
|
132
154
|
className: "mt-2",
|
|
133
|
-
onSave:
|
|
134
|
-
updatingValue:
|
|
135
|
-
fields:
|
|
136
|
-
onDeleteFile:
|
|
137
|
-
onUploadFile:
|
|
155
|
+
onSave: D,
|
|
156
|
+
updatingValue: q,
|
|
157
|
+
fields: n,
|
|
158
|
+
onDeleteFile: I,
|
|
159
|
+
onUploadFile: H,
|
|
138
160
|
purpose: p,
|
|
139
|
-
wizard:
|
|
140
|
-
onValuesChange:
|
|
161
|
+
wizard: s,
|
|
162
|
+
onValuesChange: R
|
|
141
163
|
}
|
|
142
164
|
)
|
|
143
165
|
] })
|
|
144
166
|
}
|
|
145
167
|
);
|
|
146
|
-
},
|
|
168
|
+
}, Ve = oe(de);
|
|
147
169
|
export {
|
|
148
|
-
|
|
170
|
+
Ve as default
|
|
149
171
|
};
|
|
@@ -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
|
};
|
|
@@ -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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("@ant-design/icons"),b=require("antd"),B=require("../FileCrudField.cjs.js"),W=require("../ImageCrudField.cjs.js"),C=require("../../util/DateUtil.cjs.js"),v=require("../../util/NumberUtil.cjs.js"),T=require("../../locale/index.cjs.js"),F=require("../../util/CrudUtil.cjs.js"),h=require("../../common/error/ErrorBoundaryComponent.cjs.js"),i=require("../../util/CopyUtilComponent.cjs.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("@ant-design/icons"),b=require("antd"),B=require("../FileCrudField.cjs.js"),W=require("../ImageCrudField.cjs.js"),C=require("../../util/DateUtil.cjs.js"),v=require("../../util/NumberUtil.cjs.js"),T=require("../../locale/index.cjs.js"),F=require("../../util/CrudUtil.cjs.js"),h=require("../../common/error/ErrorBoundaryComponent.cjs.js"),i=require("../../util/CopyUtilComponent.cjs.js"),q=require("../../util/ObjectUtil.cjs.js");function S({type:d,render:e,...p}){try{return d==="object"?(o,n,a)=>t.jsx(i.CopyToClipboardButtonWrapper,{copyable:p.copyable,value:o,children:typeof e=="function"?e(o,n,a):""}):d==="select"?(o,n,a)=>{if(!o)return"-";const r=p,c=o||(r.items??[]).find(s=>s[r.innerFieldId??"key"]===q.getValueByPath(n,F.getRealName(p.name,"upsertFieldName"))),u=r.multiple?Array.isArray(c)?c.map(s=>s==null?void 0:s[r.innerFieldLabel??"name"]):void 0:c==null?void 0:c[r.innerFieldLabel??"value"];return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,u),children:typeof e=="function"?e(u,n,a):Array.isArray(u)?u.join(", "):u})}:d==="number"?(o,n,a)=>{const r=p;return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,o),children:typeof e=="function"?e(o,n,a):r.int?v.default.toInt(o,r.formatted):v.default.toMoney(o)})}:d==="enum"?(o,n,a)=>{var s;if(!o)return"-";const r=p;if(typeof e=="function")return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:e(o,n,a)});if(r.multiple){const f=(Array.isArray(o)?o:o?[o]:[]).map(l=>{var j,m;const y=(j=r.tagRender)==null?void 0:j[l],x=T.tWithOrWithoutNS(((m=r==null?void 0:r.translation)==null?void 0:m[l??""])??l,void 0,l);return{tagProps:y,translatedValue:x,item:l}});if(typeof r.tagRender=="object")return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:()=>f.map(({translatedValue:l,item:y})=>l??y).join(", "),children:t.jsx(h.ErrorBoundaryComponent,{children:t.jsx(b.Space,{wrap:!0,children:f.map(({tagProps:l,translatedValue:y,item:x},j)=>l?t.jsx(b.Tag,{color:l.color,children:y},j+x):y)})})});if(r!=null&&r.translation)return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:()=>f.map(({translatedValue:l,item:y})=>l??y).join(", "),children:t.jsx(h.ErrorBoundaryComponent,{children:f==null?void 0:f.map(({translatedValue:l,item:y})=>l??y).join(", ")})});{const l=f.map(({translatedValue:y,item:x})=>y??x).join(", ");return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,l),children:l})}}const c=((s=r==null?void 0:r.translation)==null?void 0:s[o??""])??o,u=T.tWithOrWithoutNS(c,void 0,o);if(typeof r.tagRender=="object"){const f=r.tagRender[o];if(f)return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:u,children:t.jsx(b.Tag,{color:f.color,children:u})})}return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,u),children:u})}:d==="date"?(o,n,a)=>{if(!o)return"-";const r=p,c=r.formatTime?C.formatDateTime(o):C.formatDate(o);return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:c,children:t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):c})})}:d==="checkbox"?(o,n,a)=>typeof e=="function"?e(o,n,a):o?t.jsx(g.CheckOutlined,{}):t.jsx(g.CloseOutlined,{}):d==="image"?(o,n,a)=>o?t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):t.jsx(W.ImageCrudCellValue,{value:o,provider:p.provider})}):"-":d==="file"?(o,n,a)=>o?t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):t.jsx(B.FileCrudCellValue,{value:o,provider:p.provider})}):"":d==="time"?(o,n,a)=>{if(!o)return"-";const r=p,c=r.format,u=r.use12Hours,s=C.formatTime(o,c||(u?"hh:mm:ss A":void 0));return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:s,children:t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):s})})}:d==="color"?(o,n,a)=>{const r=p;return o?t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):typeof o=="string"&&o.startsWith("#")?t.jsx(b.Tooltip,{title:o,children:t.jsx(b.Avatar,{style:{backgroundColor:o}})}):String(o)})}):"-"}:d==="textarea"?(o,n,a)=>{if(!o)return"-";const r=p,c=r.truncated??1,u=typeof o=="string"&&o.split(" ").length<10;return typeof e=="function"?t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:e(o,n,a)}):c?t.jsx(h.ErrorBoundaryComponent,{children:t.jsx(b.Typography.Paragraph,{ellipsis:!u&&{rows:c===!0?1:c,expandable:"collapsible"},copyable:i.copyableFn(r.copyable,o),children:r.rich?t.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:o}}):o})}):r.rich?t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:t.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:o}})}):t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:o})}:typeof e=="function"?e:(o,n,a)=>{const r=p;return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,o),children:o})}}catch(o){return console.warn("An error occurred while rendering the value for field: "+String(p.name),o),"-"}}exports.getRendererValueCrudViewer=S;
|
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { CheckOutlined as S, CloseOutlined as F } from "@ant-design/icons";
|
|
3
|
-
import { Typography as
|
|
4
|
-
import { FileCrudCellValue as
|
|
5
|
-
import { ImageCrudCellValue as
|
|
3
|
+
import { Typography as h, Space as P, Tag as C, Tooltip as R, Avatar as V } from "antd";
|
|
4
|
+
import { FileCrudCellValue as w } from "../FileCrudField.es.js";
|
|
5
|
+
import { ImageCrudCellValue as I } from "../ImageCrudField.es.js";
|
|
6
6
|
import T from "../../util/DateUtil.es.js";
|
|
7
7
|
import j from "../../util/NumberUtil.es.js";
|
|
8
8
|
import { tWithOrWithoutNS as A } from "../../locale/index.es.js";
|
|
9
9
|
import k from "../../util/CrudUtil.es.js";
|
|
10
10
|
import { ErrorBoundaryComponent as b } from "../../common/error/ErrorBoundaryComponent.es.js";
|
|
11
|
-
import { CopyToClipboardButtonWrapper as m, copyableFn as
|
|
12
|
-
|
|
11
|
+
import { CopyToClipboardButtonWrapper as m, copyableFn as d } from "../../util/CopyUtilComponent.es.js";
|
|
12
|
+
import { getValueByPath as D } from "../../util/ObjectUtil.es.js";
|
|
13
|
+
function J({
|
|
13
14
|
type: y,
|
|
14
|
-
render:
|
|
15
|
+
render: e,
|
|
15
16
|
...u
|
|
16
17
|
}) {
|
|
17
18
|
try {
|
|
18
|
-
return y === "object" ? (t, l,
|
|
19
|
+
return y === "object" ? (t, l, n) => /* @__PURE__ */ r(
|
|
19
20
|
m,
|
|
20
21
|
{
|
|
21
22
|
copyable: u.copyable,
|
|
22
23
|
value: t,
|
|
23
|
-
children: typeof
|
|
24
|
+
children: typeof e == "function" ? e(t, l, n) : ""
|
|
24
25
|
}
|
|
25
|
-
) : y === "select" ? (t, l,
|
|
26
|
+
) : y === "select" ? (t, l, n) => {
|
|
26
27
|
if (!t) return "-";
|
|
27
28
|
const o = u, a = t || (o.items ?? []).find(
|
|
28
|
-
(f) => f[o.innerFieldId ?? "key"] === l
|
|
29
|
+
(f) => f[o.innerFieldId ?? "key"] === D(l, k.getRealName(u.name, "upsertFieldName"))
|
|
29
30
|
), c = o.multiple ? Array.isArray(a) ? a.map((f) => f == null ? void 0 : f[o.innerFieldLabel ?? "name"]) : void 0 : a == null ? void 0 : a[o.innerFieldLabel ?? "value"];
|
|
30
|
-
return /* @__PURE__ */ r(
|
|
31
|
-
} : y === "number" ? (t, l,
|
|
31
|
+
return /* @__PURE__ */ r(h.Text, { copyable: d(o.copyable, c), children: typeof e == "function" ? e(c, l, n) : Array.isArray(c) ? c.join(", ") : c });
|
|
32
|
+
} : y === "number" ? (t, l, n) => {
|
|
32
33
|
const o = u;
|
|
33
|
-
return /* @__PURE__ */ r(
|
|
34
|
-
} : y === "enum" ? (t, l,
|
|
34
|
+
return /* @__PURE__ */ r(h.Text, { copyable: d(o.copyable, t), children: typeof e == "function" ? e(t, l, n) : o.int ? j.toInt(t, o.formatted) : j.toMoney(t) });
|
|
35
|
+
} : y === "enum" ? (t, l, n) => {
|
|
35
36
|
var f;
|
|
36
37
|
if (!t) return "-";
|
|
37
38
|
const o = u;
|
|
38
|
-
if (typeof
|
|
39
|
+
if (typeof e == "function")
|
|
39
40
|
return /* @__PURE__ */ r(
|
|
40
41
|
m,
|
|
41
42
|
{
|
|
42
43
|
copyable: o.copyable,
|
|
43
44
|
value: t,
|
|
44
|
-
children:
|
|
45
|
+
children: e(t, l, n)
|
|
45
46
|
}
|
|
46
47
|
);
|
|
47
48
|
if (o.multiple) {
|
|
@@ -66,7 +67,7 @@ function z({
|
|
|
66
67
|
value: () => s.map(
|
|
67
68
|
({ translatedValue: i, item: p }) => i ?? p
|
|
68
69
|
).join(", "),
|
|
69
|
-
children: /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(
|
|
70
|
+
children: /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(P, { wrap: !0, children: s.map(({ tagProps: i, translatedValue: p, item: v }, g) => i ? /* @__PURE__ */ r(C, { color: i.color, children: p }, g + v) : p) }) })
|
|
70
71
|
}
|
|
71
72
|
);
|
|
72
73
|
if (o != null && o.translation)
|
|
@@ -85,9 +86,9 @@ function z({
|
|
|
85
86
|
{
|
|
86
87
|
const i = s.map(({ translatedValue: p, item: v }) => p ?? v).join(", ");
|
|
87
88
|
return /* @__PURE__ */ r(
|
|
88
|
-
|
|
89
|
+
h.Text,
|
|
89
90
|
{
|
|
90
|
-
copyable:
|
|
91
|
+
copyable: d(o.copyable, i),
|
|
91
92
|
children: i
|
|
92
93
|
}
|
|
93
94
|
);
|
|
@@ -106,8 +107,8 @@ function z({
|
|
|
106
107
|
}
|
|
107
108
|
);
|
|
108
109
|
}
|
|
109
|
-
return /* @__PURE__ */ r(
|
|
110
|
-
} : y === "date" ? (t, l,
|
|
110
|
+
return /* @__PURE__ */ r(h.Text, { copyable: d(o.copyable, c), children: c });
|
|
111
|
+
} : y === "date" ? (t, l, n) => {
|
|
111
112
|
if (!t) return "-";
|
|
112
113
|
const o = u, a = o.formatTime ? T.formatDateTime(t) : T.formatDate(t);
|
|
113
114
|
return /* @__PURE__ */ r(
|
|
@@ -115,22 +116,22 @@ function z({
|
|
|
115
116
|
{
|
|
116
117
|
copyable: o.copyable,
|
|
117
118
|
value: a,
|
|
118
|
-
children: /* @__PURE__ */ r(b, { children: typeof
|
|
119
|
+
children: /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : a })
|
|
119
120
|
}
|
|
120
121
|
);
|
|
121
|
-
} : y === "checkbox" ? (t, l,
|
|
122
|
-
|
|
122
|
+
} : y === "checkbox" ? (t, l, n) => typeof e == "function" ? e(t, l, n) : t ? /* @__PURE__ */ r(S, {}) : /* @__PURE__ */ r(F, {}) : y === "image" ? (t, l, n) => t ? /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : /* @__PURE__ */ r(
|
|
123
|
+
I,
|
|
123
124
|
{
|
|
124
125
|
value: t,
|
|
125
126
|
provider: u.provider
|
|
126
127
|
}
|
|
127
|
-
) }) : "-" : y === "file" ? (t, l,
|
|
128
|
-
|
|
128
|
+
) }) : "-" : y === "file" ? (t, l, n) => t ? /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : /* @__PURE__ */ r(
|
|
129
|
+
w,
|
|
129
130
|
{
|
|
130
131
|
value: t,
|
|
131
132
|
provider: u.provider
|
|
132
133
|
}
|
|
133
|
-
) }) : "" : y === "time" ? (t, l,
|
|
134
|
+
) }) : "" : y === "time" ? (t, l, n) => {
|
|
134
135
|
if (!t) return "-";
|
|
135
136
|
const o = u, a = o.format, c = o.use12Hours, f = T.formatTime(
|
|
136
137
|
t,
|
|
@@ -141,30 +142,30 @@ function z({
|
|
|
141
142
|
{
|
|
142
143
|
copyable: o.copyable,
|
|
143
144
|
value: f,
|
|
144
|
-
children: /* @__PURE__ */ r(b, { children: typeof
|
|
145
|
+
children: /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : f })
|
|
145
146
|
}
|
|
146
147
|
);
|
|
147
|
-
} : y === "color" ? (t, l,
|
|
148
|
+
} : y === "color" ? (t, l, n) => {
|
|
148
149
|
const o = u;
|
|
149
|
-
return t ? /* @__PURE__ */ r(m, { copyable: o.copyable, value: t, children: /* @__PURE__ */ r(b, { children: typeof
|
|
150
|
-
} : y === "textarea" ? (t, l,
|
|
150
|
+
return t ? /* @__PURE__ */ r(m, { copyable: o.copyable, value: t, children: /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ r(R, { title: t, children: /* @__PURE__ */ r(V, { style: { backgroundColor: t } }) }) : String(t) }) }) : "-";
|
|
151
|
+
} : y === "textarea" ? (t, l, n) => {
|
|
151
152
|
if (!t) return "-";
|
|
152
153
|
const o = u, a = o.truncated ?? 1, c = typeof t == "string" && t.split(" ").length < 10;
|
|
153
|
-
return typeof
|
|
154
|
+
return typeof e == "function" ? /* @__PURE__ */ r(
|
|
154
155
|
m,
|
|
155
156
|
{
|
|
156
157
|
copyable: o.copyable,
|
|
157
158
|
value: t,
|
|
158
|
-
children:
|
|
159
|
+
children: e(t, l, n)
|
|
159
160
|
}
|
|
160
161
|
) : a ? /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(
|
|
161
|
-
|
|
162
|
+
h.Paragraph,
|
|
162
163
|
{
|
|
163
164
|
ellipsis: !c && {
|
|
164
165
|
rows: a === !0 ? 1 : a,
|
|
165
166
|
expandable: "collapsible"
|
|
166
167
|
},
|
|
167
|
-
copyable:
|
|
168
|
+
copyable: d(o.copyable, t),
|
|
168
169
|
children: o.rich ? /* @__PURE__ */ r(
|
|
169
170
|
"div",
|
|
170
171
|
{
|
|
@@ -194,9 +195,9 @@ function z({
|
|
|
194
195
|
children: t
|
|
195
196
|
}
|
|
196
197
|
);
|
|
197
|
-
} : typeof
|
|
198
|
+
} : typeof e == "function" ? e : (t, l, n) => {
|
|
198
199
|
const o = u;
|
|
199
|
-
return /* @__PURE__ */ r(
|
|
200
|
+
return /* @__PURE__ */ r(h.Text, { copyable: d(o.copyable, t), children: t });
|
|
200
201
|
};
|
|
201
202
|
} catch (t) {
|
|
202
203
|
return console.warn(
|
|
@@ -206,5 +207,5 @@ function z({
|
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
export {
|
|
209
|
-
|
|
210
|
+
J as getRendererValueCrudViewer
|
|
210
211
|
};
|
package/dist/util/CrudUtil.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InitialCrudField, SelectCrudField } from '
|
|
1
|
+
import { InitialCrudField, SelectCrudField } from '../crud/CrudComponent';
|
|
2
2
|
declare class CrudUtil {
|
|
3
3
|
static getRealName<T>(name: InitialCrudField<T>["name"] | SelectCrudField<T>["name"], extract?: "name" | "upsertFieldName"): (string | number)[] | keyof T;
|
|
4
4
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(e,r){return typeof e!="object"||e===null?e:Array.isArray(r)?r.reduce((t,u)=>t[u],e):e[r]}function i(e,r,t){return typeof e!="object"||e===null?e:Array.isArray(r)?r.reduce((u,n)=>u[n],e):(e[r]=t,e)}exports.getValueByPath=y;exports.setValueByPath=i;
|