@unimaze/billing 0.21.69 → 0.21.71

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.
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import { AttachmentType } from "./index";
3
+ import { UploadFile } from "antd/es/upload/interface";
4
+ interface Props {
5
+ attachments: AttachmentType[];
6
+ setIsModalOpen: (isModalOpen: boolean) => void;
7
+ removeFile: (file: UploadFile) => void;
8
+ }
9
+ declare const AttachmentList: React.FC<Props>;
10
+ export default AttachmentList;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ var React = __importStar(require("react"));
63
+ var antd_1 = require("antd");
64
+ var icons_1 = require("@ant-design/icons");
65
+ var index_1 = require("./index");
66
+ var react_intl_1 = require("react-intl");
67
+ var FileUploadUtility_1 = require("../../../utils/FileUploadUtility");
68
+ var AttachmentList = function (_a) {
69
+ var attachments = _a.attachments, setIsModalOpen = _a.setIsModalOpen, removeFile = _a.removeFile;
70
+ var _b = React.useState(false), previewOpen = _b[0], setPreviewOpen = _b[1];
71
+ var _c = React.useState(undefined), previewImage = _c[0], setPreviewImage = _c[1];
72
+ var _d = React.useState(""), previewDescription = _d[0], setPreviewDescription = _d[1];
73
+ var _e = React.useState(""), previewPDFUrl = _e[0], setPreviewPDFUrl = _e[1];
74
+ var intl = (0, react_intl_1.useIntl)();
75
+ var token = antd_1.theme.useToken().token;
76
+ var handlePreview = function (file, description) { return __awaiter(void 0, void 0, void 0, function () {
77
+ var reader, _a;
78
+ return __generator(this, function (_b) {
79
+ switch (_b.label) {
80
+ case 0:
81
+ if (!file.originFileObj)
82
+ return [2 /*return*/];
83
+ if (!(file.type === "application/pdf")) return [3 /*break*/, 1];
84
+ reader = new FileReader();
85
+ reader.onload = function (e) {
86
+ var blob = file.originFileObj ? new Blob([file.originFileObj], { type: "application/pdf" }) : null;
87
+ if (blob) {
88
+ var url = URL.createObjectURL(blob);
89
+ setPreviewPDFUrl(url);
90
+ }
91
+ };
92
+ reader.readAsArrayBuffer(file.originFileObj);
93
+ return [3 /*break*/, 4];
94
+ case 1:
95
+ if (!(!file.url && !file.preview)) return [3 /*break*/, 3];
96
+ _a = file;
97
+ return [4 /*yield*/, (0, FileUploadUtility_1.getBase64)(file.originFileObj)];
98
+ case 2:
99
+ _a.preview = (_b.sent());
100
+ _b.label = 3;
101
+ case 3:
102
+ setPreviewImage(file.url || file.preview);
103
+ _b.label = 4;
104
+ case 4:
105
+ setPreviewDescription(description);
106
+ setPreviewOpen(true);
107
+ return [2 /*return*/];
108
+ }
109
+ });
110
+ }); };
111
+ var handleClosePreview = function () {
112
+ if (previewPDFUrl) {
113
+ URL.revokeObjectURL(previewPDFUrl);
114
+ setPreviewPDFUrl("");
115
+ }
116
+ if (previewImage) {
117
+ setPreviewImage("");
118
+ }
119
+ setPreviewDescription("");
120
+ setPreviewOpen(false);
121
+ };
122
+ return (React.createElement(React.Fragment, null,
123
+ React.createElement(antd_1.Flex, { vertical: true, gap: "small" },
124
+ React.createElement(antd_1.Flex, { vertical: true },
125
+ React.createElement(antd_1.Typography.Text, { disabled: true }, intl.formatMessage(index_1.translationMessages.attachment_title))),
126
+ React.createElement(antd_1.Divider, { style: { padding: 0, margin: 0 } }),
127
+ attachments.map(function (attachment) { return (React.createElement(antd_1.Flex, { key: attachment.uid, gap: "middle", justify: "space-between" },
128
+ React.createElement(antd_1.Button, { type: "link", onClick: function () { return handlePreview(attachment.file, attachment.description); }, style: { padding: 0 }, size: "small" },
129
+ React.createElement(icons_1.PaperClipOutlined, { style: { fontSize: token.fontSizeIcon } }),
130
+ attachment.file.name),
131
+ React.createElement(antd_1.Flex, { gap: "middle" },
132
+ React.createElement(icons_1.EditOutlined, { style: { fontSize: token.fontSizeHeading4 }, onClick: function () {
133
+ setIsModalOpen(true);
134
+ } }),
135
+ React.createElement(icons_1.DeleteOutlined, { style: { fontSize: token.fontSizeHeading4 }, onClick: function () {
136
+ removeFile(attachment.file);
137
+ } })))); })),
138
+ React.createElement(antd_1.Modal, { open: previewOpen, onCancel: handleClosePreview, footer: null },
139
+ previewPDFUrl && (React.createElement("iframe", { src: previewPDFUrl, style: { width: "100%", height: "700px", maxHeight: "75vh" } })),
140
+ previewImage && React.createElement(antd_1.Image, { src: previewImage, preview: false }),
141
+ React.createElement(antd_1.Typography.Text, null, previewDescription))));
142
+ };
143
+ exports.default = AttachmentList;
@@ -1,17 +1,56 @@
1
1
  import * as React from "react";
