oa-componentbook 1.0.1-stage.7 → 1.0.1-stage.70

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.
Files changed (45) hide show
  1. package/build/components/oa-component-accordion/Accordion.js +16 -5
  2. package/build/components/oa-component-feedback-form/FeedbackForm.js +75 -0
  3. package/build/components/oa-component-feedback-tooltip/FeedbackTooltip.js +69 -0
  4. package/build/components/oa-component-info/CustomInfo.js +9 -4
  5. package/build/components/oa-component-info/styles.js +3 -3
  6. package/build/components/oa-component-modal/styles.js +1 -1
  7. package/build/dev/oa-component-document-viewer/CustomDocumentViewer.js +276 -0
  8. package/build/dev/oa-component-document-viewer/styles.js +12 -0
  9. package/build/dev/oa-component-upload/CustomUpload.js +3 -0
  10. package/build/dev/oa-widget-document-side-drawer/DocumentSideDrawer.js +120 -0
  11. package/build/dev/oa-widget-document-side-drawer/styles.js +12 -0
  12. package/build/global-css/GlobalCss.js +2 -1
  13. package/build/global-css/GridLayout.js +1 -1
  14. package/build/global-css/commonStyles.js +11 -0
  15. package/build/images/oaChat.svg +5 -0
  16. package/build/index.js +56 -0
  17. package/build/layout/paymentAndConsent/CancelScreen.js +46 -0
  18. package/build/layout/paymentAndConsent/ConsentCard.js +68 -0
  19. package/build/layout/paymentAndConsent/DetailsCard.js +75 -0
  20. package/build/layout/paymentAndConsent/DetailsList.js +38 -0
  21. package/build/layout/paymentAndConsent/Header.js +33 -0
  22. package/build/layout/paymentAndConsent/InProgressScreen.js +46 -0
  23. package/build/layout/paymentAndConsent/Loader.js +21 -0
  24. package/build/layout/paymentAndConsent/Modal.js +28 -0
  25. package/build/layout/paymentAndConsent/PaymentAndConsent.js +22 -0
  26. package/build/layout/paymentAndConsent/PaymentCard.js +83 -0
  27. package/build/layout/paymentAndConsent/Section.js +34 -0
  28. package/build/layout/paymentAndConsent/SuccessScreen.js +46 -0
  29. package/build/layout/paymentAndConsent/TimeLineCard.js +28 -0
  30. package/build/layout/paymentAndConsent/TncList.js +32 -0
  31. package/build/layout/paymentAndConsent/style.js +12 -0
  32. package/build/widgets/oa-widget-add-spare-part/AddSparePartCollapseWidget.js +17 -11
  33. package/build/widgets/oa-widget-approval/ApprovalWidgetNew.js +318 -0
  34. package/build/widgets/oa-widget-approval/styles.js +2 -2
  35. package/build/widgets/oa-widget-document-upload/DocUploadWidget.js +6 -6
  36. package/build/widgets/oa-widget-feedback/FeedbackWidget.js +83 -0
  37. package/build/widgets/oa-widget-feedback/styles.js +13 -0
  38. package/build/widgets/oa-widget-image-carousel/ImageCarouselWidget.js +257 -0
  39. package/build/widgets/oa-widget-image-carousel/styles.js +23 -0
  40. package/build/widgets/oa-widget-notes/NotesWidget.js +2 -1
  41. package/build/widgets/oa-widget-reupload-drawer/ReUploadDrawer.js +161 -0
  42. package/build/widgets/oa-widget-track-shipment/TrackShipmentWidget.js +4 -2
  43. package/build/widgets/oa-widget-track-shipment-list/TrackShipmentWidgetList.js +77 -38
  44. package/build/widgets/oa-widget-track-shipment-list/fn.js +8 -8
  45. package/package.json +6 -3
