@kingteza/crud-component 1.0.59 → 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";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.59",
4
+ "version": "1.0.60",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",