@kingteza/crud-component 1.44.1 → 1.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/_virtual/index.cjs.js +1 -1
  2. package/dist/_virtual/index.cjs2.js +1 -1
  3. package/dist/_virtual/index.cjs3.js +1 -1
  4. package/dist/_virtual/index.es.js +2 -5
  5. package/dist/_virtual/index.es2.js +5 -5
  6. package/dist/_virtual/index.es3.js +5 -2
  7. package/dist/common/picker/ImagePicker.cjs.js +1 -1
  8. package/dist/common/picker/ImagePicker.d.ts +6 -2
  9. package/dist/common/picker/ImagePicker.es.js +278 -232
  10. package/dist/crud/ImageCrudField.cjs.js +1 -1
  11. package/dist/crud/ImageCrudField.d.ts +3 -1
  12. package/dist/crud/ImageCrudField.es.js +133 -96
  13. package/dist/crud/modal/index.cjs.js +1 -1
  14. package/dist/crud/modal/index.es.js +120 -109
  15. package/dist/node_modules/.pnpm/input-format@0.3.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/input-format/modules/react/Input.cjs.js +1 -1
  16. package/dist/node_modules/.pnpm/input-format@0.3.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/input-format/modules/react/Input.es.js +1 -1
  17. package/dist/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.cjs.js +1 -1
  18. package/dist/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.es.js +1 -1
  19. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/CountryIcon.cjs.js +1 -1
  20. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/CountryIcon.es.js +2 -2
  21. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/CountrySelect.cjs.js +1 -1
  22. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/CountrySelect.es.js +2 -2
  23. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/Flag.cjs.js +1 -1
  24. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/Flag.es.js +2 -2
  25. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InputBasic.cjs.js +1 -1
  26. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InputBasic.es.js +1 -1
  27. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InputSmart.cjs.js +1 -1
  28. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InputSmart.es.js +1 -1
  29. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InternationalIcon.cjs.js +1 -1
  30. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/InternationalIcon.es.js +1 -1
  31. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/PhoneInputWithCountry.cjs.js +1 -1
  32. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/PhoneInputWithCountry.es.js +2 -2
  33. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/PropTypes.cjs.js +1 -1
  34. package/dist/node_modules/.pnpm/react-phone-number-input@3.4.14_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-phone-number-input/modules/PropTypes.es.js +1 -1
  35. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";var H=Object.defineProperty;var R=(s,e,t)=>e in s?H(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var g=(s,e,t)=>R(s,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),T=require("@ant-design/icons"),f=require("antd"),q=require("path-browserify"),i=require("react"),W=require("../util/NumberUtil.cjs.js"),v=require("../util/ValidationUtil.cjs.js"),z=require("uuid"),G=require("../common/picker/ImagePicker.cjs.js"),J=require("../util/ImageUtil.cjs.js");class V{}class K extends V{constructor(t="",a=""){super();g(this,"rootPath");g(this,"subPath");this.rootPath=t,this.subPath=a}cloneFilePath(t){const a=q.parse(t),r=`${a.name}_cloned_${W.default.randInt(1e5)}`;return q.format({dir:a.dir,ext:a.ext,name:r})}generateFileName(t){return`${t.split(".")[0]}_${z.v4().replace("-","")}`}}function L({formLayoutProps:s,name:e,label:t,required:a,provider:r,onUploading:u,aspectRatio:C,onRemoved:d,fieldClassName:x,hideLabel:N=!1,listType:b,fieldHelper:S,showSkipCropButton:$=!1,skipResize:p=!1,asyncUpload:O=!1,maxCount:_=1},k){const m=f.Form.useFormInstance(),I=f.Form.useWatch(e,m),[w,E]=i.useState(!1),h=i.useCallback(async(l,F)=>{if(F){u==null||u(!0);const c=l.name,o=c.split("."),M=o[o.length-1],A=r.generateFileName(c),B=`${await r.getInitialPath()}/${A}.${M}`,D=await r.upload(l,B);E(!0),u==null||u(!1),m.setFieldValue(e,D)}else{const c=m.getFieldsValue(),o=await r.delete(c[e]);d==null||d(),o&&m.setFieldsValue({[e]:null})}},[m,e,d,u,r]),[P,j]=i.useState();return i.useEffect(()=>{!w&&I?r.getRealUrl(I).then(j):j(P)},[I,w,r,P]),i.useImperativeHandle(k,()=>({async uploadBlob(l,F){const c=await J.getBase64(l),o={name:F,uid:F+Math.random().toString(36).substring(2,15),url:c,originFileObj:l};return h(o,!0)}}),[h]),n.jsxs(f.Form.Item,{rules:a?v.required(t):[],label:N?null:t,required:a,name:e,help:S,...s,className:x,children:[n.jsx(G.default,{noStyle:!0,asyncUpload:O,listType:b,aspectRatio:C,values:P,onRemove:l=>{l&&h(l,!1)},onAdd:async l=>{l&&await h(l,!0)},className:x,showSkipCropButton:$,skipResize:p,maxCount:_}),n.jsx(f.Input,{hidden:!0})]})}const Q=i.forwardRef(L),U=({provider:s,value:e})=>{const[t,a]=i.useState();return i.useEffect(()=>{e&&s.getRealUrl(e).then(a)},[s,e]),t?n.jsx(y,{url:t}):n.jsx(n.Fragment,{})},y=({url:s})=>n.jsx(f.Avatar,{className:"p-0",children:n.jsx(f.Image,{className:"m-0 p-0 position-relative",src:s,preview:{mask:n.jsx(T.EyeOutlined,{})}})});exports.FileDownloadProvider=V;exports.FileUploadProvider=K;exports.ImageCellValue=y;exports.ImageCrudCellValue=U;exports.default=Q;
