@kingteza/crud-component 1.10.2 → 1.10.4

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"),z=require("react-highlight-words"),J=require("../locale/index.cjs.js"),K=require("./FileCrudField.cjs.js"),Q=require("./ImageCrudField.cjs.js"),X=require("../common/check-box/CheckBox.cjs.js"),Y=require("../common/date-picker/DatePicker.cjs.js"),Z=require("../common/date-picker/TimePicker.cjs.js"),U=require("../common/select/SelectComponent.cjs.js"),V=require("../common/text-field/NumberField.cjs.js"),ee=require("../common/text-field/TextField.cjs.js"),re=require("../common/tooltip/TooltipComponent.cjs.js"),le=require("./CrudTextAreaComponent.cjs.js"),M=require("../util/CrudUtil.cjs.js"),y=require("../common/error/ErrorBoundaryComponent.cjs.js");function ne(k){const{label:i,name:m,type:C,required:c,hidden:B,rules:p=[],updatable:f=!0,readonly:q=!1,fieldClassName:j,customFormFieldRender:R,fieldTooltip:F,fieldHelper:x,...r}=k,u=v.Form.useFormInstance();t.useEffect(()=>{if(C==="select"){const{items:a=[],onSearch:n,searchOnType:d}=r;!(a!=null&&a.length)&&!d&&(n==null||n(void 0,u,r==null?void 0:r.updatingValue))}},[u,r,C,r==null?void 0:r.updatingValue]);const{t:H}=J.useTranslationLibNoNS();if(q||B)return e.jsx(e.Fragment,{});if(R)return e.jsx(t.Suspense,{fallback:null,children:R(u,k)});switch(C){case"text":case"email":case"password":{const{onChange:a,placeholder:n,addonAfter:d,addonBefore:g}=r;return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(ee.default,{placeholder:n,disabled:!f,rules:p,required:c,onChange:a?o=>a(o,u):void 0,type:C,name:m,tooltip:F,label:i,className:j,autoComplete:"new-password",addonAfter:d,addonBefore:g,help:x})})})}case"number":{const{onChange:a,placeholder:n,allowMinus:d,min:g,max:o,addonAfter:T,addonBefore:b}=r;return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(V,{placeholder:n,disabled:!f,moneyField:!!r.formatted,type:C,onChange:a?S=>a(S,u):void 0,rules:p,autoComplete:"false",required:c,tooltip:F,className:j,min:d?null:g,max:o,addonAfter:T,addonBefore:b,name:m,label:i,help:x})})})}case"date":{const{range:a,disableToday:n,disabledFutureDays:d,disabledPastDays:g,onChange:o,placeholder:T,format:b}=r;return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(Y,{placeholder:T,required:c,disabled:!f,type:C,format:b,tooltip:F,range:a,name:m,label:i,onChange:o?S=>o(S,u):void 0,className:j,disableToday:n,disabledFutureDays:d,disabledPastDays:g,help:x})})})}case"time":{const{range:a=!1,disableCurrent:n,disabledFuture:d,disabledPast:g,onChange:o,use12Hours:T,format:b,placeholder:S}=r;return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(Z,{placeholder:S,required:c,format:b,disabled:!f,type:C,tooltip:F,range:a,use12Hours:T,name:m,label:i,onChange:o?s=>o(s,u):void 0,className:j,disableCurrent:n,disabledFuture:d,disabledPast:g,help:x})})})}case"textarea":return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(le,{...k})})});case"image":return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(Q.default,{...r,required:c,name:m,label:i,rules:p,fieldHelper:x,fieldClassName:j,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider})})});case"file":return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(K.default,{...r,required:c,name:m,label:i,rules:p,fieldHelper:x,fieldClassName:j,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider})})});case"select":return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(D,{...r,required:c,name:m,label:i,rules:p,fieldClassName:j,form:u,help:x,updatable:f,readonly:q,fieldTooltip:F,fieldHelper:x})})});case"enum":{const{enum:a,radio:n=!1,translation:d,onChange:g,onSearch:o,multiple:T,tagRender:b}=r,S=Array.isArray(a)?a:Object.keys(a);return n?e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(v.Form.Item,{...r,name:m,required:c,tooltip:F,rules:p,label:i,className:["w-100",j].join(" "),help:x,children:e.jsx(v.Radio.Group,{...r,onChange:g?s=>{var N;return g((N=s==null?void 0:s.target)==null?void 0:N.value,u)}:void 0,children:S.map(s=>e.jsx(v.Radio,{disabled:!f,value:s,children:d?H(d[s]):s},s))})})})}):e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(U,{...r,tagRender:typeof b=="function"?b:b?s=>{const{value:N,label:E}=s,w=b[N];return w?e.jsx(v.Tag,{color:w.color,children:E}):e.jsx(v.Tag,{children:E})}:void 0,onChange:g?s=>g(s,u):void 0,className:["w-100",j].join(" "),name:m,items:S,required:c,tooltip:F,rules:p,label:i,help:x,disabled:!f,onSearch:o?s=>o(s,u):void 0,allowClear:!0,mode:T?"multiple":void 0,itemBuilder:s=>e.jsx(v.Select.Option,{value:s,children:d?H(d[s]):s},s)})})})}case"checkbox":{const{onChange:a,switch:n}=r;return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(X,{className:j,rules:p,onChange:a?d=>a(d,u):void 0,label:i,tooltip:F,disabled:!f,name:m,help:x,switch:n})})})}case"color":return e.jsx(y.ErrorBoundaryComponent,{children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(_,{...r,type:"color",required:c,name:m,label:i,rules:p,fieldClassName:j,updatable:f,readonly:q,fieldTooltip:F,fieldHelper:x})})});default:return e.jsx(e.Fragment,{children:`${C} Not Implemented`})}}function D(k){const{items:i=[],loading:m,searchOnType:C,onSearch:c,multiple:B,onChange:p,highlightSearch:f,required:q,fieldClassName:j,rules:R,fieldTooltip:F,updatable:x,label:r,name:u,tagRender:H,updatingValue:a,onSet:n,placeholder:d,allowClear:g=!0}=k,o=k.form,[T,b]=t.useState(""),S=t.useMemo(()=>M.getRealName(u),[u]),s=t.useMemo(()=>M.getRealName(u,"upsertFieldName"),[u]),N=v.Form.useWatch(S,o),[E,w]=t.useState(!0);t.useEffect(()=>{n&&E&&N&&(n==null||n(N,i,o),w(!1))},[E,o,i,S,n,N]),t.useEffect(()=>{N&&w(!0)},[N]);const W=t.useCallback(async l=>{b(l),C&&(c==null||c(l,o,a))},[o,c,C,a]);return e.jsx(U,{...k,maxTagCount:"responsive",maxTagPlaceholder:l=>e.jsxs(re,{title:e.jsx(e.Fragment,{children:l.map(h=>e.jsxs(e.Fragment,{children:[h.label," ",e.jsx("br",{})]}))}),children:["+",l==null?void 0:l.length]}),placeholder:d,onSelect:l=>{n==null||n(l==null?void 0:l.key,i,o)},onChange:p?l=>{b(""),p(l,o)}:void 0,mode:B?"multiple":void 0,className:["w-100",j].join(" "),name:s,items:i,required:q,tooltip:F,tagRender:H,rules:R,disabled:!x,label:r,allowClear:g,onSearch:W,loading:m,filterOption:f?(l,h)=>{var O,P,A;try{const I=l.toLowerCase().split(/\s+/),G=((typeof(h==null?void 0:h.children)=="string"?h==null?void 0:h.children:(P=(O=h==null?void 0:h.children)==null?void 0:O.props)==null?void 0:P.textToHighlight)??"").toLowerCase(),$=(((A=h==null?void 0:h.value)==null?void 0:A.toString())??"").toLowerCase();return I.every(L=>G.indexOf(L)>=0||$.indexOf(L)>=0)}catch{return!0}}:void 0,itemBuilder:f?l=>{const h=l.value?String(l.value):void 0;return e.jsx(v.Select.Option,{value:l.key,title:h,disabled:l.disabled,children:e.jsx(z,{highlightClassName:"highlight-text",searchWords:(T??"").split(" "),autoEscape:!0,textToHighlight:h??""})},l.key)}:l=>e.jsx(v.Select.Option,{value:l.key,title:l.value,disabled:l.disabled,children:l.value},l.key)})}function _(k){const{required:i,fieldClassName:m,rules:C,fieldTooltip:c,updatable:B,label:p,name:f,fieldHelper:q}=k;return e.jsx(v.Form.Item,{label:p,name:f,required:i,rules:C,tooltip:c,help:q,children:e.jsx(v.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:m,disabled:!B,...k.innerProps})})}exports.ColorCrudFieldComponent=_;exports.SelectCrudFieldComponent=D;exports.default=ne;
@@ -1,173 +1,182 @@
1
- import { jsx as e, Fragment as A, jsxs as M } from "react/jsx-runtime";
2
- import { Form as j, Radio as W, Select as B, Tag as G, ColorPicker as Y } from "antd";
3
- import { useEffect as I, Suspense as k, useState as _, useMemo as $, useCallback as Z } from "react";
4
- import V from "react-highlight-words";
5
- import { useTranslationLibNoNS as ee } from "../locale/index.es.js";
6
- import le from "./FileCrudField.es.js";
7
- import re from "./ImageCrudField.es.js";
8
- import ae from "../common/check-box/CheckBox.es.js";
1
+ import { jsx as e, Fragment as B, jsxs as W } from "react/jsx-runtime";
2
+ import { Form as j, Radio as G, Select as I, Tag as _, ColorPicker as Z } from "antd";
3
+ import { useEffect as L, Suspense as k, useState as $, useMemo as z, useCallback as V } from "react";
4
+ import ee from "react-highlight-words";
5
+ import { useTranslationLibNoNS as le } from "../locale/index.es.js";
6
+ import re from "./FileCrudField.es.js";
7
+ import ae from "./ImageCrudField.es.js";
8
+ import ne from "../common/check-box/CheckBox.es.js";
9
9
  import te from "../common/date-picker/DatePicker.es.js";
