@kingteza/crud-component 1.3.0 → 1.4.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 e=require("react/jsx-runtime"),l=require("antd"),t=require("react"),H=require("./modal/index.cjs.js"),J=require("./import/CrudImportButton.cjs.js"),K=require("./view/CrudViewer.cjs.js"),L=require("../common/button/NewButton.cjs.js"),M=require("../common/button/PrintButton.cjs.js"),{useForm:Q}=l.Form;function O({idField:a="id",onCreate:C,onDelete:j,onHide:m,onUpdate:n,fields:r,data:f,grid:k,isHiding:q,isCreating:h,isDeleting:p,isUpdating:B,paginateProps:w,onPrint:i,printing:N,viewable:v,loadingData:R,formBuilder:g,extraAction:y,minusHeight:b,cloneable:F,fullWidthModal:P=!0,wizard:S,extraView:I,importable:u,onClickNew:d,size:V,...z}){const c=t.useRef(null),A=t.useCallback(()=>{var s;(s=c.current)==null||s.create()},[]),o=t.useCallback(async(s,E=!0,G=!1)=>{var x;await((x=c.current)==null?void 0:x.update(s,E,G))},[]),D=t.useCallback(async s=>{o(s,!1,!0)},[o]);return e.jsxs(e.Fragment,{children:[e.jsxs(l.Space,{direction:"vertical",className:"w-100",children:[e.jsxs("div",{className:"w-100 d-flex",children:[e.jsx("div",{style:{flex:1},children:e.jsx(L.NewButton,{onClick:()=>{d?d():A()},className:"flex-1"})}),e.jsxs(l.Space,{children:[!!i&&e.jsx(M.PrintButton,{className:"float-right",loading:N,onClick:i}),!!u&&e.jsx(J,{fields:r,importProps:u})]})]}),e.jsx(K,{...z,minusHeight:b,data:f,size:V,fields:r,extraAction:y,idField:a,isDeleting:p,loadingData:R,onClickUpdate:n?o:void 0,onHide:m,isHiding:q,onDelete:j,onUpdate:n,onClickClone:F?D:void 0,paginateProps:w,viewable:v,extraView:I})]}),e.jsx(H,{ref:c,fields:r,wizard:S,grid:k,fullWidthModal:P,isCreating:h,isUpdating:B,onCreate:C,onUpdate:n,idField:a,formBuilder:g})]})}module.exports=O;
1
+ "use strict";const e=require("react/jsx-runtime"),x=require("antd"),t=require("react"),H=require("./modal/index.cjs.js"),J=require("./import/CrudImportButton.cjs.js"),K=require("./view/CrudViewer.cjs.js"),L=require("../common/button/NewButton.cjs.js"),M=require("../common/button/PrintButton.cjs.js");function O({idField:l="id",onCreate:C,onDelete:j,onHide:f,onUpdate:n,fields:r,data:m,grid:k,isHiding:q,isCreating:h,isDeleting:p,isUpdating:B,paginateProps:w,onPrint:a,printing:N,viewable:v,loadingData:R,formBuilder:g,extraAction:y,minusHeight:b,cloneable:P,fullWidthModal:S=!0,wizard:I,extraView:V,importable:i,onClickNew:u,size:z,...A}){const c=t.useRef(null),D=t.useCallback(()=>{var s;(s=c.current)==null||s.create()},[]),o=t.useCallback(async(s,F=!0,G=!1)=>{var d;await((d=c.current)==null?void 0:d.update(s,F,G))},[]),E=t.useCallback(async s=>{o(s,!1,!0)},[o]);return e.jsxs(e.Fragment,{children:[e.jsxs(x.Space,{direction:"vertical",className:"w-100",children:[e.jsxs("div",{className:"w-100 d-flex",children:[e.jsx("div",{style:{flex:1},children:e.jsx(L.NewButton,{onClick:()=>{u?u():D()},className:"flex-1"})}),e.jsxs(x.Space,{children:[!!a&&e.jsx(M.PrintButton,{className:"float-right",loading:N,onClick:a}),!!i&&e.jsx(J,{fields:r,importProps:i})]})]}),e.jsx(K,{...A,minusHeight:b,data:m,size:z,fields:r,extraAction:y,idField:l,isDeleting:p,loadingData:R,onClickUpdate:n?o:void 0,onHide:f,isHiding:q,onDelete:j,onUpdate:n,onClickClone:P?E:void 0,paginateProps:w,viewable:v,extraView:V})]}),e.jsx(H,{ref:c,fields:r,wizard:I,grid:k,fullWidthModal:S,isCreating:h,isUpdating:B,onCreate:C,onUpdate:n,idField:l,formBuilder:g})]})}module.exports=O;
@@ -140,6 +140,7 @@ export interface ColorPickerFieldProps<T> extends Omit<InitialCrudField<T>, "pla
140
140
  export interface CheckboxBasedFieldProps<T> extends InitialCrudField<T> {
141
141
  type: "checkbox";
142
142
  onChange?: (value: boolean, form: FormInstance<T>) => void;
143
+ switch?: boolean;
143
144
  }