1
+ "use strict";var T=Object.defineProperty;var W=(s,e,t)=>e in s?T(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var q=(s,e,t)=>W(s,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),G=require("@ant-design/icons"),F=require("antd"),x=require("path-browserify"),d=require("react"),J=require("../util/NumberUtil.cjs.js"),K=require("../util/ValidationUtil.cjs.js"),L=require("uuid"),Q=require("../common/picker/ImagePicker.cjs.js"),X=require("../util/ImageUtil.cjs.js");class N{}class Y extends N{constructor(t="",l=""){super();q(this,"rootPath");q(this,"subPath");this.rootPath=t,this.subPath=l}cloneFilePath(t){const l=x.parse(t),a=`${l.name}_cloned_${J.default.randInt(1e5)}`;return x.format({dir:l.dir,ext:l.ext,name:a})}generateFileName(t){return`${t.split(".")[0]}_${L.v4().replace("-","")}`}}function Z({formLayoutProps:s,name:e,label:t,required:l,provider:a,onUploading:i,aspectRatio:$,onRemoved:m,fieldClassName:A,hideLabel:k=!1,listType:C,fieldHelper:O,showSkipCropButton:S=!1,skipCrop:_=!1,skipResize:B=!1,asyncUpload:M=!1,maxCount:h=1},z){const f=F.Form.useFormInstance(),o=e,y=F.Form.useWatch(o,f),D=d.useCallback(r=>a.getRealUrl(r),[a]),g=d.useCallback(async(r,P)=>{if(P){i==null||i(!0);try{const u=r.name,c=u.split("."),p=c[c.length-1],I=a.generateFileName(u),w=`${await a.getInitialPath()}/${I}.${p}`,j=await a.upload(r,w),V=f.getFieldValue(o);if(h>1){const H=Array.isArray(V)?V:V?[V]:[];f.setFieldValue(o,[...H,j].filter(Boolean))}else f.setFieldValue(o,j);return j}finally{i==null||i(!1)}}else{const u=f.getFieldValue(o);if(h>1){const c=r.response??(typeof r.uid=="string"?r.uid:void 0);if(!c)return;await a.delete(c),m==null||m();const I=(Array.isArray(u)?u:u?[u]:[]).filter(w=>w!==c);f.setFieldValue(o,I.length?I:null)}else{const c=await a.delete(u);m==null||m(),c&&f.setFieldValue(o,null)}}},[f,h,o,m,i,a]);d.useImperativeHandle(z,()=>({async uploadBlob(r,P){const u=await X.getBase64(r),c={name:P,uid:P+Math.random().toString(36).substring(2,15),url:u,originFileObj:r};await g(c,!0)}}),[g]);const E=d.useMemo(()=>y?(Array.isArray(y),y):h>1?[]:void 0,[y,h]);return n.jsxs(F.Form.Item,{rules:l?K.required(t):[],label:k?null:t,required:l,name:o,help:O,...s,className:A,children:[n.jsx(Q.default,{noStyle:!0,asyncUpload:M,listType:C,aspectRatio:$,values:E,getRealUrl:D,onRemove:r=>{r&&g(r,!1)},onAdd:async r=>{if(r)return g(r,!0)},className:A,showSkipCropButton:S,skipCrop:_,skipResize:B,maxCount:h}),n.jsx(F.Input,{hidden:!0})]})}const U=d.forwardRef(Z),R=({provider:s,value:e})=>{const[t,l]=d.useState([]);return d.useEffect(()=>{if(!e){l([]);return}const a=Array.isArray(e)?e:[e];Promise.all(a.filter(Boolean).map(i=>s.getRealUrl(i))).then(l)},[s,e]),t.length?n.jsx(n.Fragment,{children:t.map(a=>n.jsx(b,{url:a},a))}):n.jsx(n.Fragment,{})},b=({url:s})=>n.jsx(F.Avatar,{className:"p-0",children:n.jsx(F.Image,{className:"m-0 p-0 position-relative",src:s,preview:{mask:n.jsx(G.EyeOutlined,{})}})});exports.FileDownloadProvider=N;exports.FileUploadProvider=Y;exports.ImageCellValue=b;exports.ImageCrudCellValue=R;exports.default=U;
@@ -10,6 +10,8 @@ export interface _ImageCrudField<T> extends InitialCrudField<T> {
10
10
  fieldClassName?: string;
11
11
  listType?: UploadListType;
12
12
  showSkipCropButton?: boolean;
13
+ /** When true, skips the crop modal entirely and uploads the original image. */
14
+ skipCrop?: boolean;
13
15
  skipResize?: boolean;
14
16
  asyncUpload?: boolean;
15
17
  maxCount?: number;
@@ -40,7 +42,7 @@ declare const ImageCrudField: <T>(p: Readonly<_ImageCrudField<T>> & {
40
42
  }) => ReactElement;
41
43
  export default ImageCrudField;
42
44
  export declare const ImageCrudCellValue: FC<{
43
- value: string;
45
+ value: string | string[];
44
46
  provider: FileDownloadProvider;
45
47
  }>;
46
48
  export declare const ImageCellValue: FC<{
@@ -1,139 +1,176 @@
1
- var M = Object.defineProperty;
2
- var W = (a, e, t) => e in a ? M(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var I = (a, e, t) => W(a, typeof e != "symbol" ? e + "" : e, t);
4
- import { jsx as i, Fragment as q, jsxs as z } from "react/jsx-runtime";
5
- import { EyeOutlined as G } from "@ant-design/icons";
6
- import { Avatar as J, Image as K, Form as d, Input as L } from "antd";
7
- import y from "path-browserify";
8
- import Q, { useState as P, useEffect as V, useCallback as R, useImperativeHandle as T } from "react";
9
- import X from "../util/NumberUtil.es.js";
10
- import Y from "../util/ValidationUtil.es.js";
11
- import { v4 as Z } from "uuid";
12
- import U from "../common/picker/ImagePicker.es.js";
13
- import v from "../util/ImageUtil.es.js";
14
- class ee {
1
+ var W = Object.defineProperty;
2
+ var q = (s, e, t) => e in s ? W(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var w = (s, e, t) => q(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { jsx as o, Fragment as $, jsxs as G } from "react/jsx-runtime";
5
+ import { EyeOutlined as J } from "@ant-design/icons";
6
+ import { Avatar as K, Image as L, Form as I, Input as Q } from "antd";
7
+ import b from "path-browserify";
8
+ import T, { useState as X, useEffect as Y, useCallback as k, useImperativeHandle as Z, useMemo as U } from "react";
9
+ import R from "../util/NumberUtil.es.js";
10
+ import v from "../util/ValidationUtil.es.js";
11
+ import { v4 as ee } from "uuid";
12
+ import te from "../common/picker/ImagePicker.es.js";
13
+ import ae from "../util/ImageUtil.es.js";
14
+ class re {
15
15
  }
16
- class Fe extends ee {
17
- constructor(t = "", s = "") {
16
+ class pe extends re {
17
+ constructor(t = "", l = "") {
18
18
  super();
19
- I(this, "rootPath");
20
- I(this, "subPath");
21
- this.rootPath = t, this.subPath = s;
19
+ w(this, "rootPath");
20
+ w(this, "subPath");
21
+ this.rootPath = t, this.subPath = l;
22
22
  }
23
23
  cloneFilePath(t) {
24
- const s = y.parse(t), l = `${s.name}_cloned_${X.randInt(1e5)}`;
25
- return y.format({
26
- dir: s.dir,
27
- ext: s.ext,
28
- name: l
24
+ const l = b.parse(t), a = `${l.name}_cloned_${R.randInt(1e5)}`;
25
+ return b.format({
26
+ dir: l.dir,
27
+ ext: l.ext,
28
+ name: a
29
29
  });
30
30
  }
31
31
  generateFileName(t) {
32
- return `${t.split(".")[0]}_${Z().replace("-", "")}`;
32
+ return `${t.split(".")[0]}_${ee().replace("-", "")}`;
33
33
  }
34
34
  }
35
- function te({
36
- formLayoutProps: a,
35
+ function se({
36
+ formLayoutProps: s,
37
37
  name: e,
38
38
  label: t,
39
- required: s,
40
- provider: l,
39
+ required: l,
40
+ provider: a,
41
41
  onUploading: n,
42
- aspectRatio: x,
43
- onRemoved: m,
44
- fieldClassName: w,
45
- hideLabel: $ = !1,
46
- listType: C,
47
- fieldHelper: b,
48
- showSkipCropButton: O = !1,
49
- skipResize: j = !1,
50
- asyncUpload: k = !1,
51
- maxCount: S = 1
52
- }, _) {
53
- const o = d.useFormInstance(), F = d.useWatch(e, o), [g, A] = P(!1), f = R(
54
- async (r, h) => {
55
- if (h) {
42
+ aspectRatio: B,
43
+ onRemoved: f,
44
+ fieldClassName: A,
45
+ hideLabel: O = !1,
46
+ listType: j,
47
+ fieldHelper: z,
48
+ showSkipCropButton: S = !1,
49
+ skipCrop: _ = !1,
50
+ skipResize: x = !1,
51
+ asyncUpload: E = !1,
52
+ maxCount: h = 1
53
+ }, H) {
54
+ const m = I.useFormInstance(), u = e, d = I.useWatch(u, m), M = k(
55
+ (r) => a.getRealUrl(r),
56
+ [a]
57
+ ), y = k(
58
+ async (r, F) => {
59
+ if (F) {
56
60
  n == null || n(!0);
57
- const c = r.name, u = c.split("."), B = u[u.length - 1], E = l.generateFileName(c), H = `${await l.getInitialPath()}/${E}.${B}`, D = await l.upload(r, H);
58
- A(!0), n == null || n(!1), o.setFieldValue(e, D);
61
+ try {
62
+ const i = r.name, c = i.split("."), N = c[c.length - 1], p = a.generateFileName(i), g = `${await a.getInitialPath()}/${p}.${N}`, V = await a.upload(r, g), P = m.getFieldValue(u);
63
+ if (h > 1) {
64
+ const D = Array.isArray(P) ? P : P ? [P] : [];
65
+ m.setFieldValue(u, [
66
+ ...D,
67
+ V
68
+ ].filter(Boolean));
69
+ } else
70
+ m.setFieldValue(u, V);
71
+ return V;
72
+ } finally {
73
+ n == null || n(!1);
74
+ }
59
75
  } else {
60
- const c = o.getFieldsValue(), u = await l.delete(c[e]);
61
- m == null || m(), u && o.setFieldsValue({ [e]: null });
76
+ const i = m.getFieldValue(u);
77
+ if (h > 1) {
78
+ const c = r.response ?? (typeof r.uid == "string" ? r.uid : void 0);
79
+ if (!c) return;
80
+ await a.delete(c), f == null || f();
81
+ const p = (Array.isArray(i) ? i : i ? [i] : []).filter((g) => g !== c);
82
+ m.setFieldValue(
83
+ u,
84
+ p.length ? p : null
85
+ );
86
+ } else {
87
+ const c = await a.delete(i);
88
+ f == null || f(), c && m.setFieldValue(u, null);
89
+ }
62
90
  }
63
91
  },
64
- [o, e, m, n, l]
65
- ), [p, N] = P();
66
- return V(() => {
67
- !g && F ? l.getRealUrl(F).then(N) : N(p);
68
- }, [F, g, l, p]), T(
69
- _,
92
+ [m, h, u, f, n, a]
93
+ );
94
+ Z(
95
+ H,
70
96
  () => ({
71
- async uploadBlob(r, h) {
72
- const c = await v.getBase64(r), u = {
73
- name: h,
74
- uid: h + Math.random().toString(36).substring(2, 15),
75
- url: c,
97
+ async uploadBlob(r, F) {
98
+ const i = await ae.getBase64(r), c = {
99
+ name: F,
100
+ uid: F + Math.random().toString(36).substring(2, 15),
101
+ url: i,
76
102
  originFileObj: r
77
103
  };
78
- return f(u, !0);
104
+ await y(c, !0);
79
105
  }
80
106
  }),
81
- [f]
82
- ), /* @__PURE__ */ z(
83
- d.Item,
107
+ [y]
108
+ );
109
+ const C = U(() => d ? (Array.isArray(d), d) : h > 1 ? [] : void 0, [d, h]);
110
+ return /* @__PURE__ */ G(
111
+ I.Item,
84
112
  {
85
- rules: s ? Y.required(t) : [],
86
- label: $ ? null : t,
87
- required: s,
88
- name: e,
89
- help: b,
90
- ...a,
91
- className: w,
113
+ rules: l ? v.required(t) : [],
114
+ label: O ? null : t,
115
+ required: l,
116
+ name: u,
117
+ help: z,
118
+ ...s,
119
+ className: A,
92
120
  children: [
93
- /* @__PURE__ */ i(
94
- U,
121
+ /* @__PURE__ */ o(
122
+ te,
95
123
  {
96
124
  noStyle: !0,
97
- asyncUpload: k,
98
- listType: C,
99
- aspectRatio: x,
100
- values: p,
125
+ asyncUpload: E,
126
+ listType: j,
127
+ aspectRatio: B,
128
+ values: C,
129
+ getRealUrl: M,
101
130
  onRemove: (r) => {
102
- r && f(r, !1);
131
+ r && y(r, !1);
103
132
  },
104
133
  onAdd: async (r) => {
105
- r && await f(r, !0);
134
+ if (r) return y(r, !0);
106
135
  },
107
- className: w,
108
- showSkipCropButton: O,
109
- skipResize: j,
110
- maxCount: S
136
+ className: A,
137
+ showSkipCropButton: S,
138
+ skipCrop: _,
139
+ skipResize: x,
140
+ maxCount: h
111
141
  }
112
142
  ),
113
- /* @__PURE__ */ i(L, { hidden: !0 })
143
+ /* @__PURE__ */ o(Q, { hidden: !0 })
114
144
  ]
115
145
  }
116
146
  );
117
147
  }
118
- const pe = Q.forwardRef(te), Ie = ({ provider: a, value: e }) => {
119
- const [t, s] = P();
120
- return V(() => {
121
- e && a.getRealUrl(e).then(s);
122
- }, [a, e]), t ? /* @__PURE__ */ i(ae, { url: t }) : /* @__PURE__ */ i(q, {});
123
- }, ae = ({ url: a }) => /* @__PURE__ */ i(J, { className: "p-0", children: /* @__PURE__ */ i(
124
- K,
148
+ const Pe = T.forwardRef(se), ge = ({ provider: s, value: e }) => {
149
+ const [t, l] = X([]);
150
+ return Y(() => {
151
+ if (!e) {
152
+ l([]);
153
+ return;
154
+ }
155
+ const a = Array.isArray(e) ? e : [e];
156
+ Promise.all(a.filter(Boolean).map((n) => s.getRealUrl(n))).then(
157
+ l
158
+ );
159
+ }, [s, e]), t.length ? /* @__PURE__ */ o($, { children: t.map((a) => /* @__PURE__ */ o(le, { url: a }, a)) }) : /* @__PURE__ */ o($, {});
160
+ }, le = ({ url: s }) => /* @__PURE__ */ o(K, { className: "p-0", children: /* @__PURE__ */ o(
161
+ L,
125
162
  {
126
163
  className: "m-0 p-0 position-relative",
127
- src: a,
164
+ src: s,
128
165
  preview: {
129
- mask: /* @__PURE__ */ i(G, {})
166
+ mask: /* @__PURE__ */ o(J, {})
130
167
  }
131
168
  }
132
169
  ) });
133
170
  export {
134
- ee as FileDownloadProvider,
135
- Fe as FileUploadProvider,
136
- ae as ImageCellValue,
137
- Ie as ImageCrudCellValue,
138
- pe as default
171
+ re as FileDownloadProvider,
172
+ pe as FileUploadProvider,
173
+ le as ImageCellValue,
174
+ ge as ImageCrudCellValue,
175
+ Pe as default
139
176
  };
@@ -1 +1 @@
1
- "use strict";const g=require("react/jsx-runtime"),q=require("antd"),t=require("react"),Z=require("../CrudForm.cjs.js"),z=require("../CrudFormWizard.cjs.js"),ee=require("../../locale/index.cjs.js"),B=require("../../util/CrudUtil.cjs.js"),te=require("dayjs"),r=require("../../util/ObjectUtil.cjs.js"),ae=({fields:l,wizard:i,grid:_,fullWidthModal:A,isCreating:N,isUpdating:M,onCreate:V,onUpdate:h,idField:v="id",formBuilder:L,onValuesChange:U},E)=>{const[n]=q.Form.useForm(),{t:S}=ee.useTranslationLib(),[k,y]=t.useState(!1),[p,R]=t.useState("new"),[f,F]=t.useState(),[$,b]=t.useState(),[G,O]=t.useState(!1),[J,P]=t.useState(!1),[K,w]=t.useState(!1),W=t.useCallback(async s=>{var m;const d=i?s:await n.validateFields(),u=l.filter(a=>a.type==="color"),o={};for(const a of u){const c=B.getRealName(a.name,"upsertFieldName"),e=n.getFieldValue(c);r.setValueByPath(o,c,typeof e=="string"?e:(m=e==null?void 0:e.toHexString())==null?void 0:m.toUpperCase())}Object.assign(d,o),f&&h?(await h({...d,[v]:f[v]}),F(void 0)):!f&&V&&await V(d),b(void 0),x(new Map),n.resetFields(),y(!1)},[l,n,v,V,h,f,i]),D=t.useCallback(async s=>{O(s),P(!0)},[]),H=t.useCallback(async()=>{P(!0)},[]),I=t.useCallback(()=>{y(!0),R("new"),n.resetFields(),F(void 0),b(void 0)},[n]),[C,x]=t.useState(new Map),Q=t.useMemo(()=>C.size===0?l:l.map(s=>typeof s.updatable=="function"?{...s,updatable:C.get(B.getRealName(s.name,"name"))??s.updatable}:s),[l,C]),T=t.useCallback(async(s,d=!0,u=!1)=>{try{w(!0),y(!0),R(u?"clone":"update");const o={};for(const a of l){const c=B.getRealName(a.name,"upsertFieldName"),e=r.getValueByPath(s,c);if(u&&a.type==="image"){const j=e;try{const Y=await a.provider.clone(j);r.setValueByPath(o,c,Y);continue}catch{continue}}a.type==="date"||a.type==="time"?e&&r.setValueByPath(o,c,te(e)):a.type==="select"?a.multiple&&Array.isArray(e)?r.setValueByPath(o,c,e.map(j=>j[a.innerFieldId??"id"])):e&&typeof e=="object"?r.setValueByPath(o,c,e[a.innerFieldId??"id"]):(e&&typeof e=="string"||typeof e=="number")&&r.setValueByPath(o,c,e):r.setValueByPath(o,c,e)}n.setFieldsValue(o);const m=new Map;for(const a of l)typeof a.updatable=="function"&&m.set(B.getRealName(a.name,"name"),a.updatable(s));x(m),b(o),d&&F(s)}finally{w(!1)}},[l,n]);t.useImperativeHandle(E,()=>({create:I,update:T}),[I,T]),t.useEffect(()=>{k&&(O(!1),P(!1))},[k]);const X=t.useCallback(async()=>{x(new Map);try{if(p==="clone"){const s=i?f:n.getFieldsValue(),d=l.filter(u=>u.type==="image");for(const u of d)s[u.name]&&u.provider.delete(s[u.name])}}finally{}i||n.resetFields(),b(void 0),F(void 0),y(!1)},[p,i,n,f,l]);return g.jsx(q.Modal,{width:A?"100%":void 0,title:S("str."+(p??"new")),open:k,confirmLoading:N||M,okText:S("str."+(p==="update"?"update":"save")),cancelText:S("str.cancel"),cancelButtonProps:{disabled:J,hidden:!!i},okButtonProps:{disabled:G,hidden:!!i},onCancel:X,onOk:()=>W(),destroyOnHidden:!0,children:g.jsxs(q.Spin,{spinning:K,children:[i?null:g.jsx(Z.CrudForm,{purpose:p,fields:Q,form:n,formBuilder:L,grid:_,onDeleteFile:H,onUploadFile:D,onValuesChange:U}),i&&g.jsx(z,{submitting:N||M,className:"mt-2",onSave:W,updatingValue:$,fields:l,onDeleteFile:H,onUploadFile:D,purpose:p,wizard:i,onValuesChange:U})]})})},se=t.forwardRef(ae);module.exports=se;
1
+ "use strict";const h=require("react/jsx-runtime"),N=require("antd"),s=require("react"),z=require("../CrudForm.cjs.js"),ee=require("../CrudFormWizard.cjs.js"),te=require("../../locale/index.cjs.js"),B=require("../../util/CrudUtil.cjs.js"),ae=require("dayjs"),c=require("../../util/ObjectUtil.cjs.js"),se=({fields:i,wizard:r,grid:_,fullWidthModal:L,isCreating:M,isUpdating:U,onCreate:V,onUpdate:v,idField:P="id",formBuilder:E,onValuesChange:R},$)=>{const[l]=N.Form.useForm(),{t:S}=te.useTranslationLib(),[k,F]=s.useState(!1),[f,A]=s.useState("new"),[m,b]=s.useState(),[G,g]=s.useState(),[J,w]=s.useState(!1),[K,C]=s.useState(!1),[Q,O]=s.useState(!1),W=s.useCallback(async t=>{var p;const d=r?t:await l.validateFields(),o=i.filter(a=>a.type==="color"),n={};for(const a of o){const u=B.getRealName(a.name,"upsertFieldName"),e=l.getFieldValue(u);c.setValueByPath(n,u,typeof e=="string"?e:(p=e==null?void 0:e.toHexString())==null?void 0:p.toUpperCase())}Object.assign(d,n),m&&v?(await v({...d,[P]:m[P]}),b(void 0)):!m&&V&&await V(d),g(void 0),j(new Map),l.resetFields(),F(!1)},[i,l,P,V,v,m,r]),D=s.useCallback(async t=>{w(t),C(!0)},[]),H=s.useCallback(async()=>{C(!0)},[]),I=s.useCallback(()=>{F(!0),A("new"),l.resetFields(),b(void 0),g(void 0)},[l]),[x,j]=s.useState(new Map),X=s.useMemo(()=>x.size===0?i:i.map(t=>typeof t.updatable=="function"?{...t,updatable:x.get(B.getRealName(t.name,"name"))??t.updatable}:t),[i,x]),T=s.useCallback(async(t,d=!0,o=!1)=>{try{O(!0),F(!0),A(o?"clone":"update");const n={};for(const a of i){const u=B.getRealName(a.name,"upsertFieldName"),e=c.getValueByPath(t,u);if(o&&a.type==="image"){const y=e;try{if(Array.isArray(y)){const q=await Promise.all(y.map(Z=>a.provider.clone(Z)));c.setValueByPath(n,u,q)}else if(y){const q=await a.provider.clone(y);c.setValueByPath(n,u,q)}continue}catch{continue}}a.type==="date"||a.type==="time"?e&&c.setValueByPath(n,u,ae(e)):a.type==="select"?a.multiple&&Array.isArray(e)?c.setValueByPath(n,u,e.map(y=>y[a.innerFieldId??"id"])):e&&typeof e=="object"?c.setValueByPath(n,u,e[a.innerFieldId??"id"]):(e&&typeof e=="string"||typeof e=="number")&&c.setValueByPath(n,u,e):c.setValueByPath(n,u,e)}l.setFieldsValue(n);const p=new Map;for(const a of i)typeof a.updatable=="function"&&p.set(B.getRealName(a.name,"name"),a.updatable(t));j(p),g(n),d&&b(t)}finally{O(!1)}},[i,l]);s.useImperativeHandle($,()=>({create:I,update:T}),[I,T]),s.useEffect(()=>{k&&(w(!1),C(!1))},[k]);const Y=s.useCallback(async()=>{j(new Map);try{if(f==="clone"){const t=r?m:l.getFieldsValue(),d=i.filter(o=>o.type==="image");for(const o of d)if(t[o.name]){const n=Array.isArray(t[o.name])?t[o.name]:[t[o.name]];for(const p of n)o.provider.delete(p)}}}finally{}r||l.resetFields(),g(void 0),b(void 0),F(!1)},[f,r,l,m,i]);return h.jsx(N.Modal,{width:L?"100%":void 0,title:S("str."+(f??"new")),open:k,confirmLoading:M||U,okText:S("str."+(f==="update"?"update":"save")),cancelText:S("str.cancel"),cancelButtonProps:{disabled:K,hidden:!!r},okButtonProps:{disabled:J,hidden:!!r},onCancel:Y,onOk:()=>W(),destroyOnHidden:!0,children:h.jsxs(N.Spin,{spinning:Q,children:[r?null:h.jsx(z.CrudForm,{purpose:f,fields:X,form:l,formBuilder:E,grid:_,onDeleteFile:H,onUploadFile:D,onValuesChange:R}),r&&h.jsx(ee,{submitting:M||U,className:"mt-2",onSave:W,updatingValue:G,fields:i,onDeleteFile:H,onUploadFile:D,purpose:f,wizard:r,onValuesChange:R})]})})},ne=s.forwardRef(se);module.exports=ne;
@@ -1,171 +1,182 @@
1
- import { jsx as x, jsxs as Z } from "react/jsx-runtime";
2
- import { Form as z, Modal as ee, Spin as te } from "antd";
3
- import { forwardRef as oe, useState as c, useCallback as m, useMemo as ae, useImperativeHandle as ne, useEffect as le } from "react";
4
- import { CrudForm as se } from "../CrudForm.es.js";
5
- import ie from "../CrudFormWizard.es.js";
6
- import { useTranslationLib as re } from "../../locale/index.es.js";
7
- import v from "../../util/CrudUtil.es.js";
8
- import ce from "dayjs";
9
- import { setValueByPath as d, getValueByPath as ue } from "../../util/ObjectUtil.es.js";
10
- const de = ({
11
- fields: n,
12
- wizard: s,
13
- grid: A,
14
- fullWidthModal: L,
1
+ import { jsx as A, jsxs as z } from "react/jsx-runtime";
2
+ import { Form as ee, Modal as te, Spin as oe } from "antd";
3
+ import { forwardRef as ae, useState as c, useCallback as F, useMemo as ne, useImperativeHandle as le, useEffect as se } from "react";
4
+ import { CrudForm as ie } from "../CrudForm.es.js";
5
+ import re from "../CrudFormWizard.es.js";
6
+ import { useTranslationLib as ce } from "../../locale/index.es.js";
7
+ import h from "../../util/CrudUtil.es.js";
8
+ import ue from "dayjs";
9
+ import { setValueByPath as u, getValueByPath as de } from "../../util/ObjectUtil.es.js";
10
+ const pe = ({
11
+ fields: s,
12
+ wizard: r,
13
+ grid: L,
14
+ fullWidthModal: E,
15
15
  isCreating: C,
16
16
  isUpdating: j,
17
17
  onCreate: B,
18
18
  onUpdate: V,
19
- idField: h = "id",
20
- formBuilder: E,
21
- onValuesChange: R
22
- }, $) => {
23
- const [a] = z.useForm(), { t: N } = re(), [k, y] = c(!1), [p, w] = c("new"), [f, g] = c(), [q, b] = c(), [G, O] = c(!1), [J, M] = c(!1), [K, W] = c(!1), D = m(
24
- async (o) => {
25
- var F;
26
- const u = s ? o : await a.validateFields(), i = n.filter((t) => t.type === "color"), l = {};
27
- for (const t of i) {
28
- const r = v.getRealName(t.name, "upsertFieldName"), e = a.getFieldValue(r);
29
- d(
30
- l,
31
- r,
32
- typeof e == "string" ? e : (F = e == null ? void 0 : e.toHexString()) == null ? void 0 : F.toUpperCase()
19
+ idField: N = "id",
20
+ formBuilder: $,
21
+ onValuesChange: w
22
+ }, q) => {
23
+ const [n] = ee.useForm(), { t: P } = ce(), [k, g] = c(!1), [f, R] = c("new"), [m, b] = c(), [G, v] = c(), [J, O] = c(!1), [K, M] = c(!1), [Q, W] = c(!1), D = F(
24
+ async (t) => {
25
+ var p;
26
+ const d = r ? t : await n.validateFields(), l = s.filter((o) => o.type === "color"), a = {};
27
+ for (const o of l) {
28
+ const i = h.getRealName(o.name, "upsertFieldName"), e = n.getFieldValue(i);
29
+ u(
30
+ a,
31
+ i,
32
+ typeof e == "string" ? e : (p = e == null ? void 0 : e.toHexString()) == null ? void 0 : p.toUpperCase()
33
33
  );
34
34
  }
35
- Object.assign(u, l), f && V ? (await V({
36
- ...u,
37
- [h]: f[h]
38
- }), g(void 0)) : !f && B && await B(u), b(void 0), S(/* @__PURE__ */ new Map()), a.resetFields(), y(!1);
35
+ Object.assign(d, a), m && V ? (await V({
36
+ ...d,
37
+ [N]: m[N]
38
+ }), b(void 0)) : !m && B && await B(d), v(void 0), U(/* @__PURE__ */ new Map()), n.resetFields(), g(!1);
39
39
  },
40
- [n, a, h, B, V, f, s]
41
- ), H = m(async (o) => {
42
- O(o), M(!0);
43
- }, []), I = m(async () => {
40
+ [s, n, N, B, V, m, r]
41
+ ), H = F(async (t) => {
42
+ O(t), M(!0);
43
+ }, []), I = F(async () => {
44
44
  M(!0);
45
- }, []), T = m(() => {
46
- y(!0), w("new"), a.resetFields(), g(void 0), b(void 0);
47
- }, [a]), [P, S] = c(/* @__PURE__ */ new Map()), Q = ae(() => P.size === 0 ? n : n.map((o) => typeof o.updatable == "function" ? {
48
- ...o,
49
- updatable: P.get(v.getRealName(o.name, "name")) ?? o.updatable
50
- } : o), [n, P]), _ = m(
51
- async (o, u = !0, i = !1) => {
45
+ }, []), T = F(() => {
46
+ g(!0), R("new"), n.resetFields(), b(void 0), v(void 0);
47
+ }, [n]), [S, U] = c(/* @__PURE__ */ new Map()), X = ne(() => S.size === 0 ? s : s.map((t) => typeof t.updatable == "function" ? {
48
+ ...t,
49
+ updatable: S.get(h.getRealName(t.name, "name")) ?? t.updatable
50
+ } : t), [s, S]), _ = F(
51
+ async (t, d = !0, l = !1) => {
52
52
  try {
53
- W(!0), y(!0), w(i ? "clone" : "update");
54
- const l = {};
55
- for (const t of n) {
56
- const r = v.getRealName(
57
- t.name,
53
+ W(!0), g(!0), R(l ? "clone" : "update");
54
+ const a = {};
55
+ for (const o of s) {
56
+ const i = h.getRealName(
57
+ o.name,
58
58
  "upsertFieldName"
59
- ), e = ue(o, r);
60
- if (i && t.type === "image") {
61
- const U = e;
59
+ ), e = de(t, i);
60
+ if (l && o.type === "image") {
61
+ const y = e;
62
62
  try {
63
- const Y = await t.provider.clone(U);
64
- d(l, r, Y);
63
+ if (Array.isArray(y)) {
64
+ const x = await Promise.all(
65
+ y.map((Z) => o.provider.clone(Z))
66
+ );
67
+ u(a, i, x);
68
+ } else if (y) {
69
+ const x = await o.provider.clone(y);
70
+ u(a, i, x);
71
+ }
65
72
  continue;
66
73
  } catch {
67
74
  continue;
68
75
  }
69
76
  }
70
- t.type === "date" || t.type === "time" ? e && d(l, r, ce(e)) : t.type === "select" ? t.multiple && Array.isArray(e) ? d(
71
- l,
72
- r,
73
- e.map((U) => U[t.innerFieldId ?? "id"])
74
- ) : e && typeof e == "object" ? d(
75
- l,
76
- r,
77
- e[t.innerFieldId ?? "id"]
78
- ) : (e && typeof e == "string" || typeof e == "number") && d(l, r, e) : d(l, r, e);
77
+ o.type === "date" || o.type === "time" ? e && u(a, i, ue(e)) : o.type === "select" ? o.multiple && Array.isArray(e) ? u(
78
+ a,
79
+ i,
80
+ e.map((y) => y[o.innerFieldId ?? "id"])
81
+ ) : e && typeof e == "object" ? u(
82
+ a,
83
+ i,
84
+ e[o.innerFieldId ?? "id"]
85
+ ) : (e && typeof e == "string" || typeof e == "number") && u(a, i, e) : u(a, i, e);
79
86
  }
80
- a.setFieldsValue(l);
81
- const F = /* @__PURE__ */ new Map();
82
- for (const t of n)
83
- typeof t.updatable == "function" && F.set(
84
- v.getRealName(t.name, "name"),
85
- t.updatable(o)
87
+ n.setFieldsValue(a);
88
+ const p = /* @__PURE__ */ new Map();
89
+ for (const o of s)
90
+ typeof o.updatable == "function" && p.set(
91
+ h.getRealName(o.name, "name"),
92
+ o.updatable(t)
86
93
  );
87
- S(F), b(l), u && g(o);
94
+ U(p), v(a), d && b(t);
88
95
  } finally {
89
96
  W(!1);
90
97
  }
91
98
  },
92
- [n, a]
99
+ [s, n]
93
100
  );
94
- ne(
95
- $,
101
+ le(
102
+ q,
96
103
  () => ({
97
104
  create: T,
98
105
  update: _
99
106
  }),
100
107
  [T, _]
101
- ), le(() => {
108
+ ), se(() => {
102
109
  k && (O(!1), M(!1));
103
110
  }, [k]);
104
- const X = m(async () => {
105
- S(/* @__PURE__ */ new Map());
111
+ const Y = F(async () => {
112
+ U(/* @__PURE__ */ new Map());
106
113
  try {
107
- if (p === "clone") {
108
- const o = s ? f : a.getFieldsValue(), u = n.filter((i) => i.type === "image");
109
- for (const i of u)
110
- o[i.name] && i.provider.delete(o[i.name]);
114
+ if (f === "clone") {
115
+ const t = r ? m : n.getFieldsValue(), d = s.filter((l) => l.type === "image");
116
+ for (const l of d)
117
+ if (t[l.name]) {
118
+ const a = Array.isArray(t[l.name]) ? t[l.name] : [t[l.name]];
119
+ for (const p of a)
120
+ l.provider.delete(p);
121
+ }
111
122
  }
112
123
  } finally {
113
124
  }
114
- s || a.resetFields(), b(void 0), g(void 0), y(!1);
115
- }, [p, s, a, f, n]);
116
- return /* @__PURE__ */ x(
117
- ee,
125
+ r || n.resetFields(), v(void 0), b(void 0), g(!1);
126
+ }, [f, r, n, m, s]);
127
+ return /* @__PURE__ */ A(
128
+ te,
118
129
  {
119
- width: L ? "100%" : void 0,
120
- title: N("str." + (p ?? "new")),
130
+ width: E ? "100%" : void 0,
131
+ title: P("str." + (f ?? "new")),
121
132
  open: k,
122
133
  confirmLoading: C || j,
123
- okText: N("str." + (p === "update" ? "update" : "save")),
124
- cancelText: N("str.cancel"),
134
+ okText: P("str." + (f === "update" ? "update" : "save")),
135
+ cancelText: P("str.cancel"),
125
136
  cancelButtonProps: {
126
- disabled: J,
127
- hidden: !!s
137
+ disabled: K,
138
+ hidden: !!r
128
139
  },
129
140
  okButtonProps: {
130
- disabled: G,
131
- hidden: !!s
141
+ disabled: J,
142
+ hidden: !!r
132
143
  },
133
- onCancel: X,
144
+ onCancel: Y,
134
145
  onOk: () => D(),
135
146
  destroyOnHidden: !0,
136
- children: /* @__PURE__ */ Z(te, { spinning: K, children: [
137
- s ? null : /* @__PURE__ */ x(
138
- se,
147
+ children: /* @__PURE__ */ z(oe, { spinning: Q, children: [
148
+ r ? null : /* @__PURE__ */ A(
149
+ ie,
139
150
  {
140
- purpose: p,
141
- fields: Q,
142
- form: a,
143
- formBuilder: E,
144
- grid: A,
151
+ purpose: f,
152
+ fields: X,
153
+ form: n,
154
+ formBuilder: $,
155
+ grid: L,
145
156
  onDeleteFile: I,
146
157
  onUploadFile: H,
147
- onValuesChange: R
158
+ onValuesChange: w
148
159
  }
149
160
  ),
150
- s && /* @__PURE__ */ x(
151
- ie,
161
+ r && /* @__PURE__ */ A(
162
+ re,
152
163
  {
153
164
  submitting: C || j,
154
165
  className: "mt-2",
155
166
  onSave: D,
156
- updatingValue: q,
157
- fields: n,
167
+ updatingValue: G,
168
+ fields: s,
158
169
  onDeleteFile: I,
159
170
  onUploadFile: H,
160
- purpose: p,
161
- wizard: s,
162
- onValuesChange: R
171
+ purpose: f,
172
+ wizard: r,
173
+ onValuesChange: w
163
174
  }
164
175
  )
165
176
  ] })
166
177
  }
167
178
  );
168
- }, Ve = oe(de);
179
+ }, Ve = ae(pe);
169
180
  export {
170
181
  Ve as default
171
182
  };