10
- import ne from "../common/date-picker/TimePicker.es.js";
11
- import J from "../common/select/SelectComponent.es.js";
10
+ import ie from "../common/date-picker/TimePicker.es.js";
11
+ import K from "../common/select/SelectComponent.es.js";
12
12
  import oe from "../common/text-field/NumberField.es.js";
13
- import ie from "../common/text-field/TextField.es.js";
14
- import de from "../common/tooltip/TooltipComponent.es.js";
13
+ import de from "../common/text-field/TextField.es.js";
14
+ import ce from "../common/tooltip/TooltipComponent.es.js";
15
15
  import se from "./CrudTextAreaComponent.es.js";
16
- import z from "../util/CrudUtil.es.js";
17
- function He(N) {
16
+ import J from "../util/CrudUtil.es.js";
17
+ import { ErrorBoundaryComponent as y } from "../common/error/ErrorBoundaryComponent.es.js";
18
+ function Oe(F) {
18
19
  const {
19
- label: i,
20
+ label: o,
20
21
  name: m,
21
22
  type: b,
22
- required: s,
23
- hidden: R,
23
+ required: c,
24
+ hidden: H,
24
25
  rules: h = [],
25
26
  updatable: f = !0,
26
- readonly: w = !1,
27
+ readonly: R = !1,
27
28
  fieldClassName: C,
28
- customFormFieldRender: O,
29
- fieldTooltip: y,
29
+ customFormFieldRender: P,
30
+ fieldTooltip: x,
30
31
  fieldHelper: p,
31
32
  ...l
32
- } = N, c = j.useFormInstance();
33
- I(() => {
33
+ } = F, s = j.useFormInstance();
34
+ L(() => {
34
35
  if (b === "select") {
35
36
  const {
36
- items: t = [],
37
+ items: n = [],
37
38
  onSearch: a,
38
39
  searchOnType: d
39
40
  } = l;
40
- !(t != null && t.length) && !d && (a == null || a(void 0, c, l == null ? void 0 : l.updatingValue));
41
+ !(n != null && n.length) && !d && (a == null || a(void 0, s, l == null ? void 0 : l.updatingValue));
41
42
  }
42
- }, [c, l, b, l == null ? void 0 : l.updatingValue]);
43
- const { t: P } = ee();
44
- if (w || R) return /* @__PURE__ */ e(A, {});
45
- if (O)
46
- return O(c, N);
43
+ }, [s, l, b, l == null ? void 0 : l.updatingValue]);
44
+ const { t: A } = le();
45
+ if (R || H) return /* @__PURE__ */ e(B, {});
46
+ if (P)
47
+ return /* @__PURE__ */ e(k, { fallback: null, children: P(s, F) });
47
48
  switch (b) {
48
49
  case "text":
49
50
  case "email":
50
51
  case "password": {
51
- const { onChange: t, placeholder: a, addonAfter: d, addonBefore: g } = l;
52
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
53
- ie,
52
+ const { onChange: n, placeholder: a, addonAfter: d, addonBefore: g } = l;
53
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
54
+ de,
54
55
  {
55
56
  placeholder: a,
56
57
  disabled: !f,
57
58
  rules: h,
58
- required: s,
59
- onChange: t ? (o) => t(o, c) : void 0,
59
+ required: c,
60
+ onChange: n ? (i) => n(i, s) : void 0,
60
61
  type: b,
61
62
  name: m,
62
- tooltip: y,
63
- label: i,
63
+ tooltip: x,
64
+ label: o,
64
65
  className: C,
65
66
  autoComplete: "new-password",
66
67
  addonAfter: d,
67
68
  addonBefore: g,
68
69
  help: p
69
70
  }
70
- ) });
71
+ ) }) });
71
72
  }
