@kingteza/crud-component 1.27.3 → 1.29.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/crud/CrudComponent.cjs.js +1 -1
- package/dist/crud/CrudComponent.d.ts +14 -5
- package/dist/crud/CrudComponent.es.js +73 -69
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +302 -286
- package/dist/crud/actions/index.cjs.js +1 -1
- package/dist/crud/actions/index.d.ts +3 -1
- package/dist/crud/actions/index.es.js +63 -61
- package/dist/crud/view/CrudViewer.cjs.js +1 -1
- package/dist/crud/view/CrudViewer.d.ts +1 -1
- package/dist/crud/view/CrudViewer.es.js +190 -182
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),q=require("antd"),n=require("react")
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),q=require("antd"),n=require("react"),$=require("./modal/index.cjs.js"),p=require("./import/CrudImportButton.cjs.js"),U=require("./view/CrudViewer.cjs.js"),P=require("../common/button/NewButton.cjs.js"),ee=require("../common/button/PrintButton.cjs.js");function ce({idField:x="id",onCreate:h,onDelete:N,deletable:v,onHide:b,onUpdate:t,updatable:g,onClickUpdate:d,fields:l,data:R,grid:y,isHiding:B,isCreating:M,isDeleting:S,isUpdating:I,paginateProps:O,onPrint:k,printing:V,viewable:W,loadingData:_,formBuilder:w,extraAction:z,minusHeight:A,scroll:D,cloneable:E,fullWidthModal:F=!0,wizard:G,extraView:H,importable:m,onClickNew:r,newButtonProps:c,size:J,headerRender:i,actionWidth:K,onValuesChange:L,...Q}){const a=n.useRef(null),T=n.useCallback(()=>{var s;(s=a.current)==null||s.create()},[]),o=n.useCallback(async(s,C=!0,Z=!1)=>{var j;await((j=a.current)==null?void 0:j.update(s,C,Z))},[]),X=n.useCallback(async s=>{o(s,!1,!0)},[o]),{onClick:se,...f}=n.useMemo(()=>c||{},[c]),u=n.useMemo(()=>e.jsx(P.NewButton,{onClick:(s,C)=>{r?r():c!=null&&c.onClick?c.onClick(C):T()},className:"flex-1",...f}),[r,c,f]),Y=n.useCallback(()=>i?i({newButton:u}):u,[u,i]);return e.jsxs(e.Fragment,{children:[e.jsxs(q.Space,{direction:"vertical",className:"w-100",children:[e.jsxs("div",{className:"w-100 d-flex",children:[e.jsx("div",{className:"flex-1",children:Y()}),e.jsxs(q.Space,{children:[!!k&&e.jsx(ee.PrintButton,{className:"float-right",loading:V,onClick:k}),!!m&&e.jsx(p,{fields:l,importProps:m})]})]}),e.jsx(U,{...Q,minusHeight:A,scroll:D,data:R,size:J,fields:l,extraAction:z,actionWidth:K,idField:x,isDeleting:S,loadingData:_,onClickUpdate:d||(t?o:void 0),onHide:b,isHiding:B,onDelete:N,deletable:v,updatable:g,onUpdate:t,onClickClone:E?X:void 0,paginateProps:O,viewable:W,extraView:H})]}),e.jsx($,{ref:a,fields:l,wizard:G,grid:y,fullWidthModal:F,isCreating:M,isUpdating:I,onCreate:h,onUpdate:t,idField:x,formBuilder:w,onValuesChange:L})]})}module.exports=ce;
|
|
@@ -112,19 +112,26 @@ export interface SelectCrudField<T, ItemType extends SelectFieldItem = SelectFie
|
|
|
112
112
|
onSet?: (value: any | any[], items: SelectFieldItem[], form: FormInstance<T>) => void;
|
|
113
113
|
selectOptionRender?: (option: SelectFieldItem) => ReactNode;
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
type EnumBaseFieldProps<T> = InitialCrudField<T> & Copyable<false> & {
|
|
116
116
|
type: "enum";
|
|
117
117
|
placeholder?: string;
|
|
118
118
|
enum: object | object[];
|
|
119
|
-
radio?: boolean;
|
|
120
119
|
translation?: object;
|
|
121
|
-
multiple?: boolean;
|
|
122
120
|
tagRender?: Record<string, {
|
|
123
121
|
color: string;
|
|
124
122
|
}> | SelectTagRenderProps;
|
|
125
123
|
onChange?: (value: T[keyof T], form: FormInstance<T>) => void;
|
|
126
124
|
onSearch?: (keyword: string, form: FormInstance<T>) => void;
|
|
127
|
-
}
|
|
125
|
+
};
|
|
126
|
+
export type EnumCrudField<T> = EnumBaseFieldProps<T> & ({
|
|
127
|
+
multiple?: false;
|
|
128
|
+
radio?: true;
|
|
129
|
+
} | {
|
|
130
|
+
multiple: true;
|
|
131
|
+
checkbox?: true;
|
|
132
|
+
/** When `checkbox` is true, wraps each option in a `Col` for grid layout. */
|
|
133
|
+
checkboxGrid?: CrudFieldGrid;
|
|
134
|
+
});
|
|
128
135
|
export type AddonFieldProps = {
|
|
129
136
|
addonAfter?: ReactNode;
|
|
130
137
|
addonBefore?: ReactNode;
|
|
@@ -252,7 +259,9 @@ export type CrudComponentProps<T, FormType = T> = {
|
|
|
252
259
|
onCreate?: (t: FormType) => Promise<any>;
|
|
253
260
|
onHide?: (id: any) => Promise<any>;
|
|
254
261
|
onDelete?: (id: any) => Promise<any>;
|
|
262
|
+
deletable?: (t: T) => boolean;
|
|
255
263
|
onUpdate?: (t: FormType & IdProps) => Promise<any>;
|
|
264
|
+
updatable?: (t: T) => boolean;
|
|
256
265
|
onClickUpdate?: (t: T) => void;
|
|
257
266
|
loadingData?: boolean;
|
|
258
267
|
isCreating?: boolean;
|
|
@@ -283,5 +292,5 @@ export type CrudComponentProps<T, FormType = T> = {
|
|
|
283
292
|
}) => React.ReactElement;
|
|
284
293
|
onValuesChange?: FormProps<T>["onValuesChange"];
|
|
285
294
|
} & CrudSearchComponentProps<T, FormType>;
|
|
286
|
-
declare function CrudComponent<T, FormType = T>({ idField, onCreate, onDelete, onHide, onUpdate, onClickUpdate, fields, data, grid, isHiding, isCreating, isDeleting, isUpdating, paginateProps, onPrint, printing, viewable, loadingData, formBuilder, extraAction, minusHeight, scroll, cloneable, fullWidthModal, wizard, extraView, importable, onClickNew, newButtonProps, size, headerRender, actionWidth, onValuesChange, ...props }: CrudComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
|
|
295
|
+
declare function CrudComponent<T, FormType = T>({ idField, onCreate, onDelete, deletable, onHide, onUpdate, updatable, onClickUpdate, fields, data, grid, isHiding, isCreating, isDeleting, isUpdating, paginateProps, onPrint, printing, viewable, loadingData, formBuilder, extraAction, minusHeight, scroll, cloneable, fullWidthModal, wizard, extraView, importable, onClickNew, newButtonProps, size, headerRender, actionWidth, onValuesChange, ...props }: CrudComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
|
|
287
296
|
export default CrudComponent;
|
|
@@ -1,135 +1,139 @@
|
|
|
1
|
-
import { jsx as r, jsxs as l, Fragment as
|
|
1
|
+
import { jsx as r, jsxs as l, Fragment as U } from "react/jsx-runtime";
|
|
2
2
|
import { Space as N } from "antd";
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { NewButton as
|
|
8
|
-
import { PrintButton as
|
|
9
|
-
function
|
|
3
|
+
import { useRef as P, useCallback as c, useMemo as v } from "react";
|
|
4
|
+
import ee from "./modal/index.es.js";
|
|
5
|
+
import oe from "./import/CrudImportButton.es.js";
|
|
6
|
+
import re from "./view/CrudViewer.es.js";
|
|
7
|
+
import { NewButton as le } from "../common/button/NewButton.es.js";
|
|
8
|
+
import { PrintButton as ce } from "../common/button/PrintButton.es.js";
|
|
9
|
+
function de({
|
|
10
10
|
idField: C = "id",
|
|
11
11
|
onCreate: g,
|
|
12
12
|
onDelete: j,
|
|
13
|
-
|
|
13
|
+
deletable: y,
|
|
14
|
+
onHide: M,
|
|
14
15
|
onUpdate: i,
|
|
16
|
+
updatable: I,
|
|
15
17
|
onClickUpdate: d,
|
|
16
18
|
fields: t,
|
|
17
|
-
data:
|
|
18
|
-
grid:
|
|
19
|
-
isHiding:
|
|
20
|
-
isCreating:
|
|
21
|
-
isDeleting:
|
|
22
|
-
isUpdating:
|
|
23
|
-
paginateProps:
|
|
19
|
+
data: O,
|
|
20
|
+
grid: R,
|
|
21
|
+
isHiding: S,
|
|
22
|
+
isCreating: V,
|
|
23
|
+
isDeleting: W,
|
|
24
|
+
isUpdating: _,
|
|
25
|
+
paginateProps: b,
|
|
24
26
|
onPrint: k,
|
|
25
|
-
printing:
|
|
26
|
-
viewable:
|
|
27
|
-
loadingData:
|
|
28
|
-
formBuilder:
|
|
29
|
-
extraAction:
|
|
30
|
-
minusHeight:
|
|
31
|
-
scroll:
|
|
32
|
-
cloneable:
|
|
33
|
-
fullWidthModal:
|
|
34
|
-
wizard:
|
|
35
|
-
extraView:
|
|
27
|
+
printing: q,
|
|
28
|
+
viewable: z,
|
|
29
|
+
loadingData: A,
|
|
30
|
+
formBuilder: B,
|
|
31
|
+
extraAction: D,
|
|
32
|
+
minusHeight: E,
|
|
33
|
+
scroll: F,
|
|
34
|
+
cloneable: G,
|
|
35
|
+
fullWidthModal: H = !0,
|
|
36
|
+
wizard: J,
|
|
37
|
+
extraView: K,
|
|
36
38
|
importable: h,
|
|
37
39
|
onClickNew: a,
|
|
38
40
|
newButtonProps: e,
|
|
39
|
-
size:
|
|
41
|
+
size: L,
|
|
40
42
|
headerRender: n,
|
|
41
|
-
actionWidth:
|
|
42
|
-
onValuesChange:
|
|
43
|
-
...
|
|
43
|
+
actionWidth: Q,
|
|
44
|
+
onValuesChange: T,
|
|
45
|
+
...X
|
|
44
46
|
}) {
|
|
45
|
-
const m =
|
|
47
|
+
const m = P(null), Y = c(() => {
|
|
46
48
|
var o;
|
|
47
49
|
(o = m.current) == null || o.create();
|
|
48
50
|
}, []), s = c(
|
|
49
|
-
async (o, u = !0,
|
|
51
|
+
async (o, u = !0, w = !1) => {
|
|
50
52
|
var x;
|
|
51
|
-
await ((x = m.current) == null ? void 0 : x.update(o, u,
|
|
53
|
+
await ((x = m.current) == null ? void 0 : x.update(o, u, w));
|
|
52
54
|
},
|
|
53
55
|
[]
|
|
54
|
-
),
|
|
56
|
+
), Z = c(
|
|
55
57
|
async (o) => {
|
|
56
58
|
s(o, !1, !0);
|
|
57
59
|
},
|
|
58
60
|
[s]
|
|
59
|
-
), { onClick:
|
|
61
|
+
), { onClick: ie, ...p } = v(() => e || {}, [e]), f = v(
|
|
60
62
|
() => /* @__PURE__ */ r(
|
|
61
|
-
|
|
63
|
+
le,
|
|
62
64
|
{
|
|
63
65
|
onClick: (o, u) => {
|
|
64
|
-
a ? a() : e != null && e.onClick ? e.onClick(u) :
|
|
66
|
+
a ? a() : e != null && e.onClick ? e.onClick(u) : Y();
|
|
65
67
|
},
|
|
66
68
|
className: "flex-1",
|
|
67
69
|
...p
|
|
68
70
|
}
|
|
69
71
|
),
|
|
70
72
|
[a, e, p]
|
|
71
|
-
),
|
|
72
|
-
return /* @__PURE__ */ l(
|
|
73
|
+
), $ = c(() => n ? n({ newButton: f }) : f, [f, n]);
|
|
74
|
+
return /* @__PURE__ */ l(U, { children: [
|
|
73
75
|
/* @__PURE__ */ l(N, { direction: "vertical", className: "w-100", children: [
|
|
74
76
|
/* @__PURE__ */ l("div", { className: "w-100 d-flex", children: [
|
|
75
|
-
/* @__PURE__ */ r("div", { className: "flex-1", children:
|
|
77
|
+
/* @__PURE__ */ r("div", { className: "flex-1", children: $() }),
|
|
76
78
|
/* @__PURE__ */ l(N, { children: [
|
|
77
79
|
!!k && /* @__PURE__ */ r(
|
|
78
|
-
|
|
80
|
+
ce,
|
|
79
81
|
{
|
|
80
82
|
className: "float-right",
|
|
81
|
-
loading:
|
|
83
|
+
loading: q,
|
|
82
84
|
onClick: k
|
|
83
85
|
}
|
|
84
86
|
),
|
|
85
|
-
!!h && /* @__PURE__ */ r(
|
|
87
|
+
!!h && /* @__PURE__ */ r(oe, { fields: t, importProps: h })
|
|
86
88
|
] })
|
|
87
89
|
] }),
|
|
88
90
|
/* @__PURE__ */ r(
|
|
89
|
-
|
|
91
|
+
re,
|
|
90
92
|
{
|
|
91
|
-
...
|
|
92
|
-
minusHeight:
|
|
93
|
-
scroll:
|
|
94
|
-
data:
|
|
95
|
-
size:
|
|
93
|
+
...X,
|
|
94
|
+
minusHeight: E,
|
|
95
|
+
scroll: F,
|
|
96
|
+
data: O,
|
|
97
|
+
size: L,
|
|
96
98
|
fields: t,
|
|
97
|
-
extraAction:
|
|
98
|
-
actionWidth:
|
|
99
|
+
extraAction: D,
|
|
100
|
+
actionWidth: Q,
|
|
99
101
|
idField: C,
|
|
100
|
-
isDeleting:
|
|
101
|
-
loadingData:
|
|
102
|
+
isDeleting: W,
|
|
103
|
+
loadingData: A,
|
|
102
104
|
onClickUpdate: d || (i ? s : void 0),
|
|
103
|
-
onHide:
|
|
104
|
-
isHiding:
|
|
105
|
+
onHide: M,
|
|
106
|
+
isHiding: S,
|
|
105
107
|
onDelete: j,
|
|
108
|
+
deletable: y,
|
|
109
|
+
updatable: I,
|
|
106
110
|
onUpdate: i,
|
|
107
|
-
onClickClone:
|
|
108
|
-
paginateProps:
|
|
109
|
-
viewable:
|
|
110
|
-
extraView:
|
|
111
|
+
onClickClone: G ? Z : void 0,
|
|
112
|
+
paginateProps: b,
|
|
113
|
+
viewable: z,
|
|
114
|
+
extraView: K
|
|
111
115
|
}
|
|
112
116
|
)
|
|
113
117
|
] }),
|
|
114
118
|
/* @__PURE__ */ r(
|
|
115
|
-
|
|
119
|
+
ee,
|
|
116
120
|
{
|
|
117
121
|
ref: m,
|
|
118
122
|
fields: t,
|
|
119
|
-
wizard:
|
|
120
|
-
grid:
|
|
121
|
-
fullWidthModal:
|
|
122
|
-
isCreating:
|
|
123
|
-
isUpdating:
|
|
123
|
+
wizard: J,
|
|
124
|
+
grid: R,
|
|
125
|
+
fullWidthModal: H,
|
|
126
|
+
isCreating: V,
|
|
127
|
+
isUpdating: _,
|
|
124
128
|
onCreate: g,
|
|
125
129
|
onUpdate: i,
|
|
126
130
|
idField: C,
|
|
127
|
-
formBuilder:
|
|
128
|
-
onValuesChange:
|
|
131
|
+
formBuilder: B,
|
|
132
|
+
onValuesChange: T
|
|
129
133
|
}
|
|
130
134
|
)
|
|
131
135
|
] });
|
|
132
136
|
}
|
|
133
137
|
export {
|
|
134
|
-
|
|
138
|
+
de as default
|
|
135
139
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),x=require("antd"),k=require("react"),K=require("react-highlight-words"),Q=require("../locale/index.cjs.js"),V=require("./FileCrudField.cjs.js"),X=require("./ImageCrudField.cjs.js"),Y=require("../common/check-box/CheckBox.cjs.js"),Z=require("../common/date-picker/DatePicker.cjs.js"),ee=require("../common/date-picker/TimePicker.cjs.js"),U=require("../common/select/SelectComponent.cjs.js"),re=require("../common/text-field/NumberField.cjs.js"),te=require("../common/text-field/PhoneNumberField.cjs.js"),ae=require("../common/text-field/TextField.cjs.js"),le=require("../common/tooltip/TooltipComponent.cjs.js"),ne=require("./CrudTextAreaComponent.cjs.js"),M=require("../util/CrudUtil.cjs.js");function oe(w){const{label:o,name:c,type:j,required:i,hidden:P,rules:h=[],updatable:g=!0,readonly:R=!1,fieldClassName:u,customFormFieldRender:T,fieldTooltip:v,fieldHelper:f,formLayoutProps:y,...e}=w,C=x.Form.useFormInstance();k.useEffect(()=>{if(j==="select"){const{items:a=[],onSearch:n,searchOnType:s}=e;!(a!=null&&a.length)&&!s&&(n==null||n(void 0,C,e==null?void 0:e.updatingValue))}},[C,e,j,e==null?void 0:e.updatingValue]);const{t:S}=Q.useTranslationLibNoNS();if(R||P)return r.jsx(r.Fragment,{});if(T)return T(C,w);switch(j){case"text":case"email":case"password":{const{onChange:a,placeholder:n,addonAfter:s,addonBefore:p}=e;return r.jsx(ae.default,{...y,placeholder:n,disabled:!g,rules:h,required:i,onChange:a?b=>a(b,C):void 0,type:j,name:c,tooltip:v,label:o,className:u,autoComplete:"new-password",addonAfter:s,addonBefore:p,help:f})}case"phone":{const{onChange:a,placeholder:n,addonAfter:s,addonBefore:p}=e;return r.jsx(te,{...e,...y,placeholder:n,disabled:!g,rules:h,required:i,onChange:a?b=>a(b,C):void 0,type:j,name:c,tooltip:v,label:o,className:u,autoComplete:"new-password",addonAfter:s,addonBefore:p,help:f})}case"number":{const{onChange:a,placeholder:n,allowMinus:s,min:p,max:b,addonAfter:d,addonBefore:N}=e;return r.jsx(re,{...y,placeholder:n,disabled:!g,moneyField:!!e.formatted,type:j,onChange:a?t=>a(t,C):void 0,rules:h,autoComplete:"false",required:i,tooltip:v,className:u,min:s?null:p,max:b,addonAfter:d,addonBefore:N,name:c,label:o,help:f})}case"date":{const{range:a,disableToday:n,disabledFutureDays:s,disabledPastDays:p,onChange:b,placeholder:d,format:N}=e;return r.jsx(Z,{...y,placeholder:d,required:i,disabled:!g,type:j,format:N,tooltip:v,range:a,name:c,label:o,onChange:b?t=>b(t,C):void 0,className:u,disableToday:n,disabledFutureDays:s,disabledPastDays:p,help:f})}case"time":{const{range:a=!1,disableCurrent:n,disabledFuture:s,disabledPast:p,onChange:b,use12Hours:d,format:N,placeholder:t}=e;return r.jsx(ee,{...y,placeholder:t,required:i,format:N,disabled:!g,type:j,tooltip:v,range:a,use12Hours:d,name:c,label:o,onChange:b?F=>b(F,C):void 0,className:u,disableCurrent:n,disabledFuture:s,disabledPast:p,help:f})}case"textarea":return r.jsx(ne,{...w});case"image":return r.jsx(X.default,{...e,required:i,name:c,label:o,rules:h,fieldHelper:f,fieldClassName:u,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"file":return r.jsx(V.default,{...e,required:i,name:c,label:o,rules:h,fieldHelper:f,fieldClassName:u,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"select":return r.jsx(_,{...e,required:i,name:c,label:o,rules:h,fieldClassName:u,form:C,help:f,updatable:g,readonly:R,fieldTooltip:v,fieldHelper:f});case"enum":{const{enum:a,translation:n,onChange:s,onSearch:p,multiple:b,tagRender:d}=e,N=Array.isArray(a)?a:Object.keys(a);return"radio"in e&&e.radio?r.jsx(x.Form.Item,{...e,...y,name:c,required:i,tooltip:v,rules:h,label:o,className:["w-100",u].join(" "),help:f,children:r.jsx(x.Radio.Group,{...e,onChange:s?t=>{var F;return s((F=t==null?void 0:t.target)==null?void 0:F.value,C)}:void 0,children:N.map(t=>r.jsx(x.Radio,{disabled:!g,value:t,children:n?S(n[t]):t},t))})}):"checkbox"in e&&e.checkbox?r.jsx(x.Form.Item,{...e,...y,name:c,required:i,tooltip:v,rules:h,label:o,className:["w-100",u].join(" "),help:f,children:r.jsx(x.Checkbox.Group,{className:"w-100",children:N.map(t=>{const F=r.jsx(x.Checkbox,{disabled:!g,value:t,children:n?S(n[t]):t},t);return"checkboxGrid"in e&&e.checkboxGrid?r.jsx(x.Col,{...e.checkboxGrid,children:F}):F})})}):r.jsx(U,{...e,...y,tagRender:typeof d=="function"?d:d?t=>{const{value:F,label:O}=t,q=d[F];return q?r.jsx(x.Tag,{color:q.color,children:O}):r.jsx(x.Tag,{children:O})}:void 0,onChange:s?t=>s(t,C):void 0,className:["w-100",u].join(" "),name:c,items:N,required:i,tooltip:v,rules:h,label:o,help:f,disabled:!g,onSearch:p?t=>p(t,C):void 0,allowClear:!0,mode:b?"multiple":void 0,showLoadingInEmptyIndicator:!0,itemBuilder:t=>r.jsx(x.Select.Option,{value:t,children:n?S(n[t]):t},t)})}case"checkbox":{const{onChange:a,switch:n}=e;return r.jsx(Y,{...y,className:u,rules:h,onChange:a?s=>a(s,C):void 0,label:o,tooltip:v,disabled:!g,name:c,help:f,switch:n})}case"color":return r.jsx(D,{...e,type:"color",required:i,name:c,label:o,rules:h,fieldClassName:u,updatable:g,readonly:R,fieldTooltip:v,fieldHelper:f});default:return r.jsx(r.Fragment,{children:`${j} Not Implemented`})}}function _(w){const{items:o=[],loading:c,searchOnType:j,onSearch:i,multiple:P,onChange:h,highlightSearch:g,required:R,fieldClassName:u,rules:T,fieldTooltip:v,updatable:f,label:y,name:e,tagRender:C,updatingValue:S,onSet:a,placeholder:n,allowClear:s=!0,selectOptionRender:p,formLayoutProps:b}=w,d=w.form,[N,t]=k.useState(""),F=k.useMemo(()=>M.getRealName(e),[e]),O=k.useMemo(()=>M.getRealName(e,"upsertFieldName"),[e]),q=x.Form.useWatch(F,d),[H,I]=k.useState(!0);k.useEffect(()=>{a&&H&&q&&(a==null||a(q,o,d),I(!1))},[H,d,o,F,a,q]),k.useEffect(()=>{q&&I(!0)},[q]);const W=k.useCallback(async l=>{t(l),j&&(i==null||i(l,d,S))},[d,i,j,S]),$=k.useCallback(l=>p?p(l):l.value,[p]);return r.jsx(U,{...w,...b,showLoadingInEmptyIndicator:!0,maxTagCount:"responsive",maxTagPlaceholder:l=>r.jsxs(le,{title:r.jsx(r.Fragment,{children:l.map(m=>r.jsxs(r.Fragment,{children:[m.label," ",r.jsx("br",{})]}))}),children:["+",l==null?void 0:l.length]}),placeholder:n,onSelect:l=>{a==null||a(l==null?void 0:l.key,o,d)},onChange:h?l=>{t(""),h(l,d)}:void 0,mode:P?"multiple":void 0,className:["w-100",u].join(" "),name:O,items:o,required:R,tooltip:v,tagRender:C,rules:T,disabled:!f,label:y,allowClear:s,onSearch:W,loading:c,filterOption:g?(l,m)=>{var L,A,B;try{const E=l.toLowerCase().split(/\s+/),z=((typeof(m==null?void 0:m.children)=="string"?m==null?void 0:m.children:(A=(L=m==null?void 0:m.children)==null?void 0:L.props)==null?void 0:A.textToHighlight)??"").toLowerCase(),J=(((B=m==null?void 0:m.value)==null?void 0:B.toString())??"").toLowerCase();return E.every(G=>z.indexOf(G)>=0||J.indexOf(G)>=0)}catch{return!0}}:void 0,itemBuilder:g?l=>{const m=l.value?String(l.value):void 0;return r.jsx(x.Select.Option,{value:l.key,title:m,disabled:l.disabled,children:r.jsx(K,{highlightClassName:"highlight-text",searchWords:(N??"").split(" "),autoEscape:!0,textToHighlight:m??""})},l.key)}:l=>r.jsx(x.Select.Option,{value:l.key,title:l.value,disabled:l.disabled,children:$(l)},l.key)})}function D(w){const{formLayoutProps:o,required:c,fieldClassName:j,rules:i,fieldTooltip:P,updatable:h,label:g,name:R,fieldHelper:u}=w;return r.jsx(x.Form.Item,{...o,label:g,name:R,required:c,rules:i,tooltip:P,help:u,getValueFromEvent:T=>typeof T=="object"?T.toHexString():T,children:r.jsx(x.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:j,disabled:!h,...w.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=_;exports.default=oe;
|