@kingteza/crud-component 1.10.2 → 1.10.3

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";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),v=require("antd"),i=require("react"),$=require("react-highlight-words"),z=require("../locale/index.cjs.js"),J=require("./FileCrudField.cjs.js"),K=require("./ImageCrudField.cjs.js"),Q=require("../common/check-box/CheckBox.cjs.js"),X=require("../common/date-picker/DatePicker.cjs.js"),Y=require("../common/date-picker/TimePicker.cjs.js"),U=require("../common/select/SelectComponent.cjs.js"),Z=require("../common/text-field/NumberField.cjs.js"),V=require("../common/text-field/TextField.cjs.js"),ee=require("../common/tooltip/TooltipComponent.cjs.js"),le=require("./CrudTextAreaComponent.cjs.js"),M=require("../util/CrudUtil.cjs.js");function re(k){const{label:o,name:m,type:b,required:c,hidden:q,rules:f=[],updatable:g=!0,readonly:T=!1,fieldClassName:C,customFormFieldRender:H,fieldTooltip:F,fieldHelper:p,...l}=k,u=v.Form.useFormInstance();i.useEffect(()=>{if(b==="select"){const{items:n=[],onSearch:a,searchOnType:d}=l;!(n!=null&&n.length)&&!d&&(a==null||a(void 0,u,l==null?void 0:l.updatingValue))}},[u,l,b,l==null?void 0:l.updatingValue]);const{t:O}=z.useTranslationLibNoNS();if(T||q)return e.jsx(e.Fragment,{});if(H)return H(u,k);switch(b){case"text":case"email":case"password":{const{onChange:n,placeholder:a,addonAfter:d,addonBefore:x}=l;return e.jsx(i.Suspense,{fallback:null,children:e.jsx(V.default,{placeholder:a,disabled:!g,rules:f,required:c,onChange:n?t=>n(t,u):void 0,type:b,name:m,tooltip:F,label:o,className:C,autoComplete:"new-password",addonAfter:d,addonBefore:x,help:p})})}case"number":{const{onChange:n,placeholder:a,allowMinus:d,min:x,max:t,addonAfter:N,addonBefore:j}=l;return e.jsx(i.Suspense,{fallback:null,children:e.jsx(Z,{placeholder:a,disabled:!g,moneyField:!!l.formatted,type:b,onChange:n?S=>n(S,u):void 0,rules:f,autoComplete:"false",required:c,tooltip:F,className:C,min:d?null:x,max:t,addonAfter:N,addonBefore:j,name:m,label:o,help:p})})}case"date":{const{range:n,disableToday:a,disabledFutureDays:d,disabledPastDays:x,onChange:t,placeholder:N,format:j}=l;return e.jsx(i.Suspense,{fallback:null,children:e.jsx(X,{placeholder:N,required:c,disabled:!g,type:b,format:j,tooltip:F,range:n,name:m,label:o,onChange:t?S=>t(S,u):void 0,className:C,disableToday:a,disabledFutureDays:d,disabledPastDays:x,help:p})})}case"time":{const{range:n=!1,disableCurrent:a,disabledFuture:d,disabledPast:x,onChange:t,use12Hours:N,format:j,placeholder:S}=l;return e.jsx(i.Suspense,{fallback:null,children:e.jsx(Y,{placeholder:S,required:c,format:j,disabled:!g,type:b,tooltip:F,range:n,use12Hours:N,name:m,label:o,onChange:t?s=>t(s,u):void 0,className:C,disableCurrent:a,disabledFuture:d,disabledPast:x,help:p})})}case"textarea":return e.jsx(i.Suspense,{fallback:null,children:e.jsx(le,{...k})});case"image":return e.jsx(i.Suspense,{fallback:null,children:e.jsx(K.default,{...l,required:c,name:m,label:o,rules:f,fieldHelper:p,fieldClassName:C,onRemoved:l.onRemoved,onUploading:l.onUploading,provider:l.provider})});case"file":return e.jsx(i.Suspense,{fallback:null,children:e.jsx(J.default,{...l,required:c,name:m,label:o,rules:f,fieldHelper:p,fieldClassName:C,onRemoved:l.onRemoved,onUploading:l.onUploading,provider:l.provider})});case"select":return e.jsx(i.Suspense,{fallback:null,children:e.jsx(E,{...l,required:c,name:m,label:o,rules:f,fieldClassName:C,form:u,help:p,updatable:g,readonly:T,fieldTooltip:F,fieldHelper:p})});case"enum":{const{enum:n,radio:a=!1,translation:d,onChange:x,onSearch:t,multiple:N,tagRender:j}=l,S=Array.isArray(n)?n:Object.keys(n);return a?e.jsx(i.Suspense,{fallback:null,children:e.jsx(v.Form.Item,{...l,name:m,required:c,tooltip:F,rules:f,label:o,className:["w-100",C].join(" "),help:p,children:e.jsx(v.Radio.Group,{...l,onChange:x?s=>{var y;return x((y=s==null?void 0:s.target)==null?void 0:y.value,u)}:void 0,children:S.map(s=>e.jsx(v.Radio,{disabled:!g,value:s,children:d?O(d[s]):s},s))})})}):e.jsx(i.Suspense,{fallback:null,children:e.jsx(U,{...l,tagRender:typeof j=="function"?j:j?s=>{const{value:y,label:w}=s,R=j[y];return R?e.jsx(v.Tag,{color:R.color,children:w}):e.jsx(v.Tag,{children:w})}:void 0,onChange:x?s=>x(s,u):void 0,className:["w-100",C].join(" "),name:m,items:S,required:c,tooltip:F,rules:f,label:o,help:p,disabled:!g,onSearch:t?s=>t(s,u):void 0,allowClear:!0,mode:N?"multiple":void 0,itemBuilder:s=>e.jsx(v.Select.Option,{value:s,children:d?O(d[s]):s},s)})})}case"checkbox":{const{onChange:n,switch:a}=l;return e.jsx(i.Suspense,{fallback:null,children:e.jsx(Q,{className:C,rules:f,onChange:n?d=>n(d,u):void 0,label:o,tooltip:F,disabled:!g,name:m,help:p,switch:a})})}case"color":return e.jsx(i.Suspense,{fallback:null,children:e.jsx(D,{...l,type:"color",required:c,name:m,label:o,rules:f,fieldClassName:C,updatable:g,readonly:T,fieldTooltip:F,fieldHelper:p})});default:return e.jsx(e.Fragment,{children:`${b} Not Implemented`})}}function E(k){const{items:o=[],loading:m,searchOnType:b,onSearch:c,multiple:q,onChange:f,highlightSearch:g,required:T,fieldClassName:C,rules:H,fieldTooltip:F,updatable:p,label:l,name:u,tagRender:O,updatingValue:n,onSet:a,placeholder:d,allowClear:x=!0}=k,t=k.form,[N,j]=i.useState(""),S=i.useMemo(()=>M.getRealName(u),[u]),s=i.useMemo(()=>M.getRealName(u,"upsertFieldName"),[u]),y=v.Form.useWatch(S,t),[w,R]=i.useState(!0);i.useEffect(()=>{a&&w&&y&&(a==null||a(y,o,t),R(!1))},[w,t,o,S,a,y]),i.useEffect(()=>{y&&R(!0)},[y]);const _=i.useCallback(async r=>{j(r),b&&(c==null||c(r,t,n))},[t,c,b,n]);return e.jsx(U,{...k,maxTagCount:"responsive",maxTagPlaceholder:r=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:r.map(h=>e.jsxs(e.Fragment,{children:[h.label," ",e.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:d,onSelect:r=>{a==null||a(r==null?void 0:r.key,o,t)},onChange:f?r=>{j(""),f(r,t)}:void 0,mode:q?"multiple":void 0,className:["w-100",C].join(" "),name:s,items:o,required:T,tooltip:F,tagRender:O,rules:H,disabled:!p,label:l,allowClear:x,onSearch:_,loading:m,filterOption:g?(r,h)=>{var P,A,B;try{const I=r.toLowerCase().split(/\s+/),W=((typeof(h==null?void 0:h.children)=="string"?h==null?void 0:h.children:(A=(P=h==null?void 0:h.children)==null?void 0:P.props)==null?void 0:A.textToHighlight)??"").toLowerCase(),G=(((B=h==null?void 0:h.value)==null?void 0:B.toString())??"").toLowerCase();return I.every(L=>W.indexOf(L)>=0||G.indexOf(L)>=0)}catch{return!0}}:void 0,itemBuilder:g?r=>{const h=r.value?String(r.value):void 0;return e.jsx(v.Select.Option,{value:r.key,title:h,disabled:r.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(N??"").split(" "),autoEscape:!0,textToHighlight:h??""})},r.key)}:r=>e.jsx(v.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:r.value},r.key)})}function D(k){const{required:o,fieldClassName:m,rules:b,fieldTooltip:c,updatable:q,label:f,name:g,fieldHelper:T}=k;return e.jsx(v.Form.Item,{label:f,name:g,required:o,rules:b,tooltip:c,help:T,children:e.jsx(v.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:m,disabled:!q,...k.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=E;exports.default=re;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),v=require("antd"),t=require("react"),$=require("react-highlight-words"),z=require("../locale/index.cjs.js"),J=require("./FileCrudField.cjs.js"),K=require("./ImageCrudField.cjs.js"),Q=require("../common/check-box/CheckBox.cjs.js"),X=require("../common/date-picker/DatePicker.cjs.js"),Y=require("../common/date-picker/TimePicker.cjs.js"),U=require("../common/select/SelectComponent.cjs.js"),Z=require("../common/text-field/NumberField.cjs.js"),V=require("../common/text-field/TextField.cjs.js"),ee=require("../common/tooltip/TooltipComponent.cjs.js"),le=require("./CrudTextAreaComponent.cjs.js"),M=require("../util/CrudUtil.cjs.js");function re(k){const{label:o,name:m,type:b,required:c,hidden:q,rules:f=[],updatable:g=!0,readonly:T=!1,fieldClassName:C,customFormFieldRender:H,fieldTooltip:F,fieldHelper:p,...l}=k,u=v.Form.useFormInstance();t.useEffect(()=>{if(b==="select"){const{items:n=[],onSearch:a,searchOnType:d}=l;!(n!=null&&n.length)&&!d&&(a==null||a(void 0,u,l==null?void 0:l.updatingValue))}},[u,l,b,l==null?void 0:l.updatingValue]);const{t:O}=z.useTranslationLibNoNS();if(T||q)return e.jsx(e.Fragment,{});switch(H&&(t.Suspense,H(u,k)),b){case"text":case"email":case"password":{const{onChange:n,placeholder:a,addonAfter:d,addonBefore:x}=l;return e.jsx(t.Suspense,{fallback:null,children:e.jsx(V.default,{placeholder:a,disabled:!g,rules:f,required:c,onChange:n?i=>n(i,u):void 0,type:b,name:m,tooltip:F,label:o,className:C,autoComplete:"new-password",addonAfter:d,addonBefore:x,help:p})})}case"number":{const{onChange:n,placeholder:a,allowMinus:d,min:x,max:i,addonAfter:N,addonBefore:j}=l;return e.jsx(t.Suspense,{fallback:null,children:e.jsx(Z,{placeholder:a,disabled:!g,moneyField:!!l.formatted,type:b,onChange:n?S=>n(S,u):void 0,rules:f,autoComplete:"false",required:c,tooltip:F,className:C,min:d?null:x,max:i,addonAfter:N,addonBefore:j,name:m,label:o,help:p})})}case"date":{const{range:n,disableToday:a,disabledFutureDays:d,disabledPastDays:x,onChange:i,placeholder:N,format:j}=l;return e.jsx(t.Suspense,{fallback:null,children:e.jsx(X,{placeholder:N,required:c,disabled:!g,type:b,format:j,tooltip:F,range:n,name:m,label:o,onChange:i?S=>i(S,u):void 0,className:C,disableToday:a,disabledFutureDays:d,disabledPastDays:x,help:p})})}case"time":{const{range:n=!1,disableCurrent:a,disabledFuture:d,disabledPast:x,onChange:i,use12Hours:N,format:j,placeholder:S}=l;return e.jsx(t.Suspense,{fallback:null,children:e.jsx(Y,{placeholder:S,required:c,format:j,disabled:!g,type:b,tooltip:F,range:n,use12Hours:N,name:m,label:o,onChange:i?s=>i(s,u):void 0,className:C,disableCurrent:a,disabledFuture:d,disabledPast:x,help:p})})}case"textarea":return e.jsx(t.Suspense,{fallback:null,children:e.jsx(le,{...k})});case"image":return e.jsx(t.Suspense,{fallback:null,children:e.jsx(K.default,{...l,required:c,name:m,label:o,rules:f,fieldHelper:p,fieldClassName:C,onRemoved:l.onRemoved,onUploading:l.onUploading,provider:l.provider})});case"file":return e.jsx(t.Suspense,{fallback:null,children:e.jsx(J.default,{...l,required:c,name:m,label:o,rules:f,fieldHelper:p,fieldClassName:C,onRemoved:l.onRemoved,onUploading:l.onUploading,provider:l.provider})});case"select":return e.jsx(t.Suspense,{fallback:null,children:e.jsx(E,{...l,required:c,name:m,label:o,rules:f,fieldClassName:C,form:u,help:p,updatable:g,readonly:T,fieldTooltip:F,fieldHelper:p})});case"enum":{const{enum:n,radio:a=!1,translation:d,onChange:x,onSearch:i,multiple:N,tagRender:j}=l,S=Array.isArray(n)?n:Object.keys(n);return a?e.jsx(t.Suspense,{fallback:null,children:e.jsx(v.Form.Item,{...l,name:m,required:c,tooltip:F,rules:f,label:o,className:["w-100",C].join(" "),help:p,children:e.jsx(v.Radio.Group,{...l,onChange:x?s=>{var y;return x((y=s==null?void 0:s.target)==null?void 0:y.value,u)}:void 0,children:S.map(s=>e.jsx(v.Radio,{disabled:!g,value:s,children:d?O(d[s]):s},s))})})}):e.jsx(t.Suspense,{fallback:null,children:e.jsx(U,{...l,tagRender:typeof j=="function"?j:j?s=>{const{value:y,label:w}=s,R=j[y];return R?e.jsx(v.Tag,{color:R.color,children:w}):e.jsx(v.Tag,{children:w})}:void 0,onChange:x?s=>x(s,u):void 0,className:["w-100",C].join(" "),name:m,items:S,required:c,tooltip:F,rules:f,label:o,help:p,disabled:!g,onSearch:i?s=>i(s,u):void 0,allowClear:!0,mode:N?"multiple":void 0,itemBuilder:s=>e.jsx(v.Select.Option,{value:s,children:d?O(d[s]):s},s)})})}case"checkbox":{const{onChange:n,switch:a}=l;return e.jsx(t.Suspense,{fallback:null,children:e.jsx(Q,{className:C,rules:f,onChange:n?d=>n(d,u):void 0,label:o,tooltip:F,disabled:!g,name:m,help:p,switch:a})})}case"color":return e.jsx(t.Suspense,{fallback:null,children:e.jsx(D,{...l,type:"color",required:c,name:m,label:o,rules:f,fieldClassName:C,updatable:g,readonly:T,fieldTooltip:F,fieldHelper:p})});default:return e.jsx(e.Fragment,{children:`${b} Not Implemented`})}}function E(k){const{items:o=[],loading:m,searchOnType:b,onSearch:c,multiple:q,onChange:f,highlightSearch:g,required:T,fieldClassName:C,rules:H,fieldTooltip:F,updatable:p,label:l,name:u,tagRender:O,updatingValue:n,onSet:a,placeholder:d,allowClear:x=!0}=k,i=k.form,[N,j]=t.useState(""),S=t.useMemo(()=>M.getRealName(u),[u]),s=t.useMemo(()=>M.getRealName(u,"upsertFieldName"),[u]),y=v.Form.useWatch(S,i),[w,R]=t.useState(!0);t.useEffect(()=>{a&&w&&y&&(a==null||a(y,o,i),R(!1))},[w,i,o,S,a,y]),t.useEffect(()=>{y&&R(!0)},[y]);const _=t.useCallback(async r=>{j(r),b&&(c==null||c(r,i,n))},[i,c,b,n]);return e.jsx(U,{...k,maxTagCount:"responsive",maxTagPlaceholder:r=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:r.map(h=>e.jsxs(e.Fragment,{children:[h.label," ",e.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:d,onSelect:r=>{a==null||a(r==null?void 0:r.key,o,i)},onChange:f?r=>{j(""),f(r,i)}:void 0,mode:q?"multiple":void 0,className:["w-100",C].join(" "),name:s,items:o,required:T,tooltip:F,tagRender:O,rules:H,disabled:!p,label:l,allowClear:x,onSearch:_,loading:m,filterOption:g?(r,h)=>{var P,A,B;try{const I=r.toLowerCase().split(/\s+/),W=((typeof(h==null?void 0:h.children)=="string"?h==null?void 0:h.children:(A=(P=h==null?void 0:h.children)==null?void 0:P.props)==null?void 0:A.textToHighlight)??"").toLowerCase(),G=(((B=h==null?void 0:h.value)==null?void 0:B.toString())??"").toLowerCase();return I.every(L=>W.indexOf(L)>=0||G.indexOf(L)>=0)}catch{return!0}}:void 0,itemBuilder:g?r=>{const h=r.value?String(r.value):void 0;return e.jsx(v.Select.Option,{value:r.key,title:h,disabled:r.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(N??"").split(" "),autoEscape:!0,textToHighlight:h??""})},r.key)}:r=>e.jsx(v.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:r.value},r.key)})}function D(k){const{required:o,fieldClassName:m,rules:b,fieldTooltip:c,updatable:q,label:f,name:g,fieldHelper:T}=k;return e.jsx(v.Form.Item,{label:f,name:g,required:o,rules:b,tooltip:c,help:T,children:e.jsx(v.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:m,disabled:!q,...k.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=E;exports.default=re;
@@ -42,9 +42,7 @@ function He(N) {
42
42
  }, [c, l, b, l == null ? void 0 : l.updatingValue]);
