@kingteza/crud-component 1.0.12 → 1.0.14

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 (119) hide show
  1. package/dist/components/common/DatePicker/DatePicker.cjs +1 -0
  2. package/dist/components/common/DatePicker/DatePicker.js +88 -0
  3. package/dist/components/common/DatePicker/TimePicker.cjs +1 -0
  4. package/dist/components/common/DatePicker/TimePicker.js +78 -0
  5. package/dist/components/common/appearance/Hider.cjs +1 -0
  6. package/dist/components/common/appearance/Hider.js +5 -0
  7. package/dist/components/common/button/Button.cjs +1 -0
  8. package/dist/components/common/button/Button.js +64 -0
  9. package/dist/components/common/button/CloneButtonTable.cjs +1 -0
  10. package/dist/components/common/button/CloneButtonTable.js +20 -0
  11. package/dist/components/common/button/DeleteButtonTable.cjs +1 -0
  12. package/dist/components/common/button/DeleteButtonTable.js +68 -0
  13. package/dist/components/common/button/ExportButton.cjs +1 -0
  14. package/dist/components/common/button/ExportButton.js +27 -0
  15. package/dist/components/common/button/HideButtonTable.cjs +1 -0
  16. package/dist/components/common/button/HideButtonTable.js +68 -0
  17. package/dist/components/common/button/ImportButton.cjs +1 -0
  18. package/dist/components/common/button/ImportButton.js +56 -0
  19. package/dist/components/common/button/NewButton.cjs +1 -0
  20. package/dist/components/common/button/NewButton.js +24 -0
  21. package/dist/components/common/button/PrintButton.cjs +1 -0
  22. package/dist/components/common/button/PrintButton.js +26 -0
  23. package/dist/components/common/button/RefreshButton.cjs +1 -0
  24. package/dist/components/common/button/RefreshButton.js +24 -0
  25. package/dist/components/common/button/UnHideButton.cjs +1 -0
  26. package/dist/components/common/button/UnHideButton.js +70 -0
  27. package/dist/components/common/button/UpdateButtonTable.cjs +1 -0
  28. package/dist/components/common/button/UpdateButtonTable.js +20 -0
  29. package/dist/components/common/button/ViewButtonTable.cjs +1 -0
  30. package/dist/components/common/button/ViewButtonTable.js +20 -0
  31. package/dist/components/common/check-box/CheckBox.cjs +1 -0
  32. package/dist/components/common/check-box/CheckBox.js +40 -0
  33. package/dist/components/common/description/DescList.cjs +1 -0
  34. package/dist/components/common/description/DescList.js +16 -0
  35. package/dist/components/common/layout/VerticalSpace.cjs +1 -0
  36. package/dist/components/common/layout/VerticalSpace.js +6 -0
  37. package/dist/components/common/loading/LoadingIndicator.cjs +1 -0
  38. package/dist/components/common/loading/LoadingIndicator.js +24 -0
  39. package/dist/components/common/picker/ImagePicker.cjs +1 -0
  40. package/dist/components/common/picker/ImagePicker.js +285 -0
  41. package/dist/components/common/radio/RadioGroupComponent.cjs +1 -0
  42. package/dist/components/common/radio/RadioGroupComponent.js +19 -0
  43. package/dist/components/common/report/SelectFieldInReport.cjs +1 -0
  44. package/dist/components/common/report/SelectFieldInReport.js +30 -0
  45. package/dist/components/common/select/CustomSelectOption.cjs +1 -0
  46. package/dist/components/common/select/CustomSelectOption.js +13 -0
  47. package/dist/components/common/select/SelectComponent.cjs +1 -0
  48. package/dist/components/common/select/SelectComponent.js +89 -0
  49. package/dist/components/common/show-more/index.cjs +1 -0
  50. package/dist/components/common/show-more/index.js +8 -0
  51. package/dist/components/common/tab/TabViewWithRoute.cjs +1 -0
  52. package/dist/components/common/tab/TabViewWithRoute.js +37 -0
  53. package/dist/components/common/table/table.cjs +1 -0
  54. package/dist/components/common/table/table.js +40 -0
  55. package/dist/components/common/tag/StatusTag.cjs +1 -0
  56. package/dist/components/common/tag/StatusTag.js +30 -0
  57. package/dist/components/common/text/index.cjs +1 -0
  58. package/dist/components/common/text/index.js +5 -0
  59. package/dist/components/common/text/title/index.cjs +1 -0
  60. package/dist/components/common/text/title/index.js +5 -0
  61. package/dist/components/common/text-field/NumberField.cjs +1 -0
  62. package/dist/components/common/text-field/NumberField.js +83 -0
  63. package/dist/components/common/text-field/PhoneNumberField.cjs +1 -0
  64. package/dist/components/common/text-field/PhoneNumberField.js +18 -0
  65. package/dist/components/common/text-field/TextArea.cjs +1 -0
  66. package/dist/components/common/text-field/TextArea.js +47 -0
  67. package/dist/components/common/text-field/TextField.cjs +1 -0
  68. package/dist/components/common/text-field/TextField.js +73 -0
  69. package/dist/components/common/tooltip/TooltipComponent.cjs +1 -0
  70. package/dist/components/common/tooltip/TooltipComponent.js +9 -0
  71. package/dist/components/common/wizard/WizardResult.cjs +1 -0
  72. package/dist/components/common/wizard/WizardResult.js +61 -0
  73. package/dist/components/common/wizard/WizardViewForm.cjs +1 -0
  74. package/dist/components/common/wizard/WizardViewForm.js +74 -0
  75. package/dist/components/crud/CrudComponent.cjs +1 -0
  76. package/dist/components/crud/CrudComponent.js +210 -0
  77. package/dist/components/crud/CrudField.cjs +1 -0
  78. package/dist/components/crud/CrudField.js +459 -0
  79. package/dist/components/crud/CrudForm.cjs +1 -0
  80. package/dist/components/crud/CrudForm.js +91 -0
  81. package/dist/components/crud/CrudFormWizard.cjs +1 -0
  82. package/dist/components/crud/CrudFormWizard.js +142 -0
  83. package/dist/components/crud/CrudReportComponent.cjs +4 -0
  84. package/dist/components/crud/CrudReportComponent.js +255 -0
  85. package/dist/components/crud/CrudSearchComponent.cjs +1 -0
  86. package/dist/components/crud/CrudSearchComponent.js +95 -0
  87. package/dist/components/crud/FileCrudField.cjs +1 -0
  88. package/dist/components/crud/FileCrudField.js +227 -0
  89. package/dist/components/crud/ImageCrudField.cjs +1 -0
  90. package/dist/components/crud/ImageCrudField.js +113 -0
  91. package/dist/components/crud/import/CrudImportButton.cjs +1 -0
  92. package/dist/components/crud/import/CrudImportButton.js +31 -0
  93. package/dist/components/crud/import/CrudImportComponent.cjs +2 -0
  94. package/dist/components/crud/import/CrudImportComponent.js +222 -0
  95. package/dist/components/crud/view/CrudDecListView.cjs +1 -0
  96. package/dist/components/crud/view/CrudDecListView.js +42 -0
  97. package/dist/components/crud/view/CrudViewer.cjs +1 -0
  98. package/dist/components/crud/view/CrudViewer.js +217 -0
  99. package/dist/components/crud/view/CrudViewerUtil.cjs +1 -0
  100. package/dist/components/crud/view/CrudViewerUtil.js +58 -0
  101. package/dist/index.cjs +1 -1
  102. package/dist/index.js +10 -10
  103. package/dist/locale/hooks/translation-constants.cjs +1 -0
  104. package/dist/locale/hooks/translation-constants.js +4 -0
  105. package/dist/locale/index.cjs +1 -0
  106. package/dist/locale/index.js +33 -0
  107. package/dist/locale/translations/en.cjs +1 -0
  108. package/dist/locale/translations/en.js +60 -0
  109. package/dist/util/DateUtil.cjs +1 -0
  110. package/dist/util/DateUtil.js +6 -0
  111. package/dist/util/ImageUtil.cjs +1 -0
  112. package/dist/util/ImageUtil.js +63 -0
  113. package/dist/util/NumberUtil.cjs +1 -0
  114. package/dist/util/NumberUtil.js +60 -0
  115. package/dist/util/ValidationUtil.cjs +1 -0
  116. package/dist/util/ValidationUtil.js +60 -0
  117. package/dist/util/index.cjs +1 -1
  118. package/dist/util/index.js +4 -4
  119. package/package.json +1 -1
