@kingteza/crud-component 1.0.24 → 1.0.25

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 (204) hide show
  1. package/App.d.ts +2 -0
  2. package/components/common/DatePicker/DatePicker.cjs +1 -0
  3. package/components/common/DatePicker/DatePicker.d.ts +37 -0
  4. package/components/common/DatePicker/DatePicker.js +88 -0
  5. package/components/common/DatePicker/TimePicker.cjs +1 -0
  6. package/components/common/DatePicker/TimePicker.d.ts +34 -0
  7. package/components/common/DatePicker/TimePicker.js +78 -0
  8. package/components/common/DatePicker/index.d.ts +3 -0
  9. package/components/common/appearance/Hider.cjs +1 -0
  10. package/components/common/appearance/Hider.d.ts +6 -0
  11. package/components/common/appearance/Hider.js +5 -0
  12. package/components/common/appearance/index.d.ts +0 -0
  13. package/components/common/button/Button.cjs +1 -0
  14. package/components/common/button/Button.d.ts +12 -0
  15. package/components/common/button/Button.js +79 -0
  16. package/components/common/button/CloneButtonTable.cjs +1 -0
  17. package/components/common/button/CloneButtonTable.d.ts +6 -0
  18. package/components/common/button/CloneButtonTable.js +20 -0
  19. package/components/common/button/DeleteButtonTable.cjs +1 -0
  20. package/components/common/button/DeleteButtonTable.d.ts +13 -0
  21. package/components/common/button/DeleteButtonTable.js +68 -0
  22. package/components/common/button/ExportButton.cjs +1 -0
  23. package/components/common/button/ExportButton.d.ts +4 -0
  24. package/components/common/button/ExportButton.js +27 -0
  25. package/components/common/button/HideButtonTable.cjs +1 -0
  26. package/components/common/button/HideButtonTable.d.ts +13 -0
  27. package/components/common/button/HideButtonTable.js +68 -0
  28. package/components/common/button/ImportButton.cjs +1 -0
  29. package/components/common/button/ImportButton.d.ts +9 -0
  30. package/components/common/button/ImportButton.js +56 -0
  31. package/components/common/button/NewButton.cjs +1 -0
  32. package/components/common/button/NewButton.d.ts +12 -0
  33. package/components/common/button/NewButton.js +24 -0
  34. package/components/common/button/PrintButton.cjs +1 -0
  35. package/components/common/button/PrintButton.d.ts +12 -0
  36. package/components/common/button/PrintButton.js +26 -0
  37. package/components/common/button/RefreshButton.cjs +1 -0
  38. package/components/common/button/RefreshButton.d.ts +11 -0
  39. package/components/common/button/RefreshButton.js +24 -0
  40. package/components/common/button/UnHideButton.cjs +1 -0
  41. package/components/common/button/UnHideButton.d.ts +14 -0
  42. package/components/common/button/UnHideButton.js +70 -0
  43. package/components/common/button/UpdateButtonTable.cjs +1 -0
  44. package/components/common/button/UpdateButtonTable.d.ts +6 -0
  45. package/components/common/button/UpdateButtonTable.js +20 -0
  46. package/components/common/button/ViewButtonTable.cjs +1 -0
  47. package/components/common/button/ViewButtonTable.d.ts +6 -0
  48. package/components/common/button/ViewButtonTable.js +20 -0
  49. package/components/common/button/index.d.ts +14 -0
  50. package/components/common/check-box/CheckBox.cjs +1 -0
  51. package/components/common/check-box/CheckBox.d.ts +9 -0
  52. package/components/common/check-box/CheckBox.js +40 -0
  53. package/components/common/check-box/index.d.ts +2 -0
  54. package/components/common/description/DescList.cjs +1 -0
  55. package/components/common/description/DescList.d.ts +18 -0
  56. package/components/common/description/DescList.js +16 -0
  57. package/components/common/description/DescriptionComponent.d.ts +7 -0
  58. package/components/common/description/index.d.ts +3 -0
  59. package/components/common/index.d.ts +22 -0
  60. package/components/common/layout/VerticalSpace.cjs +1 -0
  61. package/components/common/layout/VerticalSpace.d.ts +5 -0
  62. package/components/common/layout/VerticalSpace.js +6 -0
  63. package/components/common/layout/index.d.ts +2 -0
  64. package/components/common/loading/LoadingIndicator.cjs +1 -0
  65. package/components/common/loading/LoadingIndicator.d.ts +6 -0
  66. package/components/common/loading/LoadingIndicator.js +24 -0
  67. package/components/common/loading/index.d.ts +2 -0
  68. package/components/common/picker/ImagePicker.cjs +1 -0
  69. package/components/common/picker/ImagePicker.d.ts +56 -0
  70. package/components/common/picker/ImagePicker.js +282 -0
  71. package/components/common/picker/index.d.ts +2 -0
  72. package/components/common/radio/RadioGroupComponent.cjs +1 -0
  73. package/components/common/radio/RadioGroupComponent.d.ts +18 -0
  74. package/components/common/radio/RadioGroupComponent.js +19 -0
  75. package/components/common/radio/index.d.ts +2 -0
  76. package/components/common/report/SelectFieldInReport.cjs +1 -0
  77. package/components/common/report/SelectFieldInReport.d.ts +16 -0
  78. package/components/common/report/SelectFieldInReport.js +30 -0
  79. package/components/common/report/index.d.ts +3 -0
  80. package/components/common/select/CustomSelectOption.cjs +1 -0
  81. package/components/common/select/CustomSelectOption.d.ts +7 -0
  82. package/components/common/select/CustomSelectOption.js +13 -0
  83. package/components/common/select/SelectComponent.cjs +1 -0
  84. package/components/common/select/SelectComponent.d.ts +21 -0
  85. package/components/common/select/SelectComponent.js +89 -0
  86. package/components/common/select/index.d.ts +3 -0
  87. package/components/common/show-more/index.cjs +1 -0
  88. package/components/common/show-more/index.d.ts +4 -0
  89. package/components/common/show-more/index.js +8 -0
  90. package/components/common/tab/TabViewWithRoute.cjs +1 -0
  91. package/components/common/tab/TabViewWithRoute.d.ts +13 -0
  92. package/components/common/tab/TabViewWithRoute.js +38 -0
  93. package/components/common/tab/index.d.ts +2 -0
  94. package/components/common/table/index.d.ts +3 -0
  95. package/components/common/table/table.cjs +1 -0
  96. package/components/common/table/table.d.ts +19 -0
  97. package/components/common/table/table.js +40 -0
  98. package/components/common/tag/StatusTag.cjs +1 -0
  99. package/components/common/tag/StatusTag.d.ts +14 -0
  100. package/components/common/tag/StatusTag.js +30 -0
  101. package/components/common/tag/index.d.ts +2 -0
  102. package/components/common/text/index.cjs +1 -0
  103. package/components/common/text/index.d.ts +3 -0
  104. package/components/common/text/index.js +5 -0
  105. package/components/common/text/title/TitleWithHeadTitle.d.ts +7 -0
  106. package/components/common/text/title/index.cjs +1 -0
  107. package/components/common/text/title/index.d.ts +1 -0
  108. package/components/common/text/title/index.js +5 -0
  109. package/components/common/text-field/NumberField.cjs +1 -0
  110. package/components/common/text-field/NumberField.d.ts +13 -0
  111. package/components/common/text-field/NumberField.js +83 -0
  112. package/components/common/text-field/PhoneNumberField.cjs +1 -0
  113. package/components/common/text-field/PhoneNumberField.d.ts +4 -0
  114. package/components/common/text-field/PhoneNumberField.js +18 -0
  115. package/components/common/text-field/TextArea.cjs +1 -0
  116. package/components/common/text-field/TextArea.d.ts +17 -0
  117. package/components/common/text-field/TextArea.js +47 -0
  118. package/components/common/text-field/TextField.cjs +1 -0
  119. package/components/common/text-field/TextField.d.ts +27 -0
  120. package/components/common/text-field/TextField.js +73 -0
  121. package/components/common/text-field/index.d.ts +5 -0
  122. package/components/common/tooltip/TooltipComponent.cjs +1 -0
  123. package/components/common/tooltip/TooltipComponent.d.ts +5 -0
  124. package/components/common/tooltip/TooltipComponent.js +9 -0
  125. package/components/common/tooltip/index.d.ts +2 -0
  126. package/components/common/wizard/WizardResult.cjs +1 -0
  127. package/components/common/wizard/WizardResult.d.ts +16 -0
  128. package/components/common/wizard/WizardResult.js +60 -0
  129. package/components/common/wizard/WizardViewForm.cjs +1 -0
  130. package/components/common/wizard/WizardViewForm.d.ts +24 -0
  131. package/components/common/wizard/WizardViewForm.js +74 -0
  132. package/components/common/wizard/index.d.ts +3 -0
  133. package/components/crud/CrudComponent.cjs +1 -0
  134. package/components/crud/CrudComponent.d.ts +237 -0
  135. package/components/crud/CrudComponent.js +210 -0
  136. package/components/crud/CrudField.cjs +1 -0
  137. package/components/crud/CrudField.d.ts +4 -0
  138. package/components/crud/CrudField.js +459 -0
  139. package/components/crud/CrudForm.cjs +1 -0
  140. package/components/crud/CrudForm.d.ts +14 -0
  141. package/components/crud/CrudForm.js +91 -0
  142. package/components/crud/CrudFormWizard.cjs +1 -0
  143. package/components/crud/CrudFormWizard.d.ts +14 -0
  144. package/components/crud/CrudFormWizard.js +140 -0
  145. package/components/crud/CrudReportComponent.cjs +4 -0
  146. package/components/crud/CrudReportComponent.d.ts +44 -0
  147. package/components/crud/CrudReportComponent.js +255 -0
  148. package/components/crud/CrudSearchComponent.cjs +1 -0
  149. package/components/crud/CrudSearchComponent.d.ts +21 -0
  150. package/components/crud/CrudSearchComponent.js +95 -0
  151. package/components/crud/FileCrudField.cjs +1 -0
  152. package/components/crud/FileCrudField.d.ts +25 -0
  153. package/components/crud/FileCrudField.js +220 -0
  154. package/components/crud/ImageCrudField.cjs +1 -0
  155. package/components/crud/ImageCrudField.d.ts +38 -0
  156. package/components/crud/ImageCrudField.js +113 -0
  157. package/components/crud/import/CrudImportButton.cjs +1 -0
  158. package/components/crud/import/CrudImportButton.d.ts +3 -0
  159. package/components/crud/import/CrudImportButton.js +31 -0
  160. package/components/crud/import/CrudImportComponent.cjs +2 -0
  161. package/components/crud/import/CrudImportComponent.d.ts +14 -0
  162. package/components/crud/import/CrudImportComponent.js +223 -0
  163. package/components/crud/index.d.ts +15 -0
  164. package/components/crud/view/CrudDecListView.cjs +1 -0
  165. package/components/crud/view/CrudDecListView.d.ts +14 -0
  166. package/components/crud/view/CrudDecListView.js +42 -0
  167. package/components/crud/view/CrudViewer.cjs +1 -0
  168. package/components/crud/view/CrudViewer.d.ts +43 -0
  169. package/components/crud/view/CrudViewer.js +217 -0
  170. package/components/crud/view/CrudViewerUtil.cjs +1 -0
  171. package/components/crud/view/CrudViewerUtil.d.ts +2 -0
  172. package/components/crud/view/CrudViewerUtil.js +57 -0
  173. package/components/crud/view/index.d.ts +5 -0
  174. package/index.cjs +1 -0
  175. package/index.d.ts +4 -0
  176. package/index.js +32 -0
  177. package/locale/hooks/translation-constants.cjs +1 -0
  178. package/locale/hooks/translation-constants.d.ts +1 -0
  179. package/locale/hooks/translation-constants.js +4 -0
  180. package/locale/index.cjs +1 -0
  181. package/locale/index.d.ts +74 -0
  182. package/locale/index.js +37 -0
  183. package/locale/translations/en.cjs +1 -0
  184. package/locale/translations/en.d.ts +58 -0
  185. package/locale/translations/en.js +60 -0
  186. package/main.d.ts +0 -0
  187. package/package.json +2 -2
  188. package/util/DateUtil.cjs +1 -0
  189. package/util/DateUtil.d.ts +7 -0
  190. package/util/DateUtil.js +6 -0
  191. package/util/ImageUtil.cjs +1 -0
  192. package/util/ImageUtil.d.ts +14 -0
  193. package/util/ImageUtil.js +63 -0
  194. package/util/NumberUtil.cjs +1 -0
  195. package/util/NumberUtil.d.ts +17 -0
  196. package/util/NumberUtil.js +60 -0
  197. package/util/ValidationUtil.cjs +1 -0
  198. package/util/ValidationUtil.d.ts +14 -0
  199. package/util/ValidationUtil.js +60 -0
  200. package/util/index.cjs +1 -0
  201. package/util/index.d.ts +4 -0
  202. package/util/index.js +10 -0
  203. package/vite-env.d.ts +1 -0
  204. package/README.md +0 -89
