@widergy/energy-ui 3.33.0 → 3.33.1

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,10 @@
1
+ ## [3.33.1](https://github.com/widergy/energy-ui/compare/v3.33.0...v3.33.1) (2024-10-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * component fixes ([#514](https://github.com/widergy/energy-ui/issues/514)) ([a2afbcf](https://github.com/widergy/energy-ui/commit/a2afbcf96dbc1b3c9afb155a7687db9c4d22b4e1))
7
+
1
8
  # [3.33.0](https://github.com/widergy/energy-ui/compare/v3.32.0...v3.33.0) (2024-10-18)
2
9
 
3
10
 
@@ -78,6 +78,7 @@ const UTBaseInputField = _ref => {
78
78
  const adornmentProps = {
79
79
  ...adornment.props,
80
80
  error,
81
+ focused,
81
82
  disabled: disabled && !readOnly,
82
83
  classNames: adornment.name === _constants.COMPONENT_KEYS.ACTION ? {
83
84
  root: _stylesModule.default.actionButton
@@ -86,7 +87,7 @@ const UTBaseInputField = _ref => {
86
87
  return Component ? /*#__PURE__*/_react.default.createElement(Component, _extends({}, adornmentProps, {
87
88
  key: adornment.name
88
89
  })) : null;
89
- }, [error, disabled, readOnly]);
90
+ }, [error, disabled, readOnly, focused]);
90
91
  return /*#__PURE__*/_react.default.createElement(_TextField.default, {
91
92
  margin: "none",
92
93
  autoComplete: "new-password",
@@ -37,7 +37,6 @@ const retrieveStyle = _ref => {
37
37
  bottom: verticalPadding
38
38
  },
39
39
  root: {
40
- minWidth: '320px',
41
40
  backgroundColor: theme.Palette.light['01'],
42
41
  paddingBottom: hasCharactersCount ? multilineVerticalPadding : verticalPadding,
43
42
  paddingLeft: horizontalPadding,
@@ -10,7 +10,7 @@
10
10
  | ----------------- | ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
11
11
  | classNames | objectOf(string) | | Custom class names to apply to different elements of the checklist (`root`, `header`, `checkboxesContainer`, `item`, `selectAll`). |
12
12
  | error | string | | Error message to display. |
13
- | horizontalSpacing | string | large | Spacing between the checkbox and the title horizontally. |
13
+ | horizontalSpacing | string | medium | Spacing between the checkbox and the title horizontally. |
14
14
  | isSimple | bool | false | Simplifies the selection process to only allow single checkbox selection. |
15
15
  | onChange | func.isRequired | | Function to call when the selection changes. |
16
16
  | options | arrayOf(shape) | | Array of options to be displayed as checkboxes. Each option is an object with `label`, `value`, `disabled`, `checked`, and optionally `category`. |
@@ -21,7 +21,7 @@
21
21
  | title | string | | Title for the checklist. |
22
22
  | value | arrayOf(string) | [] | Array of selected values. |
23
23
  | variant | string | | Variant style for the checklist. |
24
- | verticalSpacing | string | large | Spacing between the checkbox items vertically. |
24
+ | verticalSpacing | string | medium | Spacing between the checkbox items vertically. |
25
25
 
26
26
  ### Option Object
27
27
 
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.SPACING = void 0;
7
7
  const SPACING = exports.SPACING = {
8
8
  SMALL: 'small',
9
- LARGE: 'large'
9
+ MEDIUM: 'medium'
10
10
  };
@@ -22,8 +22,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
22
22
  const UTCheckList = _ref => {
23
23
  let {
24
24
  classNames = {},
25
+ dataTestId,
25
26
  error,
26
- horizontalSpacing = 'large',
27
+ horizontalSpacing = 'medium',
27
28
  isSimple = false,
28
29
  onChange = () => {},
29
30
  options,
@@ -34,7 +35,7 @@ const UTCheckList = _ref => {
34
35
  title,
35
36
  value = null,
36
37
  variant,
37
- verticalSpacing = 'large'
38
+ verticalSpacing = 'medium'
38
39
  } = _ref;
39
40
  const reversedBasedOnVariant = (0, _utils2.getPropValueBasedOnVariant)(variant, reversed, true);
40
41
  const verticalSpacingBasedOnVariant = (0, _utils2.getPropValueBasedOnVariant)(variant, verticalSpacing, _constants.SPACING.SMALL);
@@ -82,7 +83,8 @@ const UTCheckList = _ref => {
82
83
  onChange(areAllSelected ? [] : enabledOptions.map(item => item.value));
83
84
  }, [areAllSelected, enabledOptions, onChange]);
84
85
  return /*#__PURE__*/_react.default.createElement("div", {
85
- className: "".concat(_stylesModule.default.container, " ").concat(smallVerticalSpacingClass, " ").concat(classNames.root)
86
+ className: "".concat(_stylesModule.default.container, " ").concat(smallVerticalSpacingClass, " ").concat(classNames.root),
87
+ "data-testid": dataTestId
86
88
  }, /*#__PURE__*/_react.default.createElement("div", {
87
89
  className: "".concat(_stylesModule.default.headerContainer, " ").concat(classNames.header)
88
90
  }, title && /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
@@ -128,6 +130,7 @@ const UTCheckList = _ref => {
128
130
  };
129
131
  UTCheckList.propTypes = {
130
132
  classNames: (0, _propTypes.objectOf)(_propTypes.string),
133
+ dataTestId: _propTypes.string,
131
134
  error: _propTypes.string,
132
135
  horizontalSpacing: _propTypes.string,
133
136
  isSimple: _propTypes.bool,
@@ -137,7 +140,7 @@ UTCheckList.propTypes = {
137
140
  disabled: _propTypes.bool,
138
141
  label: _propTypes.string,
139
142
  value: _propTypes.string,
140
- category: _propTypes.string // Nueva propiedad opcional para la categoría
143
+ category: _propTypes.string
141
144
  })),
142
145
  required: _propTypes.bool,
143
146
  reversed: _propTypes.bool,
@@ -1,4 +1,4 @@
1
- $spacing-large: 16px;
1
+ $spacing-medium: 16px;
2
2
  $spacing-small: 8px;
3
3
 
4
4
  .buttonVariant {
@@ -8,7 +8,7 @@ $spacing-small: 8px;
8
8
  .categoryContainer {
9
9
  display: flex;
10
10
  flex-direction: column;
11
- grid-gap: $spacing-large;
11
+ grid-gap: $spacing-medium;
12
12
  }
13
13
 
14
14
  .categoryTitle {
@@ -19,14 +19,14 @@ $spacing-small: 8px;
19
19
  display: flex;
20
20
  flex-direction: column;
21
21
  align-self: flex-start;
22
- grid-gap: $spacing-large;
22
+ grid-gap: $spacing-medium;
23
23
  width: 100%;
24
24
  }
25
25
 
26
26
  .container {
27
27
  display: flex;
28
28
  flex-direction: column;
29
- grid-gap: $spacing-large;
29
+ grid-gap: $spacing-medium;
30
30
  }
31
31
 
32
32
  .headerContainer {
@@ -14,6 +14,7 @@
14
14
  | isSimple | bool | false | **Deprecated**: Please avoid using this property in future implementations. |
15
15
  | onChange | func | | Function to call when the checkbox state changes. |
16
16
  | required | bool | false | Indicates if the checkbox is required. |
17
+ | spacing | string | 'medium' | Defines the spacing between the checkbox and the label. Can be 'small' or 'medium'. |
17
18
  | title | string | | Title to display next to the checkbox. Supports markdown when `withMarkdown` is true. |
18
19
  | value | bool | false | Indicates if the checkbox is checked. |
19
20
  | variant | string | 'default' | Defines the visual variant of the checkbox. |
@@ -8,6 +8,6 @@ const CHECKED_ICON = exports.CHECKED_ICON = 'IconCheck';
8
8
  const INDETERMINATE_ICON = exports.INDETERMINATE_ICON = 'IconMinus';
9
9
  const SPACING = exports.SPACING = {
10
10
  SMALL: 'small',
11
- LARGE: 'large'
11
+ MEDIUM: 'medium'
12
12
  };
13
13
  const BUTTON_VARIANT = exports.BUTTON_VARIANT = 'button';
@@ -22,6 +22,7 @@ const UTCheckbox = _ref => {
22
22
  let {
23
23
  classes: theme,
24
24
  classNames,
25
+ dataTestId,
25
26
  disabled,
26
27
  indeterminate,
27
28
  isSimple = false,
@@ -49,6 +50,7 @@ const UTCheckbox = _ref => {
49
50
  const rootComponentProps = variant === _constants.BUTTON_VARIANT ? touchableProps : {};
50
51
  const boxContainerProps = variant === _constants.BUTTON_VARIANT ? {} : touchableProps;
51
52
  return /*#__PURE__*/_react.default.createElement(RootComponent, _extends({
53
+ dataTestId: dataTestId,
52
54
  className: classes.container
53
55
  }, rootComponentProps), /*#__PURE__*/_react.default.createElement(BoxContainerComponent, _extends({
54
56
  className: classes.boxContainer
@@ -66,15 +68,16 @@ const UTCheckbox = _ref => {
66
68
  name: iconName,
67
69
  size: 16
68
70
  })))), /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
71
+ className: classes.title,
69
72
  colorTheme: shouldHighlightLabel ? 'accent' : 'dark',
70
73
  required: required,
71
- className: classes.title,
72
74
  withMarkdown: withMarkdown
73
75
  }, title));
74
76
  };
75
77
  UTCheckbox.propTypes = {
76
78
  classes: (0, _propTypes.objectOf)(_propTypes.string),
77
79
  classNames: (0, _propTypes.objectOf)(_propTypes.string),
80
+ dataTestId: _propTypes.string,
78
81
  disabled: _propTypes.bool,
79
82
  indeterminate: _propTypes.bool,
80
83
  /**
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.retrieveStyle = void 0;
7
7
  var _constants = require("./constants");
8
- const NORMAL_SPACING = 16;
8
+ const MEDIUM_SPACING = 16;
9
9
  const SMALL_SPACING = 8;
10
10
  const baseCheckBoxTheme = theme => ({
11
11
  container: {
@@ -37,7 +37,7 @@ const conditionalStyles = _ref => {
37
37
  theme,
38
38
  disabled
39
39
  } = _ref;
40
- const spacingValue = spacing === _constants.SPACING.SMALL ? SMALL_SPACING : NORMAL_SPACING;
40
+ const spacingValue = spacing === _constants.SPACING.SMALL ? SMALL_SPACING : MEDIUM_SPACING;
41
41
  return {
42
42
  container: {
43
43
  ...(reversed && {
@@ -37,59 +37,84 @@ const UTPhoneInput = _ref => {
37
37
  title,
38
38
  titleVariant,
39
39
  translations = {
40
- areaCodeWithoutZeroError: 'Ingrese el código sin 0',
41
- invalidAreaCodeError: 'Código de área inválido'
40
+ areaCodeMinLenghtError: 'El código de área debe contener al menos 2 caracteres.',
41
+ areaCodeWithoutZeroError: 'El código de área debe comenzar sin 0.',
42
+ invalidAreaCodeError: 'No pudimos reconocer el código de área ingresado. Intenta con uno diferente.'
42
43
  },
43
44
  validations,
44
45
  value,
45
46
  withAreaCode = true
46
47
  } = _ref;
47
- const [areaCode, setAreaCode] = (0, _react.useState)('');
48
- const [areaCodeError, setAreaCodeError] = (0, _react.useState)('');
49
- const [isValidCode, setIsValidCode] = (0, _react.useState)(false);
48
+ const [areaCodeState, setAreaCodeState] = (0, _react.useState)({
49
+ code: '',
50
+ error: ''
51
+ });
52
+ const [blurWithError, setBlurWithError] = (0, _react.useState)(false);
50
53
  const [phoneNumber, setPhoneNumber] = (0, _react.useState)('');
54
+ const {
55
+ areaCodeWithoutZeroError,
56
+ invalidAreaCodeError,
57
+ areaCodeMinLenghtError
58
+ } = translations;
51
59
  (0, _react.useEffect)(() => {
52
60
  if (value && withAreaCode) {
53
61
  const [code, phone] = value.split('-');
54
- setAreaCode(code || '');
62
+ setAreaCodeState(prevState => ({
63
+ ...prevState,
64
+ code: code || ''
65
+ }));
55
66
  setPhoneNumber(phone || '');
56
67
  } else if (value && !withAreaCode) {
57
68
  setPhoneNumber(value);
58
69
  }
59
70
  }, [value, withAreaCode]);
71
+ const validateAreaCode = code => {
72
+ if (!code) return '';
73
+ if (code.length === 1) return areaCodeMinLenghtError;
74
+ if (code.startsWith('0')) return areaCodeWithoutZeroError;
75
+ const isValidCode = _constants2.AREA_CODES.find(element => element.code === code);
76
+ return !isValidCode ? invalidAreaCodeError : '';
77
+ };
78
+ const handleOnBlur = () => {
79
+ const validationError = validateAreaCode(areaCodeState.code);
80
+ setAreaCodeState(prevState => ({
81
+ ...prevState,
82
+ error: validationError
83
+ }));
84
+ setBlurWithError(!!validationError);
85
+ onBlur === null || onBlur === void 0 || onBlur();
86
+ };
60
87
  (0, _react.useEffect)(() => {
61
- const {
62
- areaCodeWithoutZeroError,
63
- invalidAreaCodeError
64
- } = translations;
65
- if (areaCode) {
66
- if (areaCode.startsWith('0')) {
67
- setAreaCodeError(areaCodeWithoutZeroError);
68
- setIsValidCode(false);
69
- } else {
70
- const code = _constants2.AREA_CODES.find(element => element.code === areaCode);
71
- setIsValidCode(!!code);
72
- setAreaCodeError(!code ? invalidAreaCodeError : '');
73
- }
88
+ if (blurWithError) {
89
+ const validationError = validateAreaCode(areaCodeState.code);
90
+ setAreaCodeState(prevState => ({
91
+ ...prevState,
92
+ error: validationError
93
+ }));
74
94
  }
75
- }, [areaCode, translations]);
76
- const handleChangeAreaCode = (0, _react.useCallback)(areaCodeValue => {
77
- setAreaCode(areaCodeValue);
78
- }, []);
95
+ }, [areaCodeState.code, blurWithError]);
96
+ const handleChangeAreaCode = areaCodeValue => {
97
+ setAreaCodeState(prevState => ({
98
+ ...prevState,
99
+ code: areaCodeValue
100
+ }));
101
+ };
79
102
  const handleChangePhoneNumber = (0, _react.useCallback)(phoneNumberValue => {
80
103
  setPhoneNumber(phoneNumberValue);
81
104
  }, []);
82
105
  (0, _react.useEffect)(() => {
83
- if (areaCode !== '' || phoneNumber !== '') {
84
- const newValue = withAreaCode ? "".concat(areaCode, "-").concat(phoneNumber) : phoneNumber;
106
+ if (areaCodeState.code !== '' || phoneNumber !== '') {
107
+ const newValue = withAreaCode ? "".concat(areaCodeState.code, "-").concat(phoneNumber) : phoneNumber;
85
108
  if (newValue !== value) {
86
109
  onChange(newValue);
87
110
  }
88
111
  }
89
- }, [areaCode, phoneNumber, withAreaCode, onChange, value]);
90
- const validationData = validations || areaCodeError && (0, _utils.formatErrorToValidation)(areaCodeError) || error && (0, _utils.formatErrorToValidation)(error);
112
+ }, [areaCodeState.code, phoneNumber, withAreaCode, onChange, value]);
113
+ const validationData = validations || areaCodeState.error && (0, _utils.formatErrorToValidation)(areaCodeState.error) || error && (0, _utils.formatErrorToValidation)(error);
91
114
  const hasError = (validationData === null || validationData === void 0 ? void 0 : validationData.length) > 0;
92
115
  const titleColorTheme = readOnly ? 'gray' : 'dark';
116
+ const getAreaCodeMaxLength = () => Math.min(maxLength - phoneNumber.length, 4);
117
+ const getPhoneNumberMaxLength = () => withAreaCode ? Math.min(maxLength - areaCodeState.code.length, maxLength - 2) : maxLength;
93
118
  return /*#__PURE__*/_react.default.createElement("div", {
94
119
  className: _stylesModule.default.container
95
120
  }, title && /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
@@ -106,8 +131,8 @@ const UTPhoneInput = _ref => {
106
131
  dataTestId: areaCodeDataTestId,
107
132
  disabled: disabled,
108
133
  error: hasError,
109
- maxLength: 4,
110
- onBlur: onBlur,
134
+ maxLength: getAreaCodeMaxLength(),
135
+ onBlur: handleOnBlur,
111
136
  onChange: handleChangeAreaCode,
112
137
  onFocus: onFocus,
113
138
  placeholder: areaCodePlaceholder,
@@ -118,32 +143,32 @@ const UTPhoneInput = _ref => {
118
143
  changeOnError: true
119
144
  }
120
145
  }],
121
- value: areaCode
146
+ value: areaCodeState.code
122
147
  })), /*#__PURE__*/_react.default.createElement("div", {
123
148
  className: _stylesModule.default.phoneContainer
124
149
  }, /*#__PURE__*/_react.default.createElement(_UTBaseInputField.default, {
125
- type: "numeric",
126
150
  alwaysShowPlaceholder: true,
127
151
  dataTestId: phoneNumberDataTestId,
128
- disabled: withAreaCode && !isValidCode || disabled || readOnly,
129
- error: hasError && !areaCodeError,
130
- maxLength: withAreaCode ? maxLength - ((areaCode === null || areaCode === void 0 ? void 0 : areaCode.length) || 0) : maxLength,
131
- onBlur: onBlur,
132
- onChange: handleChangePhoneNumber,
133
- onFocus: onFocus,
134
- placeholder: placeholder,
152
+ disabled: disabled,
153
+ error: hasError && !areaCodeState.error,
135
154
  leftAdornments: countryCode && !withAreaCode ? [{
136
155
  name: _constants.COMPONENT_KEYS.PREFIX,
137
156
  props: {
138
157
  text: countryCode
139
158
  }
140
159
  }] : [],
160
+ maxLength: getPhoneNumberMaxLength(),
161
+ onBlur: onBlur,
162
+ onChange: handleChangePhoneNumber,
163
+ onFocus: onFocus,
164
+ placeholder: placeholder,
141
165
  rightAdornments: [{
142
166
  name: _constants.COMPONENT_KEYS.ICON,
143
167
  props: {
144
168
  changeOnError: true
145
169
  }
146
170
  }],
171
+ type: "numeric",
147
172
  value: phoneNumber
148
173
  }))), helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
149
174
  colorTheme: "gray",
@@ -97,7 +97,8 @@ const UTTextInput = _ref => {
97
97
  return adornments;
98
98
  }, [suffix, RightIcon, error, action, tooltip]);
99
99
  return /*#__PURE__*/_react.default.createElement("div", {
100
- className: "".concat(_stylesModule.default.container, " ").concat(classNames.container)
100
+ className: "".concat(_stylesModule.default.container, " ").concat(classNames.container),
101
+ "data-testid": dataTestId
101
102
  }, title && /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
102
103
  colorTheme: titleColorTheme,
103
104
  variant: _inputs.TITLE_VARIANTS[titleVariant],
@@ -105,7 +106,6 @@ const UTTextInput = _ref => {
105
106
  }, title), /*#__PURE__*/_react.default.createElement(_UTBaseInputField.default, {
106
107
  alwaysShowPlaceholder: alwaysShowPlaceholder,
107
108
  classNames: classNames,
108
- dataTestId: dataTestId,
109
109
  disabled: disabled,
110
110
  error: error,
111
111
  id: id,
@@ -17,6 +17,7 @@ const UTTouchableWithoutFeedback = _ref => {
17
17
  children,
18
18
  className,
19
19
  containerSetter,
20
+ dataTestId,
20
21
  disabled = false,
21
22
  keyName,
22
23
  onClick,
@@ -34,12 +35,13 @@ const UTTouchableWithoutFeedback = _ref => {
34
35
  }
35
36
  };
36
37
  return /*#__PURE__*/_react.default.createElement("div", _extends({}, props, {
37
- role: "button",
38
- onClick: handleClick,
38
+ "aria-disabled": disabled,
39
39
  className: "".concat(_stylesModule.default.container, " ").concat(className, " ").concat(disabled && _stylesModule.default.disabled),
40
+ "data-testid": dataTestId,
40
41
  key: keyName,
42
+ onClick: handleClick,
41
43
  ref: setRef,
42
- "aria-disabled": disabled,
44
+ role: "button",
43
45
  tabIndex: disabled ? -1 : 0
44
46
  }), children, /*#__PURE__*/_react.default.createElement(_UTRipple.default, {
45
47
  elem: buttonRef,
@@ -49,6 +51,7 @@ const UTTouchableWithoutFeedback = _ref => {
49
51
  UTTouchableWithoutFeedback.propTypes = {
50
52
  className: _propTypes.string,
51
53
  containerSetter: _propTypes.func,
54
+ dataTestId: _propTypes.string,
52
55
  disabled: _propTypes.bool,
53
56
  keyName: _propTypes.string,
54
57
  onClick: _propTypes.func,
@@ -20,12 +20,14 @@ const UTValidation = _ref => {
20
20
  let {
21
21
  classes,
22
22
  className,
23
+ dataTestId,
23
24
  validationData = []
24
25
  } = _ref;
25
26
  if ((0, _lodash.isEmpty)(validationData)) return null;
26
27
  const showIcon = status => _constants.STATUSES_WITH_ICON.includes(status);
27
28
  return /*#__PURE__*/_react.default.createElement("div", {
28
- className: "".concat(className, " ").concat(_stylesModule.default.container)
29
+ className: "".concat(className, " ").concat(_stylesModule.default.container),
30
+ "data-testid": dataTestId
29
31
  }, validationData.map((_ref2, index) => {
30
32
  let {
31
33
  items,
@@ -81,6 +83,7 @@ const validationDataProptypes = exports.validationDataProptypes = (0, _propTypes
81
83
  UTValidation.propTypes = {
82
84
  classes: (0, _propTypes.objectOf)(_propTypes.string),
83
85
  className: _propTypes.string,
86
+ dataTestId: _propTypes.string,
84
87
  validationData: validationDataProptypes
85
88
  };
86
89
  var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTValidation);
@@ -7,7 +7,6 @@
7
7
  padding: 16px;
8
8
  position: absolute;
9
9
  right: 16px;
10
- z-index: 9999;
11
10
  }
12
11
 
13
12
  .content {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.33.0",
3
+ "version": "3.33.1",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",