@kingteza/crud-component 1.0.58 → 1.0.60

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 t=require("react/jsx-runtime"),d=require("antd"),R=require("react"),B=require("../../locale/index.cjs.js"),D=require("../tooltip/TooltipComponent.cjs.js");function E({label:l,rules:w=[],required:S,placeholder:h,notSearch:L,children:x,readOnly:s,items:c,dropdownRender:q,itemBuilder:T,loading:f,showLoadingInEmptyIndicator:_,nameFieldInArray:m="name",innerRef:p,tooltip:N,filterOption:$,tagRender:b,...n}){const{t:k}=B.useTranslationLib(),H=R.useCallback(e=>{const r=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e.id,o=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e[m];return t.jsx("option",{value:r,children:t.jsx("div",{dangerouslySetInnerHTML:{__html:o}})},r)},[m]);return t.jsx(d.ConfigProvider,{renderEmpty:_&&f?()=>t.jsx(d.Spin,{}):void 0,children:t.jsx(D,{title:N,children:t.jsx(d.Form.Item,{label:l,name:n.name,help:n.help,className:n.className,rules:[...w,{required:S,message:`${l??h??""} ${k("err.validation.required")}`}],children:t.jsx(d.Select,{ref:p,loading:f,open:s?!1:void 0,onChange:!s&&n.onChange,allowClear:!s&&n.allowClear,showSearch:!L,className:`max-width ${s?"readOnly":""}`,...n,tagRender:b,placeholder:h??l,filterOption:$??((e,r)=>{var o,g,u,C;try{const i=(u=(g=(o=r==null?void 0:r.children)==null?void 0:o.props)==null?void 0:g.dangerouslySetInnerHTML)==null?void 0:u.__html,I=e.toLowerCase().split(/\s+/),y=(r==null?void 0:r.children)??"",j=typeof y=="string"?y.toLowerCase():typeof i=="string"?i.toLowerCase():"",M=(((C=r==null?void 0:r.value)==null?void 0:C.toString())??"").toLowerCase(),O=j.replace(/\s/g,"");return I.every(a=>j.indexOf(a)>=0||M.indexOf(a)>=0||O.indexOf(a)>=0)}catch(i){return console.log(i),!0}}),dropdownRender:q,children:x===null?void 0:x??(c&&(c==null?void 0:c.map(T??H)))})})})})}module.exports=E;
1
+ "use strict";const n=require("react/jsx-runtime"),l=require("antd"),O=require("react"),V=require("../../locale/index.cjs.js"),B=require("../tooltip/TooltipComponent.cjs.js"),D=require("../../util/ValidationUtil.cjs.js");function E({label:a,rules:S=[],required:h,placeholder:x,notSearch:L,children:f,readOnly:s,items:o,dropdownRender:p,itemBuilder:q,loading:m,showLoadingInEmptyIndicator:T,nameFieldInArray:u="name",innerRef:_,tooltip:b,filterOption:N,tagRender:R,...r}){const{t:P}=V.useTranslationLib(),k=O.useCallback(e=>{const t=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e.id,c=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e[u];return n.jsx("option",{value:t,children:n.jsx("div",{dangerouslySetInnerHTML:{__html:c}})},t)},[u]),F=a??x??"";return n.jsx(l.ConfigProvider,{renderEmpty:T&&m?()=>n.jsx(l.Spin,{}):void 0,children:n.jsx(B,{title:b,children:n.jsx(l.Form.Item,{label:a,name:r.name,help:r.help,className:r.className,required:h,rules:[...S,...h?D.required(F):[]],children:n.jsx(l.Select,{ref:_,loading:m,open:s?!1:void 0,onChange:!s&&r.onChange,allowClear:!s&&r.allowClear,showSearch:!L,className:`max-width ${s?"readOnly":""}`,...r,tagRender:R,placeholder:x??a,filterOption:N??((e,t)=>{var c,g,C,j;try{const i=(C=(g=(c=t==null?void 0:t.children)==null?void 0:c.props)==null?void 0:g.dangerouslySetInnerHTML)==null?void 0:C.__html,H=e.toLowerCase().split(/\s+/),y=(t==null?void 0:t.children)??"",w=typeof y=="string"?y.toLowerCase():typeof i=="string"?i.toLowerCase():"",I=(((j=t==null?void 0:t.value)==null?void 0:j.toString())??"").toLowerCase(),M=w.replace(/\s/g,"");return H.every(d=>w.indexOf(d)>=0||I.indexOf(d)>=0||M.indexOf(d)>=0)}catch(i){return console.log(i),!0}}),popupRender:p,children:f===null?void 0:f??(o?o==null?void 0:o.map(q??k):n.jsx(n.Fragment,{}))})})})})}module.exports=E;
@@ -17,5 +17,5 @@ interface SelectComponentProps<T> extends SelectProps<any>, FormItemProps<any> {
17
17
  filterOption?: SelectProps["filterOption"];
18
18
  tagRender?: SelectTagRenderProps;
19
19
  }