72
73
  case "number": {
73
- const { onChange: t, placeholder: a, allowMinus: d, min: g, max: o, addonAfter: T, addonBefore: v } = l;
74
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
74
+ const {
75
+ onChange: n,
76
+ placeholder: a,
77
+ allowMinus: d,
78
+ min: g,
79
+ max: i,
80
+ addonAfter: w,
81
+ addonBefore: v
82
+ } = l;
83
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
75
84
  oe,
76
85
  {
77
86
  placeholder: a,
78
87
  disabled: !f,
79
88
  moneyField: !!l.formatted,
80
89
  type: b,
81
- onChange: t ? (x) => t(x, c) : void 0,
90
+ onChange: n ? (N) => n(N, s) : void 0,
82
91
  rules: h,
83
92
  autoComplete: "false",
84
- required: s,
85
- tooltip: y,
93
+ required: c,
94
+ tooltip: x,
86
95
  className: C,
87
96
  min: d ? null : g,
88
- max: o,
89
- addonAfter: T,
97
+ max: i,
98
+ addonAfter: w,
90
99
  addonBefore: v,
91
100
  name: m,
92
- label: i,
101
+ label: o,
93
102
  help: p
94
103
  }
95
- ) });
104
+ ) }) });
96
105
  }
97
106
  case "date": {
98
107
  const {
99
- range: t,
108
+ range: n,
100
109
  disableToday: a,
101
110
  disabledFutureDays: d,
102
111
  disabledPastDays: g,
103
- onChange: o,
104
- placeholder: T,
112
+ onChange: i,
113
+ placeholder: w,
105
114
  format: v
106
115
  } = l;
107
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
116
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
108
117
  te,
109
118
  {
110
- placeholder: T,
111
- required: s,
119
+ placeholder: w,
120
+ required: c,
112
121
  disabled: !f,
113
122
  type: b,
114
123
  format: v,
115
- tooltip: y,
116
- range: t,
124
+ tooltip: x,
125
+ range: n,
117
126
  name: m,
118
- label: i,
119
- onChange: o ? (x) => o(x, c) : void 0,
127
+ label: o,
128
+ onChange: i ? (N) => i(N, s) : void 0,
120
129
  className: C,
121
130
  disableToday: a,
122
131
  disabledFutureDays: d,
123
132
  disabledPastDays: g,
124
133
  help: p
125
134
  }
126
- ) });
135
+ ) }) });
127
136
  }
