@kingteza/crud-component 1.2.5 → 1.2.6

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,4 +1,4 @@
1
- import { jsxs as c, jsx as t, Fragment as Z } from "react/jsx-runtime";
1
+ import { jsxs as u, jsx as t, Fragment as Z } from "react/jsx-runtime";
2
2
  import { FileExcelOutlined as x } from "@ant-design/icons";
3
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";
@@ -12,9 +12,9 @@ import { PrintButton as te } from "../common/button/PrintButton.es.js";
12
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
- data: d,
15
+ data: i,
16
16
  idField: H,
17
- loadingData: p,
17
+ loadingData: c,
18
18
  onSubmit: T,
19
19
  paginateProps: J,
20
20
  size: K,
@@ -25,19 +25,19 @@ function be({
25
25
  searchOnMount: C,
26
26
  summary: Q
27
27
  }) {
28
- const { searchable: U, selectable: i, sortable: I, defaultSort: m } = k(() => {
29
- var f, u, j, L, G;
28
+ const { searchable: U, selectable: d, sortable: I, defaultSort: p } = k(() => {
29
+ var f, m, j, L, G;
30
30
  const e = [], r = [], o = [];
31
- let s;
31
+ let a;
32
32
  for (const l of n.filter((Y) => !Y.hidden))
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({
33
+ l.type === "image" || !l.report || ((f = l.report) != null && f.searchable && e.push(l), (m = l.report) != null && m.sortable && (r.push(l), !a && ((j = l.report) != null && j.defaultSort) && (a = l)), l.hideInTable || o.push({
34
34
  id: l.name,
35
35
  label: l.label,
36
36
  lock: (L = l.report) == null ? void 0 : L.lock,
37
37
  alreadySelected: (G = l.report) == null ? void 0 : G.alreadySelected
38
38
  }));
39
39
  return {
40
- defaultSort: s,
40
+ defaultSort: a,
41
41
  searchable: e,
42
42
  sortable: r,
43
43
  selectable: o
@@ -49,57 +49,57 @@ function be({
49
49
  sortBy: e,
50
50
  sortByType: r,
51
51
  showFields: o = [],
52
- ...s
52
+ ...a
53
53
  }) => {
54
54
  const f = [];
55
55
  e && f.push({
56
56
  field: e,
57
57
  sort: r ?? "DESC"
58
58
  }), V(
59
- n.filter((u) => o.includes(u.name)).map((u) => ({ ...u, hideInTable: !1 }))
60
- ), T({ showFields: o, sortBy: f, ...s });
59
+ n.filter((m) => o.includes(m.name)).map((m) => ({ ...m, hideInTable: !1 }))
60
+ ), T({ showFields: o, sortBy: f, ...a });
61
61
  },
62
62
  [n, T]
63
- ), [a] = B.useForm(), [q, W] = w(!1), [A, X] = w(!0);
63
+ ), [s] = 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
- a.validateFields().then((r) => {
67
+ s.validateFields().then((r) => {
68
68
  S(r);
69
69
  }), X(!1);
70
70
  }, 200);
71
71
  return () => clearTimeout(e);
72
72
  }
73
- }, [S, a, A, C]), F(() => {
74
- var r, o, s;
75
- !a.getFieldValue("sortBy") && m && (console.log((r = m.report) == null ? void 0 : r.defaultSort), a.setFieldsValue({
76
- sortBy: m.name,
77
- sortByType: typeof ((o = m.report) == null ? void 0 : o.defaultSort) == "string" ? (s = m.report) == null ? void 0 : s.defaultSort : "ASC"
78
- }));
79
- }, [m, a]), F(() => {
73
+ }, [S, s, A, C]), F(() => {
74
+ var r, o;
75
+ !s.getFieldValue("sortBy") && p && s.setFieldsValue({
76
+ sortBy: p.name,
77
+ sortByType: typeof ((r = p.report) == null ? void 0 : r.defaultSort) == "string" ? (o = p.report) == null ? void 0 : o.defaultSort : "ASC"
78
+ });
79
+ }, [p, s]), F(() => {
80
80
  if (q) {
81
- const e = i.filter((r) => r.alreadySelected).map((r) => r.id);
81
+ const e = d.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
84
  ), W(!1);
85
85
  }
86
- }, [n, q, i]), /* @__PURE__ */ c(O, { className: "w-100", direction: "vertical", children: [
87
- /* @__PURE__ */ c(B, { form: a, layout: "vertical", onFinish: S, children: [
88
- /* @__PURE__ */ c(_, { gutter: [8, 8], children: [
86
+ }, [n, q, d]), /* @__PURE__ */ u(O, { className: "w-100", direction: "vertical", children: [
87
+ /* @__PURE__ */ u(B, { form: s, layout: "vertical", onFinish: S, children: [
88
+ /* @__PURE__ */ u(_, { gutter: [8, 8], children: [
89
89
  U.map((e) => {
90
- var r, o, s;
90
+ var r, o, a;
91
91
  return /* @__PURE__ */ t(
92
92
  b,
93
93
  {
94
94
  ...e.grid ?? D,
95
95
  style: { alignSelf: "end" },
96
- children: (r = e.report) != null && r.customRender ? e.report.customRender(a) : e.type === "date" ? /* @__PURE__ */ t(
96
+ children: (r = e.report) != null && r.customRender ? e.report.customRender(s) : e.type === "date" ? /* @__PURE__ */ t(
97
97
  N,
98
98
  {
99
99
  ...e,
100
100
  type: "date",
101
101
  range: (o = e.report) == null ? void 0 : o.range,
102
- required: !!((s = e.report) != null && s.required),
102
+ required: !!((a = e.report) != null && a.required),
103
103
  readonly: !1,
104
104
  fieldClassName: "mb-0"
105
105
  }
@@ -126,10 +126,10 @@ function be({
126
126
  e.name
127
127
  );
128
128
  }),
129
- !!(i != null && i.length) && /* @__PURE__ */ t(b, { ...le, children: /* @__PURE__ */ t(
129
+ !!(d != null && d.length) && /* @__PURE__ */ t(b, { ...le, children: /* @__PURE__ */ t(
130
130
  ee,
131
131
  {
132
- items: i,
132
+ items: d,
133
133
  name: "showFields",
134
134
  mode: "multiple",
135
135
  label: "Show Fields",
@@ -145,7 +145,7 @@ function be({
145
145
  nameFieldInArray: "label",
146
146
  fieldId: "id",
147
147
  className: "mb-0",
148
- dropdownRender: (e) => /* @__PURE__ */ c(Z, { children: [
148
+ dropdownRender: (e) => /* @__PURE__ */ u(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__ */ u(_, { children: [
157
157
  /* @__PURE__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
158
158
  R,
159
159
  {
@@ -184,7 +184,7 @@ function be({
184
184
  ] })
185
185
  }
186
186
  ) }),
187
- v ? v(a) : null
187
+ v ? v(s) : null
188
188
  ] }),
189
189
  /* @__PURE__ */ t(
190
190
  z,
@@ -193,19 +193,19 @@ function be({
193
193
  type: "primary",
194
194
  block: !0,
195
195
  htmlType: "submit",
196
- disabled: p,
196
+ disabled: c,
197
197
  children: "Submit"
198
198
  }
199
199
  )
200
200
  ] }),
201
- /* @__PURE__ */ c(O, { children: [
201
+ /* @__PURE__ */ u(O, { children: [
202
202
  !!h && /* @__PURE__ */ t(
203
203
  te,
204
204
  {
205
- disabled: p || !d.length,
205
+ disabled: c || !i.length,
206
206
  onClick: () => h == null ? void 0 : h({
207
207
  tableId: "#crud-table table",
208
- data: d,
208
+ data: i,
209
209
  fields: g.map((e) => ({
210
210
  ...e,
211
211
  render: $(e)
@@ -216,10 +216,10 @@ function be({
216
216
  !!y && /* @__PURE__ */ t(
217
217
  z,
218
218
  {
219
- disabled: p || !d.length,
219
+ disabled: c || !i.length,
220
220
  onClick: () => y == null ? void 0 : y({
221
221
  tableId: "#crud-table table",
222
- data: d,
222
+ data: i,
223
223
  fields: g.map((e) => ({
224
224
  ...e,
225
225
  render: $(e)
@@ -227,7 +227,7 @@ function be({
227
227
  }),
228
228
  icon: /* @__PURE__ */ t(x, {}),
229
229
  className: `group
230
- ${p || !d.length ? "" : "!bg-green-700 hover:!bg-green-600 !text-white !border-green-700 hover:!border-green-600"}
230
+ ${c || !i.length ? "" : "!bg-green-700 hover:!bg-green-600 !text-white !border-green-700 hover:!border-green-600"}
231
231
 
232
232
  `,
233
233
  children: "Excel"
@@ -239,11 +239,11 @@ function be({
239
239
  P,
240
240
  {
241
241
  minusHeight: M,
242
- data: d,
242
+ data: i,
243
243
  size: K,
244
244
  fields: g,
245
245
  idField: H,
246
- loadingData: p,
246
+ loadingData: c,
247
247
  paginateProps: J,
248
248
  viewable: !1
249
249
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime");;/* empty css */const d=require("@ant-design/icons"),F=require("antd"),N=require("mime"),c=require("react"),z=require("../locale/index.cjs.js"),G=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),J=require("../common/layout/VerticalSpace.cjs.js"),K=require("../util/CrudUtil.cjs.js");function Q({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:k,maxCount:q=1,block:E,fieldHelper:_,...$}){const f=F.Form.useFormInstance(),H=K.getRealName(n,"upsertFieldName"),x=F.Form.useWatch(H,f),[O,b]=c.useState(!1),[V,R]=c.useState(!1),A=c.useCallback(async r=>{var i,u;try{const{file:o}=r,g=o.name;b(!0),R(!0),a==null||a(!0);const C=g??"",S=C.split("."),W=S[S.length-1],B=s.generateFileName(C),M=`${await s.getInitialPath()}/${B}.${W}`;console.log({filePath:M});const D=await s.upload({...o,originFileObj:o},M);a==null||a(!1),f.setFieldValue(n,D),(i=r.onSuccess)==null||i.call(r,D)}catch(o){(u=r.onError)==null||u.call(r,o)}finally{b(!1)}},[f,n,a,s]),[w,I]=c.useState([]);c.useEffect(()=>{!V&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const i=N.getType(r),u=r.split("/").pop(),o=await s.getRealUrl(r);return{uid:r,url:o,type:i,name:u}})).then(r=>I(()=>{const i=r.map(({url:u,type:o,uid:g,name:C})=>({uid:g,url:u,type:o,response:g,thumbUrl:u,name:C}));return console.log(i),i}))},[x,V,O,s]);const L=c.useCallback(async r=>{const i=r.response,u=i||f.getFieldValue(n);await s.delete(u),h==null||h(),r&&f.setFieldsValue({[n]:null})},[f,n,h,s]);return t.jsxs(F.Form.Item,{label:e,required:l,name:n,className:j,rules:[...l?G.required(e):[],...k??[]],help:_,children:[t.jsx("input",{hidden:!0}),t.jsx(F.Upload,{...$,fileList:w,className:((w==null?void 0:w.length)??0)>=q?"hide-upload":"",maxCount:q,customRequest:A,onRemove:L,listType:"picture",onChange:({fileList:r})=>{I(r)},style:E?{width:"100%"}:void 0,children:t.jsx(p,{loading:O,children:"Upload File"})})]})}const X=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:N.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(U,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},U=({url:n,mimeType:e="",fileName:l})=>{const s=c.useMemo(()=>e!=null&&e.includes("image")?"image":e!=null&&e.includes("pdf")?"pdf":e!=null&&e.includes("word")?"word":e!=null&&e.includes("text")?"text":e!=null&&e.includes("presentation")?"presentation":e!=null&&e.includes("excel")||e!=null&&e.includes("spreadsheet")?"excel":"file",[e]),a=c.useMemo(()=>{switch(s){case"image":return t.jsx(d.FileImageOutlined,{});case"pdf":return t.jsx(d.FilePdfOutlined,{});case"word":return t.jsx(d.FileWordOutlined,{});case"text":return t.jsx(d.FileTextOutlined,{});case"excel":return t.jsx(d.FileExcelOutlined,{});case"presentation":return t.jsx(d.FilePptOutlined,{});default:return t.jsx(d.FileOutlined,{})}},[s]),[h,j]=c.useState(!1),{t:P}=z.useTranslationLib();return s!=="file"&&s!=="text"?t.jsxs(t.Fragment,{children:[t.jsx(F.Modal,{open:h,title:l,onCancel:()=>j(!1),footer:t.jsx(t.Fragment,{}),width:"100%",style:{top:"8px",minHeight:"700px"},destroyOnHidden:!0,children:t.jsxs(J,{children:[t.jsx(p,{tooltip:l,icon:t.jsx(d.ExportOutlined,{}),target:"_blank",href:n,style:{textDecoration:"none"},children:P("str.openInNewTab")}),s==="image"?t.jsx("img",{src:n,alt:l,style:{width:"100%"}}):s==="pdf"?t.jsxs("iframe",{title:l,src:n,width:"100%",height:"700px",children:["This browser does not support PDFs. Please download the PDF to view it:",t.jsx("a",{href:n,children:"Download PDF"})]}):t.jsxs("iframe",{title:l,src:`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(n)}`,width:"100%",height:"700px",children:["This browser does not support open ",s.toUpperCase(),". Please download the",s.toUpperCase()," to view it:",t.jsxs("a",{href:n,children:["Download ",s.toUpperCase()]}),"."]})]})}),t.jsx(p,{tooltip:l,icon:a,shape:"circle",onClick:()=>j(!0)})]}):t.jsx(p,{tooltip:l,icon:a,target:"_blank",href:n,shape:"circle"})};exports.FileCellValue=U;exports.FileCrudCellValue=X;exports.default=Q;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime");;/* empty css */const d=require("@ant-design/icons"),F=require("antd"),D=require("mime"),c=require("react"),z=require("../locale/index.cjs.js"),G=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),J=require("../common/layout/VerticalSpace.cjs.js"),K=require("../util/CrudUtil.cjs.js");function Q({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:U,maxCount:q=1,block:k,fieldHelper:E,..._}){const f=F.Form.useFormInstance(),$=K.getRealName(n,"upsertFieldName"),x=F.Form.useWatch($,f),[O,b]=c.useState(!1),[V,H]=c.useState(!1),R=c.useCallback(async r=>{var o,i;try{const{file:u}=r,g=u.name;b(!0),H(!0),a==null||a(!0);const C=g??"",S=C.split("."),L=S[S.length-1],W=s.generateFileName(C),B=`${await s.getInitialPath()}/${W}.${L}`,M=await s.upload({...u,originFileObj:u},B);a==null||a(!1),f.setFieldValue(n,M),(o=r.onSuccess)==null||o.call(r,M)}catch(u){(i=r.onError)==null||i.call(r,u)}finally{b(!1)}},[f,n,a,s]),[w,I]=c.useState([]);c.useEffect(()=>{!V&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const o=D.getType(r),i=r.split("/").pop(),u=await s.getRealUrl(r);return{uid:r,url:u,type:o,name:i}})).then(r=>I(()=>r.map(({url:i,type:u,uid:g,name:C})=>({uid:g,url:i,type:u,response:g,thumbUrl:i,name:C}))))},[x,V,O,s]);const A=c.useCallback(async r=>{const o=r.response,i=o||f.getFieldValue(n);await s.delete(i),h==null||h(),r&&f.setFieldsValue({[n]:null})},[f,n,h,s]);return t.jsxs(F.Form.Item,{label:e,required:l,name:n,className:j,rules:[...l?G.required(e):[],...U??[]],help:E,children:[t.jsx("input",{hidden:!0}),t.jsx(F.Upload,{..._,fileList:w,className:((w==null?void 0:w.length)??0)>=q?"hide-upload":"",maxCount:q,customRequest:R,onRemove:A,listType:"picture",onChange:({fileList:r})=>{I(r)},style:k?{width:"100%"}:void 0,children:t.jsx(p,{loading:O,children:"Upload File"})})]})}const X=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:D.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(N,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},N=({url:n,mimeType:e="",fileName:l})=>{const s=c.useMemo(()=>e!=null&&e.includes("image")?"image":e!=null&&e.includes("pdf")?"pdf":e!=null&&e.includes("word")?"word":e!=null&&e.includes("text")?"text":e!=null&&e.includes("presentation")?"presentation":e!=null&&e.includes("excel")||e!=null&&e.includes("spreadsheet")?"excel":"file",[e]),a=c.useMemo(()=>{switch(s){case"image":return t.jsx(d.FileImageOutlined,{});case"pdf":return t.jsx(d.FilePdfOutlined,{});case"word":return t.jsx(d.FileWordOutlined,{});case"text":return t.jsx(d.FileTextOutlined,{});case"excel":return t.jsx(d.FileExcelOutlined,{});case"presentation":return t.jsx(d.FilePptOutlined,{});default:return t.jsx(d.FileOutlined,{})}},[s]),[h,j]=c.useState(!1),{t:P}=z.useTranslationLib();return s!=="file"&&s!=="text"?t.jsxs(t.Fragment,{children:[t.jsx(F.Modal,{open:h,title:l,onCancel:()=>j(!1),footer:t.jsx(t.Fragment,{}),width:"100%",style:{top:"8px",minHeight:"700px"},destroyOnHidden:!0,children:t.jsxs(J,{children:[t.jsx(p,{tooltip:l,icon:t.jsx(d.ExportOutlined,{}),target:"_blank",href:n,style:{textDecoration:"none"},children:P("str.openInNewTab")}),s==="image"?t.jsx("img",{src:n,alt:l,style:{width:"100%"}}):s==="pdf"?t.jsxs("iframe",{title:l,src:n,width:"100%",height:"700px",children:["This browser does not support PDFs. Please download the PDF to view it:",t.jsx("a",{href:n,children:"Download PDF"})]}):t.jsxs("iframe",{title:l,src:`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(n)}`,width:"100%",height:"700px",children:["This browser does not support open ",s.toUpperCase(),". Please download the",s.toUpperCase()," to view it:",t.jsxs("a",{href:n,children:["Download ",s.toUpperCase()]}),"."]})]})}),t.jsx(p,{tooltip:l,icon:a,shape:"circle",onClick:()=>j(!0)})]}):t.jsx(p,{tooltip:l,icon:a,target:"_blank",href:n,shape:"circle"})};exports.FileCellValue=N;exports.FileCrudCellValue=X;exports.default=Q;
@@ -1,72 +1,67 @@
1
- import { jsxs as f, jsx as s, Fragment as O } from "react/jsx-runtime";
1
+ import { jsxs as f, jsx as r, Fragment as O } from "react/jsx-runtime";
2
2
  /* empty css */
3
3
  import { FileOutlined as K, FilePptOutlined as Q, FileExcelOutlined as X, FileTextOutlined as Y, FileWordOutlined as Z, FilePdfOutlined as v, FileImageOutlined as y, ExportOutlined as m } from "@ant-design/icons";
4
4
  import { Form as P, Upload as T, Modal as tt } from "antd";
5
- import H from "mime";
6
- import { useState as p, useCallback as $, useEffect as S, useMemo as j } from "react";
5
+ import j from "mime";
6
+ import { useState as p, useCallback as M, useEffect as H, useMemo as $ } from "react";
7
7
  import { useTranslationLib as et } from "../locale/index.es.js";
8
- import st from "../util/ValidationUtil.es.js";
8
+ import rt from "../util/ValidationUtil.es.js";
9
9
  import C from "../common/button/Button.es.js";
10
- import lt from "../common/layout/VerticalSpace.es.js";
11
- import rt from "../util/CrudUtil.es.js";
12
- function gt({
10
+ import st from "../common/layout/VerticalSpace.es.js";
11
+ import lt from "../util/CrudUtil.es.js";
12
+ function xt({
13
13
  name: n,
14
14
  label: t,
15
- required: l,
15
+ required: s,
16
16
  provider: e,
17
17
  onUploading: a,
18
18
  onRemoved: u,
19
19
  fieldClassName: F,
20
20
  accept: b,
21
- rules: A,
21
+ rules: S,
22
22
  maxCount: I = 1,
23
- block: L,
24
- fieldHelper: W,
25
- ..._
23
+ block: A,
24
+ fieldHelper: L,
25
+ ...W
26
26
  }) {
27
- const d = P.useFormInstance(), q = rt.getRealName(n, "upsertFieldName"), h = P.useWatch(q, d), [V, D] = p(!1), [N, B] = p(!1), R = $(
28
- async (r) => {
29
- var c, i;
27
+ const d = P.useFormInstance(), _ = lt.getRealName(n, "upsertFieldName"), h = P.useWatch(_, d), [V, D] = p(!1), [N, q] = p(!1), B = M(
28
+ async (l) => {
29
+ var o, i;
30
30
  try {
31
- const { file: o } = r, g = o.name;
32
- D(!0), B(!0), a == null || a(!0);
33
- const x = g ?? "", k = x.split("."), G = k[k.length - 1], J = e.generateFileName(x), E = `${await e.getInitialPath()}/${J}.${G}`;
34
- console.log({ filePath: E });
35
- const M = await e.upload(
36
- { ...o, originFileObj: o },
37
- E
31
+ const { file: c } = l, x = c.name;
32
+ D(!0), q(!0), a == null || a(!0);
33
+ const g = x ?? "", k = g.split("."), z = k[k.length - 1], G = e.generateFileName(g), J = `${await e.getInitialPath()}/${G}.${z}`, E = await e.upload(
34
+ { ...c, originFileObj: c },
35
+ J
38
36
  );
39
- a == null || a(!1), d.setFieldValue(n, M), (c = r.onSuccess) == null || c.call(r, M);
40
- } catch (o) {
41
- (i = r.onError) == null || i.call(r, o);
37
+ a == null || a(!1), d.setFieldValue(n, E), (o = l.onSuccess) == null || o.call(l, E);
38
+ } catch (c) {
39
+ (i = l.onError) == null || i.call(l, c);
42
40
  } finally {
43
41
  D(!1);
44
42
  }
45
43
  },
46
44
  [d, n, a, e]
47
45
  ), [w, U] = p([]);
48
- S(() => {
46
+ H(() => {
49
47
  !N && h && Promise.all(
50
48
  (Array.isArray(h) ? h : [h]).map(
51
- async (r) => {
52
- const c = H.getType(r), i = r.split("/").pop(), o = await e.getRealUrl(r);
49
+ async (l) => {
50
+ const o = j.getType(l), i = l.split("/").pop(), c = await e.getRealUrl(l);
53
51
  return {
54
- uid: r,
55
- url: o,
56
- type: c,
52
+ uid: l,
53
+ url: c,
54
+ type: o,
57
55
  name: i
58
56
  };
59
57
  }
60
58
  )
61
- ).then((r) => U(() => {
62
- const c = r.map(({ url: i, type: o, uid: g, name: x }) => ({ uid: g, url: i, type: o, response: g, thumbUrl: i, name: x }));
63
- return console.log(c), c;
64
- }));
59
+ ).then((l) => U(() => l.map(({ url: i, type: c, uid: x, name: g }) => ({ uid: x, url: i, type: c, response: x, thumbUrl: i, name: g }))));
65
60
  }, [h, N, V, e]);
66
- const z = $(
67
- async (r) => {
68
- const c = r.response, i = c || d.getFieldValue(n);
69
- await e.delete(i), u == null || u(), r && d.setFieldsValue({ [n]: null });
61
+ const R = M(
62
+ async (l) => {
63
+ const o = l.response, i = o || d.getFieldValue(n);
64
+ await e.delete(i), u == null || u(), l && d.setFieldsValue({ [n]: null });
70
65
  },
71
66
  [d, n, u, e]
72
67
  );
@@ -74,104 +69,104 @@ function gt({
74
69
  P.Item,
75
70
  {
76
71
  label: t,
77
- required: l,
72
+ required: s,
78
73
  name: n,
79
74
  className: F,
80
75
  rules: [
81
- ...l ? st.required(t) : [],
82
- ...A ?? []
76
+ ...s ? rt.required(t) : [],
77
+ ...S ?? []
83
78
  ],
84
- help: W,
79
+ help: L,
85
80
  children: [
86
- /* @__PURE__ */ s("input", { hidden: !0 }),
87
- /* @__PURE__ */ s(
81
+ /* @__PURE__ */ r("input", { hidden: !0 }),
82
+ /* @__PURE__ */ r(
88
83
  T,
89
84
  {
90
- ..._,
85
+ ...W,
91
86
  fileList: w,
92
87
  className: ((w == null ? void 0 : w.length) ?? 0) >= I ? "hide-upload" : "",
93
88
  maxCount: I,
94
- customRequest: R,
95
- onRemove: z,
89
+ customRequest: B,
90
+ onRemove: R,
96
91
  listType: "picture",
97
- onChange: ({ fileList: r }) => {
98
- U(r);
92
+ onChange: ({ fileList: l }) => {
93
+ U(l);
99
94
  },
100
- style: L ? { width: "100%" } : void 0,
101
- children: /* @__PURE__ */ s(C, { loading: V, children: "Upload File" })
95
+ style: A ? { width: "100%" } : void 0,
96
+ children: /* @__PURE__ */ r(C, { loading: V, children: "Upload File" })
102
97
  }
103
98
  )
104
99
  ]
105
100
  }
106
101
  );
107
102
  }
108
- const xt = ({ provider: n, value: t }) => {
109
- const [l, e] = p();
110
- return S(() => {
103
+ const gt = ({ provider: n, value: t }) => {
104
+ const [s, e] = p();
105
+ return H(() => {
111
106
  t && n.getRealUrl(t).then((a) => {
112
107
  e({
113
- mimeType: H.getType(t),
108
+ mimeType: j.getType(t),
114
109
  url: a,
115
110
  fileName: t.split("/").pop() ?? t
116
111
  });
117
112
  });
118
- }, [n, t]), l ? /* @__PURE__ */ s(
113
+ }, [n, t]), s ? /* @__PURE__ */ r(
119
114
  nt,
120
115
  {
121
- fileName: l.fileName,
122
- url: l == null ? void 0 : l.url,
123
- mimeType: l == null ? void 0 : l.mimeType
116
+ fileName: s.fileName,
117
+ url: s == null ? void 0 : s.url,
118
+ mimeType: s == null ? void 0 : s.mimeType
124
119
  }
125
- ) : /* @__PURE__ */ s(O, {});
126
- }, nt = ({ url: n, mimeType: t = "", fileName: l }) => {
127
- const e = j(() => t != null && t.includes("image") ? "image" : t != null && t.includes("pdf") ? "pdf" : t != null && t.includes("word") ? "word" : t != null && t.includes("text") ? "text" : t != null && t.includes("presentation") ? "presentation" : t != null && t.includes("excel") || t != null && t.includes("spreadsheet") ? "excel" : "file", [t]), a = j(() => {
120
+ ) : /* @__PURE__ */ r(O, {});
121
+ }, nt = ({ url: n, mimeType: t = "", fileName: s }) => {
122
+ const e = $(() => t != null && t.includes("image") ? "image" : t != null && t.includes("pdf") ? "pdf" : t != null && t.includes("word") ? "word" : t != null && t.includes("text") ? "text" : t != null && t.includes("presentation") ? "presentation" : t != null && t.includes("excel") || t != null && t.includes("spreadsheet") ? "excel" : "file", [t]), a = $(() => {
128
123
  switch (e) {
129
124
  case "image":
130
- return /* @__PURE__ */ s(y, {});
125
+ return /* @__PURE__ */ r(y, {});
131
126
  case "pdf":
132
- return /* @__PURE__ */ s(v, {});
127
+ return /* @__PURE__ */ r(v, {});
133
128
  case "word":
134
- return /* @__PURE__ */ s(Z, {});
129
+ return /* @__PURE__ */ r(Z, {});
135
130
  case "text":
136
- return /* @__PURE__ */ s(Y, {});
131
+ return /* @__PURE__ */ r(Y, {});
137
132
  case "excel":
138
- return /* @__PURE__ */ s(X, {});
133
+ return /* @__PURE__ */ r(X, {});
139
134
  case "presentation":
140
- return /* @__PURE__ */ s(Q, {});
135
+ return /* @__PURE__ */ r(Q, {});
141
136
  default:
142
- return /* @__PURE__ */ s(K, {});
137
+ return /* @__PURE__ */ r(K, {});
143
138
  }
144
139
  }, [e]), [u, F] = p(!1), { t: b } = et();
145
140
  return e !== "file" && e !== "text" ? /* @__PURE__ */ f(O, { children: [
146
- /* @__PURE__ */ s(
141
+ /* @__PURE__ */ r(
147
142
  tt,
148
143
  {
149
144
  open: u,
150
- title: l,
145
+ title: s,
151
146
  onCancel: () => F(!1),
152
- footer: /* @__PURE__ */ s(O, {}),
147
+ footer: /* @__PURE__ */ r(O, {}),
153
148
  width: "100%",
154
149
  style: { top: "8px", minHeight: "700px" },
155
150
  destroyOnHidden: !0,
156
- children: /* @__PURE__ */ f(lt, { children: [
157
- /* @__PURE__ */ s(
151
+ children: /* @__PURE__ */ f(st, { children: [
152
+ /* @__PURE__ */ r(
158
153
  C,
159
154
  {
160
- tooltip: l,
161
- icon: /* @__PURE__ */ s(m, {}),
155
+ tooltip: s,
156
+ icon: /* @__PURE__ */ r(m, {}),
162
157
  target: "_blank",
163
158
  href: n,
164
159
  style: { textDecoration: "none" },
165
160
  children: b("str.openInNewTab")
166
161
  }
167
162
  ),
168
- e === "image" ? /* @__PURE__ */ s("img", { src: n, alt: l, style: { width: "100%" } }) : e === "pdf" ? /* @__PURE__ */ f("iframe", { title: l, src: n, width: "100%", height: "700px", children: [
163
+ e === "image" ? /* @__PURE__ */ r("img", { src: n, alt: s, style: { width: "100%" } }) : e === "pdf" ? /* @__PURE__ */ f("iframe", { title: s, src: n, width: "100%", height: "700px", children: [
169
164
  "This browser does not support PDFs. Please download the PDF to view it:",
170
- /* @__PURE__ */ s("a", { href: n, children: "Download PDF" })
165
+ /* @__PURE__ */ r("a", { href: n, children: "Download PDF" })
171
166
  ] }) : /* @__PURE__ */ f(
172
167
  "iframe",
173
168
  {
174
- title: l,
169
+ title: s,
175
170
  src: `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
176
171
  n
177
172
  )}`,
@@ -194,19 +189,19 @@ const xt = ({ provider: n, value: t }) => {
194
189
  ] })
195
190
  }
196
191
  ),
197
- /* @__PURE__ */ s(
192
+ /* @__PURE__ */ r(
198
193
  C,
199
194
  {
200
- tooltip: l,
195
+ tooltip: s,
201
196
  icon: a,
202
197
  shape: "circle",
203
198
  onClick: () => F(!0)
204
199
  }
205
200
  )
206
- ] }) : /* @__PURE__ */ s(
201
+ ] }) : /* @__PURE__ */ r(
207
202
  C,
208
203
  {
209
- tooltip: l,
204
+ tooltip: s,
210
205
  icon: a,
211
206
  target: "_blank",
212
207
  href: n,
@@ -216,6 +211,6 @@ const xt = ({ provider: n, value: t }) => {
216
211
  };
217
212
  export {
218
213
  nt as FileCellValue,
219
- xt as FileCrudCellValue,
220
- gt as default
214
+ gt as FileCrudCellValue,
215
+ xt as default
221
216
  };
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var E=(e,a,t)=>a in e?p(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t;var F=(e,a,t)=>E(e,typeof a!="symbol"?a+"":a,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime");;/* empty css */const A=require("@ant-design/icons"),n=require("antd"),q=require("path-browserify"),i=require("react"),D=require("../util/NumberUtil.cjs.js"),M=require("../util/ValidationUtil.cjs.js"),H=require("uuid"),T=require("../common/picker/ImagePicker.cjs.js");class w{}class W extends w{constructor(t="",s=""){super();F(this,"rootPath");F(this,"subPath");this.rootPath=t,this.subPath=s}cloneFilePath(t){const s=q.parse(t),l=`${s.name}_cloned_${D.default.randInt(1e5)}`;return q.format({dir:s.dir,ext:s.ext,name:l})}generateFileName(t){return`${t.split(".")[0]}_${H.v4().replace("-","")}`}}function z({name:e,label:a,required:t,provider:s,onUploading:l,aspectRatio:P,onRemoved:o,fieldClassName:N,hideLabel:V=!1,listType:g,fieldHelper:y}){const c=n.Form.useFormInstance(),d=n.Form.useWatch(e,c),[I,$]=i.useState(!1),x=i.useCallback(async(r,b)=>{if(b){l==null||l(!0);const f=r.name,m=f.split("."),S=m[m.length-1],_=s.generateFileName(f),O=`${await s.getInitialPath()}/${_}.${S}`,k=await s.upload(r,O);$(!0),l==null||l(!1),c.setFieldValue(e,k)}else{console.log(r);const f=c.getFieldsValue(),m=await s.delete(f[e]);o==null||o(),m&&c.setFieldsValue({[e]:null})}},[c,e,o,l,s]),[h,j]=i.useState();return i.useEffect(()=>{!I&&d?s.getRealUrl(d).then(j):j(h)},[d,I,s,h]),u.jsxs(n.Form.Item,{rules:t?M.required(a):[],label:V?null:a,required:t,name:e,help:y,children:[u.jsx(T.default,{noStyle:!0,listType:g,aspectRatio:P,values:h,onRemove:r=>{r&&x(r,!1)},onAdd:async r=>{r&&await x(r,!0)},className:N}),u.jsx(n.Input,{hidden:!0})]})}const B=({provider:e,value:a})=>{const[t,s]=i.useState();return i.useEffect(()=>{a&&e.getRealUrl(a).then(s)},[e,a]),t?u.jsx(C,{url:t}):u.jsx(u.Fragment,{})},C=({url:e})=>u.jsx(n.Avatar,{className:"p-0",children:u.jsx(n.Image,{className:"m-0 p-0 position-relative",src:e,preview:{mask:u.jsx(A.EyeOutlined,{})}})});exports.FileDownloadProvider=w;exports.FileUploadProvider=W;exports.ImageCellValue=C;exports.ImageCrudCellValue=B;exports.default=z;
1
+ "use strict";var p=Object.defineProperty;var E=(e,a,t)=>a in e?p(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t;var F=(e,a,t)=>E(e,typeof a!="symbol"?a+"":a,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime");;/* empty css */const A=require("@ant-design/icons"),n=require("antd"),q=require("path-browserify"),i=require("react"),D=require("../util/NumberUtil.cjs.js"),M=require("../util/ValidationUtil.cjs.js"),H=require("uuid"),T=require("../common/picker/ImagePicker.cjs.js");class w{}class W extends w{constructor(t="",s=""){super();F(this,"rootPath");F(this,"subPath");this.rootPath=t,this.subPath=s}cloneFilePath(t){const s=q.parse(t),l=`${s.name}_cloned_${D.default.randInt(1e5)}`;return q.format({dir:s.dir,ext:s.ext,name:l})}generateFileName(t){return`${t.split(".")[0]}_${H.v4().replace("-","")}`}}function z({name:e,label:a,required:t,provider:s,onUploading:l,aspectRatio:P,onRemoved:o,fieldClassName:N,hideLabel:V=!1,listType:g,fieldHelper:y}){const c=n.Form.useFormInstance(),d=n.Form.useWatch(e,c),[I,$]=i.useState(!1),x=i.useCallback(async(u,b)=>{if(b){l==null||l(!0);const f=u.name,m=f.split("."),S=m[m.length-1],_=s.generateFileName(f),O=`${await s.getInitialPath()}/${_}.${S}`,k=await s.upload(u,O);$(!0),l==null||l(!1),c.setFieldValue(e,k)}else{const f=c.getFieldsValue(),m=await s.delete(f[e]);o==null||o(),m&&c.setFieldsValue({[e]:null})}},[c,e,o,l,s]),[h,j]=i.useState();return i.useEffect(()=>{!I&&d?s.getRealUrl(d).then(j):j(h)},[d,I,s,h]),r.jsxs(n.Form.Item,{rules:t?M.required(a):[],label:V?null:a,required:t,name:e,help:y,children:[r.jsx(T.default,{noStyle:!0,listType:g,aspectRatio:P,values:h,onRemove:u=>{u&&x(u,!1)},onAdd:async u=>{u&&await x(u,!0)},className:N}),r.jsx(n.Input,{hidden:!0})]})}const B=({provider:e,value:a})=>{const[t,s]=i.useState();return i.useEffect(()=>{a&&e.getRealUrl(a).then(s)},[e,a]),t?r.jsx(C,{url:t}):r.jsx(r.Fragment,{})},C=({url:e})=>r.jsx(n.Avatar,{className:"p-0",children:r.jsx(n.Image,{className:"m-0 p-0 position-relative",src:e,preview:{mask:r.jsx(A.EyeOutlined,{})}})});exports.FileDownloadProvider=w;exports.FileUploadProvider=W;exports.ImageCellValue=C;exports.ImageCrudCellValue=B;exports.default=z;
@@ -1,6 +1,6 @@
1
1
  var A = Object.defineProperty;
2
- var E = (e, a, t) => a in e ? A(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
3
- var h = (e, a, t) => E(e, typeof a != "symbol" ? a + "" : a, t);
2
+ var E = (e, s, t) => s in e ? A(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
+ var h = (e, s, t) => E(e, typeof s != "symbol" ? s + "" : s, t);
4
4
  import { jsxs as S, jsx as i, Fragment as D } from "react/jsx-runtime";
5
5
  /* empty css */
6
6
  import { EyeOutlined as H } from "@ant-design/icons";
@@ -14,17 +14,17 @@ import L from "../common/picker/ImagePicker.es.js";
14
14
  class M {
15
15
  }
16
16
  class le extends M {
17
- constructor(t = "", s = "") {
17
+ constructor(t = "", a = "") {
18
18
  super();
19
19
  h(this, "rootPath");
20
20
  h(this, "subPath");
21
- this.rootPath = t, this.subPath = s;
21
+ this.rootPath = t, this.subPath = a;
22
22
  }
23
23
  cloneFilePath(t) {
24
- const s = w.parse(t), l = `${s.name}_cloned_${G.randInt(1e5)}`;
24
+ const a = w.parse(t), l = `${a.name}_cloned_${G.randInt(1e5)}`;
25
25
  return w.format({
26
- dir: s.dir,
27
- ext: s.ext,
26
+ dir: a.dir,
27
+ ext: a.ext,
28
28
  name: l
29
29
  });
30
30
  }
@@ -34,9 +34,9 @@ class le extends M {
34
34
  }
35
35
  function re({
36
36
  name: e,
37
- label: a,
37
+ label: s,
38
38
  required: t,
39
- provider: s,
39
+ provider: a,
40
40
  onUploading: l,
41
41
  aspectRatio: p,
42
42
  onRemoved: c,
@@ -45,27 +45,26 @@ function re({
45
45
  listType: C,
46
46
  fieldHelper: $
47
47
  }) {
48
- const n = F.useFormInstance(), u = F.useWatch(e, n), [I, g] = P(!1), N = B(
49
- async (r, b) => {
50
- if (b) {
48
+ const n = F.useFormInstance(), o = F.useWatch(e, n), [I, b] = P(!1), N = B(
49
+ async (r, g) => {
50
+ if (g) {
51
51
  l == null || l(!0);
52
- const m = r.name, o = m.split("."), k = o[o.length - 1], O = s.generateFileName(m), _ = `${await s.getInitialPath()}/${O}.${k}`, j = await s.upload(r, _);
53
- g(!0), l == null || l(!1), n.setFieldValue(e, j);
52
+ const m = r.name, u = m.split("."), k = u[u.length - 1], O = a.generateFileName(m), _ = `${await a.getInitialPath()}/${O}.${k}`, j = await a.upload(r, _);
53
+ b(!0), l == null || l(!1), n.setFieldValue(e, j);
54
54
  } else {
55
- console.log(r);
56
- const m = n.getFieldsValue(), o = await s.delete(m[e]);
57
- c == null || c(), o && n.setFieldsValue({ [e]: null });
55
+ const m = n.getFieldsValue(), u = await a.delete(m[e]);
56
+ c == null || c(), u && n.setFieldsValue({ [e]: null });
58
57
  }
59
58
  },
60
- [n, e, c, l, s]
59
+ [n, e, c, l, a]
61
60
  ), [f, d] = P();
62
61
  return V(() => {
63
- !I && u ? s.getRealUrl(u).then(d) : d(f);
64
- }, [u, I, s, f]), /* @__PURE__ */ S(
62
+ !I && o ? a.getRealUrl(o).then(d) : d(f);
63
+ }, [o, I, a, f]), /* @__PURE__ */ S(
65
64
  F.Item,
66
65
  {
67
- rules: t ? J.required(a) : [],
68
- label: y ? null : a,
66
+ rules: t ? J.required(s) : [],
67
+ label: y ? null : s,
69
68
  required: t,
70
69
  name: e,
71
70
  help: $,
@@ -91,11 +90,11 @@ function re({
91
90
  }
92
91
  );
93
92
  }
94
- const ie = ({ provider: e, value: a }) => {
95
- const [t, s] = P();
93
+ const ie = ({ provider: e, value: s }) => {
94
+ const [t, a] = P();
96
95
  return V(() => {
97
- a && e.getRealUrl(a).then(s);
98
- }, [e, a]), t ? /* @__PURE__ */ i(Q, { url: t }) : /* @__PURE__ */ i(D, {});
96
+ s && e.getRealUrl(s).then(a);
97
+ }, [e, s]), t ? /* @__PURE__ */ i(Q, { url: t }) : /* @__PURE__ */ i(D, {});
99
98
  }, Q = ({ url: e }) => /* @__PURE__ */ i(q, { className: "p-0", children: /* @__PURE__ */ i(
100
99
  z,
101
100
  {