@kingteza/crud-component 1.38.0 → 1.40.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.
@@ -1 +1 @@
1
- "use strict";const f=require("react/jsx-runtime"),N=require("antd"),i=require("react"),F=require("../../locale/index.cjs.js"),G=require("../tooltip/TooltipComponent.cjs.js"),H=require("./TextField.cjs.js"),R=/\D/g,v=/\B(?=(\d{3})+(?!\d))/g,U=/\$\s?|(,*)/g,V=new Set(["e","E","."]);function z(e,t,s){return`${e??t??""} ${s}`.trim()}function J(e){if(e==null)return"";const t=String(e);if(!t.includes("."))return t.replace(v,",");const[s,...o]=t.split(".");return[s.replace(v,","),...o].join(".")}function Q(e){return(e==null?void 0:e.replace(U,""))??""}function W(e,t){return e==null?"":String(e).replace(t,"")}function X(e,t){return e==null?"":e.replace(t,"")}const Z=i.forwardRef(function({type:t,required:s,label:o,rules:p=[],placeholder:l,onEnter:m,form:g,nextFocus:E,min:T,moneyField:u,addonAfter:_,minLength:b,defaultValue:h,pattern:w,disabled:M,readOnly:P,onChange:S,value:q,max:y,addonBefore:D,size:L,isInt:n=!1,tooltip:C,help:I,...O},j){const{t:d}=F.useTranslationLib(),c=T===null,a=n&&!c,A=l??o,k=i.useMemo(()=>{const r=[...p,{required:s,message:z(o,l,d("err.validation.required"))}];return n&&r.push({type:"number",validator:async(ee,x)=>{if(!(x==null||Number.isInteger(x)))throw new Error(d("err.validation.integer"))}}),r},[p,o,l,d,s,n]),K=i.useMemo(()=>{if(u)return J;if(a)return r=>W(r,R)},[u,a]),$=i.useMemo(()=>{if(u)return Q;if(a)return r=>X(r,R)},[u,a]),B=i.useCallback(r=>H.onEnterInternalTextField(r,E,g,m),[E,g,m]),Y=i.useCallback(r=>{if(!c&&r.key==="-"){r.preventDefault();return}V.has(r.key)&&r.preventDefault()},[c]);return f.jsx(G,{title:C,children:f.jsx(N.Form.Item,{...O,label:o,rules:k,help:I,children:f.jsx(N.InputNumber,{ref:j,disabled:M,defaultValue:h,value:q,readOnly:P,addonBefore:D,minLength:b,addonAfter:_,step:n?1:void 0,inputMode:n?"numeric":void 0,pattern:n?c?"-?[0-9]*":"[0-9]*":w,precision:n?0:void 0,onChange:S,onPressEnter:B,className:"max-width",min:c?void 0:T??0,max:y,type:u?void 0:"number",size:L,formatter:K,parser:$,onKeyDown:n?Y:void 0,placeholder:A})})})});module.exports=Z;
1
+ "use strict";const p=require("react/jsx-runtime"),R=require("antd"),o=require("react"),H=require("../../locale/index.cjs.js"),U=require("../tooltip/TooltipComponent.cjs.js"),V=require("./TextField.cjs.js"),_=/\D/g,b=/\B(?=(\d{3})+(?!\d))/g,z=/\$\s?|(,*)/g,J=new Set(["e","E","."]);function Q(e,t,c){return`${e??t??""} ${c}`.trim()}function W(e){if(e==null)return"";const t=String(e);if(!t.includes("."))return t.replace(b,",");const[c,...s]=t.split(".");return[c.replace(b,","),...s].join(".")}function X(e){return(e==null?void 0:e.replace(z,""))??""}function Z(e,t){return e==null?"":String(e).replace(t,"")}function ee(e,t){return e==null?"":e.replace(t,"")}const re=o.forwardRef(function({changeOnWheel:t,type:c,required:s,label:a,rules:m=[],placeholder:f,onEnter:g,form:E,nextFocus:T,min:x,moneyField:i,addonAfter:h,minLength:v,defaultValue:w,pattern:M,disabled:P,readOnly:S,onChange:q,value:y,max:D,addonBefore:L,size:C,isInt:n=!1,tooltip:I,help:O,step:j,...A},k){const{t:d}=H.useTranslationLib(),u=x===null,l=n&&!u,K=f??a,$=o.useMemo(()=>{const r=[...m,{required:s,message:Q(a,f,d("err.validation.required"))}];return n&&r.push({type:"number",validator:async(te,N)=>{if(!(N==null||Number.isInteger(N)))throw new Error(d("err.validation.integer"))}}),r},[m,a,f,d,s,n]),B=o.useMemo(()=>{if(i)return W;if(l)return r=>Z(r,_)},[i,l]),Y=o.useMemo(()=>{if(i)return X;if(l)return r=>ee(r,_)},[i,l]),F=o.useCallback(r=>V.onEnterInternalTextField(r,T,E,g),[T,E,g]),G=o.useCallback(r=>{if(!u&&r.key==="-"){r.preventDefault();return}J.has(r.key)&&r.preventDefault()},[u]);return p.jsx(U,{title:I,children:p.jsx(R.Form.Item,{...A,label:a,rules:$,help:O,children:p.jsx(R.InputNumber,{ref:k,changeOnWheel:t,disabled:P,defaultValue:w,value:y,readOnly:S,addonBefore:L,minLength:v,addonAfter:h,step:n?1:j,inputMode:n?"numeric":void 0,pattern:n?u?"-?[0-9]*":"[0-9]*":M,precision:n?0:void 0,onChange:q,onPressEnter:F,className:"max-width",min:u?void 0:x??0,max:D,type:i?void 0:"number",size:C,formatter:B,parser:Y,onKeyDown:n?G:void 0,placeholder:K})})})});module.exports=re;
@@ -2,9 +2,11 @@ import { ReactNode } from 'react';
2
2
  import { TextFieldProps } from './TextField';
