@kingteza/crud-component 1.44.2 → 1.46.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.
@@ -1,174 +1,187 @@
1
- var D = Object.defineProperty;
2
- var W = (s, e, t) => e in s ? D(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var w = (s, e, t) => W(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { jsx as o, Fragment as $, jsxs as q } from "react/jsx-runtime";
5
- import { EyeOutlined as G } from "@ant-design/icons";
6
- import { Avatar as J, Image as K, Form as I, Input as L } from "antd";
7
- import b from "path-browserify";
8
- import Q, { useState as T, useEffect as X, useCallback as k, useImperativeHandle as Y, useMemo as Z } from "react";
9
- import U from "../util/NumberUtil.es.js";
10
- import R from "../util/ValidationUtil.es.js";
11
- import { v4 as v } from "uuid";
12
- import ee from "../common/picker/ImagePicker.es.js";
13
- import te from "../util/ImageUtil.es.js";
14
- class ae {
1
+ var G = Object.defineProperty;
2
+ var J = (s, e, t) => e in s ? G(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var A = (s, e, t) => J(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { jsx as m, Fragment as b, jsxs as K } from "react/jsx-runtime";
5
+ import { EyeOutlined as L } from "@ant-design/icons";
6
+ import { Avatar as Q, Image as T, Form as N, Input as X } from "antd";
7
+ import k from "path-browserify";
8
+ import Y, { useState as Z, useEffect as C, useCallback as B, useImperativeHandle as R, useMemo as U } from "react";
9
+ import v from "../util/NumberUtil.es.js";
10
+ import ee from "../util/ValidationUtil.es.js";
11
+ import { v4 as te } from "uuid";
12
+ import re from "../common/picker/ImagePicker.es.js";
13
+ import ae from "../util/ImageUtil.es.js";
14
+ class se {
15
15
  }
16
- class Fe extends ae {
16
+ class ge extends se {
17
17
  constructor(t = "", l = "") {
18
18
  super();
19
- w(this, "rootPath");
20
- w(this, "subPath");
19
+ A(this, "rootPath");
20
+ A(this, "subPath");
21
21
  this.rootPath = t, this.subPath = l;
22
22
  }
23
23
  cloneFilePath(t) {
24
- const l = b.parse(t), a = `${l.name}_cloned_${U.randInt(1e5)}`;
25
- return b.format({
24
+ const l = k.parse(t), r = `${l.name}_cloned_${v.randInt(1e5)}`;
25
+ return k.format({
26
26
  dir: l.dir,
27
27
  ext: l.ext,
28
- name: a
28
+ name: r
29
29
  });
30
30
  }
31
31
  generateFileName(t) {
32
- return `${t.split(".")[0]}_${v().replace("-", "")}`;
32
+ return `${t.split(".")[0]}_${te().replace("-", "")}`;
33
33
  }
34
34
  }
35
- function re({
35
+ function le({
36
36
  formLayoutProps: s,
37
37
  name: e,
38
38
  label: t,
39
39
  required: l,
40
- provider: a,
41
- onUploading: n,
42
- aspectRatio: B,
43
- onRemoved: f,
44
- fieldClassName: A,
45
- hideLabel: O = !1,
46
- listType: j,
47
- fieldHelper: z,
48
- showSkipCropButton: S = !1,
49
- skipResize: _ = !1,
50
- asyncUpload: x = !1,
40
+ provider: r,
41
+ onUploading: i,
42
+ aspectRatio: O,
43
+ onRemoved: o,
44
+ onUploadComplete: F,
45
+ fieldClassName: p,
46
+ hideLabel: j = !1,
47
+ listType: z,
48
+ fieldHelper: S,
49
+ showSkipCropButton: _ = !1,
50
+ skipCrop: x = !1,
51
+ skipResize: E = !1,
52
+ asyncUpload: H = !1,
51
53
  maxCount: h = 1
52
- }, E) {
53
- const m = I.useFormInstance(), u = e, d = I.useWatch(u, m), H = k(
54
- (r) => a.getRealUrl(r),
55
- [a]
56
- ), y = k(
57
- async (r, F) => {
58
- if (F) {
59
- n == null || n(!0);
54
+ }, M) {
55
+ const f = N.useFormInstance(), u = e, y = N.useWatch(u, f), D = B(
56
+ (a) => r.getRealUrl(a),
57
+ [r]
58
+ ), P = B(
59
+ async (a, d) => {
60
+ if (d) {
61
+ i == null || i(!0);
60
62
  try {
61
- 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
+ const n = a.name, c = n.split("."), $ = c[c.length - 1], g = r.generateFileName(n), I = `${await r.getInitialPath()}/${g}.${$}`, V = await r.upload(a, I);
64
+ F == null || F(V);
65
+ const w = f.getFieldValue(u);
62
66
  if (h > 1) {
63
- const C = Array.isArray(P) ? P : P ? [P] : [];
64
- m.setFieldValue(u, [
65
- ...C,
67
+ const q = Array.isArray(w) ? w : w ? [w] : [];
68
+ f.setFieldValue(u, [
69
+ ...q,
66
70
  V
67
71
  ].filter(Boolean));
68
72
  } else
69
- m.setFieldValue(u, V);
73
+ f.setFieldValue(u, V);
70
74
  return V;
71
75
  } finally {
72
- n == null || n(!1);
76
+ i == null || i(!1);
73
77
  }
74
78
  } else {
75
- const i = m.getFieldValue(u);
79
+ const n = f.getFieldValue(u);
76
80
  if (h > 1) {
77
- const c = r.response ?? (typeof r.uid == "string" ? r.uid : void 0);
81
+ const c = a.response ?? (typeof a.uid == "string" ? a.uid : void 0);
78
82
  if (!c) return;
79
- await a.delete(c), f == null || f();
80
- const p = (Array.isArray(i) ? i : i ? [i] : []).filter((g) => g !== c);
81
- m.setFieldValue(
83
+ await r.delete(c), o == null || o();
84
+ const g = (Array.isArray(n) ? n : n ? [n] : []).filter((I) => I !== c);
85
+ f.setFieldValue(
82
86
  u,
83
- p.length ? p : null
87
+ g.length ? g : null
84
88
  );
85
89
  } else {
86
- const c = await a.delete(i);
87
- f == null || f(), c && m.setFieldValue(u, null);
90
+ const c = await r.delete(n);
91
+ o == null || o(), c && f.setFieldValue(u, null);
88
92
  }
89
93
  }
90
94
  },
91
- [m, h, u, f, n, a]
95
+ [
96
+ f,
97
+ h,
98
+ u,
99
+ o,
100
+ F,
101
+ i,
102
+ r
103
+ ]
92
104
  );
93
- Y(
94
- E,
105
+ R(
106
+ M,
95
107
  () => ({
96
- async uploadBlob(r, F) {
97
- const i = await te.getBase64(r), c = {
98
- name: F,
99
- uid: F + Math.random().toString(36).substring(2, 15),
100
- url: i,
101
- originFileObj: r
108
+ async uploadBlob(a, d) {
109
+ const n = await ae.getBase64(a), c = {
110
+ name: d,
111
+ uid: d + Math.random().toString(36).substring(2, 15),
112
+ url: n,
113
+ originFileObj: a
102
114
  };
103
- await y(c, !0);
115
+ await P(c, !0);
104
116
  }
105
117
  }),
106
- [y]
118
+ [P]
107
119
  );
108
- const M = Z(() => d ? (Array.isArray(d), d) : h > 1 ? [] : void 0, [d, h]);
109
- return /* @__PURE__ */ q(
110
- I.Item,
120
+ const W = U(() => y ? (Array.isArray(y), y) : h > 1 ? [] : void 0, [y, h]);
121
+ return /* @__PURE__ */ K(
122
+ N.Item,
111
123
  {
112
- rules: l ? R.required(t) : [],
113
- label: O ? null : t,
124
+ rules: l ? ee.required(t) : [],
125
+ label: j ? null : t,
114
126
  required: l,
115
127
  name: u,
116
- help: z,
128
+ help: S,
117
129
  ...s,
118
- className: A,
130
+ className: p,
119
131
  children: [
120
- /* @__PURE__ */ o(
121
- ee,
132
+ /* @__PURE__ */ m(
133
+ re,
122
134
  {
123
135
  noStyle: !0,
124
- asyncUpload: x,
125
- listType: j,
126
- aspectRatio: B,
127
- values: M,
128
- getRealUrl: H,
129
- onRemove: (r) => {
130
- r && y(r, !1);
136
+ asyncUpload: H,
137
+ listType: z,
138
+ aspectRatio: O,
139
+ values: W,
140
+ getRealUrl: D,
141
+ onRemove: (a) => {
142
+ a && P(a, !1);
131
143
  },
132
- onAdd: async (r) => {
133
- if (r) return y(r, !0);
144
+ onAdd: async (a) => {
145
+ if (a) return P(a, !0);
134
146
  },
135
- className: A,
136
- showSkipCropButton: S,
137
- skipResize: _,
147
+ className: p,
148
+ showSkipCropButton: _,
149
+ skipCrop: x,
150
+ skipResize: E,
138
151
  maxCount: h
139
152
  }
140
153
  ),
141
- /* @__PURE__ */ o(L, { hidden: !0 })
154
+ /* @__PURE__ */ m(X, { hidden: !0 })
142
155
  ]
143
156
  }
144
157
  );
145
158
  }
146
- const pe = Q.forwardRef(re), Pe = ({ provider: s, value: e }) => {
147
- const [t, l] = T([]);
148
- return X(() => {
159
+ const Ve = Y.forwardRef(le), we = ({ provider: s, value: e }) => {
160
+ const [t, l] = Z([]);
161
+ return C(() => {
149
162
  if (!e) {
150
163
  l([]);
151
164
  return;
152
165
  }
153
- const a = Array.isArray(e) ? e : [e];
154
- Promise.all(a.filter(Boolean).map((n) => s.getRealUrl(n))).then(
166
+ const r = Array.isArray(e) ? e : [e];
167
+ Promise.all(r.filter(Boolean).map((i) => s.getRealUrl(i))).then(
155
168
  l
156
169
  );
157
- }, [s, e]), t.length ? /* @__PURE__ */ o($, { children: t.map((a) => /* @__PURE__ */ o(se, { url: a }, a)) }) : /* @__PURE__ */ o($, {});
158
- }, se = ({ url: s }) => /* @__PURE__ */ o(J, { className: "p-0", children: /* @__PURE__ */ o(
159
- K,
170
+ }, [s, e]), t.length ? /* @__PURE__ */ m(b, { children: t.map((r) => /* @__PURE__ */ m(ie, { url: r }, r)) }) : /* @__PURE__ */ m(b, {});
171
+ }, ie = ({ url: s }) => /* @__PURE__ */ m(Q, { className: "p-0", children: /* @__PURE__ */ m(
172
+ T,
160
173
  {
161
174
  className: "m-0 p-0 position-relative",
162
175
  src: s,
163
176
  preview: {
164
- mask: /* @__PURE__ */ o(G, {})
177
+ mask: /* @__PURE__ */ m(L, {})
165
178
  }
166
179
  }
167
180
  ) });
168
181
  export {
169
- ae as FileDownloadProvider,
170
- Fe as FileUploadProvider,
171
- se as ImageCellValue,
172
- Pe as ImageCrudCellValue,
173
- pe as default
182
+ se as FileDownloadProvider,
183
+ ge as FileUploadProvider,
184
+ ie as ImageCellValue,
185
+ we as ImageCrudCellValue,
186
+ Ve as default
174
187
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.44.2",
4
+ "version": "1.46.0",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",