@kingteza/crud-component 1.45.0 → 1.46.1

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,176 +1,187 @@
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";
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
13
  import ae from "../util/ImageUtil.es.js";
14
- class re {
14
+ class se {
15
15
  }
16
- class pe extends re {
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_${R.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]}_${ee().replace("-", "")}`;
32
+ return `${t.split(".")[0]}_${te().replace("-", "")}`;
33
33
  }
34
34
  }
35
- function se({
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
- skipCrop: _ = !1,
50
- skipResize: x = !1,
51
- asyncUpload: E = !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,
52
53
  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) {
60
- 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);
61
62
  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
+ 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);
63
66
  if (h > 1) {
64
- const D = Array.isArray(P) ? P : P ? [P] : [];
65
- m.setFieldValue(u, [
66
- ...D,
67
+ const q = Array.isArray(w) ? w : w ? [w] : [];
68
+ f.setFieldValue(u, [
69
+ ...q,
67
70
  V
68
71
  ].filter(Boolean));
69
72
  } else
70
- m.setFieldValue(u, V);
73
+ f.setFieldValue(u, V);
71
74
  return V;
72
75
  } finally {
73
- n == null || n(!1);
76
+ i == null || i(!1);
74
77
  }
75
78
  } else {
76
- const i = m.getFieldValue(u);
79
+ const n = f.getFieldValue(u);
77
80
  if (h > 1) {
78
- 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);
79
82
  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
+ await r.delete(c), o == null || o();
84
+ const g = (Array.isArray(n) ? n : n ? [n] : []).filter((I) => I !== c);
85
+ f.setFieldValue(
83
86
  u,
84
- p.length ? p : null
87
+ g.length ? g : null
85
88
  );
86
89
  } else {
87
- const c = await a.delete(i);
88
- f == null || f(), c && m.setFieldValue(u, null);
90
+ const c = await r.delete(n);
91
+ o == null || o(), c && f.setFieldValue(u, null);
89
92
  }
90
93
  }
91
94
  },
92
- [m, h, u, f, n, a]
95
+ [
96
+ f,
97
+ h,
98
+ u,
99
+ o,
100
+ F,
101
+ i,
102
+ r
103
+ ]
93
104
  );
94
- Z(
95
- H,
105
+ R(
106
+ M,
96
107
  () => ({
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,
102
- 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
103
114
  };
104
- await y(c, !0);
115
+ await P(c, !0);
105
116
  }
106
117
  }),
107
- [y]
118
+ [P]
108
119
  );
109
- const C = U(() => d ? (Array.isArray(d), d) : h > 1 ? [] : void 0, [d, h]);
110
- return /* @__PURE__ */ G(
111
- I.Item,
120
+ const W = U(() => y ? (Array.isArray(y), y) : h > 1 ? [] : void 0, [y, h]);
121
+ return /* @__PURE__ */ K(
122
+ N.Item,
112
123
  {
113
- rules: l ? v.required(t) : [],
114
- label: O ? null : t,
124
+ rules: l ? ee.required(t) : [],
125
+ label: j ? null : t,
115
126
  required: l,
116
127
  name: u,
117
- help: z,
128
+ help: S,
118
129
  ...s,
119
- className: A,
130
+ className: p,
120
131
  children: [
121
- /* @__PURE__ */ o(
122
- te,
132
+ /* @__PURE__ */ m(
133
+ re,
123
134
  {
124
135
  noStyle: !0,
125
- asyncUpload: E,
126
- listType: j,
127
- aspectRatio: B,
128
- values: C,
129
- getRealUrl: M,
130
- onRemove: (r) => {
131
- 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);
132
143
  },
133
- onAdd: async (r) => {
134
- if (r) return y(r, !0);
144
+ onAdd: async (a) => {
145
+ if (a) return P(a, !0);
135
146
  },
136
- className: A,
137
- showSkipCropButton: S,
138
- skipCrop: _,
139
- skipResize: x,
147
+ className: p,
148
+ showSkipCropButton: _,
149
+ skipCrop: x,
150
+ skipResize: E,
140
151
  maxCount: h
141
152
  }
142
153
  ),
143
- /* @__PURE__ */ o(Q, { hidden: !0 })
154
+ /* @__PURE__ */ m(X, { hidden: !0 })
144
155
  ]
145
156
  }
146
157
  );
147
158
  }
148
- const Pe = T.forwardRef(se), ge = ({ provider: s, value: e }) => {
149
- const [t, l] = X([]);
150
- return Y(() => {
159
+ const Ve = Y.forwardRef(le), we = ({ provider: s, value: e }) => {
160
+ const [t, l] = Z([]);
161
+ return C(() => {
151
162
  if (!e) {
152
163
  l([]);
153
164
  return;
154
165
  }
155
- const a = Array.isArray(e) ? e : [e];
156
- 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(
157
168
  l
158
169
  );
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,
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,
162
173
  {
163
174
  className: "m-0 p-0 position-relative",
164
175
  src: s,
165
176
  preview: {
166
- mask: /* @__PURE__ */ o(J, {})
177
+ mask: /* @__PURE__ */ m(L, {})
167
178
  }
168
179
  }
169
180
  ) });
170
181
  export {
171
- re as FileDownloadProvider,
172
- pe as FileUploadProvider,
173
- le as ImageCellValue,
174
- ge as ImageCrudCellValue,
175
- Pe as default
182
+ se as FileDownloadProvider,
183
+ ge as FileUploadProvider,
184
+ ie as ImageCellValue,
185
+ we as ImageCrudCellValue,
186
+ Ve as default
176
187
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.45.0",
4
+ "version": "1.46.1",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",