@kingteza/crud-component 1.0.56 → 1.0.58
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/App.d.ts +5 -0
- package/common/button/Button.cjs.js +1 -1
- package/common/button/Button.d.ts +2 -3
- package/common/button/Button.es.js +54 -61
- package/crud/CrudComponent.cjs.js +1 -1
- package/crud/CrudComponent.d.ts +5 -1
- package/crud/CrudComponent.es.js +138 -137
- package/crud/CrudField.cjs.js +1 -1
- package/crud/CrudField.es.js +160 -159
- package/crud/CrudForm.cjs.js +1 -1
- package/crud/CrudForm.es.js +57 -56
- package/crud/CrudFormWizard.cjs.js +1 -1
- package/crud/CrudFormWizard.es.js +53 -52
- package/crud/CrudSearchComponent.cjs.js +1 -1
- package/crud/CrudSearchComponent.es.js +39 -38
- package/crud/CrudTextAreaComponent.cjs.js +1 -1
- package/crud/CrudTextAreaComponent.es.js +29 -28
- package/crud/FileCrudField.cjs.js +1 -1
- package/crud/FileCrudField.es.js +70 -69
- package/crud/view/CrudDecListView.cjs.js +1 -1
- package/crud/view/CrudDecListView.es.js +29 -25
- package/crud/view/CrudViewer.cjs.js +1 -1
- package/crud/view/CrudViewer.es.js +137 -133
- package/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/crud/view/CrudViewerUtil.es.js +51 -48
- package/hooks/NavigatorHooks.cjs.js +1 -1
- package/hooks/NavigatorHooks.d.ts +1 -1
- package/hooks/NavigatorHooks.es.js +4 -3
- package/package.json +2 -2
- package/util/CrudUtil.cjs.js +1 -0
- package/util/CrudUtil.d.ts +5 -0
- package/util/CrudUtil.es.js +8 -0
package/App.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const l=require("react/jsx-runtime"),d=require("antd"),s=require("react"),j=require("../../locale/index.cjs.js");;/* empty css */const x=require("../../hooks/NavigatorHooks.cjs.js"),y=s.forwardRef(({className:r,to:n,onClick:e,tooltip:a,...t},u)=>{const{t:i}=j.useTranslationLib(),o=x.useNavigateOptional(),c=s.useMemo(()=>l.jsx(d.Button,{ref:u,onClick:e??(n&&o?()=>o(n):void 0),className:r,...t,children:t.children}),[r,o,e,t,i,n]);return a?l.jsx(d.Tooltip,{title:a,children:c}):c}),q=s.forwardRef(({className:r,to:n,onClick:e,tooltip:a,...t},u)=>{const i=x.useNavigateOptional(),[o,c]=s.useState(!1),f=s.useCallback(async h=>{try{return c(!0),await e(h)}finally{c(!1)}},[e]),g=s.useMemo(()=>l.jsx(d.Button,{ref:u,loading:o||t.loading,onClick:e?f:n?()=>{i?i==null||i(n):window.location.href=n}:void 0,className:r,...t}),[f,r,o,i,e,t,n,u]);return a?l.jsx(d.Tooltip,{title:a,children:g}):g});q.displayName="ButtonComponent.Async";y.Async=q;module.exports=y;
|
|
@@ -3,10 +3,9 @@ import { default as React } from 'react';
|
|
|
3
3
|
export interface ButtonComponentProps extends ButtonProps {
|
|
4
4
|
to?: string | number;
|
|
5
5
|
tooltip?: string | undefined;
|
|
6
|
-
ref?: any;
|
|
7
6
|
}
|
|
8
|
-
type ComponentType = React.
|
|
9
|
-
Async: React.
|
|
7
|
+
type ComponentType = React.ForwardRefExoticComponent<ButtonComponentProps & React.RefAttributes<HTMLElement>> & {
|
|
8
|
+
Async: React.ForwardRefExoticComponent<ButtonComponentProps & React.RefAttributes<HTMLElement>>;
|
|
10
9
|
};
|
|
11
10
|
declare const _default: ComponentType;
|
|
12
11
|
export default _default;
|
|
@@ -1,64 +1,57 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Button as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { useTranslationLib as
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { Button as u, Tooltip as f } from "antd";
|
|
3
|
+
import { forwardRef as y, useMemo as g, useState as v, useCallback as A } from "react";
|
|
4
|
+
import { useTranslationLib as B } from "../../locale/index.es.js";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import { useNavigateOptional as
|
|
7
|
-
const
|
|
8
|
-
className: r,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
),
|
|
57
|
-
[c, r, o, i, n, e, t]
|
|
58
|
-
);
|
|
59
|
-
return a ? /* @__PURE__ */ l(u, { title: a, children: f }) : f;
|
|
60
|
-
};
|
|
61
|
-
x.Async = A;
|
|
6
|
+
import { useNavigateOptional as h } from "../../hooks/NavigatorHooks.es.js";
|
|
7
|
+
const p = y(
|
|
8
|
+
({ className: r, to: n, onClick: t, tooltip: a, ...o }, l) => {
|
|
9
|
+
const { t: e } = B(), i = h(), s = g(
|
|
10
|
+
() => /* @__PURE__ */ c(
|
|
11
|
+
u,
|
|
12
|
+
{
|
|
13
|
+
ref: l,
|
|
14
|
+
onClick: t ?? (n && i ? () => i(n) : void 0),
|
|
15
|
+
className: r,
|
|
16
|
+
...o,
|
|
17
|
+
children: o.children
|
|
18
|
+
}
|
|
19
|
+
),
|
|
20
|
+
[r, i, t, o, e, n]
|
|
21
|
+
);
|
|
22
|
+
return a ? /* @__PURE__ */ c(f, { title: a, children: s }) : s;
|
|
23
|
+
}
|
|
24
|
+
), b = y(
|
|
25
|
+
({ className: r, to: n, onClick: t, tooltip: a, ...o }, l) => {
|
|
26
|
+
const e = h(), [i, s] = v(!1), d = A(
|
|
27
|
+
async (w) => {
|
|
28
|
+
try {
|
|
29
|
+
return s(!0), await t(w);
|
|
30
|
+
} finally {
|
|
31
|
+
s(!1);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
[t]
|
|
35
|
+
), m = g(
|
|
36
|
+
() => /* @__PURE__ */ c(
|
|
37
|
+
u,
|
|
38
|
+
{
|
|
39
|
+
ref: l,
|
|
40
|
+
loading: i || o.loading,
|
|
41
|
+
onClick: t ? d : n ? () => {
|
|
42
|
+
e ? e == null || e(n) : window.location.href = n;
|
|
43
|
+
} : void 0,
|
|
44
|
+
className: r,
|
|
45
|
+
...o
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
[d, r, i, e, t, o, n, l]
|
|
49
|
+
);
|
|
50
|
+
return a ? /* @__PURE__ */ c(f, { title: a, children: m }) : m;
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
b.displayName = "ButtonComponent.Async";
|
|
54
|
+
p.Async = b;
|
|
62
55
|
export {
|
|
63
|
-
|
|
56
|
+
p as default
|
|
64
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),y=require("antd"),ce=require("dayjs"),n=require("react"),re=require("./CrudForm.cjs.js"),ue=require("./CrudFormWizard.cjs.js"),de=require("./import/CrudImportButton.cjs.js"),fe=require("./view/CrudViewer.cjs.js"),pe=require("../common/button/NewButton.cjs.js"),me=require("../common/button/PrintButton.cjs.js"),Fe=require("../locale/index.cjs.js"),M=require("../util/CrudUtil.cjs.js"),{useForm:ye}=y.Form;function ge({idField:g="id",onCreate:v,onDelete:T,onHide:W,onUpdate:p,fields:i,data:_,grid:A,isHiding:E,isCreating:q,isDeleting:H,isUpdating:N,paginateProps:L,onPrint:V,printing:G,viewable:J,loadingData:K,formBuilder:Q,extraAction:X,minusHeight:Y,cloneable:Z,fullWidthModal:$=!0,wizard:c,extraView:z,importable:P,onClickNew:O,size:ee,...te}){const{t:j}=Fe.useTranslationLib(),[k,x]=n.useState(!1),[m,B]=n.useState(),[se,b]=n.useState(),[r]=ye(),R=n.useCallback(async s=>{const d=c?s:await r.validateFields(),u=i.filter(o=>o.type==="color"),a={};u.forEach(o=>{var f;const l=M.getRealName(o.name,"upsertFieldName"),e=r.getFieldValue(l);a[l]=typeof e=="string"?e:(f=e==null?void 0:e.toHexString())==null?void 0:f.toUpperCase()}),Object.assign(d,a),m&&p?(await p({...d,[g]:m[g]}),B(void 0)):!m&&v&&await v(d),b(void 0),r.resetFields(),x(!1)},[i,r,g,v,p,m,c]),[ne,U]=n.useState(!1),[oe,h]=n.useState(!1);n.useEffect(()=>{k?(U(!1),h(!1)):C(void 0)},[k]);const w=n.useCallback(async s=>{U(s),h(!0)},[]),D=n.useCallback(async()=>{h(!0)},[]),[ae,I]=n.useState(!1),S=n.useCallback(async(s,d=!0,u=!1)=>{try{I(!0),x(!0),d&&C("update");const a={};for(const o of i){const l=M.getRealName(o.name,"upsertFieldName"),e=s[l];if(u&&o.type==="image"){const f=e;try{const ie=await o.provider.clone(f);a[l]=ie;continue}catch{continue}}o.type==="date"?e&&(a[l]=ce(e)):o.type==="select"?o.multiple&&Array.isArray(e)?a[l]=e.map(f=>f[o.innerFieldId??"id"]):e&&typeof e=="object"?a[l]=e[o.innerFieldId??"id"]:(e&&typeof e=="string"||typeof e=="number")&&(a[l]=e):a[l]=e}r.setFieldsValue(a),b(a),d&&B(s)}finally{I(!1)}},[i,r]),[F,C]=n.useState(),le=n.useCallback(async s=>{C("clone"),S(s,!1,!0)},[S]);return t.jsxs(t.Fragment,{children:[t.jsxs(y.Space,{direction:"vertical",className:"w-100",children:[t.jsxs("div",{className:"w-100 d-flex",children:[t.jsx("div",{style:{flex:1},children:t.jsx(pe.NewButton,{onClick:()=>{O?O():(x(s=>!s),C("new"))},className:"flex-1"})}),t.jsxs(y.Space,{children:[!!V&&t.jsx(me.PrintButton,{className:"float-right",loading:G,onClick:V}),!!P&&t.jsx(de,{fields:i,importProps:P})]})]}),t.jsx(fe,{...te,minusHeight:Y,data:_,size:ee,fields:i,extraAction:X,idField:g,isDeleting:H,loadingData:K,onClickUpdate:p?S:void 0,onHide:W,isHiding:E,onDelete:T,onUpdate:p,onClickClone:Z?le:void 0,paginateProps:L,viewable:J,extraView:z})]}),t.jsx(y.Modal,{width:$?"100%":void 0,title:j(F??"new"),open:k,confirmLoading:q||N,okText:j("str."+(F==="update"?"update":"save")),cancelText:j("str.cancel"),cancelButtonProps:{disabled:oe,hidden:!!c},okButtonProps:{disabled:ne,hidden:!!c},onCancel:async()=>{try{if(F==="clone"){const s=c?m:r.getFieldsValue(),d=i.filter(u=>u.type==="image");for(const u of d)s[u.name]&&u.provider.delete(s[u.name])}}finally{}c||r.resetFields(),b(void 0),B(void 0),x(!1)},onOk:()=>R(),destroyOnHidden:!0,children:t.jsxs(y.Spin,{spinning:ae,children:[!c&&t.jsx(re.CrudForm,{purpose:F,fields:i,form:r,formBuilder:Q,grid:A,onDeleteFile:D,onUploadFile:w}),c&&t.jsx(ue,{submitting:q||N,className:"mt-2",onSave:R,updatingValue:se,fields:i,onDeleteFile:D,onUploadFile:w,purpose:F,wizard:c})]})})]})}module.exports=ge;
|
package/crud/CrudComponent.d.ts
CHANGED
|
@@ -60,7 +60,11 @@ export type CrudFieldGrid = {
|
|
|
60
60
|
xl?: number;
|
|
61
61
|
xxl?: number;
|
|
62
62
|
};
|
|
63
|
-
export interface SelectCrudField<T, ItemType extends SelectFieldItem = SelectFieldItem> extends InitialCrudField<T> {
|
|
63
|
+
export interface SelectCrudField<T, ItemType extends SelectFieldItem = SelectFieldItem> extends Omit<InitialCrudField<T>, "name"> {
|
|
64
|
+
name: InitialCrudField<T>["name"] | {
|
|
65
|
+
name: keyof T | (string | number)[];
|
|
66
|
+
upsertFieldName: keyof T | (string | number)[];
|
|
67
|
+
};
|
|
64
68
|
type: "select";
|
|
65
69
|
placeholder?: string;
|
|
66
70
|
/**
|
package/crud/CrudComponent.es.js
CHANGED
|
@@ -1,204 +1,205 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Form as
|
|
3
|
-
import
|
|
4
|
-
import { useState as
|
|
5
|
-
import { CrudForm as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { NewButton as
|
|
10
|
-
import { PrintButton as
|
|
11
|
-
import { useTranslationLib as
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { jsxs as F, Fragment as de, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { Form as me, Space as w, Modal as ue, Spin as fe } from "antd";
|
|
3
|
+
import pe from "dayjs";
|
|
4
|
+
import { useState as m, useCallback as g, useEffect as ye } from "react";
|
|
5
|
+
import { CrudForm as Fe } from "./CrudForm.es.js";
|
|
6
|
+
import ge from "./CrudFormWizard.es.js";
|
|
7
|
+
import ve from "./import/CrudImportButton.es.js";
|
|
8
|
+
import Ce from "./view/CrudViewer.es.js";
|
|
9
|
+
import { NewButton as Be } from "../common/button/NewButton.es.js";
|
|
10
|
+
import { PrintButton as he } from "../common/button/PrintButton.es.js";
|
|
11
|
+
import { useTranslationLib as ke } from "../locale/index.es.js";
|
|
12
|
+
import A from "../util/CrudUtil.es.js";
|
|
13
|
+
const { useForm: be } = me;
|
|
14
|
+
function We({
|
|
15
|
+
idField: v = "id",
|
|
16
|
+
onCreate: h,
|
|
17
|
+
onDelete: E,
|
|
18
|
+
onHide: H,
|
|
18
19
|
onUpdate: f,
|
|
19
|
-
fields:
|
|
20
|
-
data:
|
|
21
|
-
grid:
|
|
22
|
-
isHiding:
|
|
20
|
+
fields: i,
|
|
21
|
+
data: L,
|
|
22
|
+
grid: R,
|
|
23
|
+
isHiding: q,
|
|
23
24
|
isCreating: P,
|
|
24
|
-
isDeleting:
|
|
25
|
+
isDeleting: G,
|
|
25
26
|
isUpdating: j,
|
|
26
|
-
paginateProps:
|
|
27
|
-
onPrint:
|
|
28
|
-
printing:
|
|
29
|
-
viewable:
|
|
30
|
-
loadingData:
|
|
31
|
-
formBuilder:
|
|
32
|
-
extraAction:
|
|
33
|
-
minusHeight:
|
|
34
|
-
cloneable:
|
|
35
|
-
fullWidthModal:
|
|
36
|
-
wizard:
|
|
37
|
-
extraView:
|
|
38
|
-
importable:
|
|
27
|
+
paginateProps: J,
|
|
28
|
+
onPrint: O,
|
|
29
|
+
printing: K,
|
|
30
|
+
viewable: Q,
|
|
31
|
+
loadingData: X,
|
|
32
|
+
formBuilder: Y,
|
|
33
|
+
extraAction: Z,
|
|
34
|
+
minusHeight: $,
|
|
35
|
+
cloneable: z,
|
|
36
|
+
fullWidthModal: ee = !0,
|
|
37
|
+
wizard: s,
|
|
38
|
+
extraView: te,
|
|
39
|
+
importable: U,
|
|
39
40
|
onClickNew: D,
|
|
40
|
-
size:
|
|
41
|
-
...
|
|
41
|
+
size: oe,
|
|
42
|
+
...ne
|
|
42
43
|
}) {
|
|
43
|
-
const { t:
|
|
44
|
-
async (
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
const
|
|
49
|
-
n[
|
|
50
|
-
}), Object.assign(
|
|
51
|
-
...
|
|
52
|
-
[
|
|
53
|
-
}),
|
|
44
|
+
const { t: k } = ke(), [b, C] = m(!1), [p, N] = m(), [le, x] = m(), [a] = be(), I = g(
|
|
45
|
+
async (t) => {
|
|
46
|
+
const c = s ? t : await a.validateFields(), r = i.filter((o) => o.type === "color"), n = {};
|
|
47
|
+
r.forEach((o) => {
|
|
48
|
+
var u;
|
|
49
|
+
const l = A.getRealName(o.name, "upsertFieldName"), e = a.getFieldValue(l);
|
|
50
|
+
n[l] = typeof e == "string" ? e : (u = e == null ? void 0 : e.toHexString()) == null ? void 0 : u.toUpperCase();
|
|
51
|
+
}), Object.assign(c, n), p && f ? (await f({
|
|
52
|
+
...c,
|
|
53
|
+
[v]: p[v]
|
|
54
|
+
}), N(void 0)) : !p && h && await h(c), x(void 0), a.resetFields(), C(!1);
|
|
54
55
|
},
|
|
55
|
-
[
|
|
56
|
-
), [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, [
|
|
60
|
-
const T =
|
|
61
|
-
M(
|
|
62
|
-
}, []),
|
|
56
|
+
[i, a, v, h, f, p, s]
|
|
57
|
+
), [ie, M] = m(!1), [se, V] = m(!1);
|
|
58
|
+
ye(() => {
|
|
59
|
+
b ? (M(!1), V(!1)) : B(void 0);
|
|
60
|
+
}, [b]);
|
|
61
|
+
const T = g(async (t) => {
|
|
62
|
+
M(t), V(!0);
|
|
63
|
+
}, []), W = g(async () => {
|
|
63
64
|
V(!0);
|
|
64
|
-
}, []), [
|
|
65
|
-
async (
|
|
65
|
+
}, []), [ae, _] = m(!1), S = g(
|
|
66
|
+
async (t, c = !0, r = !1) => {
|
|
66
67
|
try {
|
|
67
|
-
|
|
68
|
+
_(!0), C(!0), c && B("update");
|
|
68
69
|
const n = {};
|
|
69
|
-
for (const
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
const
|
|
70
|
+
for (const o of i) {
|
|
71
|
+
const l = A.getRealName(o.name, "upsertFieldName"), e = t[l];
|
|
72
|
+
if (r && o.type === "image") {
|
|
73
|
+
const u = e;
|
|
73
74
|
try {
|
|
74
|
-
const
|
|
75
|
-
n[
|
|
75
|
+
const ce = await o.provider.clone(u);
|
|
76
|
+
n[l] = ce;
|
|
76
77
|
continue;
|
|
77
78
|
} catch {
|
|
78
79
|
continue;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
(
|
|
83
|
-
) :
|
|
82
|
+
o.type === "date" ? e && (n[l] = pe(e)) : o.type === "select" ? o.multiple && Array.isArray(e) ? n[l] = e.map(
|
|
83
|
+
(u) => u[o.innerFieldId ?? "id"]
|
|
84
|
+
) : e && typeof e == "object" ? n[l] = e[o.innerFieldId ?? "id"] : (e && typeof e == "string" || typeof e == "number") && (n[l] = e) : n[l] = e;
|
|
84
85
|
}
|
|
85
|
-
a.setFieldsValue(n), x(n),
|
|
86
|
+
a.setFieldsValue(n), x(n), c && N(t);
|
|
86
87
|
} finally {
|
|
87
|
-
|
|
88
|
+
_(!1);
|
|
88
89
|
}
|
|
89
90
|
},
|
|
90
|
-
[
|
|
91
|
-
), [
|
|
92
|
-
async (
|
|
93
|
-
B("clone"), S(
|
|
91
|
+
[i, a]
|
|
92
|
+
), [y, B] = m(), re = g(
|
|
93
|
+
async (t) => {
|
|
94
|
+
B("clone"), S(t, !1, !0);
|
|
94
95
|
},
|
|
95
96
|
[S]
|
|
96
97
|
);
|
|
97
|
-
return /* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
|
|
98
|
+
return /* @__PURE__ */ F(de, { children: [
|
|
99
|
+
/* @__PURE__ */ F(w, { direction: "vertical", className: "w-100", children: [
|
|
100
|
+
/* @__PURE__ */ F("div", { className: "w-100 d-flex", children: [
|
|
101
|
+
/* @__PURE__ */ d("div", { style: { flex: 1 }, children: /* @__PURE__ */ d(
|
|
102
|
+
Be,
|
|
102
103
|
{
|
|
103
104
|
onClick: () => {
|
|
104
|
-
D ? D() : (
|
|
105
|
+
D ? D() : (C((t) => !t), B("new"));
|
|
105
106
|
},
|
|
106
107
|
className: "flex-1"
|
|
107
108
|
}
|
|
108
109
|
) }),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
!!
|
|
111
|
-
|
|
110
|
+
/* @__PURE__ */ F(w, { children: [
|
|
111
|
+
!!O && /* @__PURE__ */ d(
|
|
112
|
+
he,
|
|
112
113
|
{
|
|
113
114
|
className: "float-right",
|
|
114
|
-
loading:
|
|
115
|
-
onClick:
|
|
115
|
+
loading: K,
|
|
116
|
+
onClick: O
|
|
116
117
|
}
|
|
117
118
|
),
|
|
118
|
-
!!
|
|
119
|
+
!!U && /* @__PURE__ */ d(ve, { fields: i, importProps: U })
|
|
119
120
|
] })
|
|
120
121
|
] }),
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
|
|
122
|
+
/* @__PURE__ */ d(
|
|
123
|
+
Ce,
|
|
123
124
|
{
|
|
124
|
-
...
|
|
125
|
-
minusHeight:
|
|
126
|
-
data:
|
|
127
|
-
size:
|
|
128
|
-
fields:
|
|
129
|
-
extraAction:
|
|
130
|
-
idField:
|
|
131
|
-
isDeleting:
|
|
132
|
-
loadingData:
|
|
125
|
+
...ne,
|
|
126
|
+
minusHeight: $,
|
|
127
|
+
data: L,
|
|
128
|
+
size: oe,
|
|
129
|
+
fields: i,
|
|
130
|
+
extraAction: Z,
|
|
131
|
+
idField: v,
|
|
132
|
+
isDeleting: G,
|
|
133
|
+
loadingData: X,
|
|
133
134
|
onClickUpdate: f ? S : void 0,
|
|
134
|
-
onHide:
|
|
135
|
-
isHiding:
|
|
136
|
-
onDelete:
|
|
135
|
+
onHide: H,
|
|
136
|
+
isHiding: q,
|
|
137
|
+
onDelete: E,
|
|
137
138
|
onUpdate: f,
|
|
138
|
-
onClickClone:
|
|
139
|
-
paginateProps:
|
|
140
|
-
viewable:
|
|
141
|
-
extraView:
|
|
139
|
+
onClickClone: z ? re : void 0,
|
|
140
|
+
paginateProps: J,
|
|
141
|
+
viewable: Q,
|
|
142
|
+
extraView: te
|
|
142
143
|
}
|
|
143
144
|
)
|
|
144
145
|
] }),
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
|
|
146
|
+
/* @__PURE__ */ d(
|
|
147
|
+
ue,
|
|
147
148
|
{
|
|
148
|
-
width:
|
|
149
|
-
title:
|
|
150
|
-
open:
|
|
149
|
+
width: ee ? "100%" : void 0,
|
|
150
|
+
title: k(y ?? "new"),
|
|
151
|
+
open: b,
|
|
151
152
|
confirmLoading: P || j,
|
|
152
|
-
okText:
|
|
153
|
-
cancelText:
|
|
153
|
+
okText: k("str." + (y === "update" ? "update" : "save")),
|
|
154
|
+
cancelText: k("str.cancel"),
|
|
154
155
|
cancelButtonProps: {
|
|
155
|
-
disabled:
|
|
156
|
-
hidden: !!
|
|
156
|
+
disabled: se,
|
|
157
|
+
hidden: !!s
|
|
157
158
|
},
|
|
158
159
|
okButtonProps: {
|
|
159
|
-
disabled:
|
|
160
|
-
hidden: !!
|
|
160
|
+
disabled: ie,
|
|
161
|
+
hidden: !!s
|
|
161
162
|
},
|
|
162
163
|
onCancel: async () => {
|
|
163
164
|
try {
|
|
164
|
-
if (
|
|
165
|
-
const
|
|
166
|
-
for (const
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
if (y === "clone") {
|
|
166
|
+
const t = s ? p : a.getFieldsValue(), c = i.filter((r) => r.type === "image");
|
|
167
|
+
for (const r of c)
|
|
168
|
+
t[r.name] && r.provider.delete(
|
|
169
|
+
t[r.name]
|
|
169
170
|
);
|
|
170
171
|
}
|
|
171
172
|
} finally {
|
|
172
173
|
}
|
|
173
|
-
|
|
174
|
+
s || a.resetFields(), x(void 0), N(void 0), C(!1);
|
|
174
175
|
},
|
|
175
176
|
onOk: () => I(),
|
|
176
177
|
destroyOnHidden: !0,
|
|
177
|
-
children: /* @__PURE__ */
|
|
178
|
-
!
|
|
179
|
-
|
|
178
|
+
children: /* @__PURE__ */ F(fe, { spinning: ae, children: [
|
|
179
|
+
!s && /* @__PURE__ */ d(
|
|
180
|
+
Fe,
|
|
180
181
|
{
|
|
181
|
-
purpose:
|
|
182
|
-
fields:
|
|
182
|
+
purpose: y,
|
|
183
|
+
fields: i,
|
|
183
184
|
form: a,
|
|
184
|
-
formBuilder:
|
|
185
|
-
grid:
|
|
186
|
-
onDeleteFile:
|
|
185
|
+
formBuilder: Y,
|
|
186
|
+
grid: R,
|
|
187
|
+
onDeleteFile: W,
|
|
187
188
|
onUploadFile: T
|
|
188
189
|
}
|
|
189
190
|
),
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
s && /* @__PURE__ */ d(
|
|
192
|
+
ge,
|
|
192
193
|
{
|
|
193
194
|
submitting: P || j,
|
|
194
195
|
className: "mt-2",
|
|
195
196
|
onSave: I,
|
|
196
|
-
updatingValue:
|
|
197
|
-
fields:
|
|
198
|
-
onDeleteFile:
|
|
197
|
+
updatingValue: le,
|
|
198
|
+
fields: i,
|
|
199
|
+
onDeleteFile: W,
|
|
199
200
|
onUploadFile: T,
|
|
200
|
-
purpose:
|
|
201
|
-
wizard:
|
|
201
|
+
purpose: y,
|
|
202
|
+
wizard: s
|
|
202
203
|
}
|
|
203
204
|
)
|
|
204
205
|
] })
|
|
@@ -207,5 +208,5 @@ function Me({
|
|
|
207
208
|
] });
|
|
208
209
|
}
|
|
209
210
|
export {
|
|
210
|
-
|
|
211
|
+
We as default
|
|
211
212
|
};
|
package/crud/CrudField.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),p=require("antd"),N=require("react")
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),p=require("antd"),N=require("react"),$=require("react-highlight-words"),z=require("../locale/index.cjs.js"),J=require("./FileCrudField.cjs.js"),K=require("./ImageCrudField.cjs.js"),Q=require("../common/check-box/CheckBox.cjs.js"),X=require("../common/date-picker/DatePicker.cjs.js"),Y=require("../common/date-picker/TimePicker.cjs.js"),E=require("../common/select/SelectComponent.cjs.js"),Z=require("../common/text-field/NumberField.cjs.js"),V=require("../common/text-field/TextField.cjs.js"),ee=require("../common/tooltip/TooltipComponent.cjs.js"),te=require("./CrudTextAreaComponent.cjs.js"),B=require("../util/CrudUtil.cjs.js");function re(j){const{label:s,name:c,type:g,required:i,hidden:w,rules:u=[],updatable:m=!0,readonly:S=!1,fieldClassName:f,customFormFieldRender:O,fieldTooltip:b,...t}=j,h=p.Form.useFormInstance();N.useEffect(()=>{if(g==="select"){const{items:n=[],onSearch:o,searchOnType:l}=t;!(n!=null&&n.length)&&!l&&(o==null||o(void 0,h,t==null?void 0:t.updatingValue))}},[h,t,g,t==null?void 0:t.updatingValue]);const{t:q}=z.useTranslationLib();if(S||w)return e.jsx(e.Fragment,{});if(O)return O(h,j);switch(g){case"text":case"email":case"password":{const{onChange:n,placeholder:o}=t;return e.jsx(V.default,{placeholder:o,disabled:!m,rules:u,required:i,onChange:n?l=>n(l,h):void 0,type:g,name:c,tooltip:b,label:s,className:f,autoComplete:"new-password"})}case"number":{const{onChange:n,placeholder:o,allowMinus:l}=t;return e.jsx(Z,{placeholder:o,disabled:!m,moneyField:!!t.formatted,type:g,onChange:n?x=>n(x,h):void 0,rules:u,autoComplete:"false",required:i,tooltip:b,className:f,min:l?null:void 0,name:c,label:s})}case"date":{const{range:n,disableToday:o,disabledFutureDays:l,disabledPastDays:x,onChange:v,placeholder:C,format:F}=t;return e.jsx(X,{placeholder:C,required:i,disabled:!m,type:g,format:F,tooltip:b,range:n,name:c,label:s,onChange:v?y=>v(y,h):void 0,className:f,disableToday:o,disabledFutureDays:l,disabledPastDays:x})}case"time":{const{range:n=!1,disableCurrent:o,disabledFuture:l,disabledPast:x,onChange:v,use12Hours:C,format:F,placeholder:y}=t;return e.jsx(Y,{placeholder:y,required:i,format:F,disabled:!m,type:g,tooltip:b,range:n,use12Hours:C,name:c,label:s,onChange:v?a=>v(a,h):void 0,className:f,disableCurrent:o,disabledFuture:l,disabledPast:x})}case"textarea":return e.jsx(te,{...j});case"image":return e.jsx(K.default,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"file":return e.jsx(J.default,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"select":return e.jsx(H,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,form:h,updatable:m,readonly:S,fieldTooltip:b});case"enum":{const{enum:n,radio:o=!1,translation:l,onChange:x,onSearch:v,multiple:C,tagRender:F}=t,y=Array.isArray(n)?n:Object.keys(n);return o?e.jsx(p.Form.Item,{...t,name:c,required:i,tooltip:b,rules:u,label:s,className:["w-100",f].join(" "),children:e.jsx(p.Radio.Group,{...t,onChange:x?a=>{var R;return x((R=a==null?void 0:a.target)==null?void 0:R.value,h)}:void 0,children:y.map(a=>e.jsx(p.Radio,{disabled:!m,value:a,children:l?q(l[a]):a},a))})}):e.jsx(E,{...t,tagRender:typeof F=="function"?F:F?a=>{const{value:R,label:T}=a,k=F[R];return k?e.jsx(p.Tag,{color:k.color,children:T}):e.jsx(p.Tag,{children:T})}:void 0,onChange:x?a=>x(a,h):void 0,className:["w-100",f].join(" "),name:c,items:y,required:i,tooltip:b,rules:u,label:s,disabled:!m,onSearch:v?a=>v(a,h):void 0,allowClear:!0,mode:C?"multiple":void 0,itemBuilder:a=>e.jsx(p.Select.Option,{value:a,children:l?q(l[a]):a},a)})}case"checkbox":{const{onChange:n}=t;return e.jsx(Q,{className:f,rules:u,onChange:n?o=>n(o,h):void 0,label:s,tooltip:b,disabled:!m,name:c})}case"color":return e.jsx(D,{...t,type:"color",required:i,name:c,label:s,rules:u,fieldClassName:f,updatable:m,readonly:S,fieldTooltip:b});default:return e.jsx(e.Fragment,{children:`${g} Not Implemented`})}}function H(j){const{items:s=[],loading:c,searchOnType:g,onSearch:i,multiple:w,onChange:u,highlightSearch:m,required:S,fieldClassName:f,rules:O,fieldTooltip:b,updatable:t,label:h,name:q,tagRender:n,updatingValue:o,onSet:l,placeholder:x,allowClear:v=!0}=j,C=j.form,[F,y]=N.useState(""),a=N.useMemo(()=>B.getRealName(q),[q]),R=N.useMemo(()=>B.getRealName(q,"upsertFieldName"),[q]),T=p.Form.useWatch(a,C),[k,P]=N.useState(!0);N.useEffect(()=>{l&&k&&T&&(l==null||l(T,s,C),P(!1))},[k,C,s,a,l,T]),N.useEffect(()=>{T&&P(!0)},[T]);const _=N.useCallback(async r=>{y(r),g&&(i==null||i(r,C,o))},[C,i,g,o]);return e.jsx(E,{...j,maxTagCount:"responsive",maxTagPlaceholder:r=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:r.map(d=>e.jsxs(e.Fragment,{children:[d.label," ",e.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:x,onSelect:r=>{l==null||l(r==null?void 0:r.key,s,C)},onChange:u?r=>{y(""),u(r,C)}:void 0,mode:w?"multiple":void 0,className:["w-100",f].join(" "),name:R,items:s,required:S,tooltip:b,tagRender:n,rules:O,disabled:!t,label:h,allowClear:v,onSearch:_,loading:c,filterOption:m?(r,d)=>{var I,L,M;try{const U=r.toLowerCase().split(/\s+/),W=((typeof(d==null?void 0:d.children)=="string"?d==null?void 0:d.children:(L=(I=d==null?void 0:d.children)==null?void 0:I.props)==null?void 0:L.textToHighlight)??"").toLowerCase(),G=(((M=d==null?void 0:d.value)==null?void 0:M.toString())??"").toLowerCase();return U.every(A=>W.indexOf(A)>=0||G.indexOf(A)>=0)}catch{return!0}}:void 0,itemBuilder:m?r=>{const d=r.value?String(r.value):void 0;return e.jsx(p.Select.Option,{value:r.key,title:d,disabled:r.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(F??"").split(" "),autoEscape:!0,textToHighlight:d??""})},r.key)}:r=>e.jsx(p.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:r.value},r.key)})}function D(j){const{required:s,fieldClassName:c,rules:g,fieldTooltip:i,updatable:w,label:u,name:m}=j;return e.jsx(p.Form.Item,{label:u,name:m,required:s,rules:g,tooltip:i,children:e.jsx(p.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:c,disabled:!w,...j.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=H;exports.default=re;
|