@widergy/energy-ui 3.66.2 → 3.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +0 -2
- package/dist/components/UTAttachmentList/index.js +1 -0
- package/dist/components/UTButton/theme.js +2 -2
- package/dist/components/UTDocumentWizard/README.md +109 -0
- package/dist/components/UTDocumentWizard/components/ChevronsManager/index.js +42 -0
- package/dist/components/UTDocumentWizard/components/ChevronsManager/styles.module.scss +10 -0
- package/dist/components/UTDocumentWizard/components/PageWizard/index.js +71 -0
- package/dist/components/UTDocumentWizard/components/PageWizard/styles.module.scss +11 -0
- package/dist/components/UTDocumentWizard/components/PageWizard/utils.js +269 -0
- package/dist/components/UTDocumentWizard/components/SectionDetails/index.js +53 -0
- package/dist/components/UTDocumentWizard/components/SectionDetails/styles.module.scss +49 -0
- package/dist/components/UTDocumentWizard/components/Sheet/index.js +38 -0
- package/dist/components/UTDocumentWizard/components/Sheet/styles.module.scss +27 -0
- package/dist/components/UTDocumentWizard/constants.js +21 -0
- package/dist/components/UTDocumentWizard/index.js +173 -0
- package/dist/components/UTDocumentWizard/styles.module.scss +115 -0
- package/dist/components/UTDocumentWizard/utils.js +14 -0
- package/dist/components/UTLabel/theme.js +2 -1
- package/dist/components/UTSheet/index.js +33 -0
- package/dist/components/UTTabs/index.js +5 -1
- package/dist/index.js +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [3.67.0](https://github.com/widergy/energy-ui/compare/v3.66.3...v3.67.0) (2025-03-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* updates readme ([3d5e1de](https://github.com/widergy/energy-ui/commit/3d5e1debf9da328f12ddbf2de64efec019667cfc))
|
|
7
|
+
|
|
8
|
+
## [3.66.3](https://github.com/widergy/energy-ui/compare/v3.66.2...v3.66.3) (2025-03-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* fix message error ([35bfdaa](https://github.com/widergy/energy-ui/commit/35bfdaa436a7fd087beb3fec4d0ba8f6c022ada4))
|
|
14
|
+
|
|
1
15
|
## [3.66.2](https://github.com/widergy/energy-ui/compare/v3.66.1...v3.66.2) (2025-03-19)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -140,6 +140,7 @@ const AttachmentContainer = _ref => {
|
|
|
140
140
|
validation = await (0, _utils.pdfAspectRatioValidation)(file, allowedPDFUploadSizes);
|
|
141
141
|
if (!validation) {
|
|
142
142
|
onFailValidation(fileErrorTexts.aspectRatioError);
|
|
143
|
+
return;
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
if (!validation && !disableResize && (0, _utils.isImage)(file) && !(0, _browser.isIE)()) {
|
|
@@ -8,9 +8,9 @@ var _classesUtils = require("../../utils/classesUtils");
|
|
|
8
8
|
var _shadowUtils = require("../../utils/shadowUtils");
|
|
9
9
|
var _constants = require("./constants");
|
|
10
10
|
const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
11
|
-
var _theme$Palette$shadow;
|
|
11
|
+
var _theme$Palette, _theme$Palette$shadow;
|
|
12
12
|
const actionColorName = _constants.COLORS_MAPPER[colorTheme] || _constants.COLORS_MAPPER[_constants.DEFAULT_PROPS.colorTheme];
|
|
13
|
-
const actionPaletteColors = theme.Palette.actions || theme.Palette;
|
|
13
|
+
const actionPaletteColors = ((_theme$Palette = theme.Palette) === null || _theme$Palette === void 0 ? void 0 : _theme$Palette.actions) || theme.Palette;
|
|
14
14
|
const actionTheme = actionPaletteColors[actionColorName];
|
|
15
15
|
const shadowTheme = ((_theme$Palette$shadow = theme.Palette.shadows) === null || _theme$Palette$shadow === void 0 ? void 0 : _theme$Palette$shadow[_constants.SHADOW_MAPPER[actionColorName]]) || 'transparent';
|
|
16
16
|
const negativeTheme = actionPaletteColors[_constants.COLORS_MAPPER.negative];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# UTDocumentWizard
|
|
2
|
+
|
|
3
|
+
A component that provides an interactive document viewer with navigable sections. It allows users to explore different sections of a document (like a bill or form) through an intuitive interface with clickable areas and detailed information panels.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
| Name | Type | Default | Description |
|
|
8
|
+
| --- | --- | --- | --- |
|
|
9
|
+
| pages | array | [] | Array of page objects that define the document pages to be displayed. |
|
|
10
|
+
| sections | array | [] | Array of section objects that define the interactive areas within each page. |
|
|
11
|
+
| labels | object | {} | Object containing text labels for UI elements. |
|
|
12
|
+
|
|
13
|
+
### pages
|
|
14
|
+
|
|
15
|
+
Each page object in the `pages` array should have the following structure:
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
{
|
|
19
|
+
id: number, // Unique identifier for the page
|
|
20
|
+
image: string, // URL of the page image
|
|
21
|
+
name: string // Display name of the page
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### sections
|
|
26
|
+
|
|
27
|
+
Each section object in the `sections` array should have the following structure:
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
{
|
|
31
|
+
id: number, // Unique identifier for the section
|
|
32
|
+
page_id: number, // ID of the page this section belongs to
|
|
33
|
+
label: string, // Short label for the section (e.g., "1", "2")
|
|
34
|
+
title: string, // Title of the section
|
|
35
|
+
description: string, // Detailed description of the section
|
|
36
|
+
section_coordinates: array, // Coordinates [x1, y1, x2, y2] defining the clickable area
|
|
37
|
+
section_number: number, // Order number of the section
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### translations
|
|
42
|
+
|
|
43
|
+
The translations object should have the following structure:
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
{
|
|
47
|
+
chevronsManagerTitle: string, // Title for the chevrons manager
|
|
48
|
+
sectionDetails: {
|
|
49
|
+
titleDefault: string, // Default title for section details
|
|
50
|
+
descriptionDefault: string // Default description for section details
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Example Usage
|
|
56
|
+
|
|
57
|
+
```jsx
|
|
58
|
+
import { UTDocumentWizard } from 'energy-ui';
|
|
59
|
+
|
|
60
|
+
const pages = [
|
|
61
|
+
{
|
|
62
|
+
id: 1,
|
|
63
|
+
image: 'https://example.com/front.png',
|
|
64
|
+
name: 'Front'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 2,
|
|
68
|
+
image: 'https://example.com/back.png',
|
|
69
|
+
name: 'Back'
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const sections = [
|
|
74
|
+
{
|
|
75
|
+
id: 1001,
|
|
76
|
+
page_id: 1,
|
|
77
|
+
label: '1',
|
|
78
|
+
title: 'Section 1',
|
|
79
|
+
description: 'Description of section 1',
|
|
80
|
+
section_coordinates: [40, 45, 990, 152],
|
|
81
|
+
section_number: 1
|
|
82
|
+
}
|
|
83
|
+
// ... more sections
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
const translations = {
|
|
87
|
+
chevronsManagerTitle: 'Explore your document!',
|
|
88
|
+
sectionDetails: {
|
|
89
|
+
titleDefault: 'Explore your document!',
|
|
90
|
+
descriptionDefault: 'Click on different sections to see detailed information'
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const MyComponent = () => (
|
|
95
|
+
<UTDocumentWizard
|
|
96
|
+
pages={pages}
|
|
97
|
+
sections={sections}
|
|
98
|
+
labels={labels}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Features
|
|
104
|
+
|
|
105
|
+
- Interactive document navigation
|
|
106
|
+
- Mobile-responsive design
|
|
107
|
+
- Clickable sections with detailed information panels
|
|
108
|
+
- Support for multiple pages
|
|
109
|
+
- Customizable text labels
|
|
@@ -0,0 +1,42 @@
|
|
|
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 _propTypes = require("prop-types");
|
|
9
|
+
var _UTButton = _interopRequireDefault(require("../../../UTButton"));
|
|
10
|
+
var _constants = require("../../constants");
|
|
11
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const ChevronsManager = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
prevDisabled,
|
|
16
|
+
nextDisabled,
|
|
17
|
+
onClick
|
|
18
|
+
} = _ref;
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
20
|
+
className: _stylesModule.default.container
|
|
21
|
+
}, /*#__PURE__*/_react.default.createElement(_UTButton.default, {
|
|
22
|
+
variant: "semitransparent",
|
|
23
|
+
colorTheme: "accent",
|
|
24
|
+
disabled: prevDisabled,
|
|
25
|
+
Icon: "IconArrowNarrowLeft",
|
|
26
|
+
onClick: () => onClick(_constants.PREV)
|
|
27
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
28
|
+
className: _stylesModule.default.marginRight
|
|
29
|
+
}), /*#__PURE__*/_react.default.createElement(_UTButton.default, {
|
|
30
|
+
variant: "semitransparent",
|
|
31
|
+
colorTheme: "accent",
|
|
32
|
+
disabled: nextDisabled,
|
|
33
|
+
Icon: "IconArrowNarrowRight",
|
|
34
|
+
onClick: () => onClick(_constants.NEXT)
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
ChevronsManager.propTypes = {
|
|
38
|
+
prevDisabled: _propTypes.bool,
|
|
39
|
+
nextDisabled: _propTypes.bool,
|
|
40
|
+
onClick: _propTypes.func
|
|
41
|
+
};
|
|
42
|
+
var _default = exports.default = ChevronsManager;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = require("prop-types");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (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 && {}.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
|
+
const PageWizard = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
canvasRef,
|
|
17
|
+
clickedSection,
|
|
18
|
+
isChangingTab,
|
|
19
|
+
isMobileSize,
|
|
20
|
+
isSheetOpen,
|
|
21
|
+
onSectionChange,
|
|
22
|
+
page,
|
|
23
|
+
sectionSelected,
|
|
24
|
+
sections
|
|
25
|
+
} = _ref;
|
|
26
|
+
const sectionsBadgeCoord = {};
|
|
27
|
+
const sectionsCoord = {};
|
|
28
|
+
const animations = (0, _react.useRef)({});
|
|
29
|
+
const isPointer = false;
|
|
30
|
+
const onClick = e => (0, _utils.handleCanvasClick)(e, canvasRef, onSectionChange, sectionsBadgeCoord, sectionsCoord);
|
|
31
|
+
const onMouseMove = e => (0, _utils.handleMouseMove)(e, canvasRef, sectionsBadgeCoord, sectionsCoord, isPointer);
|
|
32
|
+
(0, _react.useEffect)(() => {
|
|
33
|
+
const canvas = canvasRef.current;
|
|
34
|
+
if (!canvas) return;
|
|
35
|
+
const ctx = canvas.getContext('2d');
|
|
36
|
+
const image = new Image();
|
|
37
|
+
image.src = page.image;
|
|
38
|
+
image.onload = () => {
|
|
39
|
+
const scale = window.devicePixelRatio || 1;
|
|
40
|
+
canvas.width = image.width * scale;
|
|
41
|
+
canvas.height = image.height * scale;
|
|
42
|
+
canvas.style.width = "".concat(image.width, "px");
|
|
43
|
+
canvas.style.height = "".concat(image.height, "px");
|
|
44
|
+
ctx.scale(scale, scale);
|
|
45
|
+
ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
46
|
+
sections.map(section => (0, _utils.drawSection)(ctx, image, section, page, clickedSection, sectionsCoord, sectionsBadgeCoord, sectionSelected, animations, isSheetOpen, isMobileSize));
|
|
47
|
+
};
|
|
48
|
+
}, [page.image, sections, clickedSection, animations.current, isPointer, isSheetOpen]);
|
|
49
|
+
(0, _react.useEffect)(() => {
|
|
50
|
+
onSectionChange(null);
|
|
51
|
+
}, [page.image]);
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement("canvas", {
|
|
53
|
+
ref: canvasRef,
|
|
54
|
+
tabIndex: "0",
|
|
55
|
+
className: "".concat(_stylesModule.default.container, " ").concat(isChangingTab ? _stylesModule.default.displayNone : _stylesModule.default.displayFlex),
|
|
56
|
+
onClick: onClick,
|
|
57
|
+
onMouseMove: onMouseMove
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
PageWizard.propTypes = {
|
|
61
|
+
canvasRef: _propTypes.object,
|
|
62
|
+
clickedSection: _propTypes.string,
|
|
63
|
+
isChangingTab: _propTypes.bool,
|
|
64
|
+
isMobileSize: _propTypes.bool,
|
|
65
|
+
isSheetOpen: _propTypes.bool,
|
|
66
|
+
page: _propTypes.object,
|
|
67
|
+
sectionSelected: _propTypes.object,
|
|
68
|
+
sections: (0, _propTypes.arrayOf)({}),
|
|
69
|
+
onSectionChange: _propTypes.func
|
|
70
|
+
};
|
|
71
|
+
var _default = exports.default = PageWizard;
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.handleMouseMove = exports.handleCanvasClick = exports.drawSection = void 0;
|
|
7
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const drawRoundedStrokeRect = (ctx, x, y, width, height, radius) => {
|
|
10
|
+
ctx.fillStyle = 'rgba(37, 224, 166, 0.1)';
|
|
11
|
+
ctx.beginPath();
|
|
12
|
+
ctx.moveTo(x + radius, y);
|
|
13
|
+
ctx.lineTo(x + width - radius, y);
|
|
14
|
+
ctx.arcTo(x + width, y, x + width, y + height, radius);
|
|
15
|
+
ctx.lineTo(x + width, y + height - radius);
|
|
16
|
+
ctx.arcTo(x + width, y + height, x + width - radius, y + height, radius);
|
|
17
|
+
ctx.lineTo(x + radius, y + height);
|
|
18
|
+
ctx.arcTo(x, y + height, x, y + height - radius, radius);
|
|
19
|
+
ctx.lineTo(x, y + radius);
|
|
20
|
+
ctx.arcTo(x, y, x + radius, y, radius);
|
|
21
|
+
ctx.closePath();
|
|
22
|
+
ctx.fill();
|
|
23
|
+
ctx.strokeStyle = 'rgba(37, 224, 166, 1)';
|
|
24
|
+
ctx.lineWidth = 1;
|
|
25
|
+
ctx.stroke();
|
|
26
|
+
};
|
|
27
|
+
const resizeText = (ctx, text, maxWidth) => {
|
|
28
|
+
let fontSize = 24;
|
|
29
|
+
ctx.font = "600 ".concat(fontSize, "px Inter");
|
|
30
|
+
while (ctx.measureText(text).width > maxWidth && fontSize > 10) {
|
|
31
|
+
fontSize -= 1;
|
|
32
|
+
ctx.font = "600 ".concat(fontSize, "px Inter");
|
|
33
|
+
}
|
|
34
|
+
return fontSize;
|
|
35
|
+
};
|
|
36
|
+
const drawBadge = (ctx, x, y, radius, sectionLabel) => {
|
|
37
|
+
ctx.beginPath();
|
|
38
|
+
ctx.arc(x, y, radius, 0, Math.PI * 2);
|
|
39
|
+
ctx.fillStyle = 'rgba(255, 255, 255, 1)';
|
|
40
|
+
ctx.fill();
|
|
41
|
+
ctx.lineWidth = 1;
|
|
42
|
+
ctx.strokeStyle = 'rgba(37, 224, 166, 1)';
|
|
43
|
+
ctx.stroke();
|
|
44
|
+
ctx.beginPath();
|
|
45
|
+
ctx.arc(x, y, 24, 0, Math.PI * 2);
|
|
46
|
+
ctx.fillStyle = 'rgba(37, 224, 166, 1)';
|
|
47
|
+
ctx.fill();
|
|
48
|
+
ctx.stroke();
|
|
49
|
+
ctx.fillStyle = 'rgba(9, 30, 66, 1)';
|
|
50
|
+
const fontSize = resizeText(ctx, "".concat(sectionLabel), 48);
|
|
51
|
+
ctx.textAlign = 'center';
|
|
52
|
+
ctx.textBaseline = 'middle';
|
|
53
|
+
ctx.fillText("".concat(sectionLabel), x, y + fontSize / 10);
|
|
54
|
+
};
|
|
55
|
+
const drawRoundedRect = (ctx, x, y, width, height, radius) => {
|
|
56
|
+
const PADDING_TITLE = 12;
|
|
57
|
+
ctx.beginPath();
|
|
58
|
+
ctx.arc(x - radius + PADDING_TITLE, y + radius, radius, Math.PI, 3 * Math.PI / 2);
|
|
59
|
+
ctx.arc(x + width - radius + PADDING_TITLE, y + radius, radius, -Math.PI / 2, 0);
|
|
60
|
+
ctx.arc(x + width - radius + PADDING_TITLE, y + height - radius, radius, 0, Math.PI / 2);
|
|
61
|
+
ctx.arc(x - radius + PADDING_TITLE, y + height - radius, radius, Math.PI / 2, Math.PI);
|
|
62
|
+
ctx.closePath();
|
|
63
|
+
ctx.fillStyle = 'rgb(255, 255, 255)';
|
|
64
|
+
ctx.fill();
|
|
65
|
+
ctx.lineWidth = 1;
|
|
66
|
+
ctx.strokeStyle = 'rgba(37, 224, 166, 1)';
|
|
67
|
+
ctx.beginPath();
|
|
68
|
+
ctx.moveTo(x - radius, y);
|
|
69
|
+
ctx.lineTo(x + PADDING_TITLE + width, y);
|
|
70
|
+
ctx.moveTo(x - radius, y + height);
|
|
71
|
+
ctx.lineTo(x + width - radius + PADDING_TITLE * 2, y + height);
|
|
72
|
+
ctx.stroke();
|
|
73
|
+
};
|
|
74
|
+
const drawBadgeSelected = (ctx, x, y, radius, sectionLabel, sectionTitle) => {
|
|
75
|
+
const fontSize = resizeText(ctx, "".concat(sectionLabel), 48);
|
|
76
|
+
const renderTitle = "".concat(sectionTitle);
|
|
77
|
+
const textMetrics = ctx.measureText(renderTitle);
|
|
78
|
+
const textWidth = textMetrics.width;
|
|
79
|
+
const INTERNAL_CIRCLE_SIZE = 24;
|
|
80
|
+
const PADDING_TITLE = 12;
|
|
81
|
+
const newX = x - (PADDING_TITLE + textWidth / 2);
|
|
82
|
+
ctx.beginPath();
|
|
83
|
+
ctx.arc(newX + PADDING_TITLE, y, radius, 0, Math.PI * 2);
|
|
84
|
+
ctx.fillStyle = 'rgba(255, 255, 255, 1)';
|
|
85
|
+
ctx.fill();
|
|
86
|
+
ctx.lineWidth = 1;
|
|
87
|
+
ctx.strokeStyle = 'rgba(37, 224, 166, 1)';
|
|
88
|
+
ctx.stroke();
|
|
89
|
+
ctx.beginPath();
|
|
90
|
+
ctx.arc(newX + textWidth + PADDING_TITLE * 2, y, radius, 0, Math.PI * 2);
|
|
91
|
+
ctx.fillStyle = 'rgba(255, 255, 255, 1)';
|
|
92
|
+
ctx.fill();
|
|
93
|
+
ctx.lineWidth = 1;
|
|
94
|
+
ctx.strokeStyle = 'rgba(37, 224, 166, 1)';
|
|
95
|
+
ctx.stroke();
|
|
96
|
+
drawRoundedRect(ctx, newX + PADDING_TITLE, y - 40, textWidth, radius * 2, Math.PI * 2);
|
|
97
|
+
ctx.textAlign = 'right';
|
|
98
|
+
ctx.textBaseline = 'middle';
|
|
99
|
+
ctx.fillStyle = 'rgba(9, 30, 66, 1)';
|
|
100
|
+
ctx.fillText(renderTitle, newX + textWidth + INTERNAL_CIRCLE_SIZE + PADDING_TITLE * 2, y + fontSize / 10);
|
|
101
|
+
ctx.beginPath();
|
|
102
|
+
ctx.arc(newX + PADDING_TITLE, y, INTERNAL_CIRCLE_SIZE, 0, Math.PI * 2);
|
|
103
|
+
ctx.fillStyle = 'rgba(37, 224, 166, 1)';
|
|
104
|
+
ctx.fill();
|
|
105
|
+
ctx.stroke();
|
|
106
|
+
ctx.fillStyle = 'rgba(9, 30, 66, 1)';
|
|
107
|
+
ctx.textAlign = 'center';
|
|
108
|
+
ctx.textBaseline = 'middle';
|
|
109
|
+
ctx.fillText("".concat(sectionLabel), newX + PADDING_TITLE, y + fontSize / 10);
|
|
110
|
+
};
|
|
111
|
+
const animateTransition = (ctx, image, sectionSelected, start, end, duration, onUpdate, isClickedSection, onComplete, animations, sectionId, isSheetOpen, isMobileSize) => {
|
|
112
|
+
var _animations$current;
|
|
113
|
+
if (!(0, _isEmpty.default)((_animations$current = animations.current) === null || _animations$current === void 0 ? void 0 : _animations$current[sectionId])) {
|
|
114
|
+
animations.current[sectionId].map(animationId => cancelAnimationFrame(animationId));
|
|
115
|
+
delete animations.current[sectionId];
|
|
116
|
+
}
|
|
117
|
+
let startTime;
|
|
118
|
+
const animate = timestamp => {
|
|
119
|
+
if (!startTime) startTime = timestamp;
|
|
120
|
+
const progress = Math.min((timestamp - startTime) / duration, 1);
|
|
121
|
+
const lerp = (a, b, t) => a + (b - a) * t;
|
|
122
|
+
const newPositions = {
|
|
123
|
+
x: lerp(start.x, end.x, progress),
|
|
124
|
+
y: lerp(start.y, end.y, progress),
|
|
125
|
+
radius: start.radius
|
|
126
|
+
};
|
|
127
|
+
ctx.save();
|
|
128
|
+
ctx.beginPath();
|
|
129
|
+
ctx.moveTo(newPositions.x - newPositions.radius, newPositions.y);
|
|
130
|
+
ctx.arcTo(newPositions.x + newPositions.radius, newPositions.y, newPositions.x + newPositions.radius, newPositions.y, newPositions.radius);
|
|
131
|
+
ctx.lineTo(newPositions.x + newPositions.radius + 10, newPositions.y + newPositions.radius * 2);
|
|
132
|
+
ctx.lineTo(newPositions.x - newPositions.radius - 10, newPositions.y + newPositions.radius * 2);
|
|
133
|
+
ctx.closePath();
|
|
134
|
+
ctx.clip();
|
|
135
|
+
ctx.drawImage(image, newPositions.x - newPositions.radius, newPositions.y - newPositions.radius, newPositions.radius * 2, newPositions.radius * 2 + 15, newPositions.x - newPositions.radius - 1, newPositions.y - newPositions.radius, newPositions.radius * 2 + 2, newPositions.radius * 2 + 15);
|
|
136
|
+
ctx.restore();
|
|
137
|
+
onUpdate(newPositions);
|
|
138
|
+
if (progress < 1 && !isMobileSize || progress < 1 && isSheetOpen && isMobileSize) {
|
|
139
|
+
animations.current[sectionId].push(requestAnimationFrame(animate));
|
|
140
|
+
} else {
|
|
141
|
+
if (isClickedSection) {
|
|
142
|
+
const x1Section = sectionSelected.section_coordinates[0];
|
|
143
|
+
const y1Section = sectionSelected.section_coordinates[1];
|
|
144
|
+
const x2Section = sectionSelected.section_coordinates[2];
|
|
145
|
+
const y2Section = sectionSelected.section_coordinates[3];
|
|
146
|
+
drawRoundedStrokeRect(ctx, x1Section, y1Section, x2Section - x1Section, y2Section - y1Section, 8);
|
|
147
|
+
}
|
|
148
|
+
if (onComplete) onComplete();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
animations.current[sectionId] = [];
|
|
152
|
+
requestAnimationFrame(animate);
|
|
153
|
+
};
|
|
154
|
+
const drawSection = (ctx, image, section, actualPage, clickedSection, sectionsCoord, sectionsBadgeCoord, sectionSelected, animations, isSheetOpen, isMobileSize) => {
|
|
155
|
+
if (actualPage.id === section.page_id) {
|
|
156
|
+
const [x1, y1, x2, y2] = section.section_coordinates;
|
|
157
|
+
const width = x2 - x1;
|
|
158
|
+
const height = y2 - y1;
|
|
159
|
+
const isClickedSection = clickedSection === "".concat(section.id);
|
|
160
|
+
sectionsCoord[section.id] = {
|
|
161
|
+
x1,
|
|
162
|
+
y1,
|
|
163
|
+
width,
|
|
164
|
+
height,
|
|
165
|
+
radius: 8
|
|
166
|
+
};
|
|
167
|
+
const EXTERNAL_RADIUS = 40;
|
|
168
|
+
const xCircle = (x2 + x1) / 2;
|
|
169
|
+
const yCircle = isClickedSection ? y1 : (y2 + y1) / 2;
|
|
170
|
+
sectionsBadgeCoord[section.id] = {
|
|
171
|
+
x: xCircle,
|
|
172
|
+
y: yCircle,
|
|
173
|
+
radius: EXTERNAL_RADIUS
|
|
174
|
+
};
|
|
175
|
+
const initialPositions = {
|
|
176
|
+
x: xCircle,
|
|
177
|
+
y: (y2 + y1) / 2,
|
|
178
|
+
radius: EXTERNAL_RADIUS
|
|
179
|
+
};
|
|
180
|
+
const finalPositions = isClickedSection ? {
|
|
181
|
+
x: xCircle,
|
|
182
|
+
y: y1,
|
|
183
|
+
radius: EXTERNAL_RADIUS
|
|
184
|
+
} : initialPositions;
|
|
185
|
+
const timeAnimation = height < 300 ? 300 : 600;
|
|
186
|
+
animateTransition(ctx, image, sectionSelected, initialPositions, finalPositions, timeAnimation, newPositions => {
|
|
187
|
+
if (!isMobileSize || isMobileSize && isSheetOpen) drawBadge(ctx, newPositions.x, newPositions.y, newPositions.radius, section.label);
|
|
188
|
+
}, isClickedSection, () => {
|
|
189
|
+
if (isClickedSection) {
|
|
190
|
+
drawBadgeSelected(ctx, finalPositions.x, finalPositions.y, finalPositions.radius, section.label, section.title);
|
|
191
|
+
} else {
|
|
192
|
+
drawBadge(ctx, finalPositions.x, finalPositions.y, finalPositions.radius, section.label);
|
|
193
|
+
}
|
|
194
|
+
}, animations, section.id, isSheetOpen, isMobileSize);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
exports.drawSection = drawSection;
|
|
198
|
+
const handleCanvasClick = (e, canvasRef, onSectionChange, sectionsBadgeCoord, sectionsCoord) => {
|
|
199
|
+
const canvas = canvasRef.current;
|
|
200
|
+
const rect = canvas.getBoundingClientRect();
|
|
201
|
+
const xClick = e.clientX - rect.left;
|
|
202
|
+
const yClick = e.clientY - rect.top;
|
|
203
|
+
const onClick = key => {
|
|
204
|
+
onSectionChange(key);
|
|
205
|
+
};
|
|
206
|
+
Object.keys(sectionsBadgeCoord).forEach(key => {
|
|
207
|
+
const {
|
|
208
|
+
x,
|
|
209
|
+
y,
|
|
210
|
+
radius
|
|
211
|
+
} = sectionsBadgeCoord[key];
|
|
212
|
+
const distance = Math.sqrt((xClick - x) ** 2 + (yClick - y) ** 2);
|
|
213
|
+
if (distance <= radius) {
|
|
214
|
+
onClick(key);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
Object.entries(sectionsCoord).forEach(_ref => {
|
|
218
|
+
let [key, {
|
|
219
|
+
x1,
|
|
220
|
+
y1,
|
|
221
|
+
width,
|
|
222
|
+
height,
|
|
223
|
+
radius
|
|
224
|
+
}] = _ref;
|
|
225
|
+
const isInsideRect = xClick >= x1 && xClick <= x1 + width && yClick >= y1 && yClick <= y1 + height;
|
|
226
|
+
const centerX = x1 + width / 2;
|
|
227
|
+
const centerY = y1 + height / 2;
|
|
228
|
+
const distance = Math.sqrt((xClick - centerX) ** 2 + (yClick - centerY) ** 2);
|
|
229
|
+
if (isInsideRect || distance <= radius) {
|
|
230
|
+
onClick(key);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
exports.handleCanvasClick = handleCanvasClick;
|
|
235
|
+
const handleMouseMove = (e, canvasRef, sectionsBadgeCoord, sectionsCoord, isPointer) => {
|
|
236
|
+
const canvas = canvasRef.current;
|
|
237
|
+
const rect = canvas.getBoundingClientRect();
|
|
238
|
+
const xMove = e.clientX - rect.left;
|
|
239
|
+
const yMove = e.clientY - rect.top;
|
|
240
|
+
Object.keys(sectionsBadgeCoord).forEach(key => {
|
|
241
|
+
const {
|
|
242
|
+
x,
|
|
243
|
+
y,
|
|
244
|
+
radius
|
|
245
|
+
} = sectionsBadgeCoord[key];
|
|
246
|
+
const distance = Math.sqrt((xMove - x) ** 2 + (yMove - y) ** 2);
|
|
247
|
+
if (distance <= radius) {
|
|
248
|
+
isPointer = true;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
Object.entries(sectionsCoord).forEach(_ref2 => {
|
|
252
|
+
let [, {
|
|
253
|
+
x1,
|
|
254
|
+
y1,
|
|
255
|
+
width,
|
|
256
|
+
height,
|
|
257
|
+
radius
|
|
258
|
+
}] = _ref2;
|
|
259
|
+
const isInsideRect = xMove >= x1 && xMove <= x1 + width && yMove >= y1 && yMove <= y1 + height;
|
|
260
|
+
const centerX = x1 + width / 2;
|
|
261
|
+
const centerY = y1 + height / 2;
|
|
262
|
+
const distance = Math.sqrt((xMove - centerX) ** 2 + (yMove - centerY) ** 2);
|
|
263
|
+
if (isInsideRect || distance <= radius) {
|
|
264
|
+
isPointer = true;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
canvas.style.cursor = isPointer ? 'pointer' : 'default';
|
|
268
|
+
};
|
|
269
|
+
exports.handleMouseMove = handleMouseMove;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 _propTypes = require("prop-types");
|
|
9
|
+
var _UTLabel = _interopRequireDefault(require("../../../UTLabel"));
|
|
10
|
+
var _UTIcon = _interopRequireDefault(require("../../../UTIcon"));
|
|
11
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const SectionDetails = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
sectionSelected,
|
|
16
|
+
titleDefault,
|
|
17
|
+
descriptionDefault
|
|
18
|
+
} = _ref;
|
|
19
|
+
if (!sectionSelected) return /*#__PURE__*/_react.default.createElement("div", {
|
|
20
|
+
className: _stylesModule.default.containerDefault
|
|
21
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
22
|
+
className: _stylesModule.default.iconContainer
|
|
23
|
+
}, /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
|
|
24
|
+
area: true,
|
|
25
|
+
colorTheme: "accent",
|
|
26
|
+
size: 32,
|
|
27
|
+
name: "IconClick"
|
|
28
|
+
})), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
29
|
+
className: _stylesModule.default.titleDefault,
|
|
30
|
+
variant: "title3"
|
|
31
|
+
}, titleDefault), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
32
|
+
variant: "body",
|
|
33
|
+
className: _stylesModule.default.details
|
|
34
|
+
}, descriptionDefault));
|
|
35
|
+
const {
|
|
36
|
+
title,
|
|
37
|
+
description
|
|
38
|
+
} = sectionSelected;
|
|
39
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
40
|
+
className: _stylesModule.default.container
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
42
|
+
className: _stylesModule.default.title,
|
|
43
|
+
variant: "title3"
|
|
44
|
+
}, title), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
45
|
+
variant: "body"
|
|
46
|
+
}, description));
|
|
47
|
+
};
|
|
48
|
+
SectionDetails.propTypes = {
|
|
49
|
+
descriptionDefault: _propTypes.string,
|
|
50
|
+
sectionSelected: _propTypes.object,
|
|
51
|
+
titleDefault: _propTypes.string
|
|
52
|
+
};
|
|
53
|
+
var _default = exports.default = SectionDetails;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
@use '../../../../scss/variables/mediaQueries.module.scss' as *;
|
|
2
|
+
|
|
3
|
+
.containerDefault {
|
|
4
|
+
align-items: center;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
min-height: 854px;
|
|
8
|
+
padding-left: 24px;
|
|
9
|
+
padding-top: 32px;
|
|
10
|
+
width: 40%;
|
|
11
|
+
@media #{$mobile} {
|
|
12
|
+
display: none;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.iconContainer {
|
|
17
|
+
align-items: center;
|
|
18
|
+
display: flex;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
padding: 12px 12px 36px 12px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.titleDefault {
|
|
24
|
+
padding-bottom: 8px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.details {
|
|
28
|
+
color: #677489;
|
|
29
|
+
font-weight: 400;
|
|
30
|
+
font-size: 16px;
|
|
31
|
+
line-height: 22px;
|
|
32
|
+
text-align: center;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.container {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
min-height: 854px;
|
|
39
|
+
padding-bottom: 24px;
|
|
40
|
+
padding-left: 24px;
|
|
41
|
+
width: 40%;
|
|
42
|
+
@media #{$mobile} {
|
|
43
|
+
display: none;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.title {
|
|
48
|
+
padding-bottom: 24px;
|
|
49
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = require("prop-types");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _UTLabel = _interopRequireDefault(require("../../../UTLabel"));
|
|
10
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const Sheet = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
sectionSelected
|
|
15
|
+
} = _ref;
|
|
16
|
+
const {
|
|
17
|
+
title,
|
|
18
|
+
description
|
|
19
|
+
} = sectionSelected;
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
21
|
+
className: _stylesModule.default.container
|
|
22
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
23
|
+
className: _stylesModule.default.swipeContainer
|
|
24
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
25
|
+
className: _stylesModule.default.swipe
|
|
26
|
+
})), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
27
|
+
className: _stylesModule.default.title,
|
|
28
|
+
variant: "title3"
|
|
29
|
+
}, title), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
30
|
+
colorTheme: "secondary",
|
|
31
|
+
className: _stylesModule.default.description,
|
|
32
|
+
variant: "body"
|
|
33
|
+
}, description));
|
|
34
|
+
};
|
|
35
|
+
Sheet.propTypes = {
|
|
36
|
+
sectionSelected: _propTypes.object
|
|
37
|
+
};
|
|
38
|
+
var _default = exports.default = Sheet;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
min-height: 300px;
|
|
3
|
+
padding: 16px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.title {
|
|
7
|
+
padding-bottom: 8px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.description {
|
|
11
|
+
color: #677489;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.swipeContainer {
|
|
15
|
+
align-items: center;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex: 1;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.swipe {
|
|
22
|
+
background-color: #F4F5F7;
|
|
23
|
+
border-radius: 100px;
|
|
24
|
+
height: 8px;
|
|
25
|
+
margin-bottom: 16px;
|
|
26
|
+
width: 65px;
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SLIDE_PROPS = exports.PREV = exports.NEXT = exports.LOADING_THICKNESS = exports.LOADING_SIZE = exports.LAST_OPTION_PROPS = void 0;
|
|
7
|
+
const SLIDE_PROPS = exports.SLIDE_PROPS = {
|
|
8
|
+
style: {
|
|
9
|
+
borderTopLeftRadius: '16px',
|
|
10
|
+
borderTopRightRadius: '16px'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const LAST_OPTION_PROPS = exports.LAST_OPTION_PROPS = {
|
|
14
|
+
style: {
|
|
15
|
+
marginRight: '4px'
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const LOADING_SIZE = exports.LOADING_SIZE = 80;
|
|
19
|
+
const LOADING_THICKNESS = exports.LOADING_THICKNESS = 5;
|
|
20
|
+
const NEXT = exports.NEXT = 'next';
|
|
21
|
+
const PREV = exports.PREV = 'prev';
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = require("prop-types");
|
|
9
|
+
var _reactPerfectScrollbar = _interopRequireDefault(require("react-perfect-scrollbar"));
|
|
10
|
+
var _UTTabs = _interopRequireDefault(require("../UTTabs"));
|
|
11
|
+
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
12
|
+
var _Loading = _interopRequireDefault(require("../Loading"));
|
|
13
|
+
var _UTSheet = _interopRequireDefault(require("../UTSheet"));
|
|
14
|
+
var _useScreenSize = require("../../utils/useScreenSize");
|
|
15
|
+
var _utils = require("./utils");
|
|
16
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
|
+
var _ChevronsManager = _interopRequireDefault(require("./components/ChevronsManager"));
|
|
18
|
+
var _PageWizard = _interopRequireDefault(require("./components/PageWizard"));
|
|
19
|
+
var _SectionDetails = _interopRequireDefault(require("./components/SectionDetails"));
|
|
20
|
+
var _Sheet = _interopRequireDefault(require("./components/Sheet"));
|
|
21
|
+
var _constants = require("./constants");
|
|
22
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
24
|
+
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 && {}.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; }
|
|
25
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
26
|
+
const UTDocumentWizard = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
sections,
|
|
29
|
+
pages,
|
|
30
|
+
labels
|
|
31
|
+
} = _ref;
|
|
32
|
+
const canvasRef = (0, _react.useRef)(null);
|
|
33
|
+
const tabsOptions = (0, _utils.getTabsOptions)(pages);
|
|
34
|
+
const [selectedTab, setSelectedTab] = (0, _react.useState)(tabsOptions[0].value);
|
|
35
|
+
const currentIndex = tabsOptions.findIndex(tab => tab.value === selectedTab);
|
|
36
|
+
const prevDisabled = currentIndex <= 0;
|
|
37
|
+
const nextDisabled = currentIndex >= tabsOptions.length - 1;
|
|
38
|
+
const changeTimeoutRef = (0, _react.useRef)(null);
|
|
39
|
+
const [isChangingTab, setIsChangingTab] = (0, _react.useState)(false);
|
|
40
|
+
const [clickedSection, setClickedSection] = (0, _react.useState)(null);
|
|
41
|
+
const sectionSelected = sections.find(section => "".concat(section.id) === clickedSection);
|
|
42
|
+
const onChangeTab = newTab => {
|
|
43
|
+
if (isChangingTab) return;
|
|
44
|
+
if (changeTimeoutRef.current) {
|
|
45
|
+
clearTimeout(changeTimeoutRef.current);
|
|
46
|
+
changeTimeoutRef.current = null;
|
|
47
|
+
}
|
|
48
|
+
setIsChangingTab(true);
|
|
49
|
+
changeTimeoutRef.current = setTimeout(() => {
|
|
50
|
+
const isSameTab = newTab === selectedTab;
|
|
51
|
+
if (isSameTab) {
|
|
52
|
+
setIsChangingTab(false);
|
|
53
|
+
changeTimeoutRef.current = null;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
setSelectedTab(newTab);
|
|
57
|
+
setIsChangingTab(false);
|
|
58
|
+
changeTimeoutRef.current = null;
|
|
59
|
+
}, 600);
|
|
60
|
+
};
|
|
61
|
+
const onTabChange = newTab => {
|
|
62
|
+
onChangeTab(newTab);
|
|
63
|
+
};
|
|
64
|
+
const onClick = direction => {
|
|
65
|
+
let newTab = null;
|
|
66
|
+
if (direction === _constants.PREV && !prevDisabled) {
|
|
67
|
+
newTab = tabsOptions[currentIndex - 1].value;
|
|
68
|
+
} else if (direction === _constants.NEXT && !nextDisabled) {
|
|
69
|
+
newTab = tabsOptions[currentIndex + 1].value;
|
|
70
|
+
}
|
|
71
|
+
if (newTab === selectedTab) return;
|
|
72
|
+
onChangeTab(newTab);
|
|
73
|
+
};
|
|
74
|
+
const containerRef = (0, _react.useRef)(null);
|
|
75
|
+
const actualPage = pages === null || pages === void 0 ? void 0 : pages.find(page => "".concat(page.id) === "".concat(selectedTab));
|
|
76
|
+
(0, _react.useEffect)(() => {
|
|
77
|
+
return () => {
|
|
78
|
+
if (changeTimeoutRef.current) {
|
|
79
|
+
clearTimeout(changeTimeoutRef.current);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
const [sheetOpen, setSheetOpen] = (0, _react.useState)(false);
|
|
84
|
+
const {
|
|
85
|
+
isMobileSize
|
|
86
|
+
} = (0, _useScreenSize.useScreenSize)();
|
|
87
|
+
const onSectionChange = newSectionSelected => {
|
|
88
|
+
setClickedSection(newSectionSelected);
|
|
89
|
+
if (isMobileSize) setSheetOpen(!!newSectionSelected);
|
|
90
|
+
};
|
|
91
|
+
const toggleDrawer = option => {
|
|
92
|
+
if (isMobileSize) {
|
|
93
|
+
if (!option) {
|
|
94
|
+
var _canvasRef$current;
|
|
95
|
+
const ctx = (_canvasRef$current = canvasRef.current) === null || _canvasRef$current === void 0 ? void 0 : _canvasRef$current.getContext('2d');
|
|
96
|
+
if (ctx) {
|
|
97
|
+
var _canvasRef$current2;
|
|
98
|
+
ctx.restore();
|
|
99
|
+
(_canvasRef$current2 = canvasRef.current) === null || _canvasRef$current2 === void 0 || _canvasRef$current2.focus();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
setSheetOpen(option);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const SheetChildren = /*#__PURE__*/_react.default.createElement(_Sheet.default, {
|
|
106
|
+
sectionSelected: sectionSelected
|
|
107
|
+
});
|
|
108
|
+
const {
|
|
109
|
+
chevronsManagerTitle,
|
|
110
|
+
sectionDetails
|
|
111
|
+
} = labels;
|
|
112
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
113
|
+
className: _stylesModule.default.container
|
|
114
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
115
|
+
className: _stylesModule.default.pageWizardContainer,
|
|
116
|
+
ref: containerRef
|
|
117
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
118
|
+
className: _stylesModule.default.pageManagerSection
|
|
119
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
120
|
+
className: _stylesModule.default.slidePageManagerContainer
|
|
121
|
+
}, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
122
|
+
variant: "title2"
|
|
123
|
+
}, chevronsManagerTitle), /*#__PURE__*/_react.default.createElement(_ChevronsManager.default, {
|
|
124
|
+
prevDisabled: prevDisabled,
|
|
125
|
+
nextDisabled: nextDisabled,
|
|
126
|
+
onClick: onClick
|
|
127
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
128
|
+
className: _stylesModule.default.pageManagerContainer
|
|
129
|
+
}, /*#__PURE__*/_react.default.createElement(_UTTabs.default, {
|
|
130
|
+
options: tabsOptions,
|
|
131
|
+
value: selectedTab,
|
|
132
|
+
onChange: onTabChange,
|
|
133
|
+
classes: {
|
|
134
|
+
tabsRoot: _stylesModule.default.tabs,
|
|
135
|
+
tabRoot: _stylesModule.default.tabRoot,
|
|
136
|
+
label: _stylesModule.default.tab,
|
|
137
|
+
selected: _stylesModule.default.selected,
|
|
138
|
+
indicator: _stylesModule.default.indicator
|
|
139
|
+
},
|
|
140
|
+
lastOptionProps: _constants.LAST_OPTION_PROPS
|
|
141
|
+
}))), /*#__PURE__*/_react.default.createElement(_reactPerfectScrollbar.default, {
|
|
142
|
+
className: _stylesModule.default.scrollContainer
|
|
143
|
+
}, isChangingTab && /*#__PURE__*/_react.default.createElement("div", {
|
|
144
|
+
className: _stylesModule.default.loadingContainer
|
|
145
|
+
}, /*#__PURE__*/_react.default.createElement(_Loading.default, {
|
|
146
|
+
size: _constants.LOADING_SIZE,
|
|
147
|
+
thickness: _constants.LOADING_THICKNESS
|
|
148
|
+
})), !isChangingTab && /*#__PURE__*/_react.default.createElement(_PageWizard.default, {
|
|
149
|
+
clickedSection: clickedSection,
|
|
150
|
+
canvasRef: canvasRef,
|
|
151
|
+
containerRef: containerRef,
|
|
152
|
+
sectionSelected: sectionSelected,
|
|
153
|
+
sections: sections,
|
|
154
|
+
onSectionChange: onSectionChange,
|
|
155
|
+
page: actualPage,
|
|
156
|
+
isChangingTab: isChangingTab,
|
|
157
|
+
isSheetOpen: sheetOpen,
|
|
158
|
+
isMobileSize: isMobileSize
|
|
159
|
+
}))), /*#__PURE__*/_react.default.createElement(_SectionDetails.default, _extends({
|
|
160
|
+
sectionSelected: sectionSelected
|
|
161
|
+
}, sectionDetails))), /*#__PURE__*/_react.default.createElement(_UTSheet.default, {
|
|
162
|
+
SlideProps: _constants.SLIDE_PROPS,
|
|
163
|
+
anchor: "bottom",
|
|
164
|
+
open: sheetOpen,
|
|
165
|
+
toggleDrawer: toggleDrawer
|
|
166
|
+
}, SheetChildren));
|
|
167
|
+
};
|
|
168
|
+
UTDocumentWizard.propTypes = {
|
|
169
|
+
pages: (0, _propTypes.arrayOf)({}),
|
|
170
|
+
sections: (0, _propTypes.arrayOf)({}),
|
|
171
|
+
labels: _propTypes.object
|
|
172
|
+
};
|
|
173
|
+
var _default = exports.default = UTDocumentWizard;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
@use '../../scss/variables/mediaQueries.module.scss' as *;
|
|
2
|
+
|
|
3
|
+
$assigned-to-icon-size: 24px;
|
|
4
|
+
|
|
5
|
+
.container {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex: 1;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
padding: 32px;
|
|
11
|
+
|
|
12
|
+
@media #{$mobile} {
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tabs {
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.tabRoot {
|
|
23
|
+
background-color: transparent;
|
|
24
|
+
color: rgba(103, 116, 137, 1);
|
|
25
|
+
height: 46px;
|
|
26
|
+
margin-left: 4px;
|
|
27
|
+
margin-right: 8px;
|
|
28
|
+
min-height: auto;
|
|
29
|
+
min-width: auto;
|
|
30
|
+
padding: 0;
|
|
31
|
+
text-transform: none;
|
|
32
|
+
transition: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.tab {
|
|
36
|
+
height: 100%;
|
|
37
|
+
margin-left: 4px;
|
|
38
|
+
margin-right: 8px;
|
|
39
|
+
transition: border-bottom 350ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.selected {
|
|
43
|
+
background-color: rgba(255, 255, 255, 1);
|
|
44
|
+
border-radius: 4px;
|
|
45
|
+
box-shadow: 0px 3px 6px 0px rgba(40, 90, 255, 0.1);
|
|
46
|
+
color: rgba(1, 54, 231, 1);
|
|
47
|
+
width: 100%;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.indicator {
|
|
51
|
+
display: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.pageWizardContainer{
|
|
55
|
+
align-items: flex-start;
|
|
56
|
+
display: flex;
|
|
57
|
+
flex: 1;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
overflow: 'hidden';
|
|
60
|
+
width: 60%;
|
|
61
|
+
@media #{$mobile} {
|
|
62
|
+
align-items: center;
|
|
63
|
+
width: 100%;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.pageManagerSection {
|
|
68
|
+
margin-bottom: 24px;
|
|
69
|
+
width: 100%;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.pageManagerContainer {
|
|
73
|
+
padding-top: 8px;
|
|
74
|
+
width: 100%;
|
|
75
|
+
@media #{$mobile} {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.slidePageManagerContainer {
|
|
81
|
+
display: none;
|
|
82
|
+
@media #{$mobile} {
|
|
83
|
+
display: flex;
|
|
84
|
+
flex: 1;
|
|
85
|
+
flex-direction: row;
|
|
86
|
+
justify-content: space-between;
|
|
87
|
+
margin-right: 12px;
|
|
88
|
+
padding: 6.5px 0px 6.5px 0px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.icon {
|
|
93
|
+
background-color: rgba(233, 239, 255, 1);
|
|
94
|
+
border-radius: 4px;
|
|
95
|
+
border-width: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.iconDisabled {
|
|
99
|
+
background-color: rgba(233, 239, 255, 0.5)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.loadingContainer {
|
|
103
|
+
align-items: center;
|
|
104
|
+
display: flex;
|
|
105
|
+
flex: 1;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
min-height: 800px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.scrollContainer {
|
|
111
|
+
display: flex;
|
|
112
|
+
justify-content: center;
|
|
113
|
+
white-space: nowrap;
|
|
114
|
+
width: 100%;
|
|
115
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTabsOptions = void 0;
|
|
7
|
+
const getTabsOptions = pages => {
|
|
8
|
+
var _pages$map;
|
|
9
|
+
return (_pages$map = pages === null || pages === void 0 ? void 0 : pages.map(page => ({
|
|
10
|
+
label: page.name,
|
|
11
|
+
value: "".concat(page.id)
|
|
12
|
+
}))) !== null && _pages$map !== void 0 ? _pages$map : [];
|
|
13
|
+
};
|
|
14
|
+
exports.getTabsOptions = getTabsOptions;
|
|
@@ -16,7 +16,8 @@ const variantsColorTheme = (colorTheme, shade, theme) => {
|
|
|
16
16
|
return colorThemeDefinition[colorShade] || _colorsModule.default.black;
|
|
17
17
|
};
|
|
18
18
|
const linkColor = (theme, colorTheme) => {
|
|
19
|
-
|
|
19
|
+
var _theme$Palette;
|
|
20
|
+
const actionPaletteColors = ((_theme$Palette = theme.Palette) === null || _theme$Palette === void 0 ? void 0 : _theme$Palette.actions) || theme.Palette;
|
|
20
21
|
const color = colorTheme === _Palette.COLOR_THEMES.light ? actionPaletteColors.negative[_Palette.COLOR_SHADES.shade05] : colorTheme === _Palette.COLOR_THEMES.error ? actionPaletteColors.error[_Palette.COLOR_SHADES.shade05] : actionPaletteColors.neutral[_Palette.COLOR_SHADES.shade05];
|
|
21
22
|
return color;
|
|
22
23
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _core = require("@material-ui/core");
|
|
8
|
+
var _propTypes = require("prop-types");
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const UTSheet = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
anchor,
|
|
14
|
+
children,
|
|
15
|
+
open,
|
|
16
|
+
toggleDrawer,
|
|
17
|
+
SlideProps
|
|
18
|
+
} = _ref;
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement(_core.SwipeableDrawer, {
|
|
20
|
+
SlideProps: SlideProps,
|
|
21
|
+
anchor: anchor,
|
|
22
|
+
open: open,
|
|
23
|
+
onClose: () => toggleDrawer(false),
|
|
24
|
+
onOpen: () => toggleDrawer(true)
|
|
25
|
+
}, children);
|
|
26
|
+
};
|
|
27
|
+
UTSheet.propTypes = {
|
|
28
|
+
anchor: _propTypes.string,
|
|
29
|
+
open: _propTypes.func,
|
|
30
|
+
toggleDrawer: _propTypes.func,
|
|
31
|
+
SlideProps: _propTypes.object
|
|
32
|
+
};
|
|
33
|
+
var _default = exports.default = UTSheet;
|
|
@@ -37,6 +37,7 @@ class UTTabs extends _react.PureComponent {
|
|
|
37
37
|
badges,
|
|
38
38
|
classes: themeClasses,
|
|
39
39
|
classNames,
|
|
40
|
+
lastOptionProps,
|
|
40
41
|
options,
|
|
41
42
|
tabProps,
|
|
42
43
|
tabsProps,
|
|
@@ -63,6 +64,8 @@ class UTTabs extends _react.PureComponent {
|
|
|
63
64
|
tooltip: opt.tooltip,
|
|
64
65
|
tooltipProps: tabTooltipProps
|
|
65
66
|
}))) : _constants.DEFAULT_TAB_COMPONENT;
|
|
67
|
+
const lastOption = i + 1 === options.length;
|
|
68
|
+
const lastOptionPropsFinal = lastOption && !!lastOptionProps ? lastOptionProps : {};
|
|
66
69
|
return /*#__PURE__*/_react.default.createElement(_Tab.default, _extends({
|
|
67
70
|
classes: {
|
|
68
71
|
root: "".concat(styles.tabRoot, " ").concat(classes.tabRoot),
|
|
@@ -77,7 +80,7 @@ class UTTabs extends _react.PureComponent {
|
|
|
77
80
|
icon: opt.icon,
|
|
78
81
|
component: tabComponent,
|
|
79
82
|
"data-testid": tabProps !== null && tabProps !== void 0 && tabProps.dataTestId ? "".concat(tabProps === null || tabProps === void 0 ? void 0 : tabProps.dataTestId).concat(i) : "".concat(tabId).concat(i)
|
|
80
|
-
}, tabProps));
|
|
83
|
+
}, tabProps, lastOptionPropsFinal));
|
|
81
84
|
}), !(0, _array.isEmpty)(badges) && badges.map(badge => /*#__PURE__*/_react.default.createElement("div", {
|
|
82
85
|
className: "".concat(badge.styles, " ").concat(!badge.show && _stylesModule.default.hiddenBadge)
|
|
83
86
|
})));
|
|
@@ -105,6 +108,7 @@ UTTabs.propTypes = {
|
|
|
105
108
|
label: _propTypes.string
|
|
106
109
|
}),
|
|
107
110
|
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
111
|
+
lastOptionProps: _propTypes.object,
|
|
108
112
|
onChange: _propTypes.func.isRequired,
|
|
109
113
|
options: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
|
|
110
114
|
label: _propTypes.string,
|
package/dist/index.js
CHANGED
|
@@ -147,6 +147,12 @@ Object.defineProperty(exports, "UTDialog", {
|
|
|
147
147
|
return _UTDialog.default;
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
|
+
Object.defineProperty(exports, "UTDocumentWizard", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () {
|
|
153
|
+
return _UTDocumentWizard.default;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
150
156
|
Object.defineProperty(exports, "UTDotMenu", {
|
|
151
157
|
enumerable: true,
|
|
152
158
|
get: function () {
|
|
@@ -535,4 +541,5 @@ var _UTVirtualKeyboard = _interopRequireDefault(require("./components/UTVirtualK
|
|
|
535
541
|
var _UTWorkflowContainer = _interopRequireDefault(require("./components/UTWorkflowContainer"));
|
|
536
542
|
var _WithLoading = _interopRequireDefault(require("./components/WithLoading"));
|
|
537
543
|
var _WithTouch = _interopRequireDefault(require("./components/WithTouch"));
|
|
544
|
+
var _UTDocumentWizard = _interopRequireDefault(require("./components/UTDocumentWizard"));
|
|
538
545
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|