@kingteza/crud-component 1.0.40 → 1.0.43

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 (70) hide show
  1. package/common/button/Button.cjs.js +1 -1
  2. package/common/button/Button.es.js +19 -20
  3. package/common/button/CloneButtonTable.cjs.js +1 -1
  4. package/common/button/CloneButtonTable.es.js +9 -10
  5. package/common/button/DeleteButtonTable.cjs.js +1 -1
  6. package/common/button/DeleteButtonTable.es.js +29 -33
  7. package/common/button/ExportButton.cjs.js +1 -1
  8. package/common/button/ExportButton.es.js +10 -11
  9. package/common/button/HideButtonTable.cjs.js +1 -1
  10. package/common/button/HideButtonTable.es.js +22 -23
  11. package/common/button/ImportButton.cjs.js +1 -1
  12. package/common/button/ImportButton.es.js +19 -20
  13. package/common/button/NewButton.cjs.js +1 -1
  14. package/common/button/NewButton.es.js +13 -14
  15. package/common/button/PrintButton.cjs.js +1 -1
  16. package/common/button/PrintButton.es.js +11 -12
  17. package/common/button/RefreshButton.cjs.js +1 -1
  18. package/common/button/RefreshButton.es.js +10 -11
  19. package/common/button/UnHideButton.cjs.js +1 -1
  20. package/common/button/UnHideButton.es.js +37 -38
  21. package/common/button/UpdateButtonTable.cjs.js +1 -1
  22. package/common/button/UpdateButtonTable.es.js +8 -9
  23. package/common/button/ViewButtonTable.cjs.js +1 -1
  24. package/common/button/ViewButtonTable.es.js +10 -11
  25. package/common/date-picker/DatePicker.cjs.js +1 -1
  26. package/common/date-picker/DatePicker.es.js +40 -41
  27. package/common/date-picker/TimePicker.cjs.js +1 -1
  28. package/common/date-picker/TimePicker.es.js +47 -48
  29. package/common/loading/LoadingIndicator.cjs.js +1 -1
  30. package/common/loading/LoadingIndicator.es.js +6 -7
  31. package/common/picker/ImagePicker.cjs.js +1 -1
  32. package/common/picker/ImagePicker.es.js +80 -81
  33. package/common/select/SelectComponent.cjs.js +1 -1
  34. package/common/select/SelectComponent.es.js +33 -34
  35. package/common/tag/StatusTag.cjs.js +1 -1
  36. package/common/tag/StatusTag.es.js +12 -13
  37. package/common/text-field/NumberField.cjs.js +1 -1
  38. package/common/text-field/NumberField.es.js +41 -42
  39. package/common/text-field/TextArea.cjs.js +1 -1
  40. package/common/text-field/TextArea.es.js +15 -16
  41. package/common/text-field/TextField.cjs.js +1 -1
  42. package/common/text-field/TextField.es.js +50 -51
  43. package/common/wizard/WizardResult.cjs.js +1 -1
  44. package/common/wizard/WizardResult.es.js +36 -38
  45. package/crud/CrudComponent.cjs.js +1 -1
  46. package/crud/CrudComponent.es.js +77 -78
  47. package/crud/CrudField.cjs.js +1 -1
  48. package/crud/CrudField.es.js +126 -127
  49. package/crud/CrudFormWizard.cjs.js +1 -1
  50. package/crud/CrudFormWizard.es.js +47 -48
  51. package/crud/FileCrudField.cjs.js +1 -1
  52. package/crud/FileCrudField.es.js +72 -73
  53. package/crud/import/CrudImportButton.cjs.js +1 -1
  54. package/crud/import/CrudImportButton.es.js +10 -11
  55. package/crud/import/CrudImportComponent.cjs.js +2 -2
  56. package/crud/import/CrudImportComponent.es.js +56 -57
  57. package/crud/view/CrudDecListView.cjs.js +1 -1
  58. package/crud/view/CrudDecListView.es.js +11 -12
  59. package/crud/view/CrudViewer.cjs.js +1 -1
  60. package/crud/view/CrudViewer.es.js +120 -121
  61. package/crud/view/CrudViewerUtil.cjs.js +1 -1
  62. package/crud/view/CrudViewerUtil.es.js +15 -17
  63. package/locale/index.cjs.js +1 -1
  64. package/locale/index.d.ts +4 -0
  65. package/locale/index.es.js +36 -24
  66. package/package.json +1 -1
  67. package/util/DateUtil.cjs.js +1 -1
  68. package/util/DateUtil.es.js +16 -4
  69. package/util/ValidationUtil.cjs.js +1 -1
  70. package/util/ValidationUtil.es.js +26 -23
@@ -1,34 +1,33 @@
1
1
  import { jsxs as w, jsx as i } from "react/jsx-runtime";
2
2
  import { WarningTwoTone as B, DownloadOutlined as z } from "@ant-design/icons";
3
- import R from "papaparse";
4
- import { Tooltip as O, App as _, Modal as $, Space as V, Spin as U, Progress as Y } from "antd";
3
+ import $ from "papaparse";
4
+ import { Tooltip as V, App as R, Modal as U, Space as O, Spin as Y, Progress as _ } from "antd";
5
5
  import { saveAs as G } from "file-saver";
