@kingteza/crud-component 1.2.5 → 1.2.7
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.
- package/dist/common/date-picker/TimePicker.cjs.js +1 -1
- package/dist/common/date-picker/TimePicker.es.js +35 -37
- package/dist/common/picker/ImagePicker.cjs.js +1 -1
- package/dist/common/picker/ImagePicker.es.js +35 -37
- package/dist/crud/CrudFormWizard.cjs.js +1 -1
- package/dist/crud/CrudFormWizard.es.js +34 -34
- package/dist/crud/CrudReportComponent.cjs.js +3 -3
- package/dist/crud/CrudReportComponent.es.js +41 -41
- package/dist/crud/FileCrudField.cjs.js +1 -1
- package/dist/crud/FileCrudField.es.js +81 -86
- package/dist/crud/ImageCrudField.cjs.js +1 -1
- package/dist/crud/ImageCrudField.es.js +25 -26
- package/dist/crud/actions/index.cjs.js +1 -1
- package/dist/crud/actions/index.es.js +30 -35
- package/dist/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/dist/crud/view/CrudViewerUtil.es.js +38 -38
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const a=require("react/jsx-runtime"),n=require("antd"),E=require("dayjs"),f=require("react"),H=require("../../locale/index.cjs.js"),I=({type:L,required:l,label:i,rules:q=[],placeholder:s,disabledPast:r=!1,disableCurrent:m=!1,onEnter:M,disabled:x,use12Hours:k,nextFocus:N,onChange:o,range:c,disabledFuture:u,defaultValue:T,value:j,format:p,autoComplete:S="off",renderExtraFooter:d,...y})=>{const{t:P}=H.useTranslationLib(),R=f.useMemo(()=>s||(c?["From","To"]:"Select time"),[s,c]),F=c?n.TimePicker.RangePicker:n.TimePicker,$=f.useCallback(e=>{if(!e)return!1;const t=E(),v=r&&e<t,w=u&&e>t,D=m&&e<t&&t<e;return v||w||D},[m,u,r]);return a.jsx(n.Form.Item,{...y,label:i,rules:[{required:l,message:`${i??s??""} ${P("err.validation.required")}`},...q],children:a.jsx(F,{use12Hours:k,renderExtraFooter:d,value:j,defaultValue:T,format:p,onChange:e=>o==null?void 0:o(e),disabledDate:$,disabled:x,className:"w-100",placeholder:R})})};module.exports=I;
|
|
@@ -1,72 +1,70 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { TimePicker as
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { TimePicker as a, Form as E } from "antd";
|
|
3
3
|
import H from "dayjs";
|
|
4
4
|
import { useMemo as I, useCallback as L } from "react";
|
|
5
5
|
import { useTranslationLib as M } from "../../locale/index.es.js";
|
|
6
6
|
const K = ({
|
|
7
7
|
type: N,
|
|
8
8
|
required: p,
|
|
9
|
-
label:
|
|
10
|
-
rules:
|
|
9
|
+
label: i,
|
|
10
|
+
rules: l = [],
|
|
11
11
|
placeholder: t,
|
|
12
|
-
disabledPast:
|
|
13
|
-
disableCurrent:
|
|
12
|
+
disabledPast: r = !1,
|
|
13
|
+
disableCurrent: c = !1,
|
|
14
14
|
onEnter: R,
|
|
15
|
-
disabled:
|
|
16
|
-
use12Hours:
|
|
15
|
+
disabled: k,
|
|
16
|
+
use12Hours: u,
|
|
17
17
|
nextFocus: S,
|
|
18
|
-
onChange:
|
|
19
|
-
range:
|
|
18
|
+
onChange: m,
|
|
19
|
+
range: s,
|
|
20
20
|
disabledFuture: n,
|
|
21
|
-
defaultValue:
|
|
22
|
-
value:
|
|
23
|
-
format:
|
|
21
|
+
defaultValue: T,
|
|
22
|
+
value: x,
|
|
23
|
+
format: y,
|
|
24
24
|
autoComplete: z = "off",
|
|
25
|
-
renderExtraFooter:
|
|
26
|
-
...
|
|
25
|
+
renderExtraFooter: d,
|
|
26
|
+
...j
|
|
27
27
|
}) => {
|
|
28
|
-
const { t:
|
|
29
|
-
() => t || (
|
|
30
|
-
[t,
|
|
31
|
-
)
|
|
32
|
-
console.log(f);
|
|
33
|
-
const $ = m ? l.RangePicker : l, q = L(
|
|
28
|
+
const { t: F } = M(), P = I(
|
|
29
|
+
() => t || (s ? ["From", "To"] : "Select time"),
|
|
30
|
+
[t, s]
|
|
31
|
+
), $ = s ? a.RangePicker : a, q = L(
|
|
34
32
|
(o) => {
|
|
35
33
|
if (!o)
|
|
36
34
|
return !1;
|
|
37
|
-
const e = H(), v =
|
|
35
|
+
const e = H(), v = r && o < e, w = n && o > e, D = c && o < e && e < o;
|
|
38
36
|
return v || w || D;
|
|
39
37
|
},
|
|
40
|
-
[
|
|
38
|
+
[c, n, r]
|
|
41
39
|
// Dependencies for useCallback
|
|
42
40
|
);
|
|
43
|
-
return /* @__PURE__ */
|
|
41
|
+
return /* @__PURE__ */ f(
|
|
44
42
|
E.Item,
|
|
45
43
|
{
|
|
46
|
-
...
|
|
47
|
-
label:
|
|
44
|
+
...j,
|
|
45
|
+
label: i,
|
|
48
46
|
rules: [
|
|
49
47
|
{
|
|
50
48
|
required: p,
|
|
51
|
-
message: `${
|
|
49
|
+
message: `${i ?? t ?? ""} ${F(
|
|
52
50
|
"err.validation.required"
|
|
53
51
|
)}`
|
|
54
52
|
},
|
|
55
|
-
...
|
|
53
|
+
...l
|
|
56
54
|
],
|
|
57
|
-
children: /* @__PURE__ */
|
|
55
|
+
children: /* @__PURE__ */ f(
|
|
58
56
|
$,
|
|
59
57
|
{
|
|
60
|
-
use12Hours:
|
|
61
|
-
renderExtraFooter:
|
|
62
|
-
value:
|
|
63
|
-
defaultValue:
|
|
64
|
-
format:
|
|
65
|
-
onChange: (o) =>
|
|
58
|
+
use12Hours: u,
|
|
59
|
+
renderExtraFooter: d,
|
|
60
|
+
value: x,
|
|
61
|
+
defaultValue: T,
|
|
62
|
+
format: y,
|
|
63
|
+
onChange: (o) => m == null ? void 0 : m(o),
|
|
66
64
|
disabledDate: q,
|
|
67
|
-
disabled:
|
|
65
|
+
disabled: k,
|
|
68
66
|
className: "w-100",
|
|
69
|
-
placeholder:
|
|
67
|
+
placeholder: P
|
|
70
68
|
}
|
|
71
69
|
)
|
|
72
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),je=require("react-advanced-cropper");;/* empty css */;/* empty css */const O=require("@ant-design/icons"),U=require("antd"),s=require("react"),he=require("../../locale/index.cjs.js"),I=require("../button/Button.cjs.js"),we=require("../../util/ImageUtil.cjs.js"),Ce=require("../../icons/FlipHIcon.cjs.js"),be=require("../../icons/FlipVIcon.cjs.js"),ve=U.Form.Item,Y="crud-component.image-picker.button-state";function Z(
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),je=require("react-advanced-cropper");;/* empty css */;/* empty css */const O=require("@ant-design/icons"),U=require("antd"),s=require("react"),he=require("../../locale/index.cjs.js"),I=require("../button/Button.cjs.js"),we=require("../../util/ImageUtil.cjs.js"),Ce=require("../../icons/FlipHIcon.cjs.js"),be=require("../../icons/FlipVIcon.cjs.js"),ve=U.Form.Item,Y="crud-component.image-picker.button-state";function Z(n){return new Promise((u,p)=>{const o=new FileReader;o.readAsDataURL(n),o.onload=()=>u(o.result),o.onerror=m=>p(m)})}const Se=({values:n=[],required:u,buttonType:p,label:o,name:m,onChange:f,aspectRatio:h,buttonTitle:w,hidePreview:C,buttonSize:g="large",showButtonText:x=!0,showOnlyIcon:E=!1,icon:k=t.jsx(O.UploadOutlined,{}),loading:F,maxCount:b=1,onAdd:a,onRemove:R,listType:q,..._})=>{const[te,re]=s.useState(""),[se,ne]=s.useState(""),[oe,A]=s.useState(!1),T=s.useRef(),l=s.useRef(null),[i,z]=s.useState([]),[j,P]=s.useState(),ie=s.useRef(),ae=()=>A(!1),ce=async e=>{!e.url&&!e.preview&&(e.preview=await Z(e.originFileObj)),ne(e.url||e.preview),A(!0),re(e.name)},[B,N]=s.useState(!1),D=e=>{var r;(r=l.current)==null||r.rotateImage(e?-90:90)},H=s.useCallback(e=>{var r;l.current&&((r=l.current)==null||r.flipImage(e==="h",e==="v"))},[]);s.useEffect(()=>{f==null||f(i[0],i)},[i,f]);const le=async()=>{var y;const e=(y=l.current)==null?void 0:y.getCanvas(),{type:r,size:c,name:v,uid:S}=T.current;N(!0),e==null||e.toBlob(async ge=>{const xe=Object.assign(new File([ge],v,{type:r}),{uid:S}),K=await we.resizeImage(xe),Q=await Z(K),X={url:Q,name:v,uid:S,type:r,size:c,thumbUrl:Q,originFileObj:K};if(a)try{N(!0),await a(X)}finally{N(!1)}z([X,...i]),N(!1)}),P(void 0)},ue=()=>{P(void 0),T.current=void 0},L=s.useCallback(e=>{const r=e;if(r){T.current=r;const c=new FileReader;c.addEventListener("load",()=>{var v;if(typeof c.result=="string"){P(c.result);const S=localStorage.getItem(Y),y=S?JSON.parse(S):void 0;y&&((v=l.current)==null||v.setState(y)),setTimeout(()=>{G(l.current)},100)}}),c.readAsDataURL(r)}},[]);s.useEffect(()=>{if(n!=null&&n.length||typeof n=="string"){const e=Array.isArray(n)?n.map(r=>[{uid:n,url:r}]):[{uid:n,url:n}];z(e)}},[n]);const{t:d}=he.useTranslationLib(),de=s.useMemo(()=>u?{required:u,validator:(e,r,c)=>{j||i!=null&&i.length?c():c(`${o??""} ${d("err.validation.required")}`)}}:void 0,[u,j,i==null?void 0:i.length,o,d]),V=w??d("message.uploadButtonText"),J=s.useMemo(()=>t.jsx(ee,{showLoadingIndicator:B,_buttonTitle:V,buttonSize:g,buttonType:p,fileList:i,hidePreview:C,icon:k,loading:F,listType:q,maxCount:b,onChangeFile:L,onRemove:R,showButtonText:x,handlePreview:ce,setFileList:z}),[B,V,g,p,i,C,k,F,q,b,L,R,x]);ie.current=J.props.beforeUpload;const[pe,W]=s.useState(0),[me,$]=s.useState(0),[M,fe]=s.useState();s.useEffect(()=>{const e=setTimeout(()=>{M&&localStorage.setItem(Y,JSON.stringify(M))},400);return()=>clearTimeout(e)},[M]),s.useEffect(()=>{if(!j){W(0),$(0);const e=setTimeout(()=>{var r;(r=l.current)==null||r.reset()},1500);return()=>clearTimeout(e)}},[j]);const G=s.useCallback(async e=>{if(e){const r=e.getCoordinates();fe(e.getState()),W((r==null?void 0:r.width)??10),$((r==null?void 0:r.height)??10)}},[]);return t.jsxs(t.Fragment,{children:[t.jsx(ve,{label:o,..._,name:m,className:"mb-0",rules:[de,..._.rules??[]],children:J}),t.jsxs(U.Modal,{open:!!j,maskClosable:!1,onOk:le,closable:!1,onCancel:ue,destroyOnHidden:!0,children:[t.jsx(je.Cropper,{ref:l,stencilProps:{grid:!0},style:{border:"1px solid black"},src:j,onChange:e=>{G(e)},aspectRatio:h?{minimum:h,maximum:h}:void 0}),t.jsx("p",{className:"text-center",children:[pe,me].join(" ⨉ ")}),t.jsx("div",{className:"mt-2 d-flex justify-content-center",children:t.jsxs(U.Space.Compact,{children:[t.jsx(I,{size:"large",tooltip:d("str.rotateLeft"),icon:t.jsx(O.RotateLeftOutlined,{}),onClick:()=>D(!0)}),t.jsx(I,{size:"large",icon:t.jsx(O.RotateRightOutlined,{}),tooltip:d("str.rotateRight"),onClick:()=>D(!1)}),t.jsx(I,{size:"large",icon:t.jsx(Ce,{}),tooltip:d("str.flipHorizontal"),onClick:()=>H("h")}),t.jsx(I,{size:"large",icon:t.jsx(be,{}),tooltip:d("str.flipVertical"),onClick:()=>H("v")})]})})]}),t.jsx(U.Modal,{open:oe,title:te,footer:null,onCancel:ae,children:t.jsx("div",{className:"text-center",children:t.jsx("img",{alt:"example",style:{maxWidth:"400px"},src:se})})})]})},ee=({_buttonTitle:n,buttonSize:u,buttonType:p,fileList:o,hidePreview:m,icon:f,loading:h,maxCount:w,onChangeFile:C,onRemove:g,showButtonText:x,handlePreview:E,setFileList:k,showLoadingIndicator:F,listType:b="picture"})=>t.jsxs(U.Upload,{accept:"image/x-png,image/gif,image/jpeg",fileList:o,defaultFileList:o,onChange:()=>{},className:(o.length>=w?" hide-upload ":"")+" mb-0",multiple:!1,onPreview:m?void 0:E,onDrop:a=>(C(a.dataTransfer.files.item(0)),!1),listType:b,showUploadList:!m,onRemove:a=>{const R=o.filter(q=>a.uid!==q.uid);g==null||g(a),k(R)},beforeUpload:async a=>(C(a),!1),maxCount:w,children:[F&&t.jsx(O.LoadingOutlined,{}),t.jsx("div",{className:"d-flex flex-column",children:o.length<w&&(b==="picture-circle"?t.jsx(O.UploadOutlined,{}):t.jsx(I,{loading:h,tooltip:x?void 0:n,size:u,icon:f,type:x?p:"text",children:x?n:void 0}))})]},o.length);exports.UploadComponent=ee;exports.default=Se;
|
|
@@ -4,7 +4,7 @@ import { Cropper as xe } from "react-advanced-cropper";
|
|
|
4
4
|
/* empty css */
|
|
5
5
|
import { RotateLeftOutlined as Fe, RotateRightOutlined as Oe, UploadOutlined as ne, LoadingOutlined as Se } from "@ant-design/icons";
|
|
6
6
|
import { Form as Ue, Modal as te, Space as ke, Upload as Re } from "antd";
|
|
7
|
-
import
|
|
7
|
+
import D, { useRef as H, useState as w, useCallback as L, useEffect as j, useMemo as re } from "react";
|
|
8
8
|
import { useTranslationLib as Ne } from "../../locale/index.es.js";
|
|
9
9
|
import O from "../button/Button.es.js";
|
|
10
10
|
import je from "../../util/ImageUtil.es.js";
|
|
@@ -29,21 +29,21 @@ const Ke = ({
|
|
|
29
29
|
hidePreview: v,
|
|
30
30
|
buttonSize: f = "large",
|
|
31
31
|
showButtonText: g = !0,
|
|
32
|
-
showOnlyIcon:
|
|
32
|
+
showOnlyIcon: V = !1,
|
|
33
33
|
icon: S = /* @__PURE__ */ r(ne, {}),
|
|
34
34
|
loading: U,
|
|
35
35
|
maxCount: y = 1,
|
|
36
36
|
onAdd: s,
|
|
37
37
|
onRemove: k,
|
|
38
38
|
listType: R,
|
|
39
|
-
...
|
|
39
|
+
..._
|
|
40
40
|
}) => {
|
|
41
|
-
const [se, ae] =
|
|
42
|
-
!e.url && !e.preview && (e.preview = await ie(e.originFileObj)), ce(e.url || e.preview),
|
|
43
|
-
}, [
|
|
41
|
+
const [se, ae] = D.useState(""), [le, ce] = D.useState(""), [de, E] = D.useState(!1), T = H(), l = H(null), [n, P] = w([]), [h, B] = w(), me = H(), pe = () => E(!1), ue = async (e) => {
|
|
42
|
+
!e.url && !e.preview && (e.preview = await ie(e.originFileObj)), ce(e.url || e.preview), E(!0), ae(e.name);
|
|
43
|
+
}, [M, N] = w(!1), J = (e) => {
|
|
44
44
|
var t;
|
|
45
45
|
(t = l.current) == null || t.rotateImage(e ? -90 : 90);
|
|
46
|
-
},
|
|
46
|
+
}, W = L((e) => {
|
|
47
47
|
var t;
|
|
48
48
|
l.current && ((t = l.current) == null || t.flipImage(e === "h", e === "v"));
|
|
49
49
|
}, []);
|
|
@@ -56,16 +56,14 @@ const Ke = ({
|
|
|
56
56
|
N(!0), e == null || e.toBlob(async (ve) => {
|
|
57
57
|
const ye = Object.assign(new File([ve], I, { type: t }), {
|
|
58
58
|
uid: x
|
|
59
|
-
}),
|
|
60
|
-
|
|
61
|
-
const ee = {
|
|
62
|
-
url: D,
|
|
59
|
+
}), Z = await je.resizeImage(ye), q = await ie(Z), ee = {
|
|
60
|
+
url: q,
|
|
63
61
|
name: I,
|
|
64
62
|
uid: x,
|
|
65
63
|
type: t,
|
|
66
64
|
size: a,
|
|
67
|
-
thumbUrl:
|
|
68
|
-
originFileObj:
|
|
65
|
+
thumbUrl: q,
|
|
66
|
+
originFileObj: Z
|
|
69
67
|
};
|
|
70
68
|
if (s)
|
|
71
69
|
try {
|
|
@@ -77,7 +75,7 @@ const Ke = ({
|
|
|
77
75
|
}), B(void 0);
|
|
78
76
|
}, ge = () => {
|
|
79
77
|
B(void 0), T.current = void 0;
|
|
80
|
-
},
|
|
78
|
+
}, $ = L((e) => {
|
|
81
79
|
const t = e;
|
|
82
80
|
if (t) {
|
|
83
81
|
T.current = t;
|
|
@@ -88,7 +86,7 @@ const Ke = ({
|
|
|
88
86
|
B(a.result);
|
|
89
87
|
const x = localStorage.getItem(oe), F = x ? JSON.parse(x) : void 0;
|
|
90
88
|
F && ((I = l.current) == null || I.setState(F)), setTimeout(() => {
|
|
91
|
-
|
|
89
|
+
Y(l.current);
|
|
92
90
|
}, 100);
|
|
93
91
|
}
|
|
94
92
|
}), a.readAsDataURL(t);
|
|
@@ -108,12 +106,12 @@ const Ke = ({
|
|
|
108
106
|
}
|
|
109
107
|
} : void 0,
|
|
110
108
|
[c, h, n == null ? void 0 : n.length, i, d]
|
|
111
|
-
),
|
|
109
|
+
), G = b ?? d("message.uploadButtonText"), K = re(
|
|
112
110
|
() => /* @__PURE__ */ r(
|
|
113
111
|
Be,
|
|
114
112
|
{
|
|
115
|
-
showLoadingIndicator:
|
|
116
|
-
_buttonTitle:
|
|
113
|
+
showLoadingIndicator: M,
|
|
114
|
+
_buttonTitle: G,
|
|
117
115
|
buttonSize: f,
|
|
118
116
|
buttonType: m,
|
|
119
117
|
fileList: n,
|
|
@@ -122,7 +120,7 @@ const Ke = ({
|
|
|
122
120
|
loading: U,
|
|
123
121
|
listType: R,
|
|
124
122
|
maxCount: y,
|
|
125
|
-
onChangeFile:
|
|
123
|
+
onChangeFile: $,
|
|
126
124
|
onRemove: k,
|
|
127
125
|
showButtonText: g,
|
|
128
126
|
handlePreview: ue,
|
|
@@ -130,8 +128,8 @@ const Ke = ({
|
|
|
130
128
|
}
|
|
131
129
|
),
|
|
132
130
|
[
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
M,
|
|
132
|
+
G,
|
|
135
133
|
f,
|
|
136
134
|
m,
|
|
137
135
|
n,
|
|
@@ -140,13 +138,13 @@ const Ke = ({
|
|
|
140
138
|
U,
|
|
141
139
|
R,
|
|
142
140
|
y,
|
|
143
|
-
|
|
141
|
+
$,
|
|
144
142
|
k,
|
|
145
143
|
g
|
|
146
144
|
]
|
|
147
145
|
);
|
|
148
|
-
me.current =
|
|
149
|
-
const [we,
|
|
146
|
+
me.current = K.props.beforeUpload;
|
|
147
|
+
const [we, Q] = w(0), [Ce, X] = w(0), [A, be] = w();
|
|
150
148
|
j(() => {
|
|
151
149
|
const e = setTimeout(() => {
|
|
152
150
|
A && localStorage.setItem(oe, JSON.stringify(A));
|
|
@@ -154,7 +152,7 @@ const Ke = ({
|
|
|
154
152
|
return () => clearTimeout(e);
|
|
155
153
|
}, [A]), j(() => {
|
|
156
154
|
if (!h) {
|
|
157
|
-
|
|
155
|
+
Q(0), X(0);
|
|
158
156
|
const e = setTimeout(() => {
|
|
159
157
|
var t;
|
|
160
158
|
(t = l.current) == null || t.reset();
|
|
@@ -162,10 +160,10 @@ const Ke = ({
|
|
|
162
160
|
return () => clearTimeout(e);
|
|
163
161
|
}
|
|
164
162
|
}, [h]);
|
|
165
|
-
const
|
|
163
|
+
const Y = L(async (e) => {
|
|
166
164
|
if (e) {
|
|
167
165
|
const t = e.getCoordinates();
|
|
168
|
-
be(e.getState()),
|
|
166
|
+
be(e.getState()), Q((t == null ? void 0 : t.width) ?? 10), X((t == null ? void 0 : t.height) ?? 10);
|
|
169
167
|
}
|
|
170
168
|
}, []);
|
|
171
169
|
return /* @__PURE__ */ z(Ie, { children: [
|
|
@@ -173,11 +171,11 @@ const Ke = ({
|
|
|
173
171
|
Pe,
|
|
174
172
|
{
|
|
175
173
|
label: i,
|
|
176
|
-
...
|
|
174
|
+
..._,
|
|
177
175
|
name: p,
|
|
178
176
|
className: "mb-0",
|
|
179
|
-
rules: [he, ...
|
|
180
|
-
children:
|
|
177
|
+
rules: [he, ..._.rules ?? []],
|
|
178
|
+
children: K
|
|
181
179
|
}
|
|
182
180
|
),
|
|
183
181
|
/* @__PURE__ */ z(
|
|
@@ -200,7 +198,7 @@ const Ke = ({
|
|
|
200
198
|
style: { border: "1px solid black" },
|
|
201
199
|
src: h,
|
|
202
200
|
onChange: (e) => {
|
|
203
|
-
|
|
201
|
+
Y(e);
|
|
204
202
|
},
|
|
205
203
|
aspectRatio: C ? {
|
|
206
204
|
minimum: C,
|
|
@@ -216,7 +214,7 @@ const Ke = ({
|
|
|
216
214
|
size: "large",
|
|
217
215
|
tooltip: d("str.rotateLeft"),
|
|
218
216
|
icon: /* @__PURE__ */ r(Fe, {}),
|
|
219
|
-
onClick: () =>
|
|
217
|
+
onClick: () => J(!0)
|
|
220
218
|
}
|
|
221
219
|
),
|
|
222
220
|
/* @__PURE__ */ r(
|
|
@@ -225,7 +223,7 @@ const Ke = ({
|
|
|
225
223
|
size: "large",
|
|
226
224
|
icon: /* @__PURE__ */ r(Oe, {}),
|
|
227
225
|
tooltip: d("str.rotateRight"),
|
|
228
|
-
onClick: () =>
|
|
226
|
+
onClick: () => J(!1)
|
|
229
227
|
}
|
|
230
228
|
),
|
|
231
229
|
/* @__PURE__ */ r(
|
|
@@ -234,7 +232,7 @@ const Ke = ({
|
|
|
234
232
|
size: "large",
|
|
235
233
|
icon: /* @__PURE__ */ r(ze, {}),
|
|
236
234
|
tooltip: d("str.flipHorizontal"),
|
|
237
|
-
onClick: () =>
|
|
235
|
+
onClick: () => W("h")
|
|
238
236
|
}
|
|
239
237
|
),
|
|
240
238
|
/* @__PURE__ */ r(
|
|
@@ -243,7 +241,7 @@ const Ke = ({
|
|
|
243
241
|
size: "large",
|
|
244
242
|
icon: /* @__PURE__ */ r(Te, {}),
|
|
245
243
|
tooltip: d("str.flipVertical"),
|
|
246
|
-
onClick: () =>
|
|
244
|
+
onClick: () => W("v")
|
|
247
245
|
}
|
|
248
246
|
)
|
|
249
247
|
] }) })
|
|
@@ -273,7 +271,7 @@ const Ke = ({
|
|
|
273
271
|
onChangeFile: v,
|
|
274
272
|
onRemove: f,
|
|
275
273
|
showButtonText: g,
|
|
276
|
-
handlePreview:
|
|
274
|
+
handlePreview: V,
|
|
277
275
|
setFileList: S,
|
|
278
276
|
showLoadingIndicator: U,
|
|
279
277
|
listType: y = "picture"
|
|
@@ -287,7 +285,7 @@ const Ke = ({
|
|
|
287
285
|
},
|
|
288
286
|
className: (i.length >= b ? " hide-upload " : "") + " mb-0",
|
|
289
287
|
multiple: !1,
|
|
290
|
-
onPreview: p ? void 0 :
|
|
288
|
+
onPreview: p ? void 0 : V,
|
|
291
289
|
onDrop: (s) => (v(s.dataTransfer.files.item(0)), !1),
|
|
292
290
|
listType: y,
|
|
293
291
|
showUploadList: !p,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),j=require("@ant-design/icons"),u=require("antd"),F=require("react"),y=require("../locale/index.cjs.js"),R=require("./CrudForm.cjs.js"),S=require("../common/wizard/WizardViewForm.cjs.js"),b=require("../util/CrudUtil.cjs.js"),C=require("../common/button/Button.cjs.js");function v({fields:d,className:m,onDeleteFile:h,onUploadFile:
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),j=require("@ant-design/icons"),u=require("antd"),F=require("react"),y=require("../locale/index.cjs.js"),R=require("./CrudForm.cjs.js"),S=require("../common/wizard/WizardViewForm.cjs.js"),b=require("../util/CrudUtil.cjs.js"),C=require("../common/button/Button.cjs.js");function v({fields:d,className:m,onDeleteFile:h,onUploadFile:s,purpose:l,wizard:t=[],updatingValue:f,onSave:x,submitting:g}){const c=F.useMemo(()=>t.map(r=>{let n=!0;const o=d.filter(i=>r.fields.includes(b.getRealName(i.name)));return o.forEach(i=>n&&(n=i.hidden??!1)),{...r,hidden:n,fieldThatShouldShowing:o}}),[d,t]),a=F.useMemo(()=>c.filter(r=>!r.hidden),[c]);return e.jsx(S,{onSubmit:(r,n)=>{x(n)},className:m,pages:a.map(({title:r,icon:n,fieldThatShouldShowing:o,hidden:i},q)=>({title:r,icon:n,hidden:i,component:k=>e.jsx(N,{fields:o,onDeleteFile:h,onUploadFile:s,purpose:l,i:q,updatingValue:f,backward:k.backward,forward:k.forward,wizard:a,submitting:g},q)}))})}function N({fields:d,onDeleteFile:m,onUploadFile:h,purpose:s,wizard:l=[],i:t,forward:f,backward:x,submitting:g,updatingValue:c}){const a=l[t],{t:r}=y.useTranslationLib(),[n]=u.Form.useForm();return F.useEffect(()=>{if(c&&(s==="update"||s==="clone")){const o={};for(const i of d)o[b.getRealName(i.name,"upsertFieldName")]=c[b.getRealName(i.name,"upsertFieldName")];n.setFieldsValue(o)}},[d,n,s,c]),e.jsxs(u.Form,{name:String(t),form:n,layout:"vertical",children:[e.jsx(R.CrudFormFields,{fields:d,formBuilder:a.formBuilder,grid:a.grid,onDeleteFile:m,onUploadFile:h,purpose:s}),e.jsx(u.Divider,{}),e.jsxs(u.Row,{gutter:[8,8],children:[t>0&&e.jsx(u.Col,{md:12,children:e.jsx(C,{block:!0,icon:e.jsx(j.LeftOutlined,{}),htmlType:"button",type:"default",size:"large",onClick:()=>x(),children:r("str.back")})}),e.jsx(u.Col,{md:t>0?12:24,children:e.jsx(C,{block:!0,icon:l.length-1===t?e.jsx(j.SaveOutlined,{}):e.jsx(j.RightOutlined,{}),htmlType:"submit",type:"primary",loading:g,size:"large",onClick:()=>{n.validateFields().then(o=>{f(o,l.length-1===t,l.length-1===t)})},children:l.length-1===t?r("str."+(s==="update"?"update":"save")):r("str.next")})})]})]})}module.exports=v;
|
|
@@ -11,46 +11,46 @@ function H({
|
|
|
11
11
|
fields: d,
|
|
12
12
|
className: u,
|
|
13
13
|
onDeleteFile: f,
|
|
14
|
-
onUploadFile:
|
|
15
|
-
purpose:
|
|
16
|
-
wizard:
|
|
14
|
+
onUploadFile: m,
|
|
15
|
+
purpose: l,
|
|
16
|
+
wizard: e = [],
|
|
17
17
|
updatingValue: s,
|
|
18
18
|
onSave: h,
|
|
19
19
|
submitting: g
|
|
20
20
|
}) {
|
|
21
|
-
const a = S(() =>
|
|
22
|
-
let
|
|
21
|
+
const a = S(() => e.map((t) => {
|
|
22
|
+
let r = !0;
|
|
23
23
|
const n = d.filter(
|
|
24
|
-
(i) =>
|
|
24
|
+
(i) => t.fields.includes(p.getRealName(i.name))
|
|
25
25
|
);
|
|
26
|
-
return n.forEach((i) =>
|
|
27
|
-
...
|
|
28
|
-
hidden:
|
|
26
|
+
return n.forEach((i) => r && (r = i.hidden ?? !1)), {
|
|
27
|
+
...t,
|
|
28
|
+
hidden: r,
|
|
29
29
|
fieldThatShouldShowing: n
|
|
30
30
|
};
|
|
31
|
-
}), [d,
|
|
32
|
-
() => a.filter((
|
|
31
|
+
}), [d, e]), c = S(
|
|
32
|
+
() => a.filter((t) => !t.hidden),
|
|
33
33
|
[a]
|
|
34
34
|
);
|
|
35
35
|
return /* @__PURE__ */ o(
|
|
36
36
|
B,
|
|
37
37
|
{
|
|
38
|
-
onSubmit: (
|
|
39
|
-
|
|
38
|
+
onSubmit: (t, r) => {
|
|
39
|
+
h(r);
|
|
40
40
|
},
|
|
41
41
|
className: u,
|
|
42
42
|
pages: c.map(
|
|
43
|
-
({ title:
|
|
44
|
-
title:
|
|
45
|
-
icon:
|
|
43
|
+
({ title: t, icon: r, fieldThatShouldShowing: n, hidden: i }, b) => ({
|
|
44
|
+
title: t,
|
|
45
|
+
icon: r,
|
|
46
46
|
hidden: i,
|
|
47
47
|
component: (F) => /* @__PURE__ */ o(
|
|
48
48
|
O,
|
|
49
49
|
{
|
|
50
50
|
fields: n,
|
|
51
51
|
onDeleteFile: f,
|
|
52
|
-
onUploadFile:
|
|
53
|
-
purpose:
|
|
52
|
+
onUploadFile: m,
|
|
53
|
+
purpose: l,
|
|
54
54
|
i: b,
|
|
55
55
|
updatingValue: s,
|
|
56
56
|
backward: F.backward,
|
|
@@ -69,23 +69,23 @@ function O({
|
|
|
69
69
|
fields: d,
|
|
70
70
|
onDeleteFile: u,
|
|
71
71
|
onUploadFile: f,
|
|
72
|
-
purpose:
|
|
73
|
-
wizard:
|
|
74
|
-
i:
|
|
72
|
+
purpose: m,
|
|
73
|
+
wizard: l = [],
|
|
74
|
+
i: e,
|
|
75
75
|
forward: s,
|
|
76
76
|
backward: h,
|
|
77
77
|
submitting: g,
|
|
78
78
|
updatingValue: a
|
|
79
79
|
}) {
|
|
80
|
-
const c =
|
|
80
|
+
const c = l[e], { t } = j(), [r] = y.useForm();
|
|
81
81
|
return W(() => {
|
|
82
|
-
if (a && (
|
|
82
|
+
if (a && (m === "update" || m === "clone")) {
|
|
83
83
|
const n = {};
|
|
84
84
|
for (const i of d)
|
|
85
85
|
n[p.getRealName(i.name, "upsertFieldName")] = a[p.getRealName(i.name, "upsertFieldName")];
|
|
86
|
-
|
|
86
|
+
r.setFieldsValue(n);
|
|
87
87
|
}
|
|
88
|
-
}, [d,
|
|
88
|
+
}, [d, r, m, a]), /* @__PURE__ */ k(y, { name: String(e), form: r, layout: "vertical", children: [
|
|
89
89
|
/* @__PURE__ */ o(
|
|
90
90
|
z,
|
|
91
91
|
{
|
|
@@ -94,12 +94,12 @@ function O({
|
|
|
94
94
|
grid: c.grid,
|
|
95
95
|
onDeleteFile: u,
|
|
96
96
|
onUploadFile: f,
|
|
97
|
-
purpose:
|
|
97
|
+
purpose: m
|
|
98
98
|
}
|
|
99
99
|
),
|
|
100
100
|
/* @__PURE__ */ o(x, {}),
|
|
101
101
|
/* @__PURE__ */ k(T, { gutter: [8, 8], children: [
|
|
102
|
-
|
|
102
|
+
e > 0 && /* @__PURE__ */ o(C, { md: 12, children: /* @__PURE__ */ o(
|
|
103
103
|
v,
|
|
104
104
|
{
|
|
105
105
|
block: !0,
|
|
@@ -108,28 +108,28 @@ function O({
|
|
|
108
108
|
type: "default",
|
|
109
109
|
size: "large",
|
|
110
110
|
onClick: () => h(),
|
|
111
|
-
children:
|
|
111
|
+
children: t("str.back")
|
|
112
112
|
}
|
|
113
113
|
) }),
|
|
114
|
-
/* @__PURE__ */ o(C, { md:
|
|
114
|
+
/* @__PURE__ */ o(C, { md: e > 0 ? 12 : 24, children: /* @__PURE__ */ o(
|
|
115
115
|
v,
|
|
116
116
|
{
|
|
117
117
|
block: !0,
|
|
118
|
-
icon:
|
|
118
|
+
icon: l.length - 1 === e ? /* @__PURE__ */ o(R, {}) : /* @__PURE__ */ o(w, {}),
|
|
119
119
|
htmlType: "submit",
|
|
120
120
|
type: "primary",
|
|
121
121
|
loading: g,
|
|
122
122
|
size: "large",
|
|
123
123
|
onClick: () => {
|
|
124
|
-
|
|
124
|
+
r.validateFields().then((n) => {
|
|
125
125
|
s(
|
|
126
126
|
n,
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
l.length - 1 === e,
|
|
128
|
+
l.length - 1 === e
|
|
129
129
|
);
|
|
130
130
|
});
|
|
131
131
|
},
|
|
132
|
-
children:
|
|
132
|
+
children: l.length - 1 === e ? t("str." + (m === "update" ? "update" : "save")) : t("str.next")
|
|
133
133
|
}
|
|
134
134
|
) })
|
|
135
135
|
] })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),J=require("@ant-design/icons"),s=require("antd"),
|
|
2
|
-
${
|
|
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:f,onSubmit:x,paginateProps:G,size:O,onClickPrint:h,onClickExcelExport:y,minusHeight:U,extraSearchFields:R,searchOnMount:B,summary:_}){const{searchable:$,selectable:c,sortable:w,defaultSort:p}=i.useMemo(()=>{var b,m,N,I,T;const e=[],t=[],o=[];let n;for(const l of d.filter(H=>!H.hidden))l.type==="image"||!l.report||((b=l.report)!=null&&b.searchable&&e.push(l),(m=l.report)!=null&&m.sortable&&(t.push(l),!n&&((N=l.report)!=null&&N.defaultSort)&&(n=l)),l.hideInTable||o.push({id:l.name,label:l.label,lock:(I=l.report)==null?void 0:I.lock,alreadySelected:(T=l.report)==null?void 0:T.alreadySelected}));return{defaultSort:n,searchable:e,sortable:t,selectable:o}},[d]),[S,F]=i.useState([]),g=i.useCallback(async({sortBy:e,sortByType:t,showFields:o=[],...n})=>{const b=[];e&&b.push({field:e,sort:t??"DESC"}),F(d.filter(m=>o.includes(m.name)).map(m=>({...m,hideInTable:!1}))),x({showFields:o,sortBy:b,...n})},[d,x]),[a]=s.Form.useForm(),[q,z]=i.useState(!1),[C,D]=i.useState(!0);return i.useEffect(()=>{if(B&&C){const e=setTimeout(()=>{a.validateFields().then(t=>{g(t)}),D(!1)},200);return()=>clearTimeout(e)}},[g,a,C,B]),i.useEffect(()=>{var t,o;!a.getFieldValue("sortBy")&&p&&a.setFieldsValue({sortBy:p.name,sortByType:typeof((t=p.report)==null?void 0:t.defaultSort)=="string"?(o=p.report)==null?void 0:o.defaultSort:"ASC"})},[p,a]),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:a,layout:"vertical",onFinish:g,children:[r.jsxs(s.Row,{gutter:[8,8],children:[$.map(e=>{var t,o,n;return r.jsx(s.Col,{...e.grid??A,style:{alignSelf:"end"},children:(t=e.report)!=null&&t.customRender?e.report.customRender(a):e.type==="date"?r.jsx(j.default,{...e,type:"date",range:(o=e.report)==null?void 0:o.range,required:!!((n=e.report)!=null&&n.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(a):null]}),r.jsx(V,{className:"mt-3",type:"primary",block:!0,htmlType:"submit",disabled:f,children:"Submit"})]}),r.jsxs(s.Space,{children:[!!h&&r.jsx(W.PrintButton,{disabled:f||!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:f||!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
|
+
${f||!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:
|
|
4
|
+
`,children:"Excel"})]}),_,r.jsx(K,{minusHeight:U,data:u,size:O,fields:S,idField:L,loadingData:f,paginateProps:G,viewable:!1})]})}module.exports=Y;
|