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