@kingteza/crud-component 1.0.65 → 1.1.0

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 (236) hide show
  1. package/package.json +21 -11
  2. package/release.config.cjs +27 -0
  3. package/App.d.ts +0 -25
  4. package/Play.d.ts +0 -2
  5. package/common/appearance/Hider.cjs.js +0 -1
  6. package/common/appearance/Hider.d.ts +0 -6
  7. package/common/appearance/Hider.es.js +0 -5
  8. package/common/appearance/index.d.ts +0 -1
  9. package/common/button/Button.cjs.js +0 -1
  10. package/common/button/Button.d.ts +0 -11
  11. package/common/button/Button.es.js +0 -57
  12. package/common/button/CloneButtonTable.cjs.js +0 -1
  13. package/common/button/CloneButtonTable.d.ts +0 -6
  14. package/common/button/CloneButtonTable.es.js +0 -19
  15. package/common/button/DeleteButtonTable.cjs.js +0 -1
  16. package/common/button/DeleteButtonTable.d.ts +0 -13
  17. package/common/button/DeleteButtonTable.es.js +0 -64
  18. package/common/button/ExportButton.cjs.js +0 -1
  19. package/common/button/ExportButton.d.ts +0 -4
  20. package/common/button/ExportButton.es.js +0 -26
  21. package/common/button/HideButtonTable.cjs.js +0 -1
  22. package/common/button/HideButtonTable.d.ts +0 -13
  23. package/common/button/HideButtonTable.es.js +0 -67
  24. package/common/button/ImportButton.cjs.js +0 -1
  25. package/common/button/ImportButton.d.ts +0 -9
  26. package/common/button/ImportButton.es.js +0 -55
  27. package/common/button/NewButton.cjs.js +0 -1
  28. package/common/button/NewButton.d.ts +0 -12
  29. package/common/button/NewButton.es.js +0 -23
  30. package/common/button/PrintButton.cjs.js +0 -1
  31. package/common/button/PrintButton.d.ts +0 -12
  32. package/common/button/PrintButton.es.js +0 -25
  33. package/common/button/RefreshButton.cjs.js +0 -1
  34. package/common/button/RefreshButton.d.ts +0 -11
  35. package/common/button/RefreshButton.es.js +0 -23
  36. package/common/button/UnHideButton.cjs.js +0 -1
  37. package/common/button/UnHideButton.d.ts +0 -14
  38. package/common/button/UnHideButton.es.js +0 -69
  39. package/common/button/UpdateButtonTable.cjs.js +0 -1
  40. package/common/button/UpdateButtonTable.d.ts +0 -6
  41. package/common/button/UpdateButtonTable.es.js +0 -19
  42. package/common/button/ViewButtonTable.cjs.js +0 -1
  43. package/common/button/ViewButtonTable.d.ts +0 -6
  44. package/common/button/ViewButtonTable.es.js +0 -19
  45. package/common/button/index.d.ts +0 -14
  46. package/common/check-box/CheckBox.cjs.js +0 -1
  47. package/common/check-box/CheckBox.d.ts +0 -9
  48. package/common/check-box/CheckBox.es.js +0 -40
  49. package/common/check-box/index.d.ts +0 -2
  50. package/common/date-picker/DatePicker.cjs.js +0 -1
  51. package/common/date-picker/DatePicker.d.ts +0 -37
  52. package/common/date-picker/DatePicker.es.js +0 -87
  53. package/common/date-picker/TimePicker.cjs.js +0 -1
  54. package/common/date-picker/TimePicker.d.ts +0 -34
  55. package/common/date-picker/TimePicker.es.js +0 -77
  56. package/common/date-picker/index.d.ts +0 -3
  57. package/common/description/DescList.cjs.js +0 -1
  58. package/common/description/DescList.d.ts +0 -18
  59. package/common/description/DescList.es.js +0 -16
  60. package/common/description/DescriptionComponent.d.ts +0 -7
  61. package/common/description/index.d.ts +0 -3
  62. package/common/icon/KIcon.cjs.js +0 -1
  63. package/common/icon/KIcon.d.ts +0 -9
  64. package/common/icon/KIcon.es.js +0 -11
  65. package/common/index.cjs.js +0 -1
  66. package/common/index.d.ts +0 -20
  67. package/common/index.es.js +0 -78
  68. package/common/layout/VerticalSpace.cjs.js +0 -1
  69. package/common/layout/VerticalSpace.d.ts +0 -5
  70. package/common/layout/VerticalSpace.es.js +0 -6
  71. package/common/layout/index.d.ts +0 -2
  72. package/common/loading/LoadingIndicator.cjs.js +0 -1
  73. package/common/loading/LoadingIndicator.d.ts +0 -6
  74. package/common/loading/LoadingIndicator.es.js +0 -23
  75. package/common/loading/index.d.ts +0 -2
  76. package/common/picker/ImagePicker.cjs.js +0 -1
  77. package/common/picker/ImagePicker.d.ts +0 -56
  78. package/common/picker/ImagePicker.es.js +0 -320
  79. package/common/picker/index.d.ts +0 -2
  80. package/common/radio/RadioGroupComponent.cjs.js +0 -1
  81. package/common/radio/RadioGroupComponent.d.ts +0 -18
  82. package/common/radio/RadioGroupComponent.es.js +0 -19
  83. package/common/radio/index.d.ts +0 -2
  84. package/common/report/SelectFieldInReport.cjs.js +0 -1
  85. package/common/report/SelectFieldInReport.d.ts +0 -16
  86. package/common/report/SelectFieldInReport.es.js +0 -30
  87. package/common/report/index.d.ts +0 -3
  88. package/common/rich/index.cjs.js +0 -1
  89. package/common/rich/index.d.ts +0 -10
  90. package/common/rich/index.es.js +0 -66
  91. package/common/select/CustomSelectOption.cjs.js +0 -1
  92. package/common/select/CustomSelectOption.d.ts +0 -7
  93. package/common/select/CustomSelectOption.es.js +0 -13
  94. package/common/select/SelectComponent.cjs.js +0 -1
  95. package/common/select/SelectComponent.d.ts +0 -21
  96. package/common/select/SelectComponent.es.js +0 -85
  97. package/common/select/index.d.ts +0 -3
  98. package/common/show-more/index.cjs.js +0 -1
  99. package/common/show-more/index.d.ts +0 -4
  100. package/common/show-more/index.es.js +0 -8
  101. package/common/tab/TabViewWithRoute.cjs.js +0 -1
  102. package/common/tab/TabViewWithRoute.d.ts +0 -13
  103. package/common/tab/TabViewWithRoute.es.js +0 -38
  104. package/common/tab/index.d.ts +0 -2
  105. package/common/table/index.d.ts +0 -3
  106. package/common/table/table.cjs.js +0 -1
  107. package/common/table/table.d.ts +0 -19
  108. package/common/table/table.es.js +0 -40
  109. package/common/tag/StatusTag.cjs.js +0 -1
  110. package/common/tag/StatusTag.d.ts +0 -14
  111. package/common/tag/StatusTag.es.js +0 -29
  112. package/common/tag/index.d.ts +0 -2
  113. package/common/text/index.cjs.js +0 -1
  114. package/common/text/index.d.ts +0 -3
  115. package/common/text/index.es.js +0 -5
  116. package/common/text/title/TitleWithHeadTitle.d.ts +0 -7
  117. package/common/text/title/index.cjs.js +0 -1
  118. package/common/text/title/index.d.ts +0 -1
  119. package/common/text/title/index.es.js +0 -5
  120. package/common/text-field/NumberField.cjs.js +0 -1
  121. package/common/text-field/NumberField.d.ts +0 -13
  122. package/common/text-field/NumberField.es.js +0 -82
  123. package/common/text-field/PhoneNumberField.cjs.js +0 -1
  124. package/common/text-field/PhoneNumberField.d.ts +0 -4
  125. package/common/text-field/PhoneNumberField.es.js +0 -18
  126. package/common/text-field/TextArea.cjs.js +0 -1
  127. package/common/text-field/TextArea.d.ts +0 -17
  128. package/common/text-field/TextArea.es.js +0 -46
  129. package/common/text-field/TextField.cjs.js +0 -1
  130. package/common/text-field/TextField.d.ts +0 -27
  131. package/common/text-field/TextField.es.js +0 -72
  132. package/common/text-field/index.d.ts +0 -5
  133. package/common/tooltip/TooltipComponent.cjs.js +0 -1
  134. package/common/tooltip/TooltipComponent.d.ts +0 -5
  135. package/common/tooltip/TooltipComponent.es.js +0 -9
  136. package/common/tooltip/index.d.ts +0 -2
  137. package/common/wizard/WizardResult.cjs.js +0 -1
  138. package/common/wizard/WizardResult.d.ts +0 -16
  139. package/common/wizard/WizardResult.es.js +0 -58
  140. package/common/wizard/WizardViewForm.cjs.js +0 -1
  141. package/common/wizard/WizardViewForm.d.ts +0 -24
  142. package/common/wizard/WizardViewForm.es.js +0 -74
  143. package/common/wizard/index.d.ts +0 -3
  144. package/crud/CrudComponent.cjs.js +0 -1
  145. package/crud/CrudComponent.d.ts +0 -244
  146. package/crud/CrudComponent.es.js +0 -123
  147. package/crud/CrudField.cjs.js +0 -1
  148. package/crud/CrudField.d.ts +0 -4
  149. package/crud/CrudField.es.js +0 -449
  150. package/crud/CrudForm.cjs.js +0 -1
  151. package/crud/CrudForm.d.ts +0 -14
  152. package/crud/CrudForm.es.js +0 -103
  153. package/crud/CrudFormWizard.cjs.js +0 -1
  154. package/crud/CrudFormWizard.d.ts +0 -14
  155. package/crud/CrudFormWizard.es.js +0 -140
  156. package/crud/CrudReportComponent.cjs.js +0 -4
  157. package/crud/CrudReportComponent.d.ts +0 -44
  158. package/crud/CrudReportComponent.es.js +0 -255
  159. package/crud/CrudSearchComponent.cjs.js +0 -1
  160. package/crud/CrudSearchComponent.d.ts +0 -21
  161. package/crud/CrudSearchComponent.es.js +0 -96
  162. package/crud/CrudTextAreaComponent.cjs.js +0 -1
  163. package/crud/CrudTextAreaComponent.d.ts +0 -22
  164. package/crud/CrudTextAreaComponent.es.js +0 -52
  165. package/crud/FileCrudField.cjs.js +0 -1
  166. package/crud/FileCrudField.d.ts +0 -25
  167. package/crud/FileCrudField.es.js +0 -219
  168. package/crud/ImageCrudField.cjs.js +0 -1
  169. package/crud/ImageCrudField.d.ts +0 -38
  170. package/crud/ImageCrudField.es.js +0 -113
  171. package/crud/actions/index.cjs.js +0 -1
  172. package/crud/actions/index.d.ts +0 -26
  173. package/crud/actions/index.es.js +0 -83
  174. package/crud/import/CrudImportButton.cjs.js +0 -1
  175. package/crud/import/CrudImportButton.d.ts +0 -3
  176. package/crud/import/CrudImportButton.es.js +0 -30
  177. package/crud/import/CrudImportComponent.cjs.js +0 -2
  178. package/crud/import/CrudImportComponent.d.ts +0 -14
  179. package/crud/import/CrudImportComponent.es.js +0 -222
  180. package/crud/index.d.ts +0 -23
  181. package/crud/modal/index.cjs.js +0 -1
  182. package/crud/modal/index.d.ts +0 -24
  183. package/crud/modal/index.es.js +0 -146
  184. package/crud/view/CrudDecListView.cjs.js +0 -1
  185. package/crud/view/CrudDecListView.d.ts +0 -15
  186. package/crud/view/CrudDecListView.es.js +0 -57
  187. package/crud/view/CrudViewer.cjs.js +0 -1
  188. package/crud/view/CrudViewer.d.ts +0 -43
  189. package/crud/view/CrudViewer.es.js +0 -304
  190. package/crud/view/CrudViewerUtil.cjs.js +0 -1
  191. package/crud/view/CrudViewerUtil.d.ts +0 -2
  192. package/crud/view/CrudViewerUtil.es.js +0 -98
  193. package/crud/view/index.d.ts +0 -5
  194. package/hooks/NavigatorHooks.cjs.js +0 -1
  195. package/hooks/NavigatorHooks.d.ts +0 -1
  196. package/hooks/NavigatorHooks.es.js +0 -9
  197. package/icons/FlipHIcon.cjs.js +0 -1
  198. package/icons/FlipHIcon.d.ts +0 -3
  199. package/icons/FlipHIcon.es.js +0 -28
  200. package/icons/FlipVIcon.cjs.js +0 -1
  201. package/icons/FlipVIcon.d.ts +0 -3
  202. package/icons/FlipVIcon.es.js +0 -28
  203. package/index.cjs.js +0 -1
  204. package/index.d.ts +0 -4
  205. package/index.es.js +0 -46
  206. package/locale/hooks/translation-constants.cjs.js +0 -1
  207. package/locale/hooks/translation-constants.d.ts +0 -1
  208. package/locale/hooks/translation-constants.es.js +0 -4
  209. package/locale/index.cjs.js +0 -1
  210. package/locale/index.d.ts +0 -85
  211. package/locale/index.es.js +0 -57
  212. package/locale/translations/en.cjs.js +0 -1
  213. package/locale/translations/en.d.ts +0 -63
  214. package/locale/translations/en.es.js +0 -65
  215. package/main.d.ts +0 -0
  216. package/types/DialogComponentProp.d.ts +0 -8
  217. package/types/Id.d.ts +0 -10
  218. package/util/CrudUtil.cjs.js +0 -1
  219. package/util/CrudUtil.d.ts +0 -5
  220. package/util/CrudUtil.es.js +0 -8
  221. package/util/DateUtil.cjs.js +0 -1
  222. package/util/DateUtil.d.ts +0 -7
  223. package/util/DateUtil.es.js +0 -18
  224. package/util/ImageUtil.cjs.js +0 -1
  225. package/util/ImageUtil.d.ts +0 -14
  226. package/util/ImageUtil.es.js +0 -63
  227. package/util/NumberUtil.cjs.js +0 -1
  228. package/util/NumberUtil.d.ts +0 -17
  229. package/util/NumberUtil.es.js +0 -60
  230. package/util/ValidationUtil.cjs.js +0 -1
  231. package/util/ValidationUtil.d.ts +0 -14
  232. package/util/ValidationUtil.es.js +0 -63
  233. package/util/index.cjs.js +0 -1
  234. package/util/index.d.ts +0 -4
  235. package/util/index.es.js +0 -10
  236. package/vite-env.d.ts +0 -1
