oa-componentbook 1.0.1-stage.96 → 1.0.1-stage.98

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,376 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.object.assign.js");
4
- require("core-js/modules/es.weak-map.js");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- require("core-js/modules/es.symbol.description.js");
10
- require("core-js/modules/web.dom-collections.iterator.js");
11
- var _react = _interopRequireWildcard(require("react"));
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
- var _antd = require("antd");
14
- var _CheckCircle = _interopRequireDefault(require("@material-ui/icons/CheckCircle"));
15
- var _Check = _interopRequireDefault(require("@material-ui/icons/Check"));
16
- var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
17
- var _UploadDownloadWidget = _interopRequireDefault(require("../oa-widget-upload-download/UploadDownloadWidget"));
18
- var _styles = require("./styles");
19
- var _CustomRadio = _interopRequireDefault(require("../../components/oa-component-radio/CustomRadio"));
20
- var _Typography = _interopRequireDefault(require("../../components/oa-component-typography/Typography"));
21
- var _CustomButton = _interopRequireDefault(require("../../components/oa-component-button/CustomButton"));
22
- var _MaterialIcon = _interopRequireDefault(require("../../components/oa-component-icons/MaterialIcon"));
23
- var _CustomTag = _interopRequireDefault(require("../../components/oa-component-tag/CustomTag"));
24
- var _CustomTooltip = _interopRequireDefault(require("../../components/oa-component-tooltip/CustomTooltip"));
25
- const _excluded = ["children", "description", "docDetails", "multipleDocDetails", "approvalForm", "isMandatory", "hasDivider", "isQuestionStyleWidget", "questionId", "title", "viewOnClick", "actionRenderType", "actionContent", "systemStatus", "documentTitle", "descriptionTitle", "data-test", "form", "columnDynamicCssClass", "tooltipPlacement"];
26
- /* eslint-disable */
27
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
29
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
30
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
31
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
32
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
33
- /**
34
- * @typedef {import('../../components/oa-component-upload/CustomUpload').DocumentDetails} DocumentDetails
35
- *
36
- * @typedef {Object} ApprovalForm
37
- * @property {boolean} [disabled=false] Whether the approval form is disabled.
38
- * @property {boolean} [hidden=false] Whether the approval form is hidden.
39
- * @property {boolean} [invisible=false] Whether the approval form is invisible (preserving layout).
40
- * @property {boolean} [isApproved] Initial value for the approval status.
41
- * @property {string} [remarks] Initial value for the remarks.
42
- *
43
- * @typedef {Object} Props
44
- * @property {React.ReactNode} [children] Content to be rendered inside the ApprovalWidget.
45
- * @property {string} [description] Description for the widget.
46
- * @property {DocumentDetails} [docDetails] Document details for the widget.
47
- * @property {ApprovalForm} [approvalForm] Form data for approval.
48
- * @property {boolean} [isMandatory=false] Whether the widget is mandatory.
49
- * @property {boolean} [hasDivider=false] Display a divider line beneath the widget.
50
- * @property {boolean} [isQuestionStyleWidget=false] Whether the widget has a question-style layout.
51
- * @property {string|number} questionId Identifier for the question.
52
- * @property {string} title Title of the widget.
53
- * @property {Function} [viewOnClick] Callback function for the view action.
54
- * @property {string} ['data-test'] Data test string to be applied to the outermost element.
55
- */
56
- function ApprovalWidget(_ref) {
57
- var _approvalForm$disable2, _actionContent$label, _approvalForm$disable3, _approvalForm$disable4, _approvalForm$disable5, _approvalForm$remarks, _approvalForm$disable6, _approvalForm$disable7, _approvalForm$disable8, _approvalForm$disable9, _approvalForm$disable10;
58
- let {
59
- children,
60
- description,
61
- docDetails,
62
- multipleDocDetails,
63
- approvalForm,
64
- isMandatory,
65
- hasDivider,
66
- isQuestionStyleWidget,
67
- questionId,
68
- title,
69
- viewOnClick,
70
- actionRenderType,
71
- actionContent,
72
- systemStatus,
73
- documentTitle,
74
- descriptionTitle,
75
- "data-test": dataTest,
76
- form,
77
- columnDynamicCssClass,
78
- tooltipPlacement
79
- } = _ref,
80
- props = _objectWithoutProperties(_ref, _excluded);
81
- const getInitialValue = isApproved => {
82
- switch (isApproved) {
83
- case true:
84
- return 1;
85
- case false:
86
- return 0;
87
- default:
88
- return undefined;
89
- }
90
- };
91
- const [isApproved, setIsApproved] = (0, _react.useState)(getInitialValue(approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.isApproved));
92
- const [radioButtonValue, setRadioButtonValue] = (0, _react.useState)(null);
93
- const getFieldDecorator = form === null || form === void 0 ? void 0 : form.getFieldDecorator;
94
- const onRadioChange = event => setIsApproved(event.target.value);
95
- const onChangeRadioWithForm = event => setRadioButtonValue(event.target.value);
96
- return /*#__PURE__*/_react.default.createElement(_styles.StyledContainer, null, /*#__PURE__*/_react.default.createElement("div", {
97
- className: "row"
98
- }, /*#__PURE__*/_react.default.createElement("div", {
99
- className: columnDynamicCssClass === null || columnDynamicCssClass === void 0 ? void 0 : columnDynamicCssClass.firstColumn
100
- }, title && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
101
- className: "type-button-500"
102
- }, title, isMandatory && /*#__PURE__*/_react.default.createElement(_styles.RedText, null, "*"))), description && /*#__PURE__*/_react.default.createElement(_styles.Styledescription, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
103
- typography: "type-b2-400",
104
- color: "secondary-content"
105
- }, descriptionTitle), /*#__PURE__*/_react.default.createElement(_Typography.default, {
106
- typography: "type-b2-400",
107
- color: "primary-content"
108
- }, description)), !isQuestionStyleWidget && ((multipleDocDetails === null || multipleDocDetails === void 0 ? void 0 : multipleDocDetails.length) > 0 ? multipleDocDetails.map(docDetails => {
109
- var _approvalForm$disable;
110
- return /*#__PURE__*/_react.default.createElement("div", {
111
- className: "oaCustomerResponse"
112
- }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
113
- typography: "type-b2-400",
114
- color: "secondary-content"
115
- }, docDetails.documentTitle, " \xA0"), /*#__PURE__*/_react.default.createElement(_UploadDownloadWidget.default, _extends({
116
- disabled: (_approvalForm$disable = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable !== void 0 ? _approvalForm$disable : false,
117
- "data-test": dataTest ? "".concat(dataTest, "--upload-download-widget") : undefined
118
- }, docDetails, {
119
- formName: isMandatory ? "file-".concat(questionId) : undefined
120
- })));
121
- }) : /*#__PURE__*/_react.default.createElement("div", {
122
- className: "oaCustomerResponse"
123
- }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
124
- typography: "type-b2-400",
125
- color: "secondary-content"
126
- }, documentTitle, " \xA0"), /*#__PURE__*/_react.default.createElement(_UploadDownloadWidget.default, _extends({
127
- disabled: (_approvalForm$disable2 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable2 !== void 0 ? _approvalForm$disable2 : false,
128
- "data-test": dataTest ? "".concat(dataTest, "--upload-download-widget") : undefined
129
- }, docDetails, {
130
- formName: isMandatory ? "file-".concat(questionId) : undefined
131
- })))), children && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children), viewOnClick && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
132
- className: "view-button",
133
- "data-test": dataTest ? "".concat(dataTest, "--view-button") : undefined,
134
- onClick: () => viewOnClick(questionId),
135
- type: "text-only",
136
- label:
137
- // isQuestionStyleWidget
138
- // ? "View Previous Description"
139
- // :
140
- "View History"
141
- }))), /*#__PURE__*/_react.default.createElement("div", {
142
- className: columnDynamicCssClass === null || columnDynamicCssClass === void 0 ? void 0 : columnDynamicCssClass.secondColumn
143
- }, systemStatus === null || systemStatus === void 0 ? void 0 : systemStatus.map(status => {
144
- var _status$items;
145
- return /*#__PURE__*/_react.default.createElement("div", null, status.renderType === "text" && /*#__PURE__*/_react.default.createElement(_Typography.default, {
146
- typography: "type-b2-400",
147
- color: "secondary-content"
148
- }, status.label), status.renderType === "tag" && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_CustomTag.default, status)), status.renderType === "toolTip" && ((_status$items = status.items) === null || _status$items === void 0 ? void 0 : _status$items.length) > 0 && /*#__PURE__*/_react.default.createElement(_CustomTooltip.default, {
149
- overlayClassName: "multipleDocumentTooltip",
150
- isDisplayed: true,
151
- placement: status.tooltipPlacement // Pass placement as a prop
152
- ,
153
- title: (() => {
154
- const totalItems = status.items.length;
155
- const numColumns = totalItems === 1 ? 1 : 2; // 1 column if only 1 item, else 2 columns
156
-
157
- const col1Size = Math.ceil(totalItems / numColumns); // First column gets extra if odd
158
- const col2Size = totalItems - col1Size; // Remaining items go to second column
159
-
160
- const columns = [status.items.slice(0, col1Size),
161
- // First column
162
- status.items.slice(col1Size) // Second column
163
- ];
164
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (status === null || status === void 0 ? void 0 : status.title) && /*#__PURE__*/_react.default.createElement(_Typography.default, {
165
- typography: "type-sl1-700",
166
- color: "secondary-content"
167
- }, status.title), /*#__PURE__*/_react.default.createElement("div", {
168
- className: "tooltip-grid",
169
- style: {
170
- flexDirection: totalItems === 1 ? "column" : "row",
171
- // Make it single column if only 1 item
172
- width: totalItems === 1 ? "100%" : "auto" // Full width if only 1 item
173
- }
174
- }, columns.map((columnItems, colIndex) => /*#__PURE__*/_react.default.createElement("div", {
175
- key: "col-".concat(colIndex),
176
- className: "tooltip-column"
177
- }, columnItems.map(item => /*#__PURE__*/_react.default.createElement("li", {
178
- key: item.title,
179
- className: "tooltip-item"
180
- }, !(status !== null && status !== void 0 && status.hideIcon) && /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
181
- size: 20,
182
- icon: item.type === "positive" ? _Check.default : _Close.default,
183
- color: item.type === "positive" ? "positive" : "negative"
184
- }), /*#__PURE__*/_react.default.createElement("p", null, item.title)))))));
185
- })()
186
- }, /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
187
- type: "text-only",
188
- label: status.label
189
- })));
190
- })), /*#__PURE__*/_react.default.createElement("div", {
191
- className: columnDynamicCssClass === null || columnDynamicCssClass === void 0 ? void 0 : columnDynamicCssClass.thirdColumn
192
- }, actionRenderType === "text" && /*#__PURE__*/_react.default.createElement("div", {
193
- className: "oaActionText"
194
- }, (actionContent === null || actionContent === void 0 ? void 0 : actionContent.icon) && /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
195
- icon: _CheckCircle.default,
196
- size: 20,
197
- color: "secondary-content"
198
- }), /*#__PURE__*/_react.default.createElement(_Typography.default, {
199
- typography: "type-b2-400",
200
- color: "secondary-content"
201
- }, (_actionContent$label = actionContent === null || actionContent === void 0 ? void 0 : actionContent.label) !== null && _actionContent$label !== void 0 ? _actionContent$label : "-")), actionRenderType === "button" && /*#__PURE__*/_react.default.createElement(_CustomButton.default, _extends({
202
- disabled: (_approvalForm$disable3 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable3 !== void 0 ? _approvalForm$disable3 : false
203
- }, actionContent)), actionRenderType === "radio" &&
204
- /*#__PURE__*/
205
- //className="col-sm-12 col-md-4 col-lg-4"
206
- _react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
207
- name: "isApproved-".concat(questionId),
208
- className: "custom-radio-group",
209
- initialValue: isApproved,
210
- rules: [{
211
- required: true,
212
- message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
213
- "data-test": "".concat(dataTest, "--is-approved-validation-message")
214
- }, "Approval status needs to be selected.") : "Approval status needs to be selected."
215
- }]
216
- }, /*#__PURE__*/_react.default.createElement(_CustomRadio.default.Group, {
217
- "data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-group") : undefined,
218
- onChange: onRadioChange,
219
- value: isApproved
220
- }, /*#__PURE__*/_react.default.createElement(_CustomRadio.default, {
221
- "data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-yes") : undefined,
222
- disabled: (_approvalForm$disable4 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable4 !== void 0 ? _approvalForm$disable4 : false,
223
- label: "Mark as Approved",
224
- value: 1
225
- }), /*#__PURE__*/_react.default.createElement(_CustomRadio.default, {
226
- "data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-no") : undefined,
227
- disabled: (_approvalForm$disable5 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable5 !== void 0 ? _approvalForm$disable5 : false,
228
- label: "Mark as Pending",
229
- value: 0
230
- }))), isApproved === 0 && /*#__PURE__*/_react.default.createElement("section", null, /*#__PURE__*/_react.default.createElement("h5", {
231
- className: "type-b2-400"
232
- }, "Remarks"), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
233
- name: "remarks-".concat(questionId),
234
- initialValue: (_approvalForm$remarks = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.remarks) !== null && _approvalForm$remarks !== void 0 ? _approvalForm$remarks : "",
235
- rules: [{
236
- required: true,
237
- message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
238
- "data-test": "".concat(dataTest, "--remarks-validation-message")
239
- }, "Remarks cannot be empty.") : "Remarks cannot be empty."
240
- }]
241
- }, /*#__PURE__*/_react.default.createElement(_antd.Input.TextArea, {
242
- "data-test": dataTest ? "".concat(dataTest, "--remarks") : undefined,
243
- disabled: (_approvalForm$disable6 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable6 !== void 0 ? _approvalForm$disable6 : false
244
- })))), actionRenderType === "buttonWithForm" && /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
245
- validateStatus: form.getFieldError("validateDocumentButton#".concat(questionId)) ? "error" : "",
246
- help: /*#__PURE__*/_react.default.createElement("div", {
247
- className: "errorForRtv"
248
- }, form.getFieldError("validateDocumentButton#".concat(questionId)) || "")
249
- }, getFieldDecorator("validateDocumentButton#".concat(questionId), {
250
- rules: isMandatory ? [{
251
- required: true,
252
- message: "This field is required"
253
- }] : []
254
- })( /*#__PURE__*/_react.default.createElement(_CustomButton.default, _extends({}, actionContent, {
255
- disabled: (_approvalForm$disable7 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable7 !== void 0 ? _approvalForm$disable7 : false
256
- })))), actionRenderType === "radioWithForm" && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
257
- className: "custom-radio-group",
258
- validateStatus: form.getFieldError("icQues_status_".concat(questionId)) ? "error" : "",
259
- help: form.getFieldError("icQues_status_".concat(questionId)) || ""
260
- }, getFieldDecorator("icQues_status_".concat(questionId), {
261
- rules: isMandatory ? [{
262
- required: true,
263
- message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
264
- "data-test": "".concat(dataTest, "--is-approved-validation-message")
265
- }, "Approval status needs to be selected.") : "Approval status needs to be selected."
266
- }] : []
267
- })( /*#__PURE__*/_react.default.createElement(_CustomRadio.default.Group, {
268
- "data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-group") : undefined,
269
- onChange: onChangeRadioWithForm,
270
- value: radioButtonValue
271
- }, /*#__PURE__*/_react.default.createElement(_CustomRadio.default, {
272
- "data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-yes") : undefined,
273
- label: "Mark as Approved",
274
- value: "Complete",
275
- disabled: (_approvalForm$disable8 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable8 !== void 0 ? _approvalForm$disable8 : false
276
- }), /*#__PURE__*/_react.default.createElement(_CustomRadio.default, {
277
- "data-test": dataTest ? "".concat(dataTest, "--is-approved-radio-no") : undefined,
278
- label: "Mark as Pending",
279
- value: "Incomplete",
280
- disabled: (_approvalForm$disable9 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable9 !== void 0 ? _approvalForm$disable9 : false
281
- })))), form.getFieldValue("icQues_status_".concat(questionId)) == "Incomplete" && /*#__PURE__*/_react.default.createElement("section", null, /*#__PURE__*/_react.default.createElement("h5", {
282
- className: "type-b2-400"
283
- }, "Remarks"), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
284
- validateStatus: form.getFieldError("icQues_remarks_".concat(questionId)) ? "error" : "",
285
- help: form.getFieldError("icQues_remarks_".concat(questionId)) || ""
286
- }, getFieldDecorator("icQues_remarks_".concat(questionId), {
287
- rules: isMandatory ? [{
288
- required: true,
289
- message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
290
- "data-test": "".concat(dataTest, "--remarks-validation-message")
291
- }, "Remarks cannot be empty.") : "Remarks cannot be empty."
292
- }] : []
293
- })( /*#__PURE__*/_react.default.createElement(_antd.Input.TextArea, {
294
- "data-test": dataTest ? "".concat(dataTest, "--remarks") : undefined,
295
- disabled: (_approvalForm$disable10 = approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.disabled) !== null && _approvalForm$disable10 !== void 0 ? _approvalForm$disable10 : false
296
- }))))), actionRenderType === "buttonWithFormV4" && /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
297
- name: "validateDocumentButton#".concat(questionId),
298
- initialValue: approvalForm === null || approvalForm === void 0 ? void 0 : approvalForm.isApproved,
299
- rules: isMandatory ? [{
300
- required: true,
301
- message: dataTest ? /*#__PURE__*/_react.default.createElement("span", {
302
- "data-test": "".concat(dataTest, "--is-approved-validation-message")
303
- }, "Approval status needs to be selected.") : "Approval status needs to be selected."
304
- }] : []
305
- }, /*#__PURE__*/_react.default.createElement(_CustomButton.default, actionContent)))), hasDivider && /*#__PURE__*/_react.default.createElement(_antd.Divider, null));
306
- }
307
- ApprovalWidget.propTypes = {
308
- children: _propTypes.default.node,
309
- "data-test": _propTypes.default.string,
310
- description: _propTypes.default.string,
311
- // Leave description optional
312
- docDetails: _propTypes.default.shape({
313
- multiple: _propTypes.default.bool,
314
- onUpload: _propTypes.default.func,
315
- uploadedDocuments: _propTypes.default.arrayOf(_propTypes.default.shape({
316
- name: _propTypes.default.string,
317
- onDelete: _propTypes.default.func,
318
- onDownload: _propTypes.default.func
319
- }))
320
- }),
321
- multipleDocDetails: _propTypes.default.array,
322
- hasDivider: _propTypes.default.bool,
323
- // Leave hasDivider optional,
324
- approvalForm: _propTypes.default.shape({
325
- disabled: _propTypes.default.bool,
326
- hidden: _propTypes.default.bool,
327
- invisible: _propTypes.default.bool,
328
- isApproved: _propTypes.default.bool,
329
- remarks: _propTypes.default.string
330
- }),
331
- isMandatory: _propTypes.default.bool,
332
- isQuestionStyleWidget: _propTypes.default.bool,
333
- questionId: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
334
- title: _propTypes.default.string.isRequired,
335
- // Make title required
336
- viewOnClick: _propTypes.default.func,
337
- actionRenderType: _propTypes.default.string,
338
- actionContent: _propTypes.default.shape({
339
- label: _propTypes.default.string
340
- }),
341
- systemStatus: _propTypes.default.arrayOf(_propTypes.default.shape({
342
- renderType: _propTypes.default.string,
343
- label: _propTypes.default.string,
344
- title: _propTypes.default.string
345
- })),
346
- documentTitle: _propTypes.default.string,
347
- descriptionTitle: _propTypes.default.string,
348
- form: _propTypes.default.object,
349
- tooltipPlacement: _propTypes.default.string,
350
- columnDynamicCssClass: _propTypes.default.object
351
- };
352
- ApprovalWidget.defaultProps = {
353
- children: null,
354
- "data-test": undefined,
355
- description: "",
356
- docDetails: {},
357
- approvalForm: {},
358
- isMandatory: false,
359
- hasDivider: false,
360
- isQuestionStyleWidget: false,
361
- viewOnClick: undefined,
362
- actionRenderType: undefined,
363
- actionContent: {},
364
- systemStatus: [],
365
- documentTitle: "",
366
- descriptionTitle: "",
367
- form: null,
368
- tooltipPlacement: "bottom",
369
- // Default placement
370
- columnDynamicCssClass: {
371
- firstColumn: "col-sm-12 col-md-5 col-lg-5",
372
- secondColumn: "col-sm-12 col-md-4 col-lg-4 flexCol8",
373
- thirdColumn: "col-sm-12 col-md-3 col-lg-3"
374
- }
375
- };
376
- var _default = exports.default = ApprovalWidget;
@@ -1,164 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.object.assign.js");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- require("core-js/modules/es.array.includes.js");
9
- require("core-js/modules/es.string.includes.js");
10
- require("core-js/modules/es.promise.js");
11
- var _react = _interopRequireDefault(require("react"));
12
- var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
13
- var _propTypes = _interopRequireDefault(require("prop-types"));
14
- var _antd = require("antd");
15
- var _InfoOutlined = _interopRequireDefault(require("@material-ui/icons/InfoOutlined"));
16
- var _CustomDrawer = _interopRequireDefault(require("../../components/oa-component-drawer/CustomDrawer"));
17
- var _MaterialIcon = _interopRequireDefault(require("../../components/oa-component-icons/MaterialIcon"));
18
- var _CustomInfo = _interopRequireDefault(require("../../components/oa-component-info/CustomInfo"));
19
- var _Typography = _interopRequireDefault(require("../../components/oa-component-typography/Typography"));
20
- var _CustomUpload = _interopRequireDefault(require("../../dev/oa-component-upload/CustomUpload"));
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
- function GenericUpload(_ref) {
24
- var _config$documents;
25
- let {
26
- config,
27
- uploadHandler,
28
- deleteHandler: _deleteHandler,
29
- downloadHandler,
30
- previewHandler,
31
- visible,
32
- onClose,
33
- validationConfig = {
34
- maxSize: 5,
35
- allowedTypes: ['image/jpeg', 'image/png', 'image/jpg', 'application/pdf'],
36
- customValidation: null
37
- },
38
- uploadedDocuments,
39
- showDelete = true,
40
- showPreview = false,
41
- form
42
- } = _ref;
43
- const validateFile = (file, docTypeId) => {
44
- const isValidType = validationConfig.allowedTypes.includes(file.type);
45
- if (!isValidType) {
46
- form.setFields([{
47
- name: docTypeId,
48
- errors: ["Only ".concat(validationConfig.allowedTypes.map(type => type.split('/')[1].toUpperCase()).join('/'), " files are allowed!")]
49
- }]);
50
- return false;
51
- }
52
- const isValidSize = file.size / 1024 / 1024 < validationConfig.maxSize;
53
- if (!isValidSize) {
54
- form.setFields([{
55
- name: docTypeId,
56
- errors: ["File must be smaller than ".concat(validationConfig.maxSize, "MB!")]
57
- }]);
58
- return false;
59
- }
60
- if (validationConfig.customValidation) {
61
- return validationConfig.customValidation(file, docTypeId);
62
- }
63
- return true;
64
- };
65
- const handleUpload = async (file, docTypeId, documentId) => {
66
- if (!validateFile(file, docTypeId)) {
67
- return null;
68
- }
69
- return uploadHandler(file, docTypeId, documentId);
70
- };
71
- return /*#__PURE__*/_react.default.createElement(_CustomDrawer.default, {
72
- title: config.title,
73
- width: config.width,
74
- open: visible,
75
- onClose: onClose,
76
- buttonConfig: config.buttonConfig
77
- }, config.systemInfo && /*#__PURE__*/_react.default.createElement("div", {
78
- className: "margin-bottom-32"
79
- }, /*#__PURE__*/_react.default.createElement(_CustomInfo.default, _extends({}, config.systemInfo, {
80
- iconConfig: {
81
- icon: /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
82
- icon: _InfoOutlined.default,
83
- size: 24,
84
- color: "negative"
85
- }),
86
- position: 'left'
87
- }
88
- }))), (config === null || config === void 0 ? void 0 : config.heading) && /*#__PURE__*/_react.default.createElement("div", {
89
- className: "padding-bottom-32"
90
- }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
91
- className: "type-t1-500",
92
- color: "primary-content"
93
- }, config.heading, ' ')), /*#__PURE__*/_react.default.createElement(_antd.Form, {
94
- form: form
95
- }, (_config$documents = config.documents) === null || _config$documents === void 0 ? void 0 : _config$documents.map(item => /*#__PURE__*/_react.default.createElement("div", {
96
- key: item.docTypeId
97
- }, /*#__PURE__*/_react.default.createElement("div", {
98
- className: "padding-bottom-4"
99
- }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
100
- typography: "type-b2-500",
101
- color: "primary-content"
102
- }, item === null || item === void 0 ? void 0 : item.docName)), /*#__PURE__*/_react.default.createElement(_CustomUpload.default, {
103
- isMandatory: true,
104
- handleCustomOnChange: (file, status) => handleUpload(file, item.docTypeId, item.documentId),
105
- formName: item.docTypeId,
106
- uploadedDocuments: uploadedDocuments && uploadedDocuments[item.docTypeId] ? [uploadedDocuments[item.docTypeId]] : [],
107
- deleteHandler: selectedFile => _deleteHandler(item.docTypeId),
108
- downloadCallback: file => downloadHandler(item.docTypeId),
109
- getPreview: previewHandler || (() => {}),
110
- showDelete: showDelete,
111
- showPreview: showPreview,
112
- accept: validationConfig.allowedTypes.join(', '),
113
- docName: item.docName
114
- })))));
115
- }
116
- GenericUpload.propTypes = {
117
- config: _propTypes.default.shape({
118
- title: _propTypes.default.string.isRequired,
119
- width: _propTypes.default.number,
120
- buttonConfig: _propTypes.default.arrayOf(_propTypes.default.shape({
121
- callback: _propTypes.default.func,
122
- label: _propTypes.default.string,
123
- type: _propTypes.default.string
124
- })),
125
- systemInfo: _propTypes.default.shape({
126
- title: _propTypes.default.string,
127
- color: _propTypes.default.string,
128
- description: _propTypes.default.node
129
- }),
130
- heading: _propTypes.default.string,
131
- documents: _propTypes.default.arrayOf(_propTypes.default.shape({
132
- title: _propTypes.default.string,
133
- docTypeId: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
134
- docName: _propTypes.default.string
135
- }))
136
- }).isRequired,
137
- uploadHandler: _propTypes.default.func.isRequired,
138
- deleteHandler: _propTypes.default.func.isRequired,
139
- downloadHandler: _propTypes.default.func.isRequired,
140
- previewHandler: _propTypes.default.func,
141
- validationConfig: _propTypes.default.shape({
142
- maxSize: _propTypes.default.number,
143
- allowedTypes: _propTypes.default.arrayOf(_propTypes.default.string),
144
- customValidation: _propTypes.default.func
145
- }),
146
- uploadedDocuments: _propTypes.default.object,
147
- showDelete: _propTypes.default.bool,
148
- showPreview: _propTypes.default.bool,
149
- form: _propTypes.default.object.isRequired,
150
- visible: _propTypes.default.bool.isRequired,
151
- onClose: _propTypes.default.func.isRequired
152
- };
153
- GenericUpload.defaultProps = {
154
- previewHandler: () => {},
155
- validationConfig: {
156
- maxSize: 5,
157
- allowedTypes: ['image/jpeg', 'image/png', 'image/jpg', 'application/pdf'],
158
- customValidation: null
159
- },
160
- uploadedDocuments: {},
161
- showDelete: true,
162
- showPreview: false
163
- };
164
- var _default = exports.default = GenericUpload;