@kingteza/crud-component 1.33.0 → 1.34.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.cjs.js +2 -2
- package/dist/common/rich/index.d.ts +1 -1
- package/dist/common/rich/index.es.js +119 -75
- package/dist/crud/CrudComponent.d.ts +1 -0
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +92 -91
- package/dist/crud/CrudTextAreaComponent.cjs.js +1 -1
- package/dist/crud/CrudTextAreaComponent.d.ts +2 -1
- package/dist/crud/CrudTextAreaComponent.es.js +19 -17
- package/dist/style.css +4 -3
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)&&
|
|
1
|
+
"use strict";var z=Object.create;var H=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var X=(r,n,o,h)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of D(n))!J.call(r,c)&&c!==o&&H(r,c,{get:()=>n[c],enumerable:!(h=A(n,c))||h.enumerable});return r};var j=(r,n,o)=>(o=r!=null?z(G(r)):{},X(n||!r||!r.__esModule?H(o,"default",{value:r,enumerable:!0}):o,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),k=require("antd"),s=require("react"),Y=require("../../util/ValidationUtil.cjs.js"),Z=async()=>{const{Quill:r}=await import("react-quill-new"),n=r.import("blots/block");n.tagName="div",r.register(n)},_=({formLayoutProps:r,name:n,label:o,required:h,rules:c=[],disabled:V,help:C})=>{const u=k.Form.useFormInstance(),[b,g]=s.useState(""),[p,Q]=s.useState(!1),[q,B]=s.useState(null),T=s.useRef(!1),i=" ";s.useEffect(()=>{Q(!0)},[]),s.useEffect(()=>{if(!p)return;let t=!1;return(async()=>{await Z();const{default:e}=await import("react-quill-new");t||B(()=>e)})(),()=>{t=!0}},[p]);const f=t=>{if(!t)return"";if(typeof t=="string")return t;try{return String(t)}catch{return""}},I=()=>function(t){const e=this.quill,a=e.getSelection(!0);if(a){const x=a.index,S=a.index+a.length,W=e.getText(),d=[];for(let l=x;l<=S;l++)(l===0||W[l-1]===`
|
|
2
|
+
`)&&d.push(l);if(d.length===0&&d.push(x),t>0){let l=0;d.forEach(m=>{e.insertText(m+l,i),l+=i.length}),e.setSelection(x+i.length,S+d.length*i.length)}else{let l=0;d.forEach(L=>{const F=L-l;e.getText(F,i.length)===i&&(e.deleteText(F,i.length),l+=i.length)});const m=Math.max(0,x-i.length),K=Math.max(m,S-l);e.setSelection(m,K)}}},N=()=>function(){const t=this.quill,e=t.getSelection(!0);return e?(t.insertText(e.index,i),t.setSelection(e.index+i.length),!1):!0},P=()=>function(){const t=this.quill,e=t.getSelection(!0);return e&&e.index>=i.length&&t.getText(e.index-i.length,i.length)===i?(t.deleteText(e.index-i.length,i.length),t.setSelection(e.index-i.length),!1):!0},E=s.useMemo(()=>{const t=I(),e=N(),a=P();return{toolbar:{container:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],[{indent:"-1"},{indent:"+1"}],["link"],["clean"]],handlers:{indent:t}},keyboard:{bindings:{tab:{key:"Tab",handler:e},"shift-tab":{key:"Tab",shiftKey:!0,handler:a}}}}},[]),y=s.useMemo(()=>["bold","italic","underline","strike","blockquote","list","bullet","link"],[]);s.useEffect(()=>{const t=u.getFieldValue(n),e=f(t);e&&e!=="<p></p>"&&e!=="<p><br></p>"&&e!=="<div></div>"&&g(e)},[u,n]);const M=k.Form.useWatch(n,u);s.useEffect(()=>{if(T.current)return;const t=f(M),e=f(b);t!==e&&g(!t||t==="<p></p>"||t==="<p><br></p>"||t==="<div></div>"?"":t)},[M]);const R=s.useCallback(t=>{const e=f(t);T.current=!0,g(e);const a=!e||e==="<p></p>"||e.trim()==="<p><br></p>"||e==="<div></div>"||e.trim()==="<div></div>"?void 0:e;u.setFieldValue(n,a),setTimeout(()=>{T.current=!1},0),u.validateFields([n]).catch(()=>{})},[u,n]),O=s.useMemo(()=>h?[...c,...Y.required(o??"")]:c,[h,c,o]),w=s.useMemo(()=>f(b)||"",[b]),U=s.useMemo(()=>({readOnly:!!V,value:String(w||""),onChange:R,theme:"snow",className:"rich-text-editor",modules:E,formats:y}),[V,w,R,E,y]);return v.jsx(k.Form.Item,{help:C,name:n,label:o,rules:O,...r,children:p&&q?v.jsx(q,{...U}):v.jsx("div",{className:"rich-text-editor rich-text-editor--loading",children:"Loading editor..."})})};exports.RichTextEditor=_;
|
|
@@ -9,6 +9,6 @@ export interface RichTextEditorProps {
|
|
|
9
9
|
required?: boolean;
|
|
10
10
|
rules?: Rule[];
|
|
11
11
|
disabled?: boolean;
|
|
12
|
-
formLayoutProps?: Pick<FormItemProps, "layout" |
|
|
12
|
+
formLayoutProps?: Pick<FormItemProps, "layout" | "labelCol" | "wrapperCol">;
|
|
13
13
|
}
|
|
14
14
|
export declare const RichTextEditor: FC<RichTextEditorProps>;
|
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Form as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
formLayoutProps:
|
|
1
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
2
|
+
import { Form as V } from "antd";
|
|
3
|
+
import { useState as S, useRef as z, useEffect as g, useMemo as a, useCallback as A } from "react";
|
|
4
|
+
import D from "../../util/ValidationUtil.es.js";
|
|
5
|
+
const G = async () => {
|
|
6
|
+
const { Quill: u } = await import("react-quill-new"), r = u.import("blots/block");
|
|
7
|
+
r.tagName = "div", u.register(r);
|
|
8
|
+
}, $ = ({
|
|
9
|
+
formLayoutProps: u,
|
|
10
10
|
name: r,
|
|
11
|
-
label:
|
|
12
|
-
required:
|
|
13
|
-
rules:
|
|
14
|
-
disabled:
|
|
15
|
-
help:
|
|
11
|
+
label: x,
|
|
12
|
+
required: q,
|
|
13
|
+
rules: p = [],
|
|
14
|
+
disabled: y,
|
|
15
|
+
help: M
|
|
16
16
|
}) => {
|
|
17
|
-
const
|
|
17
|
+
const o = V.useFormInstance(), [m, d] = S(""), [b, B] = S(!1), [E, I] = S(
|
|
18
|
+
null
|
|
19
|
+
), T = z(!1), n = " ";
|
|
20
|
+
g(() => {
|
|
21
|
+
B(!0);
|
|
22
|
+
}, []), g(() => {
|
|
23
|
+
if (!b) return;
|
|
24
|
+
let e = !1;
|
|
25
|
+
return (async () => {
|
|
26
|
+
await G();
|
|
27
|
+
const { default: t } = await import("react-quill-new");
|
|
28
|
+
e || I(() => t);
|
|
29
|
+
})(), () => {
|
|
30
|
+
e = !0;
|
|
31
|
+
};
|
|
32
|
+
}, [b]);
|
|
33
|
+
const c = (e) => {
|
|
18
34
|
if (!e) return "";
|
|
19
35
|
if (typeof e == "string") return e;
|
|
20
36
|
try {
|
|
@@ -22,36 +38,45 @@ const A = W.lazy(async () => {
|
|
|
22
38
|
} catch {
|
|
23
39
|
return "";
|
|
24
40
|
}
|
|
25
|
-
},
|
|
41
|
+
}, N = () => function(e) {
|
|
26
42
|
const t = this.quill, l = t.getSelection(!0);
|
|
27
43
|
if (l) {
|
|
28
|
-
const
|
|
29
|
-
for (let i =
|
|
30
|
-
(i === 0 ||
|
|
31
|
-
`) &&
|
|
32
|
-
if (
|
|
44
|
+
const h = l.index, k = l.index + l.length, K = t.getText(), s = [];
|
|
45
|
+
for (let i = h; i <= k; i++)
|
|
46
|
+
(i === 0 || K[i - 1] === `
|
|
47
|
+
`) && s.push(i);
|
|
48
|
+
if (s.length === 0 && s.push(h), e > 0) {
|
|
33
49
|
let i = 0;
|
|
34
|
-
|
|
35
|
-
t.insertText(
|
|
36
|
-
}), t.setSelection(
|
|
50
|
+
s.forEach((f) => {
|
|
51
|
+
t.insertText(f + i, n), i += n.length;
|
|
52
|
+
}), t.setSelection(
|
|
53
|
+
h + n.length,
|
|
54
|
+
k + s.length * n.length
|
|
55
|
+
);
|
|
37
56
|
} else {
|
|
38
57
|
let i = 0;
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
t.getText(
|
|
58
|
+
s.forEach((O) => {
|
|
59
|
+
const Q = O - i;
|
|
60
|
+
t.getText(Q, n.length) === n && (t.deleteText(Q, n.length), i += n.length);
|
|
42
61
|
});
|
|
43
|
-
const
|
|
44
|
-
t.setSelection(
|
|
62
|
+
const f = Math.max(0, h - n.length), L = Math.max(f, k - i);
|
|
63
|
+
t.setSelection(f, L);
|
|
45
64
|
}
|
|
46
65
|
}
|
|
47
|
-
},
|
|
66
|
+
}, P = () => function() {
|
|
48
67
|
const e = this.quill, t = e.getSelection(!0);
|
|
49
68
|
return t ? (e.insertText(t.index, n), e.setSelection(t.index + n.length), !1) : !0;
|
|
50
|
-
},
|
|
69
|
+
}, U = () => function() {
|
|
51
70
|
const e = this.quill, t = e.getSelection(!0);
|
|
52
|
-
return t && t.index >= n.length && e.getText(
|
|
53
|
-
|
|
54
|
-
|
|
71
|
+
return t && t.index >= n.length && e.getText(
|
|
72
|
+
t.index - n.length,
|
|
73
|
+
n.length
|
|
74
|
+
) === n ? (e.deleteText(
|
|
75
|
+
t.index - n.length,
|
|
76
|
+
n.length
|
|
77
|
+
), e.setSelection(t.index - n.length), !1) : !0;
|
|
78
|
+
}, w = a(() => {
|
|
79
|
+
const e = N(), t = P(), l = U();
|
|
55
80
|
return {
|
|
56
81
|
toolbar: {
|
|
57
82
|
container: [
|
|
@@ -79,49 +104,68 @@ const A = W.lazy(async () => {
|
|
|
79
104
|
}
|
|
80
105
|
}
|
|
81
106
|
};
|
|
82
|
-
}, []),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
}, []), H = a(
|
|
108
|
+
() => [
|
|
109
|
+
"bold",
|
|
110
|
+
"italic",
|
|
111
|
+
"underline",
|
|
112
|
+
"strike",
|
|
113
|
+
"blockquote",
|
|
114
|
+
"list",
|
|
115
|
+
"bullet",
|
|
116
|
+
"link"
|
|
117
|
+
],
|
|
118
|
+
[]
|
|
119
|
+
);
|
|
120
|
+
g(() => {
|
|
121
|
+
const e = o.getFieldValue(r), t = c(e);
|
|
122
|
+
t && t !== "<p></p>" && t !== "<p><br></p>" && t !== "<div></div>" && d(t);
|
|
123
|
+
}, [o, r]);
|
|
124
|
+
const R = V.useWatch(r, o);
|
|
125
|
+
g(() => {
|
|
98
126
|
if (T.current)
|
|
99
127
|
return;
|
|
100
|
-
const e =
|
|
101
|
-
e !== t &&
|
|
102
|
-
}, [
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
[
|
|
114
|
-
),
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
const e = c(R), t = c(m);
|
|
129
|
+
e !== t && d(!e || e === "<p></p>" || e === "<p><br></p>" || e === "<div></div>" ? "" : e);
|
|
130
|
+
}, [R]);
|
|
131
|
+
const C = A(
|
|
132
|
+
(e) => {
|
|
133
|
+
const t = c(e);
|
|
134
|
+
T.current = !0, d(t);
|
|
135
|
+
const l = !t || t === "<p></p>" || t.trim() === "<p><br></p>" || t === "<div></div>" || t.trim() === "<div></div>" ? void 0 : t;
|
|
136
|
+
o.setFieldValue(r, l), setTimeout(() => {
|
|
137
|
+
T.current = !1;
|
|
138
|
+
}, 0), o.validateFields([r]).catch(() => {
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
[o, r]
|
|
142
|
+
), W = a(
|
|
143
|
+
() => q ? [...p, ...D.required(x ?? "")] : p,
|
|
144
|
+
[q, p, x]
|
|
145
|
+
), F = a(() => c(m) || "", [m]), j = a(
|
|
146
|
+
() => ({
|
|
147
|
+
readOnly: !!y,
|
|
148
|
+
value: String(F || ""),
|
|
149
|
+
onChange: C,
|
|
150
|
+
theme: "snow",
|
|
151
|
+
className: "rich-text-editor",
|
|
152
|
+
modules: w,
|
|
153
|
+
formats: H
|
|
154
|
+
}),
|
|
155
|
+
[y, F, C, w, H]
|
|
156
|
+
);
|
|
157
|
+
return /* @__PURE__ */ v(
|
|
158
|
+
V.Item,
|
|
159
|
+
{
|
|
160
|
+
help: M,
|
|
161
|
+
name: r,
|
|
162
|
+
label: x,
|
|
163
|
+
rules: W,
|
|
164
|
+
...u,
|
|
165
|
+
children: b && E ? /* @__PURE__ */ v(E, { ...j }) : /* @__PURE__ */ v("div", { className: "rich-text-editor rich-text-editor--loading", children: "Loading editor..." })
|
|
166
|
+
}
|
|
167
|
+
);
|
|
124
168
|
};
|
|
125
169
|
export {
|
|
126
|
-
|
|
170
|
+
$ as RichTextEditor
|
|
127
171
|
};
|
|
@@ -144,6 +144,7 @@ export interface ObjectCrudField<T> extends InitialCrudField<T>, Copyable<true>
|
|
|
144
144
|
export interface TextBasedFieldProps<T> extends InitialCrudField<T>, AddonFieldProps, Copyable<false> {
|
|
145
145
|
placeholder?: string;
|
|
146
146
|
type: "text" | "time" | "email" | "password";
|
|
147
|
+
maxLength?: number;
|
|
147
148
|
onChange?: (value: string, form: FormInstance<T>) => void;
|
|
148
149
|
}
|
|
149
150
|
export interface PhoneNumberFieldProps<T> extends Omit<TextBasedFieldProps<T>, "type">, PhoneNumberConfigProps {
|
|
@@ -1 +1 @@
|
|
|
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:
|
|
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:d,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{maxLength:a,onChange:n,placeholder:s,addonAfter:p,addonBefore:b}=e;return r.jsx(ae.default,{...y,maxLength:a,placeholder:s,disabled:!g,rules:h,required:d,onChange:n?i=>n(i,C):void 0,type:j,name:c,tooltip:v,label:o,className:u,autoComplete:"new-password",addonAfter:p,addonBefore:b,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:d,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:i,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:d,tooltip:v,className:u,min:s?null:p,max:b,addonAfter:i,addonBefore:N,name:c,label:o,help:f})}case"date":{const{range:a,disableToday:n,disabledFutureDays:s,disabledPastDays:p,onChange:b,placeholder:i,format:N}=e;return r.jsx(Z,{...y,placeholder:i,required:d,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:i,format:N,placeholder:t}=e;return r.jsx(ee,{...y,placeholder:t,required:d,format:N,disabled:!g,type:j,tooltip:v,range:a,use12Hours:i,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:d,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:d,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:d,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:i}=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:d,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:d,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 i=="function"?i:i?t=>{const{value:F,label:O}=t,q=i[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:d,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:d,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:d,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,i=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,i),[H,L]=k.useState(!0);k.useEffect(()=>{a&&H&&q&&(a==null||a(q,o,i),L(!1))},[H,i,o,F,a,q]),k.useEffect(()=>{q&&L(!0)},[q]);const W=k.useCallback(async l=>{t(l),j&&(d==null||d(l,i,S))},[i,d,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,i)},onChange:h?l=>{t(""),h(l,i)}: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 I,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=(I=m==null?void 0:m.children)==null?void 0:I.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:d,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:d,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;
|