128
137
  case "time": {
129
138
  const {
130
- range: t = !1,
139
+ range: n = !1,
131
140
  disableCurrent: a,
132
141
  disabledFuture: d,
133
142
  disabledPast: g,
134
- onChange: o,
135
- use12Hours: T,
143
+ onChange: i,
144
+ use12Hours: w,
136
145
  format: v,
137
- placeholder: x
146
+ placeholder: N
138
147
  } = l;
139
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
140
- ne,
148
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
149
+ ie,
141
150
  {
142
- placeholder: x,
143
- required: s,
151
+ placeholder: N,
152
+ required: c,
144
153
  format: v,
145
154
  disabled: !f,
146
155
  type: b,
147
- tooltip: y,
148
- range: t,
149
- use12Hours: T,
156
+ tooltip: x,
157
+ range: n,
158
+ use12Hours: w,
150
159
  name: m,
151
- label: i,
152
- onChange: o ? (n) => o(n, c) : void 0,
160
+ label: o,
161
+ onChange: i ? (t) => i(t, s) : void 0,
153
162
  className: C,
154
163
  disableCurrent: a,
155
164
  disabledFuture: d,
156
165
  disabledPast: g,
157
166
  help: p
158
167
  }
159
- ) });
168
+ ) }) });
160
169
  }
