@kingteza/crud-component 1.0.9 → 1.0.11
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.
- package/dist/_virtual/ShowMoreText.cjs +1 -1
- package/dist/_virtual/advancedFormat.cjs +1 -1
- package/dist/_virtual/customParseFormat.cjs +1 -1
- package/dist/_virtual/dayjs.min.cjs +1 -1
- package/dist/_virtual/index.cjs +1 -1
- package/dist/_virtual/index10.cjs +1 -1
- package/dist/_virtual/index10.js +2 -5
- package/dist/_virtual/index2.cjs +1 -1
- package/dist/_virtual/index2.js +2 -3
- package/dist/_virtual/index3.cjs +1 -1
- package/dist/_virtual/index3.js +2 -5
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/_virtual/index4.js +2 -4
- package/dist/_virtual/index6.cjs +1 -1
- package/dist/_virtual/index6.js +5 -2
- package/dist/_virtual/index7.cjs +1 -1
- package/dist/_virtual/index7.js +5 -2
- package/dist/_virtual/index8.cjs +1 -1
- package/dist/_virtual/index8.js +7 -2
- package/dist/_virtual/index9.cjs +1 -1
- package/dist/_virtual/index9.js +2 -5
- package/dist/_virtual/localeData.cjs +1 -1
- package/dist/_virtual/main.cjs +1 -1
- package/dist/_virtual/papaparse.min.cjs +1 -1
- package/dist/_virtual/weekOfYear.cjs +1 -1
- package/dist/_virtual/weekYear.cjs +1 -1
- package/dist/_virtual/weekday.cjs +1 -1
- package/dist/common/index.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/src/components/common/DatePicker/DatePicker.cjs +1 -1
- package/dist/src/components/common/DatePicker/DatePicker.js +22 -23
- package/dist/src/components/common/DatePicker/TimePicker.cjs +1 -1
- package/dist/src/components/common/DatePicker/TimePicker.js +12 -13
- package/dist/src/components/common/appearance/Hider.cjs +1 -1
- package/dist/src/components/common/button/Button.cjs +1 -1
- package/dist/src/components/common/button/Button.js +27 -28
- package/dist/src/components/common/button/CloneButtonTable.cjs +1 -1
- package/dist/src/components/common/button/CloneButtonTable.js +3 -3
- package/dist/src/components/common/button/DeleteButtonTable.cjs +1 -1
- package/dist/src/components/common/button/DeleteButtonTable.js +7 -7
- package/dist/src/components/common/button/ExportButton.cjs +1 -1
- package/dist/src/components/common/button/ExportButton.js +5 -5
- package/dist/src/components/common/button/HideButtonTable.cjs +1 -1
- package/dist/src/components/common/button/HideButtonTable.js +7 -7
- package/dist/src/components/common/button/ImportButton.cjs +1 -1
- package/dist/src/components/common/button/ImportButton.js +5 -5
- package/dist/src/components/common/button/NewButton.cjs +1 -1
- package/dist/src/components/common/button/NewButton.js +5 -5
- package/dist/src/components/common/button/PrintButton.cjs +1 -1
- package/dist/src/components/common/button/PrintButton.js +5 -5
- package/dist/src/components/common/button/RefreshButton.cjs +1 -1
- package/dist/src/components/common/button/RefreshButton.js +5 -5
- package/dist/src/components/common/button/UnHideButton.cjs +1 -1
- package/dist/src/components/common/button/UnHideButton.js +7 -7
- package/dist/src/components/common/button/UpdateButtonTable.cjs +1 -1
- package/dist/src/components/common/button/UpdateButtonTable.js +5 -5
- package/dist/src/components/common/button/ViewButtonTable.cjs +1 -1
- package/dist/src/components/common/button/ViewButtonTable.js +5 -5
- package/dist/src/components/common/check-box/CheckBox.cjs +1 -1
- package/dist/src/components/common/check-box/CheckBox.js +15 -17
- package/dist/src/components/common/description/DescList.cjs +1 -1
- package/dist/src/components/common/description/DescList.js +1 -1
- package/dist/src/components/common/layout/VerticalSpace.cjs +1 -1
- package/dist/src/components/common/layout/VerticalSpace.js +1 -1
- package/dist/src/components/common/loading/LoadingIndicator.cjs +1 -1
- package/dist/src/components/common/loading/LoadingIndicator.js +8 -9
- package/dist/src/components/common/picker/ImagePicker.cjs +1 -1
- package/dist/src/components/common/picker/ImagePicker.js +40 -42
- package/dist/src/components/common/radio/RadioGroupComponent.cjs +1 -1
- package/dist/src/components/common/radio/RadioGroupComponent.js +16 -17
- package/dist/src/components/common/report/SelectFieldInReport.cjs +1 -1
- package/dist/src/components/common/report/SelectFieldInReport.js +16 -17
- package/dist/src/components/common/select/CustomSelectOption.cjs +1 -1
- package/dist/src/components/common/select/CustomSelectOption.js +1 -1
- package/dist/src/components/common/select/SelectComponent.cjs +1 -1
- package/dist/src/components/common/select/SelectComponent.js +33 -36
- package/dist/src/components/common/show-more/index.cjs +1 -1
- package/dist/src/components/common/tab/TabViewWithRoute.cjs +1 -1
- package/dist/src/components/common/tab/TabViewWithRoute.js +14 -15
- package/dist/src/components/common/table/table.cjs +1 -1
- package/dist/src/components/common/table/table.js +16 -16
- package/dist/src/components/common/tag/StatusTag.cjs +1 -1
- package/dist/src/components/common/tag/StatusTag.js +4 -4
- package/dist/src/components/common/text/index.cjs +1 -1
- package/dist/src/components/common/text/index.js +1 -1
- package/dist/src/components/common/text/title/index.cjs +1 -1
- package/dist/src/components/common/text/title/index.js +1 -1
- package/dist/src/components/common/text-field/NumberField.cjs +1 -1
- package/dist/src/components/common/text-field/NumberField.js +19 -20
- package/dist/src/components/common/text-field/PhoneNumberField.cjs +1 -1
- package/dist/src/components/common/text-field/TextArea.cjs +1 -1
- package/dist/src/components/common/text-field/TextArea.js +18 -19
- package/dist/src/components/common/text-field/TextField.cjs +1 -1
- package/dist/src/components/common/text-field/TextField.js +21 -22
- package/dist/src/components/common/tooltip/TooltipComponent.cjs +1 -1
- package/dist/src/components/common/tooltip/TooltipComponent.js +1 -1
- package/dist/src/components/common/wizard/WizardResult.cjs +1 -1
- package/dist/src/components/common/wizard/WizardResult.js +5 -5
- package/dist/src/components/common/wizard/WizardViewForm.cjs +1 -1
- package/dist/src/components/common/wizard/WizardViewForm.js +1 -1
- package/dist/src/components/crud/CrudComponent.cjs +1 -1
- package/dist/src/components/crud/CrudComponent.js +71 -74
- package/dist/src/components/crud/CrudField.cjs +1 -1
- package/dist/src/components/crud/CrudField.js +93 -96
- package/dist/src/components/crud/CrudForm.cjs +1 -1
- package/dist/src/components/crud/CrudForm.js +27 -30
- package/dist/src/components/crud/CrudFormWizard.cjs +1 -1
- package/dist/src/components/crud/CrudFormWizard.js +54 -57
- package/dist/src/components/crud/CrudReportComponent.cjs +3 -3
- package/dist/src/components/crud/CrudReportComponent.js +47 -51
- package/dist/src/components/crud/CrudSearchComponent.cjs +1 -1
- package/dist/src/components/crud/CrudSearchComponent.js +21 -23
- package/dist/src/components/crud/FileCrudField.cjs +1 -1
- package/dist/src/components/crud/FileCrudField.js +29 -31
- package/dist/src/components/crud/ImageCrudField.cjs +1 -1
- package/dist/src/components/crud/ImageCrudField.js +43 -46
- package/dist/src/components/crud/import/CrudImportButton.cjs +1 -1
- package/dist/src/components/crud/import/CrudImportButton.js +7 -7
- package/dist/src/components/crud/import/CrudImportComponent.cjs +2 -2
- package/dist/src/components/crud/import/CrudImportComponent.js +60 -64
- package/dist/src/components/crud/view/CrudDecListView.cjs +1 -1
- package/dist/src/components/crud/view/CrudDecListView.js +5 -5
- package/dist/src/components/crud/view/CrudViewer.cjs +1 -1
- package/dist/src/components/crud/view/CrudViewer.js +25 -25
- package/dist/src/components/crud/view/CrudViewerUtil.cjs +1 -1
- package/dist/src/components/crud/view/CrudViewerUtil.js +17 -18
- package/dist/src/context/WindowDimension.cjs +1 -1
- package/dist/src/locale/index.cjs +1 -1
- package/dist/src/locale/index.js +2 -2
- package/dist/src/locale/translations/en.cjs +1 -1
- package/dist/src/util/DateUtil.cjs +1 -1
- package/dist/src/util/DateUtil.js +4 -4
- package/dist/src/util/ImageUtil.cjs +1 -1
- package/dist/src/util/ValidationUtil.cjs +1 -1
- package/dist/src/util/ValidationUtil.js +1 -1
- package/dist/util/index.cjs +1 -1
- package/package.json +9 -7
- package/dist/_virtual/index11.cjs +0 -1
- package/dist/_virtual/index11.js +0 -7
- package/dist/_virtual/index12.cjs +0 -1
- package/dist/_virtual/index12.js +0 -4
- package/dist/_virtual/index13.cjs +0 -1
- package/dist/_virtual/index13.js +0 -4
- package/dist/_virtual/react-is.development2.cjs +0 -1
- package/dist/_virtual/react-is.development2.js +0 -4
- package/dist/_virtual/react-is.production.min2.cjs +0 -1
- package/dist/_virtual/react-is.production.min2.js +0 -4
- package/dist/common/index.d.ts +0 -2
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { j as e } from "../../../_virtual/jsx-runtime.js";
|
|
2
2
|
/* empty css */
|
|
3
|
+
import { Form as F, Upload as W, Modal as z } from "antd";
|
|
3
4
|
import M from "../../../node_modules/mime/dist/src/index.js";
|
|
4
5
|
import { useState as d, useCallback as N, useEffect as S, useMemo as E } from "react";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import z from "../../util/ValidationUtil.js";
|
|
6
|
+
import { TRANSLATION_NAMESPACE as G } from "../../locale/hooks/translation-constants.js";
|
|
7
|
+
import J from "../../util/ValidationUtil.js";
|
|
8
8
|
import g from "../common/button/Button.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import Y from "../../../node_modules/@ant-design/icons/es/icons/FileTextOutlined.js";
|
|
16
|
-
import Z from "../../../node_modules/@ant-design/icons/es/icons/FileWordOutlined.js";
|
|
9
|
+
import K from "../common/layout/VerticalSpace.js";
|
|
10
|
+
import Q from "../../../node_modules/@ant-design/icons/es/icons/FileOutlined.js";
|
|
11
|
+
import X from "../../../node_modules/@ant-design/icons/es/icons/FilePptOutlined.js";
|
|
12
|
+
import Y from "../../../node_modules/@ant-design/icons/es/icons/FileExcelOutlined.js";
|
|
13
|
+
import Z from "../../../node_modules/@ant-design/icons/es/icons/FileTextOutlined.js";
|
|
14
|
+
import m from "../../../node_modules/@ant-design/icons/es/icons/FileWordOutlined.js";
|
|
17
15
|
import v from "../../../node_modules/@ant-design/icons/es/icons/FilePdfOutlined.js";
|
|
18
16
|
import y from "../../../node_modules/@ant-design/icons/es/icons/FileImageOutlined.js";
|
|
19
|
-
import T from "../../../node_modules/
|
|
17
|
+
import { useTranslation as T } from "../../../node_modules/react-i18next/dist/es/useTranslation.js";
|
|
20
18
|
import tt from "../../../node_modules/@ant-design/icons/es/icons/ExportOutlined.js";
|
|
21
|
-
function
|
|
19
|
+
function It({
|
|
22
20
|
name: o,
|
|
23
21
|
label: t,
|
|
24
22
|
required: r,
|
|
@@ -32,13 +30,13 @@ function Pt({
|
|
|
32
30
|
block: k,
|
|
33
31
|
...O
|
|
34
32
|
}) {
|
|
35
|
-
const u = F.useFormInstance(), h = F.useWatch(o, u), [P, $] = d(!1), [R, _] = d(!1),
|
|
33
|
+
const u = F.useFormInstance(), h = F.useWatch(o, u), [P, $] = d(!1), [R, _] = d(!1), L = N(
|
|
36
34
|
async (n) => {
|
|
37
35
|
var c, a;
|
|
38
36
|
try {
|
|
39
37
|
const { file: i } = n, j = i.name;
|
|
40
38
|
$(!0), _(!0), l == null || l(!0);
|
|
41
|
-
const w = j ?? "", b = w.split("."),
|
|
39
|
+
const w = j ?? "", b = w.split("."), B = b[b.length - 1], H = s.generateFileName(w), A = `${await s.getInitialPath()}/${H}.${B}`;
|
|
42
40
|
console.log({ filePath: A });
|
|
43
41
|
const D = await s.upload(
|
|
44
42
|
{ ...i, originFileObj: i },
|
|
@@ -71,7 +69,7 @@ function Pt({
|
|
|
71
69
|
return console.log(c), c;
|
|
72
70
|
}));
|
|
73
71
|
}, [h, R, P, s]);
|
|
74
|
-
const
|
|
72
|
+
const q = N(
|
|
75
73
|
async (n) => {
|
|
76
74
|
const c = n.response, a = c || u.getFieldValue(o);
|
|
77
75
|
await s.delete(a), f == null || f(), n && u.setFieldsValue({ [o]: null });
|
|
@@ -86,20 +84,20 @@ function Pt({
|
|
|
86
84
|
name: o,
|
|
87
85
|
className: x,
|
|
88
86
|
rules: [
|
|
89
|
-
...r ?
|
|
87
|
+
...r ? J.required(t) : [],
|
|
90
88
|
...U ?? []
|
|
91
89
|
],
|
|
92
90
|
children: [
|
|
93
91
|
/* @__PURE__ */ e.jsx("input", { hidden: !0 }),
|
|
94
92
|
/* @__PURE__ */ e.jsx(
|
|
95
|
-
|
|
93
|
+
W,
|
|
96
94
|
{
|
|
97
95
|
...O,
|
|
98
96
|
fileList: p,
|
|
99
97
|
className: ((p == null ? void 0 : p.length) ?? 0) >= C ? "hide-upload" : "",
|
|
100
98
|
maxCount: C,
|
|
101
|
-
customRequest:
|
|
102
|
-
onRemove:
|
|
99
|
+
customRequest: L,
|
|
100
|
+
onRemove: q,
|
|
103
101
|
listType: "picture",
|
|
104
102
|
onChange: ({ fileList: n }) => {
|
|
105
103
|
V(n);
|
|
@@ -112,7 +110,7 @@ function Pt({
|
|
|
112
110
|
}
|
|
113
111
|
);
|
|
114
112
|
}
|
|
115
|
-
const
|
|
113
|
+
const Ct = ({ provider: o, value: t }) => {
|
|
116
114
|
const [r, s] = d();
|
|
117
115
|
return S(() => {
|
|
118
116
|
t && o.getRealUrl(t).then((l) => {
|
|
@@ -138,20 +136,20 @@ const $t = ({ provider: o, value: t }) => {
|
|
|
138
136
|
case "pdf":
|
|
139
137
|
return /* @__PURE__ */ e.jsx(v, {});
|
|
140
138
|
case "word":
|
|
141
|
-
return /* @__PURE__ */ e.jsx(
|
|
139
|
+
return /* @__PURE__ */ e.jsx(m, {});
|
|
142
140
|
case "text":
|
|
143
|
-
return /* @__PURE__ */ e.jsx(
|
|
141
|
+
return /* @__PURE__ */ e.jsx(Z, {});
|
|
144
142
|
case "excel":
|
|
145
|
-
return /* @__PURE__ */ e.jsx(
|
|
143
|
+
return /* @__PURE__ */ e.jsx(Y, {});
|
|
146
144
|
case "presentation":
|
|
147
|
-
return /* @__PURE__ */ e.jsx(
|
|
145
|
+
return /* @__PURE__ */ e.jsx(X, {});
|
|
148
146
|
default:
|
|
149
|
-
return /* @__PURE__ */ e.jsx(
|
|
147
|
+
return /* @__PURE__ */ e.jsx(Q, {});
|
|
150
148
|
}
|
|
151
|
-
}, [s]), [f, x] = d(!1), { t: I } =
|
|
149
|
+
}, [s]), [f, x] = d(!1), { t: I } = T(G);
|
|
152
150
|
return s !== "file" && s !== "text" ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
153
151
|
/* @__PURE__ */ e.jsx(
|
|
154
|
-
|
|
152
|
+
z,
|
|
155
153
|
{
|
|
156
154
|
open: f,
|
|
157
155
|
title: r,
|
|
@@ -160,7 +158,7 @@ const $t = ({ provider: o, value: t }) => {
|
|
|
160
158
|
width: "100%",
|
|
161
159
|
style: { top: "8px", minHeight: "700px" },
|
|
162
160
|
destroyOnClose: !0,
|
|
163
|
-
children: /* @__PURE__ */ e.jsxs(
|
|
161
|
+
children: /* @__PURE__ */ e.jsxs(K, { children: [
|
|
164
162
|
/* @__PURE__ */ e.jsx(
|
|
165
163
|
g,
|
|
166
164
|
{
|
|
@@ -224,6 +222,6 @@ const $t = ({ provider: o, value: t }) => {
|
|
|
224
222
|
};
|
|
225
223
|
export {
|
|
226
224
|
et as FileCellValue,
|
|
227
|
-
|
|
228
|
-
|
|
225
|
+
Ct as FileCrudCellValue,
|
|
226
|
+
It as default
|
|
229
227
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var S=Object.defineProperty;var _=(e,
|
|
1
|
+
"use strict";var S=Object.defineProperty;var _=(e,a,t)=>a in e?S(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t;var d=(e,a,t)=>_(e,typeof a!="symbol"?a+"":a,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("../../../_virtual/jsx-runtime.cjs");;/* empty css */const u=require("antd"),I=require("../../../_virtual/index.cjs"),i=require("react"),O=require("../../util/NumberUtil.cjs"),k=require("../../util/ValidationUtil.cjs"),A=require("../common/picker/ImagePicker.cjs"),D=require("../../../node_modules/uuid/dist/esm-browser/v4.cjs"),M=require("../../../node_modules/@ant-design/icons/es/icons/EyeOutlined.cjs");class p{}class T extends p{constructor(t="",s=""){super();d(this,"rootPath");d(this,"subPath");this.rootPath=t,this.subPath=s}cloneFilePath(t){const s=I.parse(t),r=`${s.name}_cloned_${O.default.randInt(1e5)}`;return I.format({dir:s.dir,ext:s.ext,name:r})}generateFileName(t){return`${t.split(".")[0]}_${D().replace("-","")}`}}function W({name:e,label:a,required:t,provider:s,onUploading:r,aspectRatio:h,onRemoved:o,fieldClassName:g,hideLabel:q=!1,listType:w}){const c=u.Form.useFormInstance(),f=u.Form.useWatch(e,c),[F,C]=i.useState(!1),P=i.useCallback(async(n,N)=>{if(N){r==null||r(!0);const m=n.name,x=m.split("."),V=x[x.length-1],y=s.generateFileName(m),$=`${await s.getInitialPath()}/${y}.${V}`,b=await s.upload(n,$);C(!0),r==null||r(!1),c.setFieldValue(e,b)}else{console.log(n);const m=c.getFieldsValue(),x=await s.delete(m[e]);o==null||o(),x&&c.setFieldsValue({[e]:null})}},[c,e,o,r,s]),[j,E]=i.useState();return i.useEffect(()=>{!F&&f?s.getRealUrl(f).then(E):E(j)},[f,F,s,j]),l.jsxRuntimeExports.jsx(l.jsxRuntimeExports.Fragment,{children:l.jsxRuntimeExports.jsxs(u.Form.Item,{rules:t?k.required(a):[],label:q?null:a,required:t,name:e,children:[l.jsxRuntimeExports.jsx(A.default,{noStyle:!0,listType:w,aspectRatio:h,values:j,onRemove:n=>{n&&P(n,!1)},onAdd:async n=>{n&&await P(n,!0)},className:g}),l.jsxRuntimeExports.jsx(u.Input,{hidden:!0})]})})}const z=({provider:e,value:a})=>{const[t,s]=i.useState();return i.useEffect(()=>{a&&e.getRealUrl(a).then(s)},[e,a]),t?l.jsxRuntimeExports.jsx(R,{url:t}):l.jsxRuntimeExports.jsx(l.jsxRuntimeExports.Fragment,{})},R=({url:e})=>l.jsxRuntimeExports.jsx(u.Avatar,{className:"p-0",children:l.jsxRuntimeExports.jsx(u.Image,{className:"m-0 p-0 position-relative",src:e,preview:{mask:l.jsxRuntimeExports.jsx(M,{})}})});exports.FileDownloadProvider=p;exports.FileUploadProvider=T;exports.ImageCellValue=R;exports.ImageCrudCellValue=z;exports.default=W;
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
var A = Object.defineProperty;
|
|
2
2
|
var E = (e, a, t) => a in e ? A(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
|
|
3
3
|
var h = (e, a, t) => E(e, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
-
import { j as
|
|
4
|
+
import { j as l } from "../../../_virtual/jsx-runtime.js";
|
|
5
5
|
/* empty css */
|
|
6
|
+
import { Form as x, Input as O, Avatar as S, Image as D } from "antd";
|
|
6
7
|
import N from "../../../_virtual/index.js";
|
|
7
|
-
import { useState as F, useCallback as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import q from "../../../node_modules/antd/es/input/index.js";
|
|
13
|
-
import z from "../../../node_modules/uuid/dist/esm-browser/v4.js";
|
|
14
|
-
import B from "../../../node_modules/antd/es/avatar/index.js";
|
|
15
|
-
import G from "../../../node_modules/antd/es/image/index.js";
|
|
8
|
+
import { useState as F, useCallback as W, useEffect as w } from "react";
|
|
9
|
+
import q from "../../util/NumberUtil.js";
|
|
10
|
+
import z from "../../util/ValidationUtil.js";
|
|
11
|
+
import B from "../common/picker/ImagePicker.js";
|
|
12
|
+
import G from "../../../node_modules/uuid/dist/esm-browser/v4.js";
|
|
16
13
|
import H from "../../../node_modules/@ant-design/icons/es/icons/EyeOutlined.js";
|
|
17
14
|
class J {
|
|
18
15
|
}
|
|
19
|
-
class
|
|
16
|
+
class te extends J {
|
|
20
17
|
constructor(t = "", s = "") {
|
|
21
18
|
super();
|
|
22
19
|
h(this, "rootPath");
|
|
@@ -24,93 +21,93 @@ class re extends J {
|
|
|
24
21
|
this.rootPath = t, this.subPath = s;
|
|
25
22
|
}
|
|
26
23
|
cloneFilePath(t) {
|
|
27
|
-
const s = N.parse(t),
|
|
24
|
+
const s = N.parse(t), r = `${s.name}_cloned_${q.randInt(1e5)}`;
|
|
28
25
|
return N.format({
|
|
29
26
|
dir: s.dir,
|
|
30
27
|
ext: s.ext,
|
|
31
|
-
name:
|
|
28
|
+
name: r
|
|
32
29
|
});
|
|
33
30
|
}
|
|
34
31
|
generateFileName(t) {
|
|
35
|
-
return `${t.split(".")[0]}_${
|
|
32
|
+
return `${t.split(".")[0]}_${G().replace("-", "")}`;
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
function
|
|
35
|
+
function se({
|
|
39
36
|
name: e,
|
|
40
37
|
label: a,
|
|
41
38
|
required: t,
|
|
42
39
|
provider: s,
|
|
43
|
-
onUploading:
|
|
44
|
-
aspectRatio:
|
|
45
|
-
onRemoved:
|
|
40
|
+
onUploading: r,
|
|
41
|
+
aspectRatio: I,
|
|
42
|
+
onRemoved: c,
|
|
46
43
|
fieldClassName: d,
|
|
47
44
|
hideLabel: V = !1,
|
|
48
45
|
listType: C
|
|
49
46
|
}) {
|
|
50
|
-
const
|
|
51
|
-
async (
|
|
47
|
+
const i = x.useFormInstance(), u = x.useWatch(e, i), [P, $] = F(!1), p = W(
|
|
48
|
+
async (n, g) => {
|
|
52
49
|
if (g) {
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
$(!0),
|
|
50
|
+
r == null || r(!0);
|
|
51
|
+
const m = n.name, o = m.split("."), y = o[o.length - 1], b = s.generateFileName(m), k = `${await s.getInitialPath()}/${b}.${y}`, _ = await s.upload(n, k);
|
|
52
|
+
$(!0), r == null || r(!1), i.setFieldValue(e, _);
|
|
56
53
|
} else {
|
|
57
|
-
console.log(
|
|
58
|
-
const
|
|
59
|
-
|
|
54
|
+
console.log(n);
|
|
55
|
+
const m = i.getFieldsValue(), o = await s.delete(m[e]);
|
|
56
|
+
c == null || c(), o && i.setFieldsValue({ [e]: null });
|
|
60
57
|
}
|
|
61
58
|
},
|
|
62
|
-
[
|
|
59
|
+
[i, e, c, r, s]
|
|
63
60
|
), [f, j] = F();
|
|
64
61
|
return w(() => {
|
|
65
|
-
!
|
|
66
|
-
}, [u,
|
|
62
|
+
!P && u ? s.getRealUrl(u).then(j) : j(f);
|
|
63
|
+
}, [u, P, s, f]), /* @__PURE__ */ l.jsx(l.Fragment, { children: /* @__PURE__ */ l.jsxs(
|
|
67
64
|
x.Item,
|
|
68
65
|
{
|
|
69
|
-
rules: t ?
|
|
66
|
+
rules: t ? z.required(a) : [],
|
|
70
67
|
label: V ? null : a,
|
|
71
68
|
required: t,
|
|
72
69
|
name: e,
|
|
73
70
|
children: [
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
|
|
71
|
+
/* @__PURE__ */ l.jsx(
|
|
72
|
+
B,
|
|
76
73
|
{
|
|
77
74
|
noStyle: !0,
|
|
78
75
|
listType: C,
|
|
79
|
-
aspectRatio:
|
|
76
|
+
aspectRatio: I,
|
|
80
77
|
values: f,
|
|
81
|
-
onRemove: (
|
|
82
|
-
|
|
78
|
+
onRemove: (n) => {
|
|
79
|
+
n && p(n, !1);
|
|
83
80
|
},
|
|
84
|
-
onAdd: async (
|
|
85
|
-
|
|
81
|
+
onAdd: async (n) => {
|
|
82
|
+
n && await p(n, !0);
|
|
86
83
|
},
|
|
87
84
|
className: d
|
|
88
85
|
}
|
|
89
86
|
),
|
|
90
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ l.jsx(O, { hidden: !0 })
|
|
91
88
|
]
|
|
92
89
|
}
|
|
93
90
|
) });
|
|
94
91
|
}
|
|
95
|
-
const
|
|
92
|
+
const ae = ({ provider: e, value: a }) => {
|
|
96
93
|
const [t, s] = F();
|
|
97
94
|
return w(() => {
|
|
98
95
|
a && e.getRealUrl(a).then(s);
|
|
99
|
-
}, [e, a]), t ? /* @__PURE__ */
|
|
100
|
-
}, K = ({ url: e }) => /* @__PURE__ */
|
|
101
|
-
|
|
96
|
+
}, [e, a]), t ? /* @__PURE__ */ l.jsx(K, { url: t }) : /* @__PURE__ */ l.jsx(l.Fragment, {});
|
|
97
|
+
}, K = ({ url: e }) => /* @__PURE__ */ l.jsx(S, { className: "p-0", children: /* @__PURE__ */ l.jsx(
|
|
98
|
+
D,
|
|
102
99
|
{
|
|
103
100
|
className: "m-0 p-0 position-relative",
|
|
104
101
|
src: e,
|
|
105
102
|
preview: {
|
|
106
|
-
mask: /* @__PURE__ */
|
|
103
|
+
mask: /* @__PURE__ */ l.jsx(H, {})
|
|
107
104
|
}
|
|
108
105
|
}
|
|
109
106
|
) });
|
|
110
107
|
export {
|
|
111
108
|
J as FileDownloadProvider,
|
|
112
|
-
|
|
109
|
+
te as FileUploadProvider,
|
|
113
110
|
K as ImageCellValue,
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
ae as ImageCrudCellValue,
|
|
112
|
+
se as default
|
|
116
113
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const t=require("../../../../_virtual/jsx-runtime.cjs"),o=require("react"),u=require("../../../locale/hooks/translation-constants.cjs"),i=require("./CrudImportComponent.cjs"),c=require("../../common/button/Button.cjs"),p=require("../../../../node_modules/react-i18next/dist/es/useTranslation.cjs"),x=require("../../../../node_modules/@ant-design/icons/es/icons/ImportOutlined.cjs");function m(n){const{t:s}=p.useTranslation(u.TRANSLATION_NAMESPACE),[r,e]=o.useState(!1);return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(i,{open:r,onCloseMethod:e,...n}),t.jsxRuntimeExports.jsx(c,{icon:t.jsxRuntimeExports.jsx(x,{}),onClick:()=>e(!0),children:s("str.import")})]})}module.exports=m;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { j as o } from "../../../../_virtual/jsx-runtime.js";
|
|
2
2
|
import { useState as e } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import i from "
|
|
6
|
-
import f from "
|
|
3
|
+
import { TRANSLATION_NAMESPACE as p } from "../../../locale/hooks/translation-constants.js";
|
|
4
|
+
import s from "./CrudImportComponent.js";
|
|
5
|
+
import i from "../../common/button/Button.js";
|
|
6
|
+
import { useTranslation as f } from "../../../../node_modules/react-i18next/dist/es/useTranslation.js";
|
|
7
7
|
import u from "../../../../node_modules/@ant-design/icons/es/icons/ImportOutlined.js";
|
|
8
8
|
function I(r) {
|
|
9
|
-
const { t: n } = p
|
|
9
|
+
const { t: n } = f(p), [m, t] = e(!1);
|
|
10
10
|
return /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
|
|
11
11
|
/* @__PURE__ */ o.jsx(
|
|
12
|
-
|
|
12
|
+
s,
|
|
13
13
|
{
|
|
14
14
|
open: m,
|
|
15
15
|
onCloseMethod: t,
|
|
@@ -17,7 +17,7 @@ function I(r) {
|
|
|
17
17
|
}
|
|
18
18
|
),
|
|
19
19
|
/* @__PURE__ */ o.jsx(
|
|
20
|
-
|
|
20
|
+
i,
|
|
21
21
|
{
|
|
22
22
|
icon: /* @__PURE__ */ o.jsx(u, {}),
|
|
23
23
|
onClick: () => t(!0),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});
|
|
1
|
+
"use strict";const s=require("../../../../_virtual/jsx-runtime.cjs"),M=require("../../../../_virtual/papaparse.min.cjs"),d=require("antd"),B=require("../../../../_virtual/FileSaver.min.cjs"),o=require("react"),O=require("../../../locale/hooks/translation-constants.cjs"),V=require("../view/CrudViewer.cjs"),_=require("../../../util/DateUtil.cjs"),L=require("../../common/button/Button.cjs"),W=require("../../common/button/ImportButton.cjs"),z=require("../../../../node_modules/react-i18next/dist/es/useTranslation.cjs"),N=require("../../../../node_modules/@ant-design/icons/es/icons/WarningTwoTone.cjs"),$=require("../../../../node_modules/@ant-design/icons/es/icons/DownloadOutlined.cjs");function U({onCloseMethod:E,open:b,fields:q,importProps:a}){const[u,w]=o.useState([]),[C,h]=o.useState(!1),[T,g]=o.useState(0);o.useEffect(()=>{b||(w([]),h(!1))},[b]);const f=o.useMemo(()=>new Map(q.filter(e=>{var t;return!e.hidden&&!((t=e.importProps)!=null&&t.hidden)&&!e.readonly}).map(e=>[e.name,e])),[q]),v=o.useMemo(()=>Array.from(f.values()).flatMap(e=>{var t;return[e.name,...((t=e.importProps)==null?void 0:t.extraFields)??[]]}),[f]),F=o.useCallback(async function(){const e=`${v.join(",")}
|
|
2
|
+
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});B.FileSaver_minExports.saveAs(t,(a==null?void 0:a.name)+" - "+_.formatDateTimeWithSecond(new Date).replaceAll(":","-")+".csv")},[v,a==null?void 0:a.name]),{t:l}=z.useTranslation(O.TRANSLATION_NAMESPACE),D=o.useCallback(async e=>{const t=new FileReader;t.onerror=console.error,t.onload=async r=>{var n;const c=(n=r==null?void 0:r.target)==null?void 0:n.result,i=M.parse(c,{header:!0});w(i.data)},t.readAsText(e)},[]),y=o.useMemo(()=>{var t,r,c;let e=!1;for(const i of u)for(const[n,x]of f.entries()){const j=i[n],m=j||!isNaN(j);if(x.required&&!m)if((r=(t=x.importProps)==null?void 0:t.extraFields)!=null&&r.length)for(const R of((c=x.importProps)==null?void 0:c.extraFields)??[])if(i[R]||!isNaN(i[R])){e=!1;break}else return!0;else return!0}return e},[u,f]),p=o.useCallback(e=>(t,r)=>{var i,n,x;const c=t||!isNaN(t);if(e.required&&!c){let j=l("err.validation.required");if((n=(i=e.importProps)==null?void 0:i.extraFields)!=null&&n.length){const m=(x=e.importProps)==null?void 0:x.extraFields;(m==null?void 0:m.find(A=>!r[A]))&&(j="Either one of these fields is required: "+[e.name,...m].join(", "))}return s.jsxRuntimeExports.jsxs(d.Tooltip,{className:"d-flex",title:j,children:[s.jsxRuntimeExports.jsx(N,{twoToneColor:"#ee9702"}),t]})}return t},[l]),S=o.useCallback(async e=>{g(e)},[]),k=o.useCallback(async()=>{try{h(!0),await a.onClickImport(u,S),E(!1)}finally{h(!1),g(0)}},[u,a,E,S]),I=o.useCallback(async()=>{y?d.Modal.warn({title:l("str.warning"),content:l("qus.importWithIssues"),okText:l("str.import"),onOk:k,okCancel:!0,closable:!0}):k()},[y,k,l]);return s.jsxRuntimeExports.jsxs(d.Modal,{title:[l("str.import"),a==null?void 0:a.name].filter(Boolean).join(" "),width:"100%",open:b,onOk:I,destroyOnClose:!0,onCancel:()=>E(!1),okText:l("str.import"),confirmLoading:C,okButtonProps:{disabled:!(u!=null&&u.length)},footer:(e,{OkBtn:t,CancelBtn:r})=>s.jsxRuntimeExports.jsxs(d.Space,{children:[s.jsxRuntimeExports.jsx(r,{}),s.jsxRuntimeExports.jsx(t,{}),y&&s.jsxRuntimeExports.jsx(d.Tooltip,{className:"d-flex",title:"Some fields have issue. Please review before submit.",children:s.jsxRuntimeExports.jsx(N,{twoToneColor:"#ee9702"})})]}),children:[s.jsxRuntimeExports.jsxs(d.Space,{children:[s.jsxRuntimeExports.jsx(L,{onClick:F,icon:s.jsxRuntimeExports.jsx($,{}),children:l("str.downloadCsvTemplate")}),s.jsxRuntimeExports.jsx(W.ImportButton,{disabled:C,type:"default",onClick:D,accept:".csv",children:l("str.importCsvFile")})]}),s.jsxRuntimeExports.jsx(d.Spin,{spinning:C,indicator:T?s.jsxRuntimeExports.jsx(d.Progress,{type:"circle",percent:T*100,size:50,format:e=>`${parseInt(e)}%`}):void 0,children:s.jsxRuntimeExports.jsx(V,{data:u,bordered:!0,size:"small",fields:Array.from(f.values()).flatMap(e=>{var t,r,c,i;return e.type==="text"?[{...e,label:e.name,render:p(e)},...((r=(t=e.importProps)==null?void 0:t.extraFields)==null?void 0:r.map(n=>({...e,name:n,label:n,render:p(e)})))??[]]:e.type==="select"?[{...e,label:e.name,type:"text",render:p(e)},...((i=(c=e.importProps)==null?void 0:c.extraFields)==null?void 0:i.map(n=>({...e,name:n,label:n,type:"text",render:p(e)})))??[]]:[{...e,label:e.name,render:p(e)}]})})})]})}module.exports=U;
|