@kingteza/crud-component 1.0.39 → 1.0.42

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.
Files changed (68) hide show
  1. package/common/button/Button.cjs.js +1 -1
  2. package/common/button/Button.es.js +19 -20
  3. package/common/button/CloneButtonTable.cjs.js +1 -1
  4. package/common/button/CloneButtonTable.es.js +9 -10
  5. package/common/button/DeleteButtonTable.cjs.js +1 -1
  6. package/common/button/DeleteButtonTable.es.js +29 -33
  7. package/common/button/ExportButton.cjs.js +1 -1
  8. package/common/button/ExportButton.es.js +10 -11
  9. package/common/button/HideButtonTable.cjs.js +1 -1
  10. package/common/button/HideButtonTable.es.js +22 -23
  11. package/common/button/ImportButton.cjs.js +1 -1
  12. package/common/button/ImportButton.es.js +19 -20
  13. package/common/button/NewButton.cjs.js +1 -1
  14. package/common/button/NewButton.es.js +13 -14
  15. package/common/button/PrintButton.cjs.js +1 -1
  16. package/common/button/PrintButton.es.js +11 -12
  17. package/common/button/RefreshButton.cjs.js +1 -1
  18. package/common/button/RefreshButton.es.js +10 -11
  19. package/common/button/UnHideButton.cjs.js +1 -1
  20. package/common/button/UnHideButton.es.js +37 -38
  21. package/common/button/UpdateButtonTable.cjs.js +1 -1
  22. package/common/button/UpdateButtonTable.es.js +8 -9
  23. package/common/button/ViewButtonTable.cjs.js +1 -1
  24. package/common/button/ViewButtonTable.es.js +10 -11
  25. package/common/date-picker/DatePicker.cjs.js +1 -1
  26. package/common/date-picker/DatePicker.es.js +40 -41
  27. package/common/date-picker/TimePicker.cjs.js +1 -1
  28. package/common/date-picker/TimePicker.es.js +47 -48
  29. package/common/loading/LoadingIndicator.cjs.js +1 -1
  30. package/common/loading/LoadingIndicator.es.js +6 -7
  31. package/common/picker/ImagePicker.cjs.js +1 -1
  32. package/common/picker/ImagePicker.es.js +80 -81
  33. package/common/select/SelectComponent.cjs.js +1 -1
  34. package/common/select/SelectComponent.es.js +33 -34
  35. package/common/tag/StatusTag.cjs.js +1 -1
  36. package/common/tag/StatusTag.es.js +12 -13
  37. package/common/text-field/NumberField.cjs.js +1 -1
  38. package/common/text-field/NumberField.es.js +41 -42
  39. package/common/text-field/TextArea.cjs.js +1 -1
  40. package/common/text-field/TextArea.es.js +15 -16
  41. package/common/text-field/TextField.cjs.js +1 -1
  42. package/common/text-field/TextField.es.js +50 -51
  43. package/common/wizard/WizardResult.cjs.js +1 -1
  44. package/common/wizard/WizardResult.es.js +36 -38
  45. package/crud/CrudComponent.cjs.js +1 -1
  46. package/crud/CrudComponent.es.js +77 -78
  47. package/crud/CrudField.cjs.js +1 -1
  48. package/crud/CrudField.es.js +126 -127
  49. package/crud/CrudFormWizard.cjs.js +1 -1
  50. package/crud/CrudFormWizard.es.js +47 -48
  51. package/crud/FileCrudField.cjs.js +1 -1
  52. package/crud/FileCrudField.es.js +72 -73
  53. package/crud/import/CrudImportButton.cjs.js +1 -1
  54. package/crud/import/CrudImportButton.es.js +10 -11
  55. package/crud/import/CrudImportComponent.cjs.js +2 -2
  56. package/crud/import/CrudImportComponent.es.js +56 -57
  57. package/crud/view/CrudDecListView.cjs.js +1 -1
  58. package/crud/view/CrudDecListView.es.js +11 -12
  59. package/crud/view/CrudViewer.cjs.js +1 -1
  60. package/crud/view/CrudViewer.es.js +120 -121
  61. package/crud/view/CrudViewerUtil.cjs.js +1 -1
  62. package/crud/view/CrudViewerUtil.es.js +15 -17
  63. package/locale/index.cjs.js +1 -1
  64. package/locale/index.d.ts +8 -4
  65. package/locale/index.es.js +36 -24
  66. package/package.json +1 -1
  67. package/util/ValidationUtil.cjs.js +1 -1
  68. package/util/ValidationUtil.es.js +26 -23
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),m=require("@ant-design/icons"),s=require("antd"),y=require("../../common/show-more/index.cjs.js"),C=require("../FileCrudField.cjs.js"),g=require("../ImageCrudField.cjs.js"),d=require("../../locale/hooks/translation-constants.cjs.js"),j=require("i18next"),r=require("../../util/DateUtil.cjs.js"),v=require("../../util/NumberUtil.cjs.js");function x({type:a,render:i,...n}){return a==="object"?(t,u,o)=>typeof i=="function"?i(t,u,o):"":a==="select"?(t,u,o)=>{const e=n;let c=e.multiple?Array.isArray(t)?t.map(f=>f==null?void 0:f[e.innerFieldLabel??"name"]):void 0:t==null?void 0:t[e.innerFieldLabel??"name"];return(!c&&typeof t=="string"||typeof t=="number")&&(c=t),typeof i=="function"?i(c,u,o):Array.isArray(c)?c.join(", "):c}:a==="number"?(t,u,o)=>typeof i=="function"?i(t,u,o):n!=null&&n.int?v.default.toInt(t,n.formatted):v.default.toMoney(t):a==="enum"?(t,u,o)=>{var c;const e=j.t(((c=n==null?void 0:n.translation)==null?void 0:c[t??""])??t,{ns:d.TRANSLATION_NAMESPACE});return typeof i=="function"?i(t,u,o):e}:a==="date"?(t,u,o)=>{if(!t)return"-";const e=n!=null&&n.formatTime?r.formatDateTime(t):r.formatDate(t);return typeof i=="function"?i(t,u,o):e}:a==="checkbox"?(t,u,o)=>typeof i=="function"?i(t,u,o):t?l.jsx(m.CheckOutlined,{}):l.jsx(m.CloseOutlined,{}):a==="image"?(t,u,o)=>typeof i=="function"?i(t,u,o):l.jsx(g.ImageCrudCellValue,{value:t,provider:n.provider}):a==="file"?(t,u,o)=>typeof i=="function"?i(t,u,o):l.jsx(C.FileCrudCellValue,{value:t,provider:n.provider}):a==="time"?(t,u,o)=>{if(!t)return"-";const e=n==null?void 0:n.format,c=n==null?void 0:n.use12Hours,f=r.formatTime(t,e||(c?"hh:mm:ss A":void 0));return typeof i=="function"?i(t,u,o):f}:a==="color"?(t,u,o)=>typeof i=="function"?i(t,u,o):typeof t=="string"&&t.startsWith("#")?l.jsx(s.Tooltip,{title:t,children:l.jsx(s.Avatar,{style:{backgroundColor:t}})}):String(t):a==="textarea"?(t,u,o)=>{const e=(n==null?void 0:n.truncated)??1;return typeof i=="function"?i(t,u,o):e?l.jsx(y.ShowMore,{lines:e===!0?1:e,children:t}):t}:typeof i=="function"?i:t=>t}exports.getRendererValueCrudViewer=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),r=require("@ant-design/icons"),v=require("antd"),y=require("../../common/show-more/index.cjs.js"),d=require("../FileCrudField.cjs.js"),g=require("../ImageCrudField.cjs.js"),m=require("../../util/DateUtil.cjs.js"),s=require("../../util/NumberUtil.cjs.js"),x=require("../../locale/index.cjs.js");function j({type:a,render:i,...u}){return a==="object"?(t,n,o)=>typeof i=="function"?i(t,n,o):"":a==="select"?(t,n,o)=>{const e=u;let c=e.multiple?Array.isArray(t)?t.map(f=>f==null?void 0:f[e.innerFieldLabel??"name"]):void 0:t==null?void 0:t[e.innerFieldLabel??"name"];return(!c&&typeof t=="string"||typeof t=="number")&&(c=t),typeof i=="function"?i(c,n,o):Array.isArray(c)?c.join(", "):c}:a==="number"?(t,n,o)=>typeof i=="function"?i(t,n,o):u!=null&&u.int?s.default.toInt(t,u.formatted):s.default.toMoney(t):a==="enum"?(t,n,o)=>{var c;const e=x.t(((c=u==null?void 0:u.translation)==null?void 0:c[t??""])??t);return typeof i=="function"?i(t,n,o):e}:a==="date"?(t,n,o)=>{if(!t)return"-";const e=u!=null&&u.formatTime?m.formatDateTime(t):m.formatDate(t);return typeof i=="function"?i(t,n,o):e}:a==="checkbox"?(t,n,o)=>typeof i=="function"?i(t,n,o):t?l.jsx(r.CheckOutlined,{}):l.jsx(r.CloseOutlined,{}):a==="image"?(t,n,o)=>typeof i=="function"?i(t,n,o):l.jsx(g.ImageCrudCellValue,{value:t,provider:u.provider}):a==="file"?(t,n,o)=>typeof i=="function"?i(t,n,o):l.jsx(d.FileCrudCellValue,{value:t,provider:u.provider}):a==="time"?(t,n,o)=>{if(!t)return"-";const e=u==null?void 0:u.format,c=u==null?void 0:u.use12Hours,f=m.formatTime(t,e||(c?"hh:mm:ss A":void 0));return typeof i=="function"?i(t,n,o):f}:a==="color"?(t,n,o)=>typeof i=="function"?i(t,n,o):typeof t=="string"&&t.startsWith("#")?l.jsx(v.Tooltip,{title:t,children:l.jsx(v.Avatar,{style:{backgroundColor:t}})}):String(t):a==="textarea"?(t,n,o)=>{const e=(u==null?void 0:u.truncated)??1;return typeof i=="function"?i(t,n,o):e?l.jsx(y.ShowMore,{lines:e===!0?1:e,children:t}):t}:typeof i=="function"?i:t=>t}exports.getRendererValueCrudViewer=j;
@@ -1,14 +1,13 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
- import { CheckOutlined as y, CloseOutlined as A } from "@ant-design/icons";
3
- import { Tooltip as e, Avatar as C } from "antd";
4
- import { ShowMore as b } from "../../common/show-more/index.es.js";
5
- import { FileCrudCellValue as g } from "../FileCrudField.es.js";
6
- import { ImageCrudCellValue as h } from "../ImageCrudField.es.js";
7
- import { TRANSLATION_NAMESPACE as T } from "../../locale/hooks/translation-constants.es.js";
8
- import { t as S } from "i18next";
2
+ import { CheckOutlined as y, CloseOutlined as e } from "@ant-design/icons";
3
+ import { Tooltip as b, Avatar as g } from "antd";
4
+ import { ShowMore as h } from "../../common/show-more/index.es.js";
5
+ import { FileCrudCellValue as C } from "../FileCrudField.es.js";
6
+ import { ImageCrudCellValue as A } from "../ImageCrudField.es.js";
9
7
  import r from "../../util/DateUtil.es.js";