2
2
  import { WrappedComponentProps } from "react-intl";
3
3
  import { FormInstance } from "antd/es/form";
4
- import { UploadFile } from "antd/es/upload/interface";
5
4
  import { AttachmentType } from ".";
5
+ export declare const translationMessages: {
6
+ attachment_title: {
7
+ id: string;
8
+ defaultMessage: string;
9
+ };
10
+ attachment_saveButton_title: {
11
+ id: string;
12
+ defaultMessage: string;
13
+ };
14
+ attachment_error_fileTooLarge: {
15
+ id: string;
16
+ defaultMessage: string;
17
+ };
18
+ attachment_error_fileWrongType: {
19
+ id: string;
20
+ defaultMessage: string;
21
+ };
22
+ attachment_error_fileFailedToUpload: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ };
26
+ attachment_labels_uploadFileMsg: {
27
+ id: string;
28
+ defaultMessage: string;
29
+ };
30
+ attachment_labels_onUploadFileMsg: {
31
+ id: string;
32
+ defaultMessage: string;
33
+ };
34
+ attachment_labels_Description_requiredMessage: {
35
+ id: string;
36
+ defaultMessage: string;
37
+ };
38
+ attachment_labels_Description: {
39
+ id: string;
40
+ defaultMessage: string;
41
+ };
42
+ attachments_sameDescription_warning: {
43
+ id: string;
44
+ defaultMessage: string;
45
+ };
46
+ };
6
47
  interface AttachmentModalProps extends WrappedComponentProps {
7
48
  isModalOpen: boolean;
8
49
  setIsModalOpen: (isModalOpen: boolean) => void;
9
50
  attachments: AttachmentType[];
10
- setAttachments: (attachments: AttachmentType[]) => void;
11
51
  uploadSizeLimit: number;
12
- formInstance: FormInstance;
13
- onRemove: (file: UploadFile) => void;
14
- onSave: () => void;
52
+ form: FormInstance;
53
+ onSave: (attachmentsFromModal: AttachmentType[]) => void;
15
54
  onCancel: () => void;
16
55
  }
