@kingteza/crud-component 1.13.0 → 1.13.2
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/README.md +16 -0
- package/dist/common/picker/ImagePicker.cjs.js +1 -1
- package/dist/common/picker/ImagePicker.es.js +168 -162
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,16 @@ This library has the following peer dependencies that need to be installed:
|
|
|
16
16
|
npm install antd@^5.22.6 react@^18.3.1 react-dom@^18.3.1 react-router-dom@^7.0.0
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
## CSS Styles
|
|
20
|
+
|
|
21
|
+
**Important:** You need to import the CSS styles manually in your application entry point:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import '@kingteza/crud-component/styles';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This should be imported once at the root of your application (e.g., in your `main.tsx`, `index.tsx`, or `App.tsx` file).
|
|
28
|
+
|
|
19
29
|
## Setup
|
|
20
30
|
|
|
21
31
|
### Option 1: Using CrudComponentProvider (Recommended)
|
|
@@ -23,6 +33,7 @@ npm install antd@^5.22.6 react@^18.3.1 react-dom@^18.3.1 react-router-dom@^7.0.0
|
|
|
23
33
|
Wrap your app with `CrudComponentProvider` to automatically initialize the library:
|
|
24
34
|
|
|
25
35
|
```typescript
|
|
36
|
+
import '@kingteza/crud-component/styles';
|
|
26
37
|
import { CrudComponentProvider } from '@kingteza/crud-component';
|
|
27
38
|
|
|
28
39
|
function App() {
|
|
@@ -66,6 +77,7 @@ function App() {
|
|
|
66
77
|
If you prefer to initialize manually, you can still use `setupI18n()`:
|
|
67
78
|
|
|
68
79
|
```typescript
|
|
80
|
+
import '@kingteza/crud-component/styles';
|
|
69
81
|
import { setupI18n } from '@kingteza/crud-component';
|
|
70
82
|
|
|
71
83
|
// Basic setup with default English translations
|
|
@@ -88,6 +100,7 @@ setupI18n({
|
|
|
88
100
|
### Usage
|
|
89
101
|
|
|
90
102
|
```typescript
|
|
103
|
+
import '@kingteza/crud-component/styles';
|
|
91
104
|
import { CrudComponentProvider, CrudComponent } from '@kingteza/crud-component';
|
|
92
105
|
import { Button } from '@kingteza/crud-component/common';
|
|
93
106
|
|
|
@@ -115,6 +128,9 @@ function App() {
|
|
|
115
128
|
The library provides several entry points for importing components:
|
|
116
129
|
|
|
117
130
|
```typescript
|
|
131
|
+
// CSS styles (required - import once at your app entry point)
|
|
132
|
+
import '@kingteza/crud-component/styles';
|
|
133
|
+
|
|
118
134
|
// Main CRUD component
|
|
119
135
|
import { CrudComponent } from '@kingteza/crud-component';
|
|
120
136
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),ye=require("react-advanced-cropper"),q=require("@ant-design/icons"),y=require("antd"),s=require("react"),Se=require("../../locale/index.cjs.js"),v=require("../button/Button.cjs.js"),ie=require("../../util/ImageUtil.cjs.js"),ke=require("../../icons/FlipHIcon.cjs.js"),Ie=require("../../icons/FlipVIcon.cjs.js"),Fe=y.Form.Item,ae="crud-component.image-picker.button-state";function V(o){return new Promise((d,f)=>{const n=new FileReader;n.readAsDataURL(o),n.onload=()=>d(n.result),n.onerror=m=>f(m)})}const Oe=({values:o=[],required:d,buttonType:f,label:n,name:m,onChange:g,aspectRatio:S,buttonTitle:k,hidePreview:I,buttonSize:x="large",showButtonText:j=!0,showOnlyIcon:A=!1,icon:z=t.jsx(q.UploadOutlined,{}),loading:N,maxCount:F=1,onAdd:l,onRemove:P,listType:T,showSkipCropButton:ce,skipResize:J,...W})=>{const[ue,de]=s.useState(""),[pe,fe]=s.useState(""),[me,$]=s.useState(!1),B=s.useRef(),c=s.useRef(null),[i,M]=s.useState([]),[h,E]=s.useState(),ge=s.useRef(),xe=()=>$(!1),je=async e=>{!e.url&&!e.preview&&(e.preview=await V(e.originFileObj)),fe(e.url||e.preview),$(!0),de(e.name)},[G,p]=s.useState(!1),K=e=>{var r;(r=c.current)==null||r.rotateImage(e?-90:90)},Q=s.useCallback(e=>{var r;c.current&&((r=c.current)==null||r.flipImage(e==="h",e==="v"))},[]);s.useEffect(()=>{g==null||g(i[0],i)},[i,g]);const[_,H]=s.useState(),X=s.useCallback(async e=>{var O;const{type:r,size:a,name:b,uid:w}=B.current;if(H(e?"skip-crop":"crop"),p(!0),e){const C=B.current,D=J?C:await ie.resizeImage(C),U=await V(D),R={url:U,name:b,uid:w,type:r,size:a,thumbUrl:U,originFileObj:D};if(l)try{p(!0),await l(R)}finally{p(!1)}M([R,...i]),p(!1),E(void 0),H(void 0)}else{const C=(O=c.current)==null?void 0:O.getCanvas();C==null||C.toBlob(async D=>{const U=Object.assign(new File([D],b,{type:r}),{uid:w}),R=J?U:await ie.resizeImage(U),oe=await V(R),ne={url:oe,name:b,uid:w,type:r,size:a,thumbUrl:oe,originFileObj:R};if(l)try{p(!0),await l(ne)}finally{p(!1)}M([ne,...i]),p(!1)}),E(void 0),H(void 0)}},[]),he=()=>{E(void 0),B.current=void 0},Y=s.useCallback(e=>{const r=e;if(r){B.current=r;const a=new FileReader;a.addEventListener("load",()=>{var b;if(typeof a.result=="string"){E(a.result);const w=localStorage.getItem(ae),O=w?JSON.parse(w):void 0;O&&((b=c.current)==null||b.setState(O)),setTimeout(()=>{se(c.current)},100)}}),a.readAsDataURL(r)}},[]);s.useEffect(()=>{if(o!=null&&o.length||typeof o=="string"){const e=Array.isArray(o)?o.map(r=>[{uid:o,url:r}]):[{uid:o,url:o}];M(e)}},[o]);const{t:u}=Se.useTranslationLib(),be=s.useMemo(()=>d?{required:d,validator:(e,r,a)=>{h||i!=null&&i.length?a():a(`${n??""} ${u("err.validation.required")}`)}}:void 0,[d,h,i==null?void 0:i.length,n,u]),Z=k??u("message.uploadButtonText"),ee=s.useMemo(()=>t.jsx(le,{showLoadingIndicator:G,_buttonTitle:Z,buttonSize:x,buttonType:f,fileList:i,hidePreview:I,icon:z,loading:N,listType:T,maxCount:F,onChangeFile:Y,onRemove:P,showButtonText:j,handlePreview:je,setFileList:M}),[G,Z,x,f,i,I,z,N,T,F,Y,P,j]);ge.current=ee.props.beforeUpload;const[we,te]=s.useState(0),[Ce,re]=s.useState(0),[L,ve]=s.useState();s.useEffect(()=>{const e=setTimeout(()=>{L&&localStorage.setItem(ae,JSON.stringify(L))},400);return()=>clearTimeout(e)},[L]),s.useEffect(()=>{if(!h){te(0),re(0);const e=setTimeout(()=>{var r;(r=c.current)==null||r.reset()},1500);return()=>clearTimeout(e)}},[h]);const se=s.useCallback(async e=>{if(e){const r=e.getCoordinates();ve(e.getState()),te((r==null?void 0:r.width)??10),re((r==null?void 0:r.height)??10)}},[]);return t.jsxs(t.Fragment,{children:[t.jsx(Fe,{label:n,...W,name:m,className:"mb-0",rules:[be,...W.rules??[]],children:ee}),t.jsxs(y.Modal,{open:!!h,maskClosable:!1,onOk:()=>X(!1),closable:!1,okButtonProps:{loading:_==="crop",disabled:_==="skip-crop"},onCancel:he,footer:(e,{CancelBtn:r,OkBtn:a})=>ce?t.jsxs(y.Space,{children:[t.jsx(r,{}),t.jsx(v,{type:"primary",loading:_==="skip-crop",disabled:_==="crop",onClick:()=>X(!0),children:u("str.skipCrop")}),t.jsx(a,{})]}):t.jsx(t.Fragment,{children:e}),destroyOnHidden:!0,children:[t.jsx(ye.Cropper,{ref:c,stencilProps:{grid:!0},style:{border:"1px solid black"},src:h,onChange:e=>{se(e)},aspectRatio:S?{minimum:S,maximum:S}:void 0}),t.jsx("p",{className:"text-center",children:[we,Ce].join(" ⨉ ")}),t.jsx("div",{className:"mt-2 d-flex justify-content-center",children:t.jsxs(y.Space.Compact,{children:[t.jsx(v,{size:"large",tooltip:u("str.rotateLeft"),icon:t.jsx(q.RotateLeftOutlined,{}),onClick:()=>K(!0)}),t.jsx(v,{size:"large",icon:t.jsx(q.RotateRightOutlined,{}),tooltip:u("str.rotateRight"),onClick:()=>K(!1)}),t.jsx(v,{size:"large",icon:t.jsx(ke,{}),tooltip:u("str.flipHorizontal"),onClick:()=>Q("h")}),t.jsx(v,{size:"large",icon:t.jsx(Ie,{}),tooltip:u("str.flipVertical"),onClick:()=>Q("v")})]})})]}),t.jsx(y.Modal,{open:me,title:ue,footer:null,onCancel:xe,children:t.jsx("div",{className:"text-center",children:t.jsx("img",{alt:"example",style:{maxWidth:"400px"},src:pe})})})]})},le=({_buttonTitle:o,buttonSize:d,buttonType:f,fileList:n,hidePreview:m,icon:g,loading:S,maxCount:k,onChangeFile:I,onRemove:x,showButtonText:j,handlePreview:A,setFileList:z,showLoadingIndicator:N,listType:F="picture"})=>t.jsxs(y.Upload,{accept:"image/x-png,image/gif,image/jpeg",fileList:n,defaultFileList:n,onChange:()=>{},className:(n.length>=k?" hide-upload ":"")+" mb-0",multiple:!1,onPreview:m?void 0:A,onDrop:l=>(I(l.dataTransfer.files.item(0)),!1),listType:F,showUploadList:!m,onRemove:l=>{const P=n.filter(T=>l.uid!==T.uid);x==null||x(l),z(P)},beforeUpload:async l=>(I(l),!1),maxCount:k,children:[N&&t.jsx(q.LoadingOutlined,{}),t.jsx("div",{className:"d-flex flex-column",children:n.length<k&&(F==="picture-circle"?t.jsx(q.UploadOutlined,{}):t.jsx(v,{loading:S,tooltip:j?void 0:o,size:d,icon:g,type:j?f:"text",children:j?o:void 0}))})]},n.length);exports.UploadComponent=le;exports.default=Oe;
|
|
@@ -1,279 +1,285 @@
|
|
|
1
|
-
import { jsx as r, jsxs as j, Fragment as
|
|
2
|
-
import { Cropper as
|
|
3
|
-
import { RotateLeftOutlined as
|
|
4
|
-
import { Form as
|
|
5
|
-
import
|
|
6
|
-
import { useTranslationLib as
|
|
1
|
+
import { jsx as r, jsxs as j, Fragment as ce } from "react/jsx-runtime";
|
|
2
|
+
import { Cropper as je } from "react-advanced-cropper";
|
|
3
|
+
import { RotateLeftOutlined as ze, RotateRightOutlined as Ne, UploadOutlined as ge, LoadingOutlined as Be } from "@ant-design/icons";
|
|
4
|
+
import { Form as Pe, Modal as de, Space as pe, Upload as Te } from "antd";
|
|
5
|
+
import J, { useRef as W, useState as m, useCallback as _, useEffect as E, useMemo as me } from "react";
|
|
6
|
+
import { useTranslationLib as De } from "../../locale/index.es.js";
|
|
7
7
|
import I from "../button/Button.es.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
const
|
|
12
|
-
function
|
|
13
|
-
return new Promise((d,
|
|
8
|
+
import ue from "../../util/ImageUtil.es.js";
|
|
9
|
+
import He from "../../icons/FlipHIcon.es.js";
|
|
10
|
+
import Le from "../../icons/FlipVIcon.es.js";
|
|
11
|
+
const Ve = Pe.Item, fe = "crud-component.image-picker.button-state";
|
|
12
|
+
function $(o) {
|
|
13
|
+
return new Promise((d, u) => {
|
|
14
14
|
const i = new FileReader();
|
|
15
|
-
i.readAsDataURL(o), i.onload = () => d(i.result), i.onerror = (
|
|
15
|
+
i.readAsDataURL(o), i.onload = () => d(i.result), i.onerror = (f) => u(f);
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
const
|
|
18
|
+
const Ye = ({
|
|
19
19
|
values: o = [],
|
|
20
20
|
required: d,
|
|
21
|
-
buttonType:
|
|
21
|
+
buttonType: u,
|
|
22
22
|
label: i,
|
|
23
|
-
name:
|
|
24
|
-
onChange:
|
|
25
|
-
aspectRatio:
|
|
26
|
-
buttonTitle:
|
|
27
|
-
hidePreview:
|
|
28
|
-
buttonSize:
|
|
29
|
-
showButtonText:
|
|
30
|
-
showOnlyIcon:
|
|
31
|
-
icon: z = /* @__PURE__ */ r(
|
|
23
|
+
name: f,
|
|
24
|
+
onChange: g,
|
|
25
|
+
aspectRatio: k,
|
|
26
|
+
buttonTitle: F,
|
|
27
|
+
hidePreview: O,
|
|
28
|
+
buttonSize: h = "large",
|
|
29
|
+
showButtonText: w = !0,
|
|
30
|
+
showOnlyIcon: G = !1,
|
|
31
|
+
icon: z = /* @__PURE__ */ r(ge, {}),
|
|
32
32
|
loading: N,
|
|
33
|
-
maxCount:
|
|
33
|
+
maxCount: x = 1,
|
|
34
34
|
onAdd: s,
|
|
35
|
-
onRemove:
|
|
35
|
+
onRemove: B,
|
|
36
36
|
listType: P,
|
|
37
|
-
showSkipCropButton:
|
|
38
|
-
skipResize:
|
|
39
|
-
...
|
|
37
|
+
showSkipCropButton: he,
|
|
38
|
+
skipResize: K,
|
|
39
|
+
...Q
|
|
40
40
|
}) => {
|
|
41
|
-
const [
|
|
42
|
-
!e.url && !e.preview && (e.preview = await
|
|
43
|
-
}, [
|
|
41
|
+
const [we, be] = J.useState(""), [ye, ve] = J.useState(""), [Ce, X] = J.useState(!1), T = W(), l = W(null), [n, D] = m([]), [b, H] = m(), Ie = W(), ke = () => X(!1), Fe = async (e) => {
|
|
42
|
+
!e.url && !e.preview && (e.preview = await $(e.originFileObj)), ve(e.url || e.preview), X(!0), be(e.name);
|
|
43
|
+
}, [Y, p] = m(!1), Z = (e) => {
|
|
44
44
|
var t;
|
|
45
45
|
(t = l.current) == null || t.rotateImage(e ? -90 : 90);
|
|
46
|
-
},
|
|
46
|
+
}, q = _((e) => {
|
|
47
47
|
var t;
|
|
48
48
|
l.current && ((t = l.current) == null || t.flipImage(e === "h", e === "v"));
|
|
49
49
|
}, []);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, [n,
|
|
53
|
-
const
|
|
54
|
-
var
|
|
55
|
-
const { type: t, size: a, name: y, uid:
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
50
|
+
E(() => {
|
|
51
|
+
g == null || g(n[0], n);
|
|
52
|
+
}, [n, g]);
|
|
53
|
+
const [L, M] = m(), ee = _(async (e) => {
|
|
54
|
+
var U;
|
|
55
|
+
const { type: t, size: a, name: y, uid: v } = T.current;
|
|
56
|
+
if (M(e ? "skip-crop" : "crop"), p(!0), e) {
|
|
57
|
+
const C = T.current, V = K ? C : await ue.resizeImage(C), S = await $(V), R = {
|
|
58
58
|
url: S,
|
|
59
59
|
name: y,
|
|
60
|
-
uid:
|
|
60
|
+
uid: v,
|
|
61
61
|
type: t,
|
|
62
62
|
size: a,
|
|
63
63
|
thumbUrl: S,
|
|
64
|
-
originFileObj:
|
|
64
|
+
originFileObj: V
|
|
65
65
|
};
|
|
66
66
|
if (s)
|
|
67
67
|
try {
|
|
68
|
-
|
|
68
|
+
p(!0), await s(R);
|
|
69
69
|
} finally {
|
|
70
|
-
|
|
70
|
+
p(!1);
|
|
71
71
|
}
|
|
72
|
-
D([R, ...n]),
|
|
72
|
+
D([R, ...n]), p(!1), H(void 0), M(void 0);
|
|
73
73
|
} else {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const S = Object.assign(new File([
|
|
77
|
-
uid:
|
|
78
|
-
}), R =
|
|
79
|
-
url:
|
|
74
|
+
const C = (U = l.current) == null ? void 0 : U.getCanvas();
|
|
75
|
+
C == null || C.toBlob(async (V) => {
|
|
76
|
+
const S = Object.assign(new File([V], y, { type: t }), {
|
|
77
|
+
uid: v
|
|
78
|
+
}), R = K ? S : await ue.resizeImage(S), se = await $(R), le = {
|
|
79
|
+
url: se,
|
|
80
80
|
name: y,
|
|
81
|
-
uid:
|
|
81
|
+
uid: v,
|
|
82
82
|
type: t,
|
|
83
83
|
size: a,
|
|
84
|
-
thumbUrl:
|
|
84
|
+
thumbUrl: se,
|
|
85
85
|
originFileObj: R
|
|
86
86
|
};
|
|
87
87
|
if (s)
|
|
88
88
|
try {
|
|
89
|
-
|
|
89
|
+
p(!0), await s(le);
|
|
90
90
|
} finally {
|
|
91
|
-
|
|
91
|
+
p(!1);
|
|
92
92
|
}
|
|
93
|
-
D([
|
|
94
|
-
}), H(void 0);
|
|
93
|
+
D([le, ...n]), p(!1);
|
|
94
|
+
}), H(void 0), M(void 0);
|
|
95
95
|
}
|
|
96
|
-
}, []),
|
|
97
|
-
H(void 0),
|
|
98
|
-
},
|
|
96
|
+
}, []), Oe = () => {
|
|
97
|
+
H(void 0), T.current = void 0;
|
|
98
|
+
}, te = _((e) => {
|
|
99
99
|
const t = e;
|
|
100
100
|
if (t) {
|
|
101
|
-
|
|
101
|
+
T.current = t;
|
|
102
102
|
const a = new FileReader();
|
|
103
103
|
a.addEventListener("load", () => {
|
|
104
104
|
var y;
|
|
105
105
|
if (typeof a.result == "string") {
|
|
106
106
|
H(a.result);
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
const v = localStorage.getItem(fe), U = v ? JSON.parse(v) : void 0;
|
|
108
|
+
U && ((y = l.current) == null || y.setState(U)), setTimeout(() => {
|
|
109
|
+
ae(l.current);
|
|
110
110
|
}, 100);
|
|
111
111
|
}
|
|
112
112
|
}), a.readAsDataURL(t);
|
|
113
113
|
}
|
|
114
114
|
}, []);
|
|
115
|
-
|
|
115
|
+
E(() => {
|
|
116
116
|
if (o != null && o.length || typeof o == "string") {
|
|
117
117
|
const e = Array.isArray(o) ? o.map((t) => [{ uid: o, url: t }]) : [{ uid: o, url: o }];
|
|
118
118
|
D(e);
|
|
119
119
|
}
|
|
120
120
|
}, [o]);
|
|
121
|
-
const { t: c } =
|
|
121
|
+
const { t: c } = De(), xe = me(
|
|
122
122
|
() => d ? {
|
|
123
123
|
required: d,
|
|
124
124
|
validator: (e, t, a) => {
|
|
125
|
-
|
|
125
|
+
b || n != null && n.length ? a() : a(`${i ?? ""} ${c("err.validation.required")}`);
|
|
126
126
|
}
|
|
127
127
|
} : void 0,
|
|
128
|
-
[d,
|
|
129
|
-
),
|
|
128
|
+
[d, b, n == null ? void 0 : n.length, i, c]
|
|
129
|
+
), re = F ?? c("message.uploadButtonText"), oe = me(
|
|
130
130
|
() => /* @__PURE__ */ r(
|
|
131
|
-
|
|
131
|
+
_e,
|
|
132
132
|
{
|
|
133
|
-
showLoadingIndicator:
|
|
134
|
-
_buttonTitle:
|
|
135
|
-
buttonSize:
|
|
136
|
-
buttonType:
|
|
133
|
+
showLoadingIndicator: Y,
|
|
134
|
+
_buttonTitle: re,
|
|
135
|
+
buttonSize: h,
|
|
136
|
+
buttonType: u,
|
|
137
137
|
fileList: n,
|
|
138
|
-
hidePreview:
|
|
138
|
+
hidePreview: O,
|
|
139
139
|
icon: z,
|
|
140
140
|
loading: N,
|
|
141
141
|
listType: P,
|
|
142
|
-
maxCount:
|
|
143
|
-
onChangeFile:
|
|
144
|
-
onRemove:
|
|
145
|
-
showButtonText:
|
|
146
|
-
handlePreview:
|
|
142
|
+
maxCount: x,
|
|
143
|
+
onChangeFile: te,
|
|
144
|
+
onRemove: B,
|
|
145
|
+
showButtonText: w,
|
|
146
|
+
handlePreview: Fe,
|
|
147
147
|
setFileList: D
|
|
148
148
|
}
|
|
149
149
|
),
|
|
150
150
|
[
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
Y,
|
|
152
|
+
re,
|
|
153
|
+
h,
|
|
154
|
+
u,
|
|
155
155
|
n,
|
|
156
|
-
|
|
156
|
+
O,
|
|
157
157
|
z,
|
|
158
158
|
N,
|
|
159
159
|
P,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
x,
|
|
161
|
+
te,
|
|
162
|
+
B,
|
|
163
|
+
w
|
|
164
164
|
]
|
|
165
165
|
);
|
|
166
|
-
|
|
167
|
-
const [
|
|
168
|
-
|
|
166
|
+
Ie.current = oe.props.beforeUpload;
|
|
167
|
+
const [Ue, ie] = m(0), [Se, ne] = m(0), [A, Re] = m();
|
|
168
|
+
E(() => {
|
|
169
169
|
const e = setTimeout(() => {
|
|
170
|
-
|
|
170
|
+
A && localStorage.setItem(fe, JSON.stringify(A));
|
|
171
171
|
}, 400);
|
|
172
172
|
return () => clearTimeout(e);
|
|
173
|
-
}, [
|
|
174
|
-
if (!
|
|
175
|
-
|
|
173
|
+
}, [A]), E(() => {
|
|
174
|
+
if (!b) {
|
|
175
|
+
ie(0), ne(0);
|
|
176
176
|
const e = setTimeout(() => {
|
|
177
177
|
var t;
|
|
178
178
|
(t = l.current) == null || t.reset();
|
|
179
179
|
}, 1500);
|
|
180
180
|
return () => clearTimeout(e);
|
|
181
181
|
}
|
|
182
|
-
}, [
|
|
183
|
-
const
|
|
182
|
+
}, [b]);
|
|
183
|
+
const ae = _(async (e) => {
|
|
184
184
|
if (e) {
|
|
185
185
|
const t = e.getCoordinates();
|
|
186
|
-
|
|
186
|
+
Re(e.getState()), ie((t == null ? void 0 : t.width) ?? 10), ne((t == null ? void 0 : t.height) ?? 10);
|
|
187
187
|
}
|
|
188
188
|
}, []);
|
|
189
|
-
return /* @__PURE__ */ j(
|
|
189
|
+
return /* @__PURE__ */ j(ce, { children: [
|
|
190
190
|
/* @__PURE__ */ r(
|
|
191
|
-
|
|
191
|
+
Ve,
|
|
192
192
|
{
|
|
193
193
|
label: i,
|
|
194
|
-
...
|
|
195
|
-
name:
|
|
194
|
+
...Q,
|
|
195
|
+
name: f,
|
|
196
196
|
className: "mb-0",
|
|
197
|
-
rules: [
|
|
198
|
-
children:
|
|
197
|
+
rules: [xe, ...Q.rules ?? []],
|
|
198
|
+
children: oe
|
|
199
199
|
}
|
|
200
200
|
),
|
|
201
201
|
/* @__PURE__ */ j(
|
|
202
|
-
|
|
202
|
+
de,
|
|
203
203
|
{
|
|
204
|
-
open: !!
|
|
204
|
+
open: !!b,
|
|
205
205
|
maskClosable: !1,
|
|
206
|
-
onOk: () =>
|
|
206
|
+
onOk: () => ee(!1),
|
|
207
207
|
closable: !1,
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
okButtonProps: {
|
|
209
|
+
loading: L === "crop",
|
|
210
|
+
disabled: L === "skip-crop"
|
|
211
|
+
},
|
|
212
|
+
onCancel: Oe,
|
|
213
|
+
footer: (e, { CancelBtn: t, OkBtn: a }) => he ? /* @__PURE__ */ j(pe, { children: [
|
|
210
214
|
/* @__PURE__ */ r(t, {}),
|
|
211
215
|
/* @__PURE__ */ r(
|
|
212
216
|
I,
|
|
213
217
|
{
|
|
214
218
|
type: "primary",
|
|
215
|
-
|
|
219
|
+
loading: L === "skip-crop",
|
|
220
|
+
disabled: L === "crop",
|
|
221
|
+
onClick: () => ee(!0),
|
|
216
222
|
children: c("str.skipCrop")
|
|
217
223
|
}
|
|
218
224
|
),
|
|
219
225
|
/* @__PURE__ */ r(a, {})
|
|
220
|
-
] }) : /* @__PURE__ */ r(
|
|
226
|
+
] }) : /* @__PURE__ */ r(ce, { children: e }),
|
|
221
227
|
destroyOnHidden: !0,
|
|
222
228
|
children: [
|
|
223
229
|
/* @__PURE__ */ r(
|
|
224
|
-
|
|
230
|
+
je,
|
|
225
231
|
{
|
|
226
232
|
ref: l,
|
|
227
233
|
stencilProps: {
|
|
228
234
|
grid: !0
|
|
229
235
|
},
|
|
230
236
|
style: { border: "1px solid black" },
|
|
231
|
-
src:
|
|
237
|
+
src: b,
|
|
232
238
|
onChange: (e) => {
|
|
233
|
-
|
|
239
|
+
ae(e);
|
|
234
240
|
},
|
|
235
|
-
aspectRatio:
|
|
236
|
-
minimum:
|
|
237
|
-
maximum:
|
|
241
|
+
aspectRatio: k ? {
|
|
242
|
+
minimum: k,
|
|
243
|
+
maximum: k
|
|
238
244
|
} : void 0
|
|
239
245
|
}
|
|
240
246
|
),
|
|
241
|
-
/* @__PURE__ */ r("p", { className: "text-center", children: [
|
|
242
|
-
/* @__PURE__ */ r("div", { className: "mt-2 d-flex justify-content-center", children: /* @__PURE__ */ j(
|
|
247
|
+
/* @__PURE__ */ r("p", { className: "text-center", children: [Ue, Se].join(" ⨉ ") }),
|
|
248
|
+
/* @__PURE__ */ r("div", { className: "mt-2 d-flex justify-content-center", children: /* @__PURE__ */ j(pe.Compact, { children: [
|
|
243
249
|
/* @__PURE__ */ r(
|
|
244
250
|
I,
|
|
245
251
|
{
|
|
246
252
|
size: "large",
|
|
247
253
|
tooltip: c("str.rotateLeft"),
|
|
248
|
-
icon: /* @__PURE__ */ r(
|
|
249
|
-
onClick: () =>
|
|
254
|
+
icon: /* @__PURE__ */ r(ze, {}),
|
|
255
|
+
onClick: () => Z(!0)
|
|
250
256
|
}
|
|
251
257
|
),
|
|
252
258
|
/* @__PURE__ */ r(
|
|
253
259
|
I,
|
|
254
260
|
{
|
|
255
261
|
size: "large",
|
|
256
|
-
icon: /* @__PURE__ */ r(
|
|
262
|
+
icon: /* @__PURE__ */ r(Ne, {}),
|
|
257
263
|
tooltip: c("str.rotateRight"),
|
|
258
|
-
onClick: () =>
|
|
264
|
+
onClick: () => Z(!1)
|
|
259
265
|
}
|
|
260
266
|
),
|
|
261
267
|
/* @__PURE__ */ r(
|
|
262
268
|
I,
|
|
263
269
|
{
|
|
264
270
|
size: "large",
|
|
265
|
-
icon: /* @__PURE__ */ r(
|
|
271
|
+
icon: /* @__PURE__ */ r(He, {}),
|
|
266
272
|
tooltip: c("str.flipHorizontal"),
|
|
267
|
-
onClick: () =>
|
|
273
|
+
onClick: () => q("h")
|
|
268
274
|
}
|
|
269
275
|
),
|
|
270
276
|
/* @__PURE__ */ r(
|
|
271
277
|
I,
|
|
272
278
|
{
|
|
273
279
|
size: "large",
|
|
274
|
-
icon: /* @__PURE__ */ r(
|
|
280
|
+
icon: /* @__PURE__ */ r(Le, {}),
|
|
275
281
|
tooltip: c("str.flipVertical"),
|
|
276
|
-
onClick: () =>
|
|
282
|
+
onClick: () => q("v")
|
|
277
283
|
}
|
|
278
284
|
)
|
|
279
285
|
] }) })
|
|
@@ -281,32 +287,32 @@ const Qe = ({
|
|
|
281
287
|
}
|
|
282
288
|
),
|
|
283
289
|
/* @__PURE__ */ r(
|
|
284
|
-
|
|
290
|
+
de,
|
|
285
291
|
{
|
|
286
292
|
open: Ce,
|
|
287
|
-
title:
|
|
293
|
+
title: we,
|
|
288
294
|
footer: null,
|
|
289
|
-
onCancel:
|
|
290
|
-
children: /* @__PURE__ */ r("div", { className: "text-center", children: /* @__PURE__ */ r("img", { alt: "example", style: { maxWidth: "400px" }, src:
|
|
295
|
+
onCancel: ke,
|
|
296
|
+
children: /* @__PURE__ */ r("div", { className: "text-center", children: /* @__PURE__ */ r("img", { alt: "example", style: { maxWidth: "400px" }, src: ye }) })
|
|
291
297
|
}
|
|
292
298
|
)
|
|
293
299
|
] });
|
|
294
|
-
},
|
|
300
|
+
}, _e = ({
|
|
295
301
|
_buttonTitle: o,
|
|
296
302
|
buttonSize: d,
|
|
297
|
-
buttonType:
|
|
303
|
+
buttonType: u,
|
|
298
304
|
fileList: i,
|
|
299
|
-
hidePreview:
|
|
300
|
-
icon:
|
|
301
|
-
loading:
|
|
302
|
-
maxCount:
|
|
303
|
-
onChangeFile:
|
|
304
|
-
onRemove:
|
|
305
|
-
showButtonText:
|
|
306
|
-
handlePreview:
|
|
305
|
+
hidePreview: f,
|
|
306
|
+
icon: g,
|
|
307
|
+
loading: k,
|
|
308
|
+
maxCount: F,
|
|
309
|
+
onChangeFile: O,
|
|
310
|
+
onRemove: h,
|
|
311
|
+
showButtonText: w,
|
|
312
|
+
handlePreview: G,
|
|
307
313
|
setFileList: z,
|
|
308
314
|
showLoadingIndicator: N,
|
|
309
|
-
listType:
|
|
315
|
+
listType: x = "picture"
|
|
310
316
|
}) => /* @__PURE__ */ j(
|
|
311
317
|
Te,
|
|
312
318
|
{
|
|
@@ -315,29 +321,29 @@ const Qe = ({
|
|
|
315
321
|
defaultFileList: i,
|
|
316
322
|
onChange: () => {
|
|
317
323
|
},
|
|
318
|
-
className: (i.length >=
|
|
324
|
+
className: (i.length >= F ? " hide-upload " : "") + " mb-0",
|
|
319
325
|
multiple: !1,
|
|
320
|
-
onPreview:
|
|
321
|
-
onDrop: (s) => (
|
|
322
|
-
listType:
|
|
323
|
-
showUploadList: !
|
|
326
|
+
onPreview: f ? void 0 : G,
|
|
327
|
+
onDrop: (s) => (O(s.dataTransfer.files.item(0)), !1),
|
|
328
|
+
listType: x,
|
|
329
|
+
showUploadList: !f,
|
|
324
330
|
onRemove: (s) => {
|
|
325
|
-
const
|
|
326
|
-
|
|
331
|
+
const B = i.filter((P) => s.uid !== P.uid);
|
|
332
|
+
h == null || h(s), z(B);
|
|
327
333
|
},
|
|
328
|
-
beforeUpload: async (s) => (
|
|
329
|
-
maxCount:
|
|
334
|
+
beforeUpload: async (s) => (O(s), !1),
|
|
335
|
+
maxCount: F,
|
|
330
336
|
children: [
|
|
331
|
-
N && /* @__PURE__ */ r(
|
|
332
|
-
/* @__PURE__ */ r("div", { className: "d-flex flex-column", children: i.length <
|
|
337
|
+
N && /* @__PURE__ */ r(Be, {}),
|
|
338
|
+
/* @__PURE__ */ r("div", { className: "d-flex flex-column", children: i.length < F && (x === "picture-circle" ? /* @__PURE__ */ r(ge, {}) : /* @__PURE__ */ r(
|
|
333
339
|
I,
|
|
334
340
|
{
|
|
335
|
-
loading:
|
|
336
|
-
tooltip:
|
|
341
|
+
loading: k,
|
|
342
|
+
tooltip: w ? void 0 : o,
|
|
337
343
|
size: d,
|
|
338
|
-
icon:
|
|
339
|
-
type:
|
|
340
|
-
children:
|
|
344
|
+
icon: g,
|
|
345
|
+
type: w ? u : "text",
|
|
346
|
+
children: w ? o : void 0
|
|
341
347
|
}
|
|
342
348
|
)) })
|
|
343
349
|
]
|
|
@@ -345,6 +351,6 @@ const Qe = ({
|
|
|
345
351
|
i.length
|
|
346
352
|
);
|
|
347
353
|
export {
|
|
348
|
-
|
|
349
|
-
|
|
354
|
+
_e as UploadComponent,
|
|
355
|
+
Ye as default
|
|
350
356
|
};
|