@kingteza/crud-component 1.29.0 → 1.30.0
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/dist/common/rich/index.d.ts +2 -1
- package/dist/common/text-field/NumberField.cjs.js +1 -1
- package/dist/common/text-field/NumberField.es.js +17 -18
- package/dist/crud/CrudComponent.d.ts +7 -5
- package/dist/crud/CrudForm.d.ts +2 -2
- package/dist/crud/CrudFormWizard.cjs.js +1 -1
- package/dist/crud/CrudFormWizard.d.ts +2 -2
- package/dist/crud/CrudFormWizard.es.js +82 -78
- package/dist/crud/CrudReportComponent.d.ts +5 -5
- package/dist/crud/CrudSearchComponent.d.ts +2 -2
- package/dist/crud/import/CrudImportComponent.d.ts +2 -2
- package/dist/crud/index.d.ts +1 -1
- package/dist/crud/modal/index.cjs.js +1 -1
- package/dist/crud/modal/index.d.ts +2 -2
- package/dist/crud/modal/index.es.js +127 -105
- package/dist/crud/view/CrudDecListView.cjs.js +1 -1
- package/dist/crud/view/CrudDecListView.d.ts +2 -2
- package/dist/crud/view/CrudDecListView.es.js +31 -30
- package/dist/crud/view/CrudViewer.d.ts +2 -2
- package/dist/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/dist/crud/view/CrudViewerUtil.es.js +39 -38
- package/dist/util/CrudUtil.d.ts +1 -1
- package/dist/util/ObjectUtil.cjs.js +1 -0
- package/dist/util/ObjectUtil.d.ts +2 -0
- package/dist/util/ObjectUtil.es.js +10 -0
- package/package.json +1 -1
- package/dist/locale/index.d.ts +0 -86
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Rule } from 'antd/es/form';
|
|
2
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
2
3
|
import { FormItemProps } from 'antd/lib';
|
|
3
4
|
import { FC, ReactNode } from 'react';
|
|
4
5
|
export interface RichTextEditorProps {
|
|
5
6
|
help?: ReactNode;
|
|
6
7
|
label?: string;
|
|
7
|
-
name:
|
|
8
|
+
name: NamePath;
|
|
8
9
|
required?: boolean;
|
|
9
10
|
rules?: Rule[];
|
|
10
11
|
disabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("react/jsx-runtime"),m=require("antd"),x=require("react"),
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),m=require("antd"),x=require("react"),M=require("../../locale/index.cjs.js"),P=require("../tooltip/TooltipComponent.cjs.js"),_=require("./TextField.cjs.js"),b=x.forwardRef(function({type:v,required:o,label:e,rules:c=[],placeholder:r,onEnter:a,form:f,nextFocus:q,min:d,moneyField:n,addonAfter:j,minLength:T,defaultValue:$,pattern:g,disabled:I,readOnly:N,onChange:R,value:w,max:B,addonBefore:E,size:F,isInt:u=!1,tooltip:h,help:z,...y},C){const{t:p}=M.useTranslationLib(),L=x.useMemo(()=>[...c,{required:o,message:`${e||r||""} ${p("err.validation.required")}`}],[c,e,r,p,o]);return i.jsx(P,{title:h,children:i.jsx(m.Form.Item,{...y,label:e,rules:L,children:i.jsx(m.InputNumber,{ref:C,disabled:I,defaultValue:$,value:w,readOnly:N,addonBefore:E,minLength:T,addonAfter:j,step:u?1:void 0,pattern:u?"d*":g,onChange:R,onPressEnter:t=>_.onEnterInternalTextField(t,q,f,a),className:"max-width",min:d===null?void 0:d??0,max:B,type:n?void 0:"number",size:F,formatter:n?t=>{if(t.includes(".")){const s=`${t}`.split(".");return s[0]=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),s.join(".")}else return`${t}`.replace(/\B(?=(\d{3})+(?!\d))/g,",")}:void 0,parser:n?t=>t==null?void 0:t.replace(/\$\s?|(,*)/g,""):void 0,placeholder:r||e})})})});module.exports=b;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import { Form as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { useTranslationLib as
|
|
5
|
-
import
|
|
6
|
-
import { onEnterInternalTextField as
|
|
7
|
-
const
|
|
2
|
+
import { Form as M, InputNumber as P } from "antd";
|
|
3
|
+
import { forwardRef as R, useMemo as _ } from "react";
|
|
4
|
+
import { useTranslationLib as b } from "../../locale/index.es.js";
|
|
5
|
+
import k from "../tooltip/TooltipComponent.es.js";
|
|
6
|
+
import { onEnterInternalTextField as q } from "./TextField.es.js";
|
|
7
|
+
const Q = R(
|
|
8
8
|
function({
|
|
9
|
-
|
|
10
|
-
type: A,
|
|
9
|
+
type: z,
|
|
11
10
|
required: s,
|
|
12
11
|
label: t,
|
|
13
12
|
rules: m = [],
|
|
@@ -29,11 +28,11 @@ const S = b(
|
|
|
29
28
|
addonBefore: E,
|
|
30
29
|
size: h,
|
|
31
30
|
isInt: d = !1,
|
|
32
|
-
tooltip:
|
|
33
|
-
help:
|
|
34
|
-
...
|
|
35
|
-
},
|
|
36
|
-
const { t: f } =
|
|
31
|
+
tooltip: y,
|
|
32
|
+
help: A,
|
|
33
|
+
...C
|
|
34
|
+
}, F) {
|
|
35
|
+
const { t: f } = b(), L = _(
|
|
37
36
|
() => [
|
|
38
37
|
...m,
|
|
39
38
|
{
|
|
@@ -45,10 +44,10 @@ const S = b(
|
|
|
45
44
|
],
|
|
46
45
|
[m, t, o, f, s]
|
|
47
46
|
);
|
|
48
|
-
return /* @__PURE__ */ i(
|
|
49
|
-
|
|
47
|
+
return /* @__PURE__ */ i(k, { title: y, children: /* @__PURE__ */ i(M.Item, { ...C, label: t, rules: L, children: /* @__PURE__ */ i(
|
|
48
|
+
P,
|
|
50
49
|
{
|
|
51
|
-
ref:
|
|
50
|
+
ref: F,
|
|
52
51
|
disabled: I,
|
|
53
52
|
defaultValue: g,
|
|
54
53
|
value: w,
|
|
@@ -59,7 +58,7 @@ const S = b(
|
|
|
59
58
|
step: d ? 1 : void 0,
|
|
60
59
|
pattern: d ? "d*" : T,
|
|
61
60
|
onChange: j,
|
|
62
|
-
onPressEnter: (r) =>
|
|
61
|
+
onPressEnter: (r) => q(r, a, u, c),
|
|
63
62
|
className: "max-width",
|
|
64
63
|
min: p === null ? void 0 : p ?? 0,
|
|
65
64
|
max: B,
|
|
@@ -79,5 +78,5 @@ const S = b(
|
|
|
79
78
|
}
|
|
80
79
|
);
|
|
81
80
|
export {
|
|
82
|
-
|
|
81
|
+
Q as default
|
|
83
82
|
};
|
|
@@ -10,11 +10,11 @@ import { CrudImportProps } from './import/CrudImportComponent';
|
|
|
10
10
|
import { CrudDragableProps, CrudViewableProps } from './view/CrudViewer';
|
|
11
11
|
import { SelectTagRenderProps } from '../common/select/SelectComponent';
|
|
12
12
|
import { default as IdProps } from '../types/Id';
|
|
13
|
-
import { TextAreaBasedFieldProps } from '
|
|
13
|
+
import { TextAreaBasedFieldProps } from './CrudTextAreaComponent';
|
|
14
14
|
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
15
|
-
import { Copyable } from '
|
|
15
|
+
import { Copyable } from '../util/CopyUtilComponent';
|
|
16
16
|
import { ColumnType } from 'antd/es/table';
|
|
17
|
-
import { PhoneNumberConfigProps } from '
|
|
17
|
+
import { PhoneNumberConfigProps } from '../common/text-field/PhoneNumberField';
|
|
18
18
|
export type SelectFieldItem = {
|
|
19
19
|
key?: string | number;
|
|
20
20
|
value: string | number;
|
|
@@ -27,7 +27,7 @@ export interface InitialCrudField<T> {
|
|
|
27
27
|
updatingValue?: T;
|
|
28
28
|
render?: (value: any, obj: T, index: number) => any;
|
|
29
29
|
required?: boolean;
|
|
30
|
-
updatable?: boolean;
|
|
30
|
+
updatable?: boolean | ((data: T) => boolean);
|
|
31
31
|
fieldTooltip?: string;
|
|
32
32
|
hideInTable?: boolean;
|
|
33
33
|
hideInDescList?: boolean;
|
|
@@ -236,6 +236,8 @@ export type CrudFieldProps<T> = {
|
|
|
236
236
|
readonly type: K;
|
|
237
237
|
};
|
|
238
238
|
}[keyof CrudFieldTypeMap<T>];
|
|
239
|
+
/** Field lists passed into CRUD components; accepts mutable arrays and `as const` tuples. */
|
|
240
|
+
export type ReadonlyCrudFields<T> = readonly CrudFieldProps<T>[];
|
|
239
241
|
export type CrudPaginateProps = false | ({
|
|
240
242
|
page?: number;
|
|
241
243
|
setPage?: (page: number, pageSize?: number) => void;
|
|
@@ -250,7 +252,7 @@ export type CrudWizardProp<T> = {
|
|
|
250
252
|
grid?: boolean;
|
|
251
253
|
};
|
|
252
254
|
export type CrudComponentProps<T, FormType = T> = {
|
|
253
|
-
fields:
|
|
255
|
+
fields: ReadonlyCrudFields<T>;
|
|
254
256
|
data: T[] | undefined;
|
|
255
257
|
idField?: string;
|
|
256
258
|
grid?: boolean;
|
package/dist/crud/CrudForm.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FormInstance, FormProps } from 'antd';
|
|
2
|
-
import {
|
|
2
|
+
import { CrudPurpose, FormBuilderFunc, ReadonlyCrudFields } from './CrudComponent';
|
|
3
3
|
export interface CurdFormFieldsProps<T> {
|
|
4
4
|
onDeleteFile?: (e: any) => void;
|
|
5
5
|
onUploadFile?: (e: any) => void;
|
|
6
6
|
grid?: boolean;
|
|
7
7
|
formBuilder?: FormBuilderFunc<T>;
|
|
8
|
-
fields:
|
|
8
|
+
fields: ReadonlyCrudFields<T>;
|
|
9
9
|
purpose?: CrudPurpose;
|
|
10
10
|
onValuesChange?: FormProps<T>["onValuesChange"];
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),y=require("@ant-design/icons"),a=require("antd"),q=require("react"),R=require("../locale/index.cjs.js"),S=require("./CrudForm.cjs.js"),B=require("../common/wizard/WizardViewForm.cjs.js"),v=require("../util/CrudUtil.cjs.js"),k=require("../util/ObjectUtil.cjs.js"),C=require("../common/button/Button.cjs.js");function w({fields:u,className:x,onDeleteFile:j,onUploadFile:i,purpose:l,wizard:t=[],updatingValue:g,onSave:b,submitting:F,onValuesChange:d}){const h=q.useMemo(()=>t.map(r=>{let n=!0;const o=u.filter(c=>{const s=v.getRealName(c.name);return!Array.isArray(s)&&r.fields.includes(s)});return o.forEach(c=>n&&(n=c.hidden??!1)),{...r,hidden:n,fieldThatShouldShowing:o}}),[u,t]),m=q.useMemo(()=>h.filter(r=>!r.hidden),[h]);return e.jsx(B,{onSubmit:(r,n)=>{b(n)},className:x,pages:m.map(({title:r,icon:n,fieldThatShouldShowing:o,hidden:c},s)=>({title:r,icon:n,hidden:c,component:f=>e.jsx(O,{fields:o,onDeleteFile:j,onUploadFile:i,purpose:l,i:s,updatingValue:g,backward:f.backward,forward:f.forward,wizard:m,submitting:F,onValuesChange:d},s)}))})}function O({fields:u,onDeleteFile:x,onUploadFile:j,purpose:i,wizard:l=[],i:t,forward:g,backward:b,submitting:F,updatingValue:d,onValuesChange:h}){const m=l[t],{t:r}=R.useTranslationLib(),[n]=a.Form.useForm();return q.useEffect(()=>{if(d&&(i==="update"||i==="clone")){const o={};for(const c of u){const s=v.getRealName(c.name,"upsertFieldName"),f=k.getValueByPath(d,s);k.setValueByPath(o,s,f)}n.setFieldsValue(o)}},[u,n,i,d]),e.jsxs(a.Form,{name:String(t),form:n,layout:"vertical",onValuesChange:h,children:[e.jsx(S.CrudFormFields,{fields:u,formBuilder:m.formBuilder,grid:m.grid,onDeleteFile:x,onUploadFile:j,purpose:i}),e.jsx(a.Divider,{}),e.jsxs(a.Row,{gutter:[8,8],children:[t>0&&e.jsx(a.Col,{md:12,children:e.jsx(C,{block:!0,icon:e.jsx(y.LeftOutlined,{}),htmlType:"button",type:"default",size:"large",onClick:()=>b(),children:r("str.back")})}),e.jsx(a.Col,{md:t>0?12:24,children:e.jsx(C,{block:!0,icon:l.length-1===t?e.jsx(y.SaveOutlined,{}):e.jsx(y.RightOutlined,{}),htmlType:"submit",type:"primary",loading:F,size:"large",onClick:()=>{n.validateFields().then(o=>{g(o,l.length-1===t,l.length-1===t)})},children:l.length-1===t?r("str."+(i==="update"?"update":"save")):r("str.next")})})]})]})}module.exports=w;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FormProps } from 'antd';
|
|
2
|
-
import {
|
|
2
|
+
import { CrudPurpose, CrudWizardProp, ReadonlyCrudFields } from './CrudComponent';
|
|
3
3
|
export interface CrudFormWizardProps<T> {
|
|
4
4
|
onDeleteFile?: (e: any) => void;
|
|
5
5
|
onUploadFile?: (e: any) => void;
|
|
6
|
-
fields:
|
|
6
|
+
fields: ReadonlyCrudFields<T>;
|
|
7
7
|
purpose?: CrudPurpose;
|
|
8
8
|
wizard?: CrudWizardProp<T>[];
|
|
9
9
|
className?: string;
|
|
@@ -1,145 +1,149 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import { LeftOutlined as
|
|
3
|
-
import { Form as
|
|
1
|
+
import { jsx as o, jsxs as F } from "react/jsx-runtime";
|
|
2
|
+
import { LeftOutlined as w, SaveOutlined as x, RightOutlined as R } from "@ant-design/icons";
|
|
3
|
+
import { Form as k, Divider as T, Row as W, Col as C } from "antd";
|
|
4
4
|
import { useMemo as v, useEffect as j } from "react";
|
|
5
5
|
import { useTranslationLib as z } from "../locale/index.es.js";
|
|
6
|
-
import { CrudFormFields as
|
|
6
|
+
import { CrudFormFields as N } from "./CrudForm.es.js";
|
|
7
7
|
import O from "../common/wizard/WizardViewForm.es.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
8
|
+
import B from "../util/CrudUtil.es.js";
|
|
9
|
+
import { getValueByPath as A, setValueByPath as E } from "../util/ObjectUtil.es.js";
|
|
10
|
+
import S from "../common/button/Button.es.js";
|
|
11
|
+
function J({
|
|
11
12
|
fields: d,
|
|
12
|
-
className:
|
|
13
|
-
onDeleteFile:
|
|
14
|
-
onUploadFile:
|
|
15
|
-
purpose:
|
|
13
|
+
className: h,
|
|
14
|
+
onDeleteFile: g,
|
|
15
|
+
onUploadFile: l,
|
|
16
|
+
purpose: m,
|
|
16
17
|
wizard: e = [],
|
|
17
|
-
updatingValue:
|
|
18
|
-
onSave:
|
|
19
|
-
submitting:
|
|
20
|
-
onValuesChange:
|
|
18
|
+
updatingValue: p,
|
|
19
|
+
onSave: b,
|
|
20
|
+
submitting: y,
|
|
21
|
+
onValuesChange: c
|
|
21
22
|
}) {
|
|
22
|
-
const
|
|
23
|
+
const s = v(() => e.map((t) => {
|
|
23
24
|
let r = !0;
|
|
24
|
-
const n = d.filter(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const n = d.filter((a) => {
|
|
26
|
+
const i = B.getRealName(a.name);
|
|
27
|
+
return !Array.isArray(i) && t.fields.includes(i);
|
|
28
|
+
});
|
|
29
|
+
return n.forEach((a) => r && (r = a.hidden ?? !1)), {
|
|
28
30
|
...t,
|
|
29
31
|
hidden: r,
|
|
30
32
|
fieldThatShouldShowing: n
|
|
31
33
|
};
|
|
32
|
-
}), [d, e]),
|
|
33
|
-
() =>
|
|
34
|
-
[
|
|
34
|
+
}), [d, e]), u = v(
|
|
35
|
+
() => s.filter((t) => !t.hidden),
|
|
36
|
+
[s]
|
|
35
37
|
);
|
|
36
38
|
return /* @__PURE__ */ o(
|
|
37
39
|
O,
|
|
38
40
|
{
|
|
39
41
|
onSubmit: (t, r) => {
|
|
40
|
-
|
|
42
|
+
b(r);
|
|
41
43
|
},
|
|
42
|
-
className:
|
|
43
|
-
pages:
|
|
44
|
-
({ title: t, icon: r, fieldThatShouldShowing: n, hidden:
|
|
44
|
+
className: h,
|
|
45
|
+
pages: u.map(
|
|
46
|
+
({ title: t, icon: r, fieldThatShouldShowing: n, hidden: a }, i) => ({
|
|
45
47
|
title: t,
|
|
46
48
|
icon: r,
|
|
47
|
-
hidden:
|
|
48
|
-
component: (
|
|
49
|
-
|
|
49
|
+
hidden: a,
|
|
50
|
+
component: (f) => /* @__PURE__ */ o(
|
|
51
|
+
L,
|
|
50
52
|
{
|
|
51
53
|
fields: n,
|
|
52
|
-
onDeleteFile:
|
|
53
|
-
onUploadFile:
|
|
54
|
-
purpose:
|
|
55
|
-
i
|
|
56
|
-
updatingValue:
|
|
57
|
-
backward:
|
|
58
|
-
forward:
|
|
59
|
-
wizard:
|
|
60
|
-
submitting:
|
|
61
|
-
onValuesChange:
|
|
54
|
+
onDeleteFile: g,
|
|
55
|
+
onUploadFile: l,
|
|
56
|
+
purpose: m,
|
|
57
|
+
i,
|
|
58
|
+
updatingValue: p,
|
|
59
|
+
backward: f.backward,
|
|
60
|
+
forward: f.forward,
|
|
61
|
+
wizard: u,
|
|
62
|
+
submitting: y,
|
|
63
|
+
onValuesChange: c
|
|
62
64
|
},
|
|
63
|
-
|
|
65
|
+
i
|
|
64
66
|
)
|
|
65
67
|
})
|
|
66
68
|
)
|
|
67
69
|
}
|
|
68
70
|
);
|
|
69
71
|
}
|
|
70
|
-
function
|
|
72
|
+
function L({
|
|
71
73
|
fields: d,
|
|
72
|
-
onDeleteFile:
|
|
73
|
-
onUploadFile:
|
|
74
|
-
purpose:
|
|
75
|
-
wizard:
|
|
74
|
+
onDeleteFile: h,
|
|
75
|
+
onUploadFile: g,
|
|
76
|
+
purpose: l,
|
|
77
|
+
wizard: m = [],
|
|
76
78
|
i: e,
|
|
77
|
-
forward:
|
|
78
|
-
backward:
|
|
79
|
-
submitting:
|
|
80
|
-
updatingValue:
|
|
81
|
-
onValuesChange:
|
|
79
|
+
forward: p,
|
|
80
|
+
backward: b,
|
|
81
|
+
submitting: y,
|
|
82
|
+
updatingValue: c,
|
|
83
|
+
onValuesChange: s
|
|
82
84
|
}) {
|
|
83
|
-
const
|
|
85
|
+
const u = m[e], { t } = z(), [r] = k.useForm();
|
|
84
86
|
return j(() => {
|
|
85
|
-
if (
|
|
87
|
+
if (c && (l === "update" || l === "clone")) {
|
|
86
88
|
const n = {};
|
|
87
|
-
for (const
|
|
88
|
-
|
|
89
|
+
for (const a of d) {
|
|
90
|
+
const i = B.getRealName(a.name, "upsertFieldName"), f = A(c, i);
|
|
91
|
+
E(n, i, f);
|
|
92
|
+
}
|
|
89
93
|
r.setFieldsValue(n);
|
|
90
94
|
}
|
|
91
|
-
}, [d, r,
|
|
92
|
-
|
|
95
|
+
}, [d, r, l, c]), /* @__PURE__ */ F(
|
|
96
|
+
k,
|
|
93
97
|
{
|
|
94
98
|
name: String(e),
|
|
95
99
|
form: r,
|
|
96
100
|
layout: "vertical",
|
|
97
|
-
onValuesChange:
|
|
101
|
+
onValuesChange: s,
|
|
98
102
|
children: [
|
|
99
103
|
/* @__PURE__ */ o(
|
|
100
|
-
|
|
104
|
+
N,
|
|
101
105
|
{
|
|
102
106
|
fields: d,
|
|
103
|
-
formBuilder:
|
|
104
|
-
grid:
|
|
105
|
-
onDeleteFile:
|
|
106
|
-
onUploadFile:
|
|
107
|
-
purpose:
|
|
107
|
+
formBuilder: u.formBuilder,
|
|
108
|
+
grid: u.grid,
|
|
109
|
+
onDeleteFile: h,
|
|
110
|
+
onUploadFile: g,
|
|
111
|
+
purpose: l
|
|
108
112
|
}
|
|
109
113
|
),
|
|
110
114
|
/* @__PURE__ */ o(T, {}),
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
e > 0 && /* @__PURE__ */ o(
|
|
113
|
-
|
|
115
|
+
/* @__PURE__ */ F(W, { gutter: [8, 8], children: [
|
|
116
|
+
e > 0 && /* @__PURE__ */ o(C, { md: 12, children: /* @__PURE__ */ o(
|
|
117
|
+
S,
|
|
114
118
|
{
|
|
115
119
|
block: !0,
|
|
116
|
-
icon: /* @__PURE__ */ o(
|
|
120
|
+
icon: /* @__PURE__ */ o(w, {}),
|
|
117
121
|
htmlType: "button",
|
|
118
122
|
type: "default",
|
|
119
123
|
size: "large",
|
|
120
|
-
onClick: () =>
|
|
124
|
+
onClick: () => b(),
|
|
121
125
|
children: t("str.back")
|
|
122
126
|
}
|
|
123
127
|
) }),
|
|
124
|
-
/* @__PURE__ */ o(
|
|
125
|
-
|
|
128
|
+
/* @__PURE__ */ o(C, { md: e > 0 ? 12 : 24, children: /* @__PURE__ */ o(
|
|
129
|
+
S,
|
|
126
130
|
{
|
|
127
131
|
block: !0,
|
|
128
|
-
icon:
|
|
132
|
+
icon: m.length - 1 === e ? /* @__PURE__ */ o(x, {}) : /* @__PURE__ */ o(R, {}),
|
|
129
133
|
htmlType: "submit",
|
|
130
134
|
type: "primary",
|
|
131
|
-
loading:
|
|
135
|
+
loading: y,
|
|
132
136
|
size: "large",
|
|
133
137
|
onClick: () => {
|
|
134
138
|
r.validateFields().then((n) => {
|
|
135
|
-
|
|
139
|
+
p(
|
|
136
140
|
n,
|
|
137
|
-
|
|
138
|
-
|
|
141
|
+
m.length - 1 === e,
|
|
142
|
+
m.length - 1 === e
|
|
139
143
|
);
|
|
140
144
|
});
|
|
141
145
|
},
|
|
142
|
-
children:
|
|
146
|
+
children: m.length - 1 === e ? t("str." + (l === "update" ? "update" : "save")) : t("str.next")
|
|
143
147
|
}
|
|
144
148
|
) })
|
|
145
149
|
] })
|
|
@@ -148,5 +152,5 @@ function E({
|
|
|
148
152
|
);
|
|
149
153
|
}
|
|
150
154
|
export {
|
|
151
|
-
|
|
155
|
+
J as default
|
|
152
156
|
};
|
|
@@ -15,7 +15,7 @@ export type SearchOnlyFields<F> = CrudFieldProps<F> & {
|
|
|
15
15
|
export type ReportCrudFields<T, F> = CrudFieldProps<T> | SearchOnlyFields<F>;
|
|
16
16
|
export interface CrudReportComponentProps<T_Data, F_Search> {
|
|
17
17
|
summary?: React.ReactNode;
|
|
18
|
-
fields: ReportCrudFields<T_Data, F_Search>[];
|
|
18
|
+
fields: readonly ReportCrudFields<T_Data, F_Search>[];
|
|
19
19
|
onSubmit: (value: CrudReportSubmitForm<F_Search>) => void;
|
|
20
20
|
data: T_Data[];
|
|
21
21
|
idField?: string;
|
|
@@ -23,16 +23,16 @@ export interface CrudReportComponentProps<T_Data, F_Search> {
|
|
|
23
23
|
size?: SizeType;
|
|
24
24
|
paginateProps?: CrudPaginateProps;
|
|
25
25
|
onClickPrint?: (props: {
|
|
26
|
-
fields: CrudFieldProps<T_Data>
|
|
26
|
+
fields: readonly (CrudFieldProps<T_Data> & {
|
|
27
27
|
render: (value: any, obj: T_Data, index: number) => any;
|
|
28
|
-
}[];
|
|
28
|
+
})[];
|
|
29
29
|
data: T_Data[];
|
|
30
30
|
tableId: string;
|
|
31
31
|
}) => void;
|
|
32
32
|
onClickExcelExport?: (props: {
|
|
33
|
-
fields: CrudFieldProps<T_Data>
|
|
33
|
+
fields: readonly (CrudFieldProps<T_Data> & {
|
|
34
34
|
render: (value: any, obj: T_Data, index: number) => any;
|
|
35
|
-
}[];
|
|
35
|
+
})[];
|
|
36
36
|
data: T_Data[];
|
|
37
37
|
tableId: string;
|
|
38
38
|
}) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColProps } from 'antd/lib';
|
|
2
|
-
import {
|
|
2
|
+
import { ReadonlyCrudFields } from './CrudComponent';
|
|
3
3
|
export type CrudSearchOption<T> = {
|
|
4
4
|
required?: boolean;
|
|
5
5
|
} & ({
|
|
@@ -12,7 +12,7 @@ export type CrudSearchOption<T> = {
|
|
|
12
12
|
});
|
|
13
13
|
export interface CrudSearchComponentProps<T, FormType> {
|
|
14
14
|
searchFields?: Array<keyof T | CrudSearchOption<T>>;
|
|
15
|
-
fields:
|
|
15
|
+
fields: ReadonlyCrudFields<T>;
|
|
16
16
|
searchOnChange?: boolean;
|
|
17
17
|
searchDefaultValues?: FormType;
|
|
18
18
|
onSearch?: (values: Partial<FormType>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReadonlyCrudFields } from '../CrudComponent';
|
|
2
2
|
import { DialogProps } from '../../types/DialogComponentProp';
|
|
3
3
|
export interface CrudImportComponentProps<T> {
|
|
4
|
-
fields:
|
|
4
|
+
fields: ReadonlyCrudFields<T>;
|
|
5
5
|
importProps: CrudImportProps<T>;
|
|
6
6
|
}
|
|
7
7
|
export interface CrudImportProps<T> {
|
package/dist/crud/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { CheckboxBasedFieldProps, ColorPickerFieldProps, CrudComponentProps, CrudFieldGrid, CrudFieldProps, CrudPaginateProps, CrudPurpose, CrudWizardProp, DateBasedFieldProps, EnumCrudField, FormBuilderFunc, FormBuilderFunc0, GetFormFieldOptions, InitialCrudField, NumberBasedFieldProps, ObjectCrudField, SelectCrudField, SelectFieldItem, TextBasedFieldProps, TimeBasedFieldProps, } from './CrudComponent';
|
|
1
|
+
export type { CheckboxBasedFieldProps, ColorPickerFieldProps, CrudComponentProps, CrudFieldGrid, CrudFieldProps, CrudPaginateProps, ReadonlyCrudFields, CrudPurpose, CrudWizardProp, DateBasedFieldProps, EnumCrudField, FormBuilderFunc, FormBuilderFunc0, GetFormFieldOptions, InitialCrudField, NumberBasedFieldProps, ObjectCrudField, SelectCrudField, SelectFieldItem, TextBasedFieldProps, TimeBasedFieldProps, } from './CrudComponent';
|
|
2
2
|
export { default as CrudComponent } from './CrudComponent';
|
|
3
3
|
export { default as CrudField, ColorCrudFieldComponent, SelectCrudFieldComponent, } from './CrudField';
|
|
4
4
|
export { CrudForm, CrudFormFields } from './CrudForm';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const g=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const g=require("react/jsx-runtime"),q=require("antd"),t=require("react"),Z=require("../CrudForm.cjs.js"),z=require("../CrudFormWizard.cjs.js"),ee=require("../../locale/index.cjs.js"),B=require("../../util/CrudUtil.cjs.js"),te=require("dayjs"),r=require("../../util/ObjectUtil.cjs.js"),ae=({fields:l,wizard:i,grid:_,fullWidthModal:A,isCreating:N,isUpdating:M,onCreate:V,onUpdate:h,idField:v="id",formBuilder:L,onValuesChange:U},E)=>{const[n]=q.Form.useForm(),{t:S}=ee.useTranslationLib(),[k,y]=t.useState(!1),[p,R]=t.useState("new"),[f,F]=t.useState(),[$,b]=t.useState(),[G,O]=t.useState(!1),[J,P]=t.useState(!1),[K,w]=t.useState(!1),W=t.useCallback(async s=>{var m;const d=i?s:await n.validateFields(),u=l.filter(a=>a.type==="color"),o={};for(const a of u){const c=B.getRealName(a.name,"upsertFieldName"),e=n.getFieldValue(c);r.setValueByPath(o,c,typeof e=="string"?e:(m=e==null?void 0:e.toHexString())==null?void 0:m.toUpperCase())}Object.assign(d,o),f&&h?(await h({...d,[v]:f[v]}),F(void 0)):!f&&V&&await V(d),b(void 0),x(new Map),n.resetFields(),y(!1)},[l,n,v,V,h,f,i]),D=t.useCallback(async s=>{O(s),P(!0)},[]),H=t.useCallback(async()=>{P(!0)},[]),I=t.useCallback(()=>{y(!0),R("new"),n.resetFields(),F(void 0),b(void 0)},[n]),[C,x]=t.useState(new Map),Q=t.useMemo(()=>C.size===0?l:l.map(s=>typeof s.updatable=="function"?{...s,updatable:C.get(B.getRealName(s.name,"name"))??s.updatable}:s),[l,C]),T=t.useCallback(async(s,d=!0,u=!1)=>{try{w(!0),y(!0),R(u?"clone":"update");const o={};for(const a of l){const c=B.getRealName(a.name,"upsertFieldName"),e=r.getValueByPath(s,c);if(u&&a.type==="image"){const j=e;try{const Y=await a.provider.clone(j);r.setValueByPath(o,c,Y);continue}catch{continue}}a.type==="date"||a.type==="time"?e&&r.setValueByPath(o,c,te(e)):a.type==="select"?a.multiple&&Array.isArray(e)?r.setValueByPath(o,c,e.map(j=>j[a.innerFieldId??"id"])):e&&typeof e=="object"?r.setValueByPath(o,c,e[a.innerFieldId??"id"]):(e&&typeof e=="string"||typeof e=="number")&&r.setValueByPath(o,c,e):r.setValueByPath(o,c,e)}n.setFieldsValue(o);const m=new Map;for(const a of l)typeof a.updatable=="function"&&m.set(B.getRealName(a.name,"name"),a.updatable(s));x(m),b(o),d&&F(s)}finally{w(!1)}},[l,n]);t.useImperativeHandle(E,()=>({create:I,update:T}),[I,T]),t.useEffect(()=>{k&&(O(!1),P(!1))},[k]);const X=t.useCallback(async()=>{x(new Map);try{if(p==="clone"){const s=i?f:n.getFieldsValue(),d=l.filter(u=>u.type==="image");for(const u of d)s[u.name]&&u.provider.delete(s[u.name])}}finally{}i||n.resetFields(),b(void 0),F(void 0),y(!1)},[p,i,n,f,l]);return g.jsx(q.Modal,{width:A?"100%":void 0,title:S("str."+(p??"new")),open:k,confirmLoading:N||M,okText:S("str."+(p==="update"?"update":"save")),cancelText:S("str.cancel"),cancelButtonProps:{disabled:J,hidden:!!i},okButtonProps:{disabled:G,hidden:!!i},onCancel:X,onOk:()=>W(),destroyOnHidden:!0,children:g.jsxs(q.Spin,{spinning:K,children:[i?null:g.jsx(Z.CrudForm,{purpose:p,fields:Q,form:n,formBuilder:L,grid:_,onDeleteFile:H,onUploadFile:D,onValuesChange:U}),i&&g.jsx(z,{submitting:N||M,className:"mt-2",onSave:W,updatingValue:$,fields:l,onDeleteFile:H,onUploadFile:D,purpose:p,wizard:i,onValuesChange:U})]})})},se=t.forwardRef(ae);module.exports=se;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FormProps } from 'antd';
|
|
2
2
|
import { Ref } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { CrudWizardProp, FormBuilderFunc, ReadonlyCrudFields } from '../CrudComponent';
|
|
4
4
|
import { default as IdProps } from '../../types/Id';
|
|
5
5
|
export interface CrudModalProps<T, FormType> {
|
|
6
|
-
fields:
|
|
6
|
+
fields: ReadonlyCrudFields<T>;
|
|
7
7
|
wizard?: CrudWizardProp<T>[];
|
|
8
8
|
grid?: boolean;
|
|
9
9
|
fullWidthModal?: boolean;
|