17
56
  declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<AttachmentModalProps, "intl"> & {
@@ -43,6 +43,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
43
43
  return to.concat(ar || Array.prototype.slice.call(from));
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.translationMessages = void 0;
46
47
  var React = __importStar(require("react"));
47
48
  var react_intl_1 = require("react-intl");
48
49
  var antd_1 = require("antd");
@@ -52,7 +53,9 @@ var lib_1 = require("antd/lib");
52
53
  var formLayout_1 = require("../../consts/formLayout");
53
54
  var validationRules_1 = require("../../consts/validationRules");
54
55
  var react_1 = require("react");
55
- var translationMessages = (0, react_intl_1.defineMessages)({
56
+ var lodash_1 = require("lodash");
57
+ var AttachmentsUtility_1 = require("../../../utils/AttachmentsUtility");
58
+ exports.translationMessages = (0, react_intl_1.defineMessages)({
56
59
  attachment_title: {
57
60
  id: "attachment_title",
58
61
  defaultMessage: "Attachments",
@@ -95,61 +98,35 @@ var translationMessages = (0, react_intl_1.defineMessages)({
95
98
  },
96
99
  });
97
100
  var AttachmentModal = function (props) {
98
- var _a = React.useState(false), isUploading = _a[0], setIsUploading = _a[1];
99
- var _b = React.useState(true), isSaveAttachmentsDisabled = _b[0], setIsSaveAttachmentsDisabled = _b[1];
100
- var _c = (0, react_1.useState)(false), sameDescriptionWarning = _c[0], setSameDescriptionWarning = _c[1];
101
- var normFile = function (e) {
102
- if (!e)
103
- return;
104
- if (Array.isArray(e)) {
105
- return e;
106
- }
107
- return e.fileList;
101
+ var isModalOpen = props.isModalOpen, setIsModalOpen = props.setIsModalOpen, attachments = props.attachments, uploadSizeLimit = props.uploadSizeLimit, form = props.form, onSave = props.onSave, onCancel = props.onCancel;
102
+ var _a = (0, react_1.useState)(false), isUploading = _a[0], setIsUploading = _a[1];
103
+ var _b = (0, react_1.useState)(true), isSaveAttachmentsDisabled = _b[0], setIsSaveAttachmentsDisabled = _b[1];
104
+ var _c = (0, react_1.useState)([]), localAttachments = _c[0], setLocalAttachments = _c[1];
105
+ (0, react_1.useEffect)(function () {
106
+ setLocalAttachments((0, lodash_1.cloneDeep)(attachments));
107
+ }, [isModalOpen, attachments]);
108
+ (0, react_1.useEffect)(function () {
109
+ updateSaveButtonState(localAttachments);
110
+ (0, AttachmentsUtility_1.updateFormState)(localAttachments, form);
111
+ }, [localAttachments]);
112
+ var updateSaveButtonState = function (updatedLocalAttachments) {
113
+ var isAttachmentListUnmodified = (0, lodash_1.isEqual)(attachments, updatedLocalAttachments);
114
+ setIsSaveAttachmentsDisabled(isAttachmentListUnmodified || hasInvalidAttachments(updatedLocalAttachments));
108
115
  };
109
- var updateFile = function (file, updatedProps) {
110
- var fileIndex = props.attachments.findIndex(function (attachment) { return attachment.file.uid === file.uid; });
111
- if (fileIndex === -1) {
112
- props.setAttachments(__spreadArray(__spreadArray([], props.attachments, true), [{ uid: file.uid, file: file, description: "", fieldValidation: "" }], false));
113
- }
114
- else {
115
- var updatedAttachments = props.attachments.map(function (attachment) {
116
- if (attachment.file.uid === file.uid) {
117
- var filterAlreadyExist = props.attachments.filter(function (att) {
118
- return att.uid !== file.uid && att.description === updatedProps.description;
119
- });
120
- if ((filterAlreadyExist === null || filterAlreadyExist === void 0 ? void 0 : filterAlreadyExist.length) > 0) {
121
- setSameDescriptionWarning(true);
122
- }
123
- else {
124
- setSameDescriptionWarning(false);
125
- }
126
- return __assign(__assign({}, attachment), updatedProps);
127
- }
128
- return attachment;
129
- });
130
- props.setAttachments(updatedAttachments);
131
- }
116
+ var hasInvalidAttachments = function (validateAttachments) {
117
+ return ((0, AttachmentsUtility_1.hasDuplicateDescriptions)(validateAttachments) ||
118
+ (0, AttachmentsUtility_1.hasEmptyDescriptions)(validateAttachments) ||
119
+ (0, AttachmentsUtility_1.hasInvalidStatus)(validateAttachments));
132
120
  };
133
- React.useEffect(function () {
134
- var _isSaveAttachmentsDisabled = props.attachments.length > 0 ? props.attachments.some(function (attachment) { return attachment.fieldValidation !== "success" || (!attachment.description.trim() || sameDescriptionWarning); }) : true;
135
- setIsSaveAttachmentsDisabled(_isSaveAttachmentsDisabled);
136
- }, [props.attachments]);
137
- var verifyAttachment = function (info, uploadSizeLimit, onRemove) {
138
- if (info.file.status === "removed")
139
- return;
140
- var isValid = (0, FileUploadUtility_1.reportIfFileIsValid)(info.file, uploadSizeLimit, {
141
- uploadErrorToLarge: props.intl.formatMessage(translationMessages.attachment_error_fileTooLarge, {
142
- uploadSizeLimit: uploadSizeLimit / 1024,
143
- }),
144
- uploadErrorWrongType: props.intl.formatMessage(translationMessages.attachment_error_fileWrongType),
145
- uploadFailed: props.intl.formatMessage(translationMessages.attachment_error_fileFailedToUpload),
121
+ var removeLocalFile = function (file) {
122
+ setLocalAttachments(function (prev) {
123
+ return prev.filter(function (attachment) { return attachment.file.uid !== file.uid; });
146
124
  });
147
- if (!isValid) {
148
- onRemove(info.file);
149
- }
150
- else {
151
- updateFile(info.file, { file: __assign({}, info.file), fieldValidation: "success" });
152
- }
125
+ };
126
+ var saveAttachmentsHandler = function () {
127
+ var attachmentsWithDescriptions = localAttachments.filter(function (at) { return at.description; });
128
+ onSave(attachmentsWithDescriptions);
129
+ setIsModalOpen(false);
153
130
  };
154
131
  var uploadProps = {
155
132
  name: "file",
@@ -159,23 +136,23 @@ var AttachmentModal = function (props) {
159
136
  accept: FileUploadUtility_1.validFileTypes.join(","),
160
137
  showUploadList: false,
161
138
  onRemove: function (file) {
162
- props.onRemove(file);
139
+ removeLocalFile(file);
163
140
  },
164
141
  onChange: function (info) {
165
142
  if (info.file.status === "uploading") {
166
143
  setIsUploading(true);
167
- var fileIndex = props.attachments.findIndex(function (attachment) { return attachment.file.uid === info.file.uid; });
168
- var isValid = (0, FileUploadUtility_1.reportIfFileIsValid)(info.file, props.uploadSizeLimit, {
169
- uploadErrorToLarge: props.intl.formatMessage(translationMessages.attachment_error_fileTooLarge, {
170
- uploadSizeLimit: props.uploadSizeLimit / 1024,
144
+ var fileIndex = localAttachments.findIndex(function (attachment) { return attachment.file.uid === info.file.uid; });
145
+ var isValid = (0, FileUploadUtility_1.reportIfFileIsValid)(info.file, uploadSizeLimit, {
146
+ uploadErrorToLarge: props.intl.formatMessage(exports.translationMessages.attachment_error_fileTooLarge, {
147
+ uploadSizeLimit: uploadSizeLimit / 1024,
171
148
  }),
172
- uploadErrorWrongType: props.intl.formatMessage(translationMessages.attachment_error_fileWrongType),
173
- uploadFailed: props.intl.formatMessage(translationMessages.attachment_error_fileFailedToUpload),
149
+ uploadErrorWrongType: props.intl.formatMessage(exports.translationMessages.attachment_error_fileWrongType),
150
+ uploadFailed: props.intl.formatMessage(exports.translationMessages.attachment_error_fileFailedToUpload),
174
151
  });
175
152
  if (fileIndex === -1 && isValid) {
176
- props.setAttachments(__spreadArray(__spreadArray([], props.attachments, true), [
153
+ setLocalAttachments(function (prev) { return __spreadArray(__spreadArray([], prev, true), [
177
154
  { uid: info.file.uid, file: info.file, description: "", fieldValidation: "" },
178
- ], false));
155
+ ], false); });
179
156
  }
180
157
  else {
181
158
  setIsUploading(false);
@@ -183,11 +160,11 @@ var AttachmentModal = function (props) {
183
160
  }
184
161
  else if (info.file.status === "done" || info.file.status === "error") {
185
162
  setIsUploading(false);
186
- verifyAttachment(info, props.uploadSizeLimit, props.onRemove);
163
+ (0, AttachmentsUtility_1.verifyAttachment)(info, uploadSizeLimit, removeLocalFile, props.intl, setLocalAttachments);
187
164
  }
188
165
  },
189
- fileList: props.attachments.map(function (attachment) { return attachment.file; }),
190
- disabled: isUploading || props.attachments.length >= 3,
166
+ fileList: localAttachments.map(function (attachment) { return attachment.file; }),
167
+ disabled: isUploading || localAttachments.length >= 3,
191
168
  customRequest: function (_a) {
192
169
  var onSuccess = _a.onSuccess;
193
170
  if (onSuccess) {
@@ -197,20 +174,19 @@ var AttachmentModal = function (props) {
197
174
  }
198
175
  }
199
176
  };
200
- return (React.createElement(antd_1.Modal, { open: props.isModalOpen, onCancel: props.onCancel, title: props.intl.formatMessage(translationMessages.attachment_title), footer: React.createElement(antd_1.Tooltip, { title: sameDescriptionWarning ? props.intl.formatMessage(translationMessages.attachments_sameDescription_warning) : undefined },
201
- React.createElement(antd_1.Button, { disabled: isSaveAttachmentsDisabled, icon: React.createElement(icons_1.CheckCircleOutlined, null), type: "primary", style: { width: "100%" }, size: "large", onClick: function () {
202
- props.onSave();
203
- props.setIsModalOpen(false);
204
- } }, props.intl.formatMessage(translationMessages.attachment_saveButton_title))) },
205
- React.createElement(lib_1.Form.Item, __assign({}, formLayout_1.fullWidthInput, { valuePropName: "fileList", getValueFromEvent: normFile, className: "upload-container" }),
177
+ return (React.createElement(antd_1.Modal, { open: isModalOpen, onCancel: onCancel, title: props.intl.formatMessage(exports.translationMessages.attachment_title), maskClosable: false, footer: React.createElement(antd_1.Tooltip, { title: (0, AttachmentsUtility_1.hasDuplicateDescriptions)(localAttachments) ? props.intl.formatMessage(exports.translationMessages.attachments_sameDescription_warning) : undefined },
178
+ React.createElement(antd_1.Button, { disabled: isSaveAttachmentsDisabled, icon: React.createElement(icons_1.CheckCircleOutlined, null), type: "primary", style: { width: "100%" }, size: "large", onClick: saveAttachmentsHandler }, props.intl.formatMessage(exports.translationMessages.attachment_saveButton_title))) },
179
+ React.createElement(lib_1.Form.Item, __assign({}, formLayout_1.fullWidthInput, { valuePropName: "fileList", getValueFromEvent: FileUploadUtility_1.getFileListFromEvent, className: "upload-container" }),
206
180
  React.createElement(antd_1.Upload, __assign({}, uploadProps, { style: { width: '100%' } }),
207
181
  React.createElement(antd_1.Button, { loading: isUploading, disabled: uploadProps.disabled, icon: React.createElement(icons_1.UploadOutlined, null), size: "large", style: { width: "100%" } }, isUploading
208
- ? props.intl.formatMessage(translationMessages.attachment_labels_onUploadFileMsg)
209
- : props.intl.formatMessage(translationMessages.attachment_labels_uploadFileMsg)))),
210
- props.attachments.length > 0 && (React.createElement(antd_1.Flex, { vertical: true },
211
- React.createElement(antd_1.Typography.Text, null, props.intl.formatMessage(translationMessages.attachment_title)),
182
+ ? props.intl.formatMessage(exports.translationMessages.attachment_labels_onUploadFileMsg)
183
+ : props.intl.formatMessage(exports.translationMessages.attachment_labels_uploadFileMsg)))),
184
+ localAttachments.length > 0 && (React.createElement(antd_1.Flex, { vertical: true },
185
+ React.createElement(antd_1.Typography.Text, null,
186
+ props.intl.formatMessage(exports.translationMessages.attachment_title),
187
+ ":"),
212
188
  React.createElement("hr", null),
213
- props.attachments.map(function (attachment, index) { return (React.createElement(antd_1.Flex, { gap: "middle", vertical: true, key: attachment.uid + index },
189
+ localAttachments.map(function (attachment, index) { return (React.createElement(antd_1.Flex, { gap: "middle", vertical: true, key: attachment.uid + index },
214
190
  React.createElement(antd_1.Flex, { gap: "middle", justify: "space-between" },
215
191
  React.createElement(antd_1.Typography.Text, { type: attachment.file.status === "error" ? "danger" : undefined },
216
192
  React.createElement(icons_1.PaperClipOutlined, null)),
@@ -218,17 +194,16 @@ var AttachmentModal = function (props) {
218
194
  React.createElement(lib_1.Form.Item, { name: ["attachments", "file".concat(index + 1), "file"], initialValue: attachment.file, hidden: true }),
219
195
  attachment.file.status === "uploading" ? (React.createElement(icons_1.LoadingOutlined, null)) : (React.createElement(antd_1.Typography.Text, { type: attachment.file.status === "error" ? "danger" : undefined },
220
196
  React.createElement(icons_1.DeleteOutlined, { onClick: function () {
221
- props.onRemove(attachment.file);
197
+ removeLocalFile(attachment.file);
222
198
  } })))),
223
199
  attachment.fieldValidation === "success" && (React.createElement(lib_1.Form.Item, __assign({}, formLayout_1.fullWidthInput, { initialValue: attachment.description, rules: [
224
200
  {
225
- required: true,
226
- message: props.intl.formatMessage(translationMessages.attachment_labels_Description_requiredMessage),
201
+ validator: (0, validationRules_1.requiredValidator)(form, index, props.intl.formatMessage(exports.translationMessages.attachment_labels_Description_requiredMessage))
227
202
  },
228
203
  {
229
204
  validator: (0, validationRules_1.noWhitespaceValidator)(props.intl)
230
205
  }
231
206
  ], name: ["attachments", "file".concat(index + 1), "description"] }),
232
- React.createElement(antd_1.Input, { prefix: React.createElement(antd_1.Typography.Text, { type: "danger" }, "*"), placeholder: props.intl.formatMessage(translationMessages.attachment_labels_Description), onChange: function (e) { return updateFile(attachment.file, { description: e.target.value }); } }))))); })))));
207
+ React.createElement(antd_1.Input, { prefix: React.createElement(antd_1.Typography.Text, { type: "danger" }, "*"), placeholder: props.intl.formatMessage(exports.translationMessages.attachment_labels_Description), onChange: function (e) { return (0, AttachmentsUtility_1.updateFile)(attachment.file, { description: e.target.value }, setLocalAttachments); } }))))); })))));
233
208
  };
234
209
  exports.default = (0, react_intl_1.injectIntl)(AttachmentModal);
@@ -4,6 +4,26 @@ import { FormInstance } from "antd/es/form";
4
4
  import { LanguageProp } from "../../types/CommonProps";
5
5
  import { UploadFile } from "antd/es/upload/interface";
6
6
  import { ValidateStatus } from "antd/lib/form/FormItem";
7
+ export declare const translationMessages: {
8
+ attachment_title: {
9
+ id: string;
10
+ defaultMessage: string;
11
+ };
12
+ attachment_tooltip_title: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ };
16
+ attachment_addAttachmentButton_title: {
17
+ id: string;
18
+ defaultMessage: string;
19
+ };
20
+ };
21
+ export type AttachmentType = {
22
+ uid: string;
23
+ file: UploadFile;
24
+ fieldValidation: ValidateStatus;
25
+ description: string;
26
+ };
7
27
  interface Props extends WrappedComponentProps {
8
28
  formInstance: FormInstance;
9
29
  uploadSizeLimit: number;
@@ -13,12 +33,6 @@ interface Props extends WrappedComponentProps {
13
33
  };
14
34
  languageString: LanguageProp;
15
35
  }
16
- export type AttachmentType = {
17
- uid: string;
18
- file: UploadFile;
19
- fieldValidation: ValidateStatus;
20
- description: string;
21
- };
22
36
  declare const AttachmentGroupIntl: React.ForwardRefExoticComponent<import("react-intl").Omit<Props, "intl"> & {
23
37
  forwardedRef?: React.Ref<any>;
24
38
  } & React.RefAttributes<any>> & {