@@ -0,0 +1,60 @@
1
+ const e = {
2
+ str: {
3
+ delete: "Delete",
4
+ clone: "Clone",
5
+ update: "Update",
6
+ new: "New",
7
+ back: "Back",
8
+ next: "Next",
9
+ save: "Save",
10
+ import: "Import",
11
+ cancel: "Cancel",
12
+ print: "Print",
13
+ hide: "Hide",
14
+ no: "No",
15
+ action: "Action",
16
+ remove: "Remove",
17
+ view: "View",
18
+ ok: "Ok",
19
+ yes: "Yes",
20
+ warning: "Warning",
21
+ success: "Success",
22
+ error: "Error",
23
+ retry: "Retry",
24
+ previous: "Previous",
25
+ unhide: "Unhide",
26
+ downloadCsvTemplate: "Download CSV Template",
27
+ importCsvFile: "Import CSV File",
28
+ export: "Export",
29
+ goBack: "Go Back",
30
+ refresh: "Refresh",
31
+ fileUploadMessage1: "Drag file here or ",
32
+ fileUploadMessage2: "Click to Upload"
33
+ },
34
+ err: {
35
+ save: "An error occurred while saving",
36
+ validation: {
37
+ required: "is required",
38
+ minLength8: "must be at least 8 characters",
39
+ percentage: "must be a percentage",
40
+ maximumValueExceeded: "must be less than %maxValue%",
41
+ invalidNic: "must be a valid NIC",
42
+ invalid: "must be a valid"
43
+ },
44
+ notFound: "Not Found"
45
+ },
46
+ message: {
47
+ loading: {
48
+ saving: "Saving"
49
+ }
50
+ },
51
+ qus: {
52
+ importWithIssues: "Some fields have issues. Do you want to proceed with the import?",
53
+ doYouWantToDelete: "Do you want to delete?",
54
+ doYouWantToHide: "Do you want to hide?",
55
+ doYouWantToUnhide: "Do you want to unhide?"
56
+ }
57
+ };
58
+ export {
59
+ e as default
60
+ };
package/main.d.ts ADDED
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.0.24",
4
+ "version": "1.0.25",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",
@@ -33,7 +33,7 @@
33
33
  "dev": "vite",
