@kingteza/crud-component 1.0.60 → 1.0.61
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),b=require("@ant-design/icons"),m=require("antd"),A=require("../../common/show-more/index.cjs.js"),F=require("../FileCrudField.cjs.js"),S=require("../ImageCrudField.cjs.js"),y=require("../../util/DateUtil.cjs.js"),q=require("../../util/NumberUtil.cjs.js"),j=require("../../locale/index.cjs.js"),T=require("../../util/CrudUtil.cjs.js");function R({type:l,render:e,...u}){try{return l==="object"?(t,i,r)=>typeof e=="function"?e(t,i,r):"":l==="select"?(t,i,r)=>{if(!t)return"-";const n=u,o=t||(n.items??[]).find(s=>s[n.innerFieldId??"key"]===i[T.getRealName(u.name,"upsertFieldName")]),f=n.multiple?Array.isArray(o)?o.map(s=>s==null?void 0:s[n.innerFieldLabel??"name"]):void 0:o==null?void 0:o[n.innerFieldLabel??"value"];return typeof e=="function"?e(f,i,r):Array.isArray(f)?f.join(", "):f}:l==="number"?(t,i,r)=>typeof e=="function"?e(t,i,r):u!=null&&u.int?q.default.toInt(t,u.formatted):q.default.toMoney(t):l==="enum"?(t,i,r)=>{var s;if(!t)return"-";const n=u;if(typeof e=="function")return e(t,i,r);if(n.multiple){const c=Array.isArray(t)?t:t?[t]:[];return typeof n.tagRender=="object"?a.jsx(m.Space,{wrap:!0,children:c.map((d,g)=>{var x,C;const v=(x=n.tagRender)==null?void 0:x[d],h=j.t(((C=n==null?void 0:n.translation)==null?void 0:C[d??""])??d);return v?a.jsx(m.Tag,{color:v.color,children:h},g+d):h})}):n!=null&&n.translation?c==null?void 0:c.map(d=>{var g;return j.t(((g=n==null?void 0:n.translation)==null?void 0:g[d??""])??d)}).join(", "):c==null?void 0:c.join(", ")}const o=((s=n==null?void 0:n.translation)==null?void 0:s[t??""])??t,f=j.t(o);if(typeof n.tagRender=="object"){const c=n.tagRender[t];if(c)return a.jsx(m.Tag,{color:c.color,children:f})}return f}:l==="date"?(t,i,r)=>{if(!t)return"-";const n=u!=null&&u.formatTime?y.formatDateTime(t):y.formatDate(t);return typeof e=="function"?e(t,i,r):n}:l==="checkbox"?(t,i,r)=>typeof e=="function"?e(t,i,r):t?a.jsx(b.CheckOutlined,{}):a.jsx(b.CloseOutlined,{}):l==="image"?(t,i,r)=>t?typeof e=="function"?e(t,i,r):a.jsx(S.ImageCrudCellValue,{value:t,provider:u.provider}):"-":l==="file"?(t,i,r)=>t?typeof e=="function"?e(t,i,r):a.jsx(F.FileCrudCellValue,{value:t,provider:u.provider}):"":l==="time"?(t,i,r)=>{if(!t)return"-";const n=u==null?void 0:u.format,o=u==null?void 0:u.use12Hours,f=y.formatTime(t,n||(o?"hh:mm:ss A":void 0));return typeof e=="function"?e(t,i,r):f}:l==="color"?(t,i,r)=>t?typeof e=="function"?e(t,i,r):typeof t=="string"&&t.startsWith("#")?a.jsx(m.Tooltip,{title:t,children:a.jsx(m.Avatar,{style:{backgroundColor:t}})}):String(t):"-":l==="textarea"?(t,i,r)=>{if(!t)return"-";const n=u,o=n.truncated??1;return typeof e=="function"?e(t,i,r):o?a.jsx(A.ShowMore,{lines:o===!0?1:o,children:n.rich?a.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t}):n.rich?a.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t}:typeof e=="function"?e:(t,i,r)=>t}catch(t){return console.warn("An error occurred while rendering the value for field: "+String(u.name),t),"-"}}exports.getRendererValueCrudViewer=R;
|
|
@@ -11,65 +11,68 @@ import x from "../../util/CrudUtil.es.js";
|
|
|
11
11
|
function q({
|
|
12
12
|
type: u,
|
|
13
13
|
render: n,
|
|
14
|
-
...
|
|
14
|
+
...a
|
|
15
15
|
}) {
|
|
16
16
|
try {
|
|
17
|
-
return u === "object" ? (t, o,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
return u === "object" ? (t, o, r) => typeof n == "function" ? n(t, o, r) : "" : u === "select" ? (t, o, r) => {
|
|
18
|
+
if (!t) return "-";
|
|
19
|
+
const i = a, l = t || (i.items ?? []).find(
|
|
20
|
+
(m) => m[i.innerFieldId ?? "key"] === o[x.getRealName(a.name, "upsertFieldName")]
|
|
21
|
+
), c = i.multiple ? Array.isArray(l) ? l.map((m) => m == null ? void 0 : m[i.innerFieldLabel ?? "name"]) : void 0 : l == null ? void 0 : l[i.innerFieldLabel ?? "value"];
|
|
22
|
+
return typeof n == "function" ? n(c, o, r) : Array.isArray(c) ? c.join(", ") : c;
|
|
23
|
+
} : u === "number" ? (t, o, r) => typeof n == "function" ? n(t, o, r) : a != null && a.int ? j.toInt(t, a.formatted) : j.toMoney(t) : u === "enum" ? (t, o, r) => {
|
|
23
24
|
var m;
|
|
24
|
-
|
|
25
|
+
if (!t) return "-";
|
|
26
|
+
const i = a;
|
|
25
27
|
if (typeof n == "function")
|
|
26
|
-
return n(t, o,
|
|
28
|
+
return n(t, o, r);
|
|
27
29
|
if (i.multiple) {
|
|
28
|
-
const
|
|
29
|
-
return typeof i.tagRender == "object" ? /* @__PURE__ */ e(F, { wrap: !0, children:
|
|
30
|
+
const f = Array.isArray(t) ? t : t ? [t] : [];
|
|
31
|
+
return typeof i.tagRender == "object" ? /* @__PURE__ */ e(F, { wrap: !0, children: f.map((s, d) => {
|
|
30
32
|
var b, A;
|
|
31
33
|
const h = (b = i.tagRender) == null ? void 0 : b[s], v = y(
|
|
32
34
|
((A = i == null ? void 0 : i.translation) == null ? void 0 : A[s ?? ""]) ?? s
|
|
33
35
|
);
|
|
34
36
|
return h ? /* @__PURE__ */ e(C, { color: h.color, children: v }, d + s) : v;
|
|
35
|
-
}) }) : i != null && i.translation ?
|
|
37
|
+
}) }) : i != null && i.translation ? f == null ? void 0 : f.map((s) => {
|
|
36
38
|
var d;
|
|
37
39
|
return y(((d = i == null ? void 0 : i.translation) == null ? void 0 : d[s ?? ""]) ?? s);
|
|
38
|
-
}).join(", ") :
|
|
40
|
+
}).join(", ") : f == null ? void 0 : f.join(", ");
|
|
39
41
|
}
|
|
40
|
-
const l = ((m = i == null ? void 0 : i.translation) == null ? void 0 : m[t ?? ""]) ?? t,
|
|
42
|
+
const l = ((m = i == null ? void 0 : i.translation) == null ? void 0 : m[t ?? ""]) ?? t, c = y(l);
|
|
41
43
|
if (typeof i.tagRender == "object") {
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return /* @__PURE__ */ e(C, { color:
|
|
44
|
+
const f = i.tagRender[t];
|
|
45
|
+
if (f)
|
|
46
|
+
return /* @__PURE__ */ e(C, { color: f.color, children: c });
|
|
45
47
|
}
|
|
46
|
-
return
|
|
47
|
-
} : u === "date" ? (t, o,
|
|
48
|
+
return c;
|
|
49
|
+
} : u === "date" ? (t, o, r) => {
|
|
48
50
|
if (!t) return "-";
|
|
49
|
-
const i =
|
|
50
|
-
return typeof n == "function" ? n(t, o,
|
|
51
|
-
} : u === "checkbox" ? (t, o,
|
|
51
|
+
const i = a != null && a.formatTime ? g.formatDateTime(t) : g.formatDate(t);
|
|
52
|
+
return typeof n == "function" ? n(t, o, r) : i;
|
|
53
|
+
} : u === "checkbox" ? (t, o, r) => typeof n == "function" ? n(t, o, r) : t ? /* @__PURE__ */ e(S, {}) : /* @__PURE__ */ e(T, {}) : u === "image" ? (t, o, r) => t ? typeof n == "function" ? n(t, o, r) : /* @__PURE__ */ e(
|
|
52
54
|
k,
|
|
53
55
|
{
|
|
54
56
|
value: t,
|
|
55
|
-
provider:
|
|
57
|
+
provider: a.provider
|
|
56
58
|
}
|
|
57
|
-
) : u === "file" ? (t, o,
|
|
59
|
+
) : "-" : u === "file" ? (t, o, r) => t ? typeof n == "function" ? n(t, o, r) : /* @__PURE__ */ e(
|
|
58
60
|
V,
|
|
59
61
|
{
|
|
60
62
|
value: t,
|
|
61
|
-
provider:
|
|
63
|
+
provider: a.provider
|
|
62
64
|
}
|
|
63
|
-
) : u === "time" ? (t, o,
|
|
65
|
+
) : "" : u === "time" ? (t, o, r) => {
|
|
64
66
|
if (!t) return "-";
|
|
65
|
-
const i =
|
|
67
|
+
const i = a == null ? void 0 : a.format, l = a == null ? void 0 : a.use12Hours, c = g.formatTime(
|
|
66
68
|
t,
|
|
67
69
|
i || (l ? "hh:mm:ss A" : void 0)
|
|
68
70
|
);
|
|
69
|
-
return typeof n == "function" ? n(t, o,
|
|
70
|
-
} : u === "color" ? (t, o,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
return typeof n == "function" ? n(t, o, r) : c;
|
|
72
|
+
} : u === "color" ? (t, o, r) => t ? typeof n == "function" ? n(t, o, r) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ e(R, { title: t, children: /* @__PURE__ */ e(w, { style: { backgroundColor: t } }) }) : String(t) : "-" : u === "textarea" ? (t, o, r) => {
|
|
73
|
+
if (!t) return "-";
|
|
74
|
+
const i = a, l = i.truncated ?? 1;
|
|
75
|
+
return typeof n == "function" ? n(t, o, r) : l ? /* @__PURE__ */ e(I, { lines: l === !0 ? 1 : l, children: i.rich ? /* @__PURE__ */ e(
|
|
73
76
|
"div",
|
|
74
77
|
{
|
|
75
78
|
style: { all: "unset" },
|
|
@@ -82,10 +85,10 @@ function q({
|
|
|
82
85
|
dangerouslySetInnerHTML: { __html: t }
|
|
83
86
|
}
|
|
84
87
|
) : t;
|
|
85
|
-
} : typeof n == "function" ? n : (t, o,
|
|
88
|
+
} : typeof n == "function" ? n : (t, o, r) => t;
|
|
86
89
|
} catch (t) {
|
|
87
90
|
return console.warn(
|
|
88
|
-
"An error occurred while rendering the value for field: " + String(
|
|
91
|
+
"An error occurred while rendering the value for field: " + String(a.name),
|
|
89
92
|
t
|
|
90
93
|
), "-";
|
|
91
94
|
}
|