@kingteza/crud-component 1.45.0 → 1.46.1
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.es.js +79 -75
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +103 -101
- package/dist/crud/FileCrudField.cjs.js +1 -1
- package/dist/crud/FileCrudField.d.ts +2 -1
- package/dist/crud/FileCrudField.es.js +133 -132
- package/dist/crud/ImageCrudField.cjs.js +1 -1
- package/dist/crud/ImageCrudField.d.ts +1 -0
- package/dist/crud/ImageCrudField.es.js +114 -103
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var U=Object.create;var
|
|
2
|
-
`)&&
|
|
1
|
+
"use strict";var U=Object.create;var L=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var Y=(i,n,l,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of $(n))!J.call(i,c)&&c!==l&&L(i,c,{get:()=>n[c],enumerable:!(u=W(n,c))||u.enumerable});return i};var P=(i,n,l)=>(l=i!=null?U(K(i)):{},Y(n||!i||!i.__esModule?L(l,"default",{value:i,enumerable:!0}):l,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react/jsx-runtime"),k=require("antd"),s=require("react"),Z=require("../../util/ValidationUtil.cjs.js"),ee=async()=>{const{Quill:i}=await import("react-quill-new"),n=i.import("blots/block");n.tagName="p",i.register(n);const l=i.prototype.getSemanticHTML;i.prototype.getSemanticHTML=function(...u){return l.apply(this,u).replaceAll(" "," ").replaceAll(" "," ")}},te=22,ne=8,ie=(i,n)=>{const l={};return i!=null&&i>0&&(l["--rich-editor-min-height"]=`${i*te+ne}px`),n!=null&&n>0&&(l.width=`min(100%, ${n}ch)`),l},re=({formLayoutProps:i,name:n,label:l,required:u,rules:c=[],disabled:m,help:_,rows:v,cols:q})=>{const d=k.Form.useFormInstance(),[T,g]=s.useState(""),[b,j]=s.useState(!1),[M,w]=s.useState(null),S=s.useRef(!1),r=" ";s.useEffect(()=>{j(!0)},[]),s.useEffect(()=>{if(!b)return;let t=!1;return(async()=>{await ee();const{default:e}=await import("react-quill-new");t||w(()=>e)})(),()=>{t=!0}},[b]);const f=t=>{if(!t)return"";if(typeof t=="string")return t;try{return String(t)}catch{return""}},N=()=>function(t){const e=this.quill,a=e.getSelection(!0);if(a){const p=a.index,y=a.index+a.length,z=e.getText(),h=[];for(let o=p;o<=y;o++)(o===0||z[o-1]===`
|
|
2
|
+
`)&&h.push(o);if(h.length===0&&h.push(p),t>0){let o=0;h.forEach(x=>{e.insertText(x+o,r),o+=r.length}),e.setSelection(p+r.length,y+h.length*r.length)}else{let o=0;h.forEach(O=>{const C=O-o;e.getText(C,r.length)===r&&(e.deleteText(C,r.length),o+=r.length)});const x=Math.max(0,p-r.length),D=Math.max(x,y-o);e.setSelection(x,D)}}},Q=()=>function(){const t=this.quill,e=t.getSelection(!0);return e?(t.insertText(e.index,r),t.setSelection(e.index+r.length),!1):!0},X=()=>function(){const t=this.quill,e=t.getSelection(!0);return e&&e.index>=r.length&&t.getText(e.index-r.length,r.length)===r?(t.deleteText(e.index-r.length,r.length),t.setSelection(e.index-r.length),!1):!0},R=s.useMemo(()=>{const t=N(),e=Q(),a=X();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}}}}},[]),H=s.useMemo(()=>["bold","italic","underline","strike","blockquote","list","bullet","link"],[]);s.useEffect(()=>{const t=d.getFieldValue(n),e=f(t);e&&e!=="<p></p>"&&e!=="<p><br></p>"&&e!=="<div></div>"&&g(e)},[d,n]);const A=k.Form.useWatch(n,d);s.useEffect(()=>{if(S.current)return;const t=f(A),e=f(T);t!==e&&g(!t||t==="<p></p>"||t==="<p><br></p>"||t==="<div></div>"?"":t)},[A]);const F=s.useCallback(t=>{const e=f(t);S.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;d.setFieldValue(n,a),setTimeout(()=>{S.current=!1},0),d.validateFields([n]).catch(()=>{})},[d,n]),B=s.useMemo(()=>u?[...c,...Z.required(l??"")]:c,[u,c,l]),I=s.useMemo(()=>f(T)||"",[T]),E=s.useMemo(()=>ie(v,q),[v,q]),G=s.useMemo(()=>({readOnly:!!m,value:String(I||""),onChange:F,theme:"snow",className:"rich-text-editor",style:E,modules:R,formats:H}),[m,I,F,R,H,E]);return V.jsx(k.Form.Item,{help:_,name:n,label:l,rules:B,...i,children:b&&M?V.jsx(M,{...G}):V.jsx("div",{className:"rich-text-editor rich-text-editor--loading",style:E,children:"Loading editor..."})})};exports.RichTextEditor=re;
|
|
@@ -1,40 +1,44 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Form as
|
|
3
|
-
import { useState as
|
|
1
|
+
import { jsx as k } from "react/jsx-runtime";
|
|
2
|
+
import { Form as v } from "antd";
|
|
3
|
+
import { useState as H, useRef as $, useEffect as x, useMemo as u, useCallback as j } from "react";
|
|
4
4
|
import K from "../../util/ValidationUtil.es.js";
|
|
5
5
|
const O = async () => {
|
|
6
|
-
const { Quill:
|
|
7
|
-
i.tagName = "
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const { Quill: l } = await import("react-quill-new"), i = l.import("blots/block");
|
|
7
|
+
i.tagName = "p", l.register(i);
|
|
8
|
+
const o = l.prototype.getSemanticHTML;
|
|
9
|
+
l.prototype.getSemanticHTML = function(...h) {
|
|
10
|
+
return o.apply(this, h).replaceAll(" ", " ").replaceAll(" ", " ");
|
|
11
|
+
};
|
|
12
|
+
}, J = 22, Y = 8, Z = (l, i) => {
|
|
13
|
+
const o = {};
|
|
14
|
+
return l != null && l > 0 && (o["--rich-editor-min-height"] = `${l * J + Y}px`), i != null && i > 0 && (o.width = `min(100%, ${i}ch)`), o;
|
|
11
15
|
}, lt = ({
|
|
12
|
-
formLayoutProps:
|
|
16
|
+
formLayoutProps: l,
|
|
13
17
|
name: i,
|
|
14
|
-
label:
|
|
15
|
-
required:
|
|
16
|
-
rules:
|
|
17
|
-
disabled:
|
|
18
|
-
help:
|
|
19
|
-
rows:
|
|
20
|
-
cols:
|
|
18
|
+
label: o,
|
|
19
|
+
required: h,
|
|
20
|
+
rules: f = [],
|
|
21
|
+
disabled: T,
|
|
22
|
+
help: F,
|
|
23
|
+
rows: q,
|
|
24
|
+
cols: R
|
|
21
25
|
}) => {
|
|
22
|
-
const c =
|
|
26
|
+
const c = v.useFormInstance(), [b, g] = H(""), [S, N] = H(!1), [A, P] = H(
|
|
23
27
|
null
|
|
24
|
-
),
|
|
28
|
+
), y = $(!1), n = " ";
|
|
25
29
|
x(() => {
|
|
26
|
-
|
|
30
|
+
N(!0);
|
|
27
31
|
}, []), x(() => {
|
|
28
|
-
if (!
|
|
32
|
+
if (!S) return;
|
|
29
33
|
let e = !1;
|
|
30
34
|
return (async () => {
|
|
31
35
|
await O();
|
|
32
36
|
const { default: t } = await import("react-quill-new");
|
|
33
|
-
e ||
|
|
37
|
+
e || P(() => t);
|
|
34
38
|
})(), () => {
|
|
35
39
|
e = !0;
|
|
36
40
|
};
|
|
37
|
-
}, [
|
|
41
|
+
}, [S]);
|
|
38
42
|
const d = (e) => {
|
|
39
43
|
if (!e) return "";
|
|
40
44
|
if (typeof e == "string") return e;
|
|
@@ -43,35 +47,35 @@ const O = async () => {
|
|
|
43
47
|
} catch {
|
|
44
48
|
return "";
|
|
45
49
|
}
|
|
46
|
-
},
|
|
47
|
-
const t = this.quill,
|
|
48
|
-
if (
|
|
49
|
-
const
|
|
50
|
-
for (let r =
|
|
51
|
-
(r === 0 ||
|
|
50
|
+
}, Q = () => function(e) {
|
|
51
|
+
const t = this.quill, s = t.getSelection(!0);
|
|
52
|
+
if (s) {
|
|
53
|
+
const p = s.index, V = s.index + s.length, D = t.getText(), a = [];
|
|
54
|
+
for (let r = p; r <= V; r++)
|
|
55
|
+
(r === 0 || D[r - 1] === `
|
|
52
56
|
`) && a.push(r);
|
|
53
|
-
if (a.length === 0 && a.push(
|
|
57
|
+
if (a.length === 0 && a.push(p), e > 0) {
|
|
54
58
|
let r = 0;
|
|
55
|
-
a.forEach((
|
|
56
|
-
t.insertText(
|
|
59
|
+
a.forEach((m) => {
|
|
60
|
+
t.insertText(m + r, n), r += n.length;
|
|
57
61
|
}), t.setSelection(
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
p + n.length,
|
|
63
|
+
V + a.length * n.length
|
|
60
64
|
);
|
|
61
65
|
} else {
|
|
62
66
|
let r = 0;
|
|
63
67
|
a.forEach((W) => {
|
|
64
|
-
const
|
|
65
|
-
t.getText(
|
|
68
|
+
const w = W - r;
|
|
69
|
+
t.getText(w, n.length) === n && (t.deleteText(w, n.length), r += n.length);
|
|
66
70
|
});
|
|
67
|
-
const
|
|
68
|
-
t.setSelection(
|
|
71
|
+
const m = Math.max(0, p - n.length), U = Math.max(m, V - r);
|
|
72
|
+
t.setSelection(m, U);
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
|
-
},
|
|
75
|
+
}, X = () => function() {
|
|
72
76
|
const e = this.quill, t = e.getSelection(!0);
|
|
73
77
|
return t ? (e.insertText(t.index, n), e.setSelection(t.index + n.length), !1) : !0;
|
|
74
|
-
},
|
|
78
|
+
}, B = () => function() {
|
|
75
79
|
const e = this.quill, t = e.getSelection(!0);
|
|
76
80
|
return t && t.index >= n.length && e.getText(
|
|
77
81
|
t.index - n.length,
|
|
@@ -80,8 +84,8 @@ const O = async () => {
|
|
|
80
84
|
t.index - n.length,
|
|
81
85
|
n.length
|
|
82
86
|
), e.setSelection(t.index - n.length), !1) : !0;
|
|
83
|
-
},
|
|
84
|
-
const e =
|
|
87
|
+
}, I = u(() => {
|
|
88
|
+
const e = Q(), t = X(), s = B();
|
|
85
89
|
return {
|
|
86
90
|
toolbar: {
|
|
87
91
|
container: [
|
|
@@ -104,12 +108,12 @@ const O = async () => {
|
|
|
104
108
|
"shift-tab": {
|
|
105
109
|
key: "Tab",
|
|
106
110
|
shiftKey: !0,
|
|
107
|
-
handler:
|
|
111
|
+
handler: s
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
};
|
|
112
|
-
}, []),
|
|
116
|
+
}, []), M = u(
|
|
113
117
|
() => [
|
|
114
118
|
"bold",
|
|
115
119
|
"italic",
|
|
@@ -124,58 +128,58 @@ const O = async () => {
|
|
|
124
128
|
);
|
|
125
129
|
x(() => {
|
|
126
130
|
const e = c.getFieldValue(i), t = d(e);
|
|
127
|
-
t && t !== "<p></p>" && t !== "<p><br></p>" && t !== "<div></div>" &&
|
|
131
|
+
t && t !== "<p></p>" && t !== "<p><br></p>" && t !== "<div></div>" && g(t);
|
|
128
132
|
}, [c, i]);
|
|
129
|
-
const
|
|
133
|
+
const C = v.useWatch(i, c);
|
|
130
134
|
x(() => {
|
|
131
|
-
if (
|
|
135
|
+
if (y.current)
|
|
132
136
|
return;
|
|
133
|
-
const e = d(
|
|
134
|
-
e !== t &&
|
|
135
|
-
}, [
|
|
136
|
-
const
|
|
137
|
+
const e = d(C), t = d(b);
|
|
138
|
+
e !== t && g(!e || e === "<p></p>" || e === "<p><br></p>" || e === "<div></div>" ? "" : e);
|
|
139
|
+
}, [C]);
|
|
140
|
+
const L = j(
|
|
137
141
|
(e) => {
|
|
138
142
|
const t = d(e);
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
c.setFieldValue(i,
|
|
142
|
-
|
|
143
|
+
y.current = !0, g(t);
|
|
144
|
+
const s = !t || t === "<p></p>" || t.trim() === "<p><br></p>" || t === "<div></div>" || t.trim() === "<div></div>" ? void 0 : t;
|
|
145
|
+
c.setFieldValue(i, s), setTimeout(() => {
|
|
146
|
+
y.current = !1;
|
|
143
147
|
}, 0), c.validateFields([i]).catch(() => {
|
|
144
148
|
});
|
|
145
149
|
},
|
|
146
150
|
[c, i]
|
|
151
|
+
), G = u(
|
|
152
|
+
() => h ? [...f, ...K.required(o ?? "")] : f,
|
|
153
|
+
[h, f, o]
|
|
154
|
+
), _ = u(() => d(b) || "", [b]), E = u(
|
|
155
|
+
() => Z(q, R),
|
|
156
|
+
[q, R]
|
|
147
157
|
), z = u(
|
|
148
|
-
() => y ? [...p, ...K.required(s ?? "")] : p,
|
|
149
|
-
[y, p, s]
|
|
150
|
-
), F = u(() => d(m) || "", [m]), S = u(
|
|
151
|
-
() => Z(R, H),
|
|
152
|
-
[R, H]
|
|
153
|
-
), D = u(
|
|
154
158
|
() => ({
|
|
155
|
-
readOnly: !!
|
|
156
|
-
value: String(
|
|
157
|
-
onChange:
|
|
159
|
+
readOnly: !!T,
|
|
160
|
+
value: String(_ || ""),
|
|
161
|
+
onChange: L,
|
|
158
162
|
theme: "snow",
|
|
159
163
|
className: "rich-text-editor",
|
|
160
|
-
style:
|
|
161
|
-
modules:
|
|
162
|
-
formats:
|
|
164
|
+
style: E,
|
|
165
|
+
modules: I,
|
|
166
|
+
formats: M
|
|
163
167
|
}),
|
|
164
|
-
[
|
|
168
|
+
[T, _, L, I, M, E]
|
|
165
169
|
);
|
|
166
|
-
return /* @__PURE__ */
|
|
167
|
-
|
|
170
|
+
return /* @__PURE__ */ k(
|
|
171
|
+
v.Item,
|
|
168
172
|
{
|
|
169
|
-
help:
|
|
173
|
+
help: F,
|
|
170
174
|
name: i,
|
|
171
|
-
label:
|
|
172
|
-
rules:
|
|
173
|
-
...
|
|
174
|
-
children:
|
|
175
|
+
label: o,
|
|
176
|
+
rules: G,
|
|
177
|
+
...l,
|
|
178
|
+
children: S && A ? /* @__PURE__ */ k(A, { ...z }) : /* @__PURE__ */ k(
|
|
175
179
|
"div",
|
|
176
180
|
{
|
|
177
181
|
className: "rich-text-editor rich-text-editor--loading",
|
|
178
|
-
style:
|
|
182
|
+
style: E,
|
|
179
183
|
children: "Loading editor..."
|
|
180
184
|
}
|
|
181
185
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),g=require("antd"),T=require("react"),Y=require("react-highlight-words"),Z=require("../locale/index.cjs.js"),ee=require("./FileCrudField.cjs.js"),te=require("./ImageCrudField.cjs.js"),re=require("../common/check-box/CheckBox.cjs.js"),ne=require("../common/date-picker/DatePicker.cjs.js"),ae=require("../common/date-picker/TimePicker.cjs.js"),D=require("../common/select/SelectComponent.cjs.js"),oe=require("../common/text-field/NumberField.cjs.js"),le=require("../common/text-field/PhoneNumberField.cjs.js"),se=require("../common/text-field/TextField.cjs.js"),ie=require("../common/tooltip/TooltipComponent.cjs.js"),de=require("./CrudTextAreaComponent.cjs.js"),_=require("../util/CrudUtil.cjs.js"),E=require("../context/CrudSearchContext.cjs.js");function ce(F){const{label:s,name:d,type:c,required:h,hidden:O,rules:b=[],updatable:m=!0,readonly:y=!1,fieldClassName:f,customFormFieldRender:k,fieldTooltip:S,fieldHelper:p,formLayoutProps:q,...t}=F,l=g.Form.useFormInstance();T.useEffect(()=>{if(c==="select"){const{items:a=[],onSearch:o,searchOnType:u}=t;!(a!=null&&a.length)&&!u&&(o==null||o(void 0,l,t==null?void 0:t.updatingValue))}},[l,t,c,t==null?void 0:t.updatingValue]);const R=E.useCrudSearchContext(),x=T.useCallback((a,o)=>{R&&R.search(),!y&&o&&o(a,l)},[R,y,l]);if(y||O)return e.jsx(e.Fragment,{});if(k)return k(l,F);switch(c){case"text":case"email":case"password":{const{maxLength:a,onChange:o,placeholder:u,addonAfter:v,addonBefore:i}=t;return e.jsx(se.default,{...q,maxLength:a,placeholder:u,disabled:!m,rules:b,required:h,onChange:o?N=>o(N,l):void 0,type:c,name:d,tooltip:S,label:s,className:f,autoComplete:"new-password",addonAfter:v,addonBefore:i,help:p})}case"phone":{const{onChange:a,placeholder:o,addonAfter:u,addonBefore:v}=t;return e.jsx(le,{...t,...q,placeholder:o,disabled:!m,rules:b,required:h,onChange:a?i=>a(i,l):void 0,type:c,name:d,tooltip:S,label:s,className:f,autoComplete:"new-password",addonAfter:u,addonBefore:v,help:p})}case"number":{const{onChange:a,placeholder:o,allowMinus:u,min:v,max:i,addonAfter:N,addonBefore:w,int:P,step:n,changeOnWheel:j=!1}=t;return e.jsx(oe,{...q,step:n,changeOnWheel:j,placeholder:o,disabled:!m,moneyField:!!t.formatted,type:c,onChange:a?H=>a(H,l):void 0,rules:b,autoComplete:"false",required:h,tooltip:S,className:f,min:u?null:v,max:i,addonAfter:N,addonBefore:w,name:d,label:s,help:p,isInt:P})}case"date":{const{range:a,disableToday:o,disabledFutureDays:u,disabledPastDays:v,onChange:i,placeholder:N,format:w}=t;return e.jsx(ne,{...q,placeholder:N,required:h,disabled:!m,type:c,format:w,tooltip:S,range:a,name:d,label:s,onChange:x,className:f,disableToday:o,disabledFutureDays:u,disabledPastDays:v,help:p})}case"time":{const{range:a=!1,disableCurrent:o,disabledFuture:u,disabledPast:v,onChange:i,use12Hours:N,format:w,placeholder:P}=t;return e.jsx(ae,{...q,placeholder:P,required:h,format:w,disabled:!m,type:c,tooltip:S,range:a,use12Hours:N,name:d,label:s,onChange:x,className:f,disableCurrent:o,disabledFuture:u,disabledPast:v,help:p})}case"textarea":return e.jsx(de,{...F});case"image":return e.jsx(te.default,{...t,required:h,name:d,label:s,rules:b,fieldHelper:p,fieldClassName:f,onRemoved:t.onRemoved,onUploadComplete:t.onUploadComplete,onUploading:t.onUploading,provider:t.provider});case"file":return e.jsx(ee.default,{...t,required:h,name:d,label:s,rules:b,fieldHelper:p,fieldClassName:f,onRemoved:t.onRemoved,onUploadComplete:t.onUploadComplete,onUploading:t.onUploading,provider:t.provider});case"select":return e.jsx($,{...t,required:h,name:d,label:s,rules:b,fieldClassName:f,form:l,help:p,updatable:m,readonly:y,fieldTooltip:S,fieldHelper:p});case"enum":return e.jsx(W,{...F});case"checkbox":{const{onChange:a,switch:o}=t;return e.jsx(re,{...q,className:f,rules:b,onChange:x,label:s,tooltip:S,disabled:!m,name:d,help:p,switch:o})}case"color":return e.jsx(z,{...t,type:"color",required:h,name:d,label:s,rules:b,fieldClassName:f,updatable:m,readonly:y,fieldTooltip:S,fieldHelper:p});default:return e.jsx(e.Fragment,{children:`${c} Not Implemented`})}}function W(F){const s=g.Form.useFormInstance(),{label:d,name:c,type:h,required:O,hidden:b,rules:m=[],updatable:y=!0,readonly:f=!1,fieldClassName:k,customFormFieldRender:S,fieldTooltip:p,fieldHelper:q,formLayoutProps:t,...l}=F,{t:R}=Z.useTranslationLibNoNS(),{enum:x,translation:a,onChange:o,onSearch:u,multiple:v,tagRender:i}=l,N=Array.isArray(x)?x:Object.keys(x),w=E.useCrudSearchContext(),P=T.useCallback(n=>{w&&w.search(),!f&&o&&o(n,s)},[w,f,o,s]);return"radio"in l&&l.radio?e.jsx(g.Form.Item,{...l,...t,name:c,required:O,tooltip:p,rules:m,label:d,className:["w-100",k].join(" "),help:q,children:e.jsx(g.Radio.Group,{...l,onChange:n=>{var j;return P((j=n==null?void 0:n.target)==null?void 0:j.value)},children:N.map(n=>e.jsx(g.Radio,{disabled:!y,value:n,children:a?R(a[n]):n},n))})}):"checkbox"in l&&l.checkbox?e.jsx(g.Form.Item,{...l,...t,name:c,required:O,tooltip:p,rules:m,label:d,className:["w-100",k].join(" "),help:q,children:e.jsx(g.Checkbox.Group,{className:"w-100",onChange:P,children:N.map(n=>{const j=e.jsx(g.Checkbox,{disabled:!y,value:n,children:a?R(a[n]):n},n);return"checkboxGrid"in l&&l.checkboxGrid?e.jsx(g.Col,{...l.checkboxGrid,children:j}):j})})}):e.jsx(D,{...l,...t,notSearch:!0,tagRender:typeof i=="function"?i:i?n=>{const{value:j,label:H}=n,I=i[j];return I?e.jsx(g.Tag,{color:I.color,children:H}):e.jsx(g.Tag,{children:H})}:void 0,onChange:P,className:["w-100",k].join(" "),name:c,items:N,required:O,tooltip:p,rules:m,label:d,help:q,disabled:!y,onSearch:u?n=>u(n,s):void 0,allowClear:!0,mode:v?"multiple":void 0,showLoadingInEmptyIndicator:!0,itemBuilder:n=>e.jsx(g.Select.Option,{value:n,children:a?R(a[n]):n},n)})}function $(F){const{items:s=[],loading:d,searchOnType:c,onSearch:h,multiple:O,onChange:b,highlightSearch:m,required:y,fieldClassName:f,rules:k,fieldTooltip:S,updatable:p,label:q,name:t,tagRender:l,updatingValue:R,onSet:x,placeholder:a,allowClear:o=!0,selectOptionRender:u,formLayoutProps:v}=F,i=F.form,[N,w]=T.useState(""),P=T.useMemo(()=>_.getRealName(t),[t]),n=T.useMemo(()=>_.getRealName(t,"upsertFieldName"),[t]),j=g.Form.useWatch(P,i),[H,I]=T.useState(!0);T.useEffect(()=>{x&&H&&j&&(x==null||x(j,s,i),I(!1))},[H,i,s,P,x,j]),T.useEffect(()=>{j&&I(!0)},[j]);const J=T.useCallback(async r=>{w(r),c&&(h==null||h(r,i,R))},[i,h,c,R]),K=T.useCallback(r=>u?u(r):r.value,[u]),L=E.useCrudSearchContext(),Q=T.useCallback(r=>{L&&L.search(),b&&(w(""),b(r,i))},[L,b,i]);return e.jsx(D,{...F,...v,showLoadingInEmptyIndicator:!0,maxTagCount:"responsive",maxTagPlaceholder:r=>e.jsxs(ie,{title:e.jsx(e.Fragment,{children:r.map(C=>e.jsxs(e.Fragment,{children:[C.label," ",e.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:a,onSelect:r=>{x==null||x(r==null?void 0:r.key,s,i)},onChange:Q,mode:O?"multiple":void 0,className:["w-100",f].join(" "),name:n,items:s,required:y,tooltip:S,tagRender:l,rules:k,disabled:!p,label:q,allowClear:o,onSearch:J,loading:d,filterOption:m?(r,C)=>{var U,A,B;try{const G=r.toLowerCase().split(/\s+/),V=((typeof(C==null?void 0:C.children)=="string"?C==null?void 0:C.children:(A=(U=C==null?void 0:C.children)==null?void 0:U.props)==null?void 0:A.textToHighlight)??"").toLowerCase(),X=(((B=C==null?void 0:C.value)==null?void 0:B.toString())??"").toLowerCase();return G.every(M=>V.indexOf(M)>=0||X.indexOf(M)>=0)}catch{return!0}}:void 0,itemBuilder:m?r=>{const C=r.value?String(r.value):void 0;return e.jsx(g.Select.Option,{value:r.key,title:C,disabled:r.disabled,children:e.jsx(Y,{highlightClassName:"highlight-text",searchWords:(N??"").split(" "),autoEscape:!0,textToHighlight:C??""})},r.key)}:r=>e.jsx(g.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:K(r)},r.key)})}function z(F){const{formLayoutProps:s,required:d,fieldClassName:c,rules:h,fieldTooltip:O,updatable:b,label:m,name:y,fieldHelper:f}=F;return e.jsx(g.Form.Item,{...s,label:m,name:y,required:d,rules:h,tooltip:O,help:f,getValueFromEvent:k=>typeof k=="object"?k.toHexString():k,children:e.jsx(g.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:c,disabled:!b,...F.innerProps})})}exports.ColorCrudFieldComponent=z;exports.EnumCrudFieldComponent=W;exports.SelectCrudFieldComponent=$;exports.default=ce;
|