161
170
  case "textarea":
162
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(se, { ...N }) });
171
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(se, { ...F }) }) });
163
172
  case "image":
164
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
165
- re,
173
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
174
+ ae,
166
175
  {
167
176
  ...l,
168
- required: s,
177
+ required: c,
169
178
  name: m,
170
- label: i,
179
+ label: o,
171
180
  rules: h,
172
181
  fieldHelper: p,
173
182
  fieldClassName: C,
@@ -175,15 +184,15 @@ function He(N) {
175
184
  onUploading: l.onUploading,
176
185
  provider: l.provider
177
186
  }
178
- ) });
187
+ ) }) });
179
188
  case "file":
180
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
181
- le,
189
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
190
+ re,
182
191
  {
183
192
  ...l,
184
- required: s,
193
+ required: c,
185
194
  name: m,
186
- label: i,
195
+ label: o,
187
196
  rules: h,
188
197
  fieldHelper: p,
189
198
  fieldClassName: C,
@@ -191,163 +200,166 @@ function He(N) {
191
200
  onUploading: l.onUploading,
192
201
  provider: l.provider
193
202
  }
194
- ) });
203
+ ) }) });
195
204
  case "select":
196
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
197
- ce,
205
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
206
+ ue,
198
207
  {
199
208
  ...l,
200
- required: s,
209
+ required: c,
201
210
  name: m,
202
- label: i,
211
+ label: o,
203
212
  rules: h,
204
213
  fieldClassName: C,
205
- form: c,
214
+ form: s,
206
215
  help: p,
207
216
  updatable: f,
208
- readonly: w,
209
- fieldTooltip: y,
217
+ readonly: R,
218
+ fieldTooltip: x,
210
219
  fieldHelper: p
211
220
  }
212
- ) });
221
+ ) }) });
213
222
  case "enum": {
214
223
  const {
215
- enum: t,
224
+ enum: n,
216
225
  radio: a = !1,
217
226
  translation: d,
218
227
  onChange: g,
219
- onSearch: o,
220
- multiple: T,
228
+ onSearch: i,
229
+ multiple: w,
221
230
  tagRender: v
222
- } = l, x = Array.isArray(t) ? t : Object.keys(t);
223
- return a ? /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
231
+ } = l, N = Array.isArray(n) ? n : Object.keys(n);
232
+ return a ? /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
224
233
  j.Item,