20
- declare function SelectComponent<T = any>({ label, rules, required, placeholder, notSearch, children, readOnly, items, dropdownRender, itemBuilder, loading, showLoadingInEmptyIndicator, nameFieldInArray, innerRef, tooltip, filterOption, tagRender, ...props }: SelectComponentProps<T>): import("react/jsx-runtime").JSX.Element;
20
+ declare function SelectComponent<T = any>({ label, rules, required, placeholder, notSearch, children, readOnly, items, dropdownRender, itemBuilder, loading, showLoadingInEmptyIndicator, nameFieldInArray, innerRef, tooltip, filterOption, tagRender, ...props }: Readonly<SelectComponentProps<T>>): import("react/jsx-runtime").JSX.Element;
21
21
  export default SelectComponent;
@@ -1,81 +1,78 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { ConfigProvider as q, Form as B, Select as D, Spin as E } from "antd";
3
- import { useCallback as F } from "react";
4
- import { useTranslationLib as P } from "../../locale/index.es.js";
5
- import V from "../tooltip/TooltipComponent.es.js";
6
- function Q({
1
+ import { jsx as t, Fragment as j } from "react/jsx-runtime";
2
+ import { ConfigProvider as B, Form as D, Select as E, Spin as P } from "antd";
3
+ import { useCallback as R } from "react";
4
+ import { useTranslationLib as U } from "../../locale/index.es.js";
5
+ import W from "../tooltip/TooltipComponent.es.js";
6
+ import $ from "../../util/ValidationUtil.es.js";
7
+ function Y({
7
8
  label: m,
8
- rules: x = [],
9
- required: S,
10
- placeholder: f,
9
+ rules: S = [],
10
+ required: f,
11
+ placeholder: a,
11
12
  notSearch: L,
12
- children: a,
13
+ children: d,
13
14
  readOnly: o,
14
15
  items: s,
15
16
  dropdownRender: u,
16
17
  itemBuilder: T,
17
- loading: d,
18
+ loading: h,
18
19
  showLoadingInEmptyIndicator: _,
19
- nameFieldInArray: h = "name",
20
- innerRef: N,
21
- tooltip: $,
22
- filterOption: b,
23
- tagRender: k,
20
+ nameFieldInArray: g = "name",
21
+ innerRef: b,
22
+ tooltip: N,
23
+ filterOption: k,
24
+ tagRender: F,
24
25
  ...n
25
26
  }) {
26
- const { t: H } = P(), I = F(
27
+ const { t: q } = U(), H = R(
27
28
  (e) => {
28
- const r = typeof e == "string" || typeof e == "number" ? e : e == null ? void 0 : e.id, c = typeof e == "string" || typeof e == "number" ? e : e == null ? void 0 : e[h];
29
+ const r = typeof e == "string" || typeof e == "number" ? e : e == null ? void 0 : e.id, c = typeof e == "string" || typeof e == "number" ? e : e == null ? void 0 : e[g];
29
30
  return /* @__PURE__ */ t("option", { value: r, children: /* @__PURE__ */ t("div", { dangerouslySetInnerHTML: { __html: c } }) }, r);
30
31
  },
31
- [h]
32
- );
32
+ [g]
33
+ ), I = m ?? a ?? "";
33
34
  return /* @__PURE__ */ t(
34
- q,
35
+ B,
35
36
  {
36
- renderEmpty: _ && d ? () => /* @__PURE__ */ t(E, {}) : void 0,
37
- children: /* @__PURE__ */ t(V, { title: $, children: /* @__PURE__ */ t(
38
- B.Item,
37
+ renderEmpty: _ && h ? () => /* @__PURE__ */ t(P, {}) : void 0,
38
+ children: /* @__PURE__ */ t(W, { title: N, children: /* @__PURE__ */ t(
39
+ D.Item,
39
40
  {
40
41
  label: m,
41
42
  name: n.name,
42
43
  help: n.help,
43
44
  className: n.className,
45
+ required: f,
44
46
  rules: [
45
- ...x,
46
- {
47
- required: S,
48
- message: `${m ?? f ?? ""} ${H(
49
- "err.validation.required"
50
- )}`
51
- }
47
+ ...S,
48
+ ...f ? $.required(I) : []
52
49
  ],
53
50
  children: /* @__PURE__ */ t(
54
- D,
51
+ E,
55
52
  {
56
- ref: N,
57
- loading: d,
53
+ ref: b,
54
+ loading: h,
58
55
  open: o ? !1 : void 0,
59
56
  onChange: !o && n.onChange,
60
57
  allowClear: !o && n.allowClear,
61
58
  showSearch: !L,
62
59
  className: `max-width ${o ? "readOnly" : ""}`,
63
60
  ...n,
64
- tagRender: k,
65
- placeholder: f ?? m,
66
- filterOption: b ?? ((e, r) => {
67
- var c, g, C, y;
61
+ tagRender: F,
62
+ placeholder: a ?? m,
63
+ filterOption: k ?? ((e, r) => {
64
+ var c, p, C, y;
68
65
  try {
69
- const i = (C = (g = (c = r == null ? void 0 : r.children) == null ? void 0 : c.props) == null ? void 0 : g.dangerouslySetInnerHTML) == null ? void 0 : C.__html, M = e.toLowerCase().split(/\s+/), p = (r == null ? void 0 : r.children) ?? "", w = typeof p == "string" ? p.toLowerCase() : typeof i == "string" ? i.toLowerCase() : "", O = (((y = r == null ? void 0 : r.value) == null ? void 0 : y.toString()) ?? "").toLowerCase(), j = w.replace(/\s/g, "");
66
+ const i = (C = (p = (c = r == null ? void 0 : r.children) == null ? void 0 : c.props) == null ? void 0 : p.dangerouslySetInnerHTML) == null ? void 0 : C.__html, M = e.toLowerCase().split(/\s+/), w = (r == null ? void 0 : r.children) ?? "", x = typeof w == "string" ? w.toLowerCase() : typeof i == "string" ? i.toLowerCase() : "", O = (((y = r == null ? void 0 : r.value) == null ? void 0 : y.toString()) ?? "").toLowerCase(), V = x.replace(/\s/g, "");
70
67
  return M.every(
71
- (l) => w.indexOf(l) >= 0 || O.indexOf(l) >= 0 || j.indexOf(l) >= 0
68
+ (l) => x.indexOf(l) >= 0 || O.indexOf(l) >= 0 || V.indexOf(l) >= 0
72
69
  );
73
70
  } catch (i) {
74
71
  return console.log(i), !0;
75
72
  }
76
73
  }),
77
- dropdownRender: u,
78
- children: a === null ? void 0 : a ?? (s && (s == null ? void 0 : s.map(T ?? I)))
74
+ popupRender: u,
75
+ children: d === null ? void 0 : d ?? (s ? s == null ? void 0 : s.map(T ?? H) : /* @__PURE__ */ t(j, {}))
79
76
  }
80
77
  )
81
78
  }
@@ -84,5 +81,5 @@ function Q({
84
81
  );
85
82
  }
86
83
  export {
87
- Q as default
84
+ Y as default
88
85
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),p=require("antd"),N=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"),E=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"),B=require("../util/CrudUtil.cjs.js");function re(j){const{label:s,name:c,type:g,required:i,hidden:w,rules:u=[],updatable:m=!0,readonly:S=!1,fieldClassName:f,customFormFieldRender:O,fieldTooltip:b,...t}=j,h=p.Form.useFormInstance();N.useEffect(()=>{if(g==="select"){const{items:n=[],onSearch:o,searchOnType:l}=t;!(n!=null&&n.length)&&!l&&(o==null||o(void 0,h,t==null?void 0:t.updatingValue))}},[h,t,g,t==null?void 0:t.updatingValue]);const{t:q}=z.useTranslationLib();if(S||w)return e.jsx(e.Fragment,{});if(O)return O(h,j);switch(g){case"text":case"email":case"password":{const{onChange:n,placeholder:o}=t;return e.jsx(V.default,{placeholder:o,disabled:!m,rules:u,required:i,onChange:n?l=>n(l,h):void 0,type:g,name:c,tooltip:b,label:s,className:f,autoComplete:"new-password"})}case"number":{const{onChange:n,placeholder:o,allowMinus:l}=t;return e.jsx(Z,{placeholder:o,disabled:!m,moneyField:!!t.formatted,type:g,onChange:n?x=>n(x,h):void 0,rules:u,autoComplete:"false",required:i,tooltip:b,className:f,min:l?null:void 0,name:c,label:s})}case"date":{const{range:n,disableToday:o,disabledFutureDays:l,disabledPastDays:x,onChange:v,placeholder:C,format:F}=t;return e.jsx(X,{placeholder:C,required:i,disabled:!m,type:g,format:F,tooltip:b,range:n,name:c,label:s,onChange:v?y=>v(y,h):void 0,className:f,disableToday:o,disabledFutureDays:l,disabledPastDays:x})}case"time":{const{range:n=!1,disableCurrent:o,disabledFuture:l,disabledPast:x,onChange:v,use12Hours:C,format:F,placeholder:y}=t;return e.jsx(Y,{placeholder:y,required:i,format:F,disabled:!m,type:g,tooltip:b,range:n,use12Hours:C,name:c,label:s,onChange:v?a=>v(a,h):void 0,className:f,disableCurrent:o,disabledFuture:l,disabledPast:x})}case"textarea":return e.jsx(te,{...j});case"image":return e.jsx(K.default,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"file":return e.jsx(J.default,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"select":return e.jsx(H,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,form:h,updatable:m,readonly:S,fieldTooltip:b});case"enum":{const{enum:n,radio:o=!1,translation:l,onChange:x,onSearch:v,multiple:C,tagRender:F}=t,y=Array.isArray(n)?n:Object.keys(n);return o?e.jsx(p.Form.Item,{...t,name:c,required:i,tooltip:b,rules:u,label:s,className:["w-100",f].join(" "),children:e.jsx(p.Radio.Group,{...t,onChange:x?a=>{var R;return x((R=a==null?void 0:a.target)==null?void 0:R.value,h)}:void 0,children:y.map(a=>e.jsx(p.Radio,{disabled:!m,value:a,children:l?q(l[a]):a},a))})}):e.jsx(E,{...t,tagRender:typeof F=="function"?F:F?a=>{const{value:R,label:T}=a,k=F[R];return k?e.jsx(p.Tag,{color:k.color,children:T}):e.jsx(p.Tag,{children:T})}:void 0,onChange:x?a=>x(a,h):void 0,className:["w-100",f].join(" "),name:c,items:y,required:i,tooltip:b,rules:u,label:s,disabled:!m,onSearch:v?a=>v(a,h):void 0,allowClear:!0,mode:C?"multiple":void 0,itemBuilder:a=>e.jsx(p.Select.Option,{value:a,children:l?q(l[a]):a},a)})}case"checkbox":{const{onChange:n}=t;return e.jsx(Q,{className:f,rules:u,onChange:n?o=>n(o,h):void 0,label:s,tooltip:b,disabled:!m,name:c})}case"color":return e.jsx(D,{...t,type:"color",required:i,name:c,label:s,rules:u,fieldClassName:f,updatable:m,readonly:S,fieldTooltip:b});default:return e.jsx(e.Fragment,{children:`${g} Not Implemented`})}}function H(j){const{items:s=[],loading:c,searchOnType:g,onSearch:i,multiple:w,onChange:u,highlightSearch:m,required:S,fieldClassName:f,rules:O,fieldTooltip:b,updatable:t,label:h,name:q,tagRender:n,updatingValue:o,onSet:l,placeholder:x,allowClear:v=!0}=j,C=j.form,[F,y]=N.useState(""),a=N.useMemo(()=>B.getRealName(q),[q]),R=N.useMemo(()=>B.getRealName(q,"upsertFieldName"),[q]),T=p.Form.useWatch(a,C),[k,P]=N.useState(!0);N.useEffect(()=>{l&&k&&T&&(l==null||l(T,s,C),P(!1))},[k,C,s,a,l,T]),N.useEffect(()=>{T&&P(!0)},[T]);const _=N.useCallback(async r=>{y(r),g&&(i==null||i(r,C,o))},[C,i,g,o]);return e.jsx(E,{...j,maxTagCount:"responsive",maxTagPlaceholder:r=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:r.map(d=>e.jsxs(e.Fragment,{children:[d.label," ",e.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:x,onSelect:r=>{l==null||l(r==null?void 0:r.key,s,C)},onChange:u?r=>{y(""),u(r,C)}:void 0,mode:w?"multiple":void 0,className:["w-100",f].join(" "),name:R,items:s,required:S,tooltip:b,tagRender:n,rules:O,disabled:!t,label:h,allowClear:v,onSearch:_,loading:c,filterOption:m?(r,d)=>{var I,L,M;try{const U=r.toLowerCase().split(/\s+/),W=((typeof(d==null?void 0:d.children)=="string"?d==null?void 0:d.children:(L=(I=d==null?void 0:d.children)==null?void 0:I.props)==null?void 0:L.textToHighlight)??"").toLowerCase(),G=(((M=d==null?void 0:d.value)==null?void 0:M.toString())??"").toLowerCase();return U.every(A=>W.indexOf(A)>=0||G.indexOf(A)>=0)}catch{return!0}}:void 0,itemBuilder:m?r=>{const d=r.value?String(r.value):void 0;return e.jsx(p.Select.Option,{value:r.key,title:d,disabled:r.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(F??"").split(" "),autoEscape:!0,textToHighlight:d??""})},r.key)}:r=>e.jsx(p.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:r.value},r.key)})}function D(j){const{required:s,fieldClassName:c,rules:g,fieldTooltip:i,updatable:w,label:u,name:m}=j;return e.jsx(p.Form.Item,{label:u,name:m,required:s,rules:g,tooltip:i,children:e.jsx(p.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:c,disabled:!w,...j.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=H;exports.default=re;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),p=require("antd"),T=require("react"),$=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"),E=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"),B=require("../util/CrudUtil.cjs.js");function re(j){const{label:s,name:c,type:g,required:i,hidden:S,rules:u=[],updatable:m=!0,readonly:w=!1,fieldClassName:f,customFormFieldRender:O,fieldTooltip:b,...t}=j,h=p.Form.useFormInstance();T.useEffect(()=>{if(g==="select"){const{items:n=[],onSearch:o,searchOnType:l}=t;!(n!=null&&n.length)&&!l&&(o==null||o(void 0,h,t==null?void 0:t.updatingValue))}},[h,t,g,t==null?void 0:t.updatingValue]);const{t:q}=z.useTranslationLibNoNS();if(w||S)return e.jsx(e.Fragment,{});if(O)return O(h,j);switch(g){case"text":case"email":case"password":{const{onChange:n,placeholder:o}=t;return e.jsx(V.default,{placeholder:o,disabled:!m,rules:u,required:i,onChange:n?l=>n(l,h):void 0,type:g,name:c,tooltip:b,label:s,className:f,autoComplete:"new-password"})}case"number":{const{onChange:n,placeholder:o,allowMinus:l}=t;return e.jsx(Z,{placeholder:o,disabled:!m,moneyField:!!t.formatted,type:g,onChange:n?x=>n(x,h):void 0,rules:u,autoComplete:"false",required:i,tooltip:b,className:f,min:l?null:void 0,name:c,label:s})}case"date":{const{range:n,disableToday:o,disabledFutureDays:l,disabledPastDays:x,onChange:v,placeholder:C,format:F}=t;return e.jsx(X,{placeholder:C,required:i,disabled:!m,type:g,format:F,tooltip:b,range:n,name:c,label:s,onChange:v?y=>v(y,h):void 0,className:f,disableToday:o,disabledFutureDays:l,disabledPastDays:x})}case"time":{const{range:n=!1,disableCurrent:o,disabledFuture:l,disabledPast:x,onChange:v,use12Hours:C,format:F,placeholder:y}=t;return e.jsx(Y,{placeholder:y,required:i,format:F,disabled:!m,type:g,tooltip:b,range:n,use12Hours:C,name:c,label:s,onChange:v?a=>v(a,h):void 0,className:f,disableCurrent:o,disabledFuture:l,disabledPast:x})}case"textarea":return e.jsx(te,{...j});case"image":return e.jsx(K.default,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"file":return e.jsx(J.default,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"select":return e.jsx(H,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,form:h,updatable:m,readonly:w,fieldTooltip:b});case"enum":{const{enum:n,radio:o=!1,translation:l,onChange:x,onSearch:v,multiple:C,tagRender:F}=t,y=Array.isArray(n)?n:Object.keys(n);return o?e.jsx(p.Form.Item,{...t,name:c,required:i,tooltip:b,rules:u,label:s,className:["w-100",f].join(" "),children:e.jsx(p.Radio.Group,{...t,onChange:x?a=>{var R;return x((R=a==null?void 0:a.target)==null?void 0:R.value,h)}:void 0,children:y.map(a=>e.jsx(p.Radio,{disabled:!m,value:a,children:l?q(l[a]):a},a))})}):e.jsx(E,{...t,tagRender:typeof F=="function"?F:F?a=>{const{value:R,label:N}=a,k=F[R];return k?e.jsx(p.Tag,{color:k.color,children:N}):e.jsx(p.Tag,{children:N})}:void 0,onChange:x?a=>x(a,h):void 0,className:["w-100",f].join(" "),name:c,items:y,required:i,tooltip:b,rules:u,label:s,disabled:!m,onSearch:v?a=>v(a,h):void 0,allowClear:!0,mode:C?"multiple":void 0,itemBuilder:a=>e.jsx(p.Select.Option,{value:a,children:l?q(l[a]):a},a)})}case"checkbox":{const{onChange:n}=t;return e.jsx(Q,{className:f,rules:u,onChange:n?o=>n(o,h):void 0,label:s,tooltip:b,disabled:!m,name:c})}case"color":return e.jsx(D,{...t,type:"color",required:i,name:c,label:s,rules:u,fieldClassName:f,updatable:m,readonly:w,fieldTooltip:b});default:return e.jsx(e.Fragment,{children:`${g} Not Implemented`})}}function H(j){const{items:s=[],loading:c,searchOnType:g,onSearch:i,multiple:S,onChange:u,highlightSearch:m,required:w,fieldClassName:f,rules:O,fieldTooltip:b,updatable:t,label:h,name:q,tagRender:n,updatingValue:o,onSet:l,placeholder:x,allowClear:v=!0}=j,C=j.form,[F,y]=T.useState(""),a=T.useMemo(()=>B.getRealName(q),[q]),R=T.useMemo(()=>B.getRealName(q,"upsertFieldName"),[q]),N=p.Form.useWatch(a,C),[k,P]=T.useState(!0);T.useEffect(()=>{l&&k&&N&&(l==null||l(N,s,C),P(!1))},[k,C,s,a,l,N]),T.useEffect(()=>{N&&P(!0)},[N]);const _=T.useCallback(async r=>{y(r),g&&(i==null||i(r,C,o))},[C,i,g,o]);return e.jsx(E,{...j,maxTagCount:"responsive",maxTagPlaceholder:r=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:r.map(d=>e.jsxs(e.Fragment,{children:[d.label," ",e.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:x,onSelect:r=>{l==null||l(r==null?void 0:r.key,s,C)},onChange:u?r=>{y(""),u(r,C)}:void 0,mode:S?"multiple":void 0,className:["w-100",f].join(" "),name:R,items:s,required:w,tooltip:b,tagRender:n,rules:O,disabled:!t,label:h,allowClear:v,onSearch:_,loading:c,filterOption:m?(r,d)=>{var I,L,M;try{const U=r.toLowerCase().split(/\s+/),W=((typeof(d==null?void 0:d.children)=="string"?d==null?void 0:d.children:(L=(I=d==null?void 0:d.children)==null?void 0:I.props)==null?void 0:L.textToHighlight)??"").toLowerCase(),G=(((M=d==null?void 0:d.value)==null?void 0:M.toString())??"").toLowerCase();return U.every(A=>W.indexOf(A)>=0||G.indexOf(A)>=0)}catch{return!0}}:void 0,itemBuilder:m?r=>{const d=r.value?String(r.value):void 0;return e.jsx(p.Select.Option,{value:r.key,title:d,disabled:r.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(F??"").split(" "),autoEscape:!0,textToHighlight:d??""})},r.key)}:r=>e.jsx(p.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:r.value},r.key)})}function D(j){const{required:s,fieldClassName:c,rules:g,fieldTooltip:i,updatable:S,label:u,name:m}=j;return e.jsx(p.Form.Item,{label:u,name:m,required:s,rules:g,tooltip:i,children:e.jsx(p.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:c,disabled:!S,...j.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=H;exports.default=re;
@@ -2,7 +2,7 @@ import { jsx as t, Fragment as S, jsxs as E } from "react/jsx-runtime";
2
2
  import { Form as j, Radio as M, Select as I, Tag as W, ColorPicker as X } from "antd";
3
3
  import { useEffect as L, useState as G, useMemo as _, useCallback as Y } from "react";
4
4
  import Z from "react-highlight-words";
5
- import { useTranslationLib as V } from "../locale/index.es.js";
5
+ import { useTranslationLibNoNS as V } from "../locale/index.es.js";
6
6
  import ee from "./FileCrudField.es.js";
7
7
  import re from "./ImageCrudField.es.js";
8
8
  import te from "../common/check-box/CheckBox.es.js";
@@ -94,7 +94,7 @@ function Re(v) {
94
94
  disabledPastDays: C,
95
95
  onChange: y,
96
96
  placeholder: g,
97
- format: x
97
+ format: N
98
98
  } = e;
99
99
  return /* @__PURE__ */ t(
100
100
  ae,
@@ -103,12 +103,12 @@ function Re(v) {
103
103
  required: d,
104
104
  disabled: !u,
105
105
  type: p,
106
- format: x,
106
+ format: N,
107
107
  tooltip: b,
108
108
  range: l,
109
109
  name: c,
110
110
  label: n,
111
- onChange: y ? (F) => y(F, h) : void 0,
111
+ onChange: y ? (x) => y(x, h) : void 0,
112
112
  className: f,
113
113
  disableToday: i,
114
114
  disabledFutureDays: o,
@@ -124,15 +124,15 @@ function Re(v) {
124
124
  disabledPast: C,
125
125
  onChange: y,
126
126
  use12Hours: g,
127
- format: x,
128
- placeholder: F
127
+ format: N,
128
+ placeholder: x
129
129
  } = e;
130
130
  return /* @__PURE__ */ t(
131
131
  oe,
132
132
  {
133
- placeholder: F,
133
+ placeholder: x,
134
134
  required: d,
135
- format: x,
135
+ format: N,
136
136
  disabled: !u,
137
137
  type: p,
138
138
  tooltip: b,
@@ -204,8 +204,8 @@ function Re(v) {
204
204
  onChange: C,
205
205
  onSearch: y,
206
206
  multiple: g,
207
- tagRender: x
208
- } = e, F = Array.isArray(l) ? l : Object.keys(l);
207
+ tagRender: N
208
+ } = e, x = Array.isArray(l) ? l : Object.keys(l);
209
209
  return i ? /* @__PURE__ */ t(
210
210
  j.Item,
211
211
  {
@@ -224,7 +224,7 @@ function Re(v) {
224
224
  var w;
225
225
  return C((w = a == null ? void 0 : a.target) == null ? void 0 : w.value, h);
226
226
  } : void 0,
227
- children: F.map((a) => /* @__PURE__ */ t(M, { disabled: !u, value: a, children: o ? T(o[a]) : a }, a))
227
+ children: x.map((a) => /* @__PURE__ */ t(M, { disabled: !u, value: a, children: o ? T(o[a]) : a }, a))
228
228
  }
229
229
  )
230
230
  }
@@ -232,14 +232,14 @@ function Re(v) {
232
232
  z,
233
233
  {
234
234
  ...e,
235
- tagRender: typeof x == "function" ? x : x ? (a) => {
236
- const { value: w, label: N } = a, O = x[w];
237
- return O ? /* @__PURE__ */ t(W, { color: O.color, children: N }) : /* @__PURE__ */ t(W, { children: N });
235
+ tagRender: typeof N == "function" ? N : N ? (a) => {
236
+ const { value: w, label: F } = a, O = N[w];
237
+ return O ? /* @__PURE__ */ t(W, { color: O.color, children: F }) : /* @__PURE__ */ t(W, { children: F });
238
238
  } : void 0,
239
239
  onChange: C ? (a) => C(a, h) : void 0,
240
240
  className: ["w-100", f].join(" "),
241
241
  name: c,
242
- items: F,
242
+ items: x,
243
243
  required: d,
244
244
  tooltip: b,
245
245
  rules: m,
@@ -308,15 +308,15 @@ function se(v) {
308
308
  onSet: o,
309
309
  placeholder: C,
310
310
  allowClear: y = !0
311
- } = v, g = v.form, [x, F] = G(""), a = _(() => $.getRealName(T), [T]), w = _(() => $.getRealName(T, "upsertFieldName"), [T]), N = j.useWatch(a, g), [O, U] = G(!0);
311
+ } = v, g = v.form, [N, x] = G(""), a = _(() => $.getRealName(T), [T]), w = _(() => $.getRealName(T, "upsertFieldName"), [T]), F = j.useWatch(a, g), [O, U] = G(!0);
312
312
  L(() => {
313
- o && O && N && (o == null || o(N, n, g), U(!1));
314
- }, [O, g, n, a, o, N]), L(() => {
315
- N && U(!0);
316
- }, [N]);
313
+ o && O && F && (o == null || o(F, n, g), U(!1));
314
+ }, [O, g, n, a, o, F]), L(() => {
315
+ F && U(!0);
316
+ }, [F]);
317
317
  const J = Y(
318
318
  async (r) => {
319
- F(r), p && (d == null || d(r, g, i));
319
+ x(r), p && (d == null || d(r, g, i));
320
320
  },
321
321
  [g, d, p, i]
322
322
  );
@@ -344,7 +344,7 @@ function se(v) {
344
344
  o == null || o(r == null ? void 0 : r.key, n, g);
345
345
  },
346
346
  onChange: m ? (r) => {
347
- F(""), m(r, g);
347
+ x(""), m(r, g);
348
348
  } : void 0,
349
349
  mode: k ? "multiple" : void 0,
350
350
  className: ["w-100", f].join(" "),
@@ -382,7 +382,7 @@ function se(v) {
382
382
  Z,
383
383
  {
384
384
  highlightClassName: "highlight-text",
385
- searchWords: (x ?? "").split(" "),
385
+ searchWords: (N ?? "").split(" "),
386
386
  autoEscape: !0,
387
387
  textToHighlight: s ?? ""
388
388
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./hooks/translation-constants.cjs.js"),I=require("./translations/en.cjs.js"),i=require("i18next"),o=require("react-i18next"),c={en:{[s.TRANSLATION_NAMESPACE]:I}};exports.i18nInstance=i;const N=(n={})=>{const{translations:e=c,language:t="en",i18nInstance:r}=n,a=r||i;return exports.i18nInstance=a,a.isInitialized?Object.entries(e).forEach(([u,l])=>{Object.entries(l).forEach(([T,A])=>{a.addResourceBundle(u,T,A,!0,!0)})}):a.use(o.initReactI18next).init({resources:e,lng:t,fallbackLng:"en",ns:s.TRANSLATION_NAMESPACE,interpolation:{escapeValue:!1}}),i},d=(n,e,t)=>{(t||i).addResourceBundle(n,s.TRANSLATION_NAMESPACE,e,!0,!0)},E=n=>o.useTranslation(s.TRANSLATION_NAMESPACE,{...n,i18n:exports.i18nInstance}),S=(n,e)=>{var t;return(t=exports.i18nInstance)==null?void 0:t.t(n,{ns:s.TRANSLATION_NAMESPACE,...e})};exports.defaultTranslations=c;exports.setupI18n=N;exports.t=S;exports.updateTranslations=d;exports.useTranslationLib=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./hooks/translation-constants.cjs.js"),N=require("./translations/en.cjs.js"),i=require("i18next"),r=require("react-i18next"),u={en:{[s.TRANSLATION_NAMESPACE]:N}};exports.i18nInstance=i;const I=(n={})=>{const{translations:e=u,language:t="en",i18nInstance:o}=n,a=o||i;return exports.i18nInstance=a,a.isInitialized?Object.entries(e).forEach(([c,l])=>{Object.entries(l).forEach(([T,A])=>{a.addResourceBundle(c,T,A,!0,!0)})}):a.use(r.initReactI18next).init({resources:e,lng:t,fallbackLng:"en",ns:s.TRANSLATION_NAMESPACE,interpolation:{escapeValue:!1}}),i},d=(n,e,t)=>{(t||i).addResourceBundle(n,s.TRANSLATION_NAMESPACE,e,!0,!0)},S=n=>r.useTranslation(s.TRANSLATION_NAMESPACE,{...n,i18n:exports.i18nInstance}),E=n=>r.useTranslation(void 0,{...n,i18n:exports.i18nInstance}),L=(n,e)=>{var t;return(t=exports.i18nInstance)==null?void 0:t.t(n,{ns:s.TRANSLATION_NAMESPACE,...e})};exports.defaultTranslations=u;exports.setupI18n=I;exports.t=L;exports.updateTranslations=d;exports.useTranslationLib=S;exports.useTranslationLibNoNS=E;
package/locale/index.d.ts CHANGED
@@ -80,4 +80,5 @@ export declare let i18nInstance: i18nType;
80
80
  export declare const setupI18n: (options?: SetupI18nOptions) => i18nType;
81
81
  export declare const updateTranslations: (language: string, translations: Record<string, any>, i18nInstance?: i18nType) => void;
82
82
  export declare const useTranslationLib: (options?: Omit<UseTranslationOptions<string>, "i18n">) => import('react-i18next').UseTranslationResponse<"crud-component", string>;
83
+ export declare const useTranslationLibNoNS: (options?: Omit<UseTranslationOptions<string>, "i18n">) => import('react-i18next').UseTranslationResponse<"translation", string>;
83
84
  export declare const t: (key: string, options?: any) => string | import('node_modules/i18next/typescript/helpers').$SpecialObject | import('i18next').TFunctionDetailedResult<string | import('node_modules/i18next/typescript/helpers').$SpecialObject, any>;
@@ -1,25 +1,25 @@
1
1
  import { TRANSLATION_NAMESPACE as s } from "./hooks/translation-constants.es.js";
2
- import T from "./translations/en.es.js";
2
+ import f from "./translations/en.es.js";
3
3
  import r from "i18next";
4
- import { initReactI18next as d, useTranslation as p } from "react-i18next";
4
+ import { initReactI18next as p, useTranslation as u } from "react-i18next";
5
5
  const m = {
6
6
  en: {
7
- [s]: T
7
+ [s]: f
8
8
  }
9
9
  };
10
10
  let t = r;
11
- const E = (e = {}) => {
11
+ const A = (n = {}) => {
12
12
  const {
13
- translations: n = m,
13
+ translations: e = m,
14
14
  language: i = "en",
15
15
  i18nInstance: a
16
- } = e, o = a || r;
17
- return t = o, o.isInitialized ? Object.entries(n).forEach(([u, c]) => {
18
- Object.entries(c).forEach(([l, f]) => {
19
- o.addResourceBundle(u, l, f, !0, !0);
16
+ } = n, o = a || r;
17
+ return t = o, o.isInitialized ? Object.entries(e).forEach(([c, l]) => {
18
+ Object.entries(l).forEach(([T, d]) => {
19
+ o.addResourceBundle(c, T, d, !0, !0);
20
20
  });
21
- }) : o.use(d).init({
22
- resources: n,
21
+ }) : o.use(p).init({
22
+ resources: e,
23
23
  lng: i,
24
24
  fallbackLng: "en",
25
25
  ns: s,
@@ -27,23 +27,24 @@ const E = (e = {}) => {
27
27
  escapeValue: !1
28
28
  }
29
29
  }), r;
30
- }, R = (e, n, i) => {
30
+ }, E = (n, e, i) => {
31
31
  (i || r).addResourceBundle(
32
- e,
33
- s,
34
32
  n,
33
+ s,
34
+ e,
35
35
  !0,
36
36
  !0
37
37
  );
38
- }, U = (e) => p(s, { ...e, i18n: t }), L = (e, n) => t == null ? void 0 : t.t(e, {
38
+ }, L = (n) => u(s, { ...n, i18n: t }), R = (n) => u(void 0, { ...n, i18n: t }), U = (n, e) => t == null ? void 0 : t.t(n, {
39
39
  ns: s,
40
- ...n
40
+ ...e
41
41
  });
42
42
  export {
43
43
  m as defaultTranslations,
44
44
  t as i18nInstance,
45
- E as setupI18n,
46
- L as t,
47
- R as updateTranslations,
48
- U as useTranslationLib
45
+ A as setupI18n,
46
+ U as t,
47
+ E as updateTranslations,
48
+ L as useTranslationLib,
49
+ R as useTranslationLibNoNS
49
50
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.0.58",
4
+ "version": "1.0.60",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",