@kingteza/crud-component 1.4.1 → 1.4.2
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 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
|
|
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,o,e)=>typeof r=="function"?r(t,o,e):"":l==="select"?(t,o,e)=>{if(!t)return"-";const n=i,a=t||(n.items??[]).find(d=>d[n.innerFieldId??"key"]===o[B.getRealName(i.name,"upsertFieldName")]),c=n.multiple?Array.isArray(a)?a.map(d=>d==null?void 0:d[n.innerFieldLabel??"name"]):void 0:a==null?void 0:a[n.innerFieldLabel??"value"];return typeof r=="function"?r(c,o,e):Array.isArray(c)?c.join(", "):c}:l==="number"?(t,o,e)=>typeof r=="function"?r(t,o,e):i!=null&&i.int?q.default.toInt(t,i.formatted):q.default.toMoney(t):l==="enum"?(t,o,e)=>{var d;if(!t)return"-";const n=i;if(typeof r=="function")return r(t,o,e);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((s,y)=>{var C,S;const x=(C=n.tagRender)==null?void 0:C[s],v=g.tWithOrWithoutNS(((S=n==null?void 0:n.translation)==null?void 0:S[s??""])??s,void 0,s);return x?u.jsx(h.Tag,{color:x.color,children:v},y+s):v})})}):n!=null&&n.translation?u.jsx(m.ErrorBoundaryComponent,{children:f==null?void 0:f.map(s=>{var y;return g.tWithOrWithoutNS(((y=n==null?void 0:n.translation)==null?void 0:y[s??""])??s,void 0,s)}).join(", ")}):f==null?void 0:f.join(", ")}const a=((d=n==null?void 0:n.translation)==null?void 0:d[t??""])??t,c=g.tWithOrWithoutNS(a,void 0,t);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,o,e)=>{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,o,e):n})}:l==="checkbox"?(t,o,e)=>typeof r=="function"?r(t,o,e):t?u.jsx(b.CheckOutlined,{}):u.jsx(b.CloseOutlined,{}):l==="image"?(t,o,e)=>t?u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,o,e):u.jsx(T.ImageCrudCellValue,{value:t,provider:i.provider})}):"-":l==="file"?(t,o,e)=>t?u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,o,e):u.jsx(F.FileCrudCellValue,{value:t,provider:i.provider})}):"":l==="time"?(t,o,e)=>{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,o,e):c})}:l==="color"?(t,o,e)=>t?typeof r=="function"?r(t,o,e):typeof t=="string"&&t.startsWith("#")?u.jsx(h.Tooltip,{title:t,children:u.jsx(h.Avatar,{style:{backgroundColor:t}})}):String(t):"-":l==="textarea"?(t,o,e)=>{if(!t)return"-";const n=i,a=n.truncated??1;return typeof r=="function"?r(t,o,e):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,o,e)=>t}catch(t){return console.warn("An error occurred while rendering the value for field: "+String(i.name),t),"-"}}exports.getRendererValueCrudViewer=R;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { CheckOutlined as T, CloseOutlined as F } from "@ant-design/icons";
|
|
3
3
|
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 v from "../../util/DateUtil.es.js";
|
|
8
8
|
import j from "../../util/NumberUtil.es.js";
|
|
9
|
-
import { tWithOrWithoutNS as
|
|
9
|
+
import { tWithOrWithoutNS as y } 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({
|
|
@@ -17,49 +17,55 @@ function z({
|
|
|
17
17
|
try {
|
|
18
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
|
-
const n = l,
|
|
21
|
-
(
|
|
22
|
-
), u = n.multiple ? Array.isArray(
|
|
20
|
+
const n = l, e = t || (n.items ?? []).find(
|
|
21
|
+
(d) => d[n.innerFieldId ?? "key"] === o[H.getRealName(l.name, "upsertFieldName")]
|
|
22
|
+
), u = n.multiple ? Array.isArray(e) ? e.map((d) => d == null ? void 0 : d[n.innerFieldLabel ?? "name"]) : void 0 : e == null ? void 0 : e[n.innerFieldLabel ?? "value"];
|
|
23
23
|
return typeof i == "function" ? i(u, o, r) : Array.isArray(u) ? u.join(", ") : u;
|
|
24
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
|
-
var
|
|
25
|
+
var d;
|
|
26
26
|
if (!t) return "-";
|
|
27
27
|
const n = l;
|
|
28
28
|
if (typeof i == "function")
|
|
29
29
|
return i(t, o, r);
|
|
30
30
|
if (n.multiple) {
|
|
31
31
|
const f = Array.isArray(t) ? t : t ? [t] : [];
|
|
32
|
-
return typeof n.tagRender == "object" ? /* @__PURE__ */
|
|
32
|
+
return typeof n.tagRender == "object" ? /* @__PURE__ */ a(h, { children: /* @__PURE__ */ a(R, { wrap: !0, children: f.map((m, s) => {
|
|
33
33
|
var b, A;
|
|
34
|
-
const
|
|
35
|
-
((A = n == null ? void 0 : n.translation) == null ? void 0 : A[
|
|
34
|
+
const g = (b = n.tagRender) == null ? void 0 : b[m], C = y(
|
|
35
|
+
((A = n == null ? void 0 : n.translation) == null ? void 0 : A[m ?? ""]) ?? m,
|
|
36
|
+
void 0,
|
|
37
|
+
m
|
|
36
38
|
);
|
|
37
|
-
return
|
|
38
|
-
}) }) }) : n != null && n.translation ? /* @__PURE__ */
|
|
39
|
-
(
|
|
39
|
+
return g ? /* @__PURE__ */ a(S, { color: g.color, children: C }, s + m) : C;
|
|
40
|
+
}) }) }) : n != null && n.translation ? /* @__PURE__ */ a(h, { children: f == null ? void 0 : f.map(
|
|
41
|
+
(m) => {
|
|
40
42
|
var s;
|
|
41
|
-
return
|
|
43
|
+
return y(
|
|
44
|
+
((s = n == null ? void 0 : n.translation) == null ? void 0 : s[m ?? ""]) ?? m,
|
|
45
|
+
void 0,
|
|
46
|
+
m
|
|
47
|
+
);
|
|
42
48
|
}
|
|
43
49
|
).join(", ") }) : f == null ? void 0 : f.join(", ");
|
|
44
50
|
}
|
|
45
|
-
const
|
|
51
|
+
const e = ((d = n == null ? void 0 : n.translation) == null ? void 0 : d[t ?? ""]) ?? t, u = y(e, void 0, t);
|
|
46
52
|
if (typeof n.tagRender == "object") {
|
|
47
53
|
const f = n.tagRender[t];
|
|
48
54
|
if (f)
|
|
49
|
-
return /* @__PURE__ */
|
|
55
|
+
return /* @__PURE__ */ a(S, { color: f.color, children: u });
|
|
50
56
|
}
|
|
51
57
|
return u;
|
|
52
58
|
} : c === "date" ? (t, o, r) => {
|
|
53
59
|
if (!t) return "-";
|
|
54
|
-
const n = l != null && l.formatTime ?
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
} : c === "checkbox" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : t ? /* @__PURE__ */
|
|
60
|
+
const n = l != null && l.formatTime ? v.formatDateTime(t) : v.formatDate(t);
|
|
61
|
+
return /* @__PURE__ */ a(h, { children: typeof i == "function" ? i(t, o, r) : n });
|
|
62
|
+
} : c === "checkbox" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : t ? /* @__PURE__ */ a(T, {}) : /* @__PURE__ */ a(F, {}) : c === "image" ? (t, o, r) => t ? /* @__PURE__ */ a(h, { children: typeof i == "function" ? i(t, o, r) : /* @__PURE__ */ a(
|
|
57
63
|
x,
|
|
58
64
|
{
|
|
59
65
|
value: t,
|
|
60
66
|
provider: l.provider
|
|
61
67
|
}
|
|
62
|
-
) }) : "-" : c === "file" ? (t, o, r) => t ? /* @__PURE__ */
|
|
68
|
+
) }) : "-" : c === "file" ? (t, o, r) => t ? /* @__PURE__ */ a(h, { children: typeof i == "function" ? i(t, o, r) : /* @__PURE__ */ a(
|
|
63
69
|
k,
|
|
64
70
|
{
|
|
65
71
|
value: t,
|
|
@@ -67,21 +73,21 @@ function z({
|
|
|
67
73
|
}
|
|
68
74
|
) }) : "" : c === "time" ? (t, o, r) => {
|
|
69
75
|
if (!t) return "-";
|
|
70
|
-
const n = l == null ? void 0 : l.format,
|
|
76
|
+
const n = l == null ? void 0 : l.format, e = l == null ? void 0 : l.use12Hours, u = v.formatTime(
|
|
71
77
|
t,
|
|
72
|
-
n || (
|
|
78
|
+
n || (e ? "hh:mm:ss A" : void 0)
|
|
73
79
|
);
|
|
74
|
-
return /* @__PURE__ */
|
|
75
|
-
} : c === "color" ? (t, o, r) => t ? typeof i == "function" ? i(t, o, r) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */
|
|
80
|
+
return /* @__PURE__ */ a(h, { children: typeof i == "function" ? i(t, o, r) : u });
|
|
81
|
+
} : c === "color" ? (t, o, r) => t ? typeof i == "function" ? i(t, o, r) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ a(w, { title: t, children: /* @__PURE__ */ a(I, { style: { backgroundColor: t } }) }) : String(t) : "-" : c === "textarea" ? (t, o, r) => {
|
|
76
82
|
if (!t) return "-";
|
|
77
|
-
const n = l,
|
|
78
|
-
return typeof i == "function" ? i(t, o, r) :
|
|
83
|
+
const n = l, e = n.truncated ?? 1;
|
|
84
|
+
return typeof i == "function" ? i(t, o, r) : e ? /* @__PURE__ */ a(h, { children: /* @__PURE__ */ a(V, { lines: e === !0 ? 1 : e, children: n.rich ? /* @__PURE__ */ a(
|
|
79
85
|
"div",
|
|
80
86
|
{
|
|
81
87
|
style: { all: "unset" },
|
|
82
88
|
dangerouslySetInnerHTML: { __html: t }
|
|
83
89
|
}
|
|
84
|
-
) : t }) }) : n.rich ? /* @__PURE__ */
|
|
90
|
+
) : t }) }) : n.rich ? /* @__PURE__ */ a(
|
|
85
91
|
"div",
|
|
86
92
|
{
|
|
87
93
|
style: { all: "unset" },
|
package/dist/locale/index.cjs.js
CHANGED
|
@@ -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("./hooks/translation-constants.cjs.js"),I=require("./translations/en.cjs.js"),a=require("i18next"),o=require("react-i18next"),u={en:{[r.TRANSLATION_NAMESPACE]:I}};exports.i18nInstance=a;const S=(n={})=>{const{translations:t=u,language:e="en",i18nInstance:i}=n,s=i||a;return exports.i18nInstance=s,s.isInitialized?Object.entries(t).forEach(([l,T])=>{Object.entries(T).forEach(([N,A])=>{s.addResourceBundle(l,N,A,!0,!0)})}):s.use(o.initReactI18next).init({resources:t,lng:e,fallbackLng:"en",ns:r.TRANSLATION_NAMESPACE,interpolation:{escapeValue:!1}}),a},d=(n,t,e)=>{(e||a).addResourceBundle(n,r.TRANSLATION_NAMESPACE,t,!0,!0)},E=n=>o.useTranslation(r.TRANSLATION_NAMESPACE,{...n,i18n:exports.i18nInstance}),L=n=>o.useTranslation(void 0,{...n,i18n:exports.i18nInstance}),c=(n,t)=>{var e;return(e=exports.i18nInstance)==null?void 0:e.t(n,{ns:r.TRANSLATION_NAMESPACE,...t})},O=(n,t,e)=>{var s;const i=c(n,t);return i||e||((s=exports.i18nInstance)==null?void 0:s.t(n,{ns:void 0,...t}))};exports.defaultTranslations=u;exports.setupI18n=S;exports.t=c;exports.tWithOrWithoutNS=O;exports.updateTranslations=d;exports.useTranslationLib=E;exports.useTranslationLibNoNS=L;
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -82,4 +82,4 @@ export declare const updateTranslations: (language: string, translations: Record
|
|
|
82
82
|
export declare const useTranslationLib: (options?: Omit<UseTranslationOptions<string>, "i18n">) => import('react-i18next').UseTranslationResponse<"crud-component", string>;
|
|
83
83
|
export declare const useTranslationLibNoNS: (options?: Omit<UseTranslationOptions<string>, "i18n">) => import('react-i18next').UseTranslationResponse<"translation", string>;
|
|
84
84
|
export declare const t: (key: string, options?: any) => string | import('node_modules/i18next/typescript/helpers').$SpecialObject | import('i18next').TFunctionDetailedResult<string | import('node_modules/i18next/typescript/helpers').$SpecialObject, any>;
|
|
85
|
-
export declare const tWithOrWithoutNS: (key: string, options?: any
|
|
85
|
+
export declare const tWithOrWithoutNS: (key: string, options?: any, fallback?: string) => string | object;
|
package/dist/locale/index.es.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { TRANSLATION_NAMESPACE as
|
|
1
|
+
import { TRANSLATION_NAMESPACE as o } from "./hooks/translation-constants.es.js";
|
|
2
2
|
import T from "./translations/en.es.js";
|
|
3
|
-
import
|
|
4
|
-
import { initReactI18next as m, useTranslation as
|
|
3
|
+
import u from "i18next";
|
|
4
|
+
import { initReactI18next as m, useTranslation as a } from "react-i18next";
|
|
5
5
|
const p = {
|
|
6
6
|
en: {
|
|
7
|
-
[
|
|
7
|
+
[o]: T
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
let e =
|
|
10
|
+
let e = u;
|
|
11
11
|
const E = (t = {}) => {
|
|
12
12
|
const {
|
|
13
13
|
translations: n = p,
|
|
14
14
|
language: r = "en",
|
|
15
|
-
i18nInstance:
|
|
16
|
-
} = t,
|
|
17
|
-
return e =
|
|
15
|
+
i18nInstance: s
|
|
16
|
+
} = t, i = s || u;
|
|
17
|
+
return e = i, i.isInitialized ? Object.entries(n).forEach(([c, l]) => {
|
|
18
18
|
Object.entries(l).forEach(([d, f]) => {
|
|
19
|
-
|
|
19
|
+
i.addResourceBundle(c, d, f, !0, !0);
|
|
20
20
|
});
|
|
21
|
-
}) :
|
|
21
|
+
}) : i.use(m).init({
|
|
22
22
|
resources: n,
|
|
23
23
|
lng: r,
|
|
24
24
|
fallbackLng: "en",
|
|
25
|
-
ns:
|
|
25
|
+
ns: o,
|
|
26
26
|
interpolation: {
|
|
27
27
|
escapeValue: !1
|
|
28
28
|
}
|
|
29
|
-
}),
|
|
29
|
+
}), u;
|
|
30
30
|
}, L = (t, n, r) => {
|
|
31
|
-
(r ||
|
|
31
|
+
(r || u).addResourceBundle(
|
|
32
32
|
t,
|
|
33
|
-
|
|
33
|
+
o,
|
|
34
34
|
n,
|
|
35
35
|
!0,
|
|
36
36
|
!0
|
|
37
37
|
);
|
|
38
|
-
}, O = (t) =>
|
|
39
|
-
ns:
|
|
38
|
+
}, O = (t) => a(o, { ...t, i18n: e }), R = (t) => a(void 0, { ...t, i18n: e }), N = (t, n) => e == null ? void 0 : e.t(t, {
|
|
39
|
+
ns: o,
|
|
40
40
|
...n
|
|
41
|
-
}), S = (t, n) => {
|
|
42
|
-
const
|
|
43
|
-
return r || (e == null ? void 0 : e.t(t, {
|
|
41
|
+
}), S = (t, n, r) => {
|
|
42
|
+
const s = N(t, n);
|
|
43
|
+
return s || r || (e == null ? void 0 : e.t(t, {
|
|
44
44
|
ns: void 0,
|
|
45
45
|
...n
|
|
46
46
|
}));
|