225
234
  {
226
235
  ...l,
227
236
  name: m,
228
- required: s,
229
- tooltip: y,
237
+ required: c,
238
+ tooltip: x,
230
239
  rules: h,
231
- label: i,
240
+ label: o,
232
241
  className: ["w-100", C].join(" "),
233
242
  help: p,
234
243
  children: /* @__PURE__ */ e(
235
- W.Group,
244
+ G.Group,
236
245
  {
237
246
  ...l,
238
- onChange: g ? (n) => {
239
- var F;
240
- return g((F = n == null ? void 0 : n.target) == null ? void 0 : F.value, c);
247
+ onChange: g ? (t) => {
248
+ var T;
249
+ return g((T = t == null ? void 0 : t.target) == null ? void 0 : T.value, s);
241
250
  } : void 0,
242
- children: x.map((n) => /* @__PURE__ */ e(W, { disabled: !f, value: n, children: d ? P(d[n]) : n }, n))
251
+ children: N.map((t) => /* @__PURE__ */ e(G, { disabled: !f, value: t, children: d ? A(d[t]) : t }, t))
243
252
  }
244
253
  )
245
254
  }
246
- ) }) : /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
247
- J,
255
+ ) }) }) : /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
256
+ K,
248
257
  {
249
258
  ...l,
250
- tagRender: typeof v == "function" ? v : v ? (n) => {
251
- const { value: F, label: H } = n, S = v[F];
252
- return S ? /* @__PURE__ */ e(G, { color: S.color, children: H }) : /* @__PURE__ */ e(G, { children: H });
259
+ tagRender: typeof v == "function" ? v : v ? (t) => {
260
+ const { value: T, label: S } = t, O = v[T];
261
+ return O ? /* @__PURE__ */ e(_, { color: O.color, children: S }) : /* @__PURE__ */ e(_, { children: S });
253
262
  } : void 0,
254
- onChange: g ? (n) => g(n, c) : void 0,
263
+ onChange: g ? (t) => g(t, s) : void 0,
255
264
  className: ["w-100", C].join(" "),
256
265
  name: m,
257
- items: x,
258
- required: s,
259
- tooltip: y,
266
+ items: N,
267
+ required: c,
268
+ tooltip: x,
260
269
  rules: h,
261
- label: i,
270
+ label: o,
262
271
  help: p,
263
272
  disabled: !f,
264
- onSearch: o ? (n) => o(n, c) : void 0,
273
+ onSearch: i ? (t) => i(t, s) : void 0,
265
274
  allowClear: !0,
266
- mode: T ? "multiple" : void 0,
267
- itemBuilder: (n) => /* @__PURE__ */ e(B.Option, { value: n, children: d ? P(d[n]) : n }, n)
275
+ mode: w ? "multiple" : void 0,
276
+ itemBuilder: (t) => /* @__PURE__ */ e(I.Option, { value: t, children: d ? A(d[t]) : t }, t)
268
277
  }
269
- ) });
278
+ ) }) });
270
279
  }
271
280
  case "checkbox": {
272
- const { onChange: t, switch: a } = l;
273
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
274
- ae,
281
+ const { onChange: n, switch: a } = l;
282
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
283
+ ne,
275
284
  {
276
285
  className: C,
277
286
  rules: h,
278
- onChange: t ? (d) => t(d, c) : void 0,
279
- label: i,
280
- tooltip: y,
287
+ onChange: n ? (d) => n(d, s) : void 0,
288
+ label: o,
289
+ tooltip: x,
281
290
  disabled: !f,
282
291
  name: m,
283
292
  help: p,
284
293
  switch: a
285
294
  }
286
- ) });
295
+ ) }) });
287
296
  }
288
297
  case "color":
289
- return /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
290
- ue,
298
+ return /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { fallback: null, children: /* @__PURE__ */ e(
299
+ me,
291
300
  {
292
301
  ...l,
293
302
  type: "color",
294
- required: s,
303
+ required: c,
295
304
  name: m,
296
- label: i,
305
+ label: o,
297
306
  rules: h,
298
307
  fieldClassName: C,
299
308
  updatable: f,
300
- readonly: w,
301
- fieldTooltip: y,
309
+ readonly: R,
310
+ fieldTooltip: x,
302
311
  fieldHelper: p
303
312
  }
304
- ) });
313
+ ) }) });
305
314
  default:
