@widergy/energy-ui 3.22.4 → 3.23.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/UTActionCard/README.md +2 -2
  3. package/dist/components/UTActionCard/components/AdditionalMessage/index.js +3 -1
  4. package/dist/components/UTActionCard/components/BottomActions/index.js +5 -3
  5. package/dist/components/UTActionCard/components/BottomActions/styles.module.scss +4 -0
  6. package/dist/components/UTActionCard/components/Header/constants.js +14 -1
  7. package/dist/components/UTActionCard/components/Header/index.js +5 -3
  8. package/dist/components/UTActionCard/components/Header/styles.module.scss +6 -8
  9. package/dist/components/UTActionCard/components/HeaderActions/index.js +9 -6
  10. package/dist/components/UTActionCard/components/HeaderActions/utils.js +26 -15
  11. package/dist/components/UTActionCard/index.js +7 -9
  12. package/dist/components/UTFieldLabel/constants.js +7 -0
  13. package/dist/components/UTFieldLabel/index.js +43 -0
  14. package/dist/components/UTFieldLabel/styles.module.scss +5 -0
  15. package/dist/components/UTIcon/styles.module.scss +0 -1
  16. package/dist/components/UTLabel/theme.js +24 -8
  17. package/dist/components/UTTextArea/index.js +11 -87
  18. package/dist/components/UTTextArea/versions/V0/index.js +102 -0
  19. package/dist/components/UTTextArea/{theme.js → versions/V0/theme.js} +1 -1
  20. package/dist/components/UTTextArea/versions/V1/README.md +33 -0
  21. package/dist/components/UTTextArea/versions/V1/index.js +18 -0
  22. package/dist/components/UTTextInput/index.js +15 -200
  23. package/dist/components/UTTextInput/versions/V0/index.js +211 -0
  24. package/dist/components/UTTextInput/{styles.module.scss → versions/V0/styles.module.scss} +1 -1
  25. package/dist/components/UTTextInput/{theme.js → versions/V0/theme.js} +1 -1
  26. package/dist/components/UTTextInput/versions/V1/README.md +85 -0
  27. package/dist/components/UTTextInput/versions/V1/components/ActionAdornment/index.js +31 -0
  28. package/dist/components/UTTextInput/versions/V1/components/IconAdornment/constants.js +8 -0
  29. package/dist/components/UTTextInput/versions/V1/components/IconAdornment/index.js +48 -0
  30. package/dist/components/UTTextInput/versions/V1/components/IconAdornment/utils.js +17 -0
  31. package/dist/components/UTTextInput/versions/V1/components/PrefixAdornment/index.js +24 -0
  32. package/dist/components/UTTextInput/versions/V1/components/SuffixAdornment/index.js +22 -0
  33. package/dist/components/UTTextInput/versions/V1/components/TooltipAdornment/index.js +26 -0
  34. package/dist/components/UTTextInput/versions/V1/index.js +177 -0
  35. package/dist/components/UTTextInput/versions/V1/styles.module.scss +29 -0
  36. package/dist/components/UTTextInput/versions/V1/theme.js +94 -0
  37. package/dist/components/UTValidation/README.md +68 -0
  38. package/dist/components/UTValidation/constants.js +27 -0
  39. package/dist/components/UTValidation/index.js +86 -0
  40. package/dist/components/UTValidation/styles.module.scss +33 -0
  41. package/dist/components/UTValidation/theme.js +25 -0
  42. package/dist/components/UTValidation/utils.js +23 -0
  43. package/dist/index.js +7 -0
  44. package/package.json +1 -1
  45. package/dist/components/UTActionCard/components/HeaderActions/constants.js +0 -7
  46. /package/dist/components/UTTextArea/{constants.js → versions/V0/constants.js} +0 -0
  47. /package/dist/components/UTTextArea/{styles.module.scss → versions/V0/styles.module.scss} +0 -0
  48. /package/dist/components/UTTextInput/{constants.js → versions/V0/constants.js} +0 -0