144
145
  export interface NumberBasedFieldProps<T> extends InitialCrudField<T>, AddonFieldProps {
145
146
  type: "number";
@@ -1,19 +1,18 @@
1
1
  import { jsxs as e, Fragment as H, jsx as r } from "react/jsx-runtime";
2
- import { Space as f, Form as J } from "antd";
3
- import { useRef as K, useCallback as c } from "react";
4
- import L from "./modal/index.es.js";
5
- import O from "./import/CrudImportButton.es.js";
6
- import Q from "./view/CrudViewer.es.js";
7
- import { NewButton as T } from "../common/button/NewButton.es.js";
8
- import { PrintButton as U } from "../common/button/PrintButton.es.js";
9
- const { useForm: eo } = J;
10
- function to({
2
+ import { Space as f } from "antd";
3
+ import { useRef as J, useCallback as c } from "react";
4
+ import K from "./modal/index.es.js";
5
+ import L from "./import/CrudImportButton.es.js";
6
+ import O from "./view/CrudViewer.es.js";
7
+ import { NewButton as Q } from "../common/button/NewButton.es.js";
8
+ import { PrintButton as T } from "../common/button/PrintButton.es.js";
9
+ function ro({
11
10
  idField: i = "id",
12
11
  onCreate: p,
13
12
  onDelete: C,
14
13
  onHide: h,
15
14
  onUpdate: t,
16
- fields: n,
15
+ fields: l,
17
16
  data: k,
18
17
  grid: x,
19
18
  isHiding: v,
@@ -24,29 +23,29 @@ function to({
24
23
  onPrint: m,
25
24
  printing: y,
26
25
  viewable: j,
27
- loadingData: F,
28
- formBuilder: R,
29
- extraAction: I,
30
- minusHeight: M,
31
- cloneable: P,
32
- fullWidthModal: S = !0,
33
- wizard: V,
34
- extraView: b,
26
+ loadingData: R,
27
+ formBuilder: I,
28
+ extraAction: M,
29
+ minusHeight: P,
30
+ cloneable: S,
31
+ fullWidthModal: V = !0,
32
+ wizard: b,
33
+ extraView: q,
35
34
  importable: s,
36
35
  onClickNew: u,
37
- size: q,
38
- ...z
36
+ size: z,
37
+ ...A
39
38
  }) {
40
- const l = K(null), A = c(() => {
39
+ const n = J(null), D = c(() => {
41
40
  var o;
42
- (o = l.current) == null || o.create();
41
+ (o = n.current) == null || o.create();
43
42
  }, []), a = c(
44
- async (o, E = !0, G = !1) => {
43
+ async (o, F = !0, G = !1) => {
45
44
  var d;
46
- await ((d = l.current) == null ? void 0 : d.update(o, E, G));
45
+ await ((d = n.current) == null ? void 0 : d.update(o, F, G));
47
46
  },
48
47
  []
49
- ), D = c(
48
+ ), E = c(
50
49
  async (o) => {
51
50
  a(o, !1, !0);
52
51
  },
@@ -56,68 +55,68 @@ function to({
56
55
  /* @__PURE__ */ e(f, { direction: "vertical", className: "w-100", children: [
57
56
  /* @__PURE__ */ e("div", { className: "w-100 d-flex", children: [
58
57
  /* @__PURE__ */ r("div", { style: { flex: 1 }, children: /* @__PURE__ */ r(
59
- T,
58
+ Q,
60
59
  {
61
60
  onClick: () => {
62
- u ? u() : A();
61
+ u ? u() : D();
63
62
  },
64
63
  className: "flex-1"
65
64
  }
66
65
  ) }),
67
66
  /* @__PURE__ */ e(f, { children: [
68
67
  !!m && /* @__PURE__ */ r(
69
- U,
68
+ T,
70
69
  {
71
70
  className: "float-right",
72
71
  loading: y,
73
72
  onClick: m
74
73
  }
75
74
  ),
76
- !!s && /* @__PURE__ */ r(O, { fields: n, importProps: s })
75
+ !!s && /* @__PURE__ */ r(L, { fields: l, importProps: s })
77
76
  ] })
78
77
  ] }),
79
78
  /* @__PURE__ */ r(
80
- Q,
79
+ O,
81
80
  {
82
- ...z,
83
- minusHeight: M,
81
+ ...A,
82
+ minusHeight: P,
84
83
  data: k,
85
- size: q,
86
- fields: n,
87
- extraAction: I,
84
+ size: z,
85
+ fields: l,
86
+ extraAction: M,
88
87
  idField: i,
89
88
  isDeleting: B,
90
- loadingData: F,
89
+ loadingData: R,
91
90
  onClickUpdate: t ? a : void 0,
92
91
  onHide: h,
93
92
  isHiding: v,
94
93
  onDelete: C,
95
94
  onUpdate: t,
96
- onClickClone: P ? D : void 0,
95
+ onClickClone: S ? E : void 0,
97
96
  paginateProps: g,
98
97
  viewable: j,
99
- extraView: b
98
+ extraView: q
100
99
  }
101
100
  )
102
101
  ] }),
103
102
  /* @__PURE__ */ r(
104
- L,
103
+ K,
105
104
  {
106
- ref: l,
107
- fields: n,
108
- wizard: V,
105
+ ref: n,
106
+ fields: l,
107
+ wizard: b,
109
108
  grid: x,
110
- fullWidthModal: S,
109
+ fullWidthModal: V,
111
110
  isCreating: w,
112
111
  isUpdating: N,
113
112
  onCreate: p,
114
113
  onUpdate: t,
115
114
  idField: i,
116
- formBuilder: R
115
+ formBuilder: I
117
116
  }
118
117
  )
119
118
  ] });
120
119
  }
121
120
  export {
122
- to as default
121
+ ro as default
123
122
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),b=require("antd"),q=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"),re=require("./CrudTextAreaComponent.cjs.js"),M=require("../util/CrudUtil.cjs.js");function te(y){const{label:o,name:m,type:x,required:i,hidden:S,rules:h=[],updatable:g=!0,readonly:R=!1,fieldClassName:C,customFormFieldRender:O,fieldTooltip:j,fieldHelper:v,...r}=y,d=b.Form.useFormInstance();q.useEffect(()=>{if(x==="select"){const{items:a=[],onSearch:l,searchOnType:u}=r;!(a!=null&&a.length)&&!u&&(l==null||l(void 0,d,r==null?void 0:r.updatingValue))}},[d,r,x,r==null?void 0:r.updatingValue]);const{t:P}=z.useTranslationLibNoNS();if(R||S)return e.jsx(e.Fragment,{});if(O)return O(d,y);switch(x){case"text":case"email":case"password":{const{onChange:a,placeholder:l,addonAfter:u,addonBefore:f}=r;return e.jsx(V.default,{placeholder:l,disabled:!g,rules:h,required:i,onChange:a?s=>a(s,d):void 0,type:x,name:m,tooltip:j,label:o,className:C,autoComplete:"new-password",addonAfter:u,addonBefore:f,help:v})}case"number":{const{onChange:a,placeholder:l,allowMinus:u,min:f,max:s,addonAfter:T,addonBefore:p}=r;return e.jsx(Z,{placeholder:l,disabled:!g,moneyField:!!r.formatted,type:x,onChange:a?F=>a(F,d):void 0,rules:h,autoComplete:"false",required:i,tooltip:j,className:C,min:u?null:f,max:s,addonAfter:T,addonBefore:p,name:m,label:o,help:v})}case"date":{const{range:a,disableToday:l,disabledFutureDays:u,disabledPastDays:f,onChange:s,placeholder:T,format:p}=r;return e.jsx(X,{placeholder:T,required:i,disabled:!g,type:x,format:p,tooltip:j,range:a,name:m,label:o,onChange:s?F=>s(F,d):void 0,className:C,disableToday:l,disabledFutureDays:u,disabledPastDays:f,help:v})}case"time":{const{range:a=!1,disableCurrent:l,disabledFuture:u,disabledPast:f,onChange:s,use12Hours:T,format:p,placeholder:F}=r;return e.jsx(Y,{placeholder:F,required:i,format:p,disabled:!g,type:x,tooltip:j,range:a,use12Hours:T,name:m,label:o,onChange:s?n=>s(n,d):void 0,className:C,disableCurrent:l,disabledFuture:u,disabledPast:f,help:v})}case"textarea":return e.jsx(re,{...y});case"image":return e.jsx(K.default,{...r,required:i,name:m,label:o,rules:h,fieldClassName:C,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"file":return e.jsx(J.default,{...r,required:i,name:m,label:o,rules:h,fieldClassName:C,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"select":return e.jsx(E,{...r,required:i,name:m,label:o,rules:h,fieldClassName:C,form:d,updatable:g,readonly:R,fieldTooltip:j,fieldHelper:v});case"enum":{const{enum:a,radio:l=!1,translation:u,onChange:f,onSearch:s,multiple:T,tagRender:p}=r,F=Array.isArray(a)?a:Object.keys(a);return l?e.jsx(b.Form.Item,{...r,name:m,required:i,tooltip:j,rules:h,label:o,className:["w-100",C].join(" "),help:v,children:e.jsx(b.Radio.Group,{...r,onChange:f?n=>{var N;return f((N=n==null?void 0:n.target)==null?void 0:N.value,d)}:void 0,children:F.map(n=>e.jsx(b.Radio,{disabled:!g,value:n,children:u?P(u[n]):n},n))})}):e.jsx(U,{...r,tagRender:typeof p=="function"?p:p?n=>{const{value:N,label:w}=n,k=p[N];return k?e.jsx(b.Tag,{color:k.color,children:w}):e.jsx(b.Tag,{children:w})}:void 0,onChange:f?n=>f(n,d):void 0,className:["w-100",C].join(" "),name:m,items:F,required:i,tooltip:j,rules:h,label:o,help:v,disabled:!g,onSearch:s?n=>s(n,d):void 0,allowClear:!0,mode:T?"multiple":void 0,itemBuilder:n=>e.jsx(b.Select.Option,{value:n,children:u?P(u[n]):n},n)})}case"checkbox":{const{onChange:a}=r;return e.jsx(Q,{className:C,rules:h,onChange:a?l=>a(l,d):void 0,label:o,tooltip:j,disabled:!g,name:m,help:v})}case"color":return e.jsx(D,{...r,type:"color",required:i,name:m,label:o,rules:h,fieldClassName:C,updatable:g,readonly:R,fieldTooltip:j,fieldHelper:v});default:return e.jsx(e.Fragment,{children:`${x} Not Implemented`})}}function E(y){const{items:o=[],loading:m,searchOnType:x,onSearch:i,multiple:S,onChange:h,highlightSearch:g,required:R,fieldClassName:C,rules:O,fieldTooltip:j,updatable:v,label:r,name:d,tagRender:P,updatingValue:a,onSet:l,placeholder:u,allowClear:f=!0}=y,s=y.form,[T,p]=q.useState(""),F=q.useMemo(()=>M.getRealName(d),[d]),n=q.useMemo(()=>M.getRealName(d,"upsertFieldName"),[d]),N=b.Form.useWatch(F,s),[w,k]=q.useState(!0);q.useEffect(()=>{l&&w&&N&&(l==null||l(N,o,s),k(!1))},[w,s,o,F,l,N]),q.useEffect(()=>{N&&k(!0)},[N]);const _=q.useCallback(async t=>{p(t),x&&(i==null||i(t,s,a))},[s,i,x,a]);return e.jsx(U,{...y,maxTagCount:"responsive",maxTagPlaceholder:t=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:t.map(c=>e.jsxs(e.Fragment,{children:[c.label," ",e.jsx("br",{})]}))}),children:["+",t==null?void 0:t.length]}),placeholder:u,onSelect:t=>{l==null||l(t==null?void 0:t.key,o,s)},onChange:h?t=>{p(""),h(t,s)}:void 0,mode:S?"multiple":void 0,className:["w-100",C].join(" "),name:n,items:o,required:R,tooltip:j,tagRender:P,rules:O,disabled:!v,label:r,allowClear:f,onSearch:_,loading:m,filterOption:g?(t,c)=>{var H,A,B;try{const I=t.toLowerCase().split(/\s+/),W=((typeof(c==null?void 0:c.children)=="string"?c==null?void 0:c.children:(A=(H=c==null?void 0:c.children)==null?void 0:H.props)==null?void 0:A.textToHighlight)??"").toLowerCase(),G=(((B=c==null?void 0:c.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?t=>{const c=t.value?String(t.value):void 0;return e.jsx(b.Select.Option,{value:t.key,title:c,disabled:t.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(T??"").split(" "),autoEscape:!0,textToHighlight:c??""})},t.key)}:t=>e.jsx(b.Select.Option,{value:t.key,title:t.value,disabled:t.disabled,children:t.value},t.key)})}function D(y){const{required:o,fieldClassName:m,rules:x,fieldTooltip:i,updatable:S,label:h,name:g,fieldHelper:R}=y;return e.jsx(b.Form.Item,{label:h,name:g,required:o,rules:x,tooltip:i,help:R,children:e.jsx(b.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:m,disabled:!S,...y.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=E;exports.default=te;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),b=require("antd"),q=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"),te=require("./CrudTextAreaComponent.cjs.js"),M=require("../util/CrudUtil.cjs.js");function re(y){const{label:o,name:m,type:x,required:d,hidden:S,rules:h=[],updatable:g=!0,readonly:w=!1,fieldClassName:C,customFormFieldRender:O,fieldTooltip:j,fieldHelper:v,...t}=y,c=b.Form.useFormInstance();q.useEffect(()=>{if(x==="select"){const{items:l=[],onSearch:a,searchOnType:i}=t;!(l!=null&&l.length)&&!i&&(a==null||a(void 0,c,t==null?void 0:t.updatingValue))}},[c,t,x,t==null?void 0:t.updatingValue]);const{t:P}=z.useTranslationLibNoNS();if(w||S)return e.jsx(e.Fragment,{});if(O)return O(c,y);switch(x){case"text":case"email":case"password":{const{onChange:l,placeholder:a,addonAfter:i,addonBefore:f}=t;return e.jsx(V.default,{placeholder:a,disabled:!g,rules:h,required:d,onChange:l?s=>l(s,c):void 0,type:x,name:m,tooltip:j,label:o,className:C,autoComplete:"new-password",addonAfter:i,addonBefore:f,help:v})}case"number":{const{onChange:l,placeholder:a,allowMinus:i,min:f,max:s,addonAfter:T,addonBefore:p}=t;return e.jsx(Z,{placeholder:a,disabled:!g,moneyField:!!t.formatted,type:x,onChange:l?F=>l(F,c):void 0,rules:h,autoComplete:"false",required:d,tooltip:j,className:C,min:i?null:f,max:s,addonAfter:T,addonBefore:p,name:m,label:o,help:v})}case"date":{const{range:l,disableToday:a,disabledFutureDays:i,disabledPastDays:f,onChange:s,placeholder:T,format:p}=t;return e.jsx(X,{placeholder:T,required:d,disabled:!g,type:x,format:p,tooltip:j,range:l,name:m,label:o,onChange:s?F=>s(F,c):void 0,className:C,disableToday:a,disabledFutureDays:i,disabledPastDays:f,help:v})}case"time":{const{range:l=!1,disableCurrent:a,disabledFuture:i,disabledPast:f,onChange:s,use12Hours:T,format:p,placeholder:F}=t;return e.jsx(Y,{placeholder:F,required:d,format:p,disabled:!g,type:x,tooltip:j,range:l,use12Hours:T,name:m,label:o,onChange:s?n=>s(n,c):void 0,className:C,disableCurrent:a,disabledFuture:i,disabledPast:f,help:v})}case"textarea":return e.jsx(te,{...y});case"image":return e.jsx(K.default,{...t,required:d,name:m,label:o,rules:h,fieldClassName:C,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"file":return e.jsx(J.default,{...t,required:d,name:m,label:o,rules:h,fieldClassName:C,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"select":return e.jsx(E,{...t,required:d,name:m,label:o,rules:h,fieldClassName:C,form:c,updatable:g,readonly:w,fieldTooltip:j,fieldHelper:v});case"enum":{const{enum:l,radio:a=!1,translation:i,onChange:f,onSearch:s,multiple:T,tagRender:p}=t,F=Array.isArray(l)?l:Object.keys(l);return a?e.jsx(b.Form.Item,{...t,name:m,required:d,tooltip:j,rules:h,label:o,className:["w-100",C].join(" "),help:v,children:e.jsx(b.Radio.Group,{...t,onChange:f?n=>{var N;return f((N=n==null?void 0:n.target)==null?void 0:N.value,c)}:void 0,children:F.map(n=>e.jsx(b.Radio,{disabled:!g,value:n,children:i?P(i[n]):n},n))})}):e.jsx(U,{...t,tagRender:typeof p=="function"?p:p?n=>{const{value:N,label:R}=n,k=p[N];return k?e.jsx(b.Tag,{color:k.color,children:R}):e.jsx(b.Tag,{children:R})}:void 0,onChange:f?n=>f(n,c):void 0,className:["w-100",C].join(" "),name:m,items:F,required:d,tooltip:j,rules:h,label:o,help:v,disabled:!g,onSearch:s?n=>s(n,c):void 0,allowClear:!0,mode:T?"multiple":void 0,itemBuilder:n=>e.jsx(b.Select.Option,{value:n,children:i?P(i[n]):n},n)})}case"checkbox":{const{onChange:l,switch:a}=t;return e.jsx(Q,{className:C,rules:h,onChange:l?i=>l(i,c):void 0,label:o,tooltip:j,disabled:!g,name:m,help:v,switch:a})}case"color":return e.jsx(D,{...t,type:"color",required:d,name:m,label:o,rules:h,fieldClassName:C,updatable:g,readonly:w,fieldTooltip:j,fieldHelper:v});default:return e.jsx(e.Fragment,{children:`${x} Not Implemented`})}}function E(y){const{items:o=[],loading:m,searchOnType:x,onSearch:d,multiple:S,onChange:h,highlightSearch:g,required:w,fieldClassName:C,rules:O,fieldTooltip:j,updatable:v,label:t,name:c,tagRender:P,updatingValue:l,onSet:a,placeholder:i,allowClear:f=!0}=y,s=y.form,[T,p]=q.useState(""),F=q.useMemo(()=>M.getRealName(c),[c]),n=q.useMemo(()=>M.getRealName(c,"upsertFieldName"),[c]),N=b.Form.useWatch(F,s),[R,k]=q.useState(!0);q.useEffect(()=>{a&&R&&N&&(a==null||a(N,o,s),k(!1))},[R,s,o,F,a,N]),q.useEffect(()=>{N&&k(!0)},[N]);const _=q.useCallback(async r=>{p(r),x&&(d==null||d(r,s,l))},[s,d,x,l]);return e.jsx(U,{...y,maxTagCount:"responsive",maxTagPlaceholder:r=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:r.map(u=>e.jsxs(e.Fragment,{children:[u.label," ",e.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:i,onSelect:r=>{a==null||a(r==null?void 0:r.key,o,s)},onChange:h?r=>{p(""),h(r,s)}:void 0,mode:S?"multiple":void 0,className:["w-100",C].join(" "),name:n,items:o,required:w,tooltip:j,tagRender:P,rules:O,disabled:!v,label:t,allowClear:f,onSearch:_,loading:m,filterOption:g?(r,u)=>{var H,A,B;try{const I=r.toLowerCase().split(/\s+/),W=((typeof(u==null?void 0:u.children)=="string"?u==null?void 0:u.children:(A=(H=u==null?void 0:u.children)==null?void 0:H.props)==null?void 0:A.textToHighlight)??"").toLowerCase(),G=(((B=u==null?void 0:u.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 u=r.value?String(r.value):void 0;return e.jsx(b.Select.Option,{value:r.key,title:u,disabled:r.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(T??"").split(" "),autoEscape:!0,textToHighlight:u??""})},r.key)}:r=>e.jsx(b.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:r.value},r.key)})}function D(y){const{required:o,fieldClassName:m,rules:x,fieldTooltip:d,updatable:S,label:h,name:g,fieldHelper:w}=y;return e.jsx(b.Form.Item,{label:h,name:g,required:o,rules:x,tooltip:d,help:w,children:e.jsx(b.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:m,disabled:!S,...y.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=E;exports.default=re;
@@ -1,5 +1,5 @@
1
- import { jsx as t, Fragment as S, jsxs as E } from "react/jsx-runtime";
2
- import { Form as j, Radio as M, Select as A, Tag as W, ColorPicker as X } from "antd";
1
+ import { jsx as t, Fragment as P, jsxs as E } from "react/jsx-runtime";
2
+ import { Form as A, Radio as M, Select as j, Tag as W, ColorPicker as X } from "antd";
3
3
  import { useEffect as B, useState as G, useMemo as _, useCallback as Y } from "react";
4
4
  import Z from "react-highlight-words";
5
5
  import { useTranslationLibNoNS as V } from "../locale/index.es.js";
@@ -19,58 +19,58 @@ function Re(N) {
19
19
  label: i,
20
20
  name: u,
21
21
  type: g,
22
- required: d,
22
+ required: s,
23
23
  hidden: k,
24
24
  rules: h = [],
25
25
  updatable: f = !0,
26
26
  readonly: w = !1,
27
27
  fieldClassName: C,
28
- customFormFieldRender: H,
28
+ customFormFieldRender: S,
29
29
  fieldTooltip: v,
30
30
  fieldHelper: y,
31
31
  ...e
32
- } = N, s = j.useFormInstance();
32
+ } = N, c = A.useFormInstance();
33
33
  B(() => {
34
34
  if (g === "select") {
35
35
  const {
36
36
  items: l = [],
37
37
  onSearch: a,
38
- searchOnType: c
38
+ searchOnType: d
39
39
  } = e;
40
- !(l != null && l.length) && !c && (a == null || a(void 0, s, e == null ? void 0 : e.updatingValue));
40
+ !(l != null && l.length) && !d && (a == null || a(void 0, c, e == null ? void 0 : e.updatingValue));
41
41
  }
42
- }, [s, e, g, e == null ? void 0 : e.updatingValue]);
43
- const { t: P } = V();
44
- if (w || k) return /* @__PURE__ */ t(S, {});
45
- if (H)
46
- return H(s, N);
42
+ }, [c, e, g, e == null ? void 0 : e.updatingValue]);
43
+ const { t: H } = V();
44
+ if (w || k) return /* @__PURE__ */ t(P, {});
45
+ if (S)
46
+ return S(c, N);
47
47
  switch (g) {
48
48
  case "text":
49
49
  case "email":
50
50
  case "password": {
51
- const { onChange: l, placeholder: a, addonAfter: c, addonBefore: p } = e;
51
+ const { onChange: l, placeholder: a, addonAfter: d, addonBefore: p } = e;
52
52
  return /* @__PURE__ */ t(
53
53
  ne,
54
54
  {
55
55
  placeholder: a,
56
56
  disabled: !f,
57
57
  rules: h,
58
- required: d,
59
- onChange: l ? (n) => l(n, s) : void 0,
58
+ required: s,
59
+ onChange: l ? (n) => l(n, c) : void 0,
60
60
  type: g,
61
61
  name: u,
62
62
  tooltip: v,
63
63
  label: i,
64
64
  className: C,
65
65
  autoComplete: "new-password",
66
- addonAfter: c,
66
+ addonAfter: d,
67
67
  addonBefore: p,
68
68
  help: y
69
69
  }
70
70
  );
71
71
  }
72
72
  case "number": {
73
- const { onChange: l, placeholder: a, allowMinus: c, min: p, max: n, addonAfter: T, addonBefore: b } = e;
73
+ const { onChange: l, placeholder: a, allowMinus: d, min: p, max: n, addonAfter: T, addonBefore: b } = e;
74
74
  return /* @__PURE__ */ t(
75
75
  oe,
76
76
  {
@@ -78,13 +78,13 @@ function Re(N) {
78
78
  disabled: !f,
79
79
  moneyField: !!e.formatted,
80
80
  type: g,
81
- onChange: l ? (x) => l(x, s) : void 0,
81
+ onChange: l ? (x) => l(x, c) : void 0,
82
82
  rules: h,
83
83
  autoComplete: "false",
84
- required: d,
84
+ required: s,
85
85
  tooltip: v,
86
86
  className: C,
87
- min: c ? null : p,
87
+ min: d ? null : p,
88
88
  max: n,
89
89
  addonAfter: T,
90
90
  addonBefore: b,
@@ -98,7 +98,7 @@ function Re(N) {
98
98
  const {
99
99
  range: l,
100
100
  disableToday: a,
101
- disabledFutureDays: c,
101
+ disabledFutureDays: d,
102
102
  disabledPastDays: p,
103
103
  onChange: n,
104
104
  placeholder: T,
@@ -108,7 +108,7 @@ function Re(N) {
108
108
  ae,
109
109
  {
110
110
  placeholder: T,
111
- required: d,
111
+ required: s,
112
112
  disabled: !f,
113
113
  type: g,
114
114
  format: b,
@@ -116,10 +116,10 @@ function Re(N) {
116
116
  range: l,
117
117
  name: u,
118
118
  label: i,
119
- onChange: n ? (x) => n(x, s) : void 0,
119
+ onChange: n ? (x) => n(x, c) : void 0,
120
120
  className: C,
121
121
  disableToday: a,
122
- disabledFutureDays: c,
122
+ disabledFutureDays: d,
123
123
  disabledPastDays: p,
124
124
  help: y
125
125
  }
@@ -129,7 +129,7 @@ function Re(N) {
129
129
  const {
130
130
  range: l = !1,
131
131
  disableCurrent: a,
132
- disabledFuture: c,
132
+ disabledFuture: d,
133
133
  disabledPast: p,
134
134
  onChange: n,
135
135
  use12Hours: T,
@@ -140,7 +140,7 @@ function Re(N) {
140
140
  le,
141
141
  {
142
142
  placeholder: x,
143
- required: d,
143
+ required: s,
144
144
  format: b,
145
145
  disabled: !f,
146
146
  type: g,
@@ -149,10 +149,10 @@ function Re(N) {
149
149
  use12Hours: T,
150
150
  name: u,
151
151
  label: i,
152
- onChange: n ? (o) => n(o, s) : void 0,
152
+ onChange: n ? (o) => n(o, c) : void 0,
153
153
  className: C,
154
154
  disableCurrent: a,
155
- disabledFuture: c,
155
+ disabledFuture: d,
156
156
  disabledPast: p,
157
157
  help: y
158
158
  }
@@ -165,7 +165,7 @@ function Re(N) {
165
165
  re,
166
166
  {
167
167
  ...e,
168
- required: d,
168
+ required: s,
169
169
  name: u,
170
170
  label: i,
171
171
  rules: h,
@@ -180,7 +180,7 @@ function Re(N) {
180
180
  ee,
181
181
  {
182
182
  ...e,
183
- required: d,
183
+ required: s,
184
184
  name: u,
185
185
  label: i,
186
186
  rules: h,
@@ -195,12 +195,12 @@ function Re(N) {
195
195
  se,
196
196
  {
197
197
  ...e,
198
- required: d,
198
+ required: s,
199
199
  name: u,
200
200
  label: i,
201
201
  rules: h,
202
202
  fieldClassName: C,
203
- form: s,
203
+ form: c,
204
204
  updatable: f,
205
205
  readonly: w,
206
206
  fieldTooltip: v,
@@ -211,18 +211,18 @@ function Re(N) {
211
211
  const {
212
212
  enum: l,
213
213
  radio: a = !1,
214
- translation: c,
214
+ translation: d,
215
215
  onChange: p,
216
216
  onSearch: n,
217
217
  multiple: T,
218
218
  tagRender: b
219
219
  } = e, x = Array.isArray(l) ? l : Object.keys(l);
220
220
  return a ? /* @__PURE__ */ t(
221
- j.Item,
221
+ A.Item,
222
222
  {
223
223
  ...e,
224
224
  name: u,
225
- required: d,
225
+ required: s,
226
226
  tooltip: v,
227
227
  rules: h,
228
228
  label: i,
@@ -234,9 +234,9 @@ function Re(N) {
234
234
  ...e,
235
235
  onChange: p ? (o) => {
236
236
  var F;
237
- return p((F = o == null ? void 0 : o.target) == null ? void 0 : F.value, s);
237
+ return p((F = o == null ? void 0 : o.target) == null ? void 0 : F.value, c);
238
238
  } : void 0,
239
- children: x.map((o) => /* @__PURE__ */ t(M, { disabled: !f, value: o, children: c ? P(c[o]) : o }, o))
239
+ children: x.map((o) => /* @__PURE__ */ t(M, { disabled: !f, value: o, children: d ? H(d[o]) : o }, o))
240
240
  }
241
241
  )
242
242
  }
@@ -248,46 +248,47 @@ function Re(N) {
248
248
  const { value: F, label: R } = o, O = b[F];
249
249
  return O ? /* @__PURE__ */ t(W, { color: O.color, children: R }) : /* @__PURE__ */ t(W, { children: R });
250
250
  } : void 0,
251
- onChange: p ? (o) => p(o, s) : void 0,
251
+ onChange: p ? (o) => p(o, c) : void 0,
252
252
  className: ["w-100", C].join(" "),
253
253
  name: u,
254
254
  items: x,
255
- required: d,
255
+ required: s,
256
256
  tooltip: v,
257
257
  rules: h,
258
258
  label: i,
259
259
  help: y,
260
260
  disabled: !f,
261
- onSearch: n ? (o) => n(o, s) : void 0,
261
+ onSearch: n ? (o) => n(o, c) : void 0,
262
262
  allowClear: !0,
263
263
  mode: T ? "multiple" : void 0,
264
- itemBuilder: (o) => /* @__PURE__ */ t(A.Option, { value: o, children: c ? P(c[o]) : o }, o)
264
+ itemBuilder: (o) => /* @__PURE__ */ t(j.Option, { value: o, children: d ? H(d[o]) : o }, o)
265
265
  }
266
266
  );
267
267
  }
268
268
  case "checkbox": {
269
- const { onChange: l } = e;
269
+ const { onChange: l, switch: a } = e;
270
270
  return /* @__PURE__ */ t(
271
271
  te,
272
272
  {
273
273
  className: C,
274
274
  rules: h,
275
- onChange: l ? (a) => l(a, s) : void 0,
275
+ onChange: l ? (d) => l(d, c) : void 0,
276
276
  label: i,
277
277
  tooltip: v,
278
278
  disabled: !f,
279
279
  name: u,
280
- help: y
280
+ help: y,
281
+ switch: a
281
282
  }
282
283
  );
283
284
  }
284
285
  case "color":
285
286
  return /* @__PURE__ */ t(
286
- me,
287
+ ce,
287
288
  {
288
289
  ...e,
289
290
  type: "color",
290
- required: d,
291
+ required: s,
291
292
  name: u,
292
293
  label: i,
293
294
  rules: h,
@@ -299,7 +300,7 @@ function Re(N) {
299
300
  }
300
301
  );
301
302
  default:
302
- return /* @__PURE__ */ t(S, { children: `${g} Not Implemented` });
303
+ return /* @__PURE__ */ t(P, { children: `${g} Not Implemented` });
303
304
  }
304
305
  }
305
306
  function se(N) {
@@ -307,23 +308,23 @@ function se(N) {
307
308
  items: i = [],
308
309
  loading: u,
309
310
  searchOnType: g,
310
- onSearch: d,
311
+ onSearch: s,
311
312
  multiple: k,
312
313
  onChange: h,
313
314
  highlightSearch: f,
314
315
  required: w,
315
316
  fieldClassName: C,
316
- rules: H,
317
+ rules: S,
317
318
  fieldTooltip: v,
318
319
  updatable: y,
319
320
  label: e,
320
- name: s,
321
- tagRender: P,
321
+ name: c,
322
+ tagRender: H,
322
323
  updatingValue: l,
323
324
  onSet: a,
324
- placeholder: c,
325
+ placeholder: d,
325
326
  allowClear: p = !0
326
- } = N, n = N.form, [T, b] = G(""), x = _(() => $.getRealName(s), [s]), o = _(() => $.getRealName(s, "upsertFieldName"), [s]), F = j.useWatch(x, n), [R, O] = G(!0);
327
+ } = N, n = N.form, [T, b] = G(""), x = _(() => $.getRealName(c), [c]), o = _(() => $.getRealName(c, "upsertFieldName"), [c]), F = A.useWatch(x, n), [R, O] = G(!0);
327
328
  B(() => {
328
329
  a && R && F && (a == null || a(F, i, n), O(!1));
329
330
  }, [R, n, i, x, a, F]), B(() => {
@@ -331,9 +332,9 @@ function se(N) {
331
332
  }, [F]);
332
333
  const J = Y(
333
334
  async (r) => {
334
- b(r), g && (d == null || d(r, n, l));
335
+ b(r), g && (s == null || s(r, n, l));
335
336
  },
336
- [n, d, g, l]
337
+ [n, s, g, l]
337
338
  );
338
339
  return /* @__PURE__ */ t(
339
340
  z,
@@ -343,7 +344,7 @@ function se(N) {
343
344
  maxTagPlaceholder: (r) => /* @__PURE__ */ E(
344
345
  ie,
345
346
  {
346
- title: /* @__PURE__ */ t(S, { children: r.map((m) => /* @__PURE__ */ E(S, { children: [
347
+ title: /* @__PURE__ */ t(P, { children: r.map((m) => /* @__PURE__ */ E(P, { children: [
347
348
  m.label,
348
349
  " ",
349
350
  /* @__PURE__ */ t("br", {})
@@ -354,7 +355,7 @@ function se(N) {
354
355
  ]
355
356
  }
356
357
  ),
357
- placeholder: c,
358
+ placeholder: d,
358
359
  onSelect: (r) => {
359
360
  a == null || a(r == null ? void 0 : r.key, i, n);
360
361
  },
@@ -367,8 +368,8 @@ function se(N) {
367
368
  items: i,
368
369
  required: w,
369
370
  tooltip: v,
370
- tagRender: P,
371
- rules: H,
371
+ tagRender: H,
372
+ rules: S,
372
373
  disabled: !y,
373
374
  label: e,
374
375
  allowClear: p,
@@ -388,7 +389,7 @@ function se(N) {
388
389
  itemBuilder: f ? (r) => {
389
390
  const m = r.value ? String(r.value) : void 0;
390
391
  return /* @__PURE__ */ t(
391
- A.Option,
392
+ j.Option,
392
393
  {
393
394
  value: r.key,
394
395
  title: m,
@@ -406,7 +407,7 @@ function se(N) {
406
407
  r.key
407
408
  );
408
409
  } : (r) => /* @__PURE__ */ t(
409
- A.Option,
410
+ j.Option,
410
411
  {
411
412
  value: r.key,
412
413
  title: r.value,
@@ -418,25 +419,25 @@ function se(N) {
418
419
  }
419
420
  );
420
421
  }
421
- function me(N) {
422
+ function ce(N) {
422
423
  const {
423
424
  required: i,
424
425
  fieldClassName: u,
425
426
  rules: g,
426
- fieldTooltip: d,
427
+ fieldTooltip: s,
427
428
  updatable: k,
428
429
  label: h,
429
430
  name: f,
430
431
  fieldHelper: w
431
432
  } = N;
432
433
  return /* @__PURE__ */ t(
433
- j.Item,
434
+ A.Item,
434
435
  {
435
436
  label: h,
436
437
  name: f,
437
438
  required: i,
438
439
  rules: g,
439
- tooltip: d,
440
+ tooltip: s,
440
441
  help: w,
441
442
  children: /* @__PURE__ */ t(
442
443
  X,
@@ -455,7 +456,7 @@ function me(N) {
455
456
  );
456
457
  }
457
458
  export {
458
- me as ColorCrudFieldComponent,
459
+ ce as ColorCrudFieldComponent,
459
460
  se as SelectCrudFieldComponent,
460
461
  Re as default
461
462
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),b=require("@ant-design/icons"),h=require("antd"),A=require("../../common/show-more/index.cjs.js"),F=require("../FileCrudField.cjs.js"),T=require("../ImageCrudField.cjs.js"),j=require("../../util/DateUtil.cjs.js"),q=require("../../util/NumberUtil.cjs.js"),g=require("../../locale/index.cjs.js"),B=require("../../util/CrudUtil.cjs.js"),m=require("../../common/error/ErrorBoundaryComponent.cjs.js");function R({type:c,render:r,...i}){try{return c==="object"?(t,o,e)=>typeof r=="function"?r(t,o,e):"":c==="select"?(t,o,e)=>{if(!t)return"-";const n=i,l=t||(n.items??[]).find(s=>s[n.innerFieldId??"key"]===o[B.getRealName(i.name,"upsertFieldName")]),a=n.multiple?Array.isArray(l)?l.map(s=>s==null?void 0:s[n.innerFieldLabel??"name"]):void 0:l==null?void 0:l[n.innerFieldLabel??"value"];return typeof r=="function"?r(a,o,e):Array.isArray(a)?a.join(", "):a}:c==="number"?(t,o,e)=>typeof r=="function"?r(t,o,e):i!=null&&i.int?q.default.toInt(t,i.formatted):q.default.toMoney(t):c==="enum"?(t,o,e)=>{var s;if(!t)return"-";const n=i;if(typeof r=="function")return r(t,o,e);if(n.multiple){const f=Array.isArray(t)?t:t?[t]:[];return typeof n.tagRender=="object"?u.jsx(m.ErrorBoundaryComponent,{children:u.jsx(h.Space,{wrap:!0,children:f.map((d,y)=>{var v,S;const x=(v=n.tagRender)==null?void 0:v[d],C=g.tWithOrWithoutNS(((S=n==null?void 0:n.translation)==null?void 0:S[d??""])??d);return x?u.jsx(h.Tag,{color:x.color,children:C},y+d):C})})}):n!=null&&n.translation?u.jsx(m.ErrorBoundaryComponent,{children:f==null?void 0:f.map(d=>{var y;return g.tWithOrWithoutNS(((y=n==null?void 0:n.translation)==null?void 0:y[d??""])??d)}).join(", ")}):f==null?void 0:f.join(", ")}const l=((s=n==null?void 0:n.translation)==null?void 0:s[t??""])??t,a=g.tWithOrWithoutNS(l);if(typeof n.tagRender=="object"){const f=n.tagRender[t];if(f)return u.jsx(h.Tag,{color:f.color,children:a})}return a}:c==="date"?(t,o,e)=>{if(!t)return"-";const n=i!=null&&i.formatTime?j.formatDateTime(t):j.formatDate(t);return u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,o,e):n})}:c==="checkbox"?(t,o,e)=>typeof r=="function"?r(t,o,e):t?u.jsx(b.CheckOutlined,{}):u.jsx(b.CloseOutlined,{}):c==="image"?(t,o,e)=>t?u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,o,e):u.jsx(T.ImageCrudCellValue,{value:t,provider:i.provider})}):"-":c==="file"?(t,o,e)=>t?u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,o,e):u.jsx(F.FileCrudCellValue,{value:t,provider:i.provider})}):"":c==="time"?(t,o,e)=>{if(!t)return"-";const n=i==null?void 0:i.format,l=i==null?void 0:i.use12Hours,a=j.formatTime(t,n||(l?"hh:mm:ss A":void 0));return u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,o,e):a})}:c==="color"?(t,o,e)=>t?typeof r=="function"?r(t,o,e):typeof t=="string"&&t.startsWith("#")?u.jsx(h.Tooltip,{title:t,children:u.jsx(h.Avatar,{style:{backgroundColor:t}})}):String(t):"-":c==="textarea"?(t,o,e)=>{if(!t)return"-";const n=i,l=n.truncated??1,a=typeof r=="function"?r(t,o,e):l?u.jsx(m.ErrorBoundaryComponent,{children:u.jsx(A.ShowMore,{lines:l===!0?1:l,children:n.rich?u.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t})}):n.rich?u.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t;return console.log("component",a),a}:typeof r=="function"?r:(t,o,e)=>t}catch(t){return console.warn("An error occurred while rendering the value for field: "+String(i.name),t),"-"}}exports.getRendererValueCrudViewer=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),b=require("@ant-design/icons"),h=require("antd"),A=require("../../common/show-more/index.cjs.js"),F=require("../FileCrudField.cjs.js"),T=require("../ImageCrudField.cjs.js"),j=require("../../util/DateUtil.cjs.js"),q=require("../../util/NumberUtil.cjs.js"),g=require("../../locale/index.cjs.js"),B=require("../../util/CrudUtil.cjs.js"),m=require("../../common/error/ErrorBoundaryComponent.cjs.js");function R({type:l,render:r,...i}){try{return l==="object"?(t,e,o)=>typeof r=="function"?r(t,e,o):"":l==="select"?(t,e,o)=>{if(!t)return"-";const n=i,a=t||(n.items??[]).find(s=>s[n.innerFieldId??"key"]===e[B.getRealName(i.name,"upsertFieldName")]),c=n.multiple?Array.isArray(a)?a.map(s=>s==null?void 0:s[n.innerFieldLabel??"name"]):void 0:a==null?void 0:a[n.innerFieldLabel??"value"];return typeof r=="function"?r(c,e,o):Array.isArray(c)?c.join(", "):c}:l==="number"?(t,e,o)=>typeof r=="function"?r(t,e,o):i!=null&&i.int?q.default.toInt(t,i.formatted):q.default.toMoney(t):l==="enum"?(t,e,o)=>{var s;if(!t)return"-";const n=i;if(typeof r=="function")return r(t,e,o);if(n.multiple){const f=Array.isArray(t)?t:t?[t]:[];return typeof n.tagRender=="object"?u.jsx(m.ErrorBoundaryComponent,{children:u.jsx(h.Space,{wrap:!0,children:f.map((d,y)=>{var v,S;const x=(v=n.tagRender)==null?void 0:v[d],C=g.tWithOrWithoutNS(((S=n==null?void 0:n.translation)==null?void 0:S[d??""])??d);return x?u.jsx(h.Tag,{color:x.color,children:C},y+d):C})})}):n!=null&&n.translation?u.jsx(m.ErrorBoundaryComponent,{children:f==null?void 0:f.map(d=>{var y;return g.tWithOrWithoutNS(((y=n==null?void 0:n.translation)==null?void 0:y[d??""])??d)}).join(", ")}):f==null?void 0:f.join(", ")}const a=((s=n==null?void 0:n.translation)==null?void 0:s[t??""])??t,c=g.tWithOrWithoutNS(a);if(typeof n.tagRender=="object"){const f=n.tagRender[t];if(f)return u.jsx(h.Tag,{color:f.color,children:c})}return c}:l==="date"?(t,e,o)=>{if(!t)return"-";const n=i!=null&&i.formatTime?j.formatDateTime(t):j.formatDate(t);return u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,e,o):n})}:l==="checkbox"?(t,e,o)=>typeof r=="function"?r(t,e,o):t?u.jsx(b.CheckOutlined,{}):u.jsx(b.CloseOutlined,{}):l==="image"?(t,e,o)=>t?u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,e,o):u.jsx(T.ImageCrudCellValue,{value:t,provider:i.provider})}):"-":l==="file"?(t,e,o)=>t?u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,e,o):u.jsx(F.FileCrudCellValue,{value:t,provider:i.provider})}):"":l==="time"?(t,e,o)=>{if(!t)return"-";const n=i==null?void 0:i.format,a=i==null?void 0:i.use12Hours,c=j.formatTime(t,n||(a?"hh:mm:ss A":void 0));return u.jsx(m.ErrorBoundaryComponent,{children:typeof r=="function"?r(t,e,o):c})}:l==="color"?(t,e,o)=>t?typeof r=="function"?r(t,e,o):typeof t=="string"&&t.startsWith("#")?u.jsx(h.Tooltip,{title:t,children:u.jsx(h.Avatar,{style:{backgroundColor:t}})}):String(t):"-":l==="textarea"?(t,e,o)=>{if(!t)return"-";const n=i,a=n.truncated??1;return typeof r=="function"?r(t,e,o):a?u.jsx(m.ErrorBoundaryComponent,{children:u.jsx(A.ShowMore,{lines:a===!0?1:a,children:n.rich?u.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t})}):n.rich?u.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t}:typeof r=="function"?r:(t,e,o)=>t}catch(t){return console.warn("An error occurred while rendering the value for field: "+String(i.name),t),"-"}}exports.getRendererValueCrudViewer=R;
@@ -4,24 +4,24 @@ import { Space as R, Tag as S, Tooltip as w, Avatar as I } from "antd";
4
4
  import { ShowMore as V } from "../../common/show-more/index.es.js";
5
5
  import { FileCrudCellValue as k } from "../FileCrudField.es.js";
6
6
  import { ImageCrudCellValue as x } from "../ImageCrudField.es.js";
7
- import g from "../../util/DateUtil.es.js";
7
+ import y from "../../util/DateUtil.es.js";
8
8
  import j from "../../util/NumberUtil.es.js";
9
- import { tWithOrWithoutNS as y } from "../../locale/index.es.js";
9
+ import { tWithOrWithoutNS as g } from "../../locale/index.es.js";
10
10
  import H from "../../util/CrudUtil.es.js";
11
11
  import { ErrorBoundaryComponent as h } from "../../common/error/ErrorBoundaryComponent.es.js";
12
12
  function z({
13
- type: u,
13
+ type: c,
14
14
  render: i,
15
15
  ...l
16
16
  }) {
17
17
  try {
18
- return u === "object" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : "" : u === "select" ? (t, o, r) => {
18
+ return c === "object" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : "" : c === "select" ? (t, o, r) => {
19
19
  if (!t) return "-";
20
20
  const n = l, a = t || (n.items ?? []).find(
21
21
  (m) => m[n.innerFieldId ?? "key"] === o[H.getRealName(l.name, "upsertFieldName")]
22
- ), c = n.multiple ? Array.isArray(a) ? a.map((m) => m == null ? void 0 : m[n.innerFieldLabel ?? "name"]) : void 0 : a == null ? void 0 : a[n.innerFieldLabel ?? "value"];
23
- return typeof i == "function" ? i(c, o, r) : Array.isArray(c) ? c.join(", ") : c;
24
- } : u === "number" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : l != null && l.int ? j.toInt(t, l.formatted) : j.toMoney(t) : u === "enum" ? (t, o, r) => {
22
+ ), u = n.multiple ? Array.isArray(a) ? a.map((m) => m == null ? void 0 : m[n.innerFieldLabel ?? "name"]) : void 0 : a == null ? void 0 : a[n.innerFieldLabel ?? "value"];
23
+ return typeof i == "function" ? i(u, o, r) : Array.isArray(u) ? u.join(", ") : u;
24
+ } : c === "number" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : l != null && l.int ? j.toInt(t, l.formatted) : j.toMoney(t) : c === "enum" ? (t, o, r) => {
25
25
  var m;
26
26
  if (!t) return "-";
27
27
  const n = l;
@@ -31,50 +31,51 @@ function z({
31
31
  const f = Array.isArray(t) ? t : t ? [t] : [];
32
32
  return typeof n.tagRender == "object" ? /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(R, { wrap: !0, children: f.map((d, s) => {
33
33
  var b, A;
34
- const v = (b = n.tagRender) == null ? void 0 : b[d], C = y(
34
+ const v = (b = n.tagRender) == null ? void 0 : b[d], C = g(
35
35
  ((A = n == null ? void 0 : n.translation) == null ? void 0 : A[d ?? ""]) ?? d
36
36
  );
37
37
  return v ? /* @__PURE__ */ e(S, { color: v.color, children: C }, s + d) : C;
38
38
  }) }) }) : n != null && n.translation ? /* @__PURE__ */ e(h, { children: f == null ? void 0 : f.map(
39
39
  (d) => {
40
40
  var s;
41
- return y(((s = n == null ? void 0 : n.translation) == null ? void 0 : s[d ?? ""]) ?? d);
41
+ return g(((s = n == null ? void 0 : n.translation) == null ? void 0 : s[d ?? ""]) ?? d);
42
42
  }
43
43
  ).join(", ") }) : f == null ? void 0 : f.join(", ");
44
44
  }
45
- const a = ((m = n == null ? void 0 : n.translation) == null ? void 0 : m[t ?? ""]) ?? t, c = y(a);
45
+ const a = ((m = n == null ? void 0 : n.translation) == null ? void 0 : m[t ?? ""]) ?? t, u = g(a);
46
46
  if (typeof n.tagRender == "object") {
47
47
  const f = n.tagRender[t];
48
48
  if (f)
49
- return /* @__PURE__ */ e(S, { color: f.color, children: c });
49
+ return /* @__PURE__ */ e(S, { color: f.color, children: u });
50
50
  }
51
- return c;
52
- } : u === "date" ? (t, o, r) => {
51
+ return u;
52
+ } : c === "date" ? (t, o, r) => {
53
53
  if (!t) return "-";
54
- const n = l != null && l.formatTime ? g.formatDateTime(t) : g.formatDate(t);
54
+ const n = l != null && l.formatTime ? y.formatDateTime(t) : y.formatDate(t);
55
55
  return /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : n });
56
- } : u === "checkbox" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : t ? /* @__PURE__ */ e(T, {}) : /* @__PURE__ */ e(F, {}) : u === "image" ? (t, o, r) => t ? /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : /* @__PURE__ */ e(
56
+ } : c === "checkbox" ? (t, o, r) => typeof i == "function" ? i(t, o, r) : t ? /* @__PURE__ */ e(T, {}) : /* @__PURE__ */ e(F, {}) : c === "image" ? (t, o, r) => t ? /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : /* @__PURE__ */ e(
57
57
  x,
58
58
  {
59
59
  value: t,
60
60
  provider: l.provider
61
61
  }
62
- ) }) : "-" : u === "file" ? (t, o, r) => t ? /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : /* @__PURE__ */ e(
62
+ ) }) : "-" : c === "file" ? (t, o, r) => t ? /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : /* @__PURE__ */ e(
63
63
  k,
64
64
  {
65
65
  value: t,
66
66
  provider: l.provider
67
67
  }
68
- ) }) : "" : u === "time" ? (t, o, r) => {
68
+ ) }) : "" : c === "time" ? (t, o, r) => {
69
69
  if (!t) return "-";
70
- const n = l == null ? void 0 : l.format, a = l == null ? void 0 : l.use12Hours, c = g.formatTime(
70
+ const n = l == null ? void 0 : l.format, a = l == null ? void 0 : l.use12Hours, u = y.formatTime(
71
71
  t,
72
72
  n || (a ? "hh:mm:ss A" : void 0)
73
73
  );
74
- return /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : c });
75
- } : u === "color" ? (t, o, r) => t ? typeof i == "function" ? i(t, o, r) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ e(w, { title: t, children: /* @__PURE__ */ e(I, { style: { backgroundColor: t } }) }) : String(t) : "-" : u === "textarea" ? (t, o, r) => {
74
+ return /* @__PURE__ */ e(h, { children: typeof i == "function" ? i(t, o, r) : u });
75
+ } : c === "color" ? (t, o, r) => t ? typeof i == "function" ? i(t, o, r) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ e(w, { title: t, children: /* @__PURE__ */ e(I, { style: { backgroundColor: t } }) }) : String(t) : "-" : c === "textarea" ? (t, o, r) => {
76
76
  if (!t) return "-";
77
- const n = l, a = n.truncated ?? 1, c = typeof i == "function" ? i(t, o, r) : a ? /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(V, { lines: a === !0 ? 1 : a, children: n.rich ? /* @__PURE__ */ e(
77
+ const n = l, a = n.truncated ?? 1;
78
+ return typeof i == "function" ? i(t, o, r) : a ? /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(V, { lines: a === !0 ? 1 : a, children: n.rich ? /* @__PURE__ */ e(
78
79
  "div",
79
80
  {
80
81
  style: { all: "unset" },
@@ -87,7 +88,6 @@ function z({
87
88
  dangerouslySetInnerHTML: { __html: t }
88
89
  }
89
90
  ) : t;
90
- return console.log("component", c), c;
91
91
  } : typeof i == "function" ? i : (t, o, r) => t;
92
92
  } catch (t) {
93
93
  return console.warn(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.3.0",
4
+ "version": "1.4.0",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",