@kingteza/crud-component 1.10.0 → 1.10.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,6 +1,6 @@
1
1
  import { UploadListType } from 'antd/es/upload/interface';
2
2
  import { UploadFile } from 'antd/lib';
3
- import { default as React, FC, ForwardedRef } from 'react';
3
+ import { FC, ReactElement, Ref } from 'react';
4
4
  import { InitialCrudField } from './CrudComponent';
5
5
  export interface _ImageCrudField<T> extends InitialCrudField<T> {
6
6
  provider: FileUploadProvider;
@@ -31,9 +31,10 @@ export declare abstract class FileUploadProvider extends FileDownloadProvider {
31
31
  export interface ImageCrudFieldRef {
32
32
  uploadBlob: (blob: Blob, fileName: string) => Promise<void>;
33
33
  }
34
- declare function Component<T>({ name, label, required, provider, onUploading, aspectRatio, onRemoved, fieldClassName, hideLabel, listType, fieldHelper: help, }: Readonly<_ImageCrudField<T>>, ref: ForwardedRef<ImageCrudFieldRef>): import("react/jsx-runtime").JSX.Element;
35
- declare const ImageCrudFieldComponent: <T>(props: React.ComponentProps<typeof Component<T>>, ref: React.Ref<any>) => React.ReactElement | null;
36
- export default ImageCrudFieldComponent;
34
+ declare const ImageCrudField: <T>(p: Readonly<_ImageCrudField<T>> & {
35
+ ref?: Ref<ImageCrudFieldRef>;
36
+ }) => ReactElement;
37
+ export default ImageCrudField;
37
38
  export declare const ImageCrudCellValue: FC<{
38
39
  value: string;
39
40
  provider: FileDownloadProvider;
@@ -1,6 +1,6 @@
1
1
  var A = Object.defineProperty;
2
2
  var B = (e, s, t) => s in e ? A(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
- var F = (e, s, t) => B(e, typeof s != "symbol" ? s + "" : s, t);
3
+ var p = (e, s, t) => B(e, typeof s != "symbol" ? s + "" : s, t);
4
4
  import { jsx as n, Fragment as E, jsxs as H } from "react/jsx-runtime";
5
5
  /* empty css */
6
6
  import { EyeOutlined as D } from "@ant-design/icons";
@@ -14,11 +14,11 @@ import R from "../common/picker/ImagePicker.es.js";
14
14
  import T from "../util/ImageUtil.es.js";
15
15
  class X {
16
16
  }
17
- class me extends X {
17
+ class ue extends X {
18
18
  constructor(t = "", a = "") {
19
19
  super();
20
- F(this, "rootPath");
21
- F(this, "subPath");
20
+ p(this, "rootPath");
21
+ p(this, "subPath");
22
22
  this.rootPath = t, this.subPath = a;
23
23
  }
24
24
  cloneFilePath(t) {
@@ -40,46 +40,46 @@ function Y({
40
40
  provider: a,
41
41
  onUploading: l,
42
42
  aspectRatio: P,
43
- onRemoved: m,
44
- fieldClassName: C,
45
- hideLabel: V = !1,
46
- listType: x,
43
+ onRemoved: u,
44
+ fieldClassName: V,
45
+ hideLabel: x = !1,
46
+ listType: C,
47
47
  fieldHelper: $
48
48
  }, b) {
49
- const c = d.useFormInstance(), h = d.useWatch(e, c), [w, O] = I(!1), u = G(
49
+ const o = d.useFormInstance(), h = d.useWatch(e, o), [w, O] = I(!1), m = G(
50
50
  async (r, f) => {
51
51
  if (f) {
52
52
  l == null || l(!0);
53
- const i = r.name, o = i.split("."), j = o[o.length - 1], k = a.generateFileName(i), S = `${await a.getInitialPath()}/${k}.${j}`, _ = await a.upload(r, S);
54
- O(!0), l == null || l(!1), c.setFieldValue(e, _);
53
+ const i = r.name, c = i.split("."), j = c[c.length - 1], k = a.generateFileName(i), S = `${await a.getInitialPath()}/${k}.${j}`, _ = await a.upload(r, S);
54
+ O(!0), l == null || l(!1), o.setFieldValue(e, _);
55
55
  } else {
56
- const i = c.getFieldsValue(), o = await a.delete(i[e]);
57
- m == null || m(), o && c.setFieldsValue({ [e]: null });
56
+ const i = o.getFieldsValue(), c = await a.delete(i[e]);
57
+ u == null || u(), c && o.setFieldsValue({ [e]: null });
58
58
  }
59
59
  },
60
- [c, e, m, l, a]
61
- ), [p, g] = I();
60
+ [o, e, u, l, a]
61
+ ), [F, g] = I();
62
62
  return y(() => {
63
- !w && h ? a.getRealUrl(h).then(g) : g(p);
64
- }, [h, w, a, p]), J(
63
+ !w && h ? a.getRealUrl(h).then(g) : g(F);
64
+ }, [h, w, a, F]), J(
65
65
  b,
66
66
  () => ({
67
67
  async uploadBlob(r, f) {
68
- const i = await T.getBase64(r), o = {
68
+ const i = await T.getBase64(r), c = {
69
69
  name: f,
70
70
  uid: f + Math.random().toString(36).substring(2, 15),
71
71
  url: i,
72
72
  originFileObj: r
73
73
  };
74
- return u(o, !0);
74
+ return m(c, !0);
75
75
  }
76
76
  }),
77
- [u]
77
+ [m]
78
78
  ), /* @__PURE__ */ H(
79
79
  d.Item,
80
80
  {
81
81
  rules: t ? L.required(s) : [],
82
- label: V ? null : s,
82
+ label: x ? null : s,
83
83
  required: t,
84
84
  name: e,
85
85
  help: $,
@@ -88,16 +88,16 @@ function Y({
88
88
  R,
89
89
  {
90
90
  noStyle: !0,
91
- listType: x,
91
+ listType: C,
92
92
  aspectRatio: P,
93
- values: p,
93
+ values: F,
94
94
  onRemove: (r) => {
95
- r && u(r, !1);
95
+ r && m(r, !1);
96
96
  },
97
97
  onAdd: async (r) => {
98
- r && await u(r, !0);
98
+ r && await m(r, !0);
99
99
  },
100
- className: C
100
+ className: V
101
101
  }
102
102
  ),
103
103
  /* @__PURE__ */ n(q, { hidden: !0 })
@@ -105,7 +105,7 @@ function Y({
105
105
  }
106
106
  );
107
107
  }
108
- const ue = z.forwardRef(Y), fe = ({ provider: e, value: s }) => {
108
+ const me = z.forwardRef(Y), fe = ({ provider: e, value: s }) => {
109
109
  const [t, a] = I();
110
110
  return y(() => {
111
111
  s && e.getRealUrl(s).then(a);
@@ -122,8 +122,8 @@ const ue = z.forwardRef(Y), fe = ({ provider: e, value: s }) => {
122
122
  ) });
123
123
  export {
124
124
  X as FileDownloadProvider,
125
- me as FileUploadProvider,
125
+ ue as FileUploadProvider,
126
126
  Z as ImageCellValue,
127
127
  fe as ImageCrudCellValue,
128
- ue as default
128
+ me as default
129
129
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.10.0",
4
+ "version": "1.10.1",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",