@kingteza/crud-component 1.0.21 → 1.0.23
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/README.md +66 -7
- package/dist/components/common/button/Button.cjs +1 -1
- package/dist/components/common/button/Button.js +49 -41
- package/dist/components/crud/import/CrudImportComponent.cjs +2 -2
- package/dist/components/crud/import/CrudImportComponent.js +80 -78
- package/dist/components/crud/view/CrudViewerUtil.cjs +1 -1
- package/dist/locale/index.cjs +1 -1
- package/dist/locale/index.d.ts +7 -2
- package/dist/locale/index.js +20 -16
- package/dist/util/DateUtil.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,23 +8,82 @@ React CRUD component library built with Ant Design and TypeScript.
|
|
|
8
8
|
npm install @kingteza/crud-component
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Prerequisites
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
This library has the following peer dependencies that need to be installed:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install antd@^5.22.6 react@^18.3.1 react-dom@^18.3.1 react-router-dom@^7.0.0
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Setup
|
|
20
|
+
|
|
21
|
+
### 1. Initialize translations
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
The library uses i18next for internationalization. You need to set it up before using the components:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
18
26
|
import { setupI18n } from '@kingteza/crud-component';
|
|
27
|
+
|
|
28
|
+
// Basic setup with default English translations
|
|
19
29
|
setupI18n();
|
|
20
30
|
|
|
31
|
+
// Or with custom options
|
|
32
|
+
setupI18n({
|
|
33
|
+
language: 'en', // default language
|
|
34
|
+
translations: {
|
|
35
|
+
en: {
|
|
36
|
+
'crud-component': {
|
|
37
|
+
// your custom translations
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
i18nInstance: existingI18nInstance // optional: use your existing i18n instance
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Usage
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { CrudComponent } from '@kingteza/crud-component';
|
|
49
|
+
import { Button } from '@kingteza/crud-component/common';
|
|
50
|
+
|
|
21
51
|
function App() {
|
|
22
52
|
return (
|
|
23
53
|
<CrudComponent
|
|
24
54
|
fields={[
|
|
25
|
-
{ type: "text", name: "name", label: "Name" }
|
|
55
|
+
{ type: "text", name: "name", label: "Name", required: true },
|
|
56
|
+
{ type: "select", name: "status", label: "Status", options: [
|
|
57
|
+
{ value: "active", label: "Active" },
|
|
58
|
+
{ value: "inactive", label: "Inactive" }
|
|
59
|
+
]}
|
|
26
60
|
]}
|
|
27
61
|
data={[]}
|
|
62
|
+
onSave={(data) => console.log(data)}
|
|
28
63
|
/>
|
|
29
64
|
);
|
|
30
|
-
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 3. Available Imports
|
|
69
|
+
|
|
70
|
+
The library provides several entry points for importing components:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// Main CRUD component
|
|
74
|
+
import { CrudComponent } from '@kingteza/crud-component';
|
|
75
|
+
|
|
76
|
+
// Common components
|
|
77
|
+
import { Button, Select, DatePicker } from '@kingteza/crud-component/common';
|
|
78
|
+
|
|
79
|
+
// Utility functions
|
|
80
|
+
import { DateUtil } from '@kingteza/crud-component/util';
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
For detailed documentation of components and their props, please visit our [GitHub repository](https://github.com/kingteza/crud-component).
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const y=require("react/jsx-runtime"),f=require("antd"),g=require("../../../locale/hooks/translation-constants.cjs"),l=require("react"),A=require("react-i18next");;/* empty css */const d=require("react-router-dom"),q=({className:i,to:t,onClick:n,tooltip:o,ref:x,...r})=>{var a;const{t:e}=A.useTranslation(g.TRANSLATION_NAMESPACE);let s;try{s=(a=d.useNavigate)==null?void 0:a.call(d)}catch(u){console.error(u)}const c=l.useMemo(()=>y.jsx(f.Button,{onClick:n||(t&&s?()=>s(t):void 0),className:i,...r,children:r.children||e(`button.${r.type}`)}),[i,s,n,r,e,t]);return o?y.jsx(f.Tooltip,{title:o,children:c}):c},j=({className:i,to:t,onClick:n,tooltip:o,ref:x,...r})=>{let e;try{e=d.useNavigate()}catch(h){console.error(h)}const[s,c]=l.useState(!1),a=l.useCallback(async h=>{try{return c(!0),await n(h)}finally{c(!1)}},[n]),u=l.useMemo(()=>y.jsx(f.Button,{loading:s||r.loading,onClick:n?a:t?()=>{e?e==null||e(t):window.location.href=t}:void 0,className:i,...r}),[a,i,s,e,n,r,t]);return o?y.jsx(f.Tooltip,{title:o,children:u}):u};q.Async=j;module.exports=q;
|
|
@@ -1,71 +1,79 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Button as u, Tooltip as
|
|
3
|
-
import { TRANSLATION_NAMESPACE as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { useTranslation as
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { Button as u, Tooltip as d } from "antd";
|
|
3
|
+
import { TRANSLATION_NAMESPACE as g } from "../../../locale/hooks/translation-constants.js";
|
|
4
|
+
import { useMemo as y, useState as b, useCallback as T } from "react";
|
|
5
|
+
import { useTranslation as v } from "react-i18next";
|
|
6
6
|
/* empty css */
|
|
7
|
-
import { useNavigate as
|
|
8
|
-
const
|
|
9
|
-
className:
|
|
10
|
-
to:
|
|
11
|
-
onClick:
|
|
12
|
-
tooltip:
|
|
13
|
-
ref:
|
|
7
|
+
import { useNavigate as h } from "react-router-dom";
|
|
8
|
+
const w = ({
|
|
9
|
+
className: i,
|
|
10
|
+
to: r,
|
|
11
|
+
onClick: e,
|
|
12
|
+
tooltip: a,
|
|
13
|
+
ref: A,
|
|
14
14
|
...n
|
|
15
15
|
}) => {
|
|
16
16
|
var l;
|
|
17
|
-
const { t
|
|
18
|
-
let
|
|
17
|
+
const { t } = v(g);
|
|
18
|
+
let o;
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
o = (l = h) == null ? void 0 : l();
|
|
21
21
|
} catch (s) {
|
|
22
22
|
console.error(s);
|
|
23
23
|
}
|
|
24
|
-
const c =
|
|
25
|
-
() => /* @__PURE__ */
|
|
24
|
+
const c = y(
|
|
25
|
+
() => /* @__PURE__ */ f(
|
|
26
26
|
u,
|
|
27
27
|
{
|
|
28
|
-
onClick:
|
|
29
|
-
className:
|
|
28
|
+
onClick: e || (r && o ? () => o(r) : void 0),
|
|
29
|
+
className: i,
|
|
30
30
|
...n,
|
|
31
|
-
children: n.children ||
|
|
31
|
+
children: n.children || t(`button.${n.type}`)
|
|
32
32
|
}
|
|
33
33
|
),
|
|
34
|
-
[
|
|
34
|
+
[i, o, e, n, t, r]
|
|
35
35
|
);
|
|
36
|
-
return
|
|
37
|
-
},
|
|
38
|
-
className:
|
|
39
|
-
to:
|
|
40
|
-
onClick:
|
|
41
|
-
tooltip:
|
|
42
|
-
ref:
|
|
36
|
+
return a ? /* @__PURE__ */ f(d, { title: a, children: c }) : c;
|
|
37
|
+
}, S = ({
|
|
38
|
+
className: i,
|
|
39
|
+
to: r,
|
|
40
|
+
onClick: e,
|
|
41
|
+
tooltip: a,
|
|
42
|
+
ref: A,
|
|
43
43
|
...n
|
|
44
44
|
}) => {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
let t;
|
|
46
|
+
try {
|
|
47
|
+
t = h();
|
|
48
|
+
} catch (m) {
|
|
49
|
+
console.error(m);
|
|
50
|
+
}
|
|
51
|
+
const [o, c] = b(!1), l = T(
|
|
52
|
+
async (m) => {
|
|
47
53
|
try {
|
|
48
|
-
return c(!0), await
|
|
54
|
+
return c(!0), await e(m);
|
|
49
55
|
} finally {
|
|
50
56
|
c(!1);
|
|
51
57
|
}
|
|
52
58
|
},
|
|
53
|
-
[
|
|
54
|
-
), s =
|
|
55
|
-
() => /* @__PURE__ */
|
|
59
|
+
[e]
|
|
60
|
+
), s = y(
|
|
61
|
+
() => /* @__PURE__ */ f(
|
|
56
62
|
u,
|
|
57
63
|
{
|
|
58
|
-
loading:
|
|
59
|
-
onClick:
|
|
60
|
-
|
|
64
|
+
loading: o || n.loading,
|
|
65
|
+
onClick: e ? l : r ? () => {
|
|
66
|
+
t ? t == null || t(r) : window.location.href = r;
|
|
67
|
+
} : void 0,
|
|
68
|
+
className: i,
|
|
61
69
|
...n
|
|
62
70
|
}
|
|
63
71
|
),
|
|
64
|
-
[l,
|
|
72
|
+
[l, i, o, t, e, n, r]
|
|
65
73
|
);
|
|
66
|
-
return
|
|
74
|
+
return a ? /* @__PURE__ */ f(d, { title: a, children: s }) : s;
|
|
67
75
|
};
|
|
68
|
-
|
|
76
|
+
w.Async = S;
|
|
69
77
|
export {
|
|
70
|
-
|
|
78
|
+
w as default
|
|
71
79
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),q=require("@ant-design/icons"),O=require("papaparse"),d=require("antd"),V=require("file-saver"),a=require("react"),W=require("react-i18next"),R=require("../../../locale/hooks/translation-constants.cjs"),L=require("../view/CrudViewer.cjs"),z=require("../../../util/DateUtil.cjs"),_=require("../../common/button/Button.cjs"),$=require("../../common/button/ImportButton.cjs");function U({onCloseMethod:C,open:w,fields:T,importProps:o}){const[u,A]=a.useState([]),[y,k]=a.useState(!1),[v,N]=a.useState(0);a.useEffect(()=>{w||(A([]),k(!1))},[w]);const p=a.useMemo(()=>new Map(T.filter(e=>{var t;return!e.hidden&&!((t=e.importProps)!=null&&t.hidden)&&!e.readonly}).map(e=>[e.name,e])),[T]),S=a.useMemo(()=>Array.from(p.values()).flatMap(e=>{var t;return[e.name,...((t=e.importProps)==null?void 0:t.extraFields)??[]]}),[p]),F=a.useCallback(async function(){const e=`${S.join(",")}
|
|
2
|
+
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});V.saveAs(t,(o==null?void 0:o.name)+" - "+z.formatDateTimeWithSecond(new Date).replaceAll(":","-")+".csv")},[S,o==null?void 0:o.name]),{t:i}=W.useTranslation(R.TRANSLATION_NAMESPACE),B=a.useCallback(async e=>{const t=new FileReader;t.onerror=console.error,t.onload=async r=>{var s;const c=(s=r==null?void 0:r.target)==null?void 0:s.result,l=O.parse(c,{header:!0});A(l.data)},t.readAsText(e)},[]),g=a.useMemo(()=>{var t,r,c;let e=!1;for(const l of u)for(const[s,f]of p.entries()){const h=l[s],m=h||!isNaN(h);if(f.required&&!m)if((r=(t=f.importProps)==null?void 0:t.extraFields)!=null&&r.length)for(const j of((c=f.importProps)==null?void 0:c.extraFields)??[])if(l[j]||!isNaN(l[j])){e=!1;break}else return!0;else return!0}return e},[u,p]),x=a.useCallback(e=>(t,r)=>{var l,s,f;const c=t||!isNaN(t);if(e.required&&!c){let h=i("err.validation.required");if((s=(l=e.importProps)==null?void 0:l.extraFields)!=null&&s.length){const m=(f=e.importProps)==null?void 0:f.extraFields;(m==null?void 0:m.find(E=>!r[E]))&&(h="Either one of these fields is required: "+[e.name,...m].join(", "))}return n.jsxs(d.Tooltip,{className:"d-flex",title:h,children:[n.jsx(q.WarningTwoTone,{twoToneColor:"#ee9702"}),t]})}return t},[i]),I=a.useCallback(async e=>{N(e)},[]),b=a.useCallback(async()=>{try{k(!0),await o.onClickImport(u,I),C(!1)}finally{k(!1),N(0)}},[u,o,C,I]),{modal:D}=d.App.useApp(),M=a.useCallback(async()=>{g?D.warning?D.warning({title:i("str.warning"),content:i("qus.importWithIssues"),okText:i("str.import"),onOk:b,okCancel:!0,closable:!0}):(console.error("You must wrap your react app with App component. https://ant.design/components/app"),window.confirm(i("qus.importWithIssues"))&&b()):b()},[g,b,i]);return n.jsxs(d.Modal,{title:[i("str.import"),o==null?void 0:o.name].filter(Boolean).join(" "),width:"100%",open:w,onOk:M,destroyOnClose:!0,onCancel:()=>C(!1),okText:i("str.import"),confirmLoading:y,okButtonProps:{disabled:!(u!=null&&u.length)},footer:(e,{OkBtn:t,CancelBtn:r})=>n.jsxs(d.Space,{children:[n.jsx(r,{}),n.jsx(t,{}),g&&n.jsx(d.Tooltip,{className:"d-flex",title:"Some fields have issue. Please review before submit.",children:n.jsx(q.WarningTwoTone,{twoToneColor:"#ee9702"})})]}),children:[n.jsxs(d.Space,{children:[n.jsx(_,{onClick:F,icon:n.jsx(q.DownloadOutlined,{}),children:i("str.downloadCsvTemplate")}),n.jsx($.ImportButton,{disabled:y,type:"default",onClick:B,accept:".csv",children:i("str.importCsvFile")})]}),n.jsx(d.Spin,{spinning:y,indicator:v?n.jsx(d.Progress,{type:"circle",percent:v*100,size:50,format:e=>`${parseInt(e)}%`}):void 0,children:n.jsx(L,{data:u,bordered:!0,size:"small",fields:Array.from(p.values()).flatMap(e=>{var t,r,c,l;return e.type==="text"?[{...e,label:e.name,render:x(e)},...((r=(t=e.importProps)==null?void 0:t.extraFields)==null?void 0:r.map(s=>({...e,name:s,label:s,render:x(e)})))??[]]:e.type==="select"?[{...e,label:e.name,type:"text",render:x(e)},...((l=(c=e.importProps)==null?void 0:c.extraFields)==null?void 0:l.map(s=>({...e,name:s,label:s,type:"text",render:x(e)})))??[]]:[{...e,label:e.name,render:x(e)}]})})})]})}module.exports=U;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { WarningTwoTone as
|
|
1
|
+
import { jsxs as w, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { WarningTwoTone as B, DownloadOutlined as z } from "@ant-design/icons";
|
|
3
3
|
import R from "papaparse";
|
|
4
|
-
import { Tooltip as
|
|
5
|
-
import { saveAs as
|
|
6
|
-
import { useState as
|
|
7
|
-
import { useTranslation as
|
|
8
|
-
import { TRANSLATION_NAMESPACE as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { ImportButton as
|
|
13
|
-
function
|
|
4
|
+
import { Tooltip as O, App as _, Modal as $, Space as V, Spin as U, Progress as Y } from "antd";
|
|
5
|
+
import { saveAs as G } from "file-saver";
|
|
6
|
+
import { useState as T, useEffect as H, useMemo as v, useCallback as f } from "react";
|
|
7
|
+
import { useTranslation as J } from "react-i18next";
|
|
8
|
+
import { TRANSLATION_NAMESPACE as K } from "../../../locale/hooks/translation-constants.js";
|
|
9
|
+
import Q from "../view/CrudViewer.js";
|
|
10
|
+
import X from "../../../util/DateUtil.js";
|
|
11
|
+
import Z from "../../common/button/Button.js";
|
|
12
|
+
import { ImportButton as P } from "../../common/button/ImportButton.js";
|
|
13
|
+
function fe({
|
|
14
14
|
onCloseMethod: x,
|
|
15
15
|
open: b,
|
|
16
16
|
fields: N,
|
|
17
17
|
importProps: o
|
|
18
18
|
}) {
|
|
19
|
-
const [c, D] =
|
|
20
|
-
|
|
21
|
-
b || (D([]),
|
|
19
|
+
const [c, D] = T([]), [C, g] = T(!1), [E, F] = T(0);
|
|
20
|
+
H(() => {
|
|
21
|
+
b || (D([]), g(!1));
|
|
22
22
|
}, [b]);
|
|
23
|
-
const u =
|
|
23
|
+
const u = v(
|
|
24
24
|
() => new Map(
|
|
25
25
|
N.filter((e) => {
|
|
26
26
|
var t;
|
|
@@ -28,7 +28,7 @@ function de({
|
|
|
28
28
|
}).map((e) => [e.name, e])
|
|
29
29
|
),
|
|
30
30
|
[N]
|
|
31
|
-
), I =
|
|
31
|
+
), I = v(
|
|
32
32
|
() => Array.from(u.values()).flatMap((e) => {
|
|
33
33
|
var t;
|
|
34
34
|
return [
|
|
@@ -37,128 +37,130 @@ function de({
|
|
|
37
37
|
];
|
|
38
38
|
}),
|
|
39
39
|
[u]
|
|
40
|
-
), M =
|
|
40
|
+
), M = f(
|
|
41
41
|
async function() {
|
|
42
42
|
const e = `${I.join(",")}
|
|
43
43
|
`, t = new Blob([e], { type: "text/csv;charset=utf-8;" });
|
|
44
|
-
|
|
44
|
+
G(
|
|
45
45
|
t,
|
|
46
|
-
(o == null ? void 0 : o.name) + " - " +
|
|
46
|
+
(o == null ? void 0 : o.name) + " - " + X.formatDateTimeWithSecond(/* @__PURE__ */ new Date()).replaceAll(":", "-") + ".csv"
|
|
47
47
|
);
|
|
48
48
|
},
|
|
49
49
|
[I, o == null ? void 0 : o.name]
|
|
50
|
-
), { t:
|
|
50
|
+
), { t: s } = J(K), W = f(async (e) => {
|
|
51
51
|
const t = new FileReader();
|
|
52
52
|
t.onerror = console.error, t.onload = async (r) => {
|
|
53
53
|
var n;
|
|
54
|
-
const
|
|
54
|
+
const l = (n = r == null ? void 0 : r.target) == null ? void 0 : n.result, a = R.parse(l, { header: !0 });
|
|
55
55
|
D(a.data);
|
|
56
56
|
}, t.readAsText(e);
|
|
57
|
-
}, []),
|
|
58
|
-
var t, r,
|
|
57
|
+
}, []), k = v(() => {
|
|
58
|
+
var t, r, l;
|
|
59
59
|
let e = !1;
|
|
60
60
|
for (const a of c)
|
|
61
61
|
for (const [n, d] of u.entries()) {
|
|
62
|
-
const h = a[n],
|
|
63
|
-
if (d.required && !
|
|
62
|
+
const h = a[n], m = h || !isNaN(h);
|
|
63
|
+
if (d.required && !m)
|
|
64
64
|
if ((r = (t = d.importProps) == null ? void 0 : t.extraFields) != null && r.length)
|
|
65
|
-
for (const
|
|
66
|
-
if (a[
|
|
65
|
+
for (const A of ((l = d.importProps) == null ? void 0 : l.extraFields) ?? [])
|
|
66
|
+
if (a[A] || !isNaN(a[A])) {
|
|
67
67
|
e = !1;
|
|
68
68
|
break;
|
|
69
69
|
} else return !0;
|
|
70
70
|
else return !0;
|
|
71
71
|
}
|
|
72
72
|
return e;
|
|
73
|
-
}, [c, u]), p =
|
|
73
|
+
}, [c, u]), p = f(
|
|
74
74
|
(e) => (t, r) => {
|
|
75
75
|
var a, n, d;
|
|
76
|
-
const
|
|
77
|
-
if (e.required && !
|
|
78
|
-
let h =
|
|
76
|
+
const l = t || !isNaN(t);
|
|
77
|
+
if (e.required && !l) {
|
|
78
|
+
let h = s("err.validation.required");
|
|
79
79
|
if ((n = (a = e.importProps) == null ? void 0 : a.extraFields) != null && n.length) {
|
|
80
|
-
const
|
|
81
|
-
(
|
|
80
|
+
const m = (d = e.importProps) == null ? void 0 : d.extraFields;
|
|
81
|
+
(m == null ? void 0 : m.find((j) => !r[j])) && (h = "Either one of these fields is required: " + [e.name, ...m].join(", "));
|
|
82
82
|
}
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ w(O, { className: "d-flex", title: h, children: [
|
|
84
|
+
/* @__PURE__ */ i(B, { twoToneColor: "#ee9702" }),
|
|
85
85
|
t
|
|
86
86
|
] });
|
|
87
87
|
}
|
|
88
88
|
return t;
|
|
89
89
|
},
|
|
90
|
-
[
|
|
91
|
-
), S =
|
|
90
|
+
[s]
|
|
91
|
+
), S = f(async (e) => {
|
|
92
92
|
F(e);
|
|
93
|
-
}, []),
|
|
93
|
+
}, []), y = f(async () => {
|
|
94
94
|
try {
|
|
95
|
-
|
|
95
|
+
g(!0), await o.onClickImport(c, S), x(!1);
|
|
96
96
|
} finally {
|
|
97
|
-
|
|
97
|
+
g(!1), F(0);
|
|
98
98
|
}
|
|
99
|
-
}, [c, o, x, S]),
|
|
100
|
-
|
|
101
|
-
title:
|
|
102
|
-
content:
|
|
103
|
-
okText:
|
|
104
|
-
onOk:
|
|
99
|
+
}, [c, o, x, S]), { modal: q } = _.useApp(), L = f(async () => {
|
|
100
|
+
k ? q.warning ? q.warning({
|
|
101
|
+
title: s("str.warning"),
|
|
102
|
+
content: s("qus.importWithIssues"),
|
|
103
|
+
okText: s("str.import"),
|
|
104
|
+
onOk: y,
|
|
105
105
|
okCancel: !0,
|
|
106
106
|
closable: !0
|
|
107
|
-
}) :
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
}) : (console.error(
|
|
108
|
+
"You must wrap your react app with App component. https://ant.design/components/app"
|
|
109
|
+
), window.confirm(s("qus.importWithIssues")) && y()) : y();
|
|
110
|
+
}, [k, y, s]);
|
|
111
|
+
return /* @__PURE__ */ w(
|
|
112
|
+
$,
|
|
111
113
|
{
|
|
112
|
-
title: [
|
|
114
|
+
title: [s("str.import"), o == null ? void 0 : o.name].filter(Boolean).join(" "),
|
|
113
115
|
width: "100%",
|
|
114
116
|
open: b,
|
|
115
|
-
onOk:
|
|
117
|
+
onOk: L,
|
|
116
118
|
destroyOnClose: !0,
|
|
117
119
|
onCancel: () => x(!1),
|
|
118
|
-
okText:
|
|
120
|
+
okText: s("str.import"),
|
|
119
121
|
confirmLoading: C,
|
|
120
122
|
okButtonProps: {
|
|
121
123
|
disabled: !(c != null && c.length)
|
|
122
124
|
},
|
|
123
|
-
footer: (e, { OkBtn: t, CancelBtn: r }) => /* @__PURE__ */
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
footer: (e, { OkBtn: t, CancelBtn: r }) => /* @__PURE__ */ w(V, { children: [
|
|
126
|
+
/* @__PURE__ */ i(r, {}),
|
|
127
|
+
/* @__PURE__ */ i(t, {}),
|
|
128
|
+
k && /* @__PURE__ */ i(
|
|
129
|
+
O,
|
|
128
130
|
{
|
|
129
131
|
className: "d-flex",
|
|
130
132
|
title: "Some fields have issue. Please review before submit.",
|
|
131
|
-
children: /* @__PURE__ */
|
|
133
|
+
children: /* @__PURE__ */ i(B, { twoToneColor: "#ee9702" })
|
|
132
134
|
}
|
|
133
135
|
)
|
|
134
136
|
] }),
|
|
135
137
|
children: [
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
|
|
138
|
+
/* @__PURE__ */ w(V, { children: [
|
|
139
|
+
/* @__PURE__ */ i(
|
|
140
|
+
Z,
|
|
139
141
|
{
|
|
140
142
|
onClick: M,
|
|
141
|
-
icon: /* @__PURE__ */
|
|
142
|
-
children:
|
|
143
|
+
icon: /* @__PURE__ */ i(z, {}),
|
|
144
|
+
children: s("str.downloadCsvTemplate")
|
|
143
145
|
}
|
|
144
146
|
),
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
|
|
147
|
+
/* @__PURE__ */ i(
|
|
148
|
+
P,
|
|
147
149
|
{
|
|
148
150
|
disabled: C,
|
|
149
151
|
type: "default",
|
|
150
|
-
onClick:
|
|
152
|
+
onClick: W,
|
|
151
153
|
accept: ".csv",
|
|
152
|
-
children:
|
|
154
|
+
children: s("str.importCsvFile")
|
|
153
155
|
}
|
|
154
156
|
)
|
|
155
157
|
] }),
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
|
|
158
|
+
/* @__PURE__ */ i(
|
|
159
|
+
U,
|
|
158
160
|
{
|
|
159
161
|
spinning: C,
|
|
160
|
-
indicator: E ? /* @__PURE__ */
|
|
161
|
-
|
|
162
|
+
indicator: E ? /* @__PURE__ */ i(
|
|
163
|
+
Y,
|
|
162
164
|
{
|
|
163
165
|
type: "circle",
|
|
164
166
|
percent: E * 100,
|
|
@@ -166,14 +168,14 @@ function de({
|
|
|
166
168
|
format: (e) => `${parseInt(e)}%`
|
|
167
169
|
}
|
|
168
170
|
) : void 0,
|
|
169
|
-
children: /* @__PURE__ */
|
|
170
|
-
|
|
171
|
+
children: /* @__PURE__ */ i(
|
|
172
|
+
Q,
|
|
171
173
|
{
|
|
172
174
|
data: c,
|
|
173
175
|
bordered: !0,
|
|
174
176
|
size: "small",
|
|
175
177
|
fields: Array.from(u.values()).flatMap((e) => {
|
|
176
|
-
var t, r,
|
|
178
|
+
var t, r, l, a;
|
|
177
179
|
return e.type === "text" ? [
|
|
178
180
|
{
|
|
179
181
|
...e,
|
|
@@ -193,7 +195,7 @@ function de({
|
|
|
193
195
|
type: "text",
|
|
194
196
|
render: p(e)
|
|
195
197
|
},
|
|
196
|
-
...((a = (
|
|
198
|
+
...((a = (l = e.importProps) == null ? void 0 : l.extraFields) == null ? void 0 : a.map((n) => ({
|
|
197
199
|
...e,
|
|
198
200
|
name: n,
|
|
199
201
|
label: n,
|
|
@@ -217,5 +219,5 @@ function de({
|
|
|
217
219
|
);
|
|
218
220
|
}
|
|
219
221
|
export {
|
|
220
|
-
|
|
222
|
+
fe as default
|
|
221
223
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),m=require("@ant-design/icons"),s=require("antd"),y=require("../../common/show-more/index.cjs"),C=require("../FileCrudField.cjs"),g=require("../ImageCrudField.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),m=require("@ant-design/icons"),s=require("antd"),y=require("../../common/show-more/index.cjs"),C=require("../FileCrudField.cjs"),g=require("../ImageCrudField.cjs"),d=require("../../../locale/hooks/translation-constants.cjs"),j=require("i18next"),r=require("../../../util/DateUtil.cjs"),v=require("../../../util/NumberUtil.cjs");function x({type:a,render:i,...n}){return a==="object"?(t,u,o)=>typeof i=="function"?i(t,u,o):"":a==="select"?(t,u,o)=>{const e=n;let c=e.multiple?Array.isArray(t)?t.map(f=>f==null?void 0:f[e.innerFieldLabel??"name"]):void 0:t==null?void 0:t[e.innerFieldLabel??"name"];return(!c&&typeof t=="string"||typeof t=="number")&&(c=t),typeof i=="function"?i(c,u,o):Array.isArray(c)?c.join(", "):c}:a==="number"?(t,u,o)=>typeof i=="function"?i(t,u,o):n!=null&&n.int?v.default.toInt(t,n.formatted):v.default.toMoney(t):a==="enum"?(t,u,o)=>{var c;const e=j.t(((c=n==null?void 0:n.translation)==null?void 0:c[t??""])??t,{ns:d.TRANSLATION_NAMESPACE});return typeof i=="function"?i(t,u,o):e}:a==="date"?(t,u,o)=>{if(!t)return"-";const e=n!=null&&n.formatTime?r.formatDateTime(t):r.formatDate(t);return typeof i=="function"?i(t,u,o):e}:a==="checkbox"?(t,u,o)=>typeof i=="function"?i(t,u,o):t?l.jsx(m.CheckOutlined,{}):l.jsx(m.CloseOutlined,{}):a==="image"?(t,u,o)=>typeof i=="function"?i(t,u,o):l.jsx(g.ImageCrudCellValue,{value:t,provider:n.provider}):a==="file"?(t,u,o)=>typeof i=="function"?i(t,u,o):l.jsx(C.FileCrudCellValue,{value:t,provider:n.provider}):a==="time"?(t,u,o)=>{if(!t)return"-";const e=n==null?void 0:n.format,c=n==null?void 0:n.use12Hours,f=r.formatTime(t,e||(c?"hh:mm:ss A":void 0));return typeof i=="function"?i(t,u,o):f}:a==="color"?(t,u,o)=>typeof i=="function"?i(t,u,o):typeof t=="string"&&t.startsWith("#")?l.jsx(s.Tooltip,{title:t,children:l.jsx(s.Avatar,{style:{backgroundColor:t}})}):String(t):a==="textarea"?(t,u,o)=>{const e=(n==null?void 0:n.truncated)??1;return typeof i=="function"?i(t,u,o):e?l.jsx(y.ShowMore,{lines:e===!0?1:e,children:t}):t}:typeof i=="function"?i:t=>t}exports.getRendererValueCrudViewer=x;
|
package/dist/locale/index.cjs
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 a=require("./hooks/translation-constants.cjs"),d=require("./translations/en.cjs"),n=require("i18next"),A=require("react-i18next"),o={en:{[a.TRANSLATION_NAMESPACE]:d}},I=(t={})=>{const{translations:e=o,language:s="en",i18nInstance:r}=t,i=r||n;return i.isInitialized?Object.entries(e).forEach(([u,c])=>{Object.entries(c).forEach(([l,T])=>{n.addResourceBundle(u,l,T,!0,!0)})}):i.use(A.initReactI18next).init({resources:e,lng:s,fallbackLng:"en",ns:a.TRANSLATION_NAMESPACE,interpolation:{escapeValue:!1}}),n},N=(t,e,s)=>{(s||n).addResourceBundle(t,a.TRANSLATION_NAMESPACE,e,!0,!0)};exports.defaultTranslations=o;exports.setupI18n=I;exports.updateTranslations=N;
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { TRANSLATION_NAMESPACE } from 'locale/hooks/translation-constants';
|
|
1
2
|
import { default as en } from './translations/en';
|
|
3
|
+
import { default as i18n } from 'i18next';
|
|
2
4
|
export declare const defaultTranslations: {
|
|
3
5
|
en: {
|
|
4
6
|
"crud-component": {
|
|
@@ -62,8 +64,11 @@ export declare const defaultTranslations: {
|
|
|
62
64
|
};
|
|
63
65
|
export type LibTranslations = typeof en;
|
|
64
66
|
export interface SetupI18nOptions {
|
|
65
|
-
translations?:
|
|
67
|
+
translations?: Record<string, {
|
|
68
|
+
[TRANSLATION_NAMESPACE]: LibTranslations;
|
|
69
|
+
}>;
|
|
66
70
|
language?: string;
|
|
71
|
+
i18nInstance?: typeof i18n;
|
|
67
72
|
}
|
|
68
73
|
export declare const setupI18n: (options?: SetupI18nOptions) => import('i18next').i18n;
|
|
69
|
-
export declare const updateTranslations: (language: string, translations: Record<string, any
|
|
74
|
+
export declare const updateTranslations: (language: string, translations: Record<string, any>, i18nInstance?: typeof i18n) => void;
|
package/dist/locale/index.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import { TRANSLATION_NAMESPACE as o } from "./hooks/translation-constants.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { initReactI18next as
|
|
5
|
-
const
|
|
2
|
+
import f from "./translations/en.js";
|
|
3
|
+
import n from "i18next";
|
|
4
|
+
import { initReactI18next as d } from "react-i18next";
|
|
5
|
+
const p = {
|
|
6
6
|
en: {
|
|
7
|
-
[o]:
|
|
7
|
+
[o]: f
|
|
8
8
|
}
|
|
9
|
-
},
|
|
10
|
-
const { translations: e =
|
|
11
|
-
return
|
|
9
|
+
}, A = (t = {}) => {
|
|
10
|
+
const { translations: e = p, language: s = "en", i18nInstance: r } = t, i = r || n;
|
|
11
|
+
return i.isInitialized ? Object.entries(e).forEach(([a, c]) => {
|
|
12
|
+
Object.entries(c).forEach(([u, l]) => {
|
|
13
|
+
n.addResourceBundle(a, u, l, !0, !0);
|
|
14
|
+
});
|
|
15
|
+
}) : i.use(d).init({
|
|
12
16
|
resources: e,
|
|
13
|
-
lng:
|
|
17
|
+
lng: s,
|
|
14
18
|
fallbackLng: "en",
|
|
15
19
|
ns: o,
|
|
16
20
|
interpolation: {
|
|
17
21
|
escapeValue: !1
|
|
18
22
|
}
|
|
19
|
-
}),
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
}), n;
|
|
24
|
+
}, E = (t, e, s) => {
|
|
25
|
+
(s || n).addResourceBundle(
|
|
26
|
+
t,
|
|
23
27
|
o,
|
|
24
28
|
e,
|
|
25
29
|
!0,
|
|
@@ -27,7 +31,7 @@ const i = {
|
|
|
27
31
|
);
|
|
28
32
|
};
|
|
29
33
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
p as defaultTranslations,
|
|
35
|
+
A as setupI18n,
|
|
36
|
+
E as updateTranslations
|
|
33
37
|
};
|
package/dist/util/DateUtil.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
const m = (
|
|
1
|
+
import t from "dayjs";
|
|
2
|
+
import o from "i18next";
|
|
3
|
+
const m = (a) => t(a).locale(o.language).format("YYYY-MM-DD HH:mm"), r = (a) => t(a).locale(o.language).format("YYYY-MM-DD HH:mm:ss"), n = (a) => t(a).locale(o.language).format("YYYY-MM-DD"), l = (a, e = "HH:mm:ss") => t(a).locale(o.language).format(e), s = { formatDateTime: m, formatDate: n, formatDateTimeWithSecond: r, formatTime: l };
|
|
4
4
|
export {
|
|
5
5
|
s as default
|
|
6
6
|
};
|