3
3
  export interface NumberTextFieldProps extends TextFieldProps {
4
4
  moneyField?: boolean;
5
+ changeOnWheel?: boolean;
5
6
  addonAfter?: ReactNode;
6
7
  minLength?: number;
7
8
  isInt?: boolean;
9
+ step?: number;
8
10
  max?: number;
9
11
  pattern?: string;
10
12
  min?: number | null;
@@ -1,128 +1,131 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { Form as G, InputNumber as H } from "antd";
3
- import { forwardRef as U, useMemo as p, useCallback as v } from "react";
4
- import { useTranslationLib as V } from "../../locale/index.es.js";
5
- import z from "../tooltip/TooltipComponent.es.js";
6
- import { onEnterInternalTextField as F } from "./TextField.es.js";
7
- const _ = /\D/g, h = /\B(?=(\d{3})+(?!\d))/g, J = /\$\s?|(,*)/g, Q = /* @__PURE__ */ new Set(["e", "E", "."]);
8
- function W(r, e, i) {
9
- return `${r ?? e ?? ""} ${i}`.trim();
1
+ import { jsx as p } from "react/jsx-runtime";
2
+ import { Form as U, InputNumber as V } from "antd";
3
+ import { forwardRef as z, useMemo as m, useCallback as h } from "react";
4
+ import { useTranslationLib as F } from "../../locale/index.es.js";
5
+ import J from "../tooltip/TooltipComponent.es.js";
6
+ import { onEnterInternalTextField as Q } from "./TextField.es.js";
7
+ const v = /\D/g, w = /\B(?=(\d{3})+(?!\d))/g, W = /\$\s?|(,*)/g, X = /* @__PURE__ */ new Set(["e", "E", "."]);
8
+ function Z(r, e, u) {
9
+ return `${r ?? e ?? ""} ${u}`.trim();
10
10
  }
11
- function X(r) {
11
+ function rr(r) {
12
12
  if (r == null) return "";
13
13
  const e = String(r);
14
14
  if (!e.includes("."))
15
- return e.replace(h, ",");
16
- const [i, ...o] = e.split(".");
17
- return [i.replace(h, ","), ...o].join(".");
15
+ return e.replace(w, ",");
16
+ const [u, ...o] = e.split(".");
17
+ return [u.replace(w, ","), ...o].join(".");
18
18
  }
19
- function Z(r) {
20
- return (r == null ? void 0 : r.replace(J, "")) ?? "";
19
+ function tr(r) {
20
+ return (r == null ? void 0 : r.replace(W, "")) ?? "";
21
21
  }
22
- function rr(r, e) {
22
+ function er(r, e) {
23
23
  return r == null ? "" : String(r).replace(e, "");
24
24
  }
25
- function tr(r, e) {
25
+ function nr(r, e) {
26
26
  return r == null ? "" : r.replace(e, "");
27
27
  }
28
- const ar = U(
28
+ const lr = z(
29
29
  function({
30
- type: e,
31
- required: i,
32
- label: o,
33
- rules: m = [],
34
- placeholder: a,
35
- onEnter: d,
36
- form: g,
37
- nextFocus: E,
38
- min: N,
39
- moneyField: s,
40
- addonAfter: w,
41
- minLength: P,
42
- defaultValue: R,
43
- pattern: S,
44
- disabled: b,
45
- readOnly: y,
46
- onChange: D,
47
- value: L,
48
- max: I,
49
- addonBefore: M,
50
- size: O,
30
+ changeOnWheel: e,
31
+ type: u,
32
+ required: o,
33
+ label: c,
34
+ rules: d = [],
35
+ placeholder: f,
36
+ onEnter: g,
37
+ form: E,
38
+ nextFocus: N,
39
+ min: T,
40
+ moneyField: i,
41
+ addonAfter: P,
42
+ minLength: R,
43
+ defaultValue: S,
44
+ pattern: b,
45
+ disabled: y,
46
+ readOnly: D,
47
+ onChange: L,
48
+ value: I,
49
+ max: M,
50
+ addonBefore: O,
51
+ size: x,
51
52
  isInt: n = !1,
52
- tooltip: x,
53
- help: A,
54
- ...C
55
- }, K) {
56
- const { t: f } = V(), u = N === null, c = n && !u, k = a ?? o, $ = p(() => {
53
+ tooltip: A,
54
+ help: C,
55
+ step: K,
56
+ ...k
57
+ }, $) {
58
+ const { t: l } = F(), s = T === null, a = n && !s, j = f ?? c, B = m(() => {
57
59
  const t = [
58
- ...m,
60
+ ...d,
59
61
  {
60
- required: i,
61
- message: W(
62
- o,
63
- a,
64
- f("err.validation.required")
62
+ required: o,
63
+ message: Z(
64
+ c,
65
+ f,
66
+ l("err.validation.required")
65
67
  )
66
68
  }
67
69
  ];
68
70
  return n && t.push({
69
71
  type: "number",
70
- validator: async (er, T) => {
71
- if (!(T == null || Number.isInteger(T)))
72
- throw new Error(f("err.validation.integer"));
72
+ validator: async (or, _) => {
73
+ if (!(_ == null || Number.isInteger(_)))
74
+ throw new Error(l("err.validation.integer"));
73
75
  }
74
76
  }), t;
75
- }, [m, o, a, f, i, n]), j = p(() => {
76
- if (s) return X;
77
- if (c)
78
- return (t) => rr(t, _);
79
- }, [s, c]), B = p(() => {
80
- if (s) return Z;
81
- if (c)
82
- return (t) => tr(t, _);
83
- }, [s, c]), Y = v(
84
- (t) => F(t, E, g, d),
85
- [E, g, d]
86
- ), q = v(
77
+ }, [d, c, f, l, o, n]), Y = m(() => {
78
+ if (i) return rr;
79
+ if (a)
80
+ return (t) => er(t, v);
81
+ }, [i, a]), q = m(() => {
82
+ if (i) return tr;
83
+ if (a)
84
+ return (t) => nr(t, v);
85
+ }, [i, a]), G = h(
86
+ (t) => Q(t, N, E, g),
87
+ [N, E, g]
88
+ ), H = h(
87
89
  (t) => {
88
- if (!u && t.key === "-") {
90
+ if (!s && t.key === "-") {
89
91
  t.preventDefault();
90
92
  return;
91
93
  }
92
- Q.has(t.key) && t.preventDefault();
94
+ X.has(t.key) && t.preventDefault();
93
95
  },
94
- [u]
96
+ [s]
95
97
  );
96
- return /* @__PURE__ */ l(z, { title: x, children: /* @__PURE__ */ l(G.Item, { ...C, label: o, rules: $, help: A, children: /* @__PURE__ */ l(
97
- H,
98
+ return /* @__PURE__ */ p(J, { title: A, children: /* @__PURE__ */ p(U.Item, { ...k, label: c, rules: B, help: C, children: /* @__PURE__ */ p(
99
+ V,
98
100
  {
99
- ref: K,
100
- disabled: b,
101
- defaultValue: R,
102
- value: L,
103
- readOnly: y,
104
- addonBefore: M,
105
- minLength: P,
106
- addonAfter: w,
107
- step: n ? 1 : void 0,
101
+ ref: $,
102
+ changeOnWheel: e,
103
+ disabled: y,
104
+ defaultValue: S,
105
+ value: I,
106
+ readOnly: D,
107
+ addonBefore: O,
108
+ minLength: R,
109
+ addonAfter: P,
110
+ step: n ? 1 : K,
108
111
  inputMode: n ? "numeric" : void 0,
109
- pattern: n ? u ? "-?[0-9]*" : "[0-9]*" : S,
112
+ pattern: n ? s ? "-?[0-9]*" : "[0-9]*" : b,
110
113
  precision: n ? 0 : void 0,
111
- onChange: D,
112
- onPressEnter: Y,
114
+ onChange: L,
115
+ onPressEnter: G,
113
116
  className: "max-width",
114
- min: u ? void 0 : N ?? 0,
115
- max: I,
116
- type: s ? void 0 : "number",
117
- size: O,
118
- formatter: j,
119
- parser: B,
120
- onKeyDown: n ? q : void 0,
121
- placeholder: k
117
+ min: s ? void 0 : T ?? 0,
118
+ max: M,
119
+ type: i ? void 0 : "number",
120
+ size: x,
121
+ formatter: Y,
122
+ parser: q,
123
+ onKeyDown: n ? H : void 0,
124
+ placeholder: j
122
125
  }
123
126
  ) }) });
124
127
  }
125
128
  );
126
129
  export {
127
- ar as default
130
+ lr as default
128
131
  };
@@ -170,6 +170,8 @@ export interface NumberBasedFieldProps<T> extends InitialCrudField<T>, AddonFiel
170
170
  */
171
171
  formatted?: boolean;
172
172
  int?: boolean;
173
+ step?: number;
174
+ changeOnWheel?: boolean;
173
175
  onChange?: (value: number, form: FormInstance<T>) => void;
174
176
  }
175
177
  export interface DateBasedFieldProps<T> extends InitialCrudField<T>, Copyable<false> {
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),p=require("antd"),T=require("react"),Y=require("react-highlight-words"),Z=require("../locale/index.cjs.js"),ee=require("./FileCrudField.cjs.js"),re=require("./ImageCrudField.cjs.js"),te=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(j){const{label:s,name:d,type:c,required:h,hidden:H,rules:b=[],updatable:m=!0,readonly:F=!1,fieldClassName:f,customFormFieldRender:k,fieldTooltip:S,fieldHelper:C,formLayoutProps:q,...r}=j,l=p.Form.useFormInstance();T.useEffect(()=>{if(c==="select"){const{items:a=[],onSearch:o,searchOnType:u}=r;!(a!=null&&a.length)&&!u&&(o==null||o(void 0,l,r==null?void 0:r.updatingValue))}},[l,r,c,r==null?void 0:r.updatingValue]);const R=E.useCrudSearchContext(),x=T.useCallback((a,o)=>{R&&R.search(),!F&&o&&o(a,l)},[R,F,l]);if(F||H)return e.jsx(e.Fragment,{});if(k)return k(l,j);switch(c){case"text":case"email":case"password":{const{maxLength:a,onChange:o,placeholder:u,addonAfter:y,addonBefore:i}=r;return e.jsx(se.default,{...q,maxLength:a,placeholder:u,disabled:!m,rules:b,required:h,onChange:o?v=>o(v,l):void 0,type:c,name:d,tooltip:S,label:s,className:f,autoComplete:"new-password",addonAfter:y,addonBefore:i,help:C})}case"phone":{const{onChange:a,placeholder:o,addonAfter:u,addonBefore:y}=r;return e.jsx(le,{...r,...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:y,help:C})}case"number":{const{onChange:a,placeholder:o,allowMinus:u,min:y,max:i,addonAfter:v,addonBefore:w,int:P}=r;return e.jsx(oe,{...q,placeholder:o,disabled:!m,moneyField:!!r.formatted,type:c,onChange:a?n=>a(n,l):void 0,rules:b,autoComplete:"false",required:h,tooltip:S,className:f,min:u?null:y,max:i,addonAfter:v,addonBefore:w,name:d,label:s,help:C,isInt:P})}case"date":{const{range:a,disableToday:o,disabledFutureDays:u,disabledPastDays:y,onChange:i,placeholder:v,format:w}=r;return e.jsx(ne,{...q,placeholder:v,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:y,help:C})}case"time":{const{range:a=!1,disableCurrent:o,disabledFuture:u,disabledPast:y,onChange:i,use12Hours:v,format:w,placeholder:P}=r;return e.jsx(ae,{...q,placeholder:P,required:h,format:w,disabled:!m,type:c,tooltip:S,range:a,use12Hours:v,name:d,label:s,onChange:x,className:f,disableCurrent:o,disabledFuture:u,disabledPast:y,help:C})}case"textarea":return e.jsx(de,{...j});case"image":return e.jsx(re.default,{...r,required:h,name:d,label:s,rules:b,fieldHelper:C,fieldClassName:f,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"file":return e.jsx(ee.default,{...r,required:h,name:d,label:s,rules:b,fieldHelper:C,fieldClassName:f,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"select":return e.jsx($,{...r,required:h,name:d,label:s,rules:b,fieldClassName:f,form:l,help:C,updatable:m,readonly:F,fieldTooltip:S,fieldHelper:C});case"enum":return e.jsx(W,{...j});case"checkbox":{const{onChange:a,switch:o}=r;return e.jsx(te,{...q,className:f,rules:b,onChange:x,label:s,tooltip:S,disabled:!m,name:d,help:C,switch:o})}case"color":return e.jsx(z,{...r,type:"color",required:h,name:d,label:s,rules:b,fieldClassName:f,updatable:m,readonly:F,fieldTooltip:S,fieldHelper:C});default:return e.jsx(e.Fragment,{children:`${c} Not Implemented`})}}function W(j){const s=p.Form.useFormInstance(),{label:d,name:c,type:h,required:H,hidden:b,rules:m=[],updatable:F=!0,readonly:f=!1,fieldClassName:k,customFormFieldRender:S,fieldTooltip:C,fieldHelper:q,formLayoutProps:r,...l}=j,{t:R}=Z.useTranslationLibNoNS(),{enum:x,translation:a,onChange:o,onSearch:u,multiple:y,tagRender:i}=l,v=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(p.Form.Item,{...l,...r,name:c,required:H,tooltip:C,rules:m,label:d,className:["w-100",k].join(" "),help:q,children:e.jsx(p.Radio.Group,{...l,onChange:n=>{var N;return P((N=n==null?void 0:n.target)==null?void 0:N.value)},children:v.map(n=>e.jsx(p.Radio,{disabled:!F,value:n,children:a?R(a[n]):n},n))})}):"checkbox"in l&&l.checkbox?e.jsx(p.Form.Item,{...l,...r,name:c,required:H,tooltip:C,rules:m,label:d,className:["w-100",k].join(" "),help:q,children:e.jsx(p.Checkbox.Group,{className:"w-100",onChange:P,children:v.map(n=>{const N=e.jsx(p.Checkbox,{disabled:!F,value:n,children:a?R(a[n]):n},n);return"checkboxGrid"in l&&l.checkboxGrid?e.jsx(p.Col,{...l.checkboxGrid,children:N}):N})})}):e.jsx(D,{...l,...r,notSearch:!0,tagRender:typeof i=="function"?i:i?n=>{const{value:N,label:I}=n,L=i[N];return L?e.jsx(p.Tag,{color:L.color,children:I}):e.jsx(p.Tag,{children:I})}:void 0,onChange:P,className:["w-100",k].join(" "),name:c,items:v,required:H,tooltip:C,rules:m,label:d,help:q,disabled:!F,onSearch:u?n=>u(n,s):void 0,allowClear:!0,mode:y?"multiple":void 0,showLoadingInEmptyIndicator:!0,itemBuilder:n=>e.jsx(p.Select.Option,{value:n,children:a?R(a[n]):n},n)})}function $(j){const{items:s=[],loading:d,searchOnType:c,onSearch:h,multiple:H,onChange:b,highlightSearch:m,required:F,fieldClassName:f,rules:k,fieldTooltip:S,updatable:C,label:q,name:r,tagRender:l,updatingValue:R,onSet:x,placeholder:a,allowClear:o=!0,selectOptionRender:u,formLayoutProps:y}=j,i=j.form,[v,w]=T.useState(""),P=T.useMemo(()=>_.getRealName(r),[r]),n=T.useMemo(()=>_.getRealName(r,"upsertFieldName"),[r]),N=p.Form.useWatch(P,i),[I,L]=T.useState(!0);T.useEffect(()=>{x&&I&&N&&(x==null||x(N,s,i),L(!1))},[I,i,s,P,x,N]),T.useEffect(()=>{N&&L(!0)},[N]);const J=T.useCallback(async t=>{w(t),c&&(h==null||h(t,i,R))},[i,h,c,R]),K=T.useCallback(t=>u?u(t):t.value,[u]),O=E.useCrudSearchContext(),Q=T.useCallback(t=>{O&&O.search(),b&&(w(""),b(t,i))},[O,b,i]);return e.jsx(D,{...j,...y,showLoadingInEmptyIndicator:!0,maxTagCount:"responsive",maxTagPlaceholder:t=>e.jsxs(ie,{title:e.jsx(e.Fragment,{children:t.map(g=>e.jsxs(e.Fragment,{children:[g.label," ",e.jsx("br",{})]}))}),children:["+",t==null?void 0:t.length]}),placeholder:a,onSelect:t=>{x==null||x(t==null?void 0:t.key,s,i)},onChange:Q,mode:H?"multiple":void 0,className:["w-100",f].join(" "),name:n,items:s,required:F,tooltip:S,tagRender:l,rules:k,disabled:!C,label:q,allowClear:o,onSearch:J,loading:d,filterOption:m?(t,g)=>{var A,B,G;try{const M=t.toLowerCase().split(/\s+/),V=((typeof(g==null?void 0:g.children)=="string"?g==null?void 0:g.children:(B=(A=g==null?void 0:g.children)==null?void 0:A.props)==null?void 0:B.textToHighlight)??"").toLowerCase(),X=(((G=g==null?void 0:g.value)==null?void 0:G.toString())??"").toLowerCase();return M.every(U=>V.indexOf(U)>=0||X.indexOf(U)>=0)}catch{return!0}}:void 0,itemBuilder:m?t=>{const g=t.value?String(t.value):void 0;return e.jsx(p.Select.Option,{value:t.key,title:g,disabled:t.disabled,children:e.jsx(Y,{highlightClassName:"highlight-text",searchWords:(v??"").split(" "),autoEscape:!0,textToHighlight:g??""})},t.key)}:t=>e.jsx(p.Select.Option,{value:t.key,title:t.value,disabled:t.disabled,children:K(t)},t.key)})}function z(j){const{formLayoutProps:s,required:d,fieldClassName:c,rules:h,fieldTooltip:H,updatable:b,label:m,name:F,fieldHelper:f}=j;return e.jsx(p.Form.Item,{...s,label:m,name:F,required:d,rules:h,tooltip:H,help:f,getValueFromEvent:k=>typeof k=="object"?k.toHexString():k,children:e.jsx(p.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:c,disabled:!b,...j.innerProps})})}exports.ColorCrudFieldComponent=z;exports.EnumCrudFieldComponent=W;exports.SelectCrudFieldComponent=$;exports.default=ce;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),p=require("antd"),T=require("react"),Y=require("react-highlight-words"),Z=require("../locale/index.cjs.js"),ee=require("./FileCrudField.cjs.js"),re=require("./ImageCrudField.cjs.js"),te=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:C,formLayoutProps:q,...r}=F,l=p.Form.useFormInstance();T.useEffect(()=>{if(c==="select"){const{items:a=[],onSearch:o,searchOnType:u}=r;!(a!=null&&a.length)&&!u&&(o==null||o(void 0,l,r==null?void 0:r.updatingValue))}},[l,r,c,r==null?void 0:r.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}=r;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:C})}case"phone":{const{onChange:a,placeholder:o,addonAfter:u,addonBefore:v}=r;return e.jsx(le,{...r,...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:C})}case"number":{const{onChange:a,placeholder:o,allowMinus:u,min:v,max:i,addonAfter:N,addonBefore:w,int:P,step:n,changeOnWheel:j=!1}=r;return e.jsx(oe,{...q,step:n,changeOnWheel:j,placeholder:o,disabled:!m,moneyField:!!r.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:C,isInt:P})}case"date":{const{range:a,disableToday:o,disabledFutureDays:u,disabledPastDays:v,onChange:i,placeholder:N,format:w}=r;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:C})}case"time":{const{range:a=!1,disableCurrent:o,disabledFuture:u,disabledPast:v,onChange:i,use12Hours:N,format:w,placeholder:P}=r;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:C})}case"textarea":return e.jsx(de,{...F});case"image":return e.jsx(re.default,{...r,required:h,name:d,label:s,rules:b,fieldHelper:C,fieldClassName:f,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"file":return e.jsx(ee.default,{...r,required:h,name:d,label:s,rules:b,fieldHelper:C,fieldClassName:f,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"select":return e.jsx($,{...r,required:h,name:d,label:s,rules:b,fieldClassName:f,form:l,help:C,updatable:m,readonly:y,fieldTooltip:S,fieldHelper:C});case"enum":return e.jsx(W,{...F});case"checkbox":{const{onChange:a,switch:o}=r;return e.jsx(te,{...q,className:f,rules:b,onChange:x,label:s,tooltip:S,disabled:!m,name:d,help:C,switch:o})}case"color":return e.jsx(z,{...r,type:"color",required:h,name:d,label:s,rules:b,fieldClassName:f,updatable:m,readonly:y,fieldTooltip:S,fieldHelper:C});default:return e.jsx(e.Fragment,{children:`${c} Not Implemented`})}}function W(F){const s=p.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:C,fieldHelper:q,formLayoutProps:r,...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(p.Form.Item,{...l,...r,name:c,required:O,tooltip:C,rules:m,label:d,className:["w-100",k].join(" "),help:q,children:e.jsx(p.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(p.Radio,{disabled:!y,value:n,children:a?R(a[n]):n},n))})}):"checkbox"in l&&l.checkbox?e.jsx(p.Form.Item,{...l,...r,name:c,required:O,tooltip:C,rules:m,label:d,className:["w-100",k].join(" "),help:q,children:e.jsx(p.Checkbox.Group,{className:"w-100",onChange:P,children:N.map(n=>{const j=e.jsx(p.Checkbox,{disabled:!y,value:n,children:a?R(a[n]):n},n);return"checkboxGrid"in l&&l.checkboxGrid?e.jsx(p.Col,{...l.checkboxGrid,children:j}):j})})}):e.jsx(D,{...l,...r,notSearch:!0,tagRender:typeof i=="function"?i:i?n=>{const{value:j,label:H}=n,I=i[j];return I?e.jsx(p.Tag,{color:I.color,children:H}):e.jsx(p.Tag,{children:H})}:void 0,onChange:P,className:["w-100",k].join(" "),name:c,items:N,required:O,tooltip:C,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(p.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:C,label:q,name:r,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(r),[r]),n=T.useMemo(()=>_.getRealName(r,"upsertFieldName"),[r]),j=p.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 t=>{w(t),c&&(h==null||h(t,i,R))},[i,h,c,R]),K=T.useCallback(t=>u?u(t):t.value,[u]),L=E.useCrudSearchContext(),Q=T.useCallback(t=>{L&&L.search(),b&&(w(""),b(t,i))},[L,b,i]);return e.jsx(D,{...F,...v,showLoadingInEmptyIndicator:!0,maxTagCount:"responsive",maxTagPlaceholder:t=>e.jsxs(ie,{title:e.jsx(e.Fragment,{children:t.map(g=>e.jsxs(e.Fragment,{children:[g.label," ",e.jsx("br",{})]}))}),children:["+",t==null?void 0:t.length]}),placeholder:a,onSelect:t=>{x==null||x(t==null?void 0:t.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:!C,label:q,allowClear:o,onSearch:J,loading:d,filterOption:m?(t,g)=>{var A,B,G;try{const M=t.toLowerCase().split(/\s+/),V=((typeof(g==null?void 0:g.children)=="string"?g==null?void 0:g.children:(B=(A=g==null?void 0:g.children)==null?void 0:A.props)==null?void 0:B.textToHighlight)??"").toLowerCase(),X=(((G=g==null?void 0:g.value)==null?void 0:G.toString())??"").toLowerCase();return M.every(U=>V.indexOf(U)>=0||X.indexOf(U)>=0)}catch{return!0}}:void 0,itemBuilder:m?t=>{const g=t.value?String(t.value):void 0;return e.jsx(p.Select.Option,{value:t.key,title:g,disabled:t.disabled,children:e.jsx(Y,{highlightClassName:"highlight-text",searchWords:(N??"").split(" "),autoEscape:!0,textToHighlight:g??""})},t.key)}:t=>e.jsx(p.Select.Option,{value:t.key,title:t.value,disabled:t.disabled,children:K(t)},t.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(p.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(p.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;
@@ -1,10 +1,10 @@
1
1
  import { jsx as r, Fragment as A, jsxs as $ } from "react/jsx-runtime";
2
- import { Form as L, ColorPicker as ae, Radio as z, Checkbox as J, Col as ne, Select as E, Tag as K } from "antd";
2
+ import { Form as O, ColorPicker as ae, Radio as z, Checkbox as J, Col as ne, Select as E, Tag as K } from "antd";
3
3
  import { useEffect as G, useCallback as j, useState as Q, useMemo as V } from "react";
4
4
  import le from "react-highlight-words";
5
5
  import { useTranslationLibNoNS as ie } from "../locale/index.es.js";
6
- import de from "./FileCrudField.es.js";
7
- import se from "./ImageCrudField.es.js";
6
+ import se from "./FileCrudField.es.js";
7
+ import de from "./ImageCrudField.es.js";
8
8
  import ce from "../common/check-box/CheckBox.es.js";
9
9
  import me from "../common/date-picker/DatePicker.es.js";
10
10
  import ue from "../common/date-picker/TimePicker.es.js";
@@ -16,23 +16,23 @@ import ge from "../common/tooltip/TooltipComponent.es.js";
16
16
  import Ce from "./CrudTextAreaComponent.es.js";
17
17
  import X from "../util/CrudUtil.es.js";
18
18
  import { useCrudSearchContext as U } from "../context/CrudSearchContext.es.js";
19
- function Ue(x) {
19
+ function Ue(y) {
20
20
  const {
21
21
  label: i,
22
- name: s,
22
+ name: d,
23
23
  type: c,
24
24
  required: u,
25
25
  hidden: I,
26
26
  rules: b = [],
27
27
  updatable: h = !0,
28
- readonly: y = !1,
28
+ readonly: v = !1,
29
29
  fieldClassName: f,
30
30
  customFormFieldRender: w,
31
31
  fieldTooltip: R,
32
32
  fieldHelper: p,
33
33
  formLayoutProps: T,
34
34
  ...e
35
- } = x, l = L.useFormInstance();
35
+ } = y, l = O.useFormInstance();
36
36
  G(() => {
37
37
  if (c === "select") {
38
38
  const {
@@ -44,16 +44,16 @@ function Ue(x) {
44
44
  }
45
45
  }, [l, e, c, e == null ? void 0 : e.updatingValue]);
46
46
  const P = U(), C = j((a, n) => {
47
- P && P.search(), !y && n && n(a, l);
48
- }, [P, y, l]);
49
- if (y || I) return /* @__PURE__ */ r(A, {});
47
+ P && P.search(), !v && n && n(a, l);
48
+ }, [P, v, l]);
49
+ if (v || I) return /* @__PURE__ */ r(A, {});
50
50
  if (w)
51
- return w(l, x);
51
+ return w(l, y);
52
52
  switch (c) {
53
53
  case "text":
54
54
  case "email":
55
55
  case "password": {
56
- const { maxLength: a, onChange: n, placeholder: m, addonAfter: v, addonBefore: d } = e;
56
+ const { maxLength: a, onChange: n, placeholder: m, addonAfter: N, addonBefore: s } = e;
57
57
  return /* @__PURE__ */ r(
58
58
  pe,
59
59
  {
@@ -63,21 +63,21 @@ function Ue(x) {
63
63
  disabled: !h,
64
64
  rules: b,
65
65
  required: u,
66
- onChange: n ? (N) => n(N, l) : void 0,
66
+ onChange: n ? (F) => n(F, l) : void 0,
67
67
  type: c,
68
- name: s,
68
+ name: d,
69
69
  tooltip: R,
70
70
  label: i,
71
71
  className: f,
72
72
  autoComplete: "new-password",
73
- addonAfter: v,
74
- addonBefore: d,
73
+ addonAfter: N,
74
+ addonBefore: s,
75
75
  help: p
76
76
  }
77
77
  );
78
78
  }
79
79
  case "phone": {
80
- const { onChange: a, placeholder: n, addonAfter: m, addonBefore: v } = e;
80
+ const { onChange: a, placeholder: n, addonAfter: m, addonBefore: N } = e;
81
81
  return /* @__PURE__ */ r(
82
82
  fe,
83
83
  {
@@ -87,15 +87,15 @@ function Ue(x) {
87
87
  disabled: !h,
88
88
  rules: b,
89
89
  required: u,
90
- onChange: a ? (d) => a(d, l) : void 0,
90
+ onChange: a ? (s) => a(s, l) : void 0,
91
91
  type: c,
92
- name: s,
92
+ name: d,
93
93
  tooltip: R,
94
94
  label: i,
95
95
  className: f,
96
96
  autoComplete: "new-password",
97
97
  addonAfter: m,
98
- addonBefore: v,
98
+ addonBefore: N,
99
99
  help: p
100
100
  }
101
101
  );
@@ -105,31 +105,35 @@ function Ue(x) {
105
105
  onChange: a,
106
106
  placeholder: n,
107
107
  allowMinus: m,
108
- min: v,
109
- max: d,
110
- addonAfter: N,
108
+ min: N,
109
+ max: s,
110
+ addonAfter: F,
111
111
  addonBefore: k,
112
- int: H
112
+ int: H,
113
+ step: o,
114
+ changeOnWheel: x = !1
113
115
  } = e;
114
116
  return /* @__PURE__ */ r(
115
117
  he,
116
118
  {
117
119
  ...T,
120
+ step: o,
121
+ changeOnWheel: x,
118
122
  placeholder: n,
119
123
  disabled: !h,
120
124
  moneyField: !!e.formatted,
121
125
  type: c,
122
- onChange: a ? (o) => a(o, l) : void 0,
126
+ onChange: a ? (L) => a(L, l) : void 0,
123
127
  rules: b,
124
128
  autoComplete: "false",
125
129
  required: u,
126
130
  tooltip: R,
127
131
  className: f,
128
- min: m ? null : v,
129
- max: d,
130
- addonAfter: N,
132
+ min: m ? null : N,
133
+ max: s,
134
+ addonAfter: F,
131
135
  addonBefore: k,
132
- name: s,
136
+ name: d,
133
137
  label: i,
134
138
  help: p,
135
139
  isInt: H
@@ -141,29 +145,29 @@ function Ue(x) {
141
145
  range: a,
142
146
  disableToday: n,
143
147
  disabledFutureDays: m,
144
- disabledPastDays: v,
145
- onChange: d,
146
- placeholder: N,
148
+ disabledPastDays: N,
149
+ onChange: s,
150
+ placeholder: F,
147
151
  format: k
148
152
  } = e;
149
153
  return /* @__PURE__ */ r(
150
154
  me,
151
155
  {
152
156
  ...T,
153
- placeholder: N,
157
+ placeholder: F,
154
158
  required: u,
155
159
  disabled: !h,
156
160
  type: c,
157
161
  format: k,
158
162
  tooltip: R,
159
163
  range: a,
160
- name: s,
164
+ name: d,
161
165
  label: i,
162
166
  onChange: C,
163
167
  className: f,
164
168
  disableToday: n,
165
169
  disabledFutureDays: m,
166
- disabledPastDays: v,
170
+ disabledPastDays: N,
167
171
  help: p
168
172
  }
169
173
  );
@@ -173,9 +177,9 @@ function Ue(x) {
173
177
  range: a = !1,
174
178
  disableCurrent: n,
175
179
  disabledFuture: m,
176
- disabledPast: v,
177
- onChange: d,
178
- use12Hours: N,
180
+ disabledPast: N,
181
+ onChange: s,
182
+ use12Hours: F,
179
183
  format: k,
180
184
  placeholder: H
181
185
  } = e;
@@ -190,27 +194,27 @@ function Ue(x) {
190
194
  type: c,
191
195
  tooltip: R,
192
196
  range: a,
193
- use12Hours: N,
194
- name: s,
197
+ use12Hours: F,
198
+ name: d,
195
199
  label: i,
196
200
  onChange: C,
197
201
  className: f,
198
202
  disableCurrent: n,
199
203
  disabledFuture: m,
200
- disabledPast: v,
204
+ disabledPast: N,
201
205
  help: p
202
206
  }
203
207
  );
204
208
  }
205
209
  case "textarea":
206
- return /* @__PURE__ */ r(Ce, { ...x });
210
+ return /* @__PURE__ */ r(Ce, { ...y });
207
211
  case "image":
208
212
  return /* @__PURE__ */ r(
209
- se,
213
+ de,
210
214
  {
211
215
  ...e,
212
216
  required: u,
213
- name: s,
217
+ name: d,
214
218
  label: i,
215
219
  rules: b,
216
220
  fieldHelper: p,
@@ -222,11 +226,11 @@ function Ue(x) {
222
226
  );
223
227
  case "file":
224
228
  return /* @__PURE__ */ r(
225
- de,
229
+ se,
226
230
  {
227
231
  ...e,
228
232
  required: u,
229
- name: s,
233
+ name: d,
230
234
  label: i,
231
235
  rules: b,
232
236
  fieldHelper: p,
@@ -242,20 +246,20 @@ function Ue(x) {
242
246
  {
243
247
  ...e,
244
248
  required: u,
245
- name: s,
249
+ name: d,
246
250
  label: i,
247
251
  rules: b,
248
252
  fieldClassName: f,
249
253
  form: l,
250
254
  help: p,
251
255
  updatable: h,
252
- readonly: y,
256
+ readonly: v,
253
257
  fieldTooltip: R,
254
258
  fieldHelper: p
255
259
  }
256
260
  );
257
261
  case "enum":
258
- return /* @__PURE__ */ r(be, { ...x });
262
+ return /* @__PURE__ */ r(be, { ...y });
259
263
  case "checkbox": {
260
264
  const { onChange: a, switch: n } = e;
261
265
  return /* @__PURE__ */ r(
@@ -268,7 +272,7 @@ function Ue(x) {
268
272
  label: i,
269
273
  tooltip: R,
270
274
  disabled: !h,
271
- name: s,
275
+ name: d,
272
276
  help: p,
273
277
  switch: n
274
278
  }
@@ -281,12 +285,12 @@ function Ue(x) {
281
285
  ...e,
282
286
  type: "color",
283
287
  required: u,
284
- name: s,
288
+ name: d,
285
289
  label: i,
286
290
  rules: b,
287
291
  fieldClassName: f,
288
292
  updatable: h,
289
- readonly: y,
293
+ readonly: v,
290
294
  fieldTooltip: R,
291
295
  fieldHelper: p
292
296
  }
@@ -295,15 +299,15 @@ function Ue(x) {
295
299
  return /* @__PURE__ */ r(A, { children: `${c} Not Implemented` });
296
300
  }
297
301
  }
298
- function be(x) {
299
- const i = L.useFormInstance(), {
300
- label: s,
302
+ function be(y) {
303
+ const i = O.useFormInstance(), {
304
+ label: d,
301
305
  name: c,
302
306
  type: u,
303
307
  required: I,
304
308
  hidden: b,
305
309
  rules: h = [],
306
- updatable: y = !0,
310
+ updatable: v = !0,
307
311
  readonly: f = !1,
308
312
  fieldClassName: w,
309
313
  customFormFieldRender: R,
@@ -311,21 +315,21 @@ function be(x) {
311
315
  fieldHelper: T,
312
316
  formLayoutProps: e,
313
317
  ...l
314
- } = x, { t: P } = ie(), {
318
+ } = y, { t: P } = ie(), {
315
319
  enum: C,
316
320
  translation: a,
317
321
  onChange: n,
318
322
  onSearch: m,
319
- multiple: v,
320
- tagRender: d
321
- } = l, N = Array.isArray(C) ? C : Object.keys(C), k = U(), H = j(
323
+ multiple: N,
324
+ tagRender: s
325
+ } = l, F = Array.isArray(C) ? C : Object.keys(C), k = U(), H = j(
322
326
  (o) => {
323
327
  k && k.search(), !f && n && n(o, i);
324
328
  },
325
329
  [k, f, n, i]
326
330
  );
327
331
  return "radio" in l && l.radio ? /* @__PURE__ */ r(
328
- L.Item,
332
+ O.Item,
329
333
  {
330
334
  ...l,
331
335
  ...e,
@@ -333,7 +337,7 @@ function be(x) {
333
337
  required: I,
334
338
  tooltip: p,
335
339
  rules: h,
336
- label: s,
340
+ label: d,
337
341
  className: ["w-100", w].join(" "),
338
342
  help: T,
339
343
  children: /* @__PURE__ */ r(
@@ -341,15 +345,15 @@ function be(x) {
341
345
  {
342
346
  ...l,
343
347
  onChange: (o) => {
344
- var F;
345
- return H((F = o == null ? void 0 : o.target) == null ? void 0 : F.value);
348
+ var x;
349
+ return H((x = o == null ? void 0 : o.target) == null ? void 0 : x.value);
346
350
  },
347
- children: N.map((o) => /* @__PURE__ */ r(z, { disabled: !y, value: o, children: a ? P(a[o]) : o }, o))
351
+ children: F.map((o) => /* @__PURE__ */ r(z, { disabled: !v, value: o, children: a ? P(a[o]) : o }, o))
348
352
  }
349
353
  )
350
354
  }
351
355
  ) : "checkbox" in l && l.checkbox ? /* @__PURE__ */ r(
352
- L.Item,
356
+ O.Item,
353
357
  {
354
358
  ...l,
355
359
  ...e,
@@ -357,12 +361,12 @@ function be(x) {
357
361
  required: I,
358
362
  tooltip: p,
359
363
  rules: h,
360
- label: s,
364
+ label: d,
361
365
  className: ["w-100", w].join(" "),
362
366
  help: T,
363
- children: /* @__PURE__ */ r(J.Group, { className: "w-100", onChange: H, children: N.map((o) => {
364
- const F = /* @__PURE__ */ r(J, { disabled: !y, value: o, children: a ? P(a[o]) : o }, o);
365
- return "checkboxGrid" in l && l.checkboxGrid ? /* @__PURE__ */ r(ne, { ...l.checkboxGrid, children: F }) : F;
367
+ children: /* @__PURE__ */ r(J.Group, { className: "w-100", onChange: H, children: F.map((o) => {
368
+ const x = /* @__PURE__ */ r(J, { disabled: !v, value: o, children: a ? P(a[o]) : o }, o);
369
+ return "checkboxGrid" in l && l.checkboxGrid ? /* @__PURE__ */ r(ne, { ...l.checkboxGrid, children: x }) : x;
366
370
  }) })
367
371
  }
368
372
  ) : /* @__PURE__ */ r(
@@ -371,38 +375,38 @@ function be(x) {
371
375
  ...l,
372
376
  ...e,
373
377
  notSearch: !0,
374
- tagRender: typeof d == "function" ? d : d ? (o) => {
375
- const { value: F, label: S } = o, O = d[F];
376
- return O ? /* @__PURE__ */ r(K, { color: O.color, children: S }) : /* @__PURE__ */ r(K, { children: S });
378
+ tagRender: typeof s == "function" ? s : s ? (o) => {
379
+ const { value: x, label: L } = o, S = s[x];
380
+ return S ? /* @__PURE__ */ r(K, { color: S.color, children: L }) : /* @__PURE__ */ r(K, { children: L });
377
381
  } : void 0,
378
382
  onChange: H,
379
383
  className: ["w-100", w].join(" "),
380
384
  name: c,
381
- items: N,
385
+ items: F,
382
386
  required: I,
383
387
  tooltip: p,
384
388
  rules: h,
385
- label: s,
389
+ label: d,
386
390
  help: T,
387
- disabled: !y,
391
+ disabled: !v,
388
392
  onSearch: m ? (o) => m(o, i) : void 0,
389
393
  allowClear: !0,
390
- mode: v ? "multiple" : void 0,
394
+ mode: N ? "multiple" : void 0,
391
395
  showLoadingInEmptyIndicator: !0,
392
396
  itemBuilder: (o) => /* @__PURE__ */ r(E.Option, { value: o, children: a ? P(a[o]) : o }, o)
393
397
  }
394
398
  );
395
399
  }
396
- function xe(x) {
400
+ function xe(y) {
397
401
  const {
398
402
  items: i = [],
399
- loading: s,
403
+ loading: d,
400
404
  searchOnType: c,
401
405
  onSearch: u,
402
406
  multiple: I,
403
407
  onChange: b,
404
408
  highlightSearch: h,
405
- required: y,
409
+ required: v,
406
410
  fieldClassName: f,
407
411
  rules: w,
408
412
  fieldTooltip: R,
@@ -415,35 +419,35 @@ function xe(x) {
415
419
  placeholder: a,
416
420
  allowClear: n = !0,
417
421
  selectOptionRender: m,
418
- formLayoutProps: v
419
- } = x, d = x.form, [N, k] = Q(""), H = V(() => X.getRealName(e), [e]), o = V(
422
+ formLayoutProps: N
423
+ } = y, s = y.form, [F, k] = Q(""), H = V(() => X.getRealName(e), [e]), o = V(
420
424
  () => X.getRealName(e, "upsertFieldName"),
421
425
  [e]
422
- ), F = L.useWatch(H, d), [S, O] = Q(!0);
426
+ ), x = O.useWatch(H, s), [L, S] = Q(!0);
423
427
  G(() => {
424
- C && S && F && (C == null || C(F, i, d), O(!1));
425
- }, [S, d, i, H, C, F]), G(() => {
426
- F && O(!0);
427
- }, [F]);
428
+ C && L && x && (C == null || C(x, i, s), S(!1));
429
+ }, [L, s, i, H, C, x]), G(() => {
430
+ x && S(!0);
431
+ }, [x]);
428
432
  const Z = j(
429
433
  async (t) => {
430
- k(t), c && (u == null || u(t, d, P));
434
+ k(t), c && (u == null || u(t, s, P));
431
435
  },
432
- [d, u, c, P]
436
+ [s, u, c, P]
433
437
  ), ee = j(
434
438
  (t) => m ? m(t) : t.value,
435
439
  [m]
436
440
  ), B = U(), re = j(
437
441
  (t) => {
438
- B && B.search(), b && (k(""), b(t, d));
442
+ B && B.search(), b && (k(""), b(t, s));
439
443
  },
440
- [B, b, d]
444
+ [B, b, s]
441
445
  );
442
446
  return /* @__PURE__ */ r(
443
447
  Y,
444
448
  {
445
- ...x,
446
- ...v,
449
+ ...y,
450
+ ...N,
447
451
  showLoadingInEmptyIndicator: !0,
448
452
  maxTagCount: "responsive",
449
453
  maxTagPlaceholder: (t) => /* @__PURE__ */ $(
@@ -462,14 +466,14 @@ function xe(x) {
462
466
  ),
463
467
  placeholder: a,
464
468
  onSelect: (t) => {
465
- C == null || C(t == null ? void 0 : t.key, i, d);
469
+ C == null || C(t == null ? void 0 : t.key, i, s);
466
470
  },
467
471
  onChange: re,
468
472
  mode: I ? "multiple" : void 0,
469
473
  className: ["w-100", f].join(" "),
470
474
  name: o,
471
475
  items: i,
472
- required: y,
476
+ required: v,
473
477
  tooltip: R,
474
478
  tagRender: l,
475
479
  rules: w,
@@ -477,12 +481,12 @@ function xe(x) {
477
481
  label: T,
478
482
  allowClear: n,
479
483
  onSearch: Z,
480
- loading: s,
484
+ loading: d,
481
485
  filterOption: h ? (t, g) => {
482
- var q, D, M;
486
+ var q, D, W;
483
487
  try {
484
- const W = t.toLowerCase().split(/\s+/), te = ((typeof (g == null ? void 0 : g.children) == "string" ? g == null ? void 0 : g.children : (D = (q = g == null ? void 0 : g.children) == null ? void 0 : q.props) == null ? void 0 : D.textToHighlight) ?? "").toLowerCase(), oe = (((M = g == null ? void 0 : g.value) == null ? void 0 : M.toString()) ?? "").toLowerCase();
485
- return W.every(
488
+ const M = t.toLowerCase().split(/\s+/), te = ((typeof (g == null ? void 0 : g.children) == "string" ? g == null ? void 0 : g.children : (D = (q = g == null ? void 0 : g.children) == null ? void 0 : q.props) == null ? void 0 : D.textToHighlight) ?? "").toLowerCase(), oe = (((W = g == null ? void 0 : g.value) == null ? void 0 : W.toString()) ?? "").toLowerCase();
489
+ return M.every(
486
490
  (_) => te.indexOf(_) >= 0 || oe.indexOf(_) >= 0
487
491
  );
488
492
  } catch {
@@ -501,7 +505,7 @@ function xe(x) {
501
505
  le,
502
506
  {
503
507
  highlightClassName: "highlight-text",
504
- searchWords: (N ?? "").split(" "),
508
+ searchWords: (F ?? "").split(" "),
505
509
  autoEscape: !0,
506
510
  textToHighlight: g ?? ""
507
511
  }
@@ -522,25 +526,25 @@ function xe(x) {
522
526
  }
523
527
  );
524
528
  }
525
- function ye(x) {
529
+ function ye(y) {
526
530
  const {
527
531
  formLayoutProps: i,
528
- required: s,
532
+ required: d,
529
533
  fieldClassName: c,
530
534
  rules: u,
531
535
  fieldTooltip: I,
532
536
  updatable: b,
533
537
  label: h,
534
- name: y,
538
+ name: v,
535
539
  fieldHelper: f
536
- } = x;
540
+ } = y;
537
541
  return /* @__PURE__ */ r(
538
- L.Item,
542
+ O.Item,
539
543
  {
540
544
  ...i,
541
545
  label: h,
542
- name: y,
543
- required: s,
546
+ name: v,
547
+ required: d,
544
548
  rules: u,
545
549
  tooltip: I,
546
550
  help: f,
@@ -555,7 +559,7 @@ function ye(x) {
555
559
  trigger: "click",
556
560
  className: c,
557
561
  disabled: !b,
558
- ...x.innerProps
562
+ ...y.innerProps
559
563
  }
560
564
  )
561
565
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.38.0",
4
+ "version": "1.40.0",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",