@@ -45,6 +45,8 @@ CollapseIcon.propTypes = {
45
45
  * @param {string | number} [key] - Key to be used for the collapsible panel.
46
46
  * @param {string | number} [defaultActiveKey] - Key of the collapsible panel that should be active by default.
47
47
  * @param {boolean} [hasContentPadding=true] - Whether to apply content padding to the collapsible panel or not.
48
+ * @param {Function} [onChange=() => {}] - Function to be called when the panel is expanded or collapsed.
49
+ * @param {string | number} [activeKey] - Key of the collapsible panel that is currently active.
48
50
  */
49
51
  function Accordion(_ref2) {
50
52
  let {
@@ -55,7 +57,10 @@ function Accordion(_ref2) {
55
57
  smallText,
56
58
  key,
57
59
  defaultActiveKey,
58
- hasContentPadding // New prop to determine whether to apply contentPadding
60
+ hasContentPadding,
61
+ // New prop to determine whether to apply contentPadding
62
+ onChange,
63
+ activeKey
59
64
  } = _ref2;
60
65
  const themeConfig = {
61
66
  components: {
@@ -70,11 +75,12 @@ function Accordion(_ref2) {
70
75
  }, /*#__PURE__*/_react.default.createElement(_styles.CollapseStyle, null, /*#__PURE__*/_react.default.createElement(_antd.Collapse, {
71
76
  expandIcon: CollapseIcon,
72
77
  expandIconPosition: "end",
73
- defaultActiveKey: disabled ? '-1' : defaultActiveKey
78
+ defaultActiveKey: disabled ? '-1' : defaultActiveKey,
79
+ onChange: onChange
74
80
  }, /*#__PURE__*/_react.default.createElement(_antd.Collapse.Panel, {
75
81
  "data-test": dataTest ? "".concat(dataTest, "--complete") : undefined,
76
82
  collapsible: disabled ? 'disabled' : undefined,
77
- key: key,
83
+ key: activeKey || key,
78
84
  header: /*#__PURE__*/_react.default.createElement("div", {
79
85
  "data-test": dataTest ? "".concat(dataTest, "--header") : undefined,
80
86
  className: "type-button-500"
@@ -92,7 +98,9 @@ Accordion.propTypes = {
92
98
  hasContentPadding: _propTypes.default.bool,
93
99
  // New prop for controlling contentPadding
94
100
  key: _propTypes.default.string,
95
- defaultActiveKey: _propTypes.default.string
101
+ defaultActiveKey: _propTypes.default.string,
102
+ onChange: _propTypes.default.func,
103
+ activeKey: _propTypes.default.string || _propTypes.default.number
96
104
  };
97
105
  Accordion.defaultProps = {
98
106
  body: '',
@@ -101,6 +109,9 @@ Accordion.defaultProps = {
101
109
  smallText: '',
102
110
  key: '1',
103
111
  defaultActiveKey: '1',
104
- hasContentPadding: true // Default value for contentPadding
112
+ hasContentPadding: true,
113
+ // Default value for contentPadding
114
+ onChange: () => {},
115
+ activeKey: null
105
116
  };
106
117
  var _default = exports.default = Accordion;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.weak-map.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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); }
13
+ 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; }
14
+ /** *********** ✨ Codeium Command ⭐ ************ */
15
+ /**
16
+ * FeedbackForm component renders an iframe and a script tag.
17
+ *
18
+ * @param {Object} props - The properties object.
19
+ * @param {string} props.iframeSrc - The source URL for the iframe.
20
+ * @param {string} props.scriptSrc - The source URL for the script.
21
+ * @param {boolean} props.open - A boolean value to control the effect.
22
+ *
23
+ * The component uses a useEffect hook to send a postMessage to the iframe
24
+ * content window once the iframe has loaded, enabling specific settings.
25
+ * The iframe is styled to fill the entire viewport.
26
+ */
27
+
28
+ /** **** 1da5e3d4-a27c-425d-956f-e856770f0f0d ****** */
29
+ function FeedbackForm(_ref) {
30
+ let {
31
+ iframeSrc,
32
+ scriptSrc,
33
+ open
34
+ } = _ref;
35
+ const [iframeKey, setIframeKey] = (0, _react.useState)(0);
36
+ (0, _react.useEffect)(() => {
37
+ const iframe = document.getElementById('s2c_embed_90232');
38
+ if (iframe) {
39
+ iframe.onload = function () {
40
+ const ifrmContWin = iframe.contentWindow;
41
+ const sendPostMsg = 'hideHeader=false&hideFooter=false';
42
+ ifrmContWin.postMessage(sendPostMsg, '*');
43
+ };
44
+ }
45
+ setIframeKey(prevKey => prevKey + 1);
46
+ }, [open]);
47
+ return /*#__PURE__*/_react.default.createElement("div", {
48
+ style: {
49
+ margin: 0,
50
+ height: '100%',
51
+ overflow: 'hidden'
52
+ }
53
+ }, /*#__PURE__*/_react.default.createElement("iframe", {
54
+ key: iframeKey,
55
+ id: "s2c_embed_90232",
56
+ width: "100%",
57
+ frameBorder: "0" // Removed line gap
58
+ ,
59
+ src: iframeSrc,
60
+ style: {
61
+ height: '100%',
62
+ width: '100%'
63
+ },
64
+ title: "Feedback Survey"
65
+ }), /*#__PURE__*/_react.default.createElement("script", {
66
+ type: "text/javascript",
67
+ src: scriptSrc
68
+ }));
69
+ }
70
+ FeedbackForm.propTypes = {
71
+ iframeSrc: _propTypes.default.string.isRequired,
72
+ scriptSrc: _propTypes.default.string.isRequired,
73
+ open: _propTypes.default.bool.isRequired
74
+ };
75
+ var _default = exports.default = FeedbackForm;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _CustomButton = _interopRequireDefault(require("../oa-component-button/CustomButton"));
9
+ var _CustomTooltip = _interopRequireDefault(require("../oa-component-tooltip/CustomTooltip"));
10
+ var _Typography = _interopRequireDefault(require("../oa-component-typography/Typography"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ /** *********** ✨ Codeium Command ⭐ ************ */
13
+ /**
14
+ * FeedbackTooltip component displays a tooltip with a title, description, and buttons.
15
+ *
16
+ * @param {Object} props - The properties object.
17
+ * @param {boolean} props.hasClickedFeedback - Flag indicating if feedback button was clicked.
18
+ * @param {string} props.tooltipTitle - Title text for the tooltip.
19
+ * @param {string} props.tooltipDescription - Description text for the tooltip.
20
+ * @param {string} props.tooltipButtonLabel - Label for the tooltip button.
21
+ * @param {string} props.feedbackButtonLabel - Label for the feedback button.
22
+ * @param {Function} props.onButtonClick - Callback function for the tooltip button click.
23
+ * @param {Function} props.onFeedbackButtonClick - Callback function for the feedback button click.
24
+ * @param {boolean} props.tooltipOpen - Flag to control the visibility of the tooltip.
25
+ *
26
+ * @returns {ReactElement} The rendered FeedbackTooltip component.
27
+ */
28
+
29
+ /** **** 8ccbdb54-5c16-4cae-9d57-f492fd44997c ****** */
30
+
31
+ function FeedbackTooltip(props) {
32
+ const {
33
+ hasClickedFeedback,
34
+ tooltipTitle,
35
+ tooltipDescription,
36
+ tooltipButtonLabel,
37
+ feedbackButtonLabel,
38
+ onButtonClick,
39
+ onFeedbackButtonClick,
40
+ tooltipOpen
41
+ } = props !== null && props !== void 0 ? props : {};
42
+ return /*#__PURE__*/_react.default.createElement(_CustomTooltip.default, {
43
+ open: tooltipOpen && !hasClickedFeedback,
44
+ overlayClassName: "OaTooltip",
45
+ placement: "left",
46
+ title: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
47
+ className: "type-t1-500",
48
+ color: "primary-content"
49
+ }, tooltipTitle), /*#__PURE__*/_react.default.createElement("div", {
50
+ className: "padding-top-4 padding-bottom-32"
51
+ }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
52
+ className: "type-b2-400",
53
+ color: "secondary-content"
54
+ }, tooltipDescription)), /*#__PURE__*/_react.default.createElement("div", {
55
+ className: "OaFooterBtn"
56
+ }, /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
57
+ label: tooltipButtonLabel,
58
+ onClick: onButtonClick
59
+ })))
60
+ }, /*#__PURE__*/_react.default.createElement("div", {
61
+ className: "whiteBg"
62
+ }, /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
63
+ className: "feedbackBtn",
64
+ onClick: onFeedbackButtonClick,
65
+ size: "large",
66
+ label: feedbackButtonLabel
67
+ })));
68
+ }
69
+ var _default = exports.default = FeedbackTooltip;
@@ -27,6 +27,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
27
27
  * @param {string} fontColor - The color of the text.
28
28
  * @param {object} iconConfig - Configuration for the icon.
29
29
  * @param {string} title - The title to be displayed.
30
+ * @param {string} borderColor - The border color of the component.
30
31
  *
31
32
  * @returns {ReactElement} A styled component with the specified properties.
32
33
  */
@@ -37,7 +38,8 @@ function CustomInfo(_ref) {
37
38
  description,
38
39
  fontColor,
39
40
  iconConfig,
40
- title
41
+ title,
42
+ borderColor
41
43
  } = _ref;
42
44
  /**
43
45
  * Renders the icon based on the presence of a title.
@@ -65,7 +67,8 @@ function CustomInfo(_ref) {
65
67
  }, renderIcon()) : renderIcon();
66
68
  };
67
69
  return /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, {
68
- $color: color
70
+ $color: color,
71
+ $borderColor: borderColor
69
72
  }, /*#__PURE__*/_react.default.createElement(_styles.RowFlex, null, iconConfig.position === 'left' && conditionallyAddTooltipToIcon(), /*#__PURE__*/_react.default.createElement(_styles.ColFlex, null, title && /*#__PURE__*/_react.default.createElement(_Typography.default, {
70
73
  color: fontColor,
71
74
  typography: "type-t2-700"
@@ -96,7 +99,8 @@ CustomInfo.propTypes = {
96
99
  position: _propTypes.default.oneOf(['left', 'right']),
97
100
  tooltipText: _propTypes.default.string
98
101
  }),
99
- title: _propTypes.default.string
102
+ title: _propTypes.default.string,
103
+ borderColor: _propTypes.default.string
100
104
  };
101
105
  CustomInfo.defaultProps = {
102
106
  buttonConfig: {
@@ -110,5 +114,6 @@ CustomInfo.defaultProps = {
110
114
  },
111
115
  fontColor: 'primary-content',
112
116
  title: '',
113
- description: ''
117
+ description: '',
118
+ borderColor: ''
114
119
  };
@@ -8,8 +8,8 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
8
  var _templateObject, _templateObject2, _templateObject3;
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
11
- const RowFlex = exports.RowFlex = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n gap: 8px;\n"])));
12
- const ColFlex = exports.ColFlex = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 8px;\n"])));
11
+ const RowFlex = exports.RowFlex = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n gap: 8px;\n"])));
12
+ const ColFlex = exports.ColFlex = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 8px;\n"])));
13
13
  const InfoContainer = exports.InfoContainer = (0, _styledComponents.default)(RowFlex).attrs({
14
14
  as: 'section'
15
- })(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 12px;\n align-items: center;\n border-radius: 8px;\n background-color: var(--color-", ");\n \n button {\n margin-left: 8px;\n };\n"])), props => props.$color);
15
+ })(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 12px;\n align-items: center;\n border-radius: 8px;\n background-color: var(--color-", ");\n border: 1px solid var(--color-", ");\n\n button {\n margin-left: 8px;\n }\n"])), props => props.$color, props => props.$borderColor);
@@ -10,4 +10,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
10
10
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
11
11
  const ButtonContainer = exports.ButtonContainer = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n gap: 16px;\n justify-content: flex-end;\n margin: 24px 0 0;\n @media (max-width: 768px) {\n justify-content: space-between;\n button{\n width: 100%;\n }\n }\n"])));
12
12
  const DescriptionContainer = exports.DescriptionContainer = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: 12px 0 0;\n"])));
13
- const TitleContainer = exports.TitleContainer = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n gap: 16px;\n flex-direction: column;\n margin: 0 0 16px;\n\n img {\n height: 36px;\n width: 36px;\n }\n"])));
13
+ const TitleContainer = exports.TitleContainer = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n gap: 16px;\n flex-direction: column;\n margin: 0 0 16px;\n padding: 0 42px 0 0;\n\n img {\n height: 36px;\n width: 36px;\n }\n"])));
@@ -0,0 +1,276 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.weak-map.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+ require("core-js/modules/es.promise.js");
10
+ require("core-js/modules/web.url.js");
11
+ require("core-js/modules/web.url-search-params.js");
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _propTypes = _interopRequireDefault(require("prop-types"));
14
+ var _reactPdf = require("react-pdf");
15
+ var _icons = require("@material-ui/icons");
16
+ var _RotateRight = _interopRequireDefault(require("@material-ui/icons/RotateRight"));
17
+ var _MaterialIcon = _interopRequireDefault(require("../../components/oa-component-icons/MaterialIcon"));
18
+ var _Typography = _interopRequireDefault(require("../../components/oa-component-typography/Typography"));
19
+ var _styles = _interopRequireDefault(require("./styles"));
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+ 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); }
22
+ 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; }
23
+ /* eslint-disable */
24
+
25
+ _reactPdf.pdfjs.GlobalWorkerOptions.workerSrc = "//cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(_reactPdf.pdfjs.version, "/pdf.worker.js");
26
+ const ZOOM_STEP = 0.2;
27
+ const MIN_ZOOM = 0.5;
28
+ const MAX_ZOOM = 3.0;
29
+ function CustomDocumentViewer(_ref) {
30
+ let {
31
+ fileType,
32
+ fileUrl,
33
+ onDownload,
34
+ hideZoom,
35
+ hideDownload,
36
+ hidePageNumber,
37
+ hideRotate,
38
+ documentViewerOverlayHeight
39
+ } = _ref;
40
+ const [totalPages, setTotalPages] = (0, _react.useState)(null);
41
+ const [scale, setScale] = (0, _react.useState)(1.0);
42
+ const [currentPage, setCurrentPage] = (0, _react.useState)(1);
43
+ // For image rotation.
44
+ const [rotation, setRotation] = (0, _react.useState)(0);
45
+ const containerRef = (0, _react.useRef)(null);
46
+ const pageRefs = (0, _react.useRef)([]);
47
+
48
+ // When the document loads, update total pages (for PDFs).
49
+ const onDocumentLoadSuccess = _ref2 => {
50
+ let {
51
+ numPages
52
+ } = _ref2;
53
+ setTotalPages(numPages);
54
+ };
55
+ // Zoom handlers.
56
+ const handleZoomIn = (0, _react.useCallback)(() => setScale(prev => Math.min(prev + ZOOM_STEP, MAX_ZOOM)), []);
57
+ const handleZoomOut = (0, _react.useCallback)(() => setScale(prev => Math.max(prev - ZOOM_STEP, MIN_ZOOM)), []);
58
+ const handleResetZoom = (0, _react.useCallback)(() => setScale(1.0), []);
59
+
60
+ // Single rotation handler for images – rotates 90° clockwise each click.
61
+ const handleRotate = (0, _react.useCallback)(() => {
62
+ setRotation(prev => prev + 90);
63
+ }, []);
64
+
65
+ // Default download function; can be overridden by passing an onDownload prop.
66
+ const defaultDownload = (0, _react.useCallback)(() => {
67
+ if (fileType === 'image') {
68
+ // Fetch the image as a blob to force download.
69
+ fetch(fileUrl, {
70
+ mode: 'cors'
71
+ }).then(res => res.blob()).then(blob => {
72
+ const url = window.URL.createObjectURL(blob);
73
+ const link = document.createElement('a');
74
+ link.href = url;
75
+ link.download = fileUrl.split('/').pop();
76
+ document.body.appendChild(link);
77
+ link.click();
78
+ document.body.removeChild(link);
79
+ window.URL.revokeObjectURL(url);
80
+ }).catch(error => {
81
+ console.error('Image download failed:', error);
82
+ });
83
+ } else {
84
+ // For PDFs and other file types, use the standard download.
85
+ const link = document.createElement('a');
86
+ link.href = fileUrl;
87
+ link.download = fileUrl.split('/').pop();
88
+ document.body.appendChild(link);
89
+ link.click();
90
+ document.body.removeChild(link);
91
+ }
92
+ }, [fileUrl, fileType]);
93
+ const handleDownload = onDownload || defaultDownload;
94
+
95
+ // Enable dragging when zoomed in.
96
+ (0, _react.useEffect)(() => {
97
+ const container = containerRef.current;
98
+ if (!container) return;
99
+ let isDragging = false;
100
+ let startX;
101
+ let startY;
102
+ let scrollLeft;
103
+ let scrollTop;
104
+ const onMouseDown = e => {
105
+ if (scale > 1.0) {
106
+ isDragging = true;
107
+ container.style.cursor = 'grabbing';
108
+ startX = e.pageX;
109
+ startY = e.pageY;
110
+ scrollLeft = container.scrollLeft;
111
+ scrollTop = container.scrollTop;
112
+ }
113
+ };
114
+ const onMouseMove = e => {
115
+ if (!isDragging) return;
116
+ e.preventDefault();
117
+ container.scrollLeft = scrollLeft - (e.pageX - startX);
118
+ container.scrollTop = scrollTop - (e.pageY - startY);
119
+ };
120
+ const onMouseUp = function onMouseUp() {
121
+ isDragging = false;
122
+ container.style.cursor = scale > 1.0 ? 'grab' : 'auto';
123
+ };
124
+ container.addEventListener('mousedown', onMouseDown);
125
+ container.addEventListener('mousemove', onMouseMove);
126
+ container.addEventListener('mouseup', onMouseUp);
127
+ container.addEventListener('mouseleave', onMouseUp);
128
+ return () => {
129
+ container.removeEventListener('mousedown', onMouseDown);
130
+ container.removeEventListener('mousemove', onMouseMove);
131
+ container.removeEventListener('mouseup', onMouseUp);
132
+ container.removeEventListener('mouseleave', onMouseUp);
133
+ };
134
+ }, [scale]);
135
+
136
+ // (Optional) Scroll event to update the current page (for PDFs).
137
+ const handleScroll = () => {
138
+ const container = containerRef.current;
139
+ if (!container) return;
140
+ const containerRect = container.getBoundingClientRect();
141
+ let closestPage = 1;
142
+ let minDistance = Infinity;
143
+ pageRefs.current.forEach((ref, index) => {
144
+ if (ref) {
145
+ const rect = ref.getBoundingClientRect();
146
+ const distance = Math.abs(rect.top - containerRect.top);
147
+ if (distance < minDistance) {
148
+ minDistance = distance;
149
+ closestPage = index + 1;
150
+ }
151
+ }
152
+ });
153
+ setCurrentPage(closestPage);
154
+ };
155
+ return /*#__PURE__*/_react.default.createElement("div", {
156
+ className: "myChotaModal"
157
+ }, /*#__PURE__*/_react.default.createElement(_styles.default, {
158
+ documentViewerOverlayHeight: documentViewerOverlayHeight
159
+ }, /*#__PURE__*/_react.default.createElement("div", {
160
+ ref: containerRef,
161
+ className: "customDocumentViewerOverlay",
162
+ style: {
163
+ cursor: scale > 1.0 ? 'grab' : 'auto'
164
+ },
165
+ onScroll: handleScroll
166
+ }, /*#__PURE__*/_react.default.createElement("div", {
167
+ className: "customDocumentViewerOverlayHeader"
168
+ }, fileType === 'pdf' && !hidePageNumber ? /*#__PURE__*/_react.default.createElement("div", {
169
+ className: "pageNumber"
170
+ }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
171
+ className: "type-button-500",
172
+ color: "primary-background"
173
+ }, "Page", ' ', currentPage, ' ', "of", ' ', totalPages)) : fileType === 'image' && !hideRotate ? /*#__PURE__*/_react.default.createElement("div", {
174
+ className: "pageNumber"
175
+ }, /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
176
+ color: "primary-background",
177
+ size: 24,
178
+ icon: _RotateRight.default,
179
+ onClick: handleRotate,
180
+ style: {
181
+ cursor: 'pointer'
182
+ }
183
+ })) : null, !hideZoom && /*#__PURE__*/_react.default.createElement("div", {
184
+ className: "customDocumentViewerOverlayHeaderIcons"
185
+ }, /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
186
+ color: "primary-background",
187
+ size: 24,
188
+ icon: _icons.RemoveRounded,
189
+ onClick: handleZoomOut,
190
+ style: {
191
+ cursor: scale === MIN_ZOOM ? 'not-allowed' : 'pointer'
192
+ }
193
+ }), /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
194
+ color: "primary-background",
195
+ size: 24,
196
+ icon: _icons.ZoomInRounded,
197
+ onClick: handleResetZoom,
198
+ style: {
199
+ cursor: scale === 1.0 ? 'not-allowed' : 'pointer'
200
+ }
201
+ }), /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
202
+ color: "primary-background",
203
+ size: 24,
204
+ icon: _icons.AddRounded,
205
+ onClick: handleZoomIn,
206
+ style: {
207
+ cursor: scale === MAX_ZOOM ? 'not-allowed' : 'pointer'
208
+ }
209
+ })), !hideDownload && /*#__PURE__*/_react.default.createElement("div", {
210
+ className: "downloadIcon"
211
+ }, /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
212
+ color: "primary-background",
213
+ size: 24,
214
+ icon: _icons.GetAppRounded,
215
+ onClick: handleDownload
216
+ }))), fileType === 'pdf' && /*#__PURE__*/_react.default.createElement("div", {
217
+ style: {
218
+ transform: "scale(".concat(scale, ")"),
219
+ transformOrigin: 'top center'
220
+ }
221
+ }, /*#__PURE__*/_react.default.createElement(_reactPdf.Document, {
222
+ file: fileUrl,
223
+ onLoadSuccess: onDocumentLoadSuccess
224
+ }, Array.from({
225
+ length: totalPages
226
+ }, (_, index) => /*#__PURE__*/_react.default.createElement("div", {
227
+ key: "page_".concat(index + 1),
228
+ ref: el => pageRefs.current[index] = el,
229
+ style: {
230
+ marginBottom: '20px',
231
+ display: 'flex',
232
+ justifyContent: 'center'
233
+ }
234
+ }, /*#__PURE__*/_react.default.createElement(_reactPdf.Page, {
235
+ pageNumber: index + 1,
236
+ scale: 1.0
237
+ }))))), fileType === 'image' && /*#__PURE__*/_react.default.createElement("div", {
238
+ style: {
239
+ transform: "scale(".concat(scale, ") rotate(").concat(rotation, "deg)"),
240
+ transformOrigin: 'center center'
241
+ }
242
+ }, /*#__PURE__*/_react.default.createElement("img", {
243
+ src: fileUrl,
244
+ alt: "document",
245
+ style: {
246
+ transition: 'transform 0.3s ease-in-out',
247
+ maxWidth: '100%',
248
+ maxHeight: '80vh'
249
+ }
250
+ })))));
251
+ }
252
+ CustomDocumentViewer.propTypes = {
253
+ fileType: _propTypes.default.string.isRequired,
254
+ // "pdf" or "image"
255
+ fileUrl: _propTypes.default.string.isRequired,
256
+ onDownload: _propTypes.default.func,
257
+ // Optional custom download function
258
+ hideZoom: _propTypes.default.bool,
259
+ // If true, hide zoom controls (for PDFs)
260
+ hideDownload: _propTypes.default.bool,
261
+ // If true, hide download button
262
+ hidePageNumber: _propTypes.default.bool,
263
+ // If true, hide page number display (for PDFs)
264
+ hideRotate: _propTypes.default.bool,
265
+ // If true, hide rotate control (for images)
266
+ documentViewerOverlayHeight: _propTypes.default.string
267
+ };
268
+ CustomDocumentViewer.defaultProps = {
269
+ onDownload: null,
270
+ hideZoom: false,
271
+ hideDownload: false,
272
+ hidePageNumber: false,
273
+ hideRotate: false,
274
+ documentViewerOverlayHeight: '100vh'
275
+ };
276
+ var _default = exports.default = CustomDocumentViewer;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _templateObject;
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
11
+ const DocumentViewerContainer = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .customDocumentViewerOverlay {\n background-color: var(--color-primary-content);\n height: ", ";\n display: flex;\n justify-content: flex-start;\n width: 100%;\n padding: 0;\n margin: 0;\n flex-direction: column;\n overflow: auto;\n align-items: center;\n }\n\n .customDocumentViewerOverlayHeader {\n position: absolute;\n padding: 0 16px;\n bottom: 12px;\n left: auto;\n right: auto;\n border-radius: 4px;\n z-index: 99;\n background: rgba(0, 0, 0, 0.7);\n box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.34);\n display: flex;\n align-items: center;\n justify-content: center;\n height: 40px;\n }\n .customDocumentViewerOverlayHeaderIcons {\n display: flex;\n padding: 8px 0;\n flex-direction: row;\n gap: 16px;\n }\n\n .downloadIcon {\n border-left: solid 1px #fff;\n padding-left: 16px;\n margin-left: 16px;\n height: 100%;\n align-items: center;\n display: flex;\n }\n .pageNumber {\n border-right: solid 1px #fff;\n padding-right: 16px;\n margin-right: 16px;\n height: 100%;\n align-items: center;\n display: flex;\n }\n .ant-radio-group {\n display: flex;\n white-space: nowrap;\n }\n"])), props => props.documentViewerOverlayHeight);
12
+ var _default = exports.default = DocumentViewerContainer;
@@ -196,6 +196,9 @@ function DocumentUpload(_ref) {
196
196
  rules: [{
197
197
  validator: (rule, value) => {
198
198
  if (isMandatory && !(value !== null && value !== void 0 && value.length)) {
199
+ if (typeof value === 'object' && Object.keys(value).length > 0) {
200
+ return Promise.resolve();
201
+ }
199
202
  return Promise.reject(new Error('Please upload the document.'));
200
203
  }
201
204
  return Promise.resolve();