@kingteza/crud-component 1.33.0 → 1.34.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.d.ts +3 -1
- package/dist/common/rich/index.es.js +139 -79
- 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 +35 -29
- package/dist/style.css +4 -3
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)&&
|
|
1
|
+
"use strict";var U=Object.create;var P=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var Y=(i,n,s,h)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of $(n))!J.call(i,c)&&c!==s&&P(i,c,{get:()=>n[c],enumerable:!(h=W(n,c))||h.enumerable});return i};var _=(i,n,s)=>(s=i!=null?U(K(i)):{},Y(n||!i||!i.__esModule?P(s,"default",{value:i,enumerable:!0}):s,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),v=require("antd"),l=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="div",i.register(n)},te=22,ne=8,ie=(i,n)=>{const s={};return i!=null&&i>0&&(s["--rich-editor-min-height"]=`${i*te+ne}px`),n!=null&&n>0&&(s.width=`min(100%, ${n}ch)`),s},re=({formLayoutProps:i,name:n,label:s,required:h,rules:c=[],disabled:V,help:j,rows:k,cols:q})=>{const a=v.Form.useFormInstance(),[T,g]=l.useState(""),[b,w]=l.useState(!1),[R,N]=l.useState(null),p=l.useRef(!1),r=" ";l.useEffect(()=>{w(!0)},[]),l.useEffect(()=>{if(!b)return;let t=!1;return(async()=>{await ee();const{default:e}=await import("react-quill-new");t||N(()=>e)})(),()=>{t=!0}},[b]);const f=t=>{if(!t)return"";if(typeof t=="string")return t;try{return String(t)}catch{return""}},Q=()=>function(t){const e=this.quill,u=e.getSelection(!0);if(u){const x=u.index,E=u.index+u.length,D=e.getText(),d=[];for(let o=x;o<=E;o++)(o===0||D[o-1]===`
|
|
2
|
+
`)&&d.push(o);if(d.length===0&&d.push(x),t>0){let o=0;d.forEach(m=>{e.insertText(m+o,r),o+=r.length}),e.setSelection(x+r.length,E+d.length*r.length)}else{let o=0;d.forEach(O=>{const C=O-o;e.getText(C,r.length)===r&&(e.deleteText(C,r.length),o+=r.length)});const m=Math.max(0,x-r.length),G=Math.max(m,E-o);e.setSelection(m,G)}}},X=()=>function(){const t=this.quill,e=t.getSelection(!0);return e?(t.insertText(e.index,r),t.setSelection(e.index+r.length),!1):!0},B=()=>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},M=l.useMemo(()=>{const t=Q(),e=X(),u=B();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:u}}}}},[]),H=l.useMemo(()=>["bold","italic","underline","strike","blockquote","list","bullet","link"],[]);l.useEffect(()=>{const t=a.getFieldValue(n),e=f(t);e&&e!=="<p></p>"&&e!=="<p><br></p>"&&e!=="<div></div>"&&g(e)},[a,n]);const F=v.Form.useWatch(n,a);l.useEffect(()=>{if(p.current)return;const t=f(F),e=f(T);t!==e&&g(!t||t==="<p></p>"||t==="<p><br></p>"||t==="<div></div>"?"":t)},[F]);const I=l.useCallback(t=>{const e=f(t);p.current=!0,g(e);const u=!e||e==="<p></p>"||e.trim()==="<p><br></p>"||e==="<div></div>"||e.trim()==="<div></div>"?void 0:e;a.setFieldValue(n,u),setTimeout(()=>{p.current=!1},0),a.validateFields([n]).catch(()=>{})},[a,n]),L=l.useMemo(()=>h?[...c,...Z.required(s??"")]:c,[h,c,s]),A=l.useMemo(()=>f(T)||"",[T]),S=l.useMemo(()=>ie(k,q),[k,q]),z=l.useMemo(()=>({readOnly:!!V,value:String(A||""),onChange:I,theme:"snow",className:"rich-text-editor",style:S,modules:M,formats:H}),[V,A,I,M,H,S]);return y.jsx(v.Form.Item,{help:j,name:n,label:s,rules:L,...i,children:b&&R?y.jsx(R,{...z}):y.jsx("div",{className:"rich-text-editor rich-text-editor--loading",style:S,children:"Loading editor..."})})};exports.RichTextEditor=re;
|
|
@@ -9,6 +9,8 @@ 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
|
+
rows?: number;
|
|
14
|
+
cols?: number;
|
|
13
15
|
}
|
|
14
16
|
export declare const RichTextEditor: FC<RichTextEditorProps>;
|
|
@@ -1,20 +1,41 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Form as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { jsx as V } from "react/jsx-runtime";
|
|
2
|
+
import { Form as k } from "antd";
|
|
3
|
+
import { useState as v, useRef as $, useEffect as x, useMemo as u, useCallback as j } from "react";
|
|
4
|
+
import K from "../../util/ValidationUtil.es.js";
|
|
5
|
+
const O = async () => {
|
|
6
|
+
const { Quill: o } = await import("react-quill-new"), i = o.import("blots/block");
|
|
7
|
+
i.tagName = "div", o.register(i);
|
|
8
|
+
}, J = 22, Y = 8, Z = (o, i) => {
|
|
9
|
+
const s = {};
|
|
10
|
+
return o != null && o > 0 && (s["--rich-editor-min-height"] = `${o * J + Y}px`), i != null && i > 0 && (s.width = `min(100%, ${i}ch)`), s;
|
|
11
|
+
}, lt = ({
|
|
12
|
+
formLayoutProps: o,
|
|
13
|
+
name: i,
|
|
14
|
+
label: s,
|
|
15
|
+
required: y,
|
|
16
|
+
rules: p = [],
|
|
17
|
+
disabled: q,
|
|
18
|
+
help: P,
|
|
19
|
+
rows: R,
|
|
20
|
+
cols: H
|
|
16
21
|
}) => {
|
|
17
|
-
const
|
|
22
|
+
const c = k.useFormInstance(), [m, h] = v(""), [T, Q] = v(!1), [I, M] = v(
|
|
23
|
+
null
|
|
24
|
+
), b = $(!1), n = " ";
|
|
25
|
+
x(() => {
|
|
26
|
+
Q(!0);
|
|
27
|
+
}, []), x(() => {
|
|
28
|
+
if (!T) return;
|
|
29
|
+
let e = !1;
|
|
30
|
+
return (async () => {
|
|
31
|
+
await O();
|
|
32
|
+
const { default: t } = await import("react-quill-new");
|
|
33
|
+
e || M(() => t);
|
|
34
|
+
})(), () => {
|
|
35
|
+
e = !0;
|
|
36
|
+
};
|
|
37
|
+
}, [T]);
|
|
38
|
+
const d = (e) => {
|
|
18
39
|
if (!e) return "";
|
|
19
40
|
if (typeof e == "string") return e;
|
|
20
41
|
try {
|
|
@@ -22,36 +43,45 @@ const A = W.lazy(async () => {
|
|
|
22
43
|
} catch {
|
|
23
44
|
return "";
|
|
24
45
|
}
|
|
25
|
-
},
|
|
46
|
+
}, X = () => function(e) {
|
|
26
47
|
const t = this.quill, l = t.getSelection(!0);
|
|
27
48
|
if (l) {
|
|
28
|
-
const
|
|
29
|
-
for (let
|
|
30
|
-
(
|
|
31
|
-
`) &&
|
|
32
|
-
if (
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
t.insertText(
|
|
36
|
-
}), t.setSelection(
|
|
49
|
+
const f = l.index, E = l.index + l.length, G = t.getText(), a = [];
|
|
50
|
+
for (let r = f; r <= E; r++)
|
|
51
|
+
(r === 0 || G[r - 1] === `
|
|
52
|
+
`) && a.push(r);
|
|
53
|
+
if (a.length === 0 && a.push(f), e > 0) {
|
|
54
|
+
let r = 0;
|
|
55
|
+
a.forEach((g) => {
|
|
56
|
+
t.insertText(g + r, n), r += n.length;
|
|
57
|
+
}), t.setSelection(
|
|
58
|
+
f + n.length,
|
|
59
|
+
E + a.length * n.length
|
|
60
|
+
);
|
|
37
61
|
} else {
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
t.getText(
|
|
62
|
+
let r = 0;
|
|
63
|
+
a.forEach((W) => {
|
|
64
|
+
const N = W - r;
|
|
65
|
+
t.getText(N, n.length) === n && (t.deleteText(N, n.length), r += n.length);
|
|
42
66
|
});
|
|
43
|
-
const
|
|
44
|
-
t.setSelection(
|
|
67
|
+
const g = Math.max(0, f - n.length), U = Math.max(g, E - r);
|
|
68
|
+
t.setSelection(g, U);
|
|
45
69
|
}
|
|
46
70
|
}
|
|
47
|
-
},
|
|
71
|
+
}, B = () => function() {
|
|
48
72
|
const e = this.quill, t = e.getSelection(!0);
|
|
49
73
|
return t ? (e.insertText(t.index, n), e.setSelection(t.index + n.length), !1) : !0;
|
|
50
|
-
},
|
|
74
|
+
}, L = () => function() {
|
|
51
75
|
const e = this.quill, t = e.getSelection(!0);
|
|
52
|
-
return t && t.index >= n.length && e.getText(
|
|
53
|
-
|
|
54
|
-
|
|
76
|
+
return t && t.index >= n.length && e.getText(
|
|
77
|
+
t.index - n.length,
|
|
78
|
+
n.length
|
|
79
|
+
) === n ? (e.deleteText(
|
|
80
|
+
t.index - n.length,
|
|
81
|
+
n.length
|
|
82
|
+
), e.setSelection(t.index - n.length), !1) : !0;
|
|
83
|
+
}, A = u(() => {
|
|
84
|
+
const e = X(), t = B(), l = L();
|
|
55
85
|
return {
|
|
56
86
|
toolbar: {
|
|
57
87
|
container: [
|
|
@@ -79,49 +109,79 @@ const A = W.lazy(async () => {
|
|
|
79
109
|
}
|
|
80
110
|
}
|
|
81
111
|
};
|
|
82
|
-
}, []),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
}, []), C = u(
|
|
113
|
+
() => [
|
|
114
|
+
"bold",
|
|
115
|
+
"italic",
|
|
116
|
+
"underline",
|
|
117
|
+
"strike",
|
|
118
|
+
"blockquote",
|
|
119
|
+
"list",
|
|
120
|
+
"bullet",
|
|
121
|
+
"link"
|
|
122
|
+
],
|
|
123
|
+
[]
|
|
124
|
+
);
|
|
125
|
+
x(() => {
|
|
126
|
+
const e = c.getFieldValue(i), t = d(e);
|
|
127
|
+
t && t !== "<p></p>" && t !== "<p><br></p>" && t !== "<div></div>" && h(t);
|
|
128
|
+
}, [c, i]);
|
|
129
|
+
const _ = k.useWatch(i, c);
|
|
130
|
+
x(() => {
|
|
131
|
+
if (b.current)
|
|
99
132
|
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
|
-
|
|
133
|
+
const e = d(_), t = d(m);
|
|
134
|
+
e !== t && h(!e || e === "<p></p>" || e === "<p><br></p>" || e === "<div></div>" ? "" : e);
|
|
135
|
+
}, [_]);
|
|
136
|
+
const w = j(
|
|
137
|
+
(e) => {
|
|
138
|
+
const t = d(e);
|
|
139
|
+
b.current = !0, h(t);
|
|
140
|
+
const l = !t || t === "<p></p>" || t.trim() === "<p><br></p>" || t === "<div></div>" || t.trim() === "<div></div>" ? void 0 : t;
|
|
141
|
+
c.setFieldValue(i, l), setTimeout(() => {
|
|
142
|
+
b.current = !1;
|
|
143
|
+
}, 0), c.validateFields([i]).catch(() => {
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
[c, i]
|
|
147
|
+
), 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
|
+
() => ({
|
|
155
|
+
readOnly: !!q,
|
|
156
|
+
value: String(F || ""),
|
|
157
|
+
onChange: w,
|
|
158
|
+
theme: "snow",
|
|
159
|
+
className: "rich-text-editor",
|
|
160
|
+
style: S,
|
|
161
|
+
modules: A,
|
|
162
|
+
formats: C
|
|
163
|
+
}),
|
|
164
|
+
[q, F, w, A, C, S]
|
|
165
|
+
);
|
|
166
|
+
return /* @__PURE__ */ V(
|
|
167
|
+
k.Item,
|
|
168
|
+
{
|
|
169
|
+
help: P,
|
|
170
|
+
name: i,
|
|
171
|
+
label: s,
|
|
172
|
+
rules: z,
|
|
173
|
+
...o,
|
|
174
|
+
children: T && I ? /* @__PURE__ */ V(I, { ...D }) : /* @__PURE__ */ V(
|
|
175
|
+
"div",
|
|
176
|
+
{
|
|
177
|
+
className: "rich-text-editor rich-text-editor--loading",
|
|
178
|
+
style: S,
|
|
179
|
+
children: "Loading editor..."
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
);
|
|
124
184
|
};
|
|
125
185
|
export {
|
|
126
|
-
|
|
186
|
+
lt as RichTextEditor
|
|
127
187
|
};
|
|
@@ -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;
|