@widergy/energy-ui 3.43.0 → 3.44.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 +7 -0
- package/dist/components/UTBaseInputField/index.js +7 -6
- package/dist/components/UTBaseInputField/styles.module.scss +0 -6
- package/dist/components/UTBaseInputField/theme.js +46 -11
- package/dist/components/UTCBUInput/index.js +12 -81
- package/dist/components/UTCBUInput/versions/V0/index.js +95 -0
- package/dist/components/UTCBUInput/versions/V1/README.md +46 -0
- package/dist/components/UTCBUInput/versions/V1/index.js +70 -0
- package/dist/components/UTPhoneInput/versions/V1/README.md +0 -2
- package/dist/components/UTPhoneInput/versions/V1/index.js +9 -15
- package/dist/components/UTPhoneInput/versions/V1/styles.module.scss +5 -2
- package/dist/components/UTSelect/versions/V1/index.js +12 -0
- package/dist/components/UTTextInput/versions/V1/index.js +3 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- /package/dist/components/UTCBUInput/{theme.js → versions/V0/theme.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.44.0](https://github.com/widergy/energy-ui/compare/v3.43.0...v3.44.0) (2024-11-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* [UGB-2008] add UTCBUInput version V1 ([#532](https://github.com/widergy/energy-ui/issues/532)) ([8db24f6](https://github.com/widergy/energy-ui/commit/8db24f6fb2bb6f44ce215a11888f2279e808c4b5))
|
|
7
|
+
|
|
1
8
|
# [3.43.0](https://github.com/widergy/energy-ui/compare/v3.42.1...v3.43.0) (2024-11-14)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -20,7 +20,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
20
20
|
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); }
|
|
21
21
|
const UTBaseInputField = _ref => {
|
|
22
22
|
let {
|
|
23
|
-
alwaysShowPlaceholder,
|
|
24
23
|
classes: theme,
|
|
25
24
|
classNames = {},
|
|
26
25
|
dataTestId,
|
|
@@ -70,7 +69,6 @@ const UTBaseInputField = _ref => {
|
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
}, [type]);
|
|
73
|
-
const shouldShowPlaceholder = alwaysShowPlaceholder || focused;
|
|
74
72
|
const multiline = maxRows > 1;
|
|
75
73
|
const hasCharactersCount = (0, _react.useMemo)(() => showCharacterCount && maxLength && !disabled && !readOnly, [showCharacterCount, maxLength, disabled, readOnly]);
|
|
76
74
|
const validLeftAdornments = (0, _react.useMemo)(() => (0, _utils.validateAdornments)(leftAdornments) ? leftAdornments : [], [leftAdornments]);
|
|
@@ -91,11 +89,15 @@ const UTBaseInputField = _ref => {
|
|
|
91
89
|
})) : null;
|
|
92
90
|
}, [error, disabled, readOnly, focused]);
|
|
93
91
|
return /*#__PURE__*/_react.default.createElement(_TextField.default, _extends({
|
|
94
|
-
|
|
92
|
+
autocomplete: "new-password",
|
|
95
93
|
className: classes.container,
|
|
96
94
|
disabled: disabled || readOnly,
|
|
97
95
|
error: error,
|
|
96
|
+
form: {
|
|
97
|
+
autocomplete: 'off'
|
|
98
|
+
},
|
|
98
99
|
id: id,
|
|
100
|
+
inputRef: inputRef,
|
|
99
101
|
margin: "none",
|
|
100
102
|
maxRows: maxRows,
|
|
101
103
|
minRows: maxRows,
|
|
@@ -104,10 +106,9 @@ const UTBaseInputField = _ref => {
|
|
|
104
106
|
onChange: handleChange,
|
|
105
107
|
onFocus: handleFocus,
|
|
106
108
|
onKeyDown: handleKeyDown,
|
|
107
|
-
placeholder:
|
|
109
|
+
placeholder: placeholder,
|
|
108
110
|
type: type === 'numeric' ? 'text' : type,
|
|
109
111
|
value: value,
|
|
110
|
-
inputRef: inputRef,
|
|
111
112
|
variant: "outlined"
|
|
112
113
|
}, muiProps, {
|
|
113
114
|
InputProps: {
|
|
@@ -120,7 +121,7 @@ const UTBaseInputField = _ref => {
|
|
|
120
121
|
classes: {
|
|
121
122
|
adornedEnd: _stylesModule.default.elementsContainer,
|
|
122
123
|
adornedStart: _stylesModule.default.elementsContainer,
|
|
123
|
-
input:
|
|
124
|
+
input: classes.input,
|
|
124
125
|
notchedOutline: "".concat(classes.inputContainer, " ").concat(focused && classes.focusedInputContainer),
|
|
125
126
|
root: "".concat(classes.root, " ").concat(focused && classes.focusedRoot, " ").concat(value && classes.withValueRoot)
|
|
126
127
|
},
|
|
@@ -51,8 +51,21 @@ const getBorderColor = _ref2 => {
|
|
|
51
51
|
if (error) return "".concat(theme.Palette.error['04'], " !important");
|
|
52
52
|
return "".concat(theme.Palette.light['05'], " !important");
|
|
53
53
|
};
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const getBackgroundColorOnHover = _ref3 => {
|
|
55
|
+
let {
|
|
56
|
+
theme,
|
|
57
|
+
variant,
|
|
58
|
+
error,
|
|
59
|
+
readOnly
|
|
60
|
+
} = _ref3;
|
|
61
|
+
if (variant === 'gray') return theme.Palette.light['05'];
|
|
62
|
+
if (variant === 'transparent' && error) return theme.Palette.error['02'];
|
|
63
|
+
if (!readOnly) return theme.Palette.light['03'];
|
|
64
|
+
return undefined;
|
|
65
|
+
};
|
|
66
|
+
const retrieveStyle = _ref4 => {
|
|
67
|
+
let {
|
|
68
|
+
alwaysShowPlaceholder,
|
|
56
69
|
disabled: receivedDisabled,
|
|
57
70
|
error,
|
|
58
71
|
inputSize,
|
|
@@ -61,7 +74,7 @@ const retrieveStyle = props => {
|
|
|
61
74
|
showCharacterCount,
|
|
62
75
|
theme,
|
|
63
76
|
variant
|
|
64
|
-
} =
|
|
77
|
+
} = _ref4;
|
|
65
78
|
const disabled = receivedDisabled && !readOnly;
|
|
66
79
|
const hasCharactersCount = showCharacterCount && maxLength && !disabled && !readOnly;
|
|
67
80
|
const {
|
|
@@ -91,7 +104,27 @@ const retrieveStyle = props => {
|
|
|
91
104
|
paddingRight: 0
|
|
92
105
|
}),
|
|
93
106
|
'&:hover': {
|
|
94
|
-
backgroundColor:
|
|
107
|
+
backgroundColor: getBackgroundColorOnHover({
|
|
108
|
+
theme,
|
|
109
|
+
variant,
|
|
110
|
+
error,
|
|
111
|
+
readOnly
|
|
112
|
+
})
|
|
113
|
+
},
|
|
114
|
+
'&:active': {
|
|
115
|
+
...(!disabled && !readOnly && {
|
|
116
|
+
backgroundColor: theme.Palette.light['01'],
|
|
117
|
+
'& $inputContainer': {
|
|
118
|
+
borderColor: error ? "".concat(theme.Palette.error['04'], " !important") : "".concat(theme.Palette.accent['04'], " !important"),
|
|
119
|
+
borderWidth: '2px'
|
|
120
|
+
},
|
|
121
|
+
'& $input': {
|
|
122
|
+
'&::placeholder': {
|
|
123
|
+
color: "".concat(theme.Palette.gray['02'], " !important"),
|
|
124
|
+
opacity: 1
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
})
|
|
95
128
|
}
|
|
96
129
|
},
|
|
97
130
|
inputContainer: {
|
|
@@ -139,20 +172,22 @@ const retrieveStyle = props => {
|
|
|
139
172
|
textOverflow: 'ellipsis',
|
|
140
173
|
'&::placeholder': {
|
|
141
174
|
color: variant === 'transparent' && !disabled ? theme.Palette.dark['05'] : theme.Palette.gray['02'],
|
|
142
|
-
opacity: 1
|
|
175
|
+
opacity: alwaysShowPlaceholder ? 1 : 0,
|
|
176
|
+
transition: 'none',
|
|
177
|
+
userSelect: 'none'
|
|
143
178
|
},
|
|
144
179
|
'&::selection': {
|
|
145
180
|
backgroundColor: theme.Palette.accent['02']
|
|
146
181
|
},
|
|
182
|
+
'&:focus': {
|
|
183
|
+
'&::placeholder': {
|
|
184
|
+
color: "".concat(theme.Palette.gray['02'], " !important"),
|
|
185
|
+
opacity: 1
|
|
186
|
+
}
|
|
187
|
+
},
|
|
147
188
|
...(disabled && {
|
|
148
189
|
color: theme.Palette.gray['04']
|
|
149
190
|
})
|
|
150
|
-
},
|
|
151
|
-
focusedInput: {
|
|
152
|
-
'&::placeholder': {
|
|
153
|
-
color: theme.Palette.gray['02'],
|
|
154
|
-
opacity: 1
|
|
155
|
-
}
|
|
156
191
|
}
|
|
157
192
|
};
|
|
158
193
|
};
|
|
@@ -4,92 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = require("prop-types");
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _formTypes = require("../../types/formTypes");
|
|
12
|
-
var _theme = require("./theme");
|
|
9
|
+
var _V = _interopRequireDefault(require("./versions/V0"));
|
|
10
|
+
var _V2 = _interopRequireDefault(require("./versions/V1"));
|
|
13
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
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); }
|
|
15
|
-
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; }
|
|
16
12
|
const UTCBUInput = _ref => {
|
|
17
13
|
let {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
field,
|
|
21
|
-
helperTextDataTestId,
|
|
22
|
-
input,
|
|
23
|
-
meta
|
|
14
|
+
version = 'V0',
|
|
15
|
+
...props
|
|
24
16
|
} = _ref;
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
placeholder,
|
|
31
|
-
title,
|
|
32
|
-
configuration
|
|
33
|
-
} = field;
|
|
34
|
-
const {
|
|
35
|
-
entities,
|
|
36
|
-
cbu_number_key: cbuNumberKey,
|
|
37
|
-
cbu_entity_key: cbuEntityKey
|
|
38
|
-
} = configuration;
|
|
39
|
-
const [entity, setEntity] = (0, _react.useState)('');
|
|
40
|
-
const onChangeText = newValue => {
|
|
41
|
-
const index = entities.findIndex(entityValue => new RegExp(entityValue.expression).test(newValue));
|
|
42
|
-
const entityToSet = index === -1 ? '' : entities[index].entity_name;
|
|
43
|
-
setEntity(entityToSet);
|
|
44
|
-
onChange({
|
|
45
|
-
[cbuNumberKey]: newValue,
|
|
46
|
-
[cbuEntityKey]: entityToSet
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
return /*#__PURE__*/_react.default.createElement(_UTTextInput.default, {
|
|
50
|
-
captionLabel: entity,
|
|
51
|
-
dataTestId: dataTestId,
|
|
52
|
-
field: field,
|
|
53
|
-
FormHelperTextProps: {
|
|
54
|
-
classes: {
|
|
55
|
-
root: classes.helper
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
helperTextDataTestId: helperTextDataTestId,
|
|
59
|
-
input: {
|
|
60
|
-
onChange: onChangeText,
|
|
61
|
-
value: {
|
|
62
|
-
[cbuNumberKey]: value[cbuNumberKey],
|
|
63
|
-
[cbuEntityKey]: entity
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
inputObjectKey: cbuNumberKey,
|
|
67
|
-
label: title,
|
|
68
|
-
meta: meta,
|
|
69
|
-
placeholder: placeholder,
|
|
70
|
-
disabled: field === null || field === void 0 ? void 0 : field.read_only
|
|
71
|
-
});
|
|
17
|
+
const Component = {
|
|
18
|
+
V0: _V.default,
|
|
19
|
+
V1: _V2.default
|
|
20
|
+
}[version];
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(Component, props);
|
|
72
22
|
};
|
|
73
23
|
UTCBUInput.propTypes = {
|
|
74
|
-
|
|
75
|
-
dataTestId: _propTypes.string,
|
|
76
|
-
field: (0, _propTypes.shape)({
|
|
77
|
-
placeholder: _propTypes.string,
|
|
78
|
-
title: _propTypes.string,
|
|
79
|
-
configuration: (0, _propTypes.shape)({
|
|
80
|
-
entities: _propTypes.array
|
|
81
|
-
}),
|
|
82
|
-
cbu_number_key: _propTypes.string,
|
|
83
|
-
cbu_entity_key: _propTypes.string
|
|
84
|
-
}),
|
|
85
|
-
helperTextDataTestId: _propTypes.string,
|
|
86
|
-
input: (0, _propTypes.shape)({
|
|
87
|
-
onChange: _propTypes.func,
|
|
88
|
-
value: (0, _propTypes.shape)({
|
|
89
|
-
cbuNumber: _propTypes.string,
|
|
90
|
-
entityName: _propTypes.string
|
|
91
|
-
})
|
|
92
|
-
}),
|
|
93
|
-
meta: _formTypes.metaPropTypes
|
|
24
|
+
version: _propTypes.string
|
|
94
25
|
};
|
|
95
|
-
var _default = exports.default =
|
|
26
|
+
var _default = exports.default = UTCBUInput;
|
|
@@ -0,0 +1,95 @@
|
|
|
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 _formTypes = require("../../../../types/formTypes");
|
|
10
|
+
var _UTTextInput = _interopRequireDefault(require("../../../UTTextInput"));
|
|
11
|
+
var _WithTheme = _interopRequireDefault(require("../../../WithTheme"));
|
|
12
|
+
var _theme = require("./theme");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
const UTCBUInput = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
classes,
|
|
19
|
+
dataTestId,
|
|
20
|
+
field,
|
|
21
|
+
helperTextDataTestId,
|
|
22
|
+
input,
|
|
23
|
+
meta
|
|
24
|
+
} = _ref;
|
|
25
|
+
const {
|
|
26
|
+
onChange,
|
|
27
|
+
value
|
|
28
|
+
} = input;
|
|
29
|
+
const {
|
|
30
|
+
placeholder,
|
|
31
|
+
title,
|
|
32
|
+
configuration
|
|
33
|
+
} = field;
|
|
34
|
+
const {
|
|
35
|
+
entities,
|
|
36
|
+
cbu_number_key: cbuNumberKey,
|
|
37
|
+
cbu_entity_key: cbuEntityKey
|
|
38
|
+
} = configuration;
|
|
39
|
+
const [entity, setEntity] = (0, _react.useState)('');
|
|
40
|
+
const onChangeText = newValue => {
|
|
41
|
+
const index = entities.findIndex(entityValue => new RegExp(entityValue.expression).test(newValue));
|
|
42
|
+
const entityToSet = index === -1 ? '' : entities[index].entity_name;
|
|
43
|
+
setEntity(entityToSet);
|
|
44
|
+
onChange({
|
|
45
|
+
[cbuNumberKey]: newValue,
|
|
46
|
+
[cbuEntityKey]: entityToSet
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement(_UTTextInput.default, {
|
|
50
|
+
captionLabel: entity,
|
|
51
|
+
dataTestId: dataTestId,
|
|
52
|
+
field: field,
|
|
53
|
+
FormHelperTextProps: {
|
|
54
|
+
classes: {
|
|
55
|
+
root: classes.helper
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
helperTextDataTestId: helperTextDataTestId,
|
|
59
|
+
input: {
|
|
60
|
+
onChange: onChangeText,
|
|
61
|
+
value: {
|
|
62
|
+
[cbuNumberKey]: value[cbuNumberKey],
|
|
63
|
+
[cbuEntityKey]: entity
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
inputObjectKey: cbuNumberKey,
|
|
67
|
+
label: title,
|
|
68
|
+
meta: meta,
|
|
69
|
+
placeholder: placeholder,
|
|
70
|
+
disabled: field === null || field === void 0 ? void 0 : field.read_only
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
UTCBUInput.propTypes = {
|
|
74
|
+
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
75
|
+
dataTestId: _propTypes.string,
|
|
76
|
+
field: (0, _propTypes.shape)({
|
|
77
|
+
placeholder: _propTypes.string,
|
|
78
|
+
title: _propTypes.string,
|
|
79
|
+
configuration: (0, _propTypes.shape)({
|
|
80
|
+
entities: _propTypes.array
|
|
81
|
+
}),
|
|
82
|
+
cbu_number_key: _propTypes.string,
|
|
83
|
+
cbu_entity_key: _propTypes.string
|
|
84
|
+
}),
|
|
85
|
+
helperTextDataTestId: _propTypes.string,
|
|
86
|
+
input: (0, _propTypes.shape)({
|
|
87
|
+
onChange: _propTypes.func,
|
|
88
|
+
value: (0, _propTypes.shape)({
|
|
89
|
+
cbuNumber: _propTypes.string,
|
|
90
|
+
entityName: _propTypes.string
|
|
91
|
+
})
|
|
92
|
+
}),
|
|
93
|
+
meta: _formTypes.metaPropTypes
|
|
94
|
+
};
|
|
95
|
+
var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTCBUInput);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# UTCBUInput
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`UTCBUInput` is a configurable input component for handling CBU (Clave Bancaria Uniforme) numbers, often used in banking contexts. It allows users to input a CBU number and automatically detects the corresponding entity (e.g., bank name) based on predefined rules. The component provides validation feedback, supports error messages, and can be customized through various props.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Name | Type | Default | Description |
|
|
10
|
+
| ------------------- | -------------------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| entityConfiguration | shape({ cbu_number_key: string, cbu_entity_key: string, entities: array }) | | Configuration for handling CBU numbers, including keys for CBU number and entity, and entity list. |
|
|
12
|
+
| error | string | | Error message to display below the input field. |
|
|
13
|
+
| onChange | func | | Callback function triggered when the input value changes. Returns an object containing the CBU and entity. |
|
|
14
|
+
| value | shape({ cbuNumber: string, entityName: string }) | `{}` | Initial value for the CBU input. Expected format is an object with `cbuNumber` and `entityName`. |
|
|
15
|
+
| ...props | any | | Inherits all other props from `UTTextInput`. |
|
|
16
|
+
|
|
17
|
+
### Entity Configuration
|
|
18
|
+
|
|
19
|
+
The `entityConfiguration` prop defines the configuration for CBU numbers and includes the following keys:
|
|
20
|
+
|
|
21
|
+
- **cbu_number_key**: The key for accessing the CBU number within the `value` object.
|
|
22
|
+
- **cbu_entity_key**: The key for accessing the entity name within the `value` object.
|
|
23
|
+
- **entities**: An array of objects, each containing `expression` (a regex pattern to match the CBU) and `entity_name` (the name of the entity to display).
|
|
24
|
+
|
|
25
|
+
### Handling Errors and Validations
|
|
26
|
+
|
|
27
|
+
Errors and validations are managed through the `error` and `validations` props:
|
|
28
|
+
|
|
29
|
+
- The `error` prop will display an error message below the input if a validation fails.
|
|
30
|
+
- The `validations` prop displays the detected entity name in a validation format if the CBU is valid.
|
|
31
|
+
|
|
32
|
+
If the `error` prop is set, any entity-related validation message will be hidden, ensuring only one validation message appears at a time.
|
|
33
|
+
|
|
34
|
+
### Example Configuration for entityConfiguration
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
const fieldConfiguration = {
|
|
38
|
+
cbu_number_key: 'CBU',
|
|
39
|
+
cbu_entity_key: 'BANK',
|
|
40
|
+
entities: [
|
|
41
|
+
{ expression: '^005', entity_name: 'A.B.N. AMRO BANK N.V.' },
|
|
42
|
+
{ expression: '^006', entity_name: 'BANCO SUDAMERIS' }
|
|
43
|
+
// Additional entities...
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
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 _V = require("../../../UTTextInput/versions/V1");
|
|
10
|
+
var _UTTextInput = _interopRequireDefault(require("../../../UTTextInput"));
|
|
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
|
+
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); }
|
|
15
|
+
const UTCBUInput = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
cbu_entity_key: cbuEntityKey,
|
|
18
|
+
cbu_number_key: cbuNumberKey,
|
|
19
|
+
entities,
|
|
20
|
+
error,
|
|
21
|
+
onChange,
|
|
22
|
+
value = {},
|
|
23
|
+
...props
|
|
24
|
+
} = _ref;
|
|
25
|
+
const findEntity = input => {
|
|
26
|
+
const matchedEntity = entities.find(_ref2 => {
|
|
27
|
+
let {
|
|
28
|
+
expression
|
|
29
|
+
} = _ref2;
|
|
30
|
+
return new RegExp(expression).test(input);
|
|
31
|
+
});
|
|
32
|
+
return matchedEntity ? matchedEntity.entity_name : '';
|
|
33
|
+
};
|
|
34
|
+
const entity = (0, _react.useMemo)(() => findEntity(value[cbuNumberKey] || ''), [value, cbuNumberKey, entities]);
|
|
35
|
+
const validations = (0, _react.useMemo)(() => entity && !error ? [{
|
|
36
|
+
items: [{
|
|
37
|
+
text: entity,
|
|
38
|
+
withIcon: false
|
|
39
|
+
}]
|
|
40
|
+
}] : [], [entity, error]);
|
|
41
|
+
const onChangeText = newValue => {
|
|
42
|
+
const entityToSet = findEntity(newValue);
|
|
43
|
+
onChange({
|
|
44
|
+
[cbuNumberKey]: newValue,
|
|
45
|
+
[cbuEntityKey]: entityToSet
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return /*#__PURE__*/_react.default.createElement(_UTTextInput.default, _extends({}, props, {
|
|
49
|
+
error: error,
|
|
50
|
+
onBlur: undefined,
|
|
51
|
+
onChange: onChangeText,
|
|
52
|
+
type: "numeric",
|
|
53
|
+
validations: validations,
|
|
54
|
+
value: value[cbuNumberKey],
|
|
55
|
+
version: "V1"
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
UTCBUInput.propTypes = {
|
|
59
|
+
cbu_entity_key: _propTypes.string,
|
|
60
|
+
cbu_number_key: _propTypes.string,
|
|
61
|
+
entities: _propTypes.array,
|
|
62
|
+
error: _propTypes.string,
|
|
63
|
+
onChange: _propTypes.func,
|
|
64
|
+
value: (0, _propTypes.shape)({
|
|
65
|
+
cbuNumber: _propTypes.string,
|
|
66
|
+
entityName: _propTypes.string
|
|
67
|
+
}),
|
|
68
|
+
..._V.propTypes
|
|
69
|
+
};
|
|
70
|
+
var _default = exports.default = UTCBUInput;
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
| error | string | | Error message displayed below the input fields. |
|
|
16
16
|
| helpText | string | | Help text displayed below the input fields. |
|
|
17
17
|
| maxLength | number | 10 | Maximum number of characters allowed in the phone number input (excluding the area code). |
|
|
18
|
-
| onBlur | func | | Function called when either the area code or phone number input loses focus. |
|
|
19
18
|
| onChange | func | | Function called when either the area code or phone number value changes. Should handle concatenated values (`areaCode-phoneNumber`). |
|
|
20
|
-
| onFocus | func | | Function called when either the area code or phone number input gains focus. |
|
|
21
19
|
| phoneNumberDataTestId | string | | Identifier for the phone number input field, useful for testing. |
|
|
22
20
|
| placeholder | string | | Placeholder text displayed in the phone number input when it's empty. |
|
|
23
21
|
| readOnly | bool | false | Makes the area code and phone number input fields read-only. |
|
|
@@ -27,9 +27,7 @@ const UTPhoneInput = _ref => {
|
|
|
27
27
|
error,
|
|
28
28
|
helpText,
|
|
29
29
|
maxLength = 10,
|
|
30
|
-
onBlur,
|
|
31
30
|
onChange,
|
|
32
|
-
onFocus,
|
|
33
31
|
phoneNumberDataTestId,
|
|
34
32
|
placeholder,
|
|
35
33
|
readOnly,
|
|
@@ -82,7 +80,6 @@ const UTPhoneInput = _ref => {
|
|
|
82
80
|
error: validationError
|
|
83
81
|
}));
|
|
84
82
|
setBlurWithError(!!validationError);
|
|
85
|
-
onBlur === null || onBlur === void 0 || onBlur();
|
|
86
83
|
};
|
|
87
84
|
(0, _react.useEffect)(() => {
|
|
88
85
|
if (blurWithError) {
|
|
@@ -123,9 +120,7 @@ const UTPhoneInput = _ref => {
|
|
|
123
120
|
variant: _inputs.TITLE_VARIANTS[titleVariant]
|
|
124
121
|
}, title), /*#__PURE__*/_react.default.createElement("div", {
|
|
125
122
|
className: _stylesModule.default.inputsContainer
|
|
126
|
-
}, withAreaCode && /*#__PURE__*/_react.default.createElement(
|
|
127
|
-
className: _stylesModule.default.areaCodeContainer
|
|
128
|
-
}, /*#__PURE__*/_react.default.createElement(_UTBaseInputField.default, {
|
|
123
|
+
}, withAreaCode && /*#__PURE__*/_react.default.createElement(_UTBaseInputField.default, {
|
|
129
124
|
type: "numeric",
|
|
130
125
|
alwaysShowPlaceholder: true,
|
|
131
126
|
dataTestId: areaCodeDataTestId,
|
|
@@ -134,9 +129,11 @@ const UTPhoneInput = _ref => {
|
|
|
134
129
|
maxLength: getAreaCodeMaxLength(),
|
|
135
130
|
onBlur: handleOnBlur,
|
|
136
131
|
onChange: handleChangeAreaCode,
|
|
137
|
-
onFocus: onFocus,
|
|
138
132
|
placeholder: areaCodePlaceholder,
|
|
139
133
|
readOnly: readOnly,
|
|
134
|
+
classNames: {
|
|
135
|
+
container: _stylesModule.default.areaCodeContainer
|
|
136
|
+
},
|
|
140
137
|
rightAdornments: [{
|
|
141
138
|
name: _constants.COMPONENT_KEYS.ICON,
|
|
142
139
|
props: {
|
|
@@ -144,9 +141,7 @@ const UTPhoneInput = _ref => {
|
|
|
144
141
|
}
|
|
145
142
|
}],
|
|
146
143
|
value: areaCodeState.code
|
|
147
|
-
})
|
|
148
|
-
className: _stylesModule.default.phoneContainer
|
|
149
|
-
}, /*#__PURE__*/_react.default.createElement(_UTBaseInputField.default, {
|
|
144
|
+
}), /*#__PURE__*/_react.default.createElement(_UTBaseInputField.default, {
|
|
150
145
|
alwaysShowPlaceholder: true,
|
|
151
146
|
dataTestId: phoneNumberDataTestId,
|
|
152
147
|
disabled: disabled,
|
|
@@ -157,10 +152,11 @@ const UTPhoneInput = _ref => {
|
|
|
157
152
|
text: countryCode
|
|
158
153
|
}
|
|
159
154
|
}] : [],
|
|
155
|
+
classNames: {
|
|
156
|
+
container: _stylesModule.default.phoneContainer
|
|
157
|
+
},
|
|
160
158
|
maxLength: getPhoneNumberMaxLength(),
|
|
161
|
-
onBlur: onBlur,
|
|
162
159
|
onChange: handleChangePhoneNumber,
|
|
163
|
-
onFocus: onFocus,
|
|
164
160
|
placeholder: placeholder,
|
|
165
161
|
rightAdornments: [{
|
|
166
162
|
name: _constants.COMPONENT_KEYS.ICON,
|
|
@@ -170,7 +166,7 @@ const UTPhoneInput = _ref => {
|
|
|
170
166
|
}],
|
|
171
167
|
type: "numeric",
|
|
172
168
|
value: phoneNumber
|
|
173
|
-
}))
|
|
169
|
+
})), helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
174
170
|
colorTheme: "gray",
|
|
175
171
|
variant: "small"
|
|
176
172
|
}, helpText), validationData && /*#__PURE__*/_react.default.createElement(_UTValidation.default, {
|
|
@@ -185,9 +181,7 @@ UTPhoneInput.propTypes = {
|
|
|
185
181
|
error: _propTypes.string,
|
|
186
182
|
helpText: _propTypes.string,
|
|
187
183
|
maxLength: _propTypes.number,
|
|
188
|
-
onBlur: _propTypes.func,
|
|
189
184
|
onChange: _propTypes.func,
|
|
190
|
-
onFocus: _propTypes.func,
|
|
191
185
|
phoneNumberDataTestId: _propTypes.string,
|
|
192
186
|
placeholder: _propTypes.string,
|
|
193
187
|
readOnly: _propTypes.bool,
|
|
@@ -66,6 +66,18 @@ const UTSelect = _ref => {
|
|
|
66
66
|
setSortedOptions((0, _utils2.sortOptions)(optionsSortedByCategory, null, multiple));
|
|
67
67
|
}
|
|
68
68
|
}, [multiple, onChange, optionsSortedByCategory, value, withAutoReset]);
|
|
69
|
+
(0, _react.useEffect)(() => {
|
|
70
|
+
if (!isPopperOpen) {
|
|
71
|
+
const displayValue = (0, _utils2.getDisplayValue)(value, optionsSortedByCategory, multiple);
|
|
72
|
+
setSearchTerm(displayValue);
|
|
73
|
+
setShowClearButton(displayValue);
|
|
74
|
+
}
|
|
75
|
+
}, [value, optionsSortedByCategory, multiple, isPopperOpen]);
|
|
76
|
+
(0, _react.useEffect)(() => {
|
|
77
|
+
if (isPopperOpen) {
|
|
78
|
+
setSortedOptions((0, _utils2.sortOptions)(optionsSortedByCategory, value, multiple));
|
|
79
|
+
}
|
|
80
|
+
}, [optionsSortedByCategory]);
|
|
69
81
|
(0, _react.useEffect)(() => {
|
|
70
82
|
setSortedOptions((0, _utils2.sortOptions)(optionsSortedByCategory, value, multiple));
|
|
71
83
|
}, []);
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.propTypes = exports.default = void 0;
|
|
7
7
|
var _propTypes = require("prop-types");
|
|
8
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
10
|
var _constants = require("../../../UTBaseInputField/constants");
|
|
10
11
|
var _utils = require("../../../UTValidation/utils");
|
|
@@ -14,9 +15,9 @@ var _UTFieldLabel = _interopRequireDefault(require("../../../UTFieldLabel"));
|
|
|
14
15
|
var _UTLabel = _interopRequireDefault(require("../../../UTLabel"));
|
|
15
16
|
var _UTValidation = _interopRequireWildcard(require("../../../UTValidation"));
|
|
16
17
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
18
|
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); }
|
|
19
19
|
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; }
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
21
|
const UTTextInput = _ref => {
|
|
21
22
|
let {
|
|
22
23
|
action,
|
|
@@ -53,7 +54,7 @@ const UTTextInput = _ref => {
|
|
|
53
54
|
value = null
|
|
54
55
|
} = _ref;
|
|
55
56
|
const titleColorTheme = readOnly ? 'gray' : 'dark';
|
|
56
|
-
const validationData = (0, _react.useMemo)(() => validations
|
|
57
|
+
const validationData = (0, _react.useMemo)(() => !(0, _isEmpty.default)(validations) ? validations : error && (0, _utils.formatErrorToValidation)(error), [error, validations]);
|
|
57
58
|
const leftAdornments = (0, _react.useMemo)(() => {
|
|
58
59
|
const adornments = [];
|
|
59
60
|
if (LeftIcon) adornments.push({
|
package/dist/index.js
CHANGED
|
@@ -479,9 +479,9 @@ var _UTPanel = _interopRequireDefault(require("./components/UTPanel"));
|
|
|
479
479
|
var _UTPasswordField = _interopRequireDefault(require("./components/UTPasswordField"));
|
|
480
480
|
var _UTPhoneInput = _interopRequireDefault(require("./components/UTPhoneInput"));
|
|
481
481
|
var _UTPieChart = _interopRequireDefault(require("./components/UTPieChart"));
|
|
482
|
+
var _UTPopUp = _interopRequireDefault(require("./components/UTPopUp"));
|
|
482
483
|
var _UTProductItem = _interopRequireDefault(require("./components/UTProductItem"));
|
|
483
484
|
var _UTProgressBar = _interopRequireDefault(require("./components/UTProgressBar"));
|
|
484
|
-
var _UTPopUp = _interopRequireDefault(require("./components/UTPopUp"));
|
|
485
485
|
var _UTRadioGroup = _interopRequireDefault(require("./components/UTRadioGroup"));
|
|
486
486
|
var _UTRating = _interopRequireDefault(require("./components/UTRating"));
|
|
487
487
|
var _UTSearchField = _interopRequireDefault(require("./components/UTSearchField"));
|
package/package.json
CHANGED
|
File without changes
|