@@ -1,83 +0,0 @@
1
- import { jsxs as w, Fragment as A, jsx as T } from "react/jsx-runtime";
2
- import { useRef as H, useCallback as x } from "react";
3
- import V from "../../common/button/CloneButtonTable.es.js";
4
- import k from "../../common/button/DeleteButtonTable.es.js";
5
- import { ExportButton as o } from "../../common/button/ExportButton.es.js";
6
- import B from "../../common/button/HideButtonTable.es.js";
7
- import C from "../../common/button/UpdateButtonTable.es.js";
8
- import F from "../modal/index.es.js";
9
- function O({
10
- data: v,
11
- idField: u = "id",
12
- extraAction: j,
13
- onUpdate: z,
14
- onClickUpdate: y,
15
- onClickClone: g,
16
- onDelete: r,
17
- onHide: E,
18
- onExport: G,
19
- isHiding: J,
20
- isDeleting: K,
21
- confirmHiding: Y,
22
- confirmDeleting: Z,
23
- closeViewOnClickUpdate: _,
24
- recentUpdateOrDeleteId: L,
25
- setRecentUpdateOrDeleteId: b,
26
- setOpenView: q,
27
- inBuiltModalProps: m
28
- }) {
29
- var S;
30
- const h = j == null ? void 0 : j(v), N = H(null), Q = x(
31
- (f, $ = !0, W = !1) => {
32
- var X;
33
- b == null || b(f[u]), m ? (X = N.current) == null || X.update(f, $, W) : W ? g == null || g(f) : y == null || y(f), _ && (q == null || q(void 0));
34
- },
35
- [m, y]
36
- );
37
- return (Array.isArray(h) ? (S = h == null ? void 0 : h.filter(Boolean)) != null && S.length : h) || z || y || g || r ? /* @__PURE__ */ w(A, { children: [
38
- m && /* @__PURE__ */ T(F, { ref: N, ...m }),
39
- h,
40
- (z || y || (m == null ? void 0 : m.onUpdate)) && /* @__PURE__ */ T(C, { value: v, onClick: (f) => Q(f) }),
41
- (g || (m == null ? void 0 : m.onCreate)) && /* @__PURE__ */ T(
42
- V,
43
- {
44
- value: v,
45
- onClick: (f) => Q(f, !1, !0)
46
- }
47
- ),
48
- G && /* @__PURE__ */ T(
49
- o,
50
- {
51
- value: v,
52
- onClick: async (f) => await G(f)
53
- }
54
- ),
55
- E && /* @__PURE__ */ T(
56
- B,
57
- {
58
- value: v,
59
- disabled: J,
60
- shouldConfirm: Y,
61
- loading: J && v[u] === L,
62
- onClick: async (f) => {
63
- b == null || b(f[u]), await E({ [u]: f[u] });
64
- }
65
- }
66
- ),
67
- r && /* @__PURE__ */ T(
68
- k,
69
- {
70
- value: v,
71
- disabled: K,
72
- shouldConfirm: Z,
73
- loading: K && v[u] === L,
74
- onClick: async (f) => {
75
- b == null || b(f[u]), await r({ [u]: f[u] });
76
- }
77
- }
78
- )
79
- ] }) : void 0;
80
- }
81
- export {
82
- O as default
83
- };
@@ -1 +0,0 @@
1
- "use strict";const t=require("react/jsx-runtime"),s=require("@ant-design/icons"),i=require("react"),u=require("../../locale/index.cjs.js"),c=require("./CrudImportComponent.cjs.js"),p=require("../../common/button/Button.cjs.js");function m(n){const{t:r}=u.useTranslationLib(),[o,e]=i.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx(c,{open:o,onCloseMethod:e,...n}),t.jsx(p,{icon:t.jsx(s.ImportOutlined,{}),onClick:()=>e(!0),children:r("str.import")})]})}module.exports=m;
@@ -1,3 +0,0 @@
1
- import { CrudImportComponentProps } from './CrudImportComponent';
2
- declare function CrudImportButton<T>(props: CrudImportComponentProps<T>): import("react/jsx-runtime").JSX.Element;
3
- export default CrudImportButton;
@@ -1,30 +0,0 @@
1
- import { jsxs as e, Fragment as p, jsx as o } from "react/jsx-runtime";
2
- import { ImportOutlined as i } from "@ant-design/icons";
3
- import { useState as s } from "react";
4
- import { useTranslationLib as u } from "../../locale/index.es.js";
5
- import f from "./CrudImportComponent.es.js";
6
- import l from "../../common/button/Button.es.js";
7
- function x(r) {
8
- const { t: n } = u(), [m, t] = s(!1);
9
- return /* @__PURE__ */ e(p, { children: [
10
- /* @__PURE__ */ o(
11
- f,
12
- {
13
- open: m,
14
- onCloseMethod: t,
15
- ...r
16
- }
17
- ),
18
- /* @__PURE__ */ o(
19
- l,
20
- {
21
- icon: /* @__PURE__ */ o(i, {}),
22
- onClick: () => t(!0),
23
- children: n("str.import")
24
- }
25
- )
26
- ] });
27
- }
28
- export {
29
- x as default
30
- };
@@ -1,2 +0,0 @@
1
- "use strict";const n=require("react/jsx-runtime"),q=require("@ant-design/icons"),V=require("papaparse"),d=require("antd"),W=require("file-saver"),a=require("react"),O=require("../../locale/index.cjs.js"),L=require("../view/CrudViewer.cjs.js"),R=require("../../util/DateUtil.cjs.js"),z=require("../../common/button/Button.cjs.js"),$=require("../../common/button/ImportButton.cjs.js");function H({onCloseMethod:w,open:y,fields:T,importProps:o}){const[u,v]=a.useState([]),[C,k]=a.useState(!1),[A,D]=a.useState(0);a.useEffect(()=>{y||(v([]),k(!1))},[y]);const p=a.useMemo(()=>new Map(T.filter(e=>{var t;return!e.hidden&&!((t=e.importProps)!=null&&t.hidden)&&!e.readonly}).map(e=>[e.name,e])),[T]),I=a.useMemo(()=>Array.from(p.values()).flatMap(e=>{var t;return[e.name,...((t=e.importProps)==null?void 0:t.extraFields)??[]]}),[p]),E=a.useCallback(async function(){const e=`${I.join(",")}
2
- `,t=new Blob([e],{type:"text/csv;charset=utf-8;"});W.saveAs(t,(o==null?void 0:o.name)+" - "+R.formatDateTimeWithSecond(new Date).replaceAll(":","-")+".csv")},[I,o==null?void 0:o.name]),{t:i}=O.useTranslationLib(),B=a.useCallback(async e=>{const t=new FileReader;t.onerror=console.error,t.onload=async r=>{var s;const c=(s=r==null?void 0:r.target)==null?void 0:s.result,l=V.parse(c,{header:!0});v(l.data)},t.readAsText(e)},[]),g=a.useMemo(()=>{var t,r,c;let e=!1;for(const l of u)for(const[s,f]of p.entries()){const h=l[s],m=h||!isNaN(h);if(f.required&&!m)if((r=(t=f.importProps)==null?void 0:t.extraFields)!=null&&r.length)for(const j of((c=f.importProps)==null?void 0:c.extraFields)??[])if(l[j]||!isNaN(l[j])){e=!1;break}else return!0;else return!0}return e},[u,p]),x=a.useCallback(e=>(t,r)=>{var l,s,f;const c=t||!isNaN(t);if(e.required&&!c){let h=i("err.validation.required");if((s=(l=e.importProps)==null?void 0:l.extraFields)!=null&&s.length){const m=(f=e.importProps)==null?void 0:f.extraFields;(m==null?void 0:m.find(N=>!r[N]))&&(h="Either one of these fields is required: "+[e.name,...m].join(", "))}return n.jsxs(d.Tooltip,{className:"d-flex",title:h,children:[n.jsx(q.WarningTwoTone,{twoToneColor:"#ee9702"}),t]})}return t},[i]),S=a.useCallback(async e=>{D(e)},[]),b=a.useCallback(async()=>{try{k(!0),await o.onClickImport(u,S),w(!1)}finally{k(!1),D(0)}},[u,o,w,S]),{modal:F}=d.App.useApp(),M=a.useCallback(async()=>{g?F.warning?F.warning({title:i("str.warning"),content:i("qus.importWithIssues"),okText:i("str.import"),onOk:b,okCancel:!0,closable:!0}):(console.error("You must wrap your react app with App component. https://ant.design/components/app"),window.confirm(i("qus.importWithIssues"))&&b()):b()},[g,b,i]);return n.jsxs(d.Modal,{title:[i("str.import"),o==null?void 0:o.name].filter(Boolean).join(" "),width:"100%",open:y,onOk:M,destroyOnHidden:!0,onCancel:()=>w(!1),okText:i("str.import"),confirmLoading:C,okButtonProps:{disabled:!(u!=null&&u.length)},footer:(e,{OkBtn:t,CancelBtn:r})=>n.jsxs(d.Space,{children:[n.jsx(r,{}),n.jsx(t,{}),g&&n.jsx(d.Tooltip,{className:"d-flex",title:"Some fields have issue. Please review before submit.",children:n.jsx(q.WarningTwoTone,{twoToneColor:"#ee9702"})})]}),children:[n.jsxs(d.Space,{children:[n.jsx(z,{onClick:E,icon:n.jsx(q.DownloadOutlined,{}),children:i("str.downloadCsvTemplate")}),n.jsx($.ImportButton,{disabled:C,type:"default",onClick:B,accept:".csv",children:i("str.importCsvFile")})]}),n.jsx(d.Spin,{spinning:C,indicator:A?n.jsx(d.Progress,{type:"circle",percent:A*100,size:50,format:e=>`${parseInt(e)}%`}):void 0,children:n.jsx(L,{data:u,bordered:!0,size:"small",fields:Array.from(p.values()).flatMap(e=>{var t,r,c,l;return e.type==="text"?[{...e,label:e.name,render:x(e)},...((r=(t=e.importProps)==null?void 0:t.extraFields)==null?void 0:r.map(s=>({...e,name:s,label:s,render:x(e)})))??[]]:e.type==="select"?[{...e,label:e.name,type:"text",render:x(e)},...((l=(c=e.importProps)==null?void 0:c.extraFields)==null?void 0:l.map(s=>({...e,name:s,label:s,type:"text",render:x(e)})))??[]]:[{...e,label:e.name,render:x(e)}]})})})]})}module.exports=H;
@@ -1,14 +0,0 @@
1
- import { CrudFieldProps } from '../CrudComponent';
2
- import { DialogProps } from '../../types/DialogComponentProp';
3
- export interface CrudImportComponentProps<T> {
4
- fields: CrudFieldProps<T>[];
5
- importProps: CrudImportProps<T>;
6
- }
7
- export interface CrudImportProps<T> {
8
- name: string;
9
- onClickImport: (data: Array<T | any>, progressCallback: (progress: number) => void) => Promise<{
10
- importJobId: string;
11
- }>;
12
- }
13
- declare function CrudImportComponent<T>({ onCloseMethod, open, fields, importProps, }: DialogProps<never, boolean> & CrudImportComponentProps<T>): import("react/jsx-runtime").JSX.Element;
14
- export default CrudImportComponent;
@@ -1,222 +0,0 @@
1
- import { jsxs as w, jsx as i } from "react/jsx-runtime";
2
- import { WarningTwoTone as B, DownloadOutlined as z } from "@ant-design/icons";
3
- import $ from "papaparse";
4
- import { Tooltip as V, App as H, Modal as R, Space as O, Spin as U, Progress as Y } from "antd";
5
- import { saveAs as _ } from "file-saver";
6
- import { useState as T, useEffect as G, useMemo as A, useCallback as f } from "react";
7
- import { useTranslationLib as J } from "../../locale/index.es.js";
8
- import K from "../view/CrudViewer.es.js";
9
- import Q from "../../util/DateUtil.es.js";
10
- import X from "../../common/button/Button.es.js";
11
- import { ImportButton as Z } from "../../common/button/ImportButton.es.js";
12
- function de({
13
- onCloseMethod: b,
14
- open: x,
15
- fields: D,
16
- importProps: o
17
- }) {
18
- const [c, F] = T([]), [g, C] = T(!1), [N, I] = T(0);
19
- G(() => {
20
- x || (F([]), C(!1));
21
- }, [x]);
22
- const u = A(
23
- () => new Map(
24
- D.filter((e) => {
25
- var t;
26
- return !e.hidden && !((t = e.importProps) != null && t.hidden) && !e.readonly;
27
- }).map((e) => [e.name, e])
28
- ),
29
- [D]
30
- ), E = A(
31
- () => Array.from(u.values()).flatMap((e) => {
32
- var t;
33
- return [
34
- e.name,
35
- ...((t = e.importProps) == null ? void 0 : t.extraFields) ?? []
36
- ];
37
- }),
38
- [u]
39
- ), W = f(
40
- async function() {
41
- const e = `${E.join(",")}
42
- `, t = new Blob([e], { type: "text/csv;charset=utf-8;" });
43
- _(
44
- t,
45
- (o == null ? void 0 : o.name) + " - " + Q.formatDateTimeWithSecond(/* @__PURE__ */ new Date()).replaceAll(":", "-") + ".csv"
46
- );
47
- },
48
- [E, o == null ? void 0 : o.name]
49
- ), { t: s } = J(), L = f(async (e) => {
50
- const t = new FileReader();
51
- t.onerror = console.error, t.onload = async (r) => {
52
- var n;
53
- const l = (n = r == null ? void 0 : r.target) == null ? void 0 : n.result, a = $.parse(l, { header: !0 });
54
- F(a.data);
55
- }, t.readAsText(e);
56
- }, []), k = A(() => {
57
- var t, r, l;
58
- let e = !1;
59
- for (const a of c)
60
- for (const [n, d] of u.entries()) {
61
- const h = a[n], m = h || !isNaN(h);
62
- if (d.required && !m)
63
- if ((r = (t = d.importProps) == null ? void 0 : t.extraFields) != null && r.length)
64
- for (const v of ((l = d.importProps) == null ? void 0 : l.extraFields) ?? [])
65
- if (a[v] || !isNaN(a[v])) {
66
- e = !1;
67
- break;
68
- } else return !0;
69
- else return !0;
70
- }
71
- return e;
72
- }, [c, u]), p = f(
73
- (e) => (t, r) => {
74
- var a, n, d;
75
- const l = t || !isNaN(t);
76
- if (e.required && !l) {
77
- let h = s("err.validation.required");
78
- if ((n = (a = e.importProps) == null ? void 0 : a.extraFields) != null && n.length) {
79
- const m = (d = e.importProps) == null ? void 0 : d.extraFields;
80
- (m == null ? void 0 : m.find((j) => !r[j])) && (h = "Either one of these fields is required: " + [e.name, ...m].join(", "));
81
- }
82
- return /* @__PURE__ */ w(V, { className: "d-flex", title: h, children: [
83
- /* @__PURE__ */ i(B, { twoToneColor: "#ee9702" }),
84
- t
85
- ] });
86
- }
87
- return t;
88
- },
89
- [s]
90
- ), q = f(async (e) => {
91
- I(e);
92
- }, []), y = f(async () => {
93
- try {
94
- C(!0), await o.onClickImport(c, q), b(!1);
95
- } finally {
96
- C(!1), I(0);
97
- }
98
- }, [c, o, b, q]), { modal: S } = H.useApp(), M = f(async () => {
99
- k ? S.warning ? S.warning({
100
- title: s("str.warning"),
101
- content: s("qus.importWithIssues"),
102
- okText: s("str.import"),
103
- onOk: y,
104
- okCancel: !0,
105
- closable: !0
106
- }) : (console.error(
107
- "You must wrap your react app with App component. https://ant.design/components/app"
108
- ), window.confirm(s("qus.importWithIssues")) && y()) : y();
109
- }, [k, y, s]);
110
- return /* @__PURE__ */ w(
111
- R,
112
- {
113
- title: [s("str.import"), o == null ? void 0 : o.name].filter(Boolean).join(" "),
114
- width: "100%",
115
- open: x,
116
- onOk: M,
117
- destroyOnHidden: !0,
118
- onCancel: () => b(!1),
119
- okText: s("str.import"),
120
- confirmLoading: g,
121
- okButtonProps: {
122
- disabled: !(c != null && c.length)
123
- },
124
- footer: (e, { OkBtn: t, CancelBtn: r }) => /* @__PURE__ */ w(O, { children: [
125
- /* @__PURE__ */ i(r, {}),
126
- /* @__PURE__ */ i(t, {}),
127
- k && /* @__PURE__ */ i(
128
- V,
129
- {
130
- className: "d-flex",
131
- title: "Some fields have issue. Please review before submit.",
132
- children: /* @__PURE__ */ i(B, { twoToneColor: "#ee9702" })
133
- }
134
- )
135
- ] }),
136
- children: [
137
- /* @__PURE__ */ w(O, { children: [
138
- /* @__PURE__ */ i(
139
- X,
140
- {
141
- onClick: W,
142
- icon: /* @__PURE__ */ i(z, {}),
143
- children: s("str.downloadCsvTemplate")
144
- }
145
- ),
146
- /* @__PURE__ */ i(
147
- Z,
148
- {
149
- disabled: g,
150
- type: "default",
151
- onClick: L,
152
- accept: ".csv",
153
- children: s("str.importCsvFile")
154
- }
155
- )
156
- ] }),
157
- /* @__PURE__ */ i(
158
- U,
159
- {
160
- spinning: g,
161
- indicator: N ? /* @__PURE__ */ i(
162
- Y,
163
- {
164
- type: "circle",
165
- percent: N * 100,
166
- size: 50,
167
- format: (e) => `${parseInt(e)}%`
168
- }
169
- ) : void 0,
170
- children: /* @__PURE__ */ i(
171
- K,
172
- {
173
- data: c,
174
- bordered: !0,
175
- size: "small",
176
- fields: Array.from(u.values()).flatMap((e) => {
177
- var t, r, l, a;
178
- return e.type === "text" ? [
179
- {
180
- ...e,
181
- label: e.name,
182
- render: p(e)
183
- },
184
- ...((r = (t = e.importProps) == null ? void 0 : t.extraFields) == null ? void 0 : r.map((n) => ({
185
- ...e,
186
- name: n,
187
- label: n,
188
- render: p(e)
189
- }))) ?? []
190
- ] : e.type === "select" ? [
191
- {
192
- ...e,
193
- label: e.name,
194
- type: "text",
195
- render: p(e)
196
- },
197
- ...((a = (l = e.importProps) == null ? void 0 : l.extraFields) == null ? void 0 : a.map((n) => ({
198
- ...e,
199
- name: n,
200
- label: n,
201
- type: "text",
202
- render: p(e)
203
- }))) ?? []
204
- ] : [
205
- {
206
- ...e,
207
- label: e.name,
208
- render: p(e)
209
- }
210
- ];
211
- })
212
- }
213
- )
214
- }
215
- )
216
- ]
217
- }
218
- );
219
- }
220
- export {
221
- de as default
222
- };
package/crud/index.d.ts DELETED
@@ -1,23 +0,0 @@
1
- export type { CheckboxBasedFieldProps, ColorPickerFieldProps, CrudComponentProps, CrudFieldGrid, CrudFieldProps, CrudPaginateProps, CrudPurpose, CrudWizardProp, DateBasedFieldProps, EnumCrudField, FormBuilderFunc, FormBuilderFunc0, GetFormFieldOptions, InitialCrudField, NumberBasedFieldProps, ObjectCrudField, SelectCrudField, SelectFieldItem, TextBasedFieldProps, TimeBasedFieldProps, } from './CrudComponent';
2
- export { default as CrudComponent } from './CrudComponent';
3
- export { default as CrudField, ColorCrudFieldComponent, SelectCrudFieldComponent, } from './CrudField';
4
- export { CrudForm, CrudFormFields } from './CrudForm';
5
- export type { CurdFormFieldsProps } from './CrudForm';
6
- export { default as CrudFormWizard } from './CrudFormWizard';
7
- export type { CrudFormWizardProps } from './CrudFormWizard';
8
- export type { CrudReportComponentProps, CrudReportSubmitForm, ReportCrudFields, SearchOnlyFields, } from './CrudReportComponent';
9
- export { default as CrudReportComponent } from './CrudReportComponent';
10
- export { default as CrudSearchComponent } from './CrudSearchComponent';
11
- export type { CrudSearchComponentProps, CrudSearchOption, } from './CrudSearchComponent';
12
- export { default as ImageCrudField, FileDownloadProvider, FileUploadProvider, ImageCellValue, ImageCrudCellValue, } from './ImageCrudField';
13
- export type { ImageCrudField as ImageCrudFieldProps } from './ImageCrudField';
14
- export { default as FileCrudField, FileCellValue, FileCrudCellValue, } from './FileCrudField';
15
- export type { FileCrudField as FileCrudFieldProps } from './FileCrudField';
16
- export { default as CrudImportComponent } from './import/CrudImportComponent';
17
- export type { CrudImportComponentProps, CrudImportProps, } from './import/CrudImportComponent';
18
- export { default as CrudImportButton } from './import/CrudImportButton';
19
- export { default as CrudActions } from './actions';
20
- export type { CrudActionsProps } from './actions';
21
- export { default as CrudModal } from './modal';
22
- export type { CrudModalProps, CrudModalRef } from './modal';
23
- export * from './view';
@@ -1 +0,0 @@
1
- "use strict";const g=require("react/jsx-runtime"),B=require("antd"),t=require("react"),G=require("../CrudForm.cjs.js"),J=require("../CrudFormWizard.cjs.js"),K=require("../../locale/index.cjs.js"),H=require("../../util/CrudUtil.cjs.js"),Q=require("dayjs"),X=({fields:u,wizard:l,grid:I,fullWidthModal:M,isCreating:h,isUpdating:j,onCreate:b,onUpdate:v,idField:k="id",formBuilder:T},W)=>{const[s]=B.Form.useForm(),{t:C}=K.useTranslationLib(),[S,m]=t.useState(!1),[p,q]=t.useState("new"),[f,F]=t.useState(),[_,y]=t.useState(),[A,N]=t.useState(!1),[L,x]=t.useState(!1),[E,V]=t.useState(!1),P=t.useCallback(async c=>{var o;const d=l?c:await s.validateFields(),i=u.filter(a=>a.type==="color"),n={};for(const a of i){const e=H.getRealName(a.name,"upsertFieldName"),r=s.getFieldValue(e);n[e]=typeof r=="string"?r:(o=r==null?void 0:r.toHexString())==null?void 0:o.toUpperCase()}Object.assign(d,n),f&&v?(await v({...d,[k]:f[k]}),F(void 0)):!f&&b&&await b(d),y(void 0),s.resetFields(),m(!1)},[u,s,k,b,v,f,l]),R=t.useCallback(async c=>{N(c),x(!0)},[]),U=t.useCallback(async()=>{x(!0)},[]),O=t.useCallback(()=>{m(!0),q("new"),s.resetFields(),F(void 0),y(void 0)},[s]),D=t.useCallback(async(c,d=!0,i=!1)=>{try{V(!0),m(!0),q(i?"clone":"update");const n={};for(const o of u){const a=H.getRealName(o.name,"upsertFieldName"),e=c[a];if(i&&o.type==="image"){const r=e;try{const w=await o.provider.clone(r);n[a]=w;continue}catch{continue}}o.type==="date"?e&&(n[a]=Q(e)):o.type==="select"?o.multiple&&Array.isArray(e)?n[a]=e.map(r=>r[o.innerFieldId??"id"]):e&&typeof e=="object"?n[a]=e[o.innerFieldId??"id"]:(e&&typeof e=="string"||typeof e=="number")&&(n[a]=e):n[a]=e}s.setFieldsValue(n),y(n),d&&F(c)}finally{V(!1)}},[u,s]);t.useImperativeHandle(W,()=>({create:O,update:D}),[O,D]),t.useEffect(()=>{S&&(N(!1),x(!1))},[S]);const $=t.useCallback(async()=>{try{if(p==="clone"){const c=l?f:s.getFieldsValue(),d=u.filter(i=>i.type==="image");for(const i of d)c[i.name]&&i.provider.delete(c[i.name])}}finally{}l||s.resetFields(),y(void 0),F(void 0),m(!1)},[p,l,s,f,u]);return g.jsx(B.Modal,{width:M?"100%":void 0,title:C(p??"new"),open:S,confirmLoading:h||j,okText:C("str."+(p==="update"?"update":"save")),cancelText:C("str.cancel"),cancelButtonProps:{disabled:L,hidden:!!l},okButtonProps:{disabled:A,hidden:!!l},onCancel:$,onOk:()=>P(),destroyOnHidden:!0,children:g.jsxs(B.Spin,{spinning:E,children:[l?null:g.jsx(G.CrudForm,{purpose:p,fields:u,form:s,formBuilder:T,grid:I,onDeleteFile:U,onUploadFile:R}),l&&g.jsx(J,{submitting:h||j,className:"mt-2",onSave:P,updatingValue:_,fields:u,onDeleteFile:U,onUploadFile:R,purpose:p,wizard:l})]})})},Y=t.forwardRef(X);module.exports=Y;
@@ -1,24 +0,0 @@
1
- import { Ref } from 'react';
2
- import { CrudFieldProps, CrudWizardProp, FormBuilderFunc } from '../CrudComponent';
3
- import { default as IdProps } from '../../types/Id';
4
- export interface CrudModalProps<T, FormType> {
5
- fields: CrudFieldProps<T>[];
6
- wizard?: CrudWizardProp<T>[];
7
- grid?: boolean;
8
- fullWidthModal?: boolean;
9
- isCreating?: boolean;
10
- isUpdating?: boolean;
11
- onCreate?: (data: FormType) => Promise<any>;
12
- onUpdate?: (data: FormType & IdProps) => Promise<any>;
13
- idField?: string;
14
- formBuilder?: FormBuilderFunc<T>;
15
- }
16
- export interface CrudModalRef<T> {
17
- create: () => void;
18
- update: (data: T, shouldSetUpdatingField?: boolean, isClone?: boolean) => Promise<void>;
19
- }
20
- declare const CrudModal: <T, FormType = T>({ fields, wizard, grid, fullWidthModal, isCreating, isUpdating, onCreate, onUpdate, idField, formBuilder, }: CrudModalProps<T, FormType>, ref: Ref<CrudModalRef<T>>) => import("react/jsx-runtime").JSX.Element;
21
- declare const _default: <T, FormType = T>(props: CrudModalProps<T, FormType> & {
22
- ref?: Ref<CrudModalRef<T>>;
23
- }) => ReturnType<typeof CrudModal>;
24
- export default _default;
@@ -1,146 +0,0 @@
1
- import { jsx as N, jsxs as G } from "react/jsx-runtime";
2
- import { Form as J, Modal as K, Spin as Q } from "antd";
3
- import { forwardRef as X, useState as u, useCallback as m, useImperativeHandle as Y, useEffect as Z } from "react";
4
- import { CrudForm as z } from "../CrudForm.es.js";
5
- import ee from "../CrudFormWizard.es.js";
6
- import { useTranslationLib as te } from "../../locale/index.es.js";
7
- import M from "../../util/CrudUtil.es.js";
8
- import oe from "dayjs";
9
- const ne = ({
10
- fields: c,
11
- wizard: l,
12
- grid: R,
13
- fullWidthModal: T,
14
- isCreating: S,
15
- isUpdating: V,
16
- onCreate: v,
17
- onUpdate: b,
18
- idField: B = "id",
19
- formBuilder: W
20
- }, _) => {
21
- const [t] = J.useForm(), { t: h } = te(), [k, F] = u(!1), [f, x] = u("new"), [p, y] = u(), [A, g] = u(), [L, j] = u(!1), [E, C] = u(!1), [$, P] = u(!1), U = m(
22
- async (i) => {
23
- var n;
24
- const d = l ? i : await t.validateFields(), a = c.filter((s) => s.type === "color"), o = {};
25
- for (const s of a) {
26
- const e = M.getRealName(s.name, "upsertFieldName"), r = t.getFieldValue(e);
27
- o[e] = typeof r == "string" ? r : (n = r == null ? void 0 : r.toHexString()) == null ? void 0 : n.toUpperCase();
28
- }
29
- Object.assign(d, o), p && b ? (await b({
30
- ...d,
31
- [B]: p[B]
32
- }), y(void 0)) : !p && v && await v(d), g(void 0), t.resetFields(), F(!1);
33
- },
34
- [c, t, B, v, b, p, l]
35
- ), O = m(async (i) => {
36
- j(i), C(!0);
37
- }, []), D = m(async () => {
38
- C(!0);
39
- }, []), H = m(() => {
40
- F(!0), x("new"), t.resetFields(), y(void 0), g(void 0);
41
- }, [t]), I = m(
42
- async (i, d = !0, a = !1) => {
43
- try {
44
- P(!0), F(!0), x(a ? "clone" : "update");
45
- const o = {};
46
- for (const n of c) {
47
- const s = M.getRealName(
48
- n.name,
49
- "upsertFieldName"
50
- ), e = i[s];
51
- if (a && n.type === "image") {
52
- const r = e;
53
- try {
54
- const w = await n.provider.clone(r);
55
- o[s] = w;
56
- continue;
57
- } catch {
58
- continue;
59
- }
60
- }
61
- n.type === "date" ? e && (o[s] = oe(e)) : n.type === "select" ? n.multiple && Array.isArray(e) ? o[s] = e.map(
62
- (r) => r[n.innerFieldId ?? "id"]
63
- ) : e && typeof e == "object" ? o[s] = e[n.innerFieldId ?? "id"] : (e && typeof e == "string" || typeof e == "number") && (o[s] = e) : o[s] = e;
64
- }
65
- t.setFieldsValue(o), g(o), d && y(i);
66
- } finally {
67
- P(!1);
68
- }
69
- },
70
- [c, t]
71
- );
72
- Y(
73
- _,
74
- () => ({
75
- create: H,
76
- update: I
77
- }),
78
- [H, I]
79
- ), Z(() => {
80
- k && (j(!1), C(!1));
81
- }, [k]);
82
- const q = m(async () => {
83
- try {
84
- if (f === "clone") {
85
- const i = l ? p : t.getFieldsValue(), d = c.filter((a) => a.type === "image");
86
- for (const a of d)
87
- i[a.name] && a.provider.delete(i[a.name]);
88
- }
89
- } finally {
90
- }
91
- l || t.resetFields(), g(void 0), y(void 0), F(!1);
92
- }, [f, l, t, p, c]);
93
- return /* @__PURE__ */ N(
94
- K,
95
- {
96
- width: T ? "100%" : void 0,
97
- title: h(f ?? "new"),
98
- open: k,
99
- confirmLoading: S || V,
100
- okText: h("str." + (f === "update" ? "update" : "save")),
101
- cancelText: h("str.cancel"),
102
- cancelButtonProps: {
103
- disabled: E,
104
- hidden: !!l
105
- },
106
- okButtonProps: {
107
- disabled: L,
108
- hidden: !!l
109
- },
110
- onCancel: q,
111
- onOk: () => U(),
112
- destroyOnHidden: !0,
113
- children: /* @__PURE__ */ G(Q, { spinning: $, children: [
114
- l ? null : /* @__PURE__ */ N(
115
- z,
116
- {
117
- purpose: f,
118
- fields: c,
119
- form: t,
120
- formBuilder: W,
121
- grid: R,
122
- onDeleteFile: D,
123
- onUploadFile: O
124
- }
125
- ),
126
- l && /* @__PURE__ */ N(
127
- ee,
128
- {
129
- submitting: S || V,
130
- className: "mt-2",
131
- onSave: U,
132
- updatingValue: A,
133
- fields: c,
134
- onDeleteFile: D,
135
- onUploadFile: O,
136
- purpose: f,
137
- wizard: l
138
- }
139
- )
140
- ] })
141
- }
142
- );
143
- }, fe = X(ne);
144
- export {
145
- fe as default
146
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("../../common/description/DescList.cjs.js"),f=require("react"),j=require("../../locale/index.cjs.js"),V=require("./CrudViewerUtil.cjs.js"),p=require("../../util/CrudUtil.cjs.js"),v=require("../actions/index.cjs.js");function w({className:c,fields:n,data:e,descListColumn:m={xs:1,md:3,sm:2,lg:4},layout:b,keepEmptyValues:g,inBuiltModalProps:q,...s}){const{t:u}=j.useTranslationLib(),x=f.useMemo(()=>{const o=n.filter(({hidden:r,hideInDescList:i})=>!r&&!i).map((r,i)=>{const C=p.getRealName(r.name);return{label:r.label,noFormatting:!0,value:V.getRendererValueCrudViewer(r)(e==null?void 0:e[C],e,i)}}),l=e?t.jsx(v,{data:e,...s,inBuiltModalProps:q}):void 0;return l&&o.push({label:u("str.action"),value:l}),o},[e,n,u,s]);return e?t.jsx(d,{keepEmptyValues:g,bordered:!0,column:m,className:c,layout:b,list:x}):t.jsx(t.Fragment,{})}exports.CrudDecListView=w;
@@ -1,15 +0,0 @@
1
- import { Breakpoint } from 'antd';
2
- import { CrudFieldProps } from '../CrudComponent';
3
- import { CrudActionsProps } from '../actions';
4
- import { CrudModalProps } from '../modal';
5
- export type DescListColumn = number | Partial<Record<Breakpoint, number>> | undefined;
6
- export interface CrudDecListViewProps<T, FormType = T> extends CrudActionsProps<T, FormType> {
7
- fields: CrudFieldProps<T>[];
8
- data: T | undefined;
9
- className?: string;
10
- descListColumn?: DescListColumn;
11
- layout?: "horizontal" | "vertical";
12
- keepEmptyValues?: boolean;
13
- inBuiltModalProps?: CrudModalProps<T, FormType>;
14
- }
15
- export declare function CrudDecListView<T, FormType = T>({ className, fields, data, descListColumn, layout, keepEmptyValues, inBuiltModalProps, ...crudActionsProps }: Readonly<CrudDecListViewProps<T, FormType>>): import("react/jsx-runtime").JSX.Element;
@@ -1,57 +0,0 @@
1
- import { jsx as t, Fragment as v } from "react/jsx-runtime";
2
- import x from "../../common/description/DescList.es.js";
3
- import { useMemo as F } from "react";
4
- import { useTranslationLib as L } from "../../locale/index.es.js";
5
- import { getRendererValueCrudViewer as V } from "./CrudViewerUtil.es.js";
6
- import w from "../../util/CrudUtil.es.js";
7
- import D from "../actions/index.es.js";
8
- function _({
9
- className: u,
10
- fields: i,
11
- data: r,
12
- descListColumn: f = { xs: 1, md: 3, sm: 2, lg: 4 },
13
- layout: p,
14
- keepEmptyValues: c,
15
- inBuiltModalProps: b,
16
- ...m
17
- }) {
18
- const { t: n } = L(), g = F(() => {
19
- const l = i.filter(({ hidden: e, hideInDescList: o }) => !e && !o).map((e, o) => {
20
- const C = w.getRealName(e.name);
21
- return {
22
- label: e.label,
23
- noFormatting: !0,
24
- value: V(e)(
25
- r == null ? void 0 : r[C],
26
- r,
27
- o
28
- )
29
- };
30
- }), s = r ? /* @__PURE__ */ t(
31
- D,
32
- {
33
- data: r,
34
- ...m,
35
- inBuiltModalProps: b
36
- }
37
- ) : void 0;
38
- return s && l.push({
39
- label: n("str.action"),
40
- value: s
41
- }), l;
42
- }, [r, i, n, m]);
43
- return r ? /* @__PURE__ */ t(
44
- x,
45
- {
46
- keepEmptyValues: c,
47
- bordered: !0,
48
- column: f,
49
- className: u,
50
- layout: p,
51
- list: g
52
- }
53
- ) : /* @__PURE__ */ t(v, {});
54
- }
55
- export {
56
- _ as CrudDecListView
57
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),xt=require("antd"),ft=require("@dnd-kit/core"),jt=require("@dnd-kit/modifiers"),yt=require("@dnd-kit/utilities"),d=require("@dnd-kit/sortable"),ht=require("../../common/button/Button.cjs.js"),qt=require("../../common/button/RefreshButton.cjs.js"),Ct=require("../../common/button/ViewButtonTable.cjs.js"),St=require("../actions/index.cjs.js"),It=require("../../common/table/table.cjs.js"),r=require("react"),lt=require("../../locale/index.cjs.js"),Rt=require("../CrudSearchComponent.cjs.js"),Mt=require("./CrudDecListView.cjs.js"),tt=require("./CrudViewerUtil.cjs.js"),dt=require("@ant-design/icons"),et=require("../../util/CrudUtil.cjs.js"),Tt=require("../../common/layout/VerticalSpace.cjs.js"),Bt=r.memo(It);function Dt({idField:n="id",loadingData:h,fields:m,isDeleting:T,isHiding:l,viewable:c=!1,paginateProps:j,onDelete:q,onHide:B,onUpdate:C,data:S=[],extraAction:D,onClickUpdate:V,minusHeight:E,scroll:k,onClickClone:v,className:z,expandable:$,size:p,bordered:A,descListColumn:ot,extraView:L,decListLayout:st,scrollToTop:Et,onClickRefresh:_,closeViewOnClickUpdate:G,onExport:J,confirmHiding:K,confirmDeleting:Q,rowClassName:X,actionWidth:Y=190,draggable:t,...rt}){const{t:Z}=lt.useTranslationLib(),P=r.useMemo(()=>m.map(({hideInTable:o,hidden:s,width:u,label:x,halign:I,...M})=>{const N=et.getRealName(M.name);return{title:x,width:u,key:N,dataIndex:N,hidden:o||s,align:I??(M.type==="number"?"right":void 0),render:tt.getRendererValueCrudViewer(M)}}),[m]),[i,R]=r.useState(),[W,H]=r.useState(),[y,U]=r.useState([]);r.useEffect(()=>{S&&U(S)},[S]),r.useEffect(()=>{S&&R(o=>{if(o)return S.find(s=>s[n]===o[n])})},[S,n,i]);const w=r.useCallback(o=>{var x;const{active:s,over:u}=o;if(t!=null&&t.onDragEnd&&(t==null||t.onDragEnd(o)),s.id!==(u==null?void 0:u.id)){const I=y.findIndex(f=>f[n]===s.id),M=y.findIndex(f=>f[n]===(u==null?void 0:u.id)),N=d.arrayMove(y,I,M);U(f=>{const it=f.findIndex(O=>O[n]===(s==null?void 0:s.id)),mt=f.findIndex(O=>O[n]===(u==null?void 0:u.id));return d.arrayMove(f,it,mt)}),(x=t==null?void 0:t.onDrag)==null||x.call(t,{newOrder:N.map(f=>f[n])})}},[y,n,t]),ct=r.useMemo(()=>{let o=typeof c=="string"?i==null?void 0:i[c]:void 0;if(typeof o=="object"){const s=m.find(u=>et.getRealName(u.name)===c);o=tt.getRendererValueCrudViewer(s)(o,i,0)}return o},[c,i,m]),a=r.useMemo(()=>({rowClassName:X,className:z,scroll:k??(E?{y:`calc(100vh - ${E})`}:void 0),id:"crud-table",bordered:A,size:p,expandable:$}),[X,z,k,E,A,p,$]),F=r.useMemo(()=>j?{total:j.count,onChange:j.setPage,current:j.page,pageSize:j.pageSize}:void 0,[j]),b=r.useMemo(()=>{const o=C||V||q||D||c,s=[];return t&&s.push({key:"key",align:"center",width:5,title:t==null?void 0:t.columnLabel,render:()=>e.jsx(Vt,{tooltip:t==null?void 0:t.tooltip})}),s.push(...P),o&&o&&s.push({title:Z("str.action"),fixed:"right",width:Y,render:(u,x)=>e.jsxs(e.Fragment,{children:[c&&e.jsx(Ct,{value:x,onClick:typeof c=="object"?()=>{var I;return(I=c.onClick)==null?void 0:I.call(c,x)}:R}),e.jsx(St,{data:x,idField:n,extraAction:D,onUpdate:C,onClickUpdate:V,onClickClone:v,onDelete:q,onHide:B,onExport:J,isHiding:l,isDeleting:T,confirmHiding:K,confirmDeleting:Q,closeViewOnClickUpdate:G,recentUpdateOrDeleteId:W,setRecentUpdateOrDeleteId:H,setOpenView:R})]})}),s},[P,C,V,q,D,c,Z,Y]),g=r.useMemo(()=>y.map(o=>o[n]),[y,n]),ut=r.useCallback(()=>{const o=e.jsx(Bt,{...a,dataSource:y,loading:h,components:t?{body:{row:Nt}}:void 0,pagination:F,columns:b});return t?e.jsx(ft.DndContext,{modifiers:[jt.restrictToVerticalAxis],onDragEnd:w,children:e.jsx(d.SortableContext,{items:g,strategy:d.verticalListSortingStrategy,children:o})}):o},[a,y,h,F,b,t,g,w]);return e.jsxs("div",{children:[typeof c=="boolean"||typeof c=="string"&&e.jsx(xt.Modal,{width:"100%",open:!!i,title:ct??e.jsx("div",{children:" "}),footer:e.jsx(e.Fragment,{}),closable:!0,onCancel:()=>R(void 0),children:!!i&&e.jsxs("div",{children:[e.jsx(Mt.CrudDecListView,{layout:st,descListColumn:ot,data:i,fields:m,idField:n,extraAction:D,onUpdate:C,onClickUpdate:V,onClickClone:v,onDelete:q,onHide:B,onExport:J,isHiding:l,isDeleting:T,confirmHiding:K,confirmDeleting:Q,closeViewOnClickUpdate:G,recentUpdateOrDeleteId:W,setRecentUpdateOrDeleteId:H,setOpenView:R}),L==null?void 0:L(i)]},i==null?void 0:i[n])}),e.jsx(Rt,{fields:m,...rt}),e.jsxs(Tt,{children:[!!_&&e.jsx(qt.RefreshButton,{onClick:_}),ut()]})]})}const nt=r.createContext({}),Vt=({tooltip:n})=>{const{setActivatorNodeRef:h,listeners:m}=r.useContext(nt);return e.jsx(ht,{type:"text",size:"small",tooltip:n,icon:e.jsx(dt.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:h,...m})},Nt=n=>{const{attributes:h,listeners:m,setNodeRef:T,setActivatorNodeRef:l,transform:c,transition:j,isDragging:q}=d.useSortable({id:n["data-row-key"]}),B={...n.style,transform:yt.CSS.Translate.toString(c),transition:j,...q?{position:"relative",zIndex:9999}:{}},C=r.useMemo(()=>({setActivatorNodeRef:l,listeners:m}),[l,m]);return e.jsx(nt.Provider,{value:C,children:e.jsx("tr",{...n,ref:T,style:B,...h})})};module.exports=Dt;