10
8
  import v from "../../util/NumberUtil.es.js";
11
- function O({
9
+ import { t as x } from "../../locale/index.es.js";
10
+ function I({
12
11
  type: m,
13
12
  render: i,
14
13
  ...o
@@ -19,23 +18,22 @@ function O({
19
18
  return (!a && typeof t == "string" || typeof t == "number") && (a = t), typeof i == "function" ? i(a, n, f) : Array.isArray(a) ? a.join(", ") : a;
20
19
  } : m === "number" ? (t, n, f) => typeof i == "function" ? i(t, n, f) : o != null && o.int ? v.toInt(t, o.formatted) : v.toMoney(t) : m === "enum" ? (t, n, f) => {
21
20
  var a;
22
- const u = S(
23
- ((a = o == null ? void 0 : o.translation) == null ? void 0 : a[t ?? ""]) ?? t,
24
- { ns: T }
21
+ const u = x(
22
+ ((a = o == null ? void 0 : o.translation) == null ? void 0 : a[t ?? ""]) ?? t
25
23
  );
26
24
  return typeof i == "function" ? i(t, n, f) : u;
27
25
  } : m === "date" ? (t, n, f) => {
28
26
  if (!t) return "-";
29
27
  const u = o != null && o.formatTime ? r.formatDateTime(t) : r.formatDate(t);
30
28
  return typeof i == "function" ? i(t, n, f) : u;
31
- } : m === "checkbox" ? (t, n, f) => typeof i == "function" ? i(t, n, f) : t ? /* @__PURE__ */ l(y, {}) : /* @__PURE__ */ l(A, {}) : m === "image" ? (t, n, f) => typeof i == "function" ? i(t, n, f) : /* @__PURE__ */ l(
32
- h,
29
+ } : m === "checkbox" ? (t, n, f) => typeof i == "function" ? i(t, n, f) : t ? /* @__PURE__ */ l(y, {}) : /* @__PURE__ */ l(e, {}) : m === "image" ? (t, n, f) => typeof i == "function" ? i(t, n, f) : /* @__PURE__ */ l(
30
+ A,
33
31
  {
34
32
  value: t,
35
33
  provider: o.provider
36
34
  }
37
35
  ) : m === "file" ? (t, n, f) => typeof i == "function" ? i(t, n, f) : /* @__PURE__ */ l(
38
- g,
36
+ C,
39
37
  {
40
38
  value: t,
41
39
  provider: o.provider
@@ -47,11 +45,11 @@ function O({
47
45
  u || (a ? "hh:mm:ss A" : void 0)
48
46
  );
49
47
  return typeof i == "function" ? i(t, n, f) : c;
50
- } : m === "color" ? (t, n, f) => typeof i == "function" ? i(t, n, f) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ l(e, { title: t, children: /* @__PURE__ */ l(C, { style: { backgroundColor: t } }) }) : String(t) : m === "textarea" ? (t, n, f) => {
48
+ } : m === "color" ? (t, n, f) => typeof i == "function" ? i(t, n, f) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ l(b, { title: t, children: /* @__PURE__ */ l(g, { style: { backgroundColor: t } }) }) : String(t) : m === "textarea" ? (t, n, f) => {
51
49
  const u = (o == null ? void 0 : o.truncated) ?? 1;
52
- return typeof i == "function" ? i(t, n, f) : u ? /* @__PURE__ */ l(b, { lines: u === !0 ? 1 : u, children: t }) : t;
50
+ return typeof i == "function" ? i(t, n, f) : u ? /* @__PURE__ */ l(h, { lines: u === !0 ? 1 : u, children: t }) : t;
53
51
  } : typeof i == "function" ? i : (t) => t;
54
52
  }
55
53
  export {
56
- O as getRendererValueCrudViewer
54
+ I as getRendererValueCrudViewer
57
55
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./hooks/translation-constants.cjs.js"),d=require("./translations/en.cjs.js"),n=require("i18next"),A=require("react-i18next"),o={en:{[a.TRANSLATION_NAMESPACE]:d}},I=(t={})=>{const{translations:e=o,language:s="en",i18nInstance:r}=t,i=r||n;return i.isInitialized?Object.entries(e).forEach(([u,c])=>{Object.entries(c).forEach(([l,T])=>{n.addResourceBundle(u,l,T,!0,!0)})}):i.use(A.initReactI18next).init({resources:e,lng:s,fallbackLng:"en",ns:a.TRANSLATION_NAMESPACE,interpolation:{escapeValue:!1}}),n},N=(t,e,s)=>{(s||n).addResourceBundle(t,a.TRANSLATION_NAMESPACE,e,!0,!0)};exports.defaultTranslations=o;exports.setupI18n=I;exports.updateTranslations=N;
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;
package/locale/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { TRANSLATION_NAMESPACE } from '../locale/hooks/translation-constants';
2
2
  import { default as en } from './translations/en';
3
- import { default as i18n } from 'i18next';
3
+ import { i18n as i18nType } from 'i18next';
4
+ import { UseTranslationOptions } from 'react-i18next';
4
5
  export declare const defaultTranslations: {
5
6
  en: {
6
7
  "crud-component": {
@@ -68,7 +69,10 @@ export interface SetupI18nOptions {
68
69
  [TRANSLATION_NAMESPACE]: LibTranslations;
69
70
  }>;
70
71
  language?: string;
71
- i18nInstance?: typeof i18n;
72
+ i18nInstance?: i18nType;
72
73
  }
73
- export declare const setupI18n: (options?: SetupI18nOptions) => import('i18next').i18n;
74
- export declare const updateTranslations: (language: string, translations: Record<string, any>, i18nInstance?: typeof i18n) => void;
74
+ export declare let i18nInstance: i18nType;
75
+ export declare const setupI18n: (options?: SetupI18nOptions) => i18nType;
76
+ export declare const updateTranslations: (language: string, translations: Record<string, any>, i18nInstance?: i18nType) => void;
77
+ export declare const useTranslationLib: (options?: Omit<UseTranslationOptions<string>, "i18n">) => import('react-i18next').UseTranslationResponse<"crud-component", string>;
78
+ 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,37 +1,49 @@
1
- import { TRANSLATION_NAMESPACE as o } from "./hooks/translation-constants.es.js";
2
- import f from "./translations/en.es.js";
3
- import n from "i18next";
4
- import { initReactI18next as d } from "react-i18next";
5
- const p = {
1
+ import { TRANSLATION_NAMESPACE as s } from "./hooks/translation-constants.es.js";
2
+ import T from "./translations/en.es.js";
3
+ import r from "i18next";
4
+ import { initReactI18next as d, useTranslation as p } from "react-i18next";
5
+ const m = {
6
6
  en: {
7
- [o]: f
7
+ [s]: T
8
8
  }
9
- }, A = (t = {}) => {
10
- const { translations: e = p, language: s = "en", i18nInstance: r } = t, i = r || n;
11
- return i.isInitialized ? Object.entries(e).forEach(([a, c]) => {
12
- Object.entries(c).forEach(([u, l]) => {
13
- n.addResourceBundle(a, u, l, !0, !0);
9
+ };
10
+ let t = r;
11
+ const E = (e = {}) => {
12
+ const {
13
+ translations: n = m,
14
+ language: i = "en",
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);
14
20
  });
15
- }) : i.use(d).init({
16
- resources: e,
17
- lng: s,
21
+ }) : o.use(d).init({
22
+ resources: n,
23
+ lng: i,
18
24
  fallbackLng: "en",
19
- ns: o,
25
+ ns: s,
20
26
  interpolation: {
21
27
  escapeValue: !1
22
28
  }
23
- }), n;
24
- }, E = (t, e, s) => {
25
- (s || n).addResourceBundle(
26
- t,
27
- o,
29
+ }), r;
30
+ }, R = (e, n, i) => {
31
+ (i || r).addResourceBundle(
28
32
  e,
33
+ s,
34
+ n,
29
35
  !0,
30
36
  !0
31
37
  );
32
- };
38
+ }, U = (e) => p(s, { ...e, i18n: t }), L = (e, n) => t == null ? void 0 : t.t(e, {
39
+ ns: s,
40
+ ...n
41
+ });
33
42
  export {
34
- p as defaultTranslations,
35
- A as setupI18n,
36
- E as updateTranslations
43
+ m as defaultTranslations,
44
+ t as i18nInstance,
45
+ E as setupI18n,
46
+ L as t,
47
+ R as updateTranslations,
48
+ U as useTranslationLib
37
49
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.0.39",
4
+ "version": "1.0.42",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",
@@ -1 +1 @@
1
- "use strict";const i=require("i18next"),a=require("./NumberUtil.cjs.js"),o=e=>[{required:!0,message:`${e} ${i.t("err.validation.required")}`}],s=()=>[{min:8,message:i.t("err.validation.minLength8")}],d=()=>[{type:"number",validator(e,r,t){const n=Number(r);isNaN(n)&&r||n<0||n>100?t(i.t("err.validation.percentage")):t()},message:i.t("err.validation.percentage")}],u=e=>[{max:Number(e),min:0,type:"number",message:i.t("err.validation.maximumValueExceeded").replace("%maxValue%",a.default.toMoney(e))}],l=()=>[{validator:(e,r,t)=>(r.length===12||r.length===10)&&r.search(/^([0-9]{9}[x|X|v|V])|([0-9]{12})$/)!==-1?t():t(i.t("err.validation.invalidNic"))}],m=e=>[{message:`${i.t("err.validation.invalid")} ${e}`,pattern:/^(?:0|94|\+94|0094)?(?:(11|21|23|24|25|26|27|31|32|33|34|35|36|37|38|41|45|47|51|52|54|55|57|63|65|66|67|81|91)(0|2|3|4|5|7|9)|7(0|1|2|4|5|6|7|8)\d)\d{6}$/}],v=()=>[{message:`${i.t("err.validation.positiveNumber")}`,type:"number",validator(e,r,t){r<=0?t(e.message):t()}}],g={percentageValidation:d,required:o,maxValidation:u,passwordValidation:s,nicValidation:l,phoneValidation:m,positiveNumberValidation:v};module.exports=g;
1
+ "use strict";const s=require("./NumberUtil.cjs.js"),n=require("../locale/index.cjs.js"),o=e=>[{required:!0,message:`${e} ${n.t("err.validation.required")}`}],d=()=>[{min:8,message:n.t("err.validation.minLength8")}],m=()=>[{type:"number",validator(e,t,r){const i=Number(t),a=n.t("err.validation.percentage");isNaN(i)&&t||i<0||i>100?r(a):r()},message:n.t("err.validation.percentage")}],u=e=>[{max:Number(e),min:0,type:"number",message:n.t("err.validation.maximumValueExceeded").replace("%maxValue%",s.default.toMoney(e))}],l=()=>[{validator:(e,t,r)=>{const i=n.t("err.validation.invalidNic");return(t.length===12||t.length===10)&&t.search(/^([0-9]{9}[x|X|v|V])|([0-9]{12})$/)!==-1?r():r(i)}}],g=e=>[{message:`${n.t("err.validation.invalid")} ${e}`,pattern:/^(?:0|94|\+94|0094)?(?:(11|21|23|24|25|26|27|31|32|33|34|35|36|37|38|41|45|47|51|52|54|55|57|63|65|66|67|81|91)(0|2|3|4|5|7|9)|7(0|1|2|4|5|6|7|8)\d)\d{6}$/}],c=()=>[{message:n.t("err.validation.positiveNumber"),type:"number",validator(t,r,i){r<=0?i(t.message):i()}}],v={percentageValidation:m,required:o,maxValidation:u,passwordValidation:d,nicValidation:l,phoneValidation:g,positiveNumberValidation:c};module.exports=v;
@@ -1,59 +1,62 @@
1
- import { t as r } from "i18next";
2
- import n from "./NumberUtil.es.js";
1
+ import s from "./NumberUtil.es.js";
2
+ import { t as a } from "../locale/index.es.js";
3
3
  const o = (e) => [
4
4
  {
5
5
  required: !0,
6
- message: `${e} ${r("err.validation.required")}`
6
+ message: `${e} ${a("err.validation.required")}`
7
7
  }
8
- ], s = () => [
8
+ ], m = () => [
9
9
  {
10
10
  min: 8,
11
- message: r("err.validation.minLength8")
11
+ message: a("err.validation.minLength8")
12
12
  }
13
13
  ], d = () => [
14
14
  {
15
15
  type: "number",
16
- validator(e, t, i) {
17
- const a = Number(t);
18
- isNaN(a) && t ? i(r("err.validation.percentage")) : a < 0 || a > 100 ? i(r("err.validation.percentage")) : i();
16
+ validator(e, r, t) {
17
+ const i = Number(r), n = a("err.validation.percentage");
18
+ isNaN(i) && r || i < 0 || i > 100 ? t(n) : t();
19
19
  },
20
- message: r("err.validation.percentage")
20
+ message: a("err.validation.percentage")
21
21
  }
22
- ], m = (e) => [
22
+ ], u = (e) => [
23
23
  {
24
24
  max: Number(e),
25
25
  min: 0,
26
26
  type: "number",
27
- message: r("err.validation.maximumValueExceeded").replace(
27
+ message: a("err.validation.maximumValueExceeded").replace(
28
28
  "%maxValue%",
29
- n.toMoney(e)
29
+ s.toMoney(e)
30
30
  )
31
31
  }
32
32
  ], l = () => [
33
33
  {
34
- validator: (e, t, i) => t.length === 12 || t.length === 10 ? t.search(/^([0-9]{9}[x|X|v|V])|([0-9]{12})$/) !== -1 ? i() : i(r("err.validation.invalidNic")) : i(r("err.validation.invalidNic"))
34
+ validator: (e, r, t) => {
35
+ const i = a("err.validation.invalidNic");
36
+ return (r.length === 12 || r.length === 10) && r.search(/^([0-9]{9}[x|X|v|V])|([0-9]{12})$/) !== -1 ? t() : t(i);
37
+ }
35
38
  }
36
- ], u = (e) => [
39
+ ], g = (e) => [
37
40
  {
38
- message: `${r("err.validation.invalid")} ${e}`,
41
+ message: `${a("err.validation.invalid")} ${e}`,
39
42
  pattern: /^(?:0|94|\+94|0094)?(?:(11|21|23|24|25|26|27|31|32|33|34|35|36|37|38|41|45|47|51|52|54|55|57|63|65|66|67|81|91)(0|2|3|4|5|7|9)|7(0|1|2|4|5|6|7|8)\d)\d{6}$/
40
43
  }
41
- ], v = () => [
44
+ ], p = () => [
42
45
  {
43
- message: `${r("err.validation.positiveNumber")}`,
46
+ message: a("err.validation.positiveNumber"),
44
47
  type: "number",
45
- validator(e, t, i) {
46
- t <= 0 ? i(e.message) : i();
48
+ validator(r, t, i) {
49
+ t <= 0 ? i(r.message) : i();
47
50
  }
48
51
  }
49
52
  ], V = {
50
53
  percentageValidation: d,
51
54
  required: o,
52
- maxValidation: m,
53
- passwordValidation: s,
55
+ maxValidation: u,
56
+ passwordValidation: m,
54
57
  nicValidation: l,
55
- phoneValidation: u,
56
- positiveNumberValidation: v
58
+ phoneValidation: g,
59
+ positiveNumberValidation: p
57
60
  };
58
61
  export {
59
62
  V as default