6
- import { useState as T, useEffect as H, useMemo as v, useCallback as f } from "react";
7
- import { useTranslation as J } from "react-i18next";
8
- import { TRANSLATION_NAMESPACE as K } from "../../locale/hooks/translation-constants.es.js";
9
- import Q from "../view/CrudViewer.es.js";
10
- import X from "../../util/DateUtil.es.js";
11
- import Z from "../../common/button/Button.es.js";
12
- import { ImportButton as P } from "../../common/button/ImportButton.es.js";
13
- function fe({
14
- onCloseMethod: x,
15
- open: b,
16
- fields: N,
6
+ import { useState as T, useEffect as H, 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,
17
16
  importProps: o
18
17
  }) {
19
- const [c, D] = T([]), [C, g] = T(!1), [E, F] = T(0);
18
+ const [c, F] = T([]), [g, C] = T(!1), [N, I] = T(0);
20
19
  H(() => {
21
- b || (D([]), g(!1));
22
- }, [b]);
23
- const u = v(
20
+ x || (F([]), C(!1));
21
+ }, [x]);
22
+ const u = A(
24
23
  () => new Map(
25
- N.filter((e) => {
24
+ D.filter((e) => {
26
25
  var t;
27
26
  return !e.hidden && !((t = e.importProps) != null && t.hidden) && !e.readonly;
28
27
  }).map((e) => [e.name, e])
29
28
  ),
30
- [N]
31
- ), I = v(
29
+ [D]
30
+ ), E = A(
32
31
  () => Array.from(u.values()).flatMap((e) => {
33
32
  var t;
34
33
  return [
@@ -37,24 +36,24 @@ function fe({
37
36
  ];
38
37
  }),
39
38
  [u]
40
- ), M = f(
39
+ ), W = f(
41
40
  async function() {
42
- const e = `${I.join(",")}
41
+ const e = `${E.join(",")}
43
42
  `, t = new Blob([e], { type: "text/csv;charset=utf-8;" });
44
43
  G(
45
44
  t,
46
- (o == null ? void 0 : o.name) + " - " + X.formatDateTimeWithSecond(/* @__PURE__ */ new Date()).replaceAll(":", "-") + ".csv"
45
+ (o == null ? void 0 : o.name) + " - " + Q.formatDateTimeWithSecond(/* @__PURE__ */ new Date()).replaceAll(":", "-") + ".csv"
47
46
  );
48
47
  },
49
- [I, o == null ? void 0 : o.name]
50
- ), { t: s } = J(K), W = f(async (e) => {
48
+ [E, o == null ? void 0 : o.name]
49
+ ), { t: s } = J(), L = f(async (e) => {
51
50
  const t = new FileReader();
52
51
  t.onerror = console.error, t.onload = async (r) => {
53
52
  var n;
54
- const l = (n = r == null ? void 0 : r.target) == null ? void 0 : n.result, a = R.parse(l, { header: !0 });
55
- D(a.data);
53
+ const l = (n = r == null ? void 0 : r.target) == null ? void 0 : n.result, a = $.parse(l, { header: !0 });
54
+ F(a.data);
56
55
  }, t.readAsText(e);
57
- }, []), k = v(() => {
56
+ }, []), k = A(() => {
58
57
  var t, r, l;
59
58
  let e = !1;
60
59
  for (const a of c)
@@ -62,8 +61,8 @@ function fe({
62
61
  const h = a[n], m = h || !isNaN(h);
63
62
  if (d.required && !m)
64
63
  if ((r = (t = d.importProps) == null ? void 0 : t.extraFields) != null && r.length)
65
- for (const A of ((l = d.importProps) == null ? void 0 : l.extraFields) ?? [])
66
- if (a[A] || !isNaN(a[A])) {
64
+ for (const v of ((l = d.importProps) == null ? void 0 : l.extraFields) ?? [])
65
+ if (a[v] || !isNaN(a[v])) {
67
66
  e = !1;
68
67
  break;
69
68
  } else return !0;
@@ -80,7 +79,7 @@ function fe({
80
79
  const m = (d = e.importProps) == null ? void 0 : d.extraFields;
81
80
  (m == null ? void 0 : m.find((j) => !r[j])) && (h = "Either one of these fields is required: " + [e.name, ...m].join(", "));
82
81
  }
83
- return /* @__PURE__ */ w(O, { className: "d-flex", title: h, children: [
82
+ return /* @__PURE__ */ w(V, { className: "d-flex", title: h, children: [
84
83
  /* @__PURE__ */ i(B, { twoToneColor: "#ee9702" }),
85
84
  t
86
85
  ] });
@@ -88,16 +87,16 @@ function fe({
88
87
  return t;
89
88
  },
90
89
  [s]
91
- ), S = f(async (e) => {
92
- F(e);
90
+ ), q = f(async (e) => {
91
+ I(e);
93
92
  }, []), y = f(async () => {
94
93
  try {
95
- g(!0), await o.onClickImport(c, S), x(!1);
94
+ C(!0), await o.onClickImport(c, q), b(!1);
96
95
  } finally {
97
- g(!1), F(0);
96
+ C(!1), I(0);
98
97
  }
99
- }, [c, o, x, S]), { modal: q } = _.useApp(), L = f(async () => {
100
- k ? q.warning ? q.warning({
98
+ }, [c, o, b, q]), { modal: S } = R.useApp(), M = f(async () => {
99
+ k ? S.warning ? S.warning({
101
100
  title: s("str.warning"),
102
101
  content: s("qus.importWithIssues"),
103
102
  okText: s("str.import"),
@@ -109,24 +108,24 @@ function fe({
109
108
  ), window.confirm(s("qus.importWithIssues")) && y()) : y();
110
109
  }, [k, y, s]);
111
110
  return /* @__PURE__ */ w(
112
- $,
111
+ U,
113
112
  {
114
113
  title: [s("str.import"), o == null ? void 0 : o.name].filter(Boolean).join(" "),
115
114
  width: "100%",
116
- open: b,
117
- onOk: L,
115
+ open: x,
116
+ onOk: M,
118
117
  destroyOnClose: !0,
119
- onCancel: () => x(!1),
118
+ onCancel: () => b(!1),
120
119
  okText: s("str.import"),
121
- confirmLoading: C,
120
+ confirmLoading: g,
122
121
  okButtonProps: {
123
122
  disabled: !(c != null && c.length)
124
123
  },
125
- footer: (e, { OkBtn: t, CancelBtn: r }) => /* @__PURE__ */ w(V, { children: [
124
+ footer: (e, { OkBtn: t, CancelBtn: r }) => /* @__PURE__ */ w(O, { children: [
126
125
  /* @__PURE__ */ i(r, {}),
127
126
  /* @__PURE__ */ i(t, {}),
128
127
  k && /* @__PURE__ */ i(
129
- O,
128
+ V,
130
129
  {
131
130
  className: "d-flex",
132
131
  title: "Some fields have issue. Please review before submit.",
@@ -135,41 +134,41 @@ function fe({
135
134
  )
136
135
  ] }),
137
136
  children: [
138
- /* @__PURE__ */ w(V, { children: [
137
+ /* @__PURE__ */ w(O, { children: [
139
138
  /* @__PURE__ */ i(
140
- Z,
139
+ X,
141
140
  {
142
- onClick: M,
141
+ onClick: W,
143
142
  icon: /* @__PURE__ */ i(z, {}),
144
143
  children: s("str.downloadCsvTemplate")
145
144
  }
146
145
  ),
147
146
  /* @__PURE__ */ i(
148
- P,
147
+ Z,
149
148
  {
150
- disabled: C,
149
+ disabled: g,
151
150
  type: "default",
152
- onClick: W,
151
+ onClick: L,
153
152
  accept: ".csv",
154
153
  children: s("str.importCsvFile")
155
154
  }
156
155
  )
157
156
  ] }),
158
157
  /* @__PURE__ */ i(
159
- U,
158
+ Y,
160
159
  {
161
- spinning: C,
162
- indicator: E ? /* @__PURE__ */ i(
163
- Y,
160
+ spinning: g,
161
+ indicator: N ? /* @__PURE__ */ i(
162
+ _,
164
163
  {
165
164
  type: "circle",
166
- percent: E * 100,
165
+ percent: N * 100,
167
166
  size: 50,
168
167
  format: (e) => `${parseInt(e)}%`
169
168
  }
170
169
  ) : void 0,
171
170
  children: /* @__PURE__ */ i(
172
- Q,
171
+ K,
173
172
  {
174
173
  data: c,
175
174
  bordered: !0,
@@ -219,5 +218,5 @@ function fe({
219
218
  );
220
219
  }
221
220
  export {
222
- fe as default
221
+ de as default
223
222
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),q=require("../../common/description/DescList.cjs.js"),C=require("react"),f=require("react-i18next"),x=require("../../locale/hooks/translation-constants.cjs.js"),V=require("./CrudViewerUtil.cjs.js");function a({className:l,fields:u,data:e,descListColumn:c={xs:1,md:3,sm:2,lg:4},layout:m,action:t,keepEmptyValues:b}){const{t:i}=f.useTranslation(x.TRANSLATION_NAMESPACE),g=C.useMemo(()=>{const o=u.filter(({hidden:r,hideInDescList:s})=>!r&&!s).map((r,s)=>({label:r.label,noFormatting:!0,value:V.getRendererValueCrudViewer(r)(e==null?void 0:e[r.name],e,s)}));return t&&o.push({label:i("str.action"),value:t}),o},[t,e,u,i]);return e?n.jsx(q,{keepEmptyValues:b,bordered:!0,column:c,className:l,layout:m,list:g}):n.jsx(n.Fragment,{})}exports.CrudDecListView=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),f=require("../../common/description/DescList.cjs.js"),q=require("react"),x=require("../../locale/index.cjs.js"),V=require("./CrudViewerUtil.cjs.js");function d({className:o,fields:u,data:e,descListColumn:c={xs:1,md:3,sm:2,lg:4},layout:m,action:t,keepEmptyValues:b}){const{t:n}=x.useTranslationLib(),g=q.useMemo(()=>{const l=u.filter(({hidden:r,hideInDescList:i})=>!r&&!i).map((r,i)=>({label:r.label,noFormatting:!0,value:V.getRendererValueCrudViewer(r)(e==null?void 0:e[r.name],e,i)}));return t&&l.push({label:n("str.action"),value:t}),l},[t,e,u,n]);return e?s.jsx(f,{keepEmptyValues:b,bordered:!0,column:c,className:o,layout:m,list:g}):s.jsx(s.Fragment,{})}exports.CrudDecListView=d;
@@ -1,30 +1,29 @@
1
1
  import { jsx as l, Fragment as b } from "react/jsx-runtime";
2
2
  import g from "../../common/description/DescList.es.js";
3
- import { useMemo as A } from "react";
4
- import { useTranslation as x } from "react-i18next";
5
- import { TRANSLATION_NAMESPACE as C } from "../../locale/hooks/translation-constants.es.js";
6
- import { getRendererValueCrudViewer as L } from "./CrudViewerUtil.es.js";
7
- function E({
3
+ import { useMemo as x } from "react";
4
+ import { useTranslationLib as L } from "../../locale/index.es.js";
5
+ import { getRendererValueCrudViewer as V } from "./CrudViewerUtil.es.js";
6
+ function h({
8
7
  className: n,
9
- fields: t,
8
+ fields: m,
10
9
  data: r,
11
10
  descListColumn: u = { xs: 1, md: 3, sm: 2, lg: 4 },
12
11
  layout: f,
13
12
  action: o,
14
13
  keepEmptyValues: p
15
14
  }) {
16
- const { t: i } = x(C), c = A(() => {
17
- const s = t.filter(({ hidden: e, hideInDescList: m }) => !e && !m).map((e, m) => ({
15
+ const { t: i } = L(), c = x(() => {
16
+ const s = m.filter(({ hidden: e, hideInDescList: t }) => !e && !t).map((e, t) => ({
18
17
  label: e.label,
19
18
  noFormatting: !0,
20
- value: L(e)(
19
+ value: V(e)(
21
20
  r == null ? void 0 : r[e.name],
22
21
  r,
23
- m
22
+ t
24
23
  )
25
24
  }));
26
25
  return o && s.push({ label: i("str.action"), value: o }), s;
27
- }, [o, r, t, i]);
26
+ }, [o, r, m, i]);
28
27
  return r ? /* @__PURE__ */ l(
29
28
  g,
30
29
  {
@@ -38,5 +37,5 @@ function E({
38
37
  ) : /* @__PURE__ */ l(b, {});
39
38
  }
40
39
  export {
41
- E as CrudDecListView
40
+ h as CrudDecListView
42
41
  };
@@ -1 +1 @@
1
- "use strict";const r=require("react/jsx-runtime"),k=require("antd"),H=require("../../common/button/CloneButtonTable.cjs.js"),p=require("../../common/button/DeleteButtonTable.cjs.js"),U=require("../../common/button/ExportButton.cjs.js"),F=require("../../common/button/HideButtonTable.cjs.js"),rr=require("../../common/button/RefreshButton.cjs.js"),er=require("../../common/button/UpdateButtonTable.cjs.js"),tr=require("../../common/button/ViewButtonTable.cjs.js"),sr=require("../../common/table/table.cjs.js"),j=require("react"),ur=require("react-i18next"),nr=require("../../locale/hooks/translation-constants.cjs.js"),or=require("../CrudSearchComponent.cjs.js"),cr=require("./CrudDecListView.cjs.js"),O=require("./CrudViewerUtil.cjs.js"),lr=require("../../common/layout/VerticalSpace.cjs.js");function ar({idField:s="id",loadingData:z,fields:l,isDeleting:T,isHiding:m,viewable:o=!1,paginateProps:h,onDelete:q,onHide:y,onUpdate:v,data:x=[],extraAction:i,onClickUpdate:c,minusHeight:R,scroll:_,onClickClone:B,className:$,expandable:w,size:A,bordered:G,descListColumn:J,extraView:S,decListLayout:K,scrollToTop:jr,onClickRefresh:I,closeViewOnClickUpdate:V,onExport:g,confirmHiding:M,confirmDeleting:d,rowClassName:Q,actionWidth:W=190,...X}){const{t:Y}=ur.useTranslation(nr.TRANSLATION_NAMESPACE),E=j.useMemo(()=>l.map(({hideInTable:e,hidden:t,width:a,name:n,label:D,halign:P,...N})=>({title:D,width:a,key:n,dataIndex:n,hidden:e||t,align:P??(N.type==="number"?"right":void 0),render:O.getRendererValueCrudViewer(N)})),[l]),[u,f]=j.useState(),[b,C]=j.useState();j.useEffect(()=>{x&&f(e=>{if(e)return x.find(t=>t[s]===e[s])})},[x,s,u]);const L=j.useCallback(e=>{var a;const t=i==null?void 0:i(e);return(Array.isArray(t)?(a=t==null?void 0:t.filter(Boolean))!=null&&a.length:t)||v||c||B||q?r.jsxs(r.Fragment,{children:[t,(v||c)&&r.jsx(er,{value:e,onClick:n=>{C(n[s]),c==null||c(e),V&&f(void 0)}}),B&&r.jsx(H,{value:e,onClick:n=>B(n)}),g&&r.jsx(U.ExportButton,{value:e,onClick:async n=>await g(n)}),y&&r.jsx(F,{value:e,disabled:m,shouldConfirm:M,loading:m&&e[s]===b,onClick:async n=>{C(n[s]),await y({[s]:n[s]})}}),q&&r.jsx(p,{value:e,disabled:T,shouldConfirm:d,loading:T&&e[s]===b,onClick:async n=>{C(n[s]),await q({[s]:n[s]})}})]}):void 0},[V,d,M,i,s,T,m,B,c,q,g,y,v,b]),Z=j.useMemo(()=>{let e=typeof o=="string"?u==null?void 0:u[o]:void 0;if(typeof e=="object"){const t=l.find(a=>a.name===o);e=O.getRendererValueCrudViewer(t)(e,u,0)}return e},[o,u,l]);return r.jsxs("div",{children:[o&&r.jsx(k.Modal,{width:"100%",open:!!u,title:Z??r.jsx("div",{children:" "}),footer:r.jsx(r.Fragment,{}),closable:!0,onCancel:()=>f(void 0),children:!!u&&r.jsxs("div",{children:[r.jsx(cr.CrudDecListView,{layout:K,descListColumn:J,data:u,fields:l,action:L(u)}),S==null?void 0:S(u)]},u==null?void 0:u[s])}),r.jsx(or,{fields:l,...X}),r.jsxs(lr,{children:[!!I&&r.jsx(rr.RefreshButton,{onClick:I}),r.jsx(sr,{rowClassName:Q,className:$,scroll:_??(R?{y:`calc(100vh - ${R})`}:void 0),id:"crud-table",dataSource:x,loading:z,bordered:G,size:A,expandable:w,pagination:h?{total:h.count,onChange:h.setPage,current:h.page,pageSize:h.pageSize}:void 0,columns:v||c||q||i||o?[...E,{title:Y("str.action"),dataIndex:"",fixed:"right",width:W,render:(e,t)=>r.jsxs(r.Fragment,{children:[o&&r.jsx(tr,{value:t,onClick:f}),L(t)]})}]:E})]})]})}module.exports=ar;
1
+ "use strict";const r=require("react/jsx-runtime"),A=require("antd"),H=require("../../common/button/CloneButtonTable.cjs.js"),p=require("../../common/button/DeleteButtonTable.cjs.js"),U=require("../../common/button/ExportButton.cjs.js"),F=require("../../common/button/HideButtonTable.cjs.js"),rr=require("../../common/button/RefreshButton.cjs.js"),er=require("../../common/button/UpdateButtonTable.cjs.js"),tr=require("../../common/button/ViewButtonTable.cjs.js"),ur=require("../../common/table/table.cjs.js"),j=require("react"),sr=require("../../locale/index.cjs.js"),nr=require("../CrudSearchComponent.cjs.js"),or=require("./CrudDecListView.cjs.js"),E=require("./CrudViewerUtil.cjs.js"),cr=require("../../common/layout/VerticalSpace.cjs.js");function lr({idField:u="id",loadingData:_,fields:l,isDeleting:m,isHiding:y,viewable:o=!1,paginateProps:h,onDelete:q,onHide:T,onUpdate:v,data:x=[],extraAction:i,onClickUpdate:c,minusHeight:C,scroll:$,onClickClone:B,className:w,expandable:G,size:J,bordered:K,descListColumn:N,extraView:b,decListLayout:Q,scrollToTop:ar,onClickRefresh:V,closeViewOnClickUpdate:d,onExport:g,confirmHiding:I,confirmDeleting:L,rowClassName:W,actionWidth:X=190,...Y}){const{t:Z}=sr.useTranslationLib(),M=j.useMemo(()=>l.map(({hideInTable:e,hidden:t,width:a,name:n,label:P,halign:k,...O})=>({title:P,width:a,key:n,dataIndex:n,hidden:e||t,align:k??(O.type==="number"?"right":void 0),render:E.getRendererValueCrudViewer(O)})),[l]),[s,f]=j.useState(),[S,R]=j.useState();j.useEffect(()=>{x&&f(e=>{if(e)return x.find(t=>t[u]===e[u])})},[x,u,s]);const z=j.useCallback(e=>{var a;const t=i==null?void 0:i(e);return(Array.isArray(t)?(a=t==null?void 0:t.filter(Boolean))!=null&&a.length:t)||v||c||B||q?r.jsxs(r.Fragment,{children:[t,(v||c)&&r.jsx(er,{value:e,onClick:n=>{R(n[u]),c==null||c(e),d&&f(void 0)}}),B&&r.jsx(H,{value:e,onClick:n=>B(n)}),g&&r.jsx(U.ExportButton,{value:e,onClick:async n=>await g(n)}),T&&r.jsx(F,{value:e,disabled:y,shouldConfirm:I,loading:y&&e[u]===S,onClick:async n=>{R(n[u]),await T({[u]:n[u]})}}),q&&r.jsx(p,{value:e,disabled:m,shouldConfirm:L,loading:m&&e[u]===S,onClick:async n=>{R(n[u]),await q({[u]:n[u]})}})]}):void 0},[d,L,I,i,u,m,y,B,c,q,g,T,v,S]),D=j.useMemo(()=>{let e=typeof o=="string"?s==null?void 0:s[o]:void 0;if(typeof e=="object"){const t=l.find(a=>a.name===o);e=E.getRendererValueCrudViewer(t)(e,s,0)}return e},[o,s,l]);return r.jsxs("div",{children:[o&&r.jsx(A.Modal,{width:"100%",open:!!s,title:D??r.jsx("div",{children:" "}),footer:r.jsx(r.Fragment,{}),closable:!0,onCancel:()=>f(void 0),children:!!s&&r.jsxs("div",{children:[r.jsx(or.CrudDecListView,{layout:Q,descListColumn:N,data:s,fields:l,action:z(s)}),b==null?void 0:b(s)]},s==null?void 0:s[u])}),r.jsx(nr,{fields:l,...Y}),r.jsxs(cr,{children:[!!V&&r.jsx(rr.RefreshButton,{onClick:V}),r.jsx(ur,{rowClassName:W,className:w,scroll:$??(C?{y:`calc(100vh - ${C})`}:void 0),id:"crud-table",dataSource:x,loading:_,bordered:K,size:J,expandable:G,pagination:h?{total:h.count,onChange:h.setPage,current:h.page,pageSize:h.pageSize}:void 0,columns:v||c||q||i||o?[...M,{title:Z("str.action"),dataIndex:"",fixed:"right",width:X,render:(e,t)=>r.jsxs(r.Fragment,{children:[o&&r.jsx(tr,{value:t,onClick:f}),z(t)]})}]:M})]})]})}module.exports=lr;
@@ -1,106 +1,105 @@
1
- import { jsxs as v, Fragment as M, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as v, Fragment as z, jsx as n } from "react/jsx-runtime";
2
2
  import { Modal as U } from "antd";
3
3
  import F from "../../common/button/CloneButtonTable.es.js";
4
4
  import rr from "../../common/button/DeleteButtonTable.es.js";
5
5
  import { ExportButton as or } from "../../common/button/ExportButton.es.js";
6
6
  import tr from "../../common/button/HideButtonTable.es.js";
7
- import { RefreshButton as mr } from "../../common/button/RefreshButton.es.js";
8
- import ur from "../../common/button/UpdateButtonTable.es.js";
7
+ import { RefreshButton as ur } from "../../common/button/RefreshButton.es.js";
8
+ import mr from "../../common/button/UpdateButtonTable.es.js";
9
9
  import nr from "../../common/button/ViewButtonTable.es.js";
10
- import fr from "../../common/table/table.es.js";
11
- import { useMemo as $, useState as q, useEffect as cr, useCallback as er } from "react";
12
- import { useTranslation as lr } from "react-i18next";
13
- import { TRANSLATION_NAMESPACE as sr } from "../../locale/hooks/translation-constants.es.js";
14
- import hr from "../CrudSearchComponent.es.js";
15
- import { CrudDecListView as ar } from "./CrudDecListView.es.js";
16
- import { getRendererValueCrudViewer as A } from "./CrudViewerUtil.es.js";
17
- import vr from "../../common/layout/VerticalSpace.es.js";
18
- function _r({
10
+ import cr from "../../common/table/table.es.js";
11
+ import { useMemo as E, useState as G, useEffect as er, useCallback as fr } from "react";
12
+ import { useTranslationLib as lr } from "../../locale/index.es.js";
13
+ import sr from "../CrudSearchComponent.es.js";
14
+ import { CrudDecListView as hr } from "./CrudDecListView.es.js";
15
+ import { getRendererValueCrudViewer as J } from "./CrudViewerUtil.es.js";
16
+ import ar from "../../common/layout/VerticalSpace.es.js";
17
+ function Vr({
19
18
  idField: t = "id",
20
- loadingData: G,
21
- fields: e,
22
- isDeleting: S,
23
- isHiding: b,
24
- viewable: f = !1,
19
+ loadingData: K,
20
+ fields: f,
21
+ isDeleting: p,
22
+ isHiding: i,
23
+ viewable: c = !1,
25
24
  paginateProps: s,
26
25
  onDelete: h,
27
- onHide: i,
28
- onUpdate: T,
29
- data: y = [],
26
+ onHide: S,
27
+ onUpdate: y,
28
+ data: B = [],
30
29
  extraAction: a,
31
- onClickUpdate: c,
32
- minusHeight: N,
33
- scroll: J,
34
- onClickClone: B,
35
- className: K,
36
- expandable: Q,
37
- size: W,
38
- bordered: X,
39
- descListColumn: Y,
30
+ onClickUpdate: e,
31
+ minusHeight: L,
32
+ scroll: N,
33
+ onClickClone: T,
34
+ className: Q,
35
+ expandable: W,
36
+ size: X,
37
+ bordered: Y,
38
+ descListColumn: Z,
40
39
  extraView: g,
41
- decListLayout: Z,
42
- scrollToTop: Tr,
43
- onClickRefresh: O,
44
- closeViewOnClickUpdate: R,
40
+ decListLayout: d,
41
+ scrollToTop: vr,
42
+ onClickRefresh: M,
43
+ closeViewOnClickUpdate: O,
45
44
  onExport: I,
46
- confirmHiding: z,
47
- confirmDeleting: E,
48
- rowClassName: d,
49
- actionWidth: P = 190,
50
- ...w
45
+ confirmHiding: R,
46
+ confirmDeleting: V,
47
+ rowClassName: w,
48
+ actionWidth: D = 190,
49
+ ...P
51
50
  }) {
52
- const { t: D } = lr(sr), L = $(
53
- () => e.map(
54
- ({ hideInTable: r, hidden: o, width: l, name: u, label: H, halign: x, ...V }) => ({
51
+ const { t: k } = lr(), _ = E(
52
+ () => f.map(
53
+ ({ hideInTable: r, hidden: o, width: l, name: m, label: H, halign: x, ...q }) => ({
55
54
  title: H,
56
55
  width: l,
57
- key: u,
58
- dataIndex: u,
56
+ key: m,
57
+ dataIndex: m,
59
58
  hidden: r || o,
60
- align: x ?? (V.type === "number" ? "right" : void 0),
61
- render: A(V)
59
+ align: x ?? (q.type === "number" ? "right" : void 0),
60
+ render: J(q)
62
61
  })
63
62
  ),
64
- [e]
65
- ), [m, p] = q(), [C, j] = q();
66
- cr(() => {
67
- y && p((r) => {
63
+ [f]
64
+ ), [u, b] = G(), [j, C] = G();
65
+ er(() => {
66
+ B && b((r) => {
68
67
  if (r)
69
- return y.find((o) => o[t] === r[t]);
68
+ return B.find((o) => o[t] === r[t]);
70
69
  });
71
- }, [y, t, m]);
72
- const _ = er(
70
+ }, [B, t, u]);
71
+ const $ = fr(
73
72
  (r) => {
74
73
  var l;
75
74
  const o = a == null ? void 0 : a(r);
76
- return (Array.isArray(o) ? (l = o == null ? void 0 : o.filter(Boolean)) != null && l.length : o) || T || c || B || h ? /* @__PURE__ */ v(M, { children: [
75
+ return (Array.isArray(o) ? (l = o == null ? void 0 : o.filter(Boolean)) != null && l.length : o) || y || e || T || h ? /* @__PURE__ */ v(z, { children: [
77
76
  o,
78
- (T || c) && /* @__PURE__ */ n(
79
- ur,
77
+ (y || e) && /* @__PURE__ */ n(
78
+ mr,
80
79
  {
81
80
  value: r,
82
- onClick: (u) => {
83
- j(u[t]), c == null || c(r), R && p(void 0);
81
+ onClick: (m) => {
82
+ C(m[t]), e == null || e(r), O && b(void 0);
84
83
  }
85
84
  }
86
85
  ),
87
- B && /* @__PURE__ */ n(F, { value: r, onClick: (u) => B(u) }),
86
+ T && /* @__PURE__ */ n(F, { value: r, onClick: (m) => T(m) }),
88
87
  I && /* @__PURE__ */ n(
89
88
  or,
90
89
  {
91
90
  value: r,
92
- onClick: async (u) => await I(u)
91
+ onClick: async (m) => await I(m)
93
92
  }
94
93
  ),
95
- i && /* @__PURE__ */ n(
94
+ S && /* @__PURE__ */ n(
96
95
  tr,
97
96
  {
98
97
  value: r,
99
- disabled: b,
100
- shouldConfirm: z,
101
- loading: b && r[t] === C,
102
- onClick: async (u) => {
103
- j(u[t]), await i({ [t]: u[t] });
98
+ disabled: i,
99
+ shouldConfirm: R,
100
+ loading: i && r[t] === j,
101
+ onClick: async (m) => {
102
+ C(m[t]), await S({ [t]: m[t] });
104
103
  }
105
104
  }
106
105
  ),
@@ -108,110 +107,110 @@ function _r({
108
107
  rr,
109
108
  {
110
109
  value: r,
111
- disabled: S,
112
- shouldConfirm: E,
113
- loading: S && r[t] === C,
114
- onClick: async (u) => {
115
- j(u[t]), await h({ [t]: u[t] });
110
+ disabled: p,
111
+ shouldConfirm: V,
112
+ loading: p && r[t] === j,
113
+ onClick: async (m) => {
114
+ C(m[t]), await h({ [t]: m[t] });
116
115
  }
117
116
  }
118
117
  )
119
118
  ] }) : void 0;
120
119
  },
121
120
  [
121
+ O,
122
+ V,
122
123
  R,
123
- E,
124
- z,
125
124
  a,
126
125
  t,
127
- S,
128
- b,
129
- B,
130
- c,
131
- h,
132
- I,
126
+ p,
133
127
  i,
134
128
  T,
135
- C
129
+ e,
130
+ h,
131
+ I,
132
+ S,
133
+ y,
134
+ j
136
135
  ]
137
- ), k = $(() => {
138
- let r = typeof f == "string" ? m == null ? void 0 : m[f] : void 0;
136
+ ), A = E(() => {
137
+ let r = typeof c == "string" ? u == null ? void 0 : u[c] : void 0;
139
138
  if (typeof r == "object") {
140
- const o = e.find((l) => l.name === f);
141
- r = A(o)(
139
+ const o = f.find((l) => l.name === c);
140
+ r = J(o)(
142
141
  r,
143
- m,
142
+ u,
144
143
  0
145
144
  );
146
145
  }
147
146
  return r;
148
- }, [f, m, e]);
147
+ }, [c, u, f]);
149
148
  return /* @__PURE__ */ v("div", { children: [
150
- f && /* @__PURE__ */ n(
149
+ c && /* @__PURE__ */ n(
151
150
  U,
152
151
  {
153
152
  width: "100%",
154
- open: !!m,
155
- title: k ?? /* @__PURE__ */ n("div", { children: " " }),
156
- footer: /* @__PURE__ */ n(M, {}),
153
+ open: !!u,
154
+ title: A ?? /* @__PURE__ */ n("div", { children: " " }),
155
+ footer: /* @__PURE__ */ n(z, {}),
157
156
  closable: !0,
158
- onCancel: () => p(void 0),
159
- children: !!m && /* @__PURE__ */ v("div", { children: [
157
+ onCancel: () => b(void 0),
158
+ children: !!u && /* @__PURE__ */ v("div", { children: [
160
159
  /* @__PURE__ */ n(
161
- ar,
160
+ hr,
162
161
  {
163
- layout: Z,
164
- descListColumn: Y,
165
- data: m,
166
- fields: e,
167
- action: _(m)
162
+ layout: d,
163
+ descListColumn: Z,
164
+ data: u,
165
+ fields: f,
166
+ action: $(u)
168
167
  }
169
168
  ),
170
- g == null ? void 0 : g(m)
171
- ] }, m == null ? void 0 : m[t])
169
+ g == null ? void 0 : g(u)
170
+ ] }, u == null ? void 0 : u[t])
172
171
  }
173
172
  ),
174
- /* @__PURE__ */ n(hr, { fields: e, ...w }),
175
- /* @__PURE__ */ v(vr, { children: [
176
- !!O && /* @__PURE__ */ n(mr, { onClick: O }),
173
+ /* @__PURE__ */ n(sr, { fields: f, ...P }),
174
+ /* @__PURE__ */ v(ar, { children: [
175
+ !!M && /* @__PURE__ */ n(ur, { onClick: M }),
177
176
  /* @__PURE__ */ n(
178
- fr,
177
+ cr,
179
178
  {
180
- rowClassName: d,
181
- className: K,
182
- scroll: J ?? (N ? {
183
- y: `calc(100vh - ${N})`
179
+ rowClassName: w,
180
+ className: Q,
181
+ scroll: N ?? (L ? {
182
+ y: `calc(100vh - ${L})`
184
183
  } : void 0),
185
184
  id: "crud-table",
186
- dataSource: y,
187
- loading: G,
188
- bordered: X,
189
- size: W,
190
- expandable: Q,
185
+ dataSource: B,
186
+ loading: K,
187
+ bordered: Y,
188
+ size: X,
189
+ expandable: W,
191
190
  pagination: s ? {
192
191
  total: s.count,
193
192
  onChange: s.setPage,
194
193
  current: s.page,
195
194
  pageSize: s.pageSize
196
195
  } : void 0,
197
- columns: T || c || h || a || f ? [
198
- ...L,
196
+ columns: y || e || h || a || c ? [
197
+ ..._,
199
198
  {
200
- title: D("str.action"),
199
+ title: k("str.action"),
201
200
  dataIndex: "",
202
201
  fixed: "right",
203
- width: P,
204
- render: (r, o) => /* @__PURE__ */ v(M, { children: [
205
- f && /* @__PURE__ */ n(nr, { value: o, onClick: p }),
206
- _(o)
202
+ width: D,
203
+ render: (r, o) => /* @__PURE__ */ v(z, { children: [
204
+ c && /* @__PURE__ */ n(nr, { value: o, onClick: b }),
205
+ $(o)
207
206
  ] })
208
207
  }
209
- ] : L
208
+ ] : _
210
209
  }
211
210
  )
212
211
  ] })
213
212
  ] });
214
213
  }
215
214
  export {
216
- _r as default
215
+ Vr as default
217
216
  };