@widergy/energy-ui 3.28.0 → 3.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/components/UTBaseInputField/constants.js +26 -0
- package/dist/components/UTBaseInputField/index.js +39 -47
- package/dist/components/UTBaseInputField/theme.js +15 -4
- package/dist/components/UTBaseInputField/utils.js +9 -0
- package/dist/components/UTCheckList/index.js +12 -160
- package/dist/components/UTCheckList/versions/V0/index.js +174 -0
- package/dist/components/UTCheckList/{theme.js → versions/V0/theme.js} +2 -2
- package/dist/components/UTCheckList/versions/V1/README.MD +134 -0
- package/dist/components/UTCheckList/versions/V1/constants.js +10 -0
- package/dist/components/UTCheckList/versions/V1/index.js +151 -0
- package/dist/components/UTCheckList/versions/V1/styles.module.scss +40 -0
- package/dist/components/UTCheckList/versions/V1/utils.js +14 -0
- package/dist/components/UTCheckbox/index.js +12 -128
- package/dist/components/UTCheckbox/versions/V0/index.js +142 -0
- package/dist/components/UTCheckbox/{theme.js → versions/V0/theme.js} +1 -1
- package/dist/components/UTCheckbox/versions/V1/README.md +37 -0
- package/dist/components/UTCheckbox/versions/V1/constants.js +13 -0
- package/dist/components/UTCheckbox/versions/V1/index.js +93 -0
- package/dist/components/UTCheckbox/versions/V1/styles.module.scss +3 -0
- package/dist/components/UTCheckbox/versions/V1/theme.js +126 -0
- package/dist/components/UTFieldLabel/index.js +3 -2
- package/dist/components/UTLabel/constants.js +0 -2
- package/dist/components/UTPhoneInput/versions/V1/index.js +24 -10
- package/dist/components/UTSearchField/README.md +35 -0
- package/dist/components/UTSearchField/index.js +89 -0
- package/dist/components/UTSearchField/theme.js +19 -0
- package/dist/components/UTTextInput/versions/V1/README.md +0 -1
- package/dist/components/UTTextInput/versions/V1/index.js +48 -6
- package/dist/components/UTTouchableWithoutFeedback/index.js +19 -10
- package/dist/components/UTTouchableWithoutFeedback/styles.module.scss +5 -0
- package/dist/index.js +7 -0
- package/package.json +1 -1
- package/dist/components/UTTextInput/versions/V1/components/ActionAdornment/index.js +0 -31
- package/dist/components/UTTextInput/versions/V1/components/IconAdornment/constants.js +0 -8
- package/dist/components/UTTextInput/versions/V1/components/IconAdornment/index.js +0 -48
- package/dist/components/UTTextInput/versions/V1/components/IconAdornment/utils.js +0 -17
- package/dist/components/UTTextInput/versions/V1/components/PrefixAdornment/index.js +0 -24
- package/dist/components/UTTextInput/versions/V1/components/SuffixAdornment/index.js +0 -22
- package/dist/components/UTTextInput/versions/V1/components/TooltipAdornment/index.js +0 -26
- package/dist/components/UTTextInput/versions/V1/theme.js +0 -94
- /package/dist/components/UTCheckList/{constants.js → versions/V0/constants.js} +0 -0
- /package/dist/components/UTCheckList/{styles.module.scss → versions/V0/styles.module.scss} +0 -0
- /package/dist/components/UTCheckbox/{assets → versions/V0/assets}/checked.svg +0 -0
- /package/dist/components/UTCheckbox/{constants.js → versions/V0/constants.js} +0 -0
- /package/dist/components/UTCheckbox/{styles.module.scss → versions/V0/styles.module.scss} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# UTCheckbox
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`UTCheckbox` is a customizable checkbox component. It supports various states such as checked, indeterminate, and disabled. Additionally, it includes the option to display a title and supports markdown for advanced formatting.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Name | Type | Default | Description |
|
|
10
|
+
| ------------- | ---------------- | --------- | ------------------------------------------------------------------------------------- |
|
|
11
|
+
| classNames | objectOf(string) | | Additional class names to apply for further styling. |
|
|
12
|
+
| disabled | bool | false | Disables the checkbox, making it unclickable. |
|
|
13
|
+
| indeterminate | bool | false | Indicates if the checkbox is in an indeterminate state. |
|
|
14
|
+
| isSimple | bool | false | **Deprecated**: Please avoid using this property in future implementations. |
|
|
15
|
+
| onChange | func | | Function to call when the checkbox state changes. |
|
|
16
|
+
| required | bool | false | Indicates if the checkbox is required. |
|
|
17
|
+
| title | string | | Title to display next to the checkbox. Supports markdown when `withMarkdown` is true. |
|
|
18
|
+
| value | bool | false | Indicates if the checkbox is checked. |
|
|
19
|
+
| variant | string | 'default' | Defines the visual variant of the checkbox. |
|
|
20
|
+
| withMarkdown | bool | false | Enables markdown formatting for the `title` prop. |
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Basic Example
|
|
25
|
+
|
|
26
|
+
```jsx
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import UTCheckbox from './UTCheckbox';
|
|
29
|
+
|
|
30
|
+
const Example = () => {
|
|
31
|
+
const [checked, setChecked] = React.useState(false);
|
|
32
|
+
|
|
33
|
+
return <UTCheckbox value={checked} title="Check me" onChange={() => setChecked(!checked)} />;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default Example;
|
|
37
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SPACING = exports.INDETERMINATE_ICON = exports.CHECKED_ICON = exports.BUTTON_VARIANT = void 0;
|
|
7
|
+
const CHECKED_ICON = exports.CHECKED_ICON = 'IconCheck';
|
|
8
|
+
const INDETERMINATE_ICON = exports.INDETERMINATE_ICON = 'IconMinus';
|
|
9
|
+
const SPACING = exports.SPACING = {
|
|
10
|
+
SMALL: 'small',
|
|
11
|
+
LARGE: 'large'
|
|
12
|
+
};
|
|
13
|
+
const BUTTON_VARIANT = exports.BUTTON_VARIANT = 'button';
|
|
@@ -0,0 +1,93 @@
|
|
|
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 _classesUtils = require("../../../../utils/classesUtils");
|
|
10
|
+
var _UTFieldLabel = _interopRequireDefault(require("../../../UTFieldLabel"));
|
|
11
|
+
var _UTIcon = _interopRequireDefault(require("../../../UTIcon"));
|
|
12
|
+
var _WithTheme = _interopRequireDefault(require("../../../WithTheme"));
|
|
13
|
+
var _UTTouchableWithoutFeedback = _interopRequireDefault(require("../../../UTTouchableWithoutFeedback"));
|
|
14
|
+
var _constants = require("./constants");
|
|
15
|
+
var _theme = require("./theme");
|
|
16
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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
|
+
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 _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
|
+
const UTCheckbox = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
classes: theme,
|
|
24
|
+
classNames,
|
|
25
|
+
disabled,
|
|
26
|
+
indeterminate,
|
|
27
|
+
isSimple = false,
|
|
28
|
+
onChange,
|
|
29
|
+
required,
|
|
30
|
+
title,
|
|
31
|
+
value,
|
|
32
|
+
variant = 'default',
|
|
33
|
+
withMarkdown
|
|
34
|
+
} = _ref;
|
|
35
|
+
const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(theme, classNames), [classNames, theme]);
|
|
36
|
+
const iconName = (0, _react.useMemo)(() => indeterminate ? _constants.INDETERMINATE_ICON : value ? _constants.CHECKED_ICON : '', [indeterminate, value]);
|
|
37
|
+
const handlePress = (0, _react.useCallback)(() => {
|
|
38
|
+
if (!disabled && onChange) {
|
|
39
|
+
onChange(!value);
|
|
40
|
+
}
|
|
41
|
+
}, [disabled, onChange, value]);
|
|
42
|
+
const shouldHighlightLabel = value && variant === _constants.BUTTON_VARIANT;
|
|
43
|
+
const touchableProps = {
|
|
44
|
+
onClick: handlePress,
|
|
45
|
+
disabled
|
|
46
|
+
};
|
|
47
|
+
const RootComponent = variant === _constants.BUTTON_VARIANT ? _UTTouchableWithoutFeedback.default : 'div';
|
|
48
|
+
const BoxContainerComponent = variant === _constants.BUTTON_VARIANT ? 'div' : _UTTouchableWithoutFeedback.default;
|
|
49
|
+
const rootComponentProps = variant === _constants.BUTTON_VARIANT ? touchableProps : {};
|
|
50
|
+
const boxContainerProps = variant === _constants.BUTTON_VARIANT ? {} : touchableProps;
|
|
51
|
+
return /*#__PURE__*/_react.default.createElement(RootComponent, _extends({
|
|
52
|
+
className: classes.container
|
|
53
|
+
}, rootComponentProps), /*#__PURE__*/_react.default.createElement(BoxContainerComponent, _extends({
|
|
54
|
+
className: classes.boxContainer
|
|
55
|
+
}, boxContainerProps), isSimple ? /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
|
|
56
|
+
name: "IconCheck",
|
|
57
|
+
shade: "04",
|
|
58
|
+
colorTheme: "accent",
|
|
59
|
+
className: value ? undefined : _stylesModule.default.hidden
|
|
60
|
+
}) : /*#__PURE__*/_react.default.createElement("div", {
|
|
61
|
+
className: classes.box
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
63
|
+
className: classes.iconContainer
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
|
|
65
|
+
colorTheme: "light",
|
|
66
|
+
name: iconName,
|
|
67
|
+
size: 16
|
|
68
|
+
})))), /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
|
|
69
|
+
colorTheme: shouldHighlightLabel ? 'accent' : 'dark',
|
|
70
|
+
required: required,
|
|
71
|
+
className: classes.title,
|
|
72
|
+
withMarkdown: withMarkdown
|
|
73
|
+
}, title));
|
|
74
|
+
};
|
|
75
|
+
UTCheckbox.propTypes = {
|
|
76
|
+
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
77
|
+
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
78
|
+
disabled: _propTypes.bool,
|
|
79
|
+
indeterminate: _propTypes.bool,
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated The "isSimple" prop is deprecated and will be removed in a future release. Please do not use it.
|
|
82
|
+
*/
|
|
83
|
+
isSimple: _propTypes.bool,
|
|
84
|
+
onChange: _propTypes.func,
|
|
85
|
+
required: _propTypes.bool,
|
|
86
|
+
reversed: _propTypes.bool,
|
|
87
|
+
spacing: _propTypes.string,
|
|
88
|
+
title: _propTypes.string,
|
|
89
|
+
value: _propTypes.bool,
|
|
90
|
+
variant: _propTypes.string,
|
|
91
|
+
withMarkdown: _propTypes.bool
|
|
92
|
+
};
|
|
93
|
+
var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTCheckbox);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retrieveStyle = void 0;
|
|
7
|
+
var _constants = require("./constants");
|
|
8
|
+
const NORMAL_SPACING = 16;
|
|
9
|
+
const SMALL_SPACING = 8;
|
|
10
|
+
const baseCheckBoxTheme = theme => ({
|
|
11
|
+
container: {
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
display: 'flex'
|
|
14
|
+
},
|
|
15
|
+
iconContainer: {
|
|
16
|
+
border: "2px solid ".concat(theme.Palette.gray['04']),
|
|
17
|
+
borderRadius: 5,
|
|
18
|
+
display: 'flex',
|
|
19
|
+
height: 20,
|
|
20
|
+
placeContent: 'center',
|
|
21
|
+
placeItems: 'center',
|
|
22
|
+
width: 20
|
|
23
|
+
},
|
|
24
|
+
box: {
|
|
25
|
+
borderRadius: 25,
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
padding: 6
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const conditionalStyles = _ref => {
|
|
31
|
+
let {
|
|
32
|
+
value,
|
|
33
|
+
indeterminate,
|
|
34
|
+
reversed,
|
|
35
|
+
spacing,
|
|
36
|
+
variant,
|
|
37
|
+
theme,
|
|
38
|
+
disabled
|
|
39
|
+
} = _ref;
|
|
40
|
+
const spacingValue = spacing === _constants.SPACING.SMALL ? SMALL_SPACING : NORMAL_SPACING;
|
|
41
|
+
return {
|
|
42
|
+
container: {
|
|
43
|
+
...(reversed && {
|
|
44
|
+
flexDirection: 'row-reverse',
|
|
45
|
+
justifyContent: 'space-between'
|
|
46
|
+
}),
|
|
47
|
+
...(disabled && {
|
|
48
|
+
opacity: 0.5
|
|
49
|
+
}),
|
|
50
|
+
...(variant === _constants.BUTTON_VARIANT && {
|
|
51
|
+
borderRadius: '8px',
|
|
52
|
+
padding: '12px 16px',
|
|
53
|
+
'&:active': {
|
|
54
|
+
backgroundColor: theme.Palette.light['04']
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
},
|
|
58
|
+
iconContainer: {
|
|
59
|
+
...((value || indeterminate) && {
|
|
60
|
+
backgroundColor: theme.Palette.accent['04'],
|
|
61
|
+
borderColor: theme.Palette.accent['04']
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
boxContainer: {
|
|
65
|
+
...(reversed ? {
|
|
66
|
+
marginLeft: spacingValue,
|
|
67
|
+
marginRight: 0
|
|
68
|
+
} : {
|
|
69
|
+
marginRight: spacingValue
|
|
70
|
+
}),
|
|
71
|
+
...(variant !== _constants.BUTTON_VARIANT && {
|
|
72
|
+
'&:active': {
|
|
73
|
+
'& $box': {
|
|
74
|
+
backgroundColor: theme.Palette.accent['02'],
|
|
75
|
+
borderColor: theme.Palette.accent['03'],
|
|
76
|
+
borderWidth: 1,
|
|
77
|
+
overflow: 'hidden'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
title: variant === _constants.BUTTON_VARIANT && {
|
|
83
|
+
userSelect: 'none'
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
const retrieveStyle = _ref2 => {
|
|
88
|
+
let {
|
|
89
|
+
value,
|
|
90
|
+
disabled,
|
|
91
|
+
indeterminate,
|
|
92
|
+
reversed,
|
|
93
|
+
spacing,
|
|
94
|
+
theme,
|
|
95
|
+
variant
|
|
96
|
+
} = _ref2;
|
|
97
|
+
const baseThemeStyles = baseCheckBoxTheme(theme);
|
|
98
|
+
const {
|
|
99
|
+
container,
|
|
100
|
+
iconContainer,
|
|
101
|
+
boxContainer,
|
|
102
|
+
title
|
|
103
|
+
} = conditionalStyles({
|
|
104
|
+
value,
|
|
105
|
+
disabled,
|
|
106
|
+
indeterminate,
|
|
107
|
+
reversed,
|
|
108
|
+
spacing,
|
|
109
|
+
variant,
|
|
110
|
+
theme
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
box: baseThemeStyles.box,
|
|
114
|
+
container: {
|
|
115
|
+
...baseThemeStyles.container,
|
|
116
|
+
...container
|
|
117
|
+
},
|
|
118
|
+
iconContainer: {
|
|
119
|
+
...baseThemeStyles.iconContainer,
|
|
120
|
+
...iconContainer
|
|
121
|
+
},
|
|
122
|
+
boxContainer,
|
|
123
|
+
title
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
exports.retrieveStyle = retrieveStyle;
|
|
@@ -15,13 +15,13 @@ const UTFieldLabel = _ref => {
|
|
|
15
15
|
children,
|
|
16
16
|
colorTheme,
|
|
17
17
|
required,
|
|
18
|
-
|
|
18
|
+
className,
|
|
19
19
|
variant,
|
|
20
20
|
weight,
|
|
21
21
|
withMarkdown
|
|
22
22
|
} = _ref;
|
|
23
23
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
24
|
-
className: "".concat(_stylesModule.default.label, " ").concat(
|
|
24
|
+
className: "".concat(_stylesModule.default.label, " ").concat(className)
|
|
25
25
|
}, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
26
26
|
colorTheme: colorTheme,
|
|
27
27
|
variant: variant,
|
|
@@ -34,6 +34,7 @@ const UTFieldLabel = _ref => {
|
|
|
34
34
|
}, _constants.REQUIRED_LABEL));
|
|
35
35
|
};
|
|
36
36
|
UTFieldLabel.propTypes = {
|
|
37
|
+
className: _propTypes.string,
|
|
37
38
|
colorTheme: _propTypes.string,
|
|
38
39
|
required: _propTypes.bool,
|
|
39
40
|
variant: _propTypes.string,
|
|
@@ -7,8 +7,6 @@ exports.WEIGHTS = exports.VARIANTS_SIZES = exports.VARIANTS_LINE_HEIGHT = export
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _Palette = require("../../constants/Palette");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
/* eslint-disable react/prop-types */
|
|
11
|
-
|
|
12
10
|
const VARIANTS = exports.VARIANTS = {
|
|
13
11
|
title1: 'h1',
|
|
14
12
|
title2: 'h2',
|
|
@@ -6,23 +6,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = require("prop-types");
|
|
9
|
+
var _constants = require("../../../UTBaseInputField/constants");
|
|
9
10
|
var _utils = require("../../../UTValidation/utils");
|
|
10
11
|
var _inputs = require("../../../../constants/inputs");
|
|
11
12
|
var _UTBaseInputField = _interopRequireDefault(require("../../../UTBaseInputField"));
|
|
12
13
|
var _UTFieldLabel = _interopRequireDefault(require("../../../UTFieldLabel"));
|
|
13
14
|
var _UTLabel = _interopRequireDefault(require("../../../UTLabel"));
|
|
14
15
|
var _UTValidation = _interopRequireWildcard(require("../../../UTValidation"));
|
|
15
|
-
var
|
|
16
|
+
var _constants2 = require("./constants");
|
|
16
17
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
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
20
|
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
21
|
const UTPhoneInput = _ref => {
|
|
21
22
|
let {
|
|
23
|
+
areaCodeDataTestId,
|
|
22
24
|
areaCodePlaceholder,
|
|
23
25
|
countryCode,
|
|
24
|
-
areaCodeDataTestId,
|
|
25
|
-
phoneNumberDataTestId,
|
|
26
26
|
disabled,
|
|
27
27
|
error,
|
|
28
28
|
helpText,
|
|
@@ -30,10 +30,10 @@ const UTPhoneInput = _ref => {
|
|
|
30
30
|
onBlur,
|
|
31
31
|
onChange,
|
|
32
32
|
onFocus,
|
|
33
|
+
phoneNumberDataTestId,
|
|
33
34
|
placeholder,
|
|
34
35
|
readOnly,
|
|
35
36
|
required,
|
|
36
|
-
RightIcon,
|
|
37
37
|
title,
|
|
38
38
|
titleVariant,
|
|
39
39
|
translations = {
|
|
@@ -45,9 +45,9 @@ const UTPhoneInput = _ref => {
|
|
|
45
45
|
withAreaCode = true
|
|
46
46
|
} = _ref;
|
|
47
47
|
const [areaCode, setAreaCode] = (0, _react.useState)('');
|
|
48
|
-
const [phoneNumber, setPhoneNumber] = (0, _react.useState)('');
|
|
49
48
|
const [areaCodeError, setAreaCodeError] = (0, _react.useState)('');
|
|
50
49
|
const [isValidCode, setIsValidCode] = (0, _react.useState)(false);
|
|
50
|
+
const [phoneNumber, setPhoneNumber] = (0, _react.useState)('');
|
|
51
51
|
(0, _react.useEffect)(() => {
|
|
52
52
|
if (value && withAreaCode) {
|
|
53
53
|
const [code, phone] = value.split('-');
|
|
@@ -67,7 +67,7 @@ const UTPhoneInput = _ref => {
|
|
|
67
67
|
setAreaCodeError(areaCodeWithoutZeroError);
|
|
68
68
|
setIsValidCode(false);
|
|
69
69
|
} else {
|
|
70
|
-
const code =
|
|
70
|
+
const code = _constants2.AREA_CODES.find(element => element.code === areaCode);
|
|
71
71
|
setIsValidCode(!!code);
|
|
72
72
|
setAreaCodeError(!code ? invalidAreaCodeError : '');
|
|
73
73
|
}
|
|
@@ -112,7 +112,12 @@ const UTPhoneInput = _ref => {
|
|
|
112
112
|
onFocus: onFocus,
|
|
113
113
|
placeholder: areaCodePlaceholder,
|
|
114
114
|
readOnly: readOnly,
|
|
115
|
-
|
|
115
|
+
rightAdornments: [{
|
|
116
|
+
name: _constants.COMPONENT_KEYS.ICON,
|
|
117
|
+
props: {
|
|
118
|
+
changeOnError: true
|
|
119
|
+
}
|
|
120
|
+
}],
|
|
116
121
|
value: areaCode
|
|
117
122
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
118
123
|
className: _stylesModule.default.phoneContainer
|
|
@@ -127,8 +132,18 @@ const UTPhoneInput = _ref => {
|
|
|
127
132
|
onChange: handleChangePhoneNumber,
|
|
128
133
|
onFocus: onFocus,
|
|
129
134
|
placeholder: placeholder,
|
|
130
|
-
|
|
131
|
-
|
|
135
|
+
leftAdornments: countryCode && !withAreaCode ? [{
|
|
136
|
+
name: _constants.COMPONENT_KEYS.PREFIX,
|
|
137
|
+
props: {
|
|
138
|
+
text: countryCode
|
|
139
|
+
}
|
|
140
|
+
}] : [],
|
|
141
|
+
rightAdornments: [{
|
|
142
|
+
name: _constants.COMPONENT_KEYS.ICON,
|
|
143
|
+
props: {
|
|
144
|
+
changeOnError: true
|
|
145
|
+
}
|
|
146
|
+
}],
|
|
132
147
|
value: phoneNumber
|
|
133
148
|
}))), helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
134
149
|
colorTheme: "gray",
|
|
@@ -152,7 +167,6 @@ UTPhoneInput.propTypes = {
|
|
|
152
167
|
placeholder: _propTypes.string,
|
|
153
168
|
readOnly: _propTypes.bool,
|
|
154
169
|
required: _propTypes.bool,
|
|
155
|
-
RightIcon: _propTypes.elementType,
|
|
156
170
|
title: _propTypes.string,
|
|
157
171
|
titleVariant: _propTypes.string,
|
|
158
172
|
translations: (0, _propTypes.shape)({
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# UTSearchField
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`UTSearchField` is a customizable search field component. It includes a search icon on the left and an optional clear button on the right when there is text in the input field.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Name | Type | Default | Description |
|
|
10
|
+
| ----------- | ------ | ------- | ----------------------------------------------------------- |
|
|
11
|
+
| className | string | | CSS class to customize the root element of the input field. |
|
|
12
|
+
| dataTestId | string | | Identifier used for testing purposes. |
|
|
13
|
+
| disabled | bool | | Disables the input field if set to true. |
|
|
14
|
+
| id | string | | Unique identifier for the input field. |
|
|
15
|
+
| onBlur | func | | Function to call when the input field loses focus. |
|
|
16
|
+
| onChange | func | | Function to call when the input field value changes. |
|
|
17
|
+
| onFocus | func | | Function to call when the input field gains focus. |
|
|
18
|
+
| placeholder | string | | Placeholder text for the input field. |
|
|
19
|
+
| size | string | | Size of the input field. One of: `small`, `large`. |
|
|
20
|
+
| type | string | | Type of input (e.g., 'numeric', 'password', 'text' ). |
|
|
21
|
+
| value | string | null | The value of the input field. |
|
|
22
|
+
| variant | string | gray | Variant of the input field. One of: `white`, `gray`. |
|
|
23
|
+
|
|
24
|
+
### Adornments
|
|
25
|
+
|
|
26
|
+
`UTSearchField` utilizes adornments on both sides of the input field:
|
|
27
|
+
|
|
28
|
+
- **Left Adornment**: A search icon is always displayed on the left side of the input field.
|
|
29
|
+
- **Right Adornment**: A clear (reset) button is displayed on the right side only when there is a value in the input field.
|
|
30
|
+
|
|
31
|
+
## Additional Information
|
|
32
|
+
|
|
33
|
+
- The clear button appears when the input field contains text and clears the input when clicked.
|
|
34
|
+
- The search icon can change its style based on the focus state of the input field.
|
|
35
|
+
- The component is built on top of `UTBaseInputField`, inheriting its flexible adornment handling.
|
|
@@ -0,0 +1,89 @@
|
|
|
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 = _interopRequireDefault(require("react"));
|
|
9
|
+
var _constants = require("../UTBaseInputField/constants");
|
|
10
|
+
var _UTBaseInputField = _interopRequireDefault(require("../UTBaseInputField"));
|
|
11
|
+
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
12
|
+
var _theme = require("./theme");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const UTSearchField = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
classes,
|
|
17
|
+
className,
|
|
18
|
+
dataTestId,
|
|
19
|
+
disabled,
|
|
20
|
+
id,
|
|
21
|
+
onBlur,
|
|
22
|
+
onChange = () => {},
|
|
23
|
+
onFocus,
|
|
24
|
+
placeholder,
|
|
25
|
+
size,
|
|
26
|
+
type,
|
|
27
|
+
value = null,
|
|
28
|
+
variant = 'gray'
|
|
29
|
+
} = _ref;
|
|
30
|
+
const clearText = () => {
|
|
31
|
+
onChange('');
|
|
32
|
+
};
|
|
33
|
+
const action = {
|
|
34
|
+
Icon: 'IconX',
|
|
35
|
+
onClick: clearText,
|
|
36
|
+
size: 'small'
|
|
37
|
+
};
|
|
38
|
+
const leftAdornments = [{
|
|
39
|
+
name: _constants.COMPONENT_KEYS.ICON,
|
|
40
|
+
props: {
|
|
41
|
+
Icon: 'IconSearch',
|
|
42
|
+
changeOnFocus: true,
|
|
43
|
+
shade: '02'
|
|
44
|
+
}
|
|
45
|
+
}];
|
|
46
|
+
const rightAdornments = value ? [{
|
|
47
|
+
name: _constants.COMPONENT_KEYS.ACTION,
|
|
48
|
+
props: {
|
|
49
|
+
action
|
|
50
|
+
}
|
|
51
|
+
}] : [];
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement(_UTBaseInputField.default, {
|
|
53
|
+
alwaysShowPlaceholder: true,
|
|
54
|
+
dataTestId: dataTestId,
|
|
55
|
+
disabled: disabled,
|
|
56
|
+
id: id,
|
|
57
|
+
inputSize: size,
|
|
58
|
+
leftAdornments: leftAdornments,
|
|
59
|
+
onBlur: onBlur,
|
|
60
|
+
onChange: onChange,
|
|
61
|
+
onFocus: onFocus,
|
|
62
|
+
placeholder: placeholder,
|
|
63
|
+
rightAdornments: rightAdornments,
|
|
64
|
+
classNames: {
|
|
65
|
+
root: className,
|
|
66
|
+
input: classes.input
|
|
67
|
+
},
|
|
68
|
+
type: type,
|
|
69
|
+
value: value,
|
|
70
|
+
variant: variant
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const propTypes = exports.propTypes = {
|
|
74
|
+
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
75
|
+
className: _propTypes.string,
|
|
76
|
+
dataTestId: _propTypes.string,
|
|
77
|
+
disabled: _propTypes.bool,
|
|
78
|
+
id: _propTypes.string,
|
|
79
|
+
onBlur: _propTypes.func,
|
|
80
|
+
onChange: _propTypes.func,
|
|
81
|
+
onFocus: _propTypes.func,
|
|
82
|
+
placeholder: _propTypes.string,
|
|
83
|
+
size: _propTypes.string,
|
|
84
|
+
type: _propTypes.string,
|
|
85
|
+
value: _propTypes.string,
|
|
86
|
+
variant: _propTypes.string
|
|
87
|
+
};
|
|
88
|
+
UTSearchField.propTypes = propTypes;
|
|
89
|
+
var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTSearchField);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retrieveStyle = void 0;
|
|
7
|
+
const retrieveStyle = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
theme
|
|
10
|
+
} = _ref;
|
|
11
|
+
return {
|
|
12
|
+
input: {
|
|
13
|
+
'&::placeholder': {
|
|
14
|
+
color: "".concat(theme.Palette.gray['04'], " !important")
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.retrieveStyle = retrieveStyle;
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
| prefix | string | | Text displayed before the entered value in the input field. |
|
|
29
29
|
| readOnly | bool | false | Makes the input field read-only. |
|
|
30
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
31
|
| RightIcon | elementType | | Icon displayed on the right side of the input field. |
|
|
33
32
|
| showCharacterCount | bool | false | Whether the character count should be displayed (if `maxLength` is defined). |
|
|
34
33
|
| style | shape({ container: object, input: object, root: object }) | | Style object to customize the input field. Can contain `root`, `container`, `input`, or `action` styles. |
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.propTypes = exports.default = void 0;
|
|
7
7
|
var _propTypes = require("prop-types");
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _constants = require("../../../UTBaseInputField/constants");
|
|
9
10
|
var _utils = require("../../../UTValidation/utils");
|
|
10
11
|
var _inputs = require("../../../../constants/inputs.js");
|
|
11
12
|
var _UTBaseInputField = _interopRequireDefault(require("../../../UTBaseInputField"));
|
|
@@ -50,6 +51,51 @@ const UTTextInput = _ref => {
|
|
|
50
51
|
} = _ref;
|
|
51
52
|
const titleColorTheme = readOnly ? 'gray' : 'dark';
|
|
52
53
|
const validationData = (0, _react.useMemo)(() => validations || error && (0, _utils.formatErrorToValidation)(error), [error, validations]);
|
|
54
|
+
const leftAdornments = (0, _react.useMemo)(() => {
|
|
55
|
+
const adornments = [];
|
|
56
|
+
if (LeftIcon) adornments.push({
|
|
57
|
+
name: _constants.COMPONENT_KEYS.ICON,
|
|
58
|
+
props: {
|
|
59
|
+
Icon: LeftIcon
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (prefix) adornments.push({
|
|
63
|
+
name: _constants.COMPONENT_KEYS.PREFIX,
|
|
64
|
+
props: {
|
|
65
|
+
text: prefix
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return adornments;
|
|
69
|
+
}, [LeftIcon, prefix]);
|
|
70
|
+
const rightAdornments = (0, _react.useMemo)(() => {
|
|
71
|
+
const adornments = [];
|
|
72
|
+
if (suffix) adornments.push({
|
|
73
|
+
name: _constants.COMPONENT_KEYS.SUFFIX,
|
|
74
|
+
props: {
|
|
75
|
+
text: suffix
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (RightIcon || error) adornments.push({
|
|
79
|
+
name: _constants.COMPONENT_KEYS.ICON,
|
|
80
|
+
props: {
|
|
81
|
+
Icon: RightIcon,
|
|
82
|
+
changeOnError: true
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (action) adornments.push({
|
|
86
|
+
name: _constants.COMPONENT_KEYS.ACTION,
|
|
87
|
+
props: {
|
|
88
|
+
action
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (tooltip) adornments.push({
|
|
92
|
+
name: _constants.COMPONENT_KEYS.TOOLTIP,
|
|
93
|
+
props: {
|
|
94
|
+
tooltip
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return adornments;
|
|
98
|
+
}, [suffix, RightIcon, error, action, tooltip]);
|
|
53
99
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
54
100
|
className: "".concat(_stylesModule.default.container, " ").concat(classNames.container)
|
|
55
101
|
}, title && /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
|
|
@@ -57,7 +103,6 @@ const UTTextInput = _ref => {
|
|
|
57
103
|
variant: _inputs.TITLE_VARIANTS[titleVariant],
|
|
58
104
|
required: required
|
|
59
105
|
}, title), /*#__PURE__*/_react.default.createElement(_UTBaseInputField.default, {
|
|
60
|
-
action: action,
|
|
61
106
|
alwaysShowPlaceholder: alwaysShowPlaceholder,
|
|
62
107
|
classNames: classNames,
|
|
63
108
|
dataTestId: dataTestId,
|
|
@@ -65,19 +110,16 @@ const UTTextInput = _ref => {
|
|
|
65
110
|
error: error,
|
|
66
111
|
id: id,
|
|
67
112
|
inputSize: inputSize,
|
|
68
|
-
|
|
113
|
+
leftAdornments: leftAdornments,
|
|
69
114
|
maxLength: maxLength,
|
|
70
115
|
maxRows: maxRows,
|
|
71
116
|
onBlur: onBlur,
|
|
72
117
|
onChange: onChange,
|
|
73
118
|
onFocus: onFocus,
|
|
74
119
|
placeholder: placeholder,
|
|
75
|
-
prefix: prefix,
|
|
76
120
|
readOnly: readOnly,
|
|
77
|
-
|
|
121
|
+
rightAdornments: rightAdornments,
|
|
78
122
|
showCharacterCount: showCharacterCount,
|
|
79
|
-
suffix: suffix,
|
|
80
|
-
tooltip: tooltip,
|
|
81
123
|
type: type,
|
|
82
124
|
value: value
|
|
83
125
|
}), helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|