@kingteza/crud-component 1.0.46 → 1.0.48

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.
@@ -1,91 +1,101 @@
1
- import { jsx as d, Fragment as m, jsxs as g } from "react/jsx-runtime";
2
- import A, { useMemo as C, createElement as f, useCallback as k } from "react";
3
- import { Form as p, Col as S, Input as h, Row as j } from "antd";
4
- import s from "./CrudField.es.js";
5
- function x({
6
- form: e,
7
- purpose: c = "new",
8
- ...i
1
+ import { jsx as d, Fragment as g, jsxs as b } from "react/jsx-runtime";
2
+ import k, { useMemo as S, createElement as s, useCallback as j } from "react";
3
+ import { Form as A, Col as w, Input as v, Row as H } from "antd";
4
+ import p from "./CrudField.es.js";
5
+ function _({
6
+ form: a,
7
+ purpose: y = "new",
8
+ ...c
9
9
  }) {
10
- return /* @__PURE__ */ d(m, { children: /* @__PURE__ */ d(p, { form: e, layout: "vertical", children: /* @__PURE__ */ d(v, { ...i, purpose: c }) }) });
10
+ return /* @__PURE__ */ d(A, { form: a, layout: "vertical", children: /* @__PURE__ */ d(I, { ...c, purpose: y }) });
11
11
  }
12
- function v({
13
- fields: e,
14
- formBuilder: c,
15
- grid: i,
16
- onDeleteFile: o,
17
- onUploadFile: l,
18
- purpose: u
12
+ function I({
13
+ fields: a,
14
+ formBuilder: y,
15
+ grid: c,
16
+ onDeleteFile: m,
17
+ onUploadFile: u,
18
+ purpose: e
19
19
  }) {
20
- const y = C(
21
- () => e.filter((r) => !r.readonly).map((r) => {
22
- const a = {
23
- onUploading: (t) => {
24
- var n;
25
- r.onUploading && ((n = r.onUploading) == null || n.call(r, t)), l == null || l(t);
26
- },
27
- onDelete: (t) => {
28
- var n;
29
- r.onUploading && ((n = r.onDelete) == null || n.call(r, t)), o == null || o(t);
30
- }
20
+ const h = S(
21
+ () => a.filter((r) => !r.readonly).map((r) => {
22
+ const i = {
23
+ onUploading: r.type === "image" || r.type === "file" ? (n) => {
24
+ var t;
25
+ r.onUploading && ((t = r.onUploading) == null || t.call(r, n)), u == null || u(n);
26
+ } : void 0,
27
+ onDelete: r.type === "image" || r.type === "file" ? (n) => {
28
+ var t;
29
+ r.onUploading && ((t = r.onDelete) == null || t.call(r, n)), m == null || m(n);
30
+ } : void 0
31
31
  };
32
- return /* @__PURE__ */ d(A.Fragment, { children: r.grid && i ? /* @__PURE__ */ d(S, { ...r.grid, children: /* @__PURE__ */ f(
33
- s,
32
+ return /* @__PURE__ */ d(k.Fragment, { children: r.grid && c ? /* @__PURE__ */ d(w, { ...r.grid, children: /* @__PURE__ */ s(
33
+ p,
34
34
  {
35
35
  ...r,
36
- ...a,
36
+ ...i,
37
37
  key: typeof r.name == "string" ? r.name : String(r.name),
38
- updatable: u !== "update" ? !0 : r.updatable
38
+ updatable: e !== "update" ? !0 : r.updatable
39
39
  }
40
- ) }) : /* @__PURE__ */ f(
41
- s,
40
+ ) }) : /* @__PURE__ */ s(
41
+ p,
42
42
  {
43
43
  ...r,
44
- ...a,
44
+ ...i,
45
45
  key: typeof r.name == "string" ? r.name : String(r.name),
46
- updatable: u !== "update" ? !0 : r.updatable
46
+ updatable: e !== "update" ? !0 : r.updatable
47
47
  }
48
48
  ) }, r.name);
49
49
  }),
50
- [e, i, o, l, u]
51
- ), b = k(
52
- (r, a = {}) => {
53
- const t = e.find((n) => n.name === r);
54
- if (t != null && t.hidden) return /* @__PURE__ */ d(m, {});
55
- if (t) {
56
- const n = /* @__PURE__ */ f(
57
- s,
50
+ [a, c, m, u, e]
51
+ ), C = j(
52
+ (r, i = {}) => {
53
+ const n = a.find((t) => t.name === r);
54
+ if (n != null && n.hidden) return /* @__PURE__ */ d(g, {});
55
+ if (n) {
56
+ const t = {
57
+ onUploading: n.type === "image" || n.type === "file" ? (o) => {
58
+ var f;
59
+ n.onUploading && ((f = n.onUploading) == null || f.call(n, o)), u == null || u(o);
60
+ } : void 0,
61
+ onDelete: n.type === "image" || n.type === "file" ? (o) => {
62
+ var f;
63
+ n.onUploading && ((f = n.onDelete) == null || f.call(n, o)), m == null || m(o);
64
+ } : void 0
65
+ }, l = /* @__PURE__ */ s(
66
+ p,
58
67
  {
68
+ ...n,
69
+ ...i,
59
70
  ...t,
60
- ...a,
61
- key: typeof t.name == "string" ? t.name : String(t.name),
62
- updatable: u !== "update" ? !0 : t.updatable
71
+ key: typeof n.name == "string" ? n.name : String(n.name),
72
+ updatable: e !== "update" ? !0 : n.updatable
63
73
  }
64
74
  );
65
- return a.render ? a.render(n) : n;
75
+ return i.render ? i.render(l) : l;
66
76
  }
67
- return /* @__PURE__ */ d(m, {});
77
+ return /* @__PURE__ */ d(g, {});
68
78
  },
69
- [e, u]
79
+ [a, e]
70
80
  );
71
- return /* @__PURE__ */ d(m, { children: c ? /* @__PURE__ */ g(m, { children: [
72
- c(b, {
81
+ return /* @__PURE__ */ d(g, { children: y ? /* @__PURE__ */ b(g, { children: [
82
+ y(C, {
73
83
  isAnyFieldHidden(...r) {
74
- const a = Array.isArray(r) ? r : [r];
75
- return e.filter((n) => a.includes(n.name)).some((n) => n.hidden);
84
+ const i = Array.isArray(r) ? r : [r];
85
+ return a.filter((t) => i.includes(t.name)).some((t) => t.hidden);
76
86
  },
77
87
  isAllFieldsHidden(...r) {
78
- const a = Array.isArray(r) ? r : [r];
79
- return e.filter((n) => a.includes(n.name)).every((n) => n.hidden);
88
+ const i = Array.isArray(r) ? r : [r];
89
+ return a.filter((t) => i.includes(t.name)).every((t) => t.hidden);
80
90
  }
81
91
  }),
82
- /* @__PURE__ */ g(p.Item, { hidden: !0, noStyle: !0, children: [
83
- /* @__PURE__ */ d(h, { name: "id" }),
84
- /* @__PURE__ */ d(h, {})
92
+ /* @__PURE__ */ b(A.Item, { hidden: !0, noStyle: !0, children: [
93
+ /* @__PURE__ */ d(v, { name: "id" }),
94
+ /* @__PURE__ */ d(v, {})
85
95
  ] })
86
- ] }) : i ? /* @__PURE__ */ d(j, { gutter: [8, 8], children: y }) : y });
96
+ ] }) : c ? /* @__PURE__ */ d(H, { gutter: [8, 8], children: h }) : h });
87
97
  }
88
98
  export {
89
- x as CrudForm,
90
- v as CrudFormFields
99
+ _ as CrudForm,
100
+ I as CrudFormFields
91
101
  };
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),g=require("@ant-design/icons"),u=require("antd"),F=require("react"),y=require("../locale/index.cjs.js"),C=require("./CrudForm.cjs.js"),S=require("../common/wizard/WizardViewForm.cjs.js"),q=require("../common/button/Button.cjs.js");function v({fields:c,className:m,onDeleteFile:h,onUploadFile:i,purpose:l,wizard:t=[],updatingValue:f,onSave:x,submitting:j}){const d=F.useMemo(()=>t.map(n=>{let r=!0;const o=c.filter(s=>n.fields.includes(s.name));return o.forEach(s=>r&&(r=s.hidden??!1)),{...n,hidden:r,fieldThatShouldShowing:o}}),[c,t]),a=F.useMemo(()=>d.filter(n=>!n.hidden),[d]);return e.jsx(e.Fragment,{children:e.jsx(S,{onSubmit:(n,r)=>{console.log(r),x(r)},className:m,pages:a.map(({title:n,icon:r,fieldThatShouldShowing:o,hidden:s},b)=>({title:n,icon:r,hidden:s,component:k=>e.jsx(w,{fields:o,onDeleteFile:h,onUploadFile:i,purpose:l,i:b,updatingValue:f,backward:k.backward,forward:k.forward,wizard:a,submitting:j},b)}))})})}function w({fields:c,onDeleteFile:m,onUploadFile:h,purpose:i,wizard:l=[],i:t,forward:f,backward:x,submitting:j,updatingValue:d}){const a=l[t],{t:n}=y.useTranslationLib(),[r]=u.Form.useForm();return F.useEffect(()=>{if(d&&(i==="update"||i==="clone")){const o={};for(const s of c)o[s.name]=d[s.name];r.setFieldsValue(o)}},[c,r,i,d]),e.jsxs(u.Form,{name:String(t),form:r,layout:"vertical",children:[e.jsx(C.CrudFormFields,{fields:c,formBuilder:a.formBuilder,grid:a.grid,onDeleteFile:m,onUploadFile:h,purpose:i}),e.jsx(u.Divider,{}),e.jsxs(u.Row,{gutter:[8,8],children:[t>0&&e.jsx(u.Col,{md:12,children:e.jsx(q,{block:!0,icon:e.jsx(g.LeftOutlined,{}),htmlType:"button",type:"default",size:"large",onClick:()=>x(),children:n("str.back")})}),e.jsx(u.Col,{md:t>0?12:24,children:e.jsx(q,{block:!0,icon:l.length-1===t?e.jsx(g.SaveOutlined,{}):e.jsx(g.RightOutlined,{}),htmlType:"submit",type:"primary",loading:j,size:"large",onClick:()=>{r.validateFields().then(o=>{f(o,l.length-1===t,l.length-1===t)})},children:l.length-1===t?n("str."+(i==="update"?"update":"save")):n("str.next")})})]})]})}module.exports=v;
1
+ "use strict";const e=require("react/jsx-runtime"),g=require("@ant-design/icons"),u=require("antd"),b=require("react"),y=require("../locale/index.cjs.js"),C=require("./CrudForm.cjs.js"),S=require("../common/wizard/WizardViewForm.cjs.js"),q=require("../common/button/Button.cjs.js");function v({fields:c,className:m,onDeleteFile:h,onUploadFile:i,purpose:l,wizard:r=[],updatingValue:f,onSave:x,submitting:j}){const d=b.useMemo(()=>r.map(n=>{let t=!0;const o=c.filter(s=>n.fields.includes(s.name));return o.forEach(s=>t&&(t=s.hidden??!1)),{...n,hidden:t,fieldThatShouldShowing:o}}),[c,r]),a=b.useMemo(()=>d.filter(n=>!n.hidden),[d]);return e.jsx(S,{onSubmit:(n,t)=>{console.log(t),x(t)},className:m,pages:a.map(({title:n,icon:t,fieldThatShouldShowing:o,hidden:s},F)=>({title:n,icon:t,hidden:s,component:k=>e.jsx(w,{fields:o,onDeleteFile:h,onUploadFile:i,purpose:l,i:F,updatingValue:f,backward:k.backward,forward:k.forward,wizard:a,submitting:j},F)}))})}function w({fields:c,onDeleteFile:m,onUploadFile:h,purpose:i,wizard:l=[],i:r,forward:f,backward:x,submitting:j,updatingValue:d}){const a=l[r],{t:n}=y.useTranslationLib(),[t]=u.Form.useForm();return b.useEffect(()=>{if(d&&(i==="update"||i==="clone")){const o={};for(const s of c)o[s.name]=d[s.name];t.setFieldsValue(o)}},[c,t,i,d]),e.jsxs(u.Form,{name:String(r),form:t,layout:"vertical",children:[e.jsx(C.CrudFormFields,{fields:c,formBuilder:a.formBuilder,grid:a.grid,onDeleteFile:m,onUploadFile:h,purpose:i}),e.jsx(u.Divider,{}),e.jsxs(u.Row,{gutter:[8,8],children:[r>0&&e.jsx(u.Col,{md:12,children:e.jsx(q,{block:!0,icon:e.jsx(g.LeftOutlined,{}),htmlType:"button",type:"default",size:"large",onClick:()=>x(),children:n("str.back")})}),e.jsx(u.Col,{md:r>0?12:24,children:e.jsx(q,{block:!0,icon:l.length-1===r?e.jsx(g.SaveOutlined,{}):e.jsx(g.RightOutlined,{}),htmlType:"submit",type:"primary",loading:j,size:"large",onClick:()=>{t.validateFields().then(o=>{f(o,l.length-1===r,l.length-1===r)})},children:l.length-1===r?n("str."+(i==="update"?"update":"save")):n("str.next")})})]})]})}module.exports=v;
@@ -10,5 +10,5 @@ export interface CrudFormWizardProps<T> {
10
10
  updatingValue?: T;
11
11
  submitting?: boolean;
12
12
  }
13
- declare function CrudFormWizard<T>({ fields, className, onDeleteFile, onUploadFile, purpose, wizard, updatingValue, onSave, submitting, }: CrudFormWizardProps<T>): import("react/jsx-runtime").JSX.Element;
13
+ declare function CrudFormWizard<T>({ fields, className, onDeleteFile, onUploadFile, purpose, wizard, updatingValue, onSave, submitting, }: Readonly<CrudFormWizardProps<T>>): import("react/jsx-runtime").JSX.Element;
14
14
  export default CrudFormWizard;
@@ -1,50 +1,50 @@
1
- import { jsx as t, Fragment as v, jsxs as F } from "react/jsx-runtime";
2
- import { LeftOutlined as w, SaveOutlined as x, RightOutlined as T } from "@ant-design/icons";
3
- import { Form as k, Divider as W, Row as j, Col as y } from "antd";
4
- import { useMemo as C, useEffect as z } from "react";
5
- import { useTranslationLib as B } from "../locale/index.es.js";
6
- import { CrudFormFields as O } from "./CrudForm.es.js";
7
- import E from "../common/wizard/WizardViewForm.es.js";
1
+ import { jsx as o, jsxs as F } from "react/jsx-runtime";
2
+ import { LeftOutlined as v, SaveOutlined as w, RightOutlined as x } from "@ant-design/icons";
3
+ import { Form as k, Divider as T, Row as W, Col as y } from "antd";
4
+ import { useMemo as C, useEffect as j } from "react";
5
+ import { useTranslationLib as z } from "../locale/index.es.js";
6
+ import { CrudFormFields as B } from "./CrudForm.es.js";
7
+ import O from "../common/wizard/WizardViewForm.es.js";
8
8
  import S from "../common/button/Button.es.js";
9
- function I({
9
+ function H({
10
10
  fields: d,
11
11
  className: f,
12
12
  onDeleteFile: u,
13
13
  onUploadFile: l,
14
14
  purpose: m,
15
- wizard: r = [],
15
+ wizard: e = [],
16
16
  updatingValue: s,
17
17
  onSave: h,
18
18
  submitting: g
19
19
  }) {
20
- const a = C(() => r.map((o) => {
21
- let e = !0;
20
+ const a = C(() => e.map((r) => {
21
+ let t = !0;
22
22
  const n = d.filter(
23
- (i) => o.fields.includes(i.name)
23
+ (i) => r.fields.includes(i.name)
24
24
  );
25
- return n.forEach((i) => e && (e = i.hidden ?? !1)), {
26
- ...o,
27
- hidden: e,
25
+ return n.forEach((i) => t && (t = i.hidden ?? !1)), {
26
+ ...r,
27
+ hidden: t,
28
28
  fieldThatShouldShowing: n
29
29
  };
30
- }), [d, r]), c = C(
31
- () => a.filter((o) => !o.hidden),
30
+ }), [d, e]), c = C(
31
+ () => a.filter((r) => !r.hidden),
32
32
  [a]
33
33
  );
34
- return /* @__PURE__ */ t(v, { children: /* @__PURE__ */ t(
35
- E,
34
+ return /* @__PURE__ */ o(
35
+ O,
36
36
  {
37
- onSubmit: (o, e) => {
38
- console.log(e), h(e);
37
+ onSubmit: (r, t) => {
38
+ console.log(t), h(t);
39
39
  },
40
40
  className: f,
41
41
  pages: c.map(
42
- ({ title: o, icon: e, fieldThatShouldShowing: n, hidden: i }, b) => ({
43
- title: o,
44
- icon: e,
42
+ ({ title: r, icon: t, fieldThatShouldShowing: n, hidden: i }, b) => ({
43
+ title: r,
44
+ icon: t,
45
45
  hidden: i,
46
- component: (p) => /* @__PURE__ */ t(
47
- L,
46
+ component: (p) => /* @__PURE__ */ o(
47
+ E,
48
48
  {
49
49
  fields: n,
50
50
  onDeleteFile: u,
@@ -62,31 +62,31 @@ function I({
62
62
  })
63
63
  )
64
64
  }
65
- ) });
65
+ );
66
66
  }
67
- function L({
67
+ function E({
68
68
  fields: d,
69
69
  onDeleteFile: f,
70
70
  onUploadFile: u,
71
71
  purpose: l,
72
72
  wizard: m = [],
73
- i: r,
73
+ i: e,
74
74
  forward: s,
75
75
  backward: h,
76
76
  submitting: g,
77
77
  updatingValue: a
78
78
  }) {
79
- const c = m[r], { t: o } = B(), [e] = k.useForm();
80
- return z(() => {
79
+ const c = m[e], { t: r } = z(), [t] = k.useForm();
80
+ return j(() => {
81
81
  if (a && (l === "update" || l === "clone")) {
82
82
  const n = {};
83
83
  for (const i of d)
84
84
  n[i.name] = a[i.name];
85
- e.setFieldsValue(n);
85
+ t.setFieldsValue(n);
86
86
  }
87
- }, [d, e, l, a]), /* @__PURE__ */ F(k, { name: String(r), form: e, layout: "vertical", children: [
88
- /* @__PURE__ */ t(
89
- O,
87
+ }, [d, t, l, a]), /* @__PURE__ */ F(k, { name: String(e), form: t, layout: "vertical", children: [
88
+ /* @__PURE__ */ o(
89
+ B,
90
90
  {
91
91
  fields: d,
92
92
  formBuilder: c.formBuilder,
@@ -96,44 +96,44 @@ function L({
96
96
  purpose: l
97
97
  }
98
98
  ),
99
- /* @__PURE__ */ t(W, {}),
100
- /* @__PURE__ */ F(j, { gutter: [8, 8], children: [
101
- r > 0 && /* @__PURE__ */ t(y, { md: 12, children: /* @__PURE__ */ t(
99
+ /* @__PURE__ */ o(T, {}),
100
+ /* @__PURE__ */ F(W, { gutter: [8, 8], children: [
101
+ e > 0 && /* @__PURE__ */ o(y, { md: 12, children: /* @__PURE__ */ o(
102
102
  S,
103
103
  {
104
104
  block: !0,
105
- icon: /* @__PURE__ */ t(w, {}),
105
+ icon: /* @__PURE__ */ o(v, {}),
106
106
  htmlType: "button",
107
107
  type: "default",
108
108
  size: "large",
109
109
  onClick: () => h(),
110
- children: o("str.back")
110
+ children: r("str.back")
111
111
  }
112
112
  ) }),
113
- /* @__PURE__ */ t(y, { md: r > 0 ? 12 : 24, children: /* @__PURE__ */ t(
113
+ /* @__PURE__ */ o(y, { md: e > 0 ? 12 : 24, children: /* @__PURE__ */ o(
114
114
  S,
115
115
  {
116
116
  block: !0,
117
- icon: m.length - 1 === r ? /* @__PURE__ */ t(x, {}) : /* @__PURE__ */ t(T, {}),
117
+ icon: m.length - 1 === e ? /* @__PURE__ */ o(w, {}) : /* @__PURE__ */ o(x, {}),
118
118
  htmlType: "submit",
119
119
  type: "primary",
120
120
  loading: g,
121
121
  size: "large",
122
122
  onClick: () => {
123
- e.validateFields().then((n) => {
123
+ t.validateFields().then((n) => {
124
124
  s(
125
125
  n,
126
- m.length - 1 === r,
127
- m.length - 1 === r
126
+ m.length - 1 === e,
127
+ m.length - 1 === e
128
128
  );
129
129
  });
130
130
  },
131
- children: m.length - 1 === r ? o("str." + (l === "update" ? "update" : "save")) : o("str.next")
131
+ children: m.length - 1 === e ? r("str." + (l === "update" ? "update" : "save")) : r("str.next")
132
132
  }
133
133
  ) })
134
134
  ] })
135
135
  ] });
136
136
  }
137
137
  export {
138
- I as default
138
+ H as default
139
139
  };
@@ -1,4 +1,4 @@
1
- "use strict";const r=require("react/jsx-runtime"),J=require("@ant-design/icons"),s=require("antd"),i=require("react"),j=require("./CrudField.cjs.js"),K=require("./view/CrudViewer.cjs.js"),M=require("../common/report/SelectFieldInReport.cjs.js"),v=require("./view/CrudViewerUtil.cjs.js"),Q=require("../common/select/SelectComponent.cjs.js"),V=require("../common/button/Button.cjs.js"),W=require("../common/button/PrintButton.cjs.js"),A={lg:6,md:8,sm:12,xs:24},X={lg:12,md:16,sm:24,xs:24};function Y({fields:d,data:u,idField:L,loadingData:p,onSubmit:x,paginateProps:G,size:O,onClickPrint:h,onClickExcelExport:y,minusHeight:U,extraSearchFields:R,searchOnMount:B,summary:_}){const{searchable:$,selectable:c,sortable:F,defaultSort:m}=i.useMemo(()=>{var b,f,N,T,I;const e=[],t=[],o=[];let a;for(const l of d.filter(H=>!H.hidden))l.type==="image"||!l.report||((b=l.report)!=null&&b.searchable&&e.push(l),(f=l.report)!=null&&f.sortable&&(t.push(l),!a&&((N=l.report)!=null&&N.defaultSort)&&(a=l)),l.hideInTable||o.push({id:l.name,label:l.label,lock:(T=l.report)==null?void 0:T.lock,alreadySelected:(I=l.report)==null?void 0:I.alreadySelected}));return{defaultSort:a,searchable:e,sortable:t,selectable:o}},[d]),[S,w]=i.useState([]),g=i.useCallback(async({sortBy:e,sortByType:t,showFields:o=[],...a})=>{const b=[];e&&b.push({field:e,sort:t??"DESC"}),w(d.filter(f=>o.includes(f.name)).map(f=>({...f,hideInTable:!1}))),x({showFields:o,sortBy:b,...a})},[d,x]),[n]=s.Form.useForm(),[q,z]=i.useState(!1),[C,D]=i.useState(!0);return i.useEffect(()=>{if(B&&C){const e=setTimeout(()=>{n.validateFields().then(t=>{g(t)}),D(!1)},200);return()=>clearTimeout(e)}},[g,n,C,B]),i.useEffect(()=>{var t,o,a;!n.getFieldValue("sortBy")&&m&&(console.log((t=m.report)==null?void 0:t.defaultSort),n.setFieldsValue({sortBy:m.name,sortByType:typeof((o=m.report)==null?void 0:o.defaultSort)=="string"?(a=m.report)==null?void 0:a.defaultSort:"ASC"}))},[m,n]),i.useEffect(()=>{if(q){const e=c.filter(t=>t.alreadySelected).map(t=>t.id);w(d.filter(t=>e.includes(t.name)).map(t=>({...t,hideInTable:!1}))),z(!1)}},[d,q,c]),r.jsx(r.Fragment,{children:r.jsxs(s.Space,{className:"w-100",direction:"vertical",children:[r.jsxs(s.Form,{form:n,layout:"vertical",onFinish:g,children:[r.jsxs(s.Row,{gutter:[8,8],children:[$.map(e=>{var t,o,a;return r.jsx(s.Col,{...e.grid??A,style:{alignSelf:"end"},children:(t=e.report)!=null&&t.customRender?e.report.customRender(n):e.type==="date"?r.jsx(j.default,{...e,type:"date",range:(o=e.report)==null?void 0:o.range,required:!!((a=e.report)!=null&&a.required),readonly:!1,fieldClassName:"mb-0"}):e.type==="select"?r.jsx(j.default,{...e,type:"select",multiple:!0,required:!1,readonly:!1,fieldClassName:"mb-0"}):r.jsx(j.default,{...e,readonly:!1,required:!1,fieldClassName:"mb-0"})},e.name)}),!!(c!=null&&c.length)&&r.jsx(s.Col,{...X,children:r.jsx(M.SelectFieldInReport,{items:c,name:"showFields",mode:"multiple",label:"Show Fields",className:"mb-0"})}),!!F.length&&r.jsx(s.Col,{...A,children:r.jsx(Q,{label:"Sort By",name:"sortBy",items:F.map(e=>({id:e.name,label:e.label})),nameFieldInArray:"label",fieldId:"id",className:"mb-0",dropdownRender:e=>r.jsxs(r.Fragment,{children:[e,r.jsx(s.Form.Item,{name:"sortByType",noStyle:!0,className:"mt-3",children:r.jsx(s.Radio.Group,{className:"w-100",defaultValue:"DESC",optionType:"button",children:r.jsxs(s.Row,{children:[r.jsx(s.Col,{xs:12,children:r.jsx(s.Radio,{className:"w-100",style:{borderTopRightRadius:0,borderBottomRightRadius:0},value:"ASC",children:"Ascending"})}),r.jsx(s.Col,{xs:12,children:r.jsx(s.Radio,{className:"w-100",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0},value:"DESC",children:"Descending"})})]})})})]})})}),R?R(n):null]}),r.jsx(V,{className:"mt-3",type:"primary",block:!0,htmlType:"submit",disabled:p,children:"Submit"})]}),r.jsxs(s.Space,{children:[!!h&&r.jsx(W.PrintButton,{disabled:p||!u.length,onClick:()=>h==null?void 0:h({tableId:"#crud-table table",data:u,fields:S.map(e=>({...e,render:v.getRendererValueCrudViewer(e)}))})}),!!y&&r.jsx(V,{disabled:p||!u.length,onClick:()=>y==null?void 0:y({tableId:"#crud-table table",data:u,fields:S.map(e=>({...e,render:v.getRendererValueCrudViewer(e)}))}),icon:r.jsx(J.FileExcelOutlined,{}),className:`group
1
+ "use strict";const r=require("react/jsx-runtime"),J=require("@ant-design/icons"),s=require("antd"),i=require("react"),j=require("./CrudField.cjs.js"),K=require("./view/CrudViewer.cjs.js"),M=require("../common/report/SelectFieldInReport.cjs.js"),v=require("./view/CrudViewerUtil.cjs.js"),Q=require("../common/select/SelectComponent.cjs.js"),V=require("../common/button/Button.cjs.js"),W=require("../common/button/PrintButton.cjs.js"),A={lg:6,md:8,sm:12,xs:24},X={lg:12,md:16,sm:24,xs:24};function Y({fields:d,data:u,idField:L,loadingData:p,onSubmit:x,paginateProps:G,size:O,onClickPrint:h,onClickExcelExport:y,minusHeight:U,extraSearchFields:R,searchOnMount:B,summary:_}){const{searchable:$,selectable:c,sortable:w,defaultSort:m}=i.useMemo(()=>{var b,f,N,T,I;const e=[],t=[],o=[];let a;for(const l of d.filter(H=>!H.hidden))l.type==="image"||!l.report||((b=l.report)!=null&&b.searchable&&e.push(l),(f=l.report)!=null&&f.sortable&&(t.push(l),!a&&((N=l.report)!=null&&N.defaultSort)&&(a=l)),l.hideInTable||o.push({id:l.name,label:l.label,lock:(T=l.report)==null?void 0:T.lock,alreadySelected:(I=l.report)==null?void 0:I.alreadySelected}));return{defaultSort:a,searchable:e,sortable:t,selectable:o}},[d]),[S,F]=i.useState([]),g=i.useCallback(async({sortBy:e,sortByType:t,showFields:o=[],...a})=>{const b=[];e&&b.push({field:e,sort:t??"DESC"}),F(d.filter(f=>o.includes(f.name)).map(f=>({...f,hideInTable:!1}))),x({showFields:o,sortBy:b,...a})},[d,x]),[n]=s.Form.useForm(),[q,z]=i.useState(!1),[C,D]=i.useState(!0);return i.useEffect(()=>{if(B&&C){const e=setTimeout(()=>{n.validateFields().then(t=>{g(t)}),D(!1)},200);return()=>clearTimeout(e)}},[g,n,C,B]),i.useEffect(()=>{var t,o,a;!n.getFieldValue("sortBy")&&m&&(console.log((t=m.report)==null?void 0:t.defaultSort),n.setFieldsValue({sortBy:m.name,sortByType:typeof((o=m.report)==null?void 0:o.defaultSort)=="string"?(a=m.report)==null?void 0:a.defaultSort:"ASC"}))},[m,n]),i.useEffect(()=>{if(q){const e=c.filter(t=>t.alreadySelected).map(t=>t.id);F(d.filter(t=>e.includes(t.name)).map(t=>({...t,hideInTable:!1}))),z(!1)}},[d,q,c]),r.jsxs(s.Space,{className:"w-100",direction:"vertical",children:[r.jsxs(s.Form,{form:n,layout:"vertical",onFinish:g,children:[r.jsxs(s.Row,{gutter:[8,8],children:[$.map(e=>{var t,o,a;return r.jsx(s.Col,{...e.grid??A,style:{alignSelf:"end"},children:(t=e.report)!=null&&t.customRender?e.report.customRender(n):e.type==="date"?r.jsx(j.default,{...e,type:"date",range:(o=e.report)==null?void 0:o.range,required:!!((a=e.report)!=null&&a.required),readonly:!1,fieldClassName:"mb-0"}):e.type==="select"?r.jsx(j.default,{...e,type:"select",multiple:!0,required:!1,readonly:!1,fieldClassName:"mb-0"}):r.jsx(j.default,{...e,readonly:!1,required:!1,fieldClassName:"mb-0"})},e.name)}),!!(c!=null&&c.length)&&r.jsx(s.Col,{...X,children:r.jsx(M.SelectFieldInReport,{items:c,name:"showFields",mode:"multiple",label:"Show Fields",className:"mb-0"})}),!!w.length&&r.jsx(s.Col,{...A,children:r.jsx(Q,{label:"Sort By",name:"sortBy",items:w.map(e=>({id:e.name,label:e.label})),nameFieldInArray:"label",fieldId:"id",className:"mb-0",dropdownRender:e=>r.jsxs(r.Fragment,{children:[e,r.jsx(s.Form.Item,{name:"sortByType",noStyle:!0,className:"mt-3",children:r.jsx(s.Radio.Group,{className:"w-100",defaultValue:"DESC",optionType:"button",children:r.jsxs(s.Row,{children:[r.jsx(s.Col,{xs:12,children:r.jsx(s.Radio,{className:"w-100",style:{borderTopRightRadius:0,borderBottomRightRadius:0},value:"ASC",children:"Ascending"})}),r.jsx(s.Col,{xs:12,children:r.jsx(s.Radio,{className:"w-100",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0},value:"DESC",children:"Descending"})})]})})})]})})}),R?R(n):null]}),r.jsx(V,{className:"mt-3",type:"primary",block:!0,htmlType:"submit",disabled:p,children:"Submit"})]}),r.jsxs(s.Space,{children:[!!h&&r.jsx(W.PrintButton,{disabled:p||!u.length,onClick:()=>h==null?void 0:h({tableId:"#crud-table table",data:u,fields:S.map(e=>({...e,render:v.getRendererValueCrudViewer(e)}))})}),!!y&&r.jsx(V,{disabled:p||!u.length,onClick:()=>y==null?void 0:y({tableId:"#crud-table table",data:u,fields:S.map(e=>({...e,render:v.getRendererValueCrudViewer(e)}))}),icon:r.jsx(J.FileExcelOutlined,{}),className:`group
2
2
  ${p||!u.length?"":"!bg-green-700 hover:!bg-green-600 !text-white !border-green-700 hover:!border-green-600"}
3
3
 
4
- `,children:"Excel"})]}),_,r.jsx(K,{minusHeight:U,data:u,size:O,fields:S,idField:L,loadingData:p,paginateProps:G,viewable:!1})]})})}module.exports=Y;
4
+ `,children:"Excel"})]}),_,r.jsx(K,{minusHeight:U,data:u,size:O,fields:S,idField:L,loadingData:p,paginateProps:G,viewable:!1})]})}module.exports=Y;
@@ -40,5 +40,5 @@ export interface CrudReportComponentProps<T_Data, F_Search> {
40
40
  extraSearchFields?: (form: FormInstance<any>) => ReactElement;
41
41
  searchOnMount?: boolean;
42
42
  }
43
- declare function CrudReportComponent<T, F = T>({ fields, data, idField, loadingData, onSubmit, paginateProps, size, onClickPrint, onClickExcelExport, minusHeight, extraSearchFields, searchOnMount, summary, }: CrudReportComponentProps<T, F>): import("react/jsx-runtime").JSX.Element;
43
+ declare function CrudReportComponent<T, F = T>({ fields, data, idField, loadingData, onSubmit, paginateProps, size, onClickPrint, onClickExcelExport, minusHeight, extraSearchFields, searchOnMount, summary, }: Readonly<CrudReportComponentProps<T, F>>): import("react/jsx-runtime").JSX.Element;
44
44
  export default CrudReportComponent;
@@ -1,35 +1,35 @@
1
- import { jsx as t, Fragment as O, jsxs as c } from "react/jsx-runtime";
1
+ import { jsxs as c, jsx as t, Fragment as Z } from "react/jsx-runtime";
2
2
  import { FileExcelOutlined as x } from "@ant-design/icons";
3
- import { Form as B, Space as _, Row as $, Col as b, Radio as R } from "antd";
3
+ import { Form as B, Space as O, Row as _, Col as b, Radio as R } from "antd";
4
4
  import { useMemo as k, useState as w, useCallback as E, useEffect as F } from "react";
5
5
  import N from "./CrudField.es.js";
6
6
  import P from "./view/CrudViewer.es.js";
7
7
  import { SelectFieldInReport as ee } from "../common/report/SelectFieldInReport.es.js";
8
- import { getRendererValueCrudViewer as z } from "./view/CrudViewerUtil.es.js";
8
+ import { getRendererValueCrudViewer as $ } from "./view/CrudViewerUtil.es.js";
9
9
  import re from "../common/select/SelectComponent.es.js";
10
- import D from "../common/button/Button.es.js";
10
+ import z from "../common/button/Button.es.js";
11
11
  import { PrintButton as te } from "../common/button/PrintButton.es.js";
12
- const H = { lg: 6, md: 8, sm: 12, xs: 24 }, le = { lg: 12, md: 16, sm: 24, xs: 24 };
12
+ const D = { lg: 6, md: 8, sm: 12, xs: 24 }, le = { lg: 12, md: 16, sm: 24, xs: 24 };
13
13
  function be({
14
14
  fields: n,
15
15
  data: d,
16
- idField: J,
16
+ idField: H,
17
17
  loadingData: p,
18
18
  onSubmit: T,
19
- paginateProps: K,
20
- size: M,
19
+ paginateProps: J,
20
+ size: K,
21
21
  onClickPrint: h,
22
22
  onClickExcelExport: y,
23
- minusHeight: Q,
23
+ minusHeight: M,
24
24
  extraSearchFields: v,
25
25
  searchOnMount: C,
26
- summary: U
26
+ summary: Q
27
27
  }) {
28
- const { searchable: W, selectable: i, sortable: I, defaultSort: m } = k(() => {
28
+ const { searchable: U, selectable: i, sortable: I, defaultSort: m } = k(() => {
29
29
  var f, u, j, L, G;
30
30
  const e = [], r = [], o = [];
31
31
  let s;
32
- for (const l of n.filter((Z) => !Z.hidden))
32
+ for (const l of n.filter((Y) => !Y.hidden))
33
33
  l.type === "image" || !l.report || ((f = l.report) != null && f.searchable && e.push(l), (u = l.report) != null && u.sortable && (r.push(l), !s && ((j = l.report) != null && j.defaultSort) && (s = l)), l.hideInTable || o.push({
34
34
  id: l.name,
35
35
  label: l.label,
@@ -60,13 +60,13 @@ function be({
60
60
  ), T({ showFields: o, sortBy: f, ...s });
61
61
  },
62
62
  [n, T]
63
- ), [a] = B.useForm(), [q, X] = w(!1), [A, Y] = w(!0);
63
+ ), [a] = B.useForm(), [q, W] = w(!1), [A, X] = w(!0);
64
64
  return F(() => {
65
65
  if (C && A) {
66
66
  const e = setTimeout(() => {
67
67
  a.validateFields().then((r) => {
68
68
  S(r);
69
- }), Y(!1);
69
+ }), X(!1);
70
70
  }, 200);
71
71
  return () => clearTimeout(e);
72
72
  }
@@ -81,17 +81,17 @@ function be({
81
81
  const e = i.filter((r) => r.alreadySelected).map((r) => r.id);
82
82
  V(
83
83
  n.filter((r) => e.includes(r.name)).map((r) => ({ ...r, hideInTable: !1 }))
84
- ), X(!1);
84
+ ), W(!1);
85
85
  }
86
- }, [n, q, i]), /* @__PURE__ */ t(O, { children: /* @__PURE__ */ c(_, { className: "w-100", direction: "vertical", children: [
86
+ }, [n, q, i]), /* @__PURE__ */ c(O, { className: "w-100", direction: "vertical", children: [
87
87
  /* @__PURE__ */ c(B, { form: a, layout: "vertical", onFinish: S, children: [
88
- /* @__PURE__ */ c($, { gutter: [8, 8], children: [
89
- W.map((e) => {
88
+ /* @__PURE__ */ c(_, { gutter: [8, 8], children: [
89
+ U.map((e) => {
90
90
  var r, o, s;
91
91
  return /* @__PURE__ */ t(
92
92
  b,
93
93
  {
94
- ...e.grid ?? H,
94
+ ...e.grid ?? D,
95
95
  style: { alignSelf: "end" },
96
96
  children: (r = e.report) != null && r.customRender ? e.report.customRender(a) : e.type === "date" ? /* @__PURE__ */ t(
97
97
  N,
@@ -136,7 +136,7 @@ function be({
136
136
  className: "mb-0"
137
137
  }
138
138
  ) }),
139
- !!I.length && /* @__PURE__ */ t(b, { ...H, children: /* @__PURE__ */ t(
139
+ !!I.length && /* @__PURE__ */ t(b, { ...D, children: /* @__PURE__ */ t(
140
140
  re,
141
141
  {
142
142
  label: "Sort By",
@@ -145,7 +145,7 @@ function be({
145
145
  nameFieldInArray: "label",
146
146
  fieldId: "id",
147
147
  className: "mb-0",
148
- dropdownRender: (e) => /* @__PURE__ */ c(O, { children: [
148
+ dropdownRender: (e) => /* @__PURE__ */ c(Z, { children: [
149
149
  e,
150
150
  /* @__PURE__ */ t(B.Item, { name: "sortByType", noStyle: !0, className: "mt-3", children: /* @__PURE__ */ t(
151
151
  R.Group,
@@ -153,7 +153,7 @@ function be({
153
153
  className: "w-100",
154
154
  defaultValue: "DESC",
155
155
  optionType: "button",
156
- children: /* @__PURE__ */ c($, { children: [
156
+ children: /* @__PURE__ */ c(_, { children: [
157
157
  /* @__PURE__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
158
158
  R,
159
159
  {
@@ -187,7 +187,7 @@ function be({
187
187
  v ? v(a) : null
188
188
  ] }),
189
189
  /* @__PURE__ */ t(
190
- D,
190
+ z,
191
191
  {
192
192
  className: "mt-3",
193
193
  type: "primary",
@@ -198,7 +198,7 @@ function be({
198
198
  }
199
199
  )
200
200
  ] }),
201
- /* @__PURE__ */ c(_, { children: [
201
+ /* @__PURE__ */ c(O, { children: [
202
202
  !!h && /* @__PURE__ */ t(
203
203
  te,
204
204
  {
@@ -208,13 +208,13 @@ function be({
208
208
  data: d,
209
209
  fields: g.map((e) => ({
210
210
  ...e,
211
- render: z(e)
211
+ render: $(e)
212
212
  }))
213
213
  })
214
214
  }
215
215
  ),
216
216
  !!y && /* @__PURE__ */ t(
217
- D,
217
+ z,
218
218
  {
219
219
  disabled: p || !d.length,
220
220
  onClick: () => y == null ? void 0 : y({
@@ -222,7 +222,7 @@ function be({
222
222
  data: d,
223
223
  fields: g.map((e) => ({
224
224
  ...e,
225
- render: z(e)
225
+ render: $(e)
226
226
  }))
227
227
  }),
228
228
  icon: /* @__PURE__ */ t(x, {}),
@@ -234,21 +234,21 @@ function be({
234
234
  }
235
235
  )
236
236
  ] }),
237
- U,
237
+ Q,
238
238
  /* @__PURE__ */ t(
239
239
  P,
240
240
  {
241
- minusHeight: Q,
241
+ minusHeight: M,
242
242
  data: d,
243
- size: M,
243
+ size: K,
244
244
  fields: g,
245
- idField: J,
245
+ idField: H,
246
246
  loadingData: p,
247
- paginateProps: K,
247
+ paginateProps: J,
248
248
  viewable: !1
249
249
  }
250
250
  )
251
- ] }) });
251
+ ] });
252
252
  }
253
253
  export {
254
254
  be as default
@@ -18,4 +18,4 @@ export interface CrudSearchComponentProps<T, FormType> {
18
18
  onSearch?: (values: Partial<FormType>) => void;
19
19
  searchFieldsCustomColumnProps?: ColProps[];
20
20
  }
21
- export default function CrudSearchComponent<T, FormType>({ searchFields, fields, searchOnChange, onSearch, searchDefaultValues, searchFieldsCustomColumnProps, }: CrudSearchComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
21
+ export default function CrudSearchComponent<T, FormType>({ searchFields, fields, searchOnChange, onSearch, searchDefaultValues, searchFieldsCustomColumnProps, }: Readonly<CrudSearchComponentProps<T, FormType>>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";const u=require("react/jsx-runtime"),h=require("../common/text-field/TextArea.cjs.js"),j=require("../common/rich/index.cjs.js"),q=require("antd"),C=({onChange:t,label:r,required:s,rules:o,name:i,updatable:n=!0,...c})=>{const x=q.Form.useFormInstance();if(c.rich)return u.jsx(j.RichTextEditor,{name:i,label:r,required:s,rules:o,disabled:!n});{const{placeholder:a,rows:l,cols:m,fieldClassName:f,fieldTooltip:T}=c;return u.jsx(h.default,{rules:o,placeholder:a,onChange:t?e=>{var d;return t((d=e==null?void 0:e.target)==null?void 0:d.value,x)}:void 0,tooltip:T,required:s,disabled:!n,name:i,label:r,className:f,rows:l,cols:m})}};module.exports=C;
@@ -0,0 +1,22 @@
1
+ import { InitialCrudField } from './CrudComponent';
2
+ import { FormInstance } from 'antd/lib';
3
+ interface InitialTextAreaProps<T> extends InitialCrudField<T> {
4
+ type: "textarea";
5
+ onChange?: (value: string, form: FormInstance<T>) => void;
6
+ /**
7
+ * number of lines to show. If false will not show truncated
8
+ * @default 2
9
+ */
10
+ truncated?: boolean | number;
11
+ }
12
+ interface TextAreaProps<T> extends InitialTextAreaProps<T> {
13
+ placeholder?: string;
14
+ rows?: number;
15
+ cols?: number;
16
+ }
17
+ interface RichTextAreaProps<T> extends InitialTextAreaProps<T> {
18
+ rich?: true;
19
+ }
20
+ export type TextAreaBasedFieldProps<T> = TextAreaProps<T> & RichTextAreaProps<T>;
21
+ declare const CrudTextAreaComponent: <T>({ onChange, label, required, rules, name, updatable, ...props }: TextAreaBasedFieldProps<T>) => import("react/jsx-runtime").JSX.Element;
22
+ export default CrudTextAreaComponent;