@@ -0,0 +1,85 @@
1
+ # UTTextInput
2
+
3
+ ## Description
4
+
5
+ `UTTextInput` is a configurable text input component that supports various customization options such as icons, validation messages, and action buttons. This component is based on Material UI and can be adapted for both single-line inputs and multi-line text areas.
6
+
7
+ ## Props
8
+
9
+ | Name | Type | Default | Description |
10
+ | --------------------- | --------------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------- |
11
+ | action | object | | Configuration for the action button that appears at the end of the input. |
12
+ | alwaysShowPlaceholder | bool | false | Whether the placeholder should always be displayed, even when the input is focused. |
13
+ | blurOnSubmit | bool | false | Whether the input should lose focus after submitting (e.g., after pressing "Enter"). |
14
+ | classNames | objectOf(string) | | Additional classes for customizing the component, independent of Material-UI. |
15
+ | disabled | bool | false | Disables the input field. |
16
+ | error | string | | Error message displayed below the input field. |
17
+ | helpText | string | | Help text displayed below the input field. |
18
+ | id | string | | Unique identifier for the input field. |
19
+ | inputRef | oneOfType([func, object]) | | Reference to the input field to access methods like `focus`, `blur`, or `clear`. |
20
+ | inputSize | string | 'large' | Size of the input field. One of: `small`, `large`. |
21
+ | maxLength | number | | Maximum number of characters allowed in the input field. |
22
+ | maxRows | number | 1 | Maximum number of rows the text area can display. If greater than 1, the input becomes a text area. |
23
+ | onBlur | func | | Function called when the input field loses focus. |
24
+ | onChange | func | | Function called when the input field value changes. |
25
+ | onFocus | func | | Function called when the input field gains focus. |
26
+ | onSubmitEditing | func | | Function called when the input field is submitted (e.g., pressing Enter on a keyboard). |
27
+ | placeholder | string | | Placeholder text displayed when the input field is empty. |
28
+ | prefix | string | | Text displayed before the entered value in the input field. |
29
+ | readOnly | bool | false | Makes the input field read-only. |
30
+ | required | bool | false | Marks the input field as required. |
31
+ | returnKeyType | string | 'done' | Determines the return key type on the keyboard (e.g., `done`, `next`). |
32
+ | RightIcon | elementType | | Icon displayed on the right side of the input field. |
33
+ | showCharacterCount | bool | false | Whether the character count should be displayed (if `maxLength` is defined). |
34
+ | style | shape({ container: object, input: object, root: object }) | | Style object to customize the input field. Can contain `root`, `container`, `input`, or `action` styles. |
35
+ | suffix | string | | Suffix text to be displayed after the entered value in the input field. |
36
+ | title | string | | Title displayed above the input field. |
37
+ | titleVariant | string | 'large' | Variant of the title, can be `small` or `large`. |
38
+ | tooltip | string | | Tooltip text displayed next to the input field. |
39
+ | type | string | 'text' | Type of input field (e.g., 'text', 'password'). |
40
+ | validations | object | | Object containing validation rules to be applied to the input field. |
41
+ | value | string | '' | Current value of the input field. |
42
+
43
+ ### action
44
+
45
+ The `action` object allows configuring the action button that appears inside the input field, such as a clear or submit icon.
46
+
47
+ | Name | Type | Description |
48
+ | -------- | ----------- | -------------------------------------------------- |
49
+ | icon | elementType | Icon to be displayed in the action button. |
50
+ | onClick | func | Function called when the action button is clicked. |
51
+ | disabled | bool | Disables the action button. |
52
+ | text | string | Text displayed inside the action button, if any. |
53
+
54
+ ### titleVariant
55
+
56
+ The value of `titleVariant` must be one of the following:
57
+
58
+ - "small"
59
+ - "large"
60
+
61
+ ### inputSize
62
+
63
+ The value of `inputSize` must be one of the following:
64
+
65
+ - "small"
66
+ - "large"
67
+
68
+ ### type
69
+
70
+ The value of `type` must be one of the following:
71
+
72
+ - "text"
73
+ - "password"
74
+
75
+ ### Right Icon
76
+
77
+ If a `RightIcon` is provided and an error occurs, the `RightIcon` will be replaced by an error icon.
78
+
79
+ ### Structure of Validations
80
+
81
+ For detailed information about the structure of validations, please refer to the UTValidation component documentation.
82
+
83
+ ### Handling Errors
84
+
85
+ Errors can be displayed below the text input using either the `error` prop or the `validations` prop.
@@ -0,0 +1,31 @@
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
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ 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); }
12
+ const ActionAdornment = _ref => {
13
+ let {
14
+ action = {},
15
+ disabled,
16
+ classNames
17
+ } = _ref;
18
+ if (!action) return null;
19
+ return /*#__PURE__*/_react.default.createElement(_UTButton.default, _extends({
20
+ disabled: disabled,
21
+ classNames: classNames,
22
+ variant: "text",
23
+ size: "small"
24
+ }, action), action.text);
25
+ };
26
+ ActionAdornment.propTypes = {
27
+ action: _propTypes.object,
28
+ classNames: (0, _propTypes.objectOf)(_propTypes.string),
29
+ disabled: _propTypes.bool
30
+ };
31
+ var _default = exports.default = ActionAdornment;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ICON_SIZE = exports.ERROR_ICON = void 0;
7
+ const ERROR_ICON = exports.ERROR_ICON = 'IconAlertCircle';
8
+ const ICON_SIZE = exports.ICON_SIZE = 20;
@@ -0,0 +1,48 @@
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 _UTIcon = _interopRequireDefault(require("../../../../../UTIcon"));
10
+ var _componentUtils = require("../../../../../../utils/componentUtils");
11
+ var _constants = require("./constants");
12
+ var _utils = require("./utils");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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 IconAdornment = _ref => {
16
+ let {
17
+ changeOnError = false,
18
+ changeOnFocus = false,
19
+ colorTheme,
20
+ error,
21
+ focused,
22
+ Icon,
23
+ inputStyle,
24
+ shade
25
+ } = _ref;
26
+ const IconToRender = error && changeOnError ? _constants.ERROR_ICON : Icon;
27
+ if (!IconToRender) return null;
28
+ return (0, _componentUtils.isUTIcon)(IconToRender) ? /*#__PURE__*/_react.default.createElement(_UTIcon.default, _extends({
29
+ name: IconToRender,
30
+ size: _constants.ICON_SIZE
31
+ }, (0, _utils.getIconColorProps)(changeOnError, changeOnFocus, colorTheme, error, focused, shade))) : /*#__PURE__*/_react.default.createElement(Icon, {
32
+ size: _constants.ICON_SIZE,
33
+ fill: inputStyle.root.color
34
+ });
35
+ };
36
+ IconAdornment.propTypes = {
37
+ changeOnError: _propTypes.bool,
38
+ changeOnFocus: _propTypes.bool,
39
+ colorTheme: _propTypes.string,
40
+ error: (0, _propTypes.oneOfType)([_propTypes.bool, _propTypes.string]),
41
+ focused: _propTypes.bool,
42
+ Icon: _propTypes.elementType,
43
+ inputStyle: (0, _propTypes.shape)({
44
+ root: _propTypes.object
45
+ }),
46
+ shade: _propTypes.string
47
+ };
48
+ var _default = exports.default = IconAdornment;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getIconColorProps = void 0;
7
+ const getIconColorProps = (changeOnError, changeOnFocus, colorTheme, error, focused, shade) => changeOnError && error ? {
8
+ colorTheme: 'error',
9
+ shade: '04'
10
+ } : changeOnFocus && focused ? {
11
+ colorTheme: 'accent',
12
+ shade: '04'
13
+ } : {
14
+ colorTheme: colorTheme || 'gray',
15
+ shade
16
+ };
17
+ exports.getIconColorProps = getIconColorProps;
@@ -0,0 +1,24 @@
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
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const PrefixAdornment = _ref => {
12
+ let {
13
+ text
14
+ } = _ref;
15
+ return /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
16
+ colorTheme: "gray",
17
+ variant: "small",
18
+ weight: "medium"
19
+ }, text);
20
+ };
21
+ PrefixAdornment.propTypes = {
22
+ text: _propTypes.string
23
+ };
24
+ var _default = exports.default = PrefixAdornment;
@@ -0,0 +1,22 @@
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
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const SuffixAdornment = _ref => {
12
+ let {
13
+ text
14
+ } = _ref;
15
+ return /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
16
+ colorTheme: "gray"
17
+ }, text);
18
+ };
19
+ SuffixAdornment.propTypes = {
20
+ text: _propTypes.string
21
+ };
22
+ var _default = exports.default = SuffixAdornment;
@@ -0,0 +1,26 @@
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 _UTTooltip = _interopRequireDefault(require("../../../../../UTTooltip"));
10
+ var _UTIcon = _interopRequireDefault(require("../../../../../UTIcon"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const TooltipAdornment = _ref => {
13
+ let {
14
+ tooltip
15
+ } = _ref;
16
+ return /*#__PURE__*/_react.default.createElement(_UTTooltip.default, {
17
+ content: tooltip
18
+ }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
19
+ name: "IconInfoCircle",
20
+ colorTheme: "gray"
21
+ })));
22
+ };
23
+ TooltipAdornment.propTypes = {
24
+ tooltip: _propTypes.string
25
+ };
26
+ var _default = exports.default = TooltipAdornment;
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.propTypes = exports.default = void 0;
7
+ var _propTypes = require("prop-types");
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
10
+ var _utils = require("../../../UTValidation/utils");
11
+ var _classesUtils = require("../../../../utils/classesUtils");
12
+ var _UTValidation = _interopRequireWildcard(require("../../../UTValidation"));
13
+ var _UTFieldLabel = _interopRequireDefault(require("../../../UTFieldLabel"));
14
+ var _UTLabel = _interopRequireDefault(require("../../../UTLabel"));
15
+ var _WithTheme = _interopRequireDefault(require("../../../WithTheme"));
16
+ var _theme = require("./theme");
17
+ var _ActionAdornment = _interopRequireDefault(require("./components/ActionAdornment"));
18
+ var _IconAdornment = _interopRequireDefault(require("./components/IconAdornment"));
19
+ var _PrefixAdornment = _interopRequireDefault(require("./components/PrefixAdornment"));
20
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
21
+ var _SuffixAdornment = _interopRequireDefault(require("./components/SuffixAdornment"));
22
+ var _TooltipAdornment = _interopRequireDefault(require("./components/TooltipAdornment"));
23
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
+ 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); }
25
+ 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; }
26
+ const UTTextInput = _ref => {
27
+ let {
28
+ action,
29
+ alwaysShowPlaceholder,
30
+ classes: theme,
31
+ classNames = {},
32
+ disabled,
33
+ error,
34
+ helpText,
35
+ id,
36
+ LeftIcon,
37
+ maxLength,
38
+ maxRows = 1,
39
+ onBlur,
40
+ onChange = () => {},
41
+ onFocus,
42
+ placeholder,
43
+ prefix,
44
+ readOnly,
45
+ required,
46
+ RightIcon,
47
+ showCharacterCount,
48
+ suffix,
49
+ title,
50
+ titleVariant = 'large',
51
+ tooltip,
52
+ type,
53
+ validations,
54
+ value = null
55
+ } = _ref;
56
+ const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(theme, classNames), [classNames, theme]);
57
+ const [focused, setFocused] = (0, _react.useState)(false);
58
+ const handleFocus = event => {
59
+ setFocused(true);
60
+ onFocus === null || onFocus === void 0 || onFocus(event);
61
+ };
62
+ const handleBlur = event => {
63
+ setFocused(false);
64
+ onBlur === null || onBlur === void 0 || onBlur(event);
65
+ };
66
+ const handleChange = event => {
67
+ onChange === null || onChange === void 0 || onChange(event.target.value);
68
+ };
69
+ const titleColorTheme = readOnly ? 'gray' : 'dark';
70
+ const titleComponentVariant = titleVariant === 'small' ? 'small' : 'body';
71
+ const shouldShowPlaceholder = alwaysShowPlaceholder || focused;
72
+ const validationData = (0, _react.useMemo)(() => validations || error && (0, _utils.formatErrorToValidation)(error), [error, validations]);
73
+ const multiline = maxRows > 1;
74
+ const hasStartAdornments = LeftIcon || prefix;
75
+ const hasCharactersCount = showCharacterCount && maxLength && !disabled && !readOnly;
76
+ const hasEndAdornments = suffix || RightIcon || action || tooltip || error;
77
+ return /*#__PURE__*/_react.default.createElement("div", {
78
+ className: "".concat(_stylesModule.default.container, " ").concat(classes.container)
79
+ }, title && /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
80
+ colorTheme: titleColorTheme,
81
+ variant: titleComponentVariant,
82
+ required: required
83
+ }, title), /*#__PURE__*/_react.default.createElement(_TextField.default, {
84
+ margin: "none",
85
+ autoComplete: "new-password" // in the new MUI's version, the autocomplete='off' doesn't work for Chrome, please use this instead
86
+ ,
87
+ disabled: disabled || readOnly,
88
+ error: error,
89
+ id: id,
90
+ maxRows: maxRows,
91
+ minRows: maxRows,
92
+ multiline: multiline,
93
+ onBlur: handleBlur,
94
+ onChange: handleChange,
95
+ onFocus: handleFocus,
96
+ placeholder: shouldShowPlaceholder ? placeholder : '',
97
+ type: type,
98
+ value: value,
99
+ variant: "outlined",
100
+ InputProps: {
101
+ inputProps: {
102
+ maxLength
103
+ },
104
+ classes: {
105
+ notchedOutline: "".concat(classes.inputContainer, " ").concat(focused && classes.focusedInputContainer),
106
+ adornedStart: _stylesModule.default.elementsContainer,
107
+ adornedEnd: _stylesModule.default.elementsContainer,
108
+ input: classes.input,
109
+ root: classes.root
110
+ },
111
+ startAdornment: hasStartAdornments ? /*#__PURE__*/_react.default.createElement("div", {
112
+ className: _stylesModule.default.adornmentsContainer
113
+ }, LeftIcon && /*#__PURE__*/_react.default.createElement(_IconAdornment.default, {
114
+ Icon: LeftIcon
115
+ }), prefix && /*#__PURE__*/_react.default.createElement(_PrefixAdornment.default, {
116
+ text: prefix
117
+ })) : hasCharactersCount && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
118
+ className: classes.charactersCount,
119
+ colorTheme: "gray",
120
+ variant: "small"
121
+ }, (value === null || value === void 0 ? void 0 : value.length) || 0, "/", maxLength),
122
+ endAdornment: hasEndAdornments && /*#__PURE__*/_react.default.createElement("div", {
123
+ className: "".concat(_stylesModule.default.adornmentsContainer, " ").concat(multiline && _stylesModule.default.multilineAdornmentsContainer)
124
+ }, suffix && /*#__PURE__*/_react.default.createElement(_SuffixAdornment.default, {
125
+ text: suffix
126
+ }), RightIcon && /*#__PURE__*/_react.default.createElement(_IconAdornment.default, {
127
+ changeOnError: true,
128
+ error: error,
129
+ Icon: RightIcon
130
+ }), action && /*#__PURE__*/_react.default.createElement(_ActionAdornment.default, {
131
+ action: action,
132
+ classNames: {
133
+ root: _stylesModule.default.actionButton
134
+ },
135
+ disabled: disabled && !readOnly
136
+ }), tooltip && /*#__PURE__*/_react.default.createElement(_TooltipAdornment.default, {
137
+ tooltip: tooltip
138
+ }))
139
+ }
140
+ }), helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
141
+ colorTheme: "gray",
142
+ variant: "small"
143
+ }, helpText), validationData && /*#__PURE__*/_react.default.createElement(_UTValidation.default, {
144
+ validationData: validationData
145
+ }));
146
+ };
147
+ const propTypes = exports.propTypes = {
148
+ action: _propTypes.elementType,
149
+ alwaysShowPlaceholder: _propTypes.bool,
150
+ classes: (0, _propTypes.objectOf)(_propTypes.string),
151
+ classNames: (0, _propTypes.objectOf)(_propTypes.string),
152
+ disabled: _propTypes.bool,
153
+ error: _propTypes.bool,
154
+ helpText: _propTypes.string,
155
+ id: _propTypes.string,
156
+ LeftIcon: _propTypes.elementType,
157
+ maxLength: _propTypes.number,
158
+ maxRows: _propTypes.number,
159
+ onBlur: _propTypes.func,
160
+ onChange: _propTypes.func,
161
+ onFocus: _propTypes.func,
162
+ placeholder: _propTypes.string,
163
+ prefix: _propTypes.string,
164
+ readOnly: _propTypes.bool,
165
+ required: _propTypes.bool,
166
+ RightIcon: _propTypes.elementType,
167
+ showCharacterCount: _propTypes.bool,
168
+ suffix: _propTypes.string,
169
+ title: _propTypes.string,
170
+ titleVariant: _propTypes.string,
171
+ tooltip: _propTypes.string,
172
+ type: _propTypes.string,
173
+ validations: _UTValidation.validationDataProptypes,
174
+ value: _propTypes.string
175
+ };
176
+ UTTextInput.propTypes = propTypes;
177
+ var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTTextInput);
@@ -0,0 +1,29 @@
1
+ .actionButton {
2
+ margin: -4px !important;
3
+ }
4
+
5
+ .adornmentsContainer {
6
+ align-items: center;
7
+ display: flex;
8
+ flex-shrink: 0;
9
+ grid-gap: 16px;
10
+ }
11
+
12
+ .container {
13
+ display: flex;
14
+ flex-direction: column;
15
+ grid-gap: 8px;
16
+ }
17
+
18
+ .elementsContainer {
19
+ grid-gap: 16px;
20
+ }
21
+
22
+ .multilineAdornmentsContainer {
23
+ place-self: start;
24
+ }
25
+
26
+ .startAdornments {
27
+ display: flex;
28
+ flex-direction: column;
29
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.retrieveStyle = void 0;
7
+ var _theme = require("../../../UTLabel/theme");
8
+ const charactersCountRowHeight = 20;
9
+ const PADDING = {
10
+ HORIZONTAL: 16,
11
+ VERTICAL: 12
12
+ };
13
+ const SMALL_PADDING = {
14
+ HORIZONTAL: 12,
15
+ VERTICAL: 8
16
+ };
17
+ const GRID_GAP = 16;
18
+ const retrieveStyle = _ref => {
19
+ let {
20
+ theme,
21
+ inputSize,
22
+ error,
23
+ disabled: receivedDisabled,
24
+ readOnly,
25
+ showCharacterCount,
26
+ maxLength
27
+ } = _ref;
28
+ const disabled = receivedDisabled && !readOnly;
29
+ const verticalPadding = "".concat(inputSize === 'small' ? SMALL_PADDING.VERTICAL : PADDING.VERTICAL, "px");
30
+ const multilineVerticalPadding = "".concat((inputSize === 'small' ? SMALL_PADDING.VERTICAL : PADDING.VERTICAL) + GRID_GAP + charactersCountRowHeight, "px");
31
+ const horizontalPadding = "".concat(inputSize === 'small' ? SMALL_PADDING.HORIZONTAL : PADDING.HORIZONTAL, "px");
32
+ const hasCharactersCount = showCharacterCount && maxLength && !disabled && !readOnly;
33
+ return {
34
+ charactersCount: {
35
+ position: 'absolute',
36
+ bottom: verticalPadding
37
+ },
38
+ root: {
39
+ backgroundColor: theme.Palette.light['01'],
40
+ paddingBottom: hasCharactersCount ? multilineVerticalPadding : verticalPadding,
41
+ paddingLeft: horizontalPadding,
42
+ paddingRight: horizontalPadding,
43
+ paddingTop: verticalPadding,
44
+ ...(readOnly && {
45
+ backgroundColor: 'transparent',
46
+ paddingLeft: 0,
47
+ paddingRight: 0
48
+ }),
49
+ ...(disabled && {
50
+ backgroundColor: theme.Palette.light['03']
51
+ })
52
+ },
53
+ inputContainer: {
54
+ borderColor: "".concat(theme.Palette.light['05'], " !important"),
55
+ borderRadius: '4px',
56
+ borderWidth: '1px',
57
+ ...(error && {
58
+ borderColor: "".concat(theme.Palette.error['04'], " !important")
59
+ }),
60
+ ...(readOnly && {
61
+ borderColor: 'transparent !important'
62
+ }),
63
+ ...(disabled && {
64
+ borderColor: 'transparent !important'
65
+ })
66
+ },
67
+ focusedInputContainer: {
68
+ ...(!error && {
69
+ borderColor: "".concat(theme.Palette.accent['04'], " !important"),
70
+ borderWidth: '2px'
71
+ })
72
+ },
73
+ input: {
74
+ ...(0, _theme.getFontStyles)({
75
+ theme,
76
+ variant: 'body',
77
+ weight: 'regular'
78
+ }),
79
+ caretColor: theme.Palette.accent['04'],
80
+ color: theme.Palette.dark['05'],
81
+ minHeight: '22px',
82
+ overflow: 'hidden',
83
+ padding: 0,
84
+ textOverflow: 'ellipsis',
85
+ '&::placeholder': {
86
+ color: theme.Palette.gray['02']
87
+ },
88
+ '&::selection': {
89
+ backgroundColor: theme.Palette.accent['02']
90
+ }
91
+ }
92
+ };
93
+ };
94
+ exports.retrieveStyle = retrieveStyle;
@@ -0,0 +1,68 @@
1
+ # UTValidation
2
+
3
+ ## Description
4
+
5
+ `UTValidation` is a component designed to display input validation messages in a structured and customizable way. It supports various statuses such as `success`, `error`, and `default`, and can include optional icons for each validation message.
6
+
7
+ ## Props
8
+
9
+ | Name | Type | Default | Description |
10
+ | -------------- | ------ | ------- | -------------------------------------------------------------------------------------------- |
11
+ | className | string | | Custom CSS class to apply to the root of the component. |
12
+ | validationData | array | [] | Array of validation data objects to display messages, each with a status and optional icons. |
13
+
14
+ ### validationData
15
+
16
+ The `validationData` prop is an array of objects, each representing a group of validation messages. Each object can optionally have a `title` and must have a `status` and an `items` array. The `items` array contains objects, each with `text`, `status`, and an optional `withIcon` property.
17
+
18
+ #### Structure of validationData
19
+
20
+ - **title** (optional): A string representing the title of the validation group.
21
+ - **status** (optional): A string indicating the status of the validation group. Defaults to `default`. Possible values are `success`, `error`, and `default`.
22
+ - **items** (required): An array of objects, each representing an individual validation item.
23
+ - **text** (required): A string containing the validation message.
24
+ - **status** (optional): A string indicating the status of the validation item. Defaults to `default`. Possible values are `success`, `error`, and `default`.
25
+ - **withIcon** (optional): A boolean indicating whether to display an icon next to the validation message. Defaults to `true`.
26
+
27
+ ### Example
28
+
29
+ ```javascript
30
+ const validationData = [
31
+ {
32
+ items: [
33
+ {
34
+ status: 'success',
35
+ text: 'Must be at least 8 characters long.',
36
+ withIcon: true // Optional, defaults to true
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ title: 'Must meet at least 2 of the following conditions:',
42
+ status: 'error',
43
+ items: [
44
+ {
45
+ text: 'At least 1 lowercase letter.' // Defaults to "default" and "withIcon" to true
46
+ },
47
+ {
48
+ text: 'At least 1 uppercase letter.' // Defaults to "default" and "withIcon" to true
49
+ },
50
+ {
51
+ status: 'success',
52
+ text: 'At least 1 number.',
53
+ withIcon: false // Will not display an icon
54
+ }
55
+ ]
56
+ }
57
+ ];
58
+ ```
59
+
60
+ ## Statuses
61
+
62
+ The `status` prop can be one of these values:
63
+
64
+ - `success`
65
+ - `error`
66
+ - `default`
67
+
68
+ If `status` is not provided, it defaults to `default`.
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.STATUS_COLOR_MAPPER = exports.STATUSES_WITH_ICON = exports.STATUSES = exports.ICON_STATUS_COLOR_MAPPER = exports.ICON_SIZE = exports.ICON_MAPPER = void 0;
7
+ const STATUSES = exports.STATUSES = {
8
+ success: 'success',
9
+ error: 'error',
10
+ default: 'default'
11
+ };
12
+ const ICON_STATUS_COLOR_MAPPER = exports.ICON_STATUS_COLOR_MAPPER = {
13
+ [STATUSES.success]: 'success',
14
+ [STATUSES.error]: 'error',
15
+ [STATUSES.default]: 'light'
16
+ };
17
+ const STATUS_COLOR_MAPPER = exports.STATUS_COLOR_MAPPER = {
18
+ [STATUSES.success]: 'success',
19
+ [STATUSES.error]: 'error',
20
+ [STATUSES.default]: 'gray'
21
+ };
22
+ const ICON_MAPPER = exports.ICON_MAPPER = {
23
+ [STATUSES.success]: 'IconCheck',
24
+ [STATUSES.error]: 'IconX'
25
+ };
26
+ const STATUSES_WITH_ICON = exports.STATUSES_WITH_ICON = [STATUSES.success, STATUSES.error];
27
+ const ICON_SIZE = exports.ICON_SIZE = 15;