306
- return /* @__PURE__ */ e(A, { children: `${b} Not Implemented` });
315
+ return /* @__PURE__ */ e(B, { children: `${b} Not Implemented` });
307
316
  }
308
317
  }
309
- function ce(N) {
318
+ function ue(F) {
310
319
  const {
311
- items: i = [],
320
+ items: o = [],
312
321
  loading: m,
313
322
  searchOnType: b,
314
- onSearch: s,
315
- multiple: R,
323
+ onSearch: c,
324
+ multiple: H,
316
325
  onChange: h,
317
326
  highlightSearch: f,
318
- required: w,
327
+ required: R,
319
328
  fieldClassName: C,
320
- rules: O,
321
- fieldTooltip: y,
329
+ rules: P,
330
+ fieldTooltip: x,
322
331
  updatable: p,
323
332
  label: l,
324
- name: c,
325
- tagRender: P,
326
- updatingValue: t,
333
+ name: s,
334
+ tagRender: A,
335
+ updatingValue: n,
327
336
  onSet: a,
328
337
  placeholder: d,
329
338
  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);
331
- I(() => {
332
- a && H && F && (a == null || a(F, i, o), S(!1));
333
- }, [H, o, i, x, a, F]), I(() => {
334
- F && S(!0);
335
- }, [F]);
336
- const K = Z(
339
+ } = F, i = F.form, [w, v] = $(""), N = z(() => J.getRealName(s), [s]), t = z(
340
+ () => J.getRealName(s, "upsertFieldName"),
341
+ [s]
342
+ ), T = j.useWatch(N, i), [S, O] = $(!0);
343
+ L(() => {
344
+ a && S && T && (a == null || a(T, o, i), O(!1));
345
+ }, [S, i, o, N, a, T]), L(() => {
346
+ T && O(!0);
347
+ }, [T]);
348
+ const Q = V(
337
349
  async (r) => {
338
- v(r), b && (s == null || s(r, o, t));
350
+ v(r), b && (c == null || c(r, i, n));
339
351
  },
340
- [o, s, b, t]
352
+ [i, c, b, n]
341
353
  );
342
354
  return /* @__PURE__ */ e(
343
- J,
355
+ K,
344
356
  {
345
- ...N,
357
+ ...F,
346
358
  maxTagCount: "responsive",
347
- maxTagPlaceholder: (r) => /* @__PURE__ */ M(
348
- de,
359
+ maxTagPlaceholder: (r) => /* @__PURE__ */ W(
360
+ ce,
349
361
  {
350
- title: /* @__PURE__ */ e(A, { children: r.map((u) => /* @__PURE__ */ M(A, { children: [
362
+ title: /* @__PURE__ */ e(B, { children: r.map((u) => /* @__PURE__ */ W(B, { children: [
351
363
  u.label,
352
364
  " ",
353
365
  /* @__PURE__ */ e("br", {})
@@ -360,30 +372,30 @@ function ce(N) {
360
372
  ),
361
373
  placeholder: d,
362
374
  onSelect: (r) => {
363
- a == null || a(r == null ? void 0 : r.key, i, o);
375
+ a == null || a(r == null ? void 0 : r.key, o, i);
364
376
  },
365
377
  onChange: h ? (r) => {
366
- v(""), h(r, o);
378
+ v(""), h(r, i);
367
379
  } : void 0,
368
- mode: R ? "multiple" : void 0,
380
+ mode: H ? "multiple" : void 0,
369
381
  className: ["w-100", C].join(" "),
370
- name: n,
371
- items: i,
372
- required: w,
373
- tooltip: y,
374
- tagRender: P,
375
- rules: O,
382
+ name: t,
383
+ items: o,
384
+ required: R,
385
+ tooltip: x,
386
+ tagRender: A,
387
+ rules: P,
376
388
  disabled: !p,
377
389
  label: l,
378
390
  allowClear: g,
379
- onSearch: K,
391
+ onSearch: Q,
380
392
  loading: m,
381
393
  filterOption: f ? (r, u) => {
382
- var L, U, q;
394
+ var U, q, D;
383
395
  try {
384
- const D = r.toLowerCase().split(/\s+/), Q = ((typeof (u == null ? void 0 : u.children) == "string" ? u == null ? void 0 : u.children : (U = (L = u == null ? void 0 : u.children) == null ? void 0 : L.props) == null ? void 0 : U.textToHighlight) ?? "").toLowerCase(), X = (((q = u == null ? void 0 : u.value) == null ? void 0 : q.toString()) ?? "").toLowerCase();
385
- return D.every(
386
- (E) => Q.indexOf(E) >= 0 || X.indexOf(E) >= 0
396
+ const E = r.toLowerCase().split(/\s+/), X = ((typeof (u == null ? void 0 : u.children) == "string" ? u == null ? void 0 : u.children : (q = (U = u == null ? void 0 : u.children) == null ? void 0 : U.props) == null ? void 0 : q.textToHighlight) ?? "").toLowerCase(), Y = (((D = u == null ? void 0 : u.value) == null ? void 0 : D.toString()) ?? "").toLowerCase();
397
+ return E.every(
398
+ (M) => X.indexOf(M) >= 0 || Y.indexOf(M) >= 0
387
399
  );
388
400
  } catch {
389
401
  return !0;
@@ -392,16 +404,16 @@ function ce(N) {
392
404
  itemBuilder: f ? (r) => {
393
405
  const u = r.value ? String(r.value) : void 0;
394
406
  return /* @__PURE__ */ e(
395
- B.Option,
407
+ I.Option,
396
408
  {
397
409
  value: r.key,
398
410
  title: u,
399
411
  disabled: r.disabled,
400
412
  children: /* @__PURE__ */ e(
401
- V,
413
+ ee,
402
414
  {
403
415
  highlightClassName: "highlight-text",
404
- searchWords: (T ?? "").split(" "),
416
+ searchWords: (w ?? "").split(" "),
405
417
  autoEscape: !0,
406
418
  textToHighlight: u ?? ""
407
419
  }
@@ -410,7 +422,7 @@ function ce(N) {
410
422
  r.key
411
423
  );
412
424
  } : (r) => /* @__PURE__ */ e(
413
- B.Option,
425
+ I.Option,
414
426
  {
415
427
  value: r.key,
416
428
  title: r.value,
@@ -422,28 +434,28 @@ function ce(N) {
422
434
  }
423
435
  );
424
436
  }
425
- function ue(N) {
437
+ function me(F) {
426
438
  const {
427
- required: i,
439
+ required: o,
428
440
  fieldClassName: m,
429
441
  rules: b,
430
- fieldTooltip: s,
431
- updatable: R,
442
+ fieldTooltip: c,
443
+ updatable: H,
432
444
  label: h,
433
445
  name: f,
434
- fieldHelper: w
435
- } = N;
446
+ fieldHelper: R
447
+ } = F;
436
448
  return /* @__PURE__ */ e(
437
449
  j.Item,
438
450
  {
439
451
  label: h,
440
452
  name: f,
441
- required: i,
453
+ required: o,
442
454
  rules: b,
443
- tooltip: s,
444
- help: w,
455
+ tooltip: c,
456
+ help: R,
445
457
  children: /* @__PURE__ */ e(
446
- Y,
458
+ Z,
447
459
  {
448
460
  disabledAlpha: !0,
449
461
  format: "hex",
@@ -451,15 +463,15 @@ function ue(N) {
451
463
  showText: !0,
452
464
  trigger: "click",
453
465
  className: m,
454
- disabled: !R,
455
- ...N.innerProps
466
+ disabled: !H,
467
+ ...F.innerProps
456
468
  }
457
469
  )
458
470
  }
459
471
  );
460
472
  }
461
473
  export {
462
- ue as ColorCrudFieldComponent,
463
- ce as SelectCrudFieldComponent,
464
- He as default
474
+ me as ColorCrudFieldComponent,
475
+ ue as SelectCrudFieldComponent,
476
+ Oe as default
465
477
  };
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.4",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",