43
43
  const { t: P } = ee();
44
44
  if (w || R) return /* @__PURE__ */ e(A, {});
45
- if (O)
46
- return O(c, N);
47
- switch (b) {
45
+ switch (O && (k, O(c, N)), b) {
48
46
  case "text":
49
47
  case "email":
50
48
  case "password": {
@@ -70,7 +68,15 @@ function He(N) {
70
68
  ) });
71
69
  }
72
70
  case "number": {
73
- const { onChange: t, placeholder: a, allowMinus: d, min: g, max: o, addonAfter: T, addonBefore: v } = l;
71
+ const {
72
+ onChange: t,
73
+ placeholder: a,
74
+ allowMinus: d,
75
+ min: g,
76
+ max: o,
77
+ addonAfter: T,
78
+ addonBefore: v
79
+ } = l;
74
80
  return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
75
81
  oe,
76
82
  {
@@ -327,7 +333,10 @@ function ce(N) {
327
333
  onSet: a,
328
334
  placeholder: d,
329
335
  allowClear: g = !0
330
- } = N, o = N.form, [T, v] = _(""), x = $(() => z.getRealName(c), [c]), n = $(() => z.getRealName(c, "upsertFieldName"), [c]), F = j.useWatch(x, o), [H, S] = _(!0);
336
+ } = N, o = N.form, [T, v] = _(""), x = $(() => z.getRealName(c), [c]), n = $(
337
+ () => z.getRealName(c, "upsertFieldName"),
338
+ [c]
339
+ ), F = j.useWatch(x, o), [H, S] = _(!0);
331
340
  I(() => {
332
341
  a && H && F && (a == null || a(F, i, o), S(!1));
333
342
  }, [H, o, i, x, a, F]), I(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.10.2",
4
+ "version": "1.10.3",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",