34
34
  "clean": "rm -rf dist",
35
35
  "build": "npm run clean && tsc && vite build && cp package.json dist/",
36
- "prepublishOnly": "npm run clean && npm run build",
36
+ "publish-npm": "yarn build && cd dist && npm publish",
37
37
  "lint": "eslint .",
38
38
  "preview": "vite preview"
39
39
  },
@@ -0,0 +1 @@
1
+ "use strict";const e=require("dayjs"),a=require("i18next"),o=t=>e(t).locale(a.language).format("YYYY-MM-DD HH:mm"),m=t=>e(t).locale(a.language).format("YYYY-MM-DD HH:mm:ss"),n=t=>e(t).locale(a.language).format("YYYY-MM-DD"),s=(t,r="HH:mm:ss")=>e(t).locale(a.language).format(r),c={formatDateTime:o,formatDate:n,formatDateTimeWithSecond:m,formatTime:s};module.exports=c;
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ formatDateTime: (d?: Date) => string;
3
+ formatDate: (d?: Date) => string;
4
+ formatDateTimeWithSecond: (d?: Date) => string;
5
+ formatTime: (d?: Date, format?: string) => string;
6
+ };
7
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import t from "dayjs";
2
+ import o from "i18next";
3
+ const m = (a) => t(a).locale(o.language).format("YYYY-MM-DD HH:mm"), r = (a) => t(a).locale(o.language).format("YYYY-MM-DD HH:mm:ss"), n = (a) => t(a).locale(o.language).format("YYYY-MM-DD"), l = (a, e = "HH:mm:ss") => t(a).locale(o.language).format(e), s = { formatDateTime: m, formatDate: n, formatDateTimeWithSecond: r, formatTime: l };
4
+ export {
5
+ s as default
6
+ };
@@ -0,0 +1 @@
1
+ "use strict";const c=require("browser-image-compression");class g{async resizeImage(t){const e=await c(t,{maxSizeMB:1,maxWidthOrHeight:1920,useWebWorker:!0}),a=t.uid;return Object.assign(e,{uid:a,lastModifiedDate:new Date})}async getImageData(t){const e=await this.getImageData0(t);if(e){const a=new Image;a.src=e.data;const o=await new Promise(n=>{a.onload=function(){n({height:a.height,width:a.width})}});return Object.assign(e,o),e}else return null}async getImageData0(t){try{if(t.startsWith("data:image/")){const e=t.match(/^data:image\/(png|jpeg|jpg);base64,(.*)$/);if(!e)throw new Error("Invalid base64 image data");return{data:t,type:e[1]}}else{const e=await fetch(t);if(!e.ok)throw new Error("Network response was not ok");const a=await e.blob();return new Promise((o,n)=>{const s=new FileReader;s.onloadend=function(){const r=s.result,i=r.match(/^data:image\/(png|jpeg|jpg);base64,/);i?o({data:r,type:i[1]}):n(new Error("Could not determine image type"))},s.onerror=n,s.readAsDataURL(a)})}}catch(e){return console.warn(e),null}}}const d=new g;module.exports=d;
@@ -0,0 +1,14 @@
1
+ import { RcFile } from 'antd/lib/upload';
2
+ export type ImageDataReturn = {
3
+ data: string;
4
+ type: 'png' | 'jpeg' | 'jpg';
5
+ width: number;
6
+ height: number;
7
+ } | null;
8
+ declare class ImageUtl {
9
+ resizeImage(file: RcFile): Promise<RcFile>;
10
+ getImageData(uriOrBase64: string): Promise<ImageDataReturn>;
11
+ getImageData0(uriOrBase64: string): Promise<ImageDataReturn>;
12
+ }
13
+ declare const _default: ImageUtl;
14
+ export default _default;
@@ -0,0 +1,63 @@
1
+ import c from "browser-image-compression";
2
+ class g {
3
+ async resizeImage(t) {
4
+ const e = await c(t, {
5
+ maxSizeMB: 1,
6
+ maxWidthOrHeight: 1920,
7
+ useWebWorker: !0
8
+ }), a = t.uid;
9
+ return Object.assign(e, {
10
+ uid: a,
11
+ lastModifiedDate: /* @__PURE__ */ new Date()
12
+ });
13
+ }
14
+ async getImageData(t) {
15
+ const e = await this.getImageData0(t);
16
+ if (e) {
17
+ const a = new Image();
18
+ a.src = e.data;
19
+ const o = await new Promise(
20
+ (n) => {
21
+ a.onload = function() {
22
+ n({
23
+ height: a.height,
24
+ width: a.width
25
+ });
26
+ };
27
+ }
28
+ );
29
+ return Object.assign(e, o), e;
30
+ } else
31
+ return null;
32
+ }
33
+ async getImageData0(t) {
34
+ try {
35
+ if (t.startsWith("data:image/")) {
36
+ const e = t.match(/^data:image\/(png|jpeg|jpg);base64,(.*)$/);
37
+ if (!e)
38
+ throw new Error("Invalid base64 image data");
39
+ return { data: t, type: e[1] };
40
+ } else {
41
+ const e = await fetch(t);
42
+ if (!e.ok) throw new Error("Network response was not ok");
43
+ const a = await e.blob();
44
+ return new Promise((o, n) => {
45
+ const s = new FileReader();
46
+ s.onloadend = function() {
47
+ const r = s.result, i = r.match(/^data:image\/(png|jpeg|jpg);base64,/);
48
+ i ? o({
49
+ data: r,
50
+ type: i[1]
51
+ }) : n(new Error("Could not determine image type"));
52
+ }, s.onerror = n, s.readAsDataURL(a);
53
+ });
54
+ }
55
+ } catch (e) {
56
+ return console.warn(e), null;
57
+ }
58
+ }
59
+ }
60
+ const l = new g();
61
+ export {
62
+ l as default
63
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i={minimumFractionDigits:2,maximumFractionDigits:2},a={minimumFractionDigits:0,maximumFractionDigits:0};function u(t=0){return(+t).toLocaleString("en",i)}function c(t=0,n=2){const r=e(t,n);return isNaN(r)?void 0:r}function e(t=0,n=2){switch(t=+t,(typeof n!="number"||n<0)&&(n=2),n){case 0:return Math.round(t);case 1:return Math.round(t*10)/10;case 2:return Math.round(t*100)/100;case 3:return Math.round(t*1e3)/1e3;case 4:return Math.round(t*1e4)/1e4;default:{const r=Math.pow(10,n);return Math.round(t*r)/r}}}function s(t=0,n=!1){const r=Math.floor(t);return n?r.toLocaleString("en",a):r.toString()}function d(t=1e9){return Math.floor(Math.random()*(t+1))}function o(t){const n=Number(t);return isNaN(n)?0:n}function l(t=0){const n=t.toString();if(!n.includes("."))return t;const r=n.replace(/\.?0+$/,"");return Number(r)}const f={toInt:s,round:e,toMoney:u,randInt:d,withoutNan:o,removeTrailingZeros:l,roundNoNan:c};exports.default=f;exports.withoutNan=o;
@@ -0,0 +1,17 @@
1
+ declare function toMoney(num?: number): string;
2
+ declare function roundNoNan(num?: number, pow?: number): number | undefined;
3
+ declare function round(num?: number, pow?: number): number;
4
+ declare function toInt(num?: number, formatted?: boolean): string;
5
+ declare function randInt(max?: number): number;
6
+ export declare function withoutNan(value: number): number;
7
+ declare function removeTrailingZeros(num?: number): number;
8
+ declare const _default: {
9
+ toInt: typeof toInt;
10
+ round: typeof round;
11
+ toMoney: typeof toMoney;
12
+ randInt: typeof randInt;
13
+ withoutNan: typeof withoutNan;
14
+ removeTrailingZeros: typeof removeTrailingZeros;
15
+ roundNoNan: typeof roundNoNan;
16
+ };
17
+ export default _default;
@@ -0,0 +1,60 @@
1
+ const o = {
2
+ minimumFractionDigits: 2,
3
+ maximumFractionDigits: 2
4
+ }, i = { minimumFractionDigits: 0, maximumFractionDigits: 0 };
5
+ function a(t = 0) {
6
+ return (+t).toLocaleString("en", o);
7
+ }
8
+ function u(t = 0, n = 2) {
9
+ const r = e(t, n);
10
+ return isNaN(r) ? void 0 : r;
11
+ }
12
+ function e(t = 0, n = 2) {
13
+ switch (t = +t, (typeof n != "number" || n < 0) && (n = 2), n) {
14
+ case 0:
15
+ return Math.round(t);
16
+ case 1:
17
+ return Math.round(t * 10) / 10;
18
+ case 2:
19
+ return Math.round(t * 100) / 100;
20
+ case 3:
21
+ return Math.round(t * 1e3) / 1e3;
22
+ case 4:
23
+ return Math.round(t * 1e4) / 1e4;
24
+ default: {
25
+ const r = Math.pow(10, n);
26
+ return Math.round(t * r) / r;
27
+ }
28
+ }
29
+ }
30
+ function c(t = 0, n = !1) {
31
+ const r = Math.floor(t);
32
+ return n ? r.toLocaleString("en", i) : r.toString();
33
+ }
34
+ function s(t = 1e9) {
35
+ return Math.floor(Math.random() * (t + 1));
36
+ }
37
+ function d(t) {
38
+ const n = Number(t);
39
+ return isNaN(n) ? 0 : n;
40
+ }
41
+ function f(t = 0) {
42
+ const n = t.toString();
43
+ if (!n.includes("."))
44
+ return t;
45
+ const r = n.replace(/\.?0+$/, "");
46
+ return Number(r);
47
+ }
48
+ const m = {
49
+ toInt: c,
50
+ round: e,
51
+ toMoney: a,
52
+ randInt: s,
53
+ withoutNan: d,
54
+ removeTrailingZeros: f,
55
+ roundNoNan: u
56
+ };
57
+ export {
58
+ m as default,
59
+ d as withoutNan
60
+ };
@@ -0,0 +1 @@
1
+ "use strict";const i=require("i18next"),a=require("./NumberUtil.cjs"),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;
@@ -0,0 +1,14 @@
1
+ import { Rule } from 'antd/lib/form';
2
+ declare const _default: {
3
+ percentageValidation: () => Rule[];
4
+ required: (modelName: string) => {
5
+ required: boolean;
6
+ message: string;
7
+ }[];
8
+ maxValidation: (max: number) => Rule[];
9
+ passwordValidation: () => Rule[];
10
+ nicValidation: () => Rule[];
11
+ phoneValidation: (modelName: string) => Rule[];
12
+ positiveNumberValidation: () => Rule[];
13
+ };
14
+ export default _default;
@@ -0,0 +1,60 @@
1
+ import { t as r } from "i18next";
2
+ import n from "./NumberUtil.js";
3
+ const o = (e) => [
4
+ {
5
+ required: !0,
6
+ message: `${e} ${r("err.validation.required")}`
7
+ }
8
+ ], s = () => [
9
+ {
10
+ min: 8,
11
+ message: r("err.validation.minLength8")
12
+ }
13
+ ], d = () => [
14
+ {
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();
19
+ },
20
+ message: r("err.validation.percentage")
21
+ }
22
+ ], m = (e) => [
23
+ {
24
+ max: Number(e),
25
+ min: 0,
26
+ type: "number",
27
+ message: r("err.validation.maximumValueExceeded").replace(
28
+ "%maxValue%",
29
+ n.toMoney(e)
30
+ )
31
+ }
32
+ ], l = () => [
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"))
35
+ }
36
+ ], u = (e) => [
37
+ {
38
+ message: `${r("err.validation.invalid")} ${e}`,
39
+ 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
+ }
41
+ ], v = () => [
42
+ {
43
+ message: `${r("err.validation.positiveNumber")}`,
44
+ type: "number",
45
+ validator(e, t, i) {
46
+ t <= 0 ? i(e.message) : i();
47
+ }
48
+ }
49
+ ], V = {
50
+ percentageValidation: d,
51
+ required: o,
52
+ maxValidation: m,
53
+ passwordValidation: s,
54
+ nicValidation: l,
55
+ phoneValidation: u,
56
+ positiveNumberValidation: v
57
+ };
58
+ export {
59
+ V as default
60
+ };
package/util/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./DateUtil.cjs"),e=require("./NumberUtil.cjs"),i=require("./ImageUtil.cjs"),l=require("./ValidationUtil.cjs");exports.DateUtil=t;exports.NumberUtil=e.default;exports.ImageUtil=i;exports.ValidationUtil=l;
@@ -0,0 +1,4 @@
1
+ export { default as DateUtil } from './DateUtil';
2
+ export { default as NumberUtil } from './NumberUtil';
3
+ export { default as ImageUtil } from './ImageUtil';
4
+ export { default as ValidationUtil } from './ValidationUtil';
package/util/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { default as e } from "./DateUtil.js";
2
+ import { default as o } from "./NumberUtil.js";
3
+ import { default as f } from "./ImageUtil.js";
4
+ import { default as m } from "./ValidationUtil.js";
5
+ export {
6
+ e as DateUtil,
7
+ f as ImageUtil,
8
+ o as NumberUtil,
9
+ m as ValidationUtil
10
+ };
package/vite-env.d.ts ADDED
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
package/README.md DELETED
@@ -1,89 +0,0 @@
1
- # @kingteza/crud-component
2
-
3
- React CRUD component library built with Ant Design and TypeScript.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @kingteza/crud-component
9
- ```
10
-
11
- ## Prerequisites
12
-
13
- This library has the following peer dependencies that need to be installed:
14
-
15
- ```bash
16
- npm install antd@^5.22.6 react@^18.3.1 react-dom@^18.3.1 react-router-dom@^7.0.0
17
- ```
18
-
19
- ## Setup
20
-
21
- ### 1. Initialize translations
22
-
23
- The library uses i18next for internationalization. You need to set it up before using the components:
24
-
25
- ```typescript
26
- import { setupI18n } from '@kingteza/crud-component';
27
-
28
- // Basic setup with default English translations
29
- setupI18n();
30
-
31
- // Or with custom options
32
- setupI18n({
33
- language: 'en', // default language
34
- translations: {
35
- en: {
36
- 'crud-component': {
37
- // your custom translations
38
- }
39
- }
40
- },
41
- i18nInstance: existingI18nInstance // optional: use your existing i18n instance
42
- });
43
- ```
44
-
45
- ### 2. Usage
46
-
47
- ```typescript
48
- import { CrudComponent } from '@kingteza/crud-component';
49
- import { Button } from '@kingteza/crud-component/common';
50
-
51
- function App() {
52
- return (
53
- <CrudComponent
54
- fields={[
55
- { type: "text", name: "name", label: "Name", required: true },
56
- { type: "select", name: "status", label: "Status", options: [
57
- { value: "active", label: "Active" },
58
- { value: "inactive", label: "Inactive" }
59
- ]}
60
- ]}
61
- data={[]}
62
- onSave={(data) => console.log(data)}
63
- />
64
- );
65
- }
66
- ```
67
-
68
- ### 3. Available Imports
69
-
70
- The library provides several entry points for importing components:
71
-
72
- ```typescript
73
- // Main CRUD component
74
- import { CrudComponent } from '@kingteza/crud-component';
75
-
76
- // Common components
77
- import { Button, Select, DatePicker } from '@kingteza/crud-component/common';
78
-
79
- // Utility functions
80
- import { DateUtil } from '@kingteza/crud-component/util';
81
- ```
82
-
83
- ## Documentation
84
-
85
- For detailed documentation of components and their props, please visit our [GitHub repository](https://github.com/kingteza/crud-component).
86
-
87
- ## License
88
-
89
- MIT