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