@widergy/energy-ui 3.100.2 → 3.101.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [3.101.0](https://github.com/widergy/energy-ui/compare/v3.100.3...v3.101.0) (2025-08-26)
2
+
3
+
4
+ ### Features
5
+
6
+ * [CPE-10] adds UTSignature component ([#670](https://github.com/widergy/energy-ui/issues/670)) ([b6d8d09](https://github.com/widergy/energy-ui/commit/b6d8d097db47dc0c5486579fa157e5f945377575))
7
+
8
+ ## [3.100.3](https://github.com/widergy/energy-ui/compare/v3.100.2...v3.100.3) (2025-08-25)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * [SFPE-405] add title tooltip ([#675](https://github.com/widergy/energy-ui/issues/675)) ([42c9cc5](https://github.com/widergy/energy-ui/commit/42c9cc5afe5fd8b2f39158de1a3ae78f0767463b))
14
+
1
15
  ## [3.100.2](https://github.com/widergy/energy-ui/compare/v3.100.1...v3.100.2) (2025-08-20)
2
16
 
3
17
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SPACING = exports.PADDING = exports.ORIENTATION = exports.ACTION_TYPE = void 0;
6
+ exports.TOOLTIP_PROPS = exports.SPACING = exports.PADDING = exports.ORIENTATION = exports.ACTION_TYPE = void 0;
7
7
  const ORIENTATION = exports.ORIENTATION = {
8
8
  HORIZONTAL: 'horizontal',
9
9
  VERTICAL: 'vertical'
@@ -19,4 +19,8 @@ const SPACING = exports.SPACING = {
19
19
  const ACTION_TYPE = exports.ACTION_TYPE = {
20
20
  SWITCH: 'switch',
21
21
  BUTTON: 'button'
22
+ };
23
+ const TOOLTIP_PROPS = exports.TOOLTIP_PROPS = {
24
+ appendTo: () => document.body,
25
+ interactive: false
22
26
  };
@@ -9,6 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
10
10
  var _isString = _interopRequireDefault(require("lodash/isString"));
11
11
  var _isFinite = _interopRequireDefault(require("lodash/isFinite"));
12
+ var _UTTooltip = _interopRequireDefault(require("../UTTooltip"));
12
13
  var _UTBadge = _interopRequireDefault(require("../UTBadge"));
13
14
  var _UTLabel = _interopRequireDefault(require("../UTLabel"));
14
15
  var _WithTheme = _interopRequireDefault(require("../WithTheme"));
@@ -64,6 +65,11 @@ const UTDataElement = _ref => {
64
65
  const IconComponent = (0, _componentUtils.isUTIcon)(Icon) ? _UTIcon.default : Icon;
65
66
  const DataComponent = (0, _componentUtils.isUTLabel)(Data) ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, dataProps, Data) : Data;
66
67
  const showBadge = forceShowBadge || (0, _isString.default)(badge) && !(0, _isEmpty.default)(badge) || (0, _isFinite.default)(badge);
68
+ const {
69
+ tooltip: titleTooltip
70
+ } = titleProps || {};
71
+ const withTitleTooltip = (0, _isString.default)(titleTooltip) && !(0, _isEmpty.default)(titleTooltip);
72
+ const TitleWrapper = withTitleTooltip ? _UTTooltip.default : _react.Fragment;
67
73
  const contentClasses = "".concat(classes.content, " ").concat(_stylesModule.default["spacing".concat((0, _componentUtils.capitalize)(spacing))]);
68
74
  const infoClasses = "".concat(classes.info, " ").concat(orientation === _constants.ORIENTATION.VERTICAL && classes.vertical);
69
75
  const iconCollapseButtonClasses = "".concat(classes.iconCollapseButton, " ").concat(isCollapsed && classes.collapsed);
@@ -81,9 +87,12 @@ const UTDataElement = _ref => {
81
87
  className: classes.topInfo
82
88
  }, prefix && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
83
89
  colorTheme: "gray"
84
- }, prefixProps), prefix), title && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
90
+ }, prefixProps), prefix), title && /*#__PURE__*/_react.default.createElement(TitleWrapper, withTitleTooltip ? {
91
+ tippyProps: _constants.TOOLTIP_PROPS,
92
+ content: titleTooltip
93
+ } : {}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
85
94
  colorTheme: "gray"
86
- }, titleProps), title), showBadge && /*#__PURE__*/_react.default.createElement(_UTBadge.default, _extends({
95
+ }, titleProps), title))), showBadge && /*#__PURE__*/_react.default.createElement(_UTBadge.default, _extends({
87
96
  colorTheme: "accent",
88
97
  className: classes.badge
89
98
  }, badgeProps), forceShowBadge ? null : badge)), DataComponent && DataComponent), action && /*#__PURE__*/_react.default.createElement(_MainAction.default, _extends({
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.Default = void 0;
7
+ var _utils = require("stories/utils");
8
+ var _inputs = require("../../constants/inputs");
9
+ var _ = _interopRequireDefault(require("."));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ var _default = exports.default = {
12
+ argTypes: {
13
+ title: {
14
+ control: 'text',
15
+ description: 'Título que se muestra en el header del componente.',
16
+ table: {
17
+ defaultValue: {
18
+ summary: 'undefined'
19
+ },
20
+ type: {
21
+ summary: 'string'
22
+ }
23
+ }
24
+ },
25
+ penColor: {
26
+ control: 'color',
27
+ description: 'Color del lápiz.',
28
+ table: {
29
+ defaultValue: {
30
+ summary: 'black'
31
+ },
32
+ type: {
33
+ summary: 'string'
34
+ }
35
+ }
36
+ },
37
+ titleVariant: {
38
+ control: 'select',
39
+ description: 'Tamaño del título.',
40
+ options: Object.keys(_inputs.TITLE_VARIANTS),
41
+ table: {
42
+ defaultValue: {
43
+ summary: 'large'
44
+ },
45
+ type: {
46
+ summary: (0, _utils.joinArgTypes)(Object.keys(_inputs.TITLE_VARIANTS))
47
+ }
48
+ }
49
+ },
50
+ required: {
51
+ control: 'boolean',
52
+ description: 'Determina si el componente es requerido.',
53
+ table: {
54
+ defaultValue: {
55
+ summary: 'false'
56
+ },
57
+ type: {
58
+ summary: 'boolean'
59
+ }
60
+ }
61
+ },
62
+ width: {
63
+ control: 'number',
64
+ description: 'Ancho del componente.',
65
+ table: {
66
+ defaultValue: {
67
+ summary: '500'
68
+ },
69
+ type: {
70
+ summary: 'number'
71
+ }
72
+ }
73
+ },
74
+ height: {
75
+ control: 'number',
76
+ description: 'Altura del componente.',
77
+ table: {
78
+ defaultValue: {
79
+ summary: '200'
80
+ },
81
+ type: {
82
+ summary: 'number'
83
+ }
84
+ }
85
+ }
86
+ },
87
+ component: _.default,
88
+ parameters: {
89
+ controls: {
90
+ exclude: ['actions', 'onChange', 'error', 'helpText', 'validationDataTestId', 'value', 'input']
91
+ },
92
+ docs: {
93
+ description: {
94
+ component: 'Este componente se usa para renderizar un canvas de firma.'
95
+ }
96
+ }
97
+ }
98
+ };
99
+ const Default = exports.Default = {
100
+ args: {
101
+ penColor: 'black',
102
+ title: 'Firma'
103
+ },
104
+ name: 'Playground'
105
+ };
@@ -0,0 +1,143 @@
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 _reactSignatureCanvas = _interopRequireDefault(require("react-signature-canvas"));
9
+ var _propTypes = require("prop-types");
10
+ var _UTButton = _interopRequireDefault(require("../UTButton"));
11
+ var _UTFieldLabel = _interopRequireDefault(require("../UTFieldLabel"));
12
+ var _UTLabel = _interopRequireDefault(require("../UTLabel"));
13
+ var _UTValidation = _interopRequireDefault(require("../UTValidation"));
14
+ var _buttonTypes = require("../../types/buttonTypes");
15
+ var _inputs = require("../../constants/inputs");
16
+ var _utils = require("../UTValidation/utils");
17
+ var _formTypes = require("../../types/formTypes");
18
+ var _colorsModule = _interopRequireDefault(require("../../scss/variables/colors.module.scss"));
19
+ var _helperFunctions = require("../../utils/helperFunctions");
20
+ var _testIds = require("../../constants/testIds");
21
+ var _classesUtils = require("../../utils/classesUtils");
22
+ var _WithTheme = _interopRequireDefault(require("../WithTheme"));
23
+ var _theme = require("./theme");
24
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
25
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
27
+ const {
28
+ signature
29
+ } = _testIds.TEST_IDS;
30
+ const {
31
+ TITLE,
32
+ CANVAS,
33
+ HELP_TEXT,
34
+ VALIDATION_DATA,
35
+ CLEAR_BUTTON
36
+ } = _testIds.ID_CONSTANTS;
37
+ const UTSignature = _ref => {
38
+ var _getCanvas3;
39
+ let {
40
+ actions: titleActions,
41
+ canvasBackgroundColor = _colorsModule.default.white,
42
+ classes: themeClasses = {},
43
+ classNames = {},
44
+ dataTestId = signature,
45
+ error,
46
+ height = 200,
47
+ helpText,
48
+ input,
49
+ onChange = () => {},
50
+ penColor = _colorsModule.default.black,
51
+ required,
52
+ title,
53
+ titleVariant = _inputs.TITLE_VARIANTS.large,
54
+ value,
55
+ width = 500
56
+ } = _ref;
57
+ const sigCanvasRef = (0, _react.useRef)(null);
58
+ const getCanvas = () => sigCanvasRef.current;
59
+ const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(themeClasses, classNames), [themeClasses, classNames]);
60
+ const currentValue = input ? input.value : value;
61
+ const handleChange = newValue => input ? input.onChange(newValue) : onChange(newValue);
62
+ const clear = () => {
63
+ var _getCanvas;
64
+ (_getCanvas = getCanvas()) === null || _getCanvas === void 0 || _getCanvas.clear();
65
+ handleChange('');
66
+ };
67
+ const handleEnd = () => {
68
+ var _getCanvas2;
69
+ const data = ((_getCanvas2 = getCanvas()) === null || _getCanvas2 === void 0 ? void 0 : _getCanvas2.toDataURL('image/png')) || '';
70
+ if (!data) {
71
+ handleChange('');
72
+ return;
73
+ }
74
+ handleChange({
75
+ file: (0, _helperFunctions.base64ToFile)(data, 'signature.png')
76
+ });
77
+ };
78
+ (0, _react.useEffect)(() => {
79
+ const canvas = getCanvas();
80
+ if (!canvas) return;
81
+ if (typeof currentValue === 'string' && currentValue.startsWith('data:image')) {
82
+ canvas.fromDataURL(currentValue);
83
+ }
84
+ }, [currentValue]);
85
+ const validationData = ((_getCanvas3 = getCanvas()) === null || _getCanvas3 === void 0 ? void 0 : _getCanvas3.isEmpty()) && error && (0, _utils.formatErrorToValidation)(error);
86
+ return /*#__PURE__*/_react.default.createElement("div", {
87
+ className: "".concat(_stylesModule.default.container, " ").concat(classNames.container),
88
+ "data-testid": dataTestId
89
+ }, title && /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
90
+ actions: titleActions,
91
+ dataTestId: "".concat(dataTestId, ".").concat(TITLE),
92
+ required: required,
93
+ size: titleVariant
94
+ }, title), /*#__PURE__*/_react.default.createElement(_reactSignatureCanvas.default, {
95
+ backgroundColor: canvasBackgroundColor,
96
+ canvasProps: {
97
+ className: "".concat(_stylesModule.default.canvas, " ").concat(classNames.canvas, " ").concat(classes.canvas),
98
+ 'data-testid': "".concat(dataTestId, ".").concat(CANVAS),
99
+ height,
100
+ tabIndex: 0,
101
+ width
102
+ },
103
+ onEnd: handleEnd,
104
+ penColor: penColor,
105
+ ref: sigCanvasRef
106
+ }), helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
107
+ colorTheme: "gray",
108
+ dataTestId: "".concat(dataTestId, ".").concat(HELP_TEXT),
109
+ variant: "small"
110
+ }, helpText), validationData && /*#__PURE__*/_react.default.createElement(_UTValidation.default, {
111
+ dataTestId: "".concat(dataTestId, ".").concat(VALIDATION_DATA),
112
+ validationData: validationData
113
+ }), /*#__PURE__*/_react.default.createElement(_UTButton.default, {
114
+ colorTheme: "error",
115
+ dataTestId: "".concat(dataTestId, ".").concat(CLEAR_BUTTON),
116
+ onClick: clear,
117
+ variant: "text"
118
+ }, "Limpiar"));
119
+ };
120
+ UTSignature.propTypes = {
121
+ actions: (0, _propTypes.arrayOf)(_buttonTypes.buttonTypes),
122
+ canvasBackgroundColor: _propTypes.string,
123
+ classes: (0, _propTypes.objectOf)(_propTypes.string),
124
+ classNames: _propTypes.object,
125
+ dataTestId: _propTypes.string,
126
+ error: _propTypes.string,
127
+ height: _propTypes.number,
128
+ helpText: _propTypes.string,
129
+ input: _formTypes.inputPropTypes,
130
+ onChange: _propTypes.func,
131
+ penColor: _propTypes.string,
132
+ required: _propTypes.bool,
133
+ title: _propTypes.string,
134
+ titleVariant: _propTypes.string,
135
+ value: (0, _propTypes.oneOfType)([_propTypes.string, (0, _propTypes.shape)({
136
+ name: _propTypes.string,
137
+ type: _propTypes.string
138
+ }), (0, _propTypes.shape)({
139
+ file: _propTypes.object
140
+ })]),
141
+ width: _propTypes.number
142
+ };
143
+ var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTSignature);
@@ -0,0 +1,6 @@
1
+ .container {
2
+ align-items: start;
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: 10px;
6
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.retrieveStyle = void 0;
7
+ const retrieveStyle = _ref => {
8
+ var _theme$Palette;
9
+ let {
10
+ theme
11
+ } = _ref;
12
+ const actionPaletteColors = ((_theme$Palette = theme.Palette) === null || _theme$Palette === void 0 ? void 0 : _theme$Palette.actions) || theme.Palette;
13
+ const actionTheme = actionPaletteColors.accent;
14
+ const grayTheme = theme.Palette.gray;
15
+ return {
16
+ canvas: {
17
+ borderRadius: '4px',
18
+ border: "1px solid ".concat(grayTheme['01']),
19
+ cursor: 'pointer',
20
+ '&:focus': {
21
+ border: "2px solid ".concat(actionTheme['04'])
22
+ },
23
+ '&:active': {
24
+ border: "2px solid ".concat(actionTheme['04'])
25
+ }
26
+ }
27
+ };
28
+ };
29
+ exports.retrieveStyle = retrieveStyle;
@@ -7,19 +7,24 @@ exports.TEST_IDS = exports.ID_CONSTANTS = void 0;
7
7
  const ID_CONSTANTS = exports.ID_CONSTANTS = {
8
8
  ACTIONS: 'actions',
9
9
  BOTTOM_NAV: 'bottomNav',
10
+ CANVAS: 'canvas',
10
11
  CELL: 'cell',
12
+ CLEAR_BUTTON: 'clearButton',
11
13
  CREDIT_CARD: 'creditCard',
14
+ DATA_CATEGORY: 'dataCategory',
15
+ DATA_ELEMENT: 'dataElement',
12
16
  DIALOG: 'dialog',
13
17
  HEADER: 'header',
18
+ HELP_TEXT: 'helpText',
14
19
  ONBOARDING: 'onboarding',
15
20
  PANEL: 'panel',
16
21
  SELECTION_COMPONENT: 'selectionComponent',
17
22
  STATUS_MESSAGE: 'statusMessage',
18
- TABLE: 'table',
19
23
  TABLE_ROW: 'tableRow',
20
- WORKFLOW_CONTAINER: 'workflowContainer',
21
- DATA_CATEGORY: 'dataCategory',
22
- DATA_ELEMENT: 'dataElement'
24
+ TABLE: 'table',
25
+ TITLE: 'title',
26
+ VALIDATION_DATA: 'validationData',
27
+ WORKFLOW_CONTAINER: 'workflowContainer'
23
28
  };
24
29
  const TEST_IDS = exports.TEST_IDS = {
25
30
  barChart: {
@@ -71,6 +76,7 @@ const TEST_IDS = exports.TEST_IDS = {
71
76
  secondaryAction: "".concat(ID_CONSTANTS.PANEL, ".secondaryAction"),
72
77
  title: "".concat(ID_CONSTANTS.PANEL, ".title")
73
78
  },
79
+ signature: 'signature',
74
80
  snackBar: {
75
81
  closeButton: 'snackbar.closeButton',
76
82
  label: 'snackbar.label'
package/dist/index.js CHANGED
@@ -345,6 +345,12 @@ Object.defineProperty(exports, "UTSidebar", {
345
345
  return _UTSidebar.default;
346
346
  }
347
347
  });
348
+ Object.defineProperty(exports, "UTSignature", {
349
+ enumerable: true,
350
+ get: function () {
351
+ return _UTSignature.default;
352
+ }
353
+ });
348
354
  Object.defineProperty(exports, "UTSkeleton", {
349
355
  enumerable: true,
350
356
  get: function () {
@@ -542,6 +548,7 @@ var _UTSearchField = _interopRequireDefault(require("./components/UTSearchField"
542
548
  var _UTSelect = _interopRequireDefault(require("./components/UTSelect"));
543
549
  var _UTSelectableCard = _interopRequireDefault(require("./components/UTSelectableCard"));
544
550
  var _UTSidebar = _interopRequireDefault(require("./components/UTSidebar"));
551
+ var _UTSignature = _interopRequireDefault(require("./components/UTSignature"));
545
552
  var _UTSkeleton = _interopRequireDefault(require("./components/UTSkeleton"));
546
553
  var _UTStatus = _interopRequireDefault(require("./components/UTStatus"));
547
554
  var _UTStatusMessage = _interopRequireDefault(require("./components/UTStatusMessage"));
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.throttle = void 0;
6
+ exports.throttle = exports.base64ToFile = void 0;
7
7
  const throttle = (func, limit) => {
8
8
  let inThrottle;
9
9
  return function throttled() {
@@ -20,4 +20,19 @@ const throttle = (func, limit) => {
20
20
  }
21
21
  };
22
22
  };
23
- exports.throttle = throttle;
23
+ exports.throttle = throttle;
24
+ const base64ToFile = (base64, filename) => {
25
+ var _arr$0$match;
26
+ const arr = base64.split(',');
27
+ const mime = ((_arr$0$match = arr[0].match(/:(.*?);/)) === null || _arr$0$match === void 0 ? void 0 : _arr$0$match[1]) || 'image/png';
28
+ const bstr = atob(arr[1]);
29
+ const n = bstr.length;
30
+ const u8arr = new Uint8Array(n);
31
+ for (let i = 0; i < n; i += 1) {
32
+ u8arr[i] = bstr.charCodeAt(i);
33
+ }
34
+ return new File([u8arr], filename, {
35
+ type: mime
36
+ });
37
+ };
38
+ exports.base64ToFile = base64ToFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.100.2",
3
+ "version": "3.101.0",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",
@@ -56,6 +56,7 @@
56
56
  "react-jss": "^8.6.1",
57
57
  "react-markdown": "^8.0.7",
58
58
  "react-perfect-scrollbar": "^1.5.3",
59
+ "react-signature-canvas": "1.0.7",
59
60
  "react-simple-keyboard": "^3.8.28",
60
61
  "react-transition-group": "^4.2.2",
61
62
  "react-window": "^1.8.5",
@@ -113,7 +114,8 @@
113
114
  "@babel/preset-env": "^7.8.7",
114
115
  "caniuse-lite": "1.0.30001632",
115
116
  "minimatch": "3.1.2",
116
- "react-error-overlay": "6.0.9"
117
+ "react-error-overlay": "6.0.9",
118
+ "react-signature-canvas": "1.0.7"
117
119
  },
118
120
  "browserslist": [
119
121
  ">0.2%",