@kingteza/crud-component 1.17.2 → 1.19.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 +2 -0
- package/dist/common/rich/index.es.js +52 -51
- package/dist/common/select/SelectComponent.cjs.js +1 -1
- package/dist/common/select/SelectComponent.d.ts +1 -1
- package/dist/common/select/SelectComponent.es.js +39 -37
- package/dist/crud/CrudComponent.d.ts +2 -1
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +293 -281
- package/dist/crud/CrudTextAreaComponent.cjs.js +1 -1
- package/dist/crud/CrudTextAreaComponent.d.ts +1 -1
- package/dist/crud/CrudTextAreaComponent.es.js +32 -29
- package/dist/crud/FileCrudField.cjs.js +1 -1
- package/dist/crud/FileCrudField.d.ts +1 -1
- package/dist/crud/FileCrudField.es.js +37 -35
- package/dist/crud/ImageCrudField.cjs.js +1 -1
- package/dist/crud/ImageCrudField.es.js +88 -86
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)&&h.push(
|
|
1
|
+
"use strict";var O=Object.create;var j=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var L=(r,n,s,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of W(n))!K.call(r,c)&&c!==s&&j(r,c,{get:()=>n[c],enumerable:!(u=U(n,c))||u.enumerable});return r};var A=(r,n,s)=>(s=r!=null?O(z(r)):{},L(n||!r||!r.__esModule?j(s,"default",{value:r,enumerable:!0}):s,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),k=require("antd"),o=require("react"),D=require("../../util/ValidationUtil.cjs.js"),G=o.lazy(async()=>{const{default:r}=await import("react-quill"),{Quill:n}=r,s=n.import("blots/block");return s.tagName="div",n.register(s),{default:u=>g.jsx(r,{...u})}}),J=({formLayoutProps:r,name:n,label:s,required:u,rules:c=[],disabled:v,help:F})=>{const d=k.Form.useFormInstance(),[m,x]=o.useState(""),T=o.useRef(!1),i=" ",f=t=>{if(!t)return"";if(typeof t=="string")return t;try{return String(t)}catch{return""}},H=()=>function(t){const e=this.quill,a=e.getSelection(!0);if(a){const b=a.index,S=a.index+a.length,Q=e.getText(),h=[];for(let l=b;l<=S;l++)(l===0||Q[l-1]===`
|
|
2
|
+
`)&&h.push(l);if(h.length===0&&h.push(b),t>0){let l=0;h.forEach(p=>{e.insertText(p+l,i),l+=i.length}),e.setSelection(b+i.length,S+h.length*i.length)}else{let l=0;h.forEach(N=>{const R=N-l;e.getText(R,i.length)===i&&(e.deleteText(R,i.length),l+=i.length)});const p=Math.max(0,b-i.length),B=Math.max(p,S-l);e.setSelection(p,B)}}},w=()=>function(){const t=this.quill,e=t.getSelection(!0);return e?(t.insertText(e.index,i),t.setSelection(e.index+i.length),!1):!0},C=()=>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},V=o.useMemo(()=>{const t=H(),e=w(),a=C();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}}}}},[]),q=o.useMemo(()=>["bold","italic","underline","strike","blockquote","list","bullet","link"],[]);o.useEffect(()=>{const t=d.getFieldValue(n),e=f(t);e&&e!=="<p></p>"&&e!=="<p><br></p>"&&e!=="<div></div>"&&x(e)},[d,n]);const y=k.Form.useWatch(n,d);o.useEffect(()=>{if(T.current)return;const t=f(y),e=f(m);t!==e&&x(!t||t==="<p></p>"||t==="<p><br></p>"||t==="<div></div>"?"":t)},[y]);const E=o.useCallback(t=>{const e=f(t);T.current=!0,x(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(()=>{T.current=!1},0),d.validateFields([n]).catch(()=>{})},[d,n]),I=o.useMemo(()=>u?[...c,...D.required(s??"")]:c,[u,c,s]),M=o.useMemo(()=>f(m)||"",[m]),P=o.useMemo(()=>({readOnly:!!v,value:String(M||""),onChange:E,theme:"snow",className:"rich-text-editor",modules:V,formats:q}),[v,M,E,V,q]);return g.jsx(k.Form.Item,{help:F,name:n,label:s,rules:I,...r,children:g.jsx(o.Suspense,{fallback:g.jsx("div",{children:"Loading editor..."}),children:g.jsx(G,{...P})})})};exports.RichTextEditor=J;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Rule } from 'antd/es/form';
|
|
2
|
+
import { FormItemProps } from 'antd/lib';
|
|
2
3
|
import { FC, ReactNode } from 'react';
|
|
3
4
|
export interface RichTextEditorProps {
|
|
4
5
|
help?: ReactNode;
|
|
@@ -7,5 +8,6 @@ export interface RichTextEditorProps {
|
|
|
7
8
|
required?: boolean;
|
|
8
9
|
rules?: Rule[];
|
|
9
10
|
disabled?: boolean;
|
|
11
|
+
formLayoutProps?: Pick<FormItemProps, "layout" | 'labelCol' | 'wrapperCol'>;
|
|
10
12
|
}
|
|
11
13
|
export declare const RichTextEditor: FC<RichTextEditorProps>;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Form as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
const { default:
|
|
7
|
-
return
|
|
8
|
-
}),
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { Form as S } from "antd";
|
|
3
|
+
import W, { useState as j, useRef as z, useMemo as u, useEffect as w, useCallback as K, Suspense as L } from "react";
|
|
4
|
+
import O from "../../util/ValidationUtil.es.js";
|
|
5
|
+
const A = W.lazy(async () => {
|
|
6
|
+
const { default: h } = await import("react-quill"), { Quill: r } = h, o = r.import("blots/block");
|
|
7
|
+
return o.tagName = "div", r.register(o), { default: (f) => /* @__PURE__ */ d(h, { ...f }) };
|
|
8
|
+
}), Z = ({
|
|
9
|
+
formLayoutProps: h,
|
|
9
10
|
name: r,
|
|
10
11
|
label: o,
|
|
11
|
-
required:
|
|
12
|
-
rules:
|
|
13
|
-
disabled:
|
|
14
|
-
help:
|
|
12
|
+
required: f,
|
|
13
|
+
rules: b = [],
|
|
14
|
+
disabled: V,
|
|
15
|
+
help: C
|
|
15
16
|
}) => {
|
|
16
|
-
const s =
|
|
17
|
+
const s = S.useFormInstance(), [m, g] = j(""), T = z(!1), n = " ", a = (e) => {
|
|
17
18
|
if (!e) return "";
|
|
18
19
|
if (typeof e == "string") return e;
|
|
19
20
|
try {
|
|
@@ -21,36 +22,36 @@ const O = U.lazy(async () => {
|
|
|
21
22
|
} catch {
|
|
22
23
|
return "";
|
|
23
24
|
}
|
|
24
|
-
},
|
|
25
|
+
}, F = () => function(e) {
|
|
25
26
|
const t = this.quill, l = t.getSelection(!0);
|
|
26
27
|
if (l) {
|
|
27
|
-
const x = l.index,
|
|
28
|
-
for (let i = x; i <=
|
|
29
|
-
(i === 0 ||
|
|
28
|
+
const x = l.index, k = l.index + l.length, N = t.getText(), c = [];
|
|
29
|
+
for (let i = x; i <= k; i++)
|
|
30
|
+
(i === 0 || N[i - 1] === `
|
|
30
31
|
`) && c.push(i);
|
|
31
32
|
if (c.length === 0 && c.push(x), e > 0) {
|
|
32
33
|
let i = 0;
|
|
33
34
|
c.forEach((p) => {
|
|
34
35
|
t.insertText(p + i, n), i += n.length;
|
|
35
|
-
}), t.setSelection(x + n.length,
|
|
36
|
+
}), t.setSelection(x + n.length, k + c.length * n.length);
|
|
36
37
|
} else {
|
|
37
38
|
let i = 0;
|
|
38
|
-
c.forEach((
|
|
39
|
-
const
|
|
40
|
-
t.getText(
|
|
39
|
+
c.forEach((U) => {
|
|
40
|
+
const R = U - i;
|
|
41
|
+
t.getText(R, n.length) === n && (t.deleteText(R, n.length), i += n.length);
|
|
41
42
|
});
|
|
42
|
-
const p = Math.max(0, x - n.length),
|
|
43
|
-
t.setSelection(p,
|
|
43
|
+
const p = Math.max(0, x - n.length), P = Math.max(p, k - i);
|
|
44
|
+
t.setSelection(p, P);
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
},
|
|
47
|
+
}, I = () => function() {
|
|
47
48
|
const e = this.quill, t = e.getSelection(!0);
|
|
48
49
|
return t ? (e.insertText(t.index, n), e.setSelection(t.index + n.length), !1) : !0;
|
|
49
|
-
},
|
|
50
|
+
}, M = () => function() {
|
|
50
51
|
const e = this.quill, t = e.getSelection(!0);
|
|
51
52
|
return t && t.index >= n.length && e.getText(t.index - n.length, n.length) === n ? (e.deleteText(t.index - n.length, n.length), e.setSelection(t.index - n.length), !1) : !0;
|
|
52
|
-
},
|
|
53
|
-
const e =
|
|
53
|
+
}, v = u(() => {
|
|
54
|
+
const e = F(), t = I(), l = M();
|
|
54
55
|
return {
|
|
55
56
|
toolbar: {
|
|
56
57
|
container: [
|
|
@@ -78,7 +79,7 @@ const O = U.lazy(async () => {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
};
|
|
81
|
-
}, []),
|
|
82
|
+
}, []), q = u(() => [
|
|
82
83
|
"bold",
|
|
83
84
|
"italic",
|
|
84
85
|
"underline",
|
|
@@ -88,39 +89,39 @@ const O = U.lazy(async () => {
|
|
|
88
89
|
"bullet",
|
|
89
90
|
"link"
|
|
90
91
|
], []);
|
|
91
|
-
|
|
92
|
-
const e = s.getFieldValue(r), t =
|
|
92
|
+
w(() => {
|
|
93
|
+
const e = s.getFieldValue(r), t = a(e);
|
|
93
94
|
t && t !== "<p></p>" && t !== "<p><br></p>" && t !== "<div></div>" && g(t);
|
|
94
95
|
}, [s, r]);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
if (
|
|
96
|
+
const y = S.useWatch(r, s);
|
|
97
|
+
w(() => {
|
|
98
|
+
if (T.current)
|
|
98
99
|
return;
|
|
99
|
-
const e =
|
|
100
|
+
const e = a(y), t = a(m);
|
|
100
101
|
e !== t && g(!e || e === "<p></p>" || e === "<p><br></p>" || e === "<div></div>" ? "" : e);
|
|
101
|
-
}, [
|
|
102
|
-
const
|
|
103
|
-
const t =
|
|
104
|
-
|
|
102
|
+
}, [y]);
|
|
103
|
+
const E = K((e) => {
|
|
104
|
+
const t = a(e);
|
|
105
|
+
T.current = !0, g(t);
|
|
105
106
|
const l = !t || t === "<p></p>" || t.trim() === "<p><br></p>" || t === "<div></div>" || t.trim() === "<div></div>" ? void 0 : t;
|
|
106
107
|
s.setFieldValue(r, l), setTimeout(() => {
|
|
107
|
-
|
|
108
|
+
T.current = !1;
|
|
108
109
|
}, 0), s.validateFields([r]).catch(() => {
|
|
109
110
|
});
|
|
110
|
-
}, [s, r]),
|
|
111
|
-
() =>
|
|
112
|
-
[
|
|
113
|
-
),
|
|
114
|
-
readOnly: !!
|
|
115
|
-
value: String(
|
|
116
|
-
onChange:
|
|
111
|
+
}, [s, r]), Q = u(
|
|
112
|
+
() => f ? [...b, ...O.required(o ?? "")] : b,
|
|
113
|
+
[f, b, o]
|
|
114
|
+
), H = u(() => a(m) || "", [m]), B = u(() => ({
|
|
115
|
+
readOnly: !!V,
|
|
116
|
+
value: String(H || ""),
|
|
117
|
+
onChange: E,
|
|
117
118
|
theme: "snow",
|
|
118
119
|
className: "rich-text-editor",
|
|
119
|
-
modules:
|
|
120
|
-
formats:
|
|
121
|
-
}), [
|
|
122
|
-
return /* @__PURE__ */
|
|
120
|
+
modules: v,
|
|
121
|
+
formats: q
|
|
122
|
+
}), [V, H, E, v, q]);
|
|
123
|
+
return /* @__PURE__ */ d(S.Item, { help: C, name: r, label: o, rules: Q, ...h, children: /* @__PURE__ */ d(L, { fallback: /* @__PURE__ */ d("div", { children: "Loading editor..." }), children: /* @__PURE__ */ d(A, { ...B }) }) });
|
|
123
124
|
};
|
|
124
125
|
export {
|
|
125
|
-
|
|
126
|
+
Z as RichTextEditor
|
|
126
127
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),x=require("antd"),
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),x=require("antd"),B=require("react"),D=require("../../locale/index.cjs.js"),E=require("../tooltip/TooltipComponent.cjs.js"),P=require("../../util/ValidationUtil.cjs.js");function U({layout:S,label:s,rules:L=[],required:f,placeholder:o,notSearch:q,children:m,readOnly:c,items:i,dropdownRender:T,itemBuilder:_,loading:h,showLoadingInEmptyIndicator:p,nameFieldInArray:u="name",innerRef:N,tooltip:R,filterOption:b,tagRender:k,help:F,...r}){const{t:W}=D.useTranslationLib(),H=B.useCallback(e=>{const t=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e.id,d=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e[u];return n.jsx("option",{value:t,children:n.jsx("div",{dangerouslySetInnerHTML:{__html:d}})},t)},[u]),I=s||o||"";return n.jsx(x.ConfigProvider,{renderEmpty:p&&h?()=>n.jsx(x.Spin,{}):void 0,children:n.jsx(E,{title:R,children:n.jsx(x.Form.Item,{label:s,name:r.name,help:F,layout:S,className:r.className,required:f,rules:[...L,...f?P.required(I):[]],children:n.jsx(x.Select,{ref:N,loading:h,open:c?!1:void 0,onChange:!c&&r.onChange,allowClear:!c&&r.allowClear,showSearch:!q,className:`max-width ${c?"readOnly":""}`,...r,tagRender:k,placeholder:o||s,filterOption:b??((e,t)=>{var d,g,C,j;try{const a=(C=(g=(d=t==null?void 0:t.children)==null?void 0:d.props)==null?void 0:g.dangerouslySetInnerHTML)==null?void 0:C.__html,M=e.toLowerCase().split(/\s+/),y=(t==null?void 0:t.children)??"",w=typeof y=="string"?y.toLowerCase():typeof a=="string"?a.toLowerCase():"",O=(((j=t==null?void 0:t.value)==null?void 0:j.toString())??"").toLowerCase(),V=w.replace(/\s/g,"");return M.every(l=>w.indexOf(l)>=0||O.indexOf(l)>=0||V.indexOf(l)>=0)}catch(a){return console.log(a),!0}}),popupRender:T,children:m===null?void 0:m??(i?i==null?void 0:i.map(_??H):n.jsx(n.Fragment,{}))})})})})}module.exports=U;
|
|
@@ -17,5 +17,5 @@ interface SelectComponentProps<T> extends SelectProps<any>, FormItemProps<any> {
|
|
|
17
17
|
filterOption?: SelectProps["filterOption"];
|
|
18
18
|
tagRender?: SelectTagRenderProps;
|
|
19
19
|
}
|
|
20
|
-
declare function SelectComponent<T = any>({ label, rules, required, placeholder, notSearch, children, readOnly, items, dropdownRender, itemBuilder, loading, showLoadingInEmptyIndicator, nameFieldInArray, innerRef, tooltip, filterOption, tagRender, help, ...props }: Readonly<SelectComponentProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare function SelectComponent<T = any>({ layout, label, rules, required, placeholder, notSearch, children, readOnly, items, dropdownRender, itemBuilder, loading, showLoadingInEmptyIndicator, nameFieldInArray, innerRef, tooltip, filterOption, tagRender, help, ...props }: Readonly<SelectComponentProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
21
21
|
export default SelectComponent;
|
|
@@ -1,79 +1,81 @@
|
|
|
1
|
-
import { jsx as r, Fragment as
|
|
2
|
-
import { ConfigProvider as
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { useTranslationLib as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
function
|
|
1
|
+
import { jsx as r, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import { ConfigProvider as E, Form as P, Select as R, Spin as U } from "antd";
|
|
3
|
+
import { useCallback as W } from "react";
|
|
4
|
+
import { useTranslationLib as $ } from "../../locale/index.es.js";
|
|
5
|
+
import q from "../tooltip/TooltipComponent.es.js";
|
|
6
|
+
import z from "../../util/ValidationUtil.es.js";
|
|
7
|
+
function A({
|
|
8
|
+
layout: S,
|
|
8
9
|
label: o,
|
|
9
|
-
rules:
|
|
10
|
+
rules: L = [],
|
|
10
11
|
required: d,
|
|
11
12
|
placeholder: s,
|
|
12
|
-
notSearch:
|
|
13
|
+
notSearch: u,
|
|
13
14
|
children: l,
|
|
14
15
|
readOnly: c,
|
|
15
16
|
items: i,
|
|
16
|
-
dropdownRender:
|
|
17
|
-
itemBuilder:
|
|
17
|
+
dropdownRender: T,
|
|
18
|
+
itemBuilder: _,
|
|
18
19
|
loading: h,
|
|
19
|
-
showLoadingInEmptyIndicator:
|
|
20
|
+
showLoadingInEmptyIndicator: N,
|
|
20
21
|
nameFieldInArray: g = "name",
|
|
21
|
-
innerRef:
|
|
22
|
-
tooltip:
|
|
23
|
-
filterOption:
|
|
24
|
-
tagRender:
|
|
25
|
-
help:
|
|
22
|
+
innerRef: b,
|
|
23
|
+
tooltip: k,
|
|
24
|
+
filterOption: F,
|
|
25
|
+
tagRender: H,
|
|
26
|
+
help: I,
|
|
26
27
|
...n
|
|
27
28
|
}) {
|
|
28
|
-
const { t:
|
|
29
|
+
const { t: G } = $(), M = W(
|
|
29
30
|
(t) => {
|
|
30
31
|
const e = typeof t == "string" || typeof t == "number" ? t : t == null ? void 0 : t.id, m = typeof t == "string" || typeof t == "number" ? t : t == null ? void 0 : t[g];
|
|
31
32
|
return /* @__PURE__ */ r("option", { value: e, children: /* @__PURE__ */ r("div", { dangerouslySetInnerHTML: { __html: m } }) }, e);
|
|
32
33
|
},
|
|
33
34
|
[g]
|
|
34
|
-
),
|
|
35
|
+
), O = o || s || "";
|
|
35
36
|
return /* @__PURE__ */ r(
|
|
36
|
-
|
|
37
|
+
E,
|
|
37
38
|
{
|
|
38
|
-
renderEmpty:
|
|
39
|
-
children: /* @__PURE__ */ r(
|
|
40
|
-
|
|
39
|
+
renderEmpty: N && h ? () => /* @__PURE__ */ r(U, {}) : void 0,
|
|
40
|
+
children: /* @__PURE__ */ r(q, { title: k, children: /* @__PURE__ */ r(
|
|
41
|
+
P.Item,
|
|
41
42
|
{
|
|
42
43
|
label: o,
|
|
43
44
|
name: n.name,
|
|
44
|
-
help:
|
|
45
|
+
help: I,
|
|
46
|
+
layout: S,
|
|
45
47
|
className: n.className,
|
|
46
48
|
required: d,
|
|
47
49
|
rules: [
|
|
48
|
-
...
|
|
49
|
-
...d ?
|
|
50
|
+
...L,
|
|
51
|
+
...d ? z.required(O) : []
|
|
50
52
|
],
|
|
51
53
|
children: /* @__PURE__ */ r(
|
|
52
|
-
|
|
54
|
+
R,
|
|
53
55
|
{
|
|
54
|
-
ref:
|
|
56
|
+
ref: b,
|
|
55
57
|
loading: h,
|
|
56
58
|
open: c ? !1 : void 0,
|
|
57
59
|
onChange: !c && n.onChange,
|
|
58
60
|
allowClear: !c && n.allowClear,
|
|
59
|
-
showSearch: !
|
|
61
|
+
showSearch: !u,
|
|
60
62
|
className: `max-width ${c ? "readOnly" : ""}`,
|
|
61
63
|
...n,
|
|
62
|
-
tagRender:
|
|
64
|
+
tagRender: H,
|
|
63
65
|
placeholder: s || o,
|
|
64
|
-
filterOption:
|
|
66
|
+
filterOption: F ?? ((t, e) => {
|
|
65
67
|
var m, C, p, y;
|
|
66
68
|
try {
|
|
67
|
-
const f = (p = (C = (m = e == null ? void 0 : e.children) == null ? void 0 : m.props) == null ? void 0 : C.dangerouslySetInnerHTML) == null ? void 0 : p.__html,
|
|
68
|
-
return
|
|
69
|
-
(a) => x.indexOf(a) >= 0 ||
|
|
69
|
+
const f = (p = (C = (m = e == null ? void 0 : e.children) == null ? void 0 : m.props) == null ? void 0 : C.dangerouslySetInnerHTML) == null ? void 0 : p.__html, V = t.toLowerCase().split(/\s+/), w = (e == null ? void 0 : e.children) ?? "", x = typeof w == "string" ? w.toLowerCase() : typeof f == "string" ? f.toLowerCase() : "", j = (((y = e == null ? void 0 : e.value) == null ? void 0 : y.toString()) ?? "").toLowerCase(), B = x.replace(/\s/g, "");
|
|
70
|
+
return V.every(
|
|
71
|
+
(a) => x.indexOf(a) >= 0 || j.indexOf(a) >= 0 || B.indexOf(a) >= 0
|
|
70
72
|
);
|
|
71
73
|
} catch (f) {
|
|
72
74
|
return console.log(f), !0;
|
|
73
75
|
}
|
|
74
76
|
}),
|
|
75
|
-
popupRender:
|
|
76
|
-
children: l === null ? void 0 : l ?? (i ? i == null ? void 0 : i.map(
|
|
77
|
+
popupRender: T,
|
|
78
|
+
children: l === null ? void 0 : l ?? (i ? i == null ? void 0 : i.map(_ ?? M) : /* @__PURE__ */ r(D, {}))
|
|
77
79
|
}
|
|
78
80
|
)
|
|
79
81
|
}
|
|
@@ -82,5 +84,5 @@ function Z({
|
|
|
82
84
|
);
|
|
83
85
|
}
|
|
84
86
|
export {
|
|
85
|
-
|
|
87
|
+
A as default
|
|
86
88
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ButtonProps, ColorPickerProps } from 'antd';
|
|
2
2
|
import { Rule } from 'antd/es/form';
|
|
3
|
-
import { FormInstance, TablePaginationConfig } from 'antd/lib';
|
|
3
|
+
import { FormInstance, FormItemProps, TablePaginationConfig } from 'antd/lib';
|
|
4
4
|
import { Dayjs } from 'dayjs';
|
|
5
5
|
import { default as React, ReactElement, ReactNode } from 'react';
|
|
6
6
|
import { CrudSearchComponentProps } from './CrudSearchComponent';
|
|
@@ -20,6 +20,7 @@ export type SelectFieldItem = {
|
|
|
20
20
|
disabled?: boolean;
|
|
21
21
|
};
|
|
22
22
|
export interface InitialCrudField<T> {
|
|
23
|
+
formLayoutProps?: Pick<FormItemProps, "layout" | 'labelCol' | 'wrapperCol'>;
|
|
23
24
|
label: string;
|
|
24
25
|
fieldHelper?: ReactNode;
|
|
25
26
|
updatingValue?: T;
|
|
@@ -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"),v=require("antd"),q=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"),_=require("../common/select/SelectComponent.cjs.js"),re=require("../common/text-field/NumberField.cjs.js"),te=require("../common/text-field/TextField.cjs.js"),le=require("../common/tooltip/TooltipComponent.cjs.js"),ae=require("./CrudTextAreaComponent.cjs.js"),U=require("../util/CrudUtil.cjs.js");function ne(N){const{label:n,name:c,type:b,required:o,hidden:O,rules:f=[],updatable:g=!0,readonly:S=!1,fieldClassName:m,customFormFieldRender:w,fieldTooltip:F,fieldHelper:p,formLayoutProps:T,...e}=N,x=v.Form.useFormInstance();q.useEffect(()=>{if(b==="select"){const{items:l=[],onSearch:i,searchOnType:s}=e;!(l!=null&&l.length)&&!s&&(i==null||i(void 0,x,e==null?void 0:e.updatingValue))}},[x,e,b,e==null?void 0:e.updatingValue]);const{t:P}=Q.useTranslationLibNoNS();if(S||O)return r.jsx(r.Fragment,{});if(w)return w(x,N);switch(b){case"text":case"email":case"password":{const{onChange:l,placeholder:i,addonAfter:s,addonBefore:u}=e;return r.jsx(te.default,{...T,placeholder:i,disabled:!g,rules:f,required:o,onChange:l?C=>l(C,x):void 0,type:b,name:c,tooltip:F,label:n,className:m,autoComplete:"new-password",addonAfter:s,addonBefore:u,help:p})}case"number":{const{onChange:l,placeholder:i,allowMinus:s,min:u,max:C,addonAfter:h,addonBefore:j}=e;return r.jsx(re,{...T,placeholder:i,disabled:!g,moneyField:!!e.formatted,type:b,onChange:l?y=>l(y,x):void 0,rules:f,autoComplete:"false",required:o,tooltip:F,className:m,min:s?null:u,max:C,addonAfter:h,addonBefore:j,name:c,label:n,help:p})}case"date":{const{range:l,disableToday:i,disabledFutureDays:s,disabledPastDays:u,onChange:C,placeholder:h,format:j}=e;return r.jsx(Z,{...T,placeholder:h,required:o,disabled:!g,type:b,format:j,tooltip:F,range:l,name:c,label:n,onChange:C?y=>C(y,x):void 0,className:m,disableToday:i,disabledFutureDays:s,disabledPastDays:u,help:p})}case"time":{const{range:l=!1,disableCurrent:i,disabledFuture:s,disabledPast:u,onChange:C,use12Hours:h,format:j,placeholder:y}=e;return r.jsx(ee,{...T,placeholder:y,required:o,format:j,disabled:!g,type:b,tooltip:F,range:l,use12Hours:h,name:c,label:n,onChange:C?a=>C(a,x):void 0,className:m,disableCurrent:i,disabledFuture:s,disabledPast:u,help:p})}case"textarea":return r.jsx(ae,{...N});case"image":return r.jsx(X.default,{...e,required:o,name:c,label:n,rules:f,fieldHelper:p,fieldClassName:m,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"file":return r.jsx(V.default,{...e,required:o,name:c,label:n,rules:f,fieldHelper:p,fieldClassName:m,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"select":return r.jsx(D,{...e,required:o,name:c,label:n,rules:f,fieldClassName:m,form:x,help:p,updatable:g,readonly:S,fieldTooltip:F,fieldHelper:p});case"enum":{const{enum:l,radio:i=!1,translation:s,onChange:u,onSearch:C,multiple:h,tagRender:j}=e,y=Array.isArray(l)?l:Object.keys(l);return i?r.jsx(v.Form.Item,{...e,...T,name:c,required:o,tooltip:F,rules:f,label:n,className:["w-100",m].join(" "),help:p,children:r.jsx(v.Radio.Group,{...e,onChange:u?a=>{var k;return u((k=a==null?void 0:a.target)==null?void 0:k.value,x)}:void 0,children:y.map(a=>r.jsx(v.Radio,{disabled:!g,value:a,children:s?P(s[a]):a},a))})}):r.jsx(_,{...e,...T,tagRender:typeof j=="function"?j:j?a=>{const{value:k,label:R}=a,H=j[k];return H?r.jsx(v.Tag,{color:H.color,children:R}):r.jsx(v.Tag,{children:R})}:void 0,onChange:u?a=>u(a,x):void 0,className:["w-100",m].join(" "),name:c,items:y,required:o,tooltip:F,rules:f,label:n,help:p,disabled:!g,onSearch:C?a=>C(a,x):void 0,allowClear:!0,mode:h?"multiple":void 0,itemBuilder:a=>r.jsx(v.Select.Option,{value:a,children:s?P(s[a]):a},a)})}case"checkbox":{const{onChange:l,switch:i}=e;return r.jsx(Y,{...T,className:m,rules:f,onChange:l?s=>l(s,x):void 0,label:n,tooltip:F,disabled:!g,name:c,help:p,switch:i})}case"color":return r.jsx(W,{...e,type:"color",required:o,name:c,label:n,rules:f,fieldClassName:m,updatable:g,readonly:S,fieldTooltip:F,fieldHelper:p});default:return r.jsx(r.Fragment,{children:`${b} Not Implemented`})}}function D(N){const{items:n=[],loading:c,searchOnType:b,onSearch:o,multiple:O,onChange:f,highlightSearch:g,required:S,fieldClassName:m,rules:w,fieldTooltip:F,updatable:p,label:T,name:e,tagRender:x,updatingValue:P,onSet:l,placeholder:i,allowClear:s=!0,selectOptionRender:u,formLayoutProps:C}=N,h=N.form,[j,y]=q.useState(""),a=q.useMemo(()=>U.getRealName(e),[e]),k=q.useMemo(()=>U.getRealName(e,"upsertFieldName"),[e]),R=v.Form.useWatch(a,h),[H,L]=q.useState(!0);q.useEffect(()=>{l&&H&&R&&(l==null||l(R,n,h),L(!1))},[H,h,n,a,l,R]),q.useEffect(()=>{R&&L(!0)},[R]);const G=q.useCallback(async t=>{y(t),b&&(o==null||o(t,h,P))},[h,o,b,P]),$=q.useCallback(t=>u?u(t):t.value,[u]);return r.jsx(_,{...N,...C,maxTagCount:"responsive",maxTagPlaceholder:t=>r.jsxs(le,{title:r.jsx(r.Fragment,{children:t.map(d=>r.jsxs(r.Fragment,{children:[d.label," ",r.jsx("br",{})]}))}),children:["+",t==null?void 0:t.length]}),placeholder:i,onSelect:t=>{l==null||l(t==null?void 0:t.key,n,h)},onChange:f?t=>{y(""),f(t,h)}:void 0,mode:O?"multiple":void 0,className:["w-100",m].join(" "),name:k,items:n,required:S,tooltip:F,tagRender:x,rules:w,disabled:!p,label:T,allowClear:s,onSearch:G,loading:c,filterOption:g?(t,d)=>{var A,B,E;try{const I=t.toLowerCase().split(/\s+/),z=((typeof(d==null?void 0:d.children)=="string"?d==null?void 0:d.children:(B=(A=d==null?void 0:d.children)==null?void 0:A.props)==null?void 0:B.textToHighlight)??"").toLowerCase(),J=(((E=d==null?void 0:d.value)==null?void 0:E.toString())??"").toLowerCase();return I.every(M=>z.indexOf(M)>=0||J.indexOf(M)>=0)}catch{return!0}}:void 0,itemBuilder:g?t=>{const d=t.value?String(t.value):void 0;return r.jsx(v.Select.Option,{value:t.key,title:d,disabled:t.disabled,children:r.jsx(K,{highlightClassName:"highlight-text",searchWords:(j??"").split(" "),autoEscape:!0,textToHighlight:d??""})},t.key)}:t=>r.jsx(v.Select.Option,{value:t.key,title:t.value,disabled:t.disabled,children:$(t)},t.key)})}function W(N){const{formLayoutProps:n,required:c,fieldClassName:b,rules:o,fieldTooltip:O,updatable:f,label:g,name:S,fieldHelper:m}=N;return r.jsx(v.Form.Item,{...n,label:g,name:S,required:c,rules:o,tooltip:O,help:m,getValueFromEvent:w=>typeof w=="object"?w.toHexString():w,children:r.jsx(v.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:b,disabled:!f,...N.innerProps})})}exports.ColorCrudFieldComponent=W;exports.SelectCrudFieldComponent=D;exports.default=ne;
|