@kingteza/crud-component 1.3.0 → 1.4.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.cjs.js +1 -1
- package/dist/common/rich/index.d.ts +2 -1
- package/dist/common/rich/index.es.js +19 -18
- package/dist/common/select/SelectComponent.cjs.js +1 -1
- package/dist/common/select/SelectComponent.d.ts +1 -1
- package/dist/common/select/SelectComponent.es.js +22 -21
- package/dist/crud/CrudComponent.cjs.js +1 -1
- package/dist/crud/CrudComponent.d.ts +1 -0
- package/dist/crud/CrudComponent.es.js +44 -45
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +186 -182
- package/dist/crud/CrudTextAreaComponent.cjs.js +1 -1
- package/dist/crud/CrudTextAreaComponent.es.js +37 -35
- package/dist/crud/FileCrudField.d.ts +2 -1
- package/dist/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/dist/crud/view/CrudViewerUtil.es.js +22 -22
- package/package.json +1 -1
|
@@ -1,52 +1,54 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { RichTextEditor as
|
|
4
|
-
import { Form as
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import C from "../common/text-field/TextArea.es.js";
|
|
3
|
+
import { RichTextEditor as N } from "../common/rich/index.es.js";
|
|
4
|
+
import { Form as T } from "antd";
|
|
5
5
|
import F from "../util/CrudUtil.es.js";
|
|
6
|
-
const
|
|
7
|
-
onChange:
|
|
8
|
-
label:
|
|
9
|
-
required:
|
|
10
|
-
rules:
|
|
11
|
-
name:
|
|
6
|
+
const w = ({
|
|
7
|
+
onChange: t,
|
|
8
|
+
label: r,
|
|
9
|
+
required: m,
|
|
10
|
+
rules: i,
|
|
11
|
+
name: l,
|
|
12
12
|
updatable: s = !0,
|
|
13
|
-
...
|
|
13
|
+
...e
|
|
14
14
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
return /* @__PURE__ */
|
|
18
|
-
|
|
15
|
+
const f = T.useFormInstance(), n = F.getRealName(l, "upsertFieldName");
|
|
16
|
+
if (e.rich)
|
|
17
|
+
return /* @__PURE__ */ a(
|
|
18
|
+
N,
|
|
19
19
|
{
|
|
20
|
-
name:
|
|
21
|
-
label:
|
|
22
|
-
required:
|
|
23
|
-
rules:
|
|
24
|
-
disabled: !s
|
|
20
|
+
name: n,
|
|
21
|
+
label: r,
|
|
22
|
+
required: m,
|
|
23
|
+
rules: i,
|
|
24
|
+
disabled: !s,
|
|
25
|
+
help: e.fieldHelper
|
|
25
26
|
}
|
|
26
27
|
);
|
|
27
28
|
{
|
|
28
|
-
const { placeholder:
|
|
29
|
-
return /* @__PURE__ */
|
|
30
|
-
|
|
29
|
+
const { placeholder: c, rows: p, cols: u, fieldClassName: h, fieldTooltip: x } = e;
|
|
30
|
+
return /* @__PURE__ */ a(
|
|
31
|
+
C,
|
|
31
32
|
{
|
|
32
|
-
rules:
|
|
33
|
-
placeholder:
|
|
34
|
-
onChange:
|
|
35
|
-
var
|
|
36
|
-
return
|
|
33
|
+
rules: i,
|
|
34
|
+
placeholder: c,
|
|
35
|
+
onChange: t ? (o) => {
|
|
36
|
+
var d;
|
|
37
|
+
return t((d = o == null ? void 0 : o.target) == null ? void 0 : d.value, f);
|
|
37
38
|
} : void 0,
|
|
38
|
-
tooltip:
|
|
39
|
-
required:
|
|
39
|
+
tooltip: x,
|
|
40
|
+
required: m,
|
|
40
41
|
disabled: !s,
|
|
41
|
-
name:
|
|
42
|
-
label:
|
|
43
|
-
className:
|
|
42
|
+
name: l,
|
|
43
|
+
label: r,
|
|
44
|
+
className: h,
|
|
44
45
|
rows: p,
|
|
45
|
-
cols: u
|
|
46
|
+
cols: u,
|
|
47
|
+
help: e.fieldHelper
|
|
46
48
|
}
|
|
47
49
|
);
|
|
48
50
|
}
|
|
49
51
|
};
|
|
50
52
|
export {
|
|
51
|
-
|
|
53
|
+
w as default
|
|
52
54
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { InitialCrudField } from './CrudComponent';
|
|
3
3
|
import { FileDownloadProvider, FileUploadProvider } from './ImageCrudField';
|
|
4
4
|
export interface FileCrudField<T> extends _FileCrudField<T> {
|
|
@@ -12,6 +12,7 @@ export interface _FileCrudField<T> extends InitialCrudField<T> {
|
|
|
12
12
|
accept?: string;
|
|
13
13
|
maxCount?: number;
|
|
14
14
|
block?: boolean;
|
|
15
|
+
help?: ReactNode;
|
|
15
16
|
}
|
|
16
17
|
export default function FileCrudFieldComponent<T>({ name, label, required, provider, onUploading, onRemoved, fieldClassName, accept, rules, maxCount, block, fieldHelper: help, ...props }: Readonly<_FileCrudField<T>>): import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
export declare const FileCrudCellValue: FC<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),b=require("@ant-design/icons"),h=require("antd"),A=require("../../common/show-more/index.cjs.js"),F=require("../FileCrudField.cjs.js"),T=require("../ImageCrudField.cjs.js"),j=require("../../util/DateUtil.cjs.js"),q=require("../../util/NumberUtil.cjs.js"),g=require("../../locale/index.cjs.js"),B=require("../../util/CrudUtil.cjs.js"),m=require("../../common/error/ErrorBoundaryComponent.cjs.js");function R({type:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),b=require("@ant-design/icons"),h=require("antd"),A=require("../../common/show-more/index.cjs.js"),F=require("../FileCrudField.cjs.js"),T=require("../ImageCrudField.cjs.js"),j=require("../../util/DateUtil.cjs.js"),q=require("../../util/NumberUtil.cjs.js"),g=require("../../locale/index.cjs.js"),B=require("../../util/CrudUtil.cjs.js"),m=require("../../common/error/ErrorBoundaryComponent.cjs.js");function R({type:l,render:r,...i}){try{return l==="object"?(t,e,o)=>typeof r=="function"?r(t,e,o):"":l==="select"?(t,e,o)=>{if(!t)return"-";const n=i,a=t||(n.items??[]).find(s=>s[n.innerFieldId??"key"]===e[B.getRealName(i.name,"upsertFieldName")]),c=n.multiple?Array.isArray(a)?a.map(s=>s==null?void 0:s[n.innerFieldLabel??"name"]):void 0:a==null?void 0:a[n.innerFieldLabel??"value"];return typeof r=="function"?r(c,e,o):Array.isArray(c)?c.join(", "):c}:l==="number"?(t,e,o)=>typeof r=="function"?r(t,e,o):i!=null&&i.int?q.default.toInt(t,i.formatted):q.default.toMoney(t):l==="enum"?(t,e,o)=>{var s;if(!t)return"-";const n=i;if(typeof r=="function")return r(t,e,o);if(n.multiple){const f=Array.isArray(t)?t:t?[t]:[];return typeof n.tagRender=="object"?u.jsx(m.ErrorBoundaryComponent,{children:u.jsx(h.Space,{wrap:!0,children:f.map((d,y)=>{var v,S;const x=(v=n.tagRender)==null?void 0:v[d],C=g.tWithOrWithoutNS(((S=n==null?void 0:n.translation)==null?void 0:S[d??""])??d);return x?u.jsx(h.Tag,{color:x.color,children:C},y+d):C})})}):n!=null&&n.translation?u.jsx(m.ErrorBoundaryComponent,{children:f==null?void 0:f.map(d=>{var y;return g.tWithOrWithoutNS(((y=n==null?void 0:n.translation)==null?void 0:y[d??""])??d)}).join(", ")}):f==null?void 0:f.join(", ")}const a=((s=n==null?void 0:n.translation)==null?void 0:s[t??""])??t,c=g.tWithOrWithoutNS(a);if(typeof n.tagRender=="object"){const f=n.tagRender[t];if(f)return u.jsx(h.Tag,{color:f.color,children:c})}return c}:l==="date"?(t,e,o)=>{if(!t)return"-";const n=i!=null&&i.formatTime?j.formatDateTime(t):j.formatDate(t);return u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,e,o):n})}:l==="checkbox"?(t,e,o)=>typeof r=="function"?r(t,e,o):t?u.jsx(b.CheckOutlined,{}):u.jsx(b.CloseOutlined,{}):l==="image"?(t,e,o)=>t?u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,e,o):u.jsx(T.ImageCrudCellValue,{value:t,provider:i.provider})}):"-":l==="file"?(t,e,o)=>t?u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,e,o):u.jsx(F.FileCrudCellValue,{value:t,provider:i.provider})}):"":l==="time"?(t,e,o)=>{if(!t)return"-";const n=i==null?void 0:i.format,a=i==null?void 0:i.use12Hours,c=j.formatTime(t,n||(a?"hh:mm:ss A":void 0));return u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,e,o):c})}:l==="color"?(t,e,o)=>t?typeof r=="function"?r(t,e,o):typeof t=="string"&&t.startsWith("#")?u.jsx(h.Tooltip,{title:t,children:u.jsx(h.Avatar,{style:{backgroundColor:t}})}):String(t):"-":l==="textarea"?(t,e,o)=>{if(!t)return"-";const n=i,a=n.truncated??1;return typeof r=="function"?r(t,e,o):a?u.jsx(m.ErrorBoundaryComponent,{children:u.jsx(A.ShowMore,{lines:a===!0?1:a,children:n.rich?u.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t})}):n.rich?u.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t}:typeof r=="function"?r:(t,e,o)=>t}catch(t){return console.warn("An error occurred while rendering the value for field: "+String(i.name),t),"-"}}exports.getRendererValueCrudViewer=R;
|
|
@@ -4,24 +4,24 @@ import { Space as R, Tag as S, Tooltip as w, Avatar as I } from "antd";
|
|
|
4
4
|
import { ShowMore as V } from "../../common/show-more/index.es.js";
|
|
5
5
|
import { FileCrudCellValue as k } from "../FileCrudField.es.js";
|
|
6
6
|
import { ImageCrudCellValue as x } from "../ImageCrudField.es.js";
|
|
7
|
-
import
|
|
7
|
+
import y from "../../util/DateUtil.es.js";
|
|
8
8
|
import j from "../../util/NumberUtil.es.js";
|
|
9
|
-
import { tWithOrWithoutNS as
|
|
9
|
+
import { tWithOrWithoutNS as g } from "../../locale/index.es.js";
|
|
10
10
|
import H from "../../util/CrudUtil.es.js";
|
|
11
11
|
import { ErrorBoundaryComponent as h } from "../../common/error/ErrorBoundaryComponent.es.js";
|
|
12
12
|
function z({
|
|
13
|
-
type:
|
|
13
|
+
type: c,
|
|
14
14
|
render: i,
|
|
15
15
|
...l
|
|
16
16
|
}) {
|
|
17
17
|
try {
|
|
18
|
-
return
|
|
18
|
+
return c === "object" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : "" : c === "select" ? (t, o, r) => {
|
|
19
19
|
if (!t) return "-";
|
|
20
20
|
const n = l, a = t || (n.items ?? []).find(
|
|
21
21
|
(m) => m[n.innerFieldId ?? "key"] === o[H.getRealName(l.name, "upsertFieldName")]
|
|
22
|
-
),
|
|
23
|
-
return typeof i == "function" ? i(
|
|
24
|
-
} :
|
|
22
|
+
), u = n.multiple ? Array.isArray(a) ? a.map((m) => m == null ? void 0 : m[n.innerFieldLabel ?? "name"]) : void 0 : a == null ? void 0 : a[n.innerFieldLabel ?? "value"];
|
|
23
|
+
return typeof i == "function" ? i(u, o, r) : Array.isArray(u) ? u.join(", ") : u;
|
|
24
|
+
} : c === "number" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : l != null && l.int ? j.toInt(t, l.formatted) : j.toMoney(t) : c === "enum" ? (t, o, r) => {
|
|
25
25
|
var m;
|
|
26
26
|
if (!t) return "-";
|
|
27
27
|
const n = l;
|
|
@@ -31,50 +31,51 @@ function z({
|
|
|
31
31
|
const f = Array.isArray(t) ? t : t ? [t] : [];
|
|
32
32
|
return typeof n.tagRender == "object" ? /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(R, { wrap: !0, children: f.map((d, s) => {
|
|
33
33
|
var b, A;
|
|
34
|
-
const v = (b = n.tagRender) == null ? void 0 : b[d], C =
|
|
34
|
+
const v = (b = n.tagRender) == null ? void 0 : b[d], C = g(
|
|
35
35
|
((A = n == null ? void 0 : n.translation) == null ? void 0 : A[d ?? ""]) ?? d
|
|
36
36
|
);
|
|
37
37
|
return v ? /* @__PURE__ */ e(S, { color: v.color, children: C }, s + d) : C;
|
|
38
38
|
}) }) }) : n != null && n.translation ? /* @__PURE__ */ e(h, { children: f == null ? void 0 : f.map(
|
|
39
39
|
(d) => {
|
|
40
40
|
var s;
|
|
41
|
-
return
|
|
41
|
+
return g(((s = n == null ? void 0 : n.translation) == null ? void 0 : s[d ?? ""]) ?? d);
|
|
42
42
|
}
|
|
43
43
|
).join(", ") }) : f == null ? void 0 : f.join(", ");
|
|
44
44
|
}
|
|
45
|
-
const a = ((m = n == null ? void 0 : n.translation) == null ? void 0 : m[t ?? ""]) ?? t,
|
|
45
|
+
const a = ((m = n == null ? void 0 : n.translation) == null ? void 0 : m[t ?? ""]) ?? t, u = g(a);
|
|
46
46
|
if (typeof n.tagRender == "object") {
|
|
47
47
|
const f = n.tagRender[t];
|
|
48
48
|
if (f)
|
|
49
|
-
return /* @__PURE__ */ e(S, { color: f.color, children:
|
|
49
|
+
return /* @__PURE__ */ e(S, { color: f.color, children: u });
|
|
50
50
|
}
|
|
51
|
-
return
|
|
52
|
-
} :
|
|
51
|
+
return u;
|
|
52
|
+
} : c === "date" ? (t, o, r) => {
|
|
53
53
|
if (!t) return "-";
|
|
54
|
-
const n = l != null && l.formatTime ?
|
|
54
|
+
const n = l != null && l.formatTime ? y.formatDateTime(t) : y.formatDate(t);
|
|
55
55
|
return /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : n });
|
|
56
|
-
} :
|
|
56
|
+
} : c === "checkbox" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : t ? /* @__PURE__ */ e(T, {}) : /* @__PURE__ */ e(F, {}) : c === "image" ? (t, o, r) => t ? /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : /* @__PURE__ */ e(
|
|
57
57
|
x,
|
|
58
58
|
{
|
|
59
59
|
value: t,
|
|
60
60
|
provider: l.provider
|
|
61
61
|
}
|
|
62
|
-
) }) : "-" :
|
|
62
|
+
) }) : "-" : c === "file" ? (t, o, r) => t ? /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : /* @__PURE__ */ e(
|
|
63
63
|
k,
|
|
64
64
|
{
|
|
65
65
|
value: t,
|
|
66
66
|
provider: l.provider
|
|
67
67
|
}
|
|
68
|
-
) }) : "" :
|
|
68
|
+
) }) : "" : c === "time" ? (t, o, r) => {
|
|
69
69
|
if (!t) return "-";
|
|
70
|
-
const n = l == null ? void 0 : l.format, a = l == null ? void 0 : l.use12Hours,
|
|
70
|
+
const n = l == null ? void 0 : l.format, a = l == null ? void 0 : l.use12Hours, u = y.formatTime(
|
|
71
71
|
t,
|
|
72
72
|
n || (a ? "hh:mm:ss A" : void 0)
|
|
73
73
|
);
|
|
74
|
-
return /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) :
|
|
75
|
-
} :
|
|
74
|
+
return /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : u });
|
|
75
|
+
} : c === "color" ? (t, o, r) => t ? typeof i == "function" ? i(t, o, r) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ e(w, { title: t, children: /* @__PURE__ */ e(I, { style: { backgroundColor: t } }) }) : String(t) : "-" : c === "textarea" ? (t, o, r) => {
|
|
76
76
|
if (!t) return "-";
|
|
77
|
-
const n = l, a = n.truncated ?? 1
|
|
77
|
+
const n = l, a = n.truncated ?? 1;
|
|
78
|
+
return typeof i == "function" ? i(t, o, r) : a ? /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(V, { lines: a === !0 ? 1 : a, children: n.rich ? /* @__PURE__ */ e(
|
|
78
79
|
"div",
|
|
79
80
|
{
|
|
80
81
|
style: { all: "unset" },
|
|
@@ -87,7 +88,6 @@ function z({
|
|
|
87
88
|
dangerouslySetInnerHTML: { __html: t }
|
|
88
89
|
}
|
|
89
90
|
) : t;
|
|
90
|
-
return console.log("component", c), c;
|
|
91
91
|
} : typeof i == "function" ? i : (t, o, r) => t;
|
|
92
92
|
} catch (t) {
|
|
93
93
|
return console.warn(
|