oa-componentbook 1.0.1-stage.413 → 1.0.1-stage.414

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.
@@ -92,7 +92,8 @@ function Accordion(_ref2) {
92
92
  componentConfig,
93
93
  subtext,
94
94
  customBody,
95
- onActionClick
95
+ onActionClick,
96
+ collapsibleActiveKey
96
97
  } = _ref2;
97
98
  const themeConfig = {
98
99
  components: {
@@ -108,7 +109,8 @@ function Accordion(_ref2) {
108
109
  expandIcon: CollapseIcon,
109
110
  expandIconPosition: "end",
110
111
  defaultActiveKey: disabled ? "-1" : defaultActiveKey,
111
- onChange: onChange
112
+ onChange: onChange,
113
+ activeKey: collapsibleActiveKey
112
114
  }, /*#__PURE__*/_react.default.createElement(_antd.Collapse.Panel, {
113
115
  "data-test": dataTest ? "".concat(dataTest, "--complete") : undefined,
114
116
  collapsible: disabled ? "disabled" : undefined,
@@ -14,7 +14,7 @@ var _Typography = _interopRequireDefault(require("../oa-component-typography/Typ
14
14
  var _typographyOptions = require("../../global-css/typography-options");
15
15
  var _utils = require("../../utils");
16
16
  var _styles = require("./styles");
17
- const _excluded = ["buttonConfig", "children", "data-test", "imgSrc", "onCancel", "open", "title", "typographies", "width", "bgColor", "showCloseIcon"];
17
+ const _excluded = ["buttonConfig", "children", "data-test", "imgSrc", "onCancel", "open", "title", "typographies", "width", "bgColor", "showCloseIcon", "maskClosable"];
18
18
  /* eslint-disable */
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
20
  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); }
@@ -63,7 +63,9 @@ function CustomModal(_ref) {
63
63
  typographies,
64
64
  width,
65
65
  bgColor,
66
- showCloseIcon = true // Add this prop with default value
66
+ showCloseIcon = true,
67
+ // Add this prop with default value
68
+ maskClosable = true // Control whether clicking mask closes modal
67
69
  } = _ref,
68
70
  props = _objectWithoutProperties(_ref, _excluded);
69
71
  /*
@@ -107,7 +109,8 @@ function CustomModal(_ref) {
107
109
  }), /*#__PURE__*/_react.default.createElement(_Typography.default, {
108
110
  typography: typographies.title
109
111
  }, title)),
110
- width: width
112
+ width: width,
113
+ maskClosable: maskClosable
111
114
  }, props), children && /*#__PURE__*/_react.default.createElement(_styles.DescriptionContainer, null,
112
115
  // The label is a string or a number
113
116
  ((0, _utils.isString)(children) || (0, _utils.isNumber)(children)) && /*#__PURE__*/_react.default.createElement(_Typography.default, {
@@ -18,7 +18,7 @@ var _ColorVariablesMap = _interopRequireDefault(require("../../global-css/ColorV
18
18
  var _handIcon = _interopRequireDefault(require("../../images/hand-icon.svg"));
19
19
  var _PdfSampleImage = _interopRequireDefault(require("../../images/PdfSampleImage.png"));
20
20
  var _styles = require("./styles");
21
- const _excluded = ["uploadedDocuments", "handleCustomOnChange", "multipleDoc", "showDelete", "formName", "getPreview", "isMandatory", "noOfUpload", "downloadCallback", "showDownloadButton", "showDeleteButton", "deleteHandler", "showRoateButton", "showZoomInButton", "showZoomOutButton"];
21
+ const _excluded = ["uploadedDocuments", "handleCustomOnChange", "multipleDoc", "showDelete", "formName", "getPreview", "isMandatory", "noOfUpload", "downloadCallback", "showDownloadButton", "showDeleteButton", "deleteHandler", "showRoateButton", "showZoomInButton", "showZoomOutButton", "uploadButtonConfig", "notShowPreviewButton", "listType", "deleteModalConfig"];
22
22
  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); }
23
23
  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; }
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -44,18 +44,18 @@ const getBase64 = file => new Promise((resolve, reject) => {
44
44
  * @returns {undefined}
45
45
  */
46
46
  const downloadFile = (base64String, fileName) => {
47
- const link = document.createElement('a');
47
+ const link = document.createElement("a");
48
48
  link.href = base64String;
49
- link.download = fileName || 'download';
49
+ link.download = fileName || "download";
50
50
  link.click();
51
51
  };
52
52
  function isImageFile(fileName) {
53
53
  var _fileName$split;
54
54
  // Extract the file extension from the file name
55
- const fileExtension = fileName === null || fileName === void 0 || (_fileName$split = fileName.split('.')) === null || _fileName$split === void 0 || (_fileName$split = _fileName$split.pop()) === null || _fileName$split === void 0 ? void 0 : _fileName$split.toLowerCase();
55
+ const fileExtension = fileName === null || fileName === void 0 || (_fileName$split = fileName.split(".")) === null || _fileName$split === void 0 || (_fileName$split = _fileName$split.pop()) === null || _fileName$split === void 0 ? void 0 : _fileName$split.toLowerCase();
56
56
 
57
57
  // Define an array of image file extensions
58
- const imageFileExtensions = ['jpg', 'jpeg', 'png'];
58
+ const imageFileExtensions = ["jpg", "jpeg", "png"];
59
59
 
60
60
  // Check if the file extension is in the array of image file extensions
61
61
  if (imageFileExtensions.indexOf(fileExtension) !== -1) {
@@ -94,12 +94,16 @@ function DocumentUpload(_ref) {
94
94
  deleteHandler,
95
95
  showRoateButton,
96
96
  showZoomInButton,
97
- showZoomOutButton
97
+ showZoomOutButton,
98
+ uploadButtonConfig,
99
+ notShowPreviewButton,
100
+ listType,
101
+ deleteModalConfig
98
102
  } = _ref,
99
103
  antDesignProps = _objectWithoutProperties(_ref, _excluded);
100
104
  const [previewOpen, setPreviewOpen] = (0, _react.useState)(false);
101
105
  const [previewImage, setPreviewImage] = (0, _react.useState)(null);
102
- const [previewTitle, setPreviewTitle] = (0, _react.useState)('');
106
+ const [previewTitle, setPreviewTitle] = (0, _react.useState)("");
103
107
  const [loading, setLoading] = (0, _react.useState)(false);
104
108
  const [fileList, setFileList] = (0, _react.useState)(uploadedDocuments);
105
109
  const [deleteConfirmation, setDeleteConfirmation] = (0, _react.useState)(false);
@@ -109,9 +113,13 @@ function DocumentUpload(_ref) {
109
113
  setFileList(uploadedDocuments);
110
114
  }, [uploadedDocuments === null || uploadedDocuments === void 0 ? void 0 : uploadedDocuments.length]);
111
115
  const handlePreview = async file => {
116
+ // Don't show preview if notShowPreviewButton is true
117
+ if (notShowPreviewButton) {
118
+ return;
119
+ }
112
120
  if (file !== null && file !== void 0 && file.originFileObj) {
113
121
  setPreviewImage(file);
114
- } else if ((file === null || file === void 0 ? void 0 : file.fileType) === 'thumbnail') {
122
+ } else if ((file === null || file === void 0 ? void 0 : file.fileType) === "thumbnail") {
115
123
  const url = await getPreview();
116
124
  setPreviewImage(url);
117
125
  } else {
@@ -126,16 +134,31 @@ function DocumentUpload(_ref) {
126
134
  fileList: newFileList,
127
135
  file
128
136
  } = _ref2;
137
+ if (antDesignProps !== null && antDesignProps !== void 0 && antDesignProps.customRequest) {
138
+ const isMaxFileSize = newFileList.some(f => {
139
+ var _f$error;
140
+ return (f === null || f === void 0 || (_f$error = f.error) === null || _f$error === void 0 ? void 0 : _f$error.status) !== "MAX_FILE_SIZE";
141
+ });
142
+ if (isMaxFileSize) {
143
+ setFileList([]);
144
+ return;
145
+ }
146
+ setFileList(newFileList);
147
+ const isUploading = newFileList.some(f => f.status === "uploading");
148
+ setLoading(isUploading);
149
+ return;
150
+ }
151
+
152
+ // Default behavior for non-custom uploads
129
153
  const modifiedList = await Promise.all(newFileList.map(async files => {
130
154
  let modifiedFile = files;
131
155
  setLoading(true);
132
156
  try {
133
157
  if ((file === null || file === void 0 ? void 0 : file.uid) === (files === null || files === void 0 ? void 0 : files.uid)) {
134
158
  await handleCustomOnChange(files);
135
- modifiedFile.status = 'done';
159
+ modifiedFile.status = "done";
136
160
  if (!isImageFile(file === null || file === void 0 ? void 0 : file.name)) {
137
161
  modifiedFile.url = _PdfSampleImage.default;
138
- // delete modifiedFile?.type;
139
162
  }
140
163
  }
141
164
  } catch (error) {
@@ -147,48 +170,81 @@ function DocumentUpload(_ref) {
147
170
  const tempList = modifiedList === null || modifiedList === void 0 ? void 0 : modifiedList.filter(Boolean);
148
171
  setFileList(tempList);
149
172
  };
173
+ const getUploadButtonIcon = () => {
174
+ if ((uploadButtonConfig === null || uploadButtonConfig === void 0 ? void 0 : uploadButtonConfig.icon) === "PlusOutlined") {
175
+ return /*#__PURE__*/_react.default.createElement(_icons.PlusOutlined, null);
176
+ }
177
+ return /*#__PURE__*/_react.default.createElement(_icons.UploadOutlined, null);
178
+ };
150
179
  const uploadButton = /*#__PURE__*/_react.default.createElement("button", {
151
180
  style: {
152
181
  border: 0,
153
- background: 'none'
182
+ background: "none"
154
183
  },
155
184
  type: "button"
156
- }, loading ? /*#__PURE__*/_react.default.createElement(_icons.LoadingOutlined, null) :
157
- /*#__PURE__*/
158
- // <CustomIcon
159
- // className="UploadImg"
160
- // alt="phone img"
161
- // src={offerImg}
162
- // />
163
- _react.default.createElement(_icons.UploadOutlined, null), /*#__PURE__*/_react.default.createElement("div", null, "Upload"));
185
+ }, loading ? /*#__PURE__*/_react.default.createElement(_icons.LoadingOutlined, null) : getUploadButtonIcon(), /*#__PURE__*/_react.default.createElement("div", null, uploadButtonConfig !== null && uploadButtonConfig !== void 0 && uploadButtonConfig.text ? uploadButtonConfig === null || uploadButtonConfig === void 0 ? void 0 : uploadButtonConfig.text : "Upload"));
164
186
  const DeleteFile = async () => {
165
- await deleteHandler(selectedFile);
187
+ await deleteHandler(selectedFile, isEmptyFileList => {
188
+ if (isEmptyFileList) {
189
+ setFileList([]);
190
+ }
191
+ });
166
192
  setDeleteConfirmation(false);
167
193
  if (showDeleteButton) {
168
194
  setPreviewOpen(false);
169
195
  }
170
196
  };
171
197
  const handleRemove = file => new Promise((resolve, reject) => {
172
- setSelectedFile(file);
173
- setDeleteConfirmation(true);
174
- resolve(false);
198
+ // If file is uploading, cancel immediately without confirmation
199
+ if ((file === null || file === void 0 ? void 0 : file.status) === "uploading") {
200
+ // Remove file from list immediately to cancel upload
201
+ const newFileList = fileList.filter(f => f.uid !== file.uid);
202
+ setFileList(newFileList);
203
+ resolve(true); // Allow removal
204
+ return;
205
+ }
206
+
207
+ // If file is done or error, show confirmation modal
208
+ if ((file === null || file === void 0 ? void 0 : file.status) === "done" || (file === null || file === void 0 ? void 0 : file.status) === "error") {
209
+ setSelectedFile(file);
210
+ setDeleteConfirmation(true);
211
+ resolve(false); // Prevent removal until confirmed
212
+ return;
213
+ }
214
+
215
+ // Default: allow removal
216
+ resolve(true);
175
217
  });
176
218
  const handleModalDeleteButton = file => {
177
219
  setSelectedFile(file);
178
220
  setDeleteConfirmation(true);
179
221
  };
222
+
223
+ // Get the appropriate remove icon based on file status
224
+ const getRemoveIcon = file => {
225
+ // Show cross icon during upload (to cancel)
226
+ if ((file === null || file === void 0 ? void 0 : file.status) === "uploading") {
227
+ return /*#__PURE__*/_react.default.createElement(_icons.CloseOutlined, null);
228
+ }
229
+ // Show delete icon after upload is done or if upload failed
230
+ if ((file === null || file === void 0 ? void 0 : file.status) === "done" || (file === null || file === void 0 ? void 0 : file.status) === "error") {
231
+ return /*#__PURE__*/_react.default.createElement(_icons.DeleteFilled, null);
232
+ }
233
+ // Default to delete icon
234
+ return /*#__PURE__*/_react.default.createElement(_icons.DeleteFilled, null);
235
+ };
180
236
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_styles.MainStyleSec, null, /*#__PURE__*/_react.default.createElement(_styles.StyledSection, null, /*#__PURE__*/_react.default.createElement("div", {
181
237
  className: "uploadDiv"
182
238
  }, multipleDoc > 0 && /*#__PURE__*/_react.default.createElement("em", null, multipleDoc), /*#__PURE__*/_react.default.createElement(_antd.ConfigProvider, {
183
239
  theme: {
184
240
  token: {
185
- colorBorder: _ColorVariablesMap.default['--color-divider'],
241
+ colorBorder: _ColorVariablesMap.default["--color-divider"],
186
242
  borderRadiusLG: 4,
187
- colorPrimaryHover: _ColorVariablesMap.default['--color-primary'],
188
- colorPrimaryBorder: _ColorVariablesMap.default['--color-divider'],
189
- colorFillAlter: _ColorVariablesMap.default['--color-secondary-background'],
190
- colorError: _ColorVariablesMap.default['--color-negative'],
191
- colorText: _ColorVariablesMap.default['--color-secondary-content']
243
+ colorPrimaryHover: _ColorVariablesMap.default["--color-primary"],
244
+ colorPrimaryBorder: _ColorVariablesMap.default["--color-divider"],
245
+ colorFillAlter: _ColorVariablesMap.default["--color-secondary-background"],
246
+ colorError: _ColorVariablesMap.default["--color-negative"],
247
+ colorText: _ColorVariablesMap.default["--color-secondary-content"]
192
248
  }
193
249
  }
194
250
  }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
@@ -196,27 +252,28 @@ function DocumentUpload(_ref) {
196
252
  rules: [{
197
253
  validator: (rule, value) => {
198
254
  if (isMandatory && !(value !== null && value !== void 0 && value.length)) {
199
- if (typeof value === 'object' && Object.keys(value).length > 0) {
255
+ if (typeof value === "object" && Object.keys(value).length > 0) {
200
256
  return Promise.resolve();
201
257
  }
202
- return Promise.reject(new Error('Please upload the document.'));
258
+ return Promise.reject(new Error("Please upload the document."));
203
259
  }
204
260
  return Promise.resolve();
205
261
  }
206
262
  }]
207
263
  }, /*#__PURE__*/_react.default.createElement(_antd.Upload, _extends({
208
- customRequest: () => {},
209
- listType: "picture-card",
264
+ listType: listType ? listType : "picture-card",
210
265
  fileList: fileList,
211
- onPreview: handlePreview,
266
+ onPreview: notShowPreviewButton ? undefined : handlePreview,
212
267
  onChange: handleChange,
213
268
  onRemove: handleRemove,
214
269
  showUploadList: {
215
270
  showDownloadIcon: false,
216
- showRemoveIcon: showDelete,
217
- removeIcon: /*#__PURE__*/_react.default.createElement(_icons.DeleteFilled, null),
218
- previewIcon: /*#__PURE__*/_react.default.createElement(_icons.EyeFilled, null)
219
- }
271
+ showRemoveIcon: showDelete !== undefined ? showDelete : true,
272
+ showPreviewIcon: !notShowPreviewButton,
273
+ removeIcon: file => getRemoveIcon(file),
274
+ previewIcon: notShowPreviewButton ? false : /*#__PURE__*/_react.default.createElement(_icons.EyeFilled, null)
275
+ },
276
+ maxCount: noOfUpload
220
277
  }, antDesignProps), (fileList === null || fileList === void 0 ? void 0 : fileList.length) >= noOfUpload ? null : uploadButton)))))), previewOpen && /*#__PURE__*/_react.default.createElement(_CustomViewer.default, {
221
278
  open: previewOpen,
222
279
  previewFile: previewImage,
@@ -233,15 +290,15 @@ function DocumentUpload(_ref) {
233
290
  }), deleteConfirmation && /*#__PURE__*/_react.default.createElement(_CustomModal.default, {
234
291
  buttonConfig: [{
235
292
  callback: () => DeleteFile(),
236
- label: 'Yes, Delete',
237
- type: 'danger-primary'
293
+ label: "Yes, Delete",
294
+ type: "danger-primary"
238
295
  }],
239
296
  imgSrc: _handIcon.default,
240
297
  open: deleteConfirmation,
241
298
  onCancel: () => setDeleteConfirmation(false),
242
- title: "Delete Item?",
299
+ title: deleteModalConfig !== null && deleteModalConfig !== void 0 && deleteModalConfig.title ? deleteModalConfig.title : "Delete Item?",
243
300
  className: "delete-modal-confirmation"
244
- }, "This action will permanently delete the selected item"));
301
+ }, deleteModalConfig !== null && deleteModalConfig !== void 0 && deleteModalConfig.body ? deleteModalConfig.body : "This action will permanently delete the selected item"));
245
302
  }
246
303
  DocumentUpload.propTypes = {
247
304
  uploadedDocuments: _propTypes.default.array,
@@ -262,12 +319,15 @@ DocumentUpload.propTypes = {
262
319
  showDeleteButton: _propTypes.default.bool,
263
320
  showRoateButton: _propTypes.default.bool,
264
321
  showZoomInButton: _propTypes.default.bool,
265
- showZoomOutButton: _propTypes.default.bool
322
+ showZoomOutButton: _propTypes.default.bool,
323
+ uploadButtonConfig: _propTypes.default.object,
324
+ // Config for upload button text
325
+ notShowPreviewButton: _propTypes.default.bool // Hide preview button
266
326
  };
267
327
  DocumentUpload.defaultProps = {
268
328
  uploadedDocuments: [],
269
329
  handleCustomOnChange: () => {},
270
- formName: '',
330
+ formName: "",
271
331
  multipleDoc: 0,
272
332
  showDelete: true,
273
333
  getPreview: () => {},
@@ -280,6 +340,8 @@ DocumentUpload.defaultProps = {
280
340
  showDownloadButton: true,
281
341
  showRoateButton: true,
282
342
  showZoomInButton: true,
283
- showZoomOutButton: true
343
+ showZoomOutButton: true,
344
+ uploadButtonConfig: null,
345
+ notShowPreviewButton: false
284
346
  };
285
347
  var _default = exports.default = DocumentUpload;
@@ -81,7 +81,8 @@ function GenricLayOut(_ref) {
81
81
  handleCollapsibleKeyData,
82
82
  handleProfileReroute,
83
83
  handleTableFooterApi,
84
- handleSwitchSelectItem
84
+ handleSwitchSelectItem,
85
+ handleTableColumnClickParent
85
86
  } = {}
86
87
  } = _ref;
87
88
  const [state, dispatch] = (0, _react.useReducer)(_layoutReducer.genericLayoutReducer, config !== null && config !== void 0 ? config : _layoutReducer.initialState);
@@ -835,7 +836,11 @@ function GenricLayOut(_ref) {
835
836
  if (error) {
836
837
  showErrorNotification(error);
837
838
  } else {
838
- if ((configArgs === null || configArgs === void 0 ? void 0 : configArgs.type) === "openNestedDrawer") {
839
+ if ((data === null || data === void 0 ? void 0 : data.call) === "parent") {
840
+ handleTableColumnClickParent({
841
+ data
842
+ });
843
+ } else if ((configArgs === null || configArgs === void 0 ? void 0 : configArgs.type) === "openNestedDrawer") {
839
844
  var _config$nestedDrawer;
840
845
  const record = config === null || config === void 0 || (_config$nestedDrawer = config.nestedDrawer) === null || _config$nestedDrawer === void 0 || (_config$nestedDrawer = _config$nestedDrawer.data) === null || _config$nestedDrawer === void 0 ? void 0 : _config$nestedDrawer.cancelOrder;
841
846
  const dynamicConfig = (0, _staticConfigResolver.default)(record, data !== null && data !== void 0 ? data : {});
@@ -22,7 +22,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
22
22
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
23
23
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint-disable */
24
24
  function LayoutModal(_ref) {
25
- var _modal$jsxConfig;
25
+ var _modal$jsxConfig, _modal$modalContent14;
26
26
  let {
27
27
  modal,
28
28
  onCancel,
@@ -84,7 +84,8 @@ function LayoutModal(_ref) {
84
84
  imgSrc: modal === null || modal === void 0 ? void 0 : modal.imgSrc,
85
85
  buttonConfig: getModalButtonConfig(modal === null || modal === void 0 || (_modal$jsxConfig = modal.jsxConfig) === null || _modal$jsxConfig === void 0 ? void 0 : _modal$jsxConfig.buttonConfig),
86
86
  bgColor: modal === null || modal === void 0 ? void 0 : modal.bgColor,
87
- showCloseIcon: modal === null || modal === void 0 ? void 0 : modal.showCloseIcon
87
+ showCloseIcon: modal === null || modal === void 0 ? void 0 : modal.showCloseIcon,
88
+ maskClosable: (modal === null || modal === void 0 || (_modal$modalContent14 = modal.modalContent) === null || _modal$modalContent14 === void 0 ? void 0 : _modal$modalContent14.backClickDisable) === true ? false : (modal === null || modal === void 0 ? void 0 : modal.maskClosable) !== undefined ? modal === null || modal === void 0 ? void 0 : modal.maskClosable : true
88
89
  }, render());
89
90
  }
90
91
  LayoutModal.propTypes = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-componentbook",
3
- "version": "1.0.1-stage.413",
3
+ "version": "1.0.1-stage.414",
4
4
  "private": false,
5
5
  "description": "Reusable components",
6
6
  "main": "build/index.js",