@kingteza/crud-component 1.0.39 → 1.0.42
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/common/button/Button.cjs.js +1 -1
- package/common/button/Button.es.js +19 -20
- package/common/button/CloneButtonTable.cjs.js +1 -1
- package/common/button/CloneButtonTable.es.js +9 -10
- package/common/button/DeleteButtonTable.cjs.js +1 -1
- package/common/button/DeleteButtonTable.es.js +29 -33
- package/common/button/ExportButton.cjs.js +1 -1
- package/common/button/ExportButton.es.js +10 -11
- package/common/button/HideButtonTable.cjs.js +1 -1
- package/common/button/HideButtonTable.es.js +22 -23
- package/common/button/ImportButton.cjs.js +1 -1
- package/common/button/ImportButton.es.js +19 -20
- package/common/button/NewButton.cjs.js +1 -1
- package/common/button/NewButton.es.js +13 -14
- package/common/button/PrintButton.cjs.js +1 -1
- package/common/button/PrintButton.es.js +11 -12
- package/common/button/RefreshButton.cjs.js +1 -1
- package/common/button/RefreshButton.es.js +10 -11
- package/common/button/UnHideButton.cjs.js +1 -1
- package/common/button/UnHideButton.es.js +37 -38
- package/common/button/UpdateButtonTable.cjs.js +1 -1
- package/common/button/UpdateButtonTable.es.js +8 -9
- package/common/button/ViewButtonTable.cjs.js +1 -1
- package/common/button/ViewButtonTable.es.js +10 -11
- package/common/date-picker/DatePicker.cjs.js +1 -1
- package/common/date-picker/DatePicker.es.js +40 -41
- package/common/date-picker/TimePicker.cjs.js +1 -1
- package/common/date-picker/TimePicker.es.js +47 -48
- package/common/loading/LoadingIndicator.cjs.js +1 -1
- package/common/loading/LoadingIndicator.es.js +6 -7
- package/common/picker/ImagePicker.cjs.js +1 -1
- package/common/picker/ImagePicker.es.js +80 -81
- package/common/select/SelectComponent.cjs.js +1 -1
- package/common/select/SelectComponent.es.js +33 -34
- package/common/tag/StatusTag.cjs.js +1 -1
- package/common/tag/StatusTag.es.js +12 -13
- package/common/text-field/NumberField.cjs.js +1 -1
- package/common/text-field/NumberField.es.js +41 -42
- package/common/text-field/TextArea.cjs.js +1 -1
- package/common/text-field/TextArea.es.js +15 -16
- package/common/text-field/TextField.cjs.js +1 -1
- package/common/text-field/TextField.es.js +50 -51
- package/common/wizard/WizardResult.cjs.js +1 -1
- package/common/wizard/WizardResult.es.js +36 -38
- package/crud/CrudComponent.cjs.js +1 -1
- package/crud/CrudComponent.es.js +77 -78
- package/crud/CrudField.cjs.js +1 -1
- package/crud/CrudField.es.js +126 -127
- package/crud/CrudFormWizard.cjs.js +1 -1
- package/crud/CrudFormWizard.es.js +47 -48
- package/crud/FileCrudField.cjs.js +1 -1
- package/crud/FileCrudField.es.js +72 -73
- package/crud/import/CrudImportButton.cjs.js +1 -1
- package/crud/import/CrudImportButton.es.js +10 -11
- package/crud/import/CrudImportComponent.cjs.js +2 -2
- package/crud/import/CrudImportComponent.es.js +56 -57
- package/crud/view/CrudDecListView.cjs.js +1 -1
- package/crud/view/CrudDecListView.es.js +11 -12
- package/crud/view/CrudViewer.cjs.js +1 -1
- package/crud/view/CrudViewer.es.js +120 -121
- package/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/crud/view/CrudViewerUtil.es.js +15 -17
- package/locale/index.cjs.js +1 -1
- package/locale/index.d.ts +8 -4
- package/locale/index.es.js +36 -24
- package/package.json +1 -1
- package/util/ValidationUtil.cjs.js +1 -1
- package/util/ValidationUtil.es.js +26 -23
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { Form as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const T = (r, e, t, n) => {
|
|
2
|
+
import { Form as u, Input as p } from "antd";
|
|
3
|
+
import { useTranslationLib as I } from "../../locale/index.es.js";
|
|
4
|
+
const f = (n, e, t, r) => {
|
|
6
5
|
var o;
|
|
7
|
-
e && t && (
|
|
6
|
+
e && t && (n.preventDefault(), (o = t == null ? void 0 : t.getFieldInstance(e)) == null || o.focus()), r && r(n);
|
|
8
7
|
}, g = ({
|
|
9
|
-
required:
|
|
8
|
+
required: n,
|
|
10
9
|
label: e,
|
|
11
10
|
rules: t = [],
|
|
12
|
-
placeholder:
|
|
11
|
+
placeholder: r,
|
|
13
12
|
onEnter: o,
|
|
14
|
-
nextFocus:
|
|
13
|
+
nextFocus: c,
|
|
15
14
|
className: i,
|
|
16
15
|
...s
|
|
17
16
|
}) => {
|
|
18
|
-
const { t:
|
|
17
|
+
const { t: d } = I(), l = u.useFormInstance();
|
|
19
18
|
return /* @__PURE__ */ a(
|
|
20
|
-
|
|
19
|
+
u.Item,
|
|
21
20
|
{
|
|
22
21
|
...s,
|
|
23
22
|
className: i,
|
|
@@ -25,17 +24,17 @@ const T = (r, e, t, n) => {
|
|
|
25
24
|
rules: [
|
|
26
25
|
...t,
|
|
27
26
|
{
|
|
28
|
-
required:
|
|
29
|
-
message: `${e} ${
|
|
27
|
+
required: n,
|
|
28
|
+
message: `${e} ${d("err.validation.required")}`
|
|
30
29
|
}
|
|
31
30
|
],
|
|
32
31
|
children: /* @__PURE__ */ a(
|
|
33
|
-
|
|
32
|
+
p.TextArea,
|
|
34
33
|
{
|
|
35
34
|
...s,
|
|
36
35
|
className: i,
|
|
37
|
-
onPressEnter: (
|
|
38
|
-
placeholder:
|
|
36
|
+
onPressEnter: (m) => f(m, c, l, o),
|
|
37
|
+
placeholder: r ?? e
|
|
39
38
|
}
|
|
40
39
|
)
|
|
41
40
|
}
|
|
@@ -43,5 +42,5 @@ const T = (r, e, t, n) => {
|
|
|
43
42
|
};
|
|
44
43
|
export {
|
|
45
44
|
g as default,
|
|
46
|
-
|
|
45
|
+
f as onEnterInternalTextField
|
|
47
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),R=require("@ant-design/icons"),d=require("antd"),S=require("react"),_=require("../../locale/index.cjs.js"),$=require("../tooltip/TooltipComponent.cjs.js"),c=(n,t,e,i)=>{var s;t&&e&&(n.preventDefault(),(s=e==null?void 0:e.getFieldInstance(t))==null||s.focus()),i&&i(n)},A=({type:n,required:t,label:e,disabled:i,rules:s=[],placeholder:u,onEnter:l,size:p,form:x,addonAfter:g,addonBefore:m,nextFocus:f,autoComplete:j="off",defaultValue:q,readOnly:v,value:I,loading:T,onBlur:F,inputRef:P,status:h,autoFocus:C,onChange:D,tooltip:E,...M})=>{const{t:a}=_.useTranslationLib(),w=S.useMemo(()=>{const r=[...s,{required:t,message:`${e??u??""} ${a("err.validation.required")}`}];return n==="email"&&r.push({type:"email",message:a("err.validation.invalidEmail")}),r},[s,t,e,u,a,n]),L={disabled:i,value:I,readOnly:v,defaultValue:q,autoFocus:C,addonBefore:m,ref:P,onBlur:F,addonAfter:T?o.jsx(R.LoadingOutlined,{}):g,status:h,size:p,autoComplete:j,onPressEnter:r=>c(r,f,x,l),type:n,placeholder:u??e},O=n=="password"?d.Input.Password:d.Input;return o.jsx($,{title:E,children:o.jsx(d.Form.Item,{...M,label:e,rules:w,children:o.jsx(O,{...L})})})};exports.default=A;exports.onEnterInternalTextField=c;
|
|
@@ -1,73 +1,72 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { LoadingOutlined as
|
|
3
|
-
import { Input as d, Form as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
const _ = (o, n, t, r) => {
|
|
2
|
+
import { LoadingOutlined as D } from "@ant-design/icons";
|
|
3
|
+
import { Input as d, Form as M } from "antd";
|
|
4
|
+
import { useMemo as O } from "react";
|
|
5
|
+
import { useTranslationLib as k } from "../../locale/index.es.js";
|
|
6
|
+
import q from "../tooltip/TooltipComponent.es.js";
|
|
7
|
+
const z = (n, o, t, e) => {
|
|
9
8
|
var i;
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
type:
|
|
13
|
-
required:
|
|
9
|
+
o && t && (n.preventDefault(), (i = t == null ? void 0 : t.getFieldInstance(o)) == null || i.focus()), e && e(n);
|
|
10
|
+
}, R = ({
|
|
11
|
+
type: n,
|
|
12
|
+
required: o,
|
|
14
13
|
label: t,
|
|
15
|
-
disabled:
|
|
14
|
+
disabled: e,
|
|
16
15
|
rules: i = [],
|
|
17
|
-
placeholder:
|
|
16
|
+
placeholder: a,
|
|
18
17
|
onEnter: p,
|
|
19
18
|
size: f,
|
|
20
19
|
form: l,
|
|
21
20
|
addonAfter: u,
|
|
22
21
|
addonBefore: c,
|
|
23
|
-
nextFocus:
|
|
24
|
-
autoComplete:
|
|
25
|
-
defaultValue:
|
|
26
|
-
readOnly:
|
|
27
|
-
value:
|
|
28
|
-
loading:
|
|
29
|
-
onBlur:
|
|
30
|
-
inputRef:
|
|
31
|
-
status:
|
|
32
|
-
autoFocus:
|
|
33
|
-
onChange:
|
|
34
|
-
tooltip:
|
|
35
|
-
...
|
|
22
|
+
nextFocus: g,
|
|
23
|
+
autoComplete: v = "off",
|
|
24
|
+
defaultValue: I,
|
|
25
|
+
readOnly: T,
|
|
26
|
+
value: h,
|
|
27
|
+
loading: x,
|
|
28
|
+
onBlur: C,
|
|
29
|
+
inputRef: F,
|
|
30
|
+
status: P,
|
|
31
|
+
autoFocus: w,
|
|
32
|
+
onChange: B,
|
|
33
|
+
tooltip: E,
|
|
34
|
+
...L
|
|
36
35
|
}) => {
|
|
37
|
-
const { t:
|
|
38
|
-
const
|
|
36
|
+
const { t: m } = k(), $ = O(() => {
|
|
37
|
+
const r = [
|
|
39
38
|
...i,
|
|
40
39
|
{
|
|
41
|
-
required:
|
|
42
|
-
message: `${t ??
|
|
40
|
+
required: o,
|
|
41
|
+
message: `${t ?? a ?? ""} ${m(
|
|
43
42
|
"err.validation.required"
|
|
44
43
|
)}`
|
|
45
44
|
}
|
|
46
45
|
];
|
|
47
|
-
return
|
|
46
|
+
return n === "email" && r.push({
|
|
48
47
|
type: "email",
|
|
49
|
-
message:
|
|
50
|
-
}),
|
|
51
|
-
}, [i,
|
|
52
|
-
disabled:
|
|
53
|
-
value:
|
|
54
|
-
readOnly:
|
|
55
|
-
defaultValue:
|
|
56
|
-
autoFocus:
|
|
48
|
+
message: m("err.validation.invalidEmail")
|
|
49
|
+
}), r;
|
|
50
|
+
}, [i, o, t, a, m, n]), j = {
|
|
51
|
+
disabled: e,
|
|
52
|
+
value: h,
|
|
53
|
+
readOnly: T,
|
|
54
|
+
defaultValue: I,
|
|
55
|
+
autoFocus: w,
|
|
57
56
|
addonBefore: c,
|
|
58
|
-
ref:
|
|
59
|
-
onBlur:
|
|
60
|
-
addonAfter:
|
|
61
|
-
status:
|
|
57
|
+
ref: F,
|
|
58
|
+
onBlur: C,
|
|
59
|
+
addonAfter: x ? /* @__PURE__ */ s(D, {}) : u,
|
|
60
|
+
status: P,
|
|
62
61
|
size: f,
|
|
63
|
-
autoComplete:
|
|
64
|
-
onPressEnter: (
|
|
65
|
-
type:
|
|
66
|
-
placeholder:
|
|
67
|
-
},
|
|
68
|
-
return /* @__PURE__ */ s(
|
|
62
|
+
autoComplete: v,
|
|
63
|
+
onPressEnter: (r) => z(r, g, l, p),
|
|
64
|
+
type: n,
|
|
65
|
+
placeholder: a ?? t
|
|
66
|
+
}, A = n == "password" ? d.Password : d;
|
|
67
|
+
return /* @__PURE__ */ s(q, { title: E, children: /* @__PURE__ */ s(M.Item, { ...L, label: t, rules: $, children: /* @__PURE__ */ s(A, { ...j }) }) });
|
|
69
68
|
};
|
|
70
69
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
R as default,
|
|
71
|
+
z as onEnterInternalTextField
|
|
73
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),l=require("@ant-design/icons"),r=require("antd"),x=require("../button/Button.cjs.js"),b=require("../../locale/index.cjs.js"),F=({errorChildren:v,children:a,onRetry:c,onClickBack:u,success:e,loading:o,error:i,successTitle:j,successMessage:p,errorMessage:n,errorTitle:m,loadingTitle:y,loadingMessage:T})=>{const{t:s}=b.useTranslationLib(),f=j??s("str.success"),q=m??s("str.error"),d=n?typeof n=="function"?n():n:s("err.save"),h=y??s("message.loading.saving");return t.jsx(r.Result,{status:o?void 0:e?"success":i?["403","404","500"].includes(i==null?void 0:i.code)?i.code:i?"error":void 0:void 0,title:o?h:e?f:i?q:void 0,icon:o?t.jsx(l.LoadingOutlined,{}):void 0,subTitle:o?T:e?p:i?typeof n=="function"?n()??d:n??d:void 0,extra:[e?t.jsx(t.Fragment,{children:a}):i?t.jsxs(t.Fragment,{children:[!!u&&t.jsx(x,{onClick:u,htmlType:"button",type:"primary",icon:t.jsx(l.ArrowLeftOutlined,{}),children:s("str.previous")}),!!c&&t.jsx(x,{type:"primary",onClick:()=>c(void 0,void 0,!0),children:s("str.retry")},"retry"),v]}):t.jsx(t.Fragment,{})]})};module.exports=F;
|
|
@@ -1,60 +1,58 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { LoadingOutlined as
|
|
3
|
-
import { Result as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
success: o,
|
|
14
|
-
loading: e,
|
|
1
|
+
import { jsx as o, Fragment as s, jsxs as j } from "react/jsx-runtime";
|
|
2
|
+
import { LoadingOutlined as B, ArrowLeftOutlined as C } from "@ant-design/icons";
|
|
3
|
+
import { Result as O } from "antd";
|
|
4
|
+
import e from "../button/Button.es.js";
|
|
5
|
+
import { useTranslationLib as r } from "../../locale/index.es.js";
|
|
6
|
+
const W = ({
|
|
7
|
+
errorChildren: p,
|
|
8
|
+
children: f,
|
|
9
|
+
onRetry: c,
|
|
10
|
+
onClickBack: m,
|
|
11
|
+
success: d,
|
|
12
|
+
loading: l,
|
|
15
13
|
error: t,
|
|
16
|
-
successTitle: v
|
|
17
|
-
successMessage:
|
|
18
|
-
errorMessage:
|
|
19
|
-
errorTitle:
|
|
20
|
-
loadingTitle:
|
|
21
|
-
loadingMessage:
|
|
14
|
+
successTitle: v,
|
|
15
|
+
successMessage: a,
|
|
16
|
+
errorMessage: i,
|
|
17
|
+
errorTitle: y,
|
|
18
|
+
loadingTitle: T,
|
|
19
|
+
loadingMessage: h
|
|
22
20
|
}) => {
|
|
23
|
-
const { t: n } = L(
|
|
24
|
-
return /* @__PURE__ */
|
|
25
|
-
|
|
21
|
+
const { t: n } = r(), x = v ?? n("str.success"), b = y ?? n("str.error"), u = i ? typeof i == "function" ? i() : i : n("err.save"), L = T ?? n("message.loading.saving");
|
|
22
|
+
return /* @__PURE__ */ o(
|
|
23
|
+
O,
|
|
26
24
|
{
|
|
27
|
-
status:
|
|
28
|
-
title:
|
|
29
|
-
icon:
|
|
30
|
-
subTitle:
|
|
25
|
+
status: l ? void 0 : d ? "success" : t ? ["403", "404", "500"].includes(t == null ? void 0 : t.code) ? t.code : t ? "error" : void 0 : void 0,
|
|
26
|
+
title: l ? L : d ? x : t ? b : void 0,
|
|
27
|
+
icon: l ? /* @__PURE__ */ o(B, {}) : void 0,
|
|
28
|
+
subTitle: l ? h : d ? a : t ? typeof i == "function" ? i() ?? u : i ?? u : void 0,
|
|
31
29
|
extra: [
|
|
32
|
-
|
|
33
|
-
!!
|
|
34
|
-
|
|
30
|
+
d ? /* @__PURE__ */ o(s, { children: f }) : t ? /* @__PURE__ */ j(s, { children: [
|
|
31
|
+
!!m && /* @__PURE__ */ o(
|
|
32
|
+
e,
|
|
35
33
|
{
|
|
36
|
-
onClick:
|
|
34
|
+
onClick: m,
|
|
37
35
|
htmlType: "button",
|
|
38
36
|
type: "primary",
|
|
39
|
-
icon: /* @__PURE__ */
|
|
37
|
+
icon: /* @__PURE__ */ o(C, {}),
|
|
40
38
|
children: n("str.previous")
|
|
41
39
|
}
|
|
42
40
|
),
|
|
43
|
-
!!
|
|
44
|
-
|
|
41
|
+
!!c && /* @__PURE__ */ o(
|
|
42
|
+
e,
|
|
45
43
|
{
|
|
46
44
|
type: "primary",
|
|
47
|
-
onClick: () =>
|
|
45
|
+
onClick: () => c(void 0, void 0, !0),
|
|
48
46
|
children: n("str.retry")
|
|
49
47
|
},
|
|
50
48
|
"retry"
|
|
51
49
|
),
|
|
52
|
-
|
|
53
|
-
] }) : /* @__PURE__ */
|
|
50
|
+
p
|
|
51
|
+
] }) : /* @__PURE__ */ o(s, {})
|
|
54
52
|
]
|
|
55
53
|
}
|
|
56
54
|
);
|
|
57
55
|
};
|
|
58
56
|
export {
|
|
59
|
-
|
|
57
|
+
W as default
|
|
60
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),y=require("antd"),ae=require("dayjs"),o=require("react"),le=require("
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),y=require("antd"),ae=require("dayjs"),o=require("react"),le=require("./CrudForm.cjs.js"),ie=require("./CrudFormWizard.cjs.js"),ce=require("./import/CrudImportButton.cjs.js"),re=require("./view/CrudViewer.cjs.js"),ue=require("../common/button/NewButton.cjs.js"),de=require("../common/button/PrintButton.cjs.js"),fe=require("../locale/index.cjs.js"),{useForm:pe}=y.Form;function me({idField:x="id",onCreate:g,onDelete:T,onHide:U,onUpdate:f,fields:l,data:W,grid:_,isHiding:A,isCreating:S,isDeleting:E,isUpdating:q,paginateProps:L,onPrint:V,printing:R,viewable:H,loadingData:G,formBuilder:J,extraAction:K,minusHeight:Q,cloneable:X,fullWidthModal:Y=!0,wizard:i,extraView:Z,importable:P,onClickNew:N,...$}){const{t:v}=fe.useTranslationLib(),[j,F]=o.useState(!1),[p,k]=o.useState(),[z,B]=o.useState(),[c]=pe(),O=o.useCallback(async s=>{const u=i?s:await c.validateFields(),r=l.filter(e=>e.type==="color"),a={};r.forEach(e=>{var d;const t=c.getFieldValue(e.name);a[e.name]=typeof t=="string"?t:(d=t==null?void 0:t.toHexString())==null?void 0:d.toUpperCase()}),Object.assign(u,a),p&&f?(await f({...u,[x]:p[x]}),k(void 0)):!p&&g&&await g(u),B(void 0),c.resetFields(),F(!1)},[l,c,x,g,f,p,i]),[ee,w]=o.useState(!1),[te,b]=o.useState(!1);o.useEffect(()=>{j?(w(!1),b(!1)):C(void 0)},[j]);const D=o.useCallback(async s=>{w(s),b(!0)},[]),I=o.useCallback(async()=>{b(!0)},[]),[ne,M]=o.useState(!1),h=o.useCallback(async(s,u=!0,r=!1)=>{try{M(!0),F(!0),u&&C("update");const a={};for(const e of l){const t=s[e.name];if(r&&e.type==="image"){const d=t;try{const oe=await e.provider.clone(d);a[e.name]=oe;continue}catch{continue}}e.type==="date"?t&&(a[e.name]=ae(t)):e.type==="select"?e.multiple&&Array.isArray(t)?a[e.name]=t.map(d=>d[e.innerFieldId??"id"]):t&&typeof t=="object"?a[e.name]=t[e.innerFieldId??"id"]:(t&&typeof t=="string"||typeof t=="number")&&(a[e.name]=t):a[e.name]=t}c.setFieldsValue(a),B(a),u&&k(s)}finally{M(!1)}},[l,c]),[m,C]=o.useState(),se=o.useCallback(async s=>{C("clone"),h(s,!1,!0)},[h]);return n.jsxs(n.Fragment,{children:[n.jsxs(y.Space,{direction:"vertical",className:"w-100",children:[n.jsxs("div",{className:"w-100 d-flex",children:[n.jsx("div",{style:{flex:1},children:n.jsx(ue.NewButton,{onClick:()=>{N?N():(F(s=>!s),C("new"))},className:"flex-1"})}),n.jsxs(y.Space,{children:[!!V&&n.jsx(de.PrintButton,{className:"float-right",loading:R,onClick:V}),!!P&&n.jsx(ce,{fields:l,importProps:P})]})]}),n.jsx(re,{...$,minusHeight:Q,data:W,fields:l,extraAction:K,idField:x,isDeleting:E,loadingData:G,onClickUpdate:f?h:void 0,onHide:U,isHiding:A,onDelete:T,onUpdate:f,onClickClone:X?se:void 0,paginateProps:L,viewable:H,extraView:Z})]}),n.jsx(y.Modal,{width:Y?"100%":void 0,title:v(m??"new"),open:j,confirmLoading:S||q,okText:v("str."+(m==="update"?"update":"save")),cancelText:v("str.cancel"),cancelButtonProps:{disabled:te,hidden:!!i},okButtonProps:{disabled:ee,hidden:!!i},onCancel:async()=>{try{if(m==="clone"){const s=i?p:c.getFieldsValue(),u=l.filter(r=>r.type==="image");for(const r of u)s[r.name]&&r.provider.delete(s[r.name])}}finally{}i||c.resetFields(),B(void 0),k(void 0),F(!1)},onOk:()=>O(),destroyOnClose:!0,children:n.jsxs(y.Spin,{spinning:ne,children:[!i&&n.jsx(le.CrudForm,{purpose:m,fields:l,form:c,formBuilder:J,grid:_,onDeleteFile:I,onUploadFile:D}),i&&n.jsx(ie,{submitting:S||q,className:"mt-2",onSave:O,updatingValue:z,fields:l,onDeleteFile:I,onUploadFile:D,purpose:m,wizard:i})]})})]})}module.exports=me;
|
package/crud/CrudComponent.es.js
CHANGED
|
@@ -1,142 +1,141 @@
|
|
|
1
1
|
import { jsxs as y, Fragment as se, jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import { Space as
|
|
3
|
-
import
|
|
4
|
-
import { useState as m, useCallback as F, useEffect as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import Fe from "./
|
|
9
|
-
import ge from "
|
|
10
|
-
import ve from "
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
const { useForm: he } = me;
|
|
2
|
+
import { Space as _, Modal as re, Spin as ce, Form as me } from "antd";
|
|
3
|
+
import de from "dayjs";
|
|
4
|
+
import { useState as m, useCallback as F, useEffect as fe } from "react";
|
|
5
|
+
import { CrudForm as ue } from "./CrudForm.es.js";
|
|
6
|
+
import pe from "./CrudFormWizard.es.js";
|
|
7
|
+
import ye from "./import/CrudImportButton.es.js";
|
|
8
|
+
import Fe from "./view/CrudViewer.es.js";
|
|
9
|
+
import { NewButton as ge } from "../common/button/NewButton.es.js";
|
|
10
|
+
import { PrintButton as ve } from "../common/button/PrintButton.es.js";
|
|
11
|
+
import { useTranslationLib as Ce } from "../locale/index.es.js";
|
|
12
|
+
const { useForm: Be } = me;
|
|
14
13
|
function Ie({
|
|
15
14
|
idField: g = "id",
|
|
16
15
|
onCreate: B,
|
|
17
|
-
onDelete:
|
|
18
|
-
onHide:
|
|
19
|
-
onUpdate:
|
|
16
|
+
onDelete: w,
|
|
17
|
+
onHide: A,
|
|
18
|
+
onUpdate: f,
|
|
20
19
|
fields: l,
|
|
21
|
-
data:
|
|
20
|
+
data: E,
|
|
22
21
|
grid: L,
|
|
23
22
|
isHiding: H,
|
|
24
|
-
isCreating:
|
|
25
|
-
isDeleting:
|
|
26
|
-
isUpdating:
|
|
27
|
-
paginateProps:
|
|
28
|
-
onPrint:
|
|
29
|
-
printing:
|
|
30
|
-
viewable:
|
|
31
|
-
loadingData:
|
|
32
|
-
formBuilder:
|
|
23
|
+
isCreating: P,
|
|
24
|
+
isDeleting: q,
|
|
25
|
+
isUpdating: j,
|
|
26
|
+
paginateProps: G,
|
|
27
|
+
onPrint: N,
|
|
28
|
+
printing: J,
|
|
29
|
+
viewable: K,
|
|
30
|
+
loadingData: Q,
|
|
31
|
+
formBuilder: R,
|
|
33
32
|
extraAction: X,
|
|
34
33
|
minusHeight: Y,
|
|
35
34
|
cloneable: Z,
|
|
36
35
|
fullWidthModal: $ = !0,
|
|
37
36
|
wizard: a,
|
|
38
37
|
extraView: z,
|
|
39
|
-
importable:
|
|
40
|
-
onClickNew:
|
|
38
|
+
importable: O,
|
|
39
|
+
onClickNew: D,
|
|
41
40
|
...ee
|
|
42
41
|
}) {
|
|
43
|
-
const { t: h } =
|
|
42
|
+
const { t: h } = Ce(), [k, v] = m(!1), [u, b] = m(), [te, x] = m(), [i] = Be(), I = F(
|
|
44
43
|
async (o) => {
|
|
45
44
|
const r = a ? o : await i.validateFields(), s = l.filter((e) => e.type === "color"), n = {};
|
|
46
45
|
s.forEach((e) => {
|
|
47
|
-
var
|
|
46
|
+
var d;
|
|
48
47
|
const t = i.getFieldValue(e.name);
|
|
49
|
-
n[e.name] = typeof t == "string" ? t : (
|
|
50
|
-
}), Object.assign(r, n), u &&
|
|
48
|
+
n[e.name] = typeof t == "string" ? t : (d = t == null ? void 0 : t.toHexString()) == null ? void 0 : d.toUpperCase();
|
|
49
|
+
}), Object.assign(r, n), u && f ? (await f({
|
|
51
50
|
...r,
|
|
52
51
|
[g]: u[g]
|
|
53
52
|
}), b(void 0)) : !u && B && await B(r), x(void 0), i.resetFields(), v(!1);
|
|
54
53
|
},
|
|
55
|
-
[l, i, g, B,
|
|
56
|
-
), [oe,
|
|
57
|
-
|
|
58
|
-
k ? (
|
|
54
|
+
[l, i, g, B, f, u, a]
|
|
55
|
+
), [oe, M] = m(!1), [ne, V] = m(!1);
|
|
56
|
+
fe(() => {
|
|
57
|
+
k ? (M(!1), V(!1)) : C(void 0);
|
|
59
58
|
}, [k]);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
}, []),
|
|
63
|
-
|
|
64
|
-
}, []), [le,
|
|
59
|
+
const T = F(async (o) => {
|
|
60
|
+
M(o), V(!0);
|
|
61
|
+
}, []), U = F(async () => {
|
|
62
|
+
V(!0);
|
|
63
|
+
}, []), [le, W] = m(!1), S = F(
|
|
65
64
|
async (o, r = !0, s = !1) => {
|
|
66
65
|
try {
|
|
67
|
-
|
|
66
|
+
W(!0), v(!0), r && C("update");
|
|
68
67
|
const n = {};
|
|
69
68
|
for (const e of l) {
|
|
70
69
|
const t = o[e.name];
|
|
71
70
|
if (s && e.type === "image") {
|
|
72
|
-
const
|
|
71
|
+
const d = t;
|
|
73
72
|
try {
|
|
74
|
-
const ie = await e.provider.clone(
|
|
73
|
+
const ie = await e.provider.clone(d);
|
|
75
74
|
n[e.name] = ie;
|
|
76
75
|
continue;
|
|
77
76
|
} catch {
|
|
78
77
|
continue;
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
e.type === "date" ? t && (n[e.name] =
|
|
82
|
-
(
|
|
80
|
+
e.type === "date" ? t && (n[e.name] = de(t)) : e.type === "select" ? e.multiple && Array.isArray(t) ? n[e.name] = t.map(
|
|
81
|
+
(d) => d[e.innerFieldId ?? "id"]
|
|
83
82
|
) : t && typeof t == "object" ? n[e.name] = t[e.innerFieldId ?? "id"] : (t && typeof t == "string" || typeof t == "number") && (n[e.name] = t) : n[e.name] = t;
|
|
84
83
|
}
|
|
85
84
|
i.setFieldsValue(n), x(n), r && b(o);
|
|
86
85
|
} finally {
|
|
87
|
-
|
|
86
|
+
W(!1);
|
|
88
87
|
}
|
|
89
88
|
},
|
|
90
89
|
[l, i]
|
|
91
90
|
), [p, C] = m(), ae = F(
|
|
92
91
|
async (o) => {
|
|
93
|
-
C("clone"),
|
|
92
|
+
C("clone"), S(o, !1, !0);
|
|
94
93
|
},
|
|
95
|
-
[
|
|
94
|
+
[S]
|
|
96
95
|
);
|
|
97
96
|
return /* @__PURE__ */ y(se, { children: [
|
|
98
|
-
/* @__PURE__ */ y(
|
|
97
|
+
/* @__PURE__ */ y(_, { direction: "vertical", className: "w-100", children: [
|
|
99
98
|
/* @__PURE__ */ y("div", { className: "w-100 d-flex", children: [
|
|
100
99
|
/* @__PURE__ */ c("div", { style: { flex: 1 }, children: /* @__PURE__ */ c(
|
|
101
|
-
|
|
100
|
+
ge,
|
|
102
101
|
{
|
|
103
102
|
onClick: () => {
|
|
104
|
-
|
|
103
|
+
D ? D() : (v((o) => !o), C("new"));
|
|
105
104
|
},
|
|
106
105
|
className: "flex-1"
|
|
107
106
|
}
|
|
108
107
|
) }),
|
|
109
|
-
/* @__PURE__ */ y(
|
|
110
|
-
!!
|
|
111
|
-
|
|
108
|
+
/* @__PURE__ */ y(_, { children: [
|
|
109
|
+
!!N && /* @__PURE__ */ c(
|
|
110
|
+
ve,
|
|
112
111
|
{
|
|
113
112
|
className: "float-right",
|
|
114
|
-
loading:
|
|
115
|
-
onClick:
|
|
113
|
+
loading: J,
|
|
114
|
+
onClick: N
|
|
116
115
|
}
|
|
117
116
|
),
|
|
118
|
-
!!
|
|
117
|
+
!!O && /* @__PURE__ */ c(ye, { fields: l, importProps: O })
|
|
119
118
|
] })
|
|
120
119
|
] }),
|
|
121
120
|
/* @__PURE__ */ c(
|
|
122
|
-
|
|
121
|
+
Fe,
|
|
123
122
|
{
|
|
124
123
|
...ee,
|
|
125
124
|
minusHeight: Y,
|
|
126
|
-
data:
|
|
125
|
+
data: E,
|
|
127
126
|
fields: l,
|
|
128
127
|
extraAction: X,
|
|
129
128
|
idField: g,
|
|
130
|
-
isDeleting:
|
|
131
|
-
loadingData:
|
|
132
|
-
onClickUpdate:
|
|
133
|
-
onHide:
|
|
129
|
+
isDeleting: q,
|
|
130
|
+
loadingData: Q,
|
|
131
|
+
onClickUpdate: f ? S : void 0,
|
|
132
|
+
onHide: A,
|
|
134
133
|
isHiding: H,
|
|
135
|
-
onDelete:
|
|
136
|
-
onUpdate:
|
|
134
|
+
onDelete: w,
|
|
135
|
+
onUpdate: f,
|
|
137
136
|
onClickClone: Z ? ae : void 0,
|
|
138
|
-
paginateProps:
|
|
139
|
-
viewable:
|
|
137
|
+
paginateProps: G,
|
|
138
|
+
viewable: K,
|
|
140
139
|
extraView: z
|
|
141
140
|
}
|
|
142
141
|
)
|
|
@@ -147,7 +146,7 @@ function Ie({
|
|
|
147
146
|
width: $ ? "100%" : void 0,
|
|
148
147
|
title: h(p ?? "new"),
|
|
149
148
|
open: k,
|
|
150
|
-
confirmLoading:
|
|
149
|
+
confirmLoading: P || j,
|
|
151
150
|
okText: h("str." + (p === "update" ? "update" : "save")),
|
|
152
151
|
cancelText: h("str.cancel"),
|
|
153
152
|
cancelButtonProps: {
|
|
@@ -171,31 +170,31 @@ function Ie({
|
|
|
171
170
|
}
|
|
172
171
|
a || i.resetFields(), x(void 0), b(void 0), v(!1);
|
|
173
172
|
},
|
|
174
|
-
onOk: () =>
|
|
173
|
+
onOk: () => I(),
|
|
175
174
|
destroyOnClose: !0,
|
|
176
175
|
children: /* @__PURE__ */ y(ce, { spinning: le, children: [
|
|
177
176
|
!a && /* @__PURE__ */ c(
|
|
178
|
-
|
|
177
|
+
ue,
|
|
179
178
|
{
|
|
180
179
|
purpose: p,
|
|
181
180
|
fields: l,
|
|
182
181
|
form: i,
|
|
183
|
-
formBuilder:
|
|
182
|
+
formBuilder: R,
|
|
184
183
|
grid: L,
|
|
185
|
-
onDeleteFile:
|
|
186
|
-
onUploadFile:
|
|
184
|
+
onDeleteFile: U,
|
|
185
|
+
onUploadFile: T
|
|
187
186
|
}
|
|
188
187
|
),
|
|
189
188
|
a && /* @__PURE__ */ c(
|
|
190
|
-
|
|
189
|
+
pe,
|
|
191
190
|
{
|
|
192
|
-
submitting:
|
|
191
|
+
submitting: P || j,
|
|
193
192
|
className: "mt-2",
|
|
194
|
-
onSave:
|
|
193
|
+
onSave: I,
|
|
195
194
|
updatingValue: te,
|
|
196
195
|
fields: l,
|
|
197
|
-
onDeleteFile:
|
|
198
|
-
onUploadFile:
|
|
196
|
+
onDeleteFile: U,
|
|
197
|
+
onUploadFile: T,
|
|
199
198
|
purpose: p,
|
|
200
199
|
wizard: a
|
|
201
200
|
}
|
package/crud/CrudField.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),v=require("antd"),q=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),v=require("antd"),q=require("react"),_=require("react-highlight-words"),W=require("../locale/index.cjs.js"),G=require("./FileCrudField.cjs.js"),$=require("./ImageCrudField.cjs.js"),z=require("../common/check-box/CheckBox.cjs.js"),J=require("../common/date-picker/DatePicker.cjs.js"),K=require("../common/date-picker/TimePicker.cjs.js"),B=require("../common/select/SelectComponent.cjs.js"),Q=require("../common/text-field/NumberField.cjs.js"),X=require("../common/text-field/TextField.cjs.js"),Y=require("../common/text-field/TextArea.cjs.js"),Z=require("../common/tooltip/TooltipComponent.cjs.js");function V(F){const{label:o,name:c,type:p,required:i,hidden:N,rules:m=[],updatable:h=!0,readonly:w=!1,fieldClassName:f,customFormFieldRender:S,fieldTooltip:b,...e}=F,g=v.Form.useFormInstance();q.useEffect(()=>{if(p==="select"){const{items:a=[],onSearch:n,searchOnType:l}=e;!(a!=null&&a.length)&&!l&&(n==null||n(void 0,g,e==null?void 0:e.updatingValue))}},[g,e,p,e==null?void 0:e.updatingValue]);const{t:T}=W.useTranslationLib();if(w||N)return t.jsx(t.Fragment,{});if(S)return S(g,F);switch(p){case"text":case"email":case"password":{const{onChange:a,placeholder:n}=e;return t.jsx(X.default,{placeholder:n,disabled:!h,rules:m,required:i,onChange:a?l=>a(l,g):void 0,type:p,name:c,tooltip:b,label:o,className:f,autoComplete:"new-password"})}case"number":{const{onChange:a,placeholder:n,allowMinus:l}=e;return t.jsx(Q,{placeholder:n,disabled:!h,moneyField:!!e.formatted,type:p,onChange:a?C=>a(C,g):void 0,rules:m,autoComplete:"false",required:i,tooltip:b,className:f,min:l?null:void 0,name:c,label:o})}case"date":{const{range:a,disableToday:n,disabledFutureDays:l,disabledPastDays:C,onChange:x,placeholder:u,format:y}=e;return t.jsx(J,{placeholder:u,required:i,disabled:!h,type:p,format:y,tooltip:b,range:a,name:c,label:o,onChange:x?s=>x(s,g):void 0,className:f,disableToday:n,disabledFutureDays:l,disabledPastDays:C})}case"time":{const{range:a=!1,disableCurrent:n,disabledFuture:l,disabledPast:C,onChange:x,use12Hours:u,format:y,placeholder:s}=e;return t.jsx(K,{placeholder:s,required:i,format:y,disabled:!h,type:p,tooltip:b,range:a,use12Hours:u,name:c,label:o,onChange:x?j=>x(j,g):void 0,className:f,disableCurrent:n,disabledFuture:l,disabledPast:C})}case"textarea":{const{onChange:a,placeholder:n,rows:l,cols:C}=e;return t.jsx(Y.default,{rules:m,placeholder:n,onChange:a?x=>{var u;return a((u=x==null?void 0:x.target)==null?void 0:u.value,g)}:void 0,tooltip:b,required:i,disabled:!h,name:c,label:o,className:f,rows:l,cols:C})}case"image":return t.jsx($.default,{...e,required:i,name:c,label:o,rules:m,fieldClassName:f,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"file":return t.jsx(G.default,{...e,required:i,name:c,label:o,rules:m,fieldClassName:f,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"select":return t.jsx(E,{...e,required:i,name:c,label:o,rules:m,fieldClassName:f,form:g,updatable:h,readonly:w,fieldTooltip:b});case"enum":{const{enum:a,radio:n=!1,translation:l,onChange:C,onSearch:x,multiple:u}=e,y=Array.isArray(a)?a:Object.keys(a);return n?t.jsx(v.Form.Item,{...e,name:c,required:i,tooltip:b,rules:m,label:o,className:["w-100",f].join(" "),children:t.jsx(v.Radio.Group,{...e,onChange:C?s=>{var j;return C((j=s==null?void 0:s.target)==null?void 0:j.value,g)}:void 0,children:y.map(s=>t.jsx(v.Radio,{disabled:!h,value:s,children:l?T(l[s]):s},s))})}):t.jsx(B,{...e,onChange:C?s=>C(s,g):void 0,className:["w-100",f].join(" "),name:c,items:y,required:i,tooltip:b,rules:m,label:o,disabled:!h,onSearch:x?s=>x(s,g):void 0,allowClear:!0,mode:u?"multiple":void 0,itemBuilder:s=>t.jsx(v.Select.Option,{value:s,children:l?T(l[s]):s},s)})}case"checkbox":{const{onChange:a}=e;return t.jsx(z,{className:f,rules:m,onChange:a?n=>a(n,g):void 0,label:o,tooltip:b,disabled:!h,name:c})}case"color":return t.jsx(H,{...e,type:"color",required:i,name:c,label:o,rules:m,fieldClassName:f,updatable:h,readonly:w,fieldTooltip:b});default:return t.jsx(t.Fragment,{children:`${p} Not Implemented`})}}function E(F){const{items:o=[],loading:c,searchOnType:p,onSearch:i,multiple:N,onChange:m,highlightSearch:h,required:w,fieldClassName:f,rules:S,fieldTooltip:b,updatable:e,label:g,name:T,tagRender:a,updatingValue:n,onSet:l,placeholder:C,allowClear:x=!0}=F,u=F.form,[y,s]=q.useState(""),j=v.Form.useWatch(T,u),[k,O]=q.useState(!0);q.useEffect(()=>{l&&k&&j&&(l==null||l(j,o,u),O(!1))},[k,u,o,T,l,j]),q.useEffect(()=>{j&&O(!0)},[j]);const U=q.useCallback(async r=>{s(r),p&&(i==null||i(r,u,n))},[u,i,p,n]);return t.jsx(B,{...F,maxTagCount:"responsive",maxTagPlaceholder:r=>t.jsxs(Z,{title:t.jsx(t.Fragment,{children:r.map(d=>t.jsxs(t.Fragment,{children:[d.label," ",t.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:C,onSelect:r=>{l==null||l(r==null?void 0:r.key,o,u)},onChange:m?r=>{s(""),m(r,u)}:void 0,mode:N?"multiple":void 0,className:["w-100",f].join(" "),name:T,items:o,required:w,tooltip:b,tagRender:a,rules:S,disabled:!e,label:g,allowClear:x,onSearch:U,loading:c,filterOption:h?(r,d)=>{var R,P,I;try{const L=r.toLowerCase().split(/\s+/),D=((typeof(d==null?void 0:d.children)=="string"?d==null?void 0:d.children:(P=(R=d==null?void 0:d.children)==null?void 0:R.props)==null?void 0:P.textToHighlight)??"").toLowerCase(),M=(((I=d==null?void 0:d.value)==null?void 0:I.toString())??"").toLowerCase();return L.every(A=>D.indexOf(A)>=0||M.indexOf(A)>=0)}catch{return!0}}:void 0,itemBuilder:h?r=>{const d=r.value?String(r.value):void 0;return t.jsx(v.Select.Option,{value:r.key,title:d,disabled:r.disabled,children:t.jsx(_,{highlightClassName:"highlight-text",searchWords:(y??"").split(" "),autoEscape:!0,textToHighlight:d??""})},r.key)}:r=>t.jsx(v.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:r.value},r.key)})}function H(F){const{required:o,fieldClassName:c,rules:p,fieldTooltip:i,updatable:N,label:m,name:h}=F;return t.jsx(v.Form.Item,{label:m,name:h,required:o,rules:p,tooltip:i,children:t.jsx(v.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:c,disabled:!N,...F.innerProps})})}exports.ColorCrudFieldComponent=H;exports.SelectCrudFieldComponent=E;exports.default=V;
|