@@ -0,0 +1,217 @@
1
+ import { j as r } from "../../../_virtual/jsx-runtime.js";
2
+ import { Modal as k } from "antd";
3
+ import H from "../../common/button/CloneButtonTable.js";
4
+ import U from "../../common/button/DeleteButtonTable.js";
5
+ import { ExportButton as F } from "../../common/button/ExportButton.js";
6
+ import rr from "../../common/button/HideButtonTable.js";
7
+ import { RefreshButton as or } from "../../common/button/RefreshButton.js";
8
+ import tr from "../../common/button/UpdateButtonTable.js";
9
+ import sr from "../../common/button/ViewButtonTable.js";
10
+ import mr from "../../common/layout/VerticalSpace.js";
11
+ import ur from "../../common/table/table.js";
12
+ import { useMemo as L, useState as _, useEffect as nr, useCallback as er } from "react";
13
+ import { TRANSLATION_NAMESPACE as fr } from "../../../locale/hooks/translation-constants.js";
14
+ import cr from "../CrudSearchComponent.js";
15
+ import { CrudDecListView as lr } from "./CrudDecListView.js";
16
+ import { getRendererValueCrudViewer as V } from "./CrudViewerUtil.js";
17
+ import { useTranslation as jr } from "../../../node_modules/react-i18next/dist/es/useTranslation.js";
18
+ function Or({
19
+ idField: s = "id",
20
+ loadingData: $,
21
+ fields: f,
22
+ isDeleting: y,
23
+ isHiding: B,
24
+ viewable: n = !1,
25
+ paginateProps: l,
26
+ onDelete: j,
27
+ onHide: p,
28
+ onUpdate: h,
29
+ data: v = [],
30
+ extraAction: a,
31
+ onClickUpdate: e,
32
+ minusHeight: I,
33
+ scroll: q,
34
+ onClickClone: T,
35
+ className: A,
36
+ expandable: G,
37
+ size: J,
38
+ bordered: K,
39
+ descListColumn: Q,
40
+ extraView: i,
41
+ decListLayout: W,
42
+ scrollToTop: ar,
43
+ onClickRefresh: C,
44
+ closeViewOnClickUpdate: R,
45
+ onExport: S,
46
+ confirmHiding: E,
47
+ confirmDeleting: M,
48
+ rowClassName: X,
49
+ actionWidth: Y = 190,
50
+ ...Z
51
+ }) {
52
+ const { t: d } = jr(fr), N = L(
53
+ () => f.map(
54
+ ({ hideInTable: o, hidden: t, width: c, name: u, label: w, halign: D, ...z }) => ({
55
+ title: w,
56
+ width: c,
57
+ key: u,
58
+ dataIndex: u,
59
+ hidden: o || t,
60
+ align: D ?? (z.type === "number" ? "right" : void 0),
61
+ render: V(z)
62
+ })
63
+ ),
64
+ [f]
65
+ ), [m, x] = _(), [b, g] = _();
66
+ nr(() => {
67
+ v && x((o) => {
68
+ if (o)
69
+ return v.find((t) => t[s] === o[s]);
70
+ });
71
+ }, [v, s, m]);
72
+ const O = er(
73
+ (o) => {
74
+ var c;
75
+ const t = a == null ? void 0 : a(o);
76
+ return (Array.isArray(t) ? (c = t == null ? void 0 : t.filter(Boolean)) != null && c.length : t) || h || e || T || j ? /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
77
+ t,
78
+ (h || e) && /* @__PURE__ */ r.jsx(
79
+ tr,
80
+ {
81
+ value: o,
82
+ onClick: (u) => {
83
+ g(u[s]), e == null || e(o), R && x(void 0);
84
+ }
85
+ }
86
+ ),
87
+ T && /* @__PURE__ */ r.jsx(H, { value: o, onClick: (u) => T(u) }),
88
+ S && /* @__PURE__ */ r.jsx(
89
+ F,
90
+ {
91
+ value: o,
92
+ onClick: async (u) => await S(u)
93
+ }
94
+ ),
95
+ p && /* @__PURE__ */ r.jsx(
96
+ rr,
97
+ {
98
+ value: o,
99
+ disabled: B,
100
+ shouldConfirm: E,
101
+ loading: B && o[s] === b,
102
+ onClick: async (u) => {
103
+ g(u[s]), await p({ [s]: u[s] });
104
+ }
105
+ }
106
+ ),
107
+ j && /* @__PURE__ */ r.jsx(
108
+ U,
109
+ {
110
+ value: o,
111
+ disabled: y,
112
+ shouldConfirm: M,
113
+ loading: y && o[s] === b,
114
+ onClick: async (u) => {
115
+ g(u[s]), await j({ [s]: u[s] });
116
+ }
117
+ }
118
+ )
119
+ ] }) : void 0;
120
+ },
121
+ [
122
+ R,
123
+ M,
124
+ E,
125
+ a,
126
+ s,
127
+ y,
128
+ B,
129
+ T,
130
+ e,
131
+ j,
132
+ S,
133
+ p,
134
+ h,
135
+ b
136
+ ]
137
+ ), P = L(() => {
138
+ let o = typeof n == "string" ? m == null ? void 0 : m[n] : void 0;
139
+ if (typeof o == "object") {
140
+ const t = f.find((c) => c.name === n);
141
+ o = V(t)(
142
+ o,
143
+ m,
144
+ 0
145
+ );
146
+ }
147
+ return o;
148
+ }, [n, m, f]);
149
+ return /* @__PURE__ */ r.jsxs("div", { children: [
150
+ n && /* @__PURE__ */ r.jsx(
151
+ k,
152
+ {
153
+ width: "100%",
154
+ open: !!m,
155
+ title: P ?? /* @__PURE__ */ r.jsx("div", { children: " " }),
156
+ footer: /* @__PURE__ */ r.jsx(r.Fragment, {}),
157
+ closable: !0,
158
+ onCancel: () => x(void 0),
159
+ children: !!m && /* @__PURE__ */ r.jsxs("div", { children: [
160
+ /* @__PURE__ */ r.jsx(
161
+ lr,
162
+ {
163
+ layout: W,
164
+ descListColumn: Q,
165
+ data: m,
166
+ fields: f,
167
+ action: O(m)
168
+ }
169
+ ),
170
+ i == null ? void 0 : i(m)
171
+ ] }, m == null ? void 0 : m[s])
172
+ }
173
+ ),
174
+ /* @__PURE__ */ r.jsx(cr, { fields: f, ...Z }),
175
+ /* @__PURE__ */ r.jsxs(mr, { children: [
176
+ !!C && /* @__PURE__ */ r.jsx(or, { onClick: C }),
177
+ /* @__PURE__ */ r.jsx(
178
+ ur,
179
+ {
180
+ rowClassName: X,
181
+ className: A,
182
+ scroll: q ?? (I ? {
183
+ y: `calc(100vh - ${I})`
184
+ } : void 0),
185
+ id: "crud-table",
186
+ dataSource: v,
187
+ loading: $,
188
+ bordered: K,
189
+ size: J,
190
+ expandable: G,
191
+ pagination: l ? {
192
+ total: l.count,
193
+ onChange: l.setPage,
194
+ current: l.page,
195
+ pageSize: l.pageSize
196
+ } : void 0,
197
+ columns: h || e || j || a || n ? [
198
+ ...N,
199
+ {
200
+ title: d("str.action"),
201
+ dataIndex: "",
202
+ fixed: "right",
203
+ width: Y,
204
+ render: (o, t) => /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
205
+ n && /* @__PURE__ */ r.jsx(sr, { value: t, onClick: x }),
206
+ O(t)
207
+ ] })
208
+ }
209
+ ] : N
210
+ }
211
+ )
212
+ ] })
213
+ ] });
214
+ }
215
+ export {
216
+ Or as default
217
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../../_virtual/jsx-runtime.cjs"),m=require("antd"),x=require("../../common/show-more/index.cjs"),j=require("../FileCrudField.cjs"),v=require("../ImageCrudField.cjs"),y=require("../../../locale/hooks/translation-constants.cjs"),C=require("../../../node_modules/i18next/dist/esm/i18next.cjs"),r=require("../../../util/DateUtil.cjs"),s=require("../../../util/NumberUtil.cjs"),g=require("../../../node_modules/@ant-design/icons/es/icons/CheckOutlined.cjs"),d=require("../../../node_modules/@ant-design/icons/es/icons/CloseOutlined.cjs");function q({type:a,render:i,...n}){return a==="object"?(t,u,e)=>typeof i=="function"?i(t,u,e):"":a==="select"?(t,u,e)=>{const o=n;let c=o.multiple?Array.isArray(t)?t.map(f=>f==null?void 0:f[o.innerFieldLabel??"name"]):void 0:t==null?void 0:t[o.innerFieldLabel??"name"];return(!c&&typeof t=="string"||typeof t=="number")&&(c=t),typeof i=="function"?i(c,u,e):Array.isArray(c)?c.join(", "):c}:a==="number"?(t,u,e)=>typeof i=="function"?i(t,u,e):n!=null&&n.int?s.default.toInt(t,n.formatted):s.default.toMoney(t):a==="enum"?(t,u,e)=>{var c;const o=C.t(((c=n==null?void 0:n.translation)==null?void 0:c[t??""])??t,{ns:y.TRANSLATION_NAMESPACE});return typeof i=="function"?i(t,u,e):o}:a==="date"?(t,u,e)=>{if(!t)return"-";const o=n!=null&&n.formatTime?r.formatDateTime(t):r.formatDate(t);return typeof i=="function"?i(t,u,e):o}:a==="checkbox"?(t,u,e)=>typeof i=="function"?i(t,u,e):t?l.jsxRuntimeExports.jsx(g,{}):l.jsxRuntimeExports.jsx(d,{}):a==="image"?(t,u,e)=>typeof i=="function"?i(t,u,e):l.jsxRuntimeExports.jsx(v.ImageCrudCellValue,{value:t,provider:n.provider}):a==="file"?(t,u,e)=>typeof i=="function"?i(t,u,e):l.jsxRuntimeExports.jsx(j.FileCrudCellValue,{value:t,provider:n.provider}):a==="time"?(t,u,e)=>{if(!t)return"-";const o=n==null?void 0:n.format,c=n==null?void 0:n.use12Hours,f=r.formatTime(t,o||(c?"hh:mm:ss A":void 0));return typeof i=="function"?i(t,u,e):f}:a==="color"?(t,u,e)=>typeof i=="function"?i(t,u,e):typeof t=="string"&&t.startsWith("#")?l.jsxRuntimeExports.jsx(m.Tooltip,{title:t,children:l.jsxRuntimeExports.jsx(m.Avatar,{style:{backgroundColor:t}})}):String(t):a==="textarea"?(t,u,e)=>{const o=(n==null?void 0:n.truncated)??1;return typeof i=="function"?i(t,u,e):o?l.jsxRuntimeExports.jsx(x.ShowMore,{lines:o===!0?1:o,children:t}):t}:typeof i=="function"?i:t=>t}exports.getRendererValueCrudViewer=q;
@@ -0,0 +1,58 @@
1
+ import { j as c } from "../../../_virtual/jsx-runtime.js";
2
+ import { Tooltip as x, Avatar as j } from "antd";
3
+ import { ShowMore as y } from "../../common/show-more/index.js";
4
+ import { FileCrudCellValue as A } from "../FileCrudField.js";
5
+ import { ImageCrudCellValue as b } from "../ImageCrudField.js";
6
+ import { TRANSLATION_NAMESPACE as e } from "../../../locale/hooks/translation-constants.js";
7
+ import { t as g } from "../../../node_modules/i18next/dist/esm/i18next.js";
8
+ import r from "../../../util/DateUtil.js";
9
+ import v from "../../../util/NumberUtil.js";
10
+ import h from "../../../node_modules/@ant-design/icons/es/icons/CheckOutlined.js";
11
+ import C from "../../../node_modules/@ant-design/icons/es/icons/CloseOutlined.js";
12
+ function M({
13
+ type: u,
14
+ render: i,
15
+ ...o
16
+ }) {
17
+ return u === "object" ? (t, f, n) => typeof i == "function" ? i(t, f, n) : "" : u === "select" ? (t, f, n) => {
18
+ const m = o;
19
+ let a = m.multiple ? Array.isArray(t) ? t.map((l) => l == null ? void 0 : l[m.innerFieldLabel ?? "name"]) : void 0 : t == null ? void 0 : t[m.innerFieldLabel ?? "name"];
20
+ return (!a && typeof t == "string" || typeof t == "number") && (a = t), typeof i == "function" ? i(a, f, n) : Array.isArray(a) ? a.join(", ") : a;
21
+ } : u === "number" ? (t, f, n) => typeof i == "function" ? i(t, f, n) : o != null && o.int ? v.toInt(t, o.formatted) : v.toMoney(t) : u === "enum" ? (t, f, n) => {
22
+ var a;
23
+ const m = g(
24
+ ((a = o == null ? void 0 : o.translation) == null ? void 0 : a[t ?? ""]) ?? t,
25
+ { ns: e }
26
+ );
27
+ return typeof i == "function" ? i(t, f, n) : m;
28
+ } : u === "date" ? (t, f, n) => {
29
+ if (!t) return "-";
30
+ const m = o != null && o.formatTime ? r.formatDateTime(t) : r.formatDate(t);
31
+ return typeof i == "function" ? i(t, f, n) : m;
32
+ } : u === "checkbox" ? (t, f, n) => typeof i == "function" ? i(t, f, n) : t ? /* @__PURE__ */ c.jsx(h, {}) : /* @__PURE__ */ c.jsx(C, {}) : u === "image" ? (t, f, n) => typeof i == "function" ? i(t, f, n) : /* @__PURE__ */ c.jsx(
33
+ b,
34
+ {
35
+ value: t,
36
+ provider: o.provider
37
+ }
38
+ ) : u === "file" ? (t, f, n) => typeof i == "function" ? i(t, f, n) : /* @__PURE__ */ c.jsx(
39
+ A,
40
+ {
41
+ value: t,
42
+ provider: o.provider
43
+ }
44
+ ) : u === "time" ? (t, f, n) => {
45
+ if (!t) return "-";
46
+ const m = o == null ? void 0 : o.format, a = o == null ? void 0 : o.use12Hours, l = r.formatTime(
47
+ t,
48
+ m || (a ? "hh:mm:ss A" : void 0)
49
+ );
50
+ return typeof i == "function" ? i(t, f, n) : l;
51
+ } : u === "color" ? (t, f, n) => typeof i == "function" ? i(t, f, n) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ c.jsx(x, { title: t, children: /* @__PURE__ */ c.jsx(j, { style: { backgroundColor: t } }) }) : String(t) : u === "textarea" ? (t, f, n) => {
52
+ const m = (o == null ? void 0 : o.truncated) ?? 1;
53
+ return typeof i == "function" ? i(t, f, n) : m ? /* @__PURE__ */ c.jsx(y, { lines: m === !0 ? 1 : m, children: t }) : t;
54
+ } : typeof i == "function" ? i : (t) => t;
55
+ }
56
+ export {
57
+ M as getRendererValueCrudViewer
58
+ };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./src/locale/hooks/translation-constants.cjs"),o=require("./src/locale/index.cjs"),C=require("./src/components/crud/CrudComponent.cjs"),r=require("./src/components/crud/CrudField.cjs"),i=require("./src/components/crud/CrudFormWizard.cjs"),n=require("./src/components/crud/CrudReportComponent.cjs"),t=require("./src/components/crud/CrudSearchComponent.cjs"),d=require("./src/components/crud/CrudForm.cjs"),l=require("./src/components/crud/FileCrudField.cjs"),e=require("./src/components/crud/ImageCrudField.cjs");exports.TRANSLATION_NAMESPACE=u.TRANSLATION_NAMESPACE;exports.setupI18n=o.setupI18n;exports.updateTranslations=o.updateTranslations;exports.CrudComponent=C;exports.ColorCrudFieldComponent=r.ColorCrudFieldComponent;exports.CrudField=r.default;exports.SelectCrudFieldComponent=r.SelectCrudFieldComponent;exports.CrudFormWizard=i;exports.CrudReportComponent=n;exports.CrudSearchComponent=t;exports.CrudForm=d.CrudForm;exports.CrudFormFields=d.CrudFormFields;exports.FileCellValue=l.FileCellValue;exports.FileCrudCellValue=l.FileCrudCellValue;exports.FileCrudField=l.default;exports.FileDownloadProvider=e.FileDownloadProvider;exports.FileUploadProvider=e.FileUploadProvider;exports.ImageCellValue=e.ImageCellValue;exports.ImageCrudCellValue=e.ImageCrudCellValue;exports.ImageCrudField=e.default;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./locale/hooks/translation-constants.cjs"),o=require("./locale/index.cjs"),C=require("./components/crud/CrudComponent.cjs"),r=require("./components/crud/CrudField.cjs"),i=require("./components/crud/CrudFormWizard.cjs"),n=require("./components/crud/CrudReportComponent.cjs"),t=require("./components/crud/CrudSearchComponent.cjs"),d=require("./components/crud/CrudForm.cjs"),l=require("./components/crud/FileCrudField.cjs"),e=require("./components/crud/ImageCrudField.cjs");exports.TRANSLATION_NAMESPACE=u.TRANSLATION_NAMESPACE;exports.setupI18n=o.setupI18n;exports.updateTranslations=o.updateTranslations;exports.CrudComponent=C;exports.ColorCrudFieldComponent=r.ColorCrudFieldComponent;exports.CrudField=r.default;exports.SelectCrudFieldComponent=r.SelectCrudFieldComponent;exports.CrudFormWizard=i;exports.CrudReportComponent=n;exports.CrudSearchComponent=t;exports.CrudForm=d.CrudForm;exports.CrudFormFields=d.CrudFormFields;exports.FileCellValue=l.FileCellValue;exports.FileCrudCellValue=l.FileCrudCellValue;exports.FileCrudField=l.default;exports.FileDownloadProvider=e.FileDownloadProvider;exports.FileUploadProvider=e.FileUploadProvider;exports.ImageCellValue=e.ImageCellValue;exports.ImageCrudCellValue=e.ImageCrudCellValue;exports.ImageCrudField=e.default;
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { TRANSLATION_NAMESPACE as o } from "./src/locale/hooks/translation-constants.js";
2
- import { setupI18n as d, updateTranslations as a } from "./src/locale/index.js";
3
- import { default as u } from "./src/components/crud/CrudComponent.js";
4
- import { ColorCrudFieldComponent as m, default as p, SelectCrudFieldComponent as f } from "./src/components/crud/CrudField.js";
5
- import { default as n } from "./src/components/crud/CrudFormWizard.js";
6
- import { default as s } from "./src/components/crud/CrudReportComponent.js";
7
- import { default as I } from "./src/components/crud/CrudSearchComponent.js";
8
- import { CrudForm as S, CrudFormFields as V } from "./src/components/crud/CrudForm.js";
9
- import { FileCellValue as N, FileCrudCellValue as P, default as T } from "./src/components/crud/FileCrudField.js";
10
- import { FileDownloadProvider as v, FileUploadProvider as E, ImageCellValue as R, ImageCrudCellValue as h, default as w } from "./src/components/crud/ImageCrudField.js";
1
+ import { TRANSLATION_NAMESPACE as o } from "./locale/hooks/translation-constants.js";
2
+ import { setupI18n as d, updateTranslations as a } from "./locale/index.js";
3
+ import { default as u } from "./components/crud/CrudComponent.js";
4
+ import { ColorCrudFieldComponent as m, default as p, SelectCrudFieldComponent as f } from "./components/crud/CrudField.js";
5
+ import { default as n } from "./components/crud/CrudFormWizard.js";
6
+ import { default as s } from "./components/crud/CrudReportComponent.js";
7
+ import { default as I } from "./components/crud/CrudSearchComponent.js";
8
+ import { CrudForm as S, CrudFormFields as V } from "./components/crud/CrudForm.js";
9
+ import { FileCellValue as N, FileCrudCellValue as P, default as T } from "./components/crud/FileCrudField.js";
10
+ import { FileDownloadProvider as v, FileUploadProvider as E, ImageCellValue as R, ImageCrudCellValue as h, default as w } from "./components/crud/ImageCrudField.js";
11
11
  export {
12
12
  m as ColorCrudFieldComponent,
13
13
  u as CrudComponent,
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="crud-component";exports.TRANSLATION_NAMESPACE=e;
@@ -0,0 +1,4 @@
1
+ const o = "crud-component";
2
+ export {
3
+ o as TRANSLATION_NAMESPACE
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./hooks/translation-constants.cjs"),u=require("./translations/en.cjs"),n=require("../node_modules/i18next/dist/esm/i18next.cjs"),o=require("../node_modules/react-i18next/dist/es/initReactI18next.cjs"),s={en:{[a.TRANSLATION_NAMESPACE]:u}},i=(e={})=>{const{translations:t=s,language:r="en"}=e;return n.default.use(o.initReactI18next).init({resources:t,lng:r,fallbackLng:"en",ns:a.TRANSLATION_NAMESPACE,interpolation:{escapeValue:!1}}),n.default},l=(e,t)=>{n.default.addResourceBundle(e,a.TRANSLATION_NAMESPACE,t,!0,!0)};exports.defaultTranslations=s;exports.setupI18n=i;exports.updateTranslations=l;
@@ -0,0 +1,33 @@
1
+ import { TRANSLATION_NAMESPACE as o } from "./hooks/translation-constants.js";
2
+ import a from "./translations/en.js";
3
+ import t from "../node_modules/i18next/dist/esm/i18next.js";
4
+ import { initReactI18next as s } from "../node_modules/react-i18next/dist/es/initReactI18next.js";
5
+ const i = {
6
+ en: {
7
+ [o]: a
8
+ }
9
+ }, m = (n = {}) => {
10
+ const { translations: e = i, language: r = "en" } = n;
11
+ return t.use(s).init({
12
+ resources: e,
13
+ lng: r,
14
+ fallbackLng: "en",
15
+ ns: o,
16
+ interpolation: {
17
+ escapeValue: !1
18
+ }
19
+ }), t;
20
+ }, f = (n, e) => {
21
+ t.addResourceBundle(
22
+ n,
23
+ o,
24
+ e,
25
+ !0,
26
+ !0
27
+ );
28
+ };
29
+ export {
30
+ i as defaultTranslations,
31
+ m as setupI18n,
32
+ f as updateTranslations
33
+ };
@@ -0,0 +1 @@
1
+ "use strict";const e={str:{delete:"Delete",clone:"Clone",update:"Update",new:"New",back:"Back",next:"Next",save:"Save",import:"Import",cancel:"Cancel",print:"Print",hide:"Hide",no:"No",action:"Action",remove:"Remove",view:"View",ok:"Ok",yes:"Yes",warning:"Warning",success:"Success",error:"Error",retry:"Retry",previous:"Previous",unhide:"Unhide",downloadCsvTemplate:"Download CSV Template",importCsvFile:"Import CSV File",export:"Export",goBack:"Go Back",refresh:"Refresh",fileUploadMessage1:"Drag file here or ",fileUploadMessage2:"Click to Upload"},err:{save:"An error occurred while saving",validation:{required:"is required",minLength8:"must be at least 8 characters",percentage:"must be a percentage",maximumValueExceeded:"must be less than %maxValue%",invalidNic:"must be a valid NIC",invalid:"must be a valid"},notFound:"Not Found"},message:{loading:{saving:"Saving"}},qus:{importWithIssues:"Some fields have issues. Do you want to proceed with the import?",doYouWantToDelete:"Do you want to delete?",doYouWantToHide:"Do you want to hide?",doYouWantToUnhide:"Do you want to unhide?"}};module.exports=e;
@@ -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
+ };
@@ -0,0 +1 @@
1
+ "use strict";const e=require("../_virtual/dayjs.min.cjs"),a=require("../node_modules/i18next/dist/esm/i18next.cjs"),o=t=>e(t).locale(a.default.language).format("YYYY-MM-DD HH:mm"),m=t=>e(t).locale(a.default.language).format("YYYY-MM-DD HH:mm:ss"),n=t=>e(t).locale(a.default.language).format("YYYY-MM-DD"),l=(t,r="HH:mm:ss")=>e(t).locale(a.default.language).format(r),s={formatDateTime:o,formatDate:n,formatDateTimeWithSecond:m,formatTime:l};module.exports=s;
@@ -0,0 +1,6 @@
1
+ import t from "../_virtual/dayjs.min.js";
2
+ import e from "../node_modules/i18next/dist/esm/i18next.js";
3
+ const m = (a) => t(a).locale(e.language).format("YYYY-MM-DD HH:mm"), r = (a) => t(a).locale(e.language).format("YYYY-MM-DD HH:mm:ss"), n = (a) => t(a).locale(e.language).format("YYYY-MM-DD"), l = (a, o = "HH:mm:ss") => t(a).locale(e.language).format(o), c = { formatDateTime: m, formatDate: n, formatDateTimeWithSecond: r, formatTime: l };
4
+ export {
5
+ c as default
6
+ };
@@ -0,0 +1 @@
1
+ "use strict";const c=require("../node_modules/browser-image-compression/dist/browser-image-compression.cjs");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 r=await new Promise(n=>{a.onload=function(){n({height:a.height,width:a.width})}});return Object.assign(e,r),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((r,n)=>{const s=new FileReader;s.onloadend=function(){const o=s.result,i=o.match(/^data:image\/(png|jpeg|jpg);base64,/);i?r({data:o,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,63 @@
1
+ import c from "../node_modules/browser-image-compression/dist/browser-image-compression.js";
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,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("../node_modules/i18next/dist/esm/i18next.cjs"),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,60 @@
1
+ import { t as r } from "../node_modules/i18next/dist/esm/i18next.js";
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
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../src/util/DateUtil.cjs"),e=require("../src/util/NumberUtil.cjs"),i=require("../src/util/ImageUtil.cjs"),l=require("../src/util/ValidationUtil.cjs");exports.DateUtil=t;exports.NumberUtil=e.default;exports.ImageUtil=i;exports.ValidationUtil=l;
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;
@@ -1,7 +1,7 @@
1
- import { default as e } from "../src/util/DateUtil.js";
2
- import { default as o } from "../src/util/NumberUtil.js";
3
- import { default as f } from "../src/util/ImageUtil.js";
4
- import { default as m } from "../src/util/ValidationUtil.js";
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
5
  export {
6
6
  e as DateUtil,
7
7
  f as ImageUtil,