@xaypay/tui 0.0.52 → 0.0.53
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/dist/index.es.js +331 -195
- package/dist/index.js +330 -198
- package/package.json +7 -3
- package/src/components/button/button.stories.js +3 -24
- package/src/components/button/index.js +88 -67
- package/src/components/input/index.js +149 -95
- package/src/components/input/input.module.css +15 -83
- package/src/components/input/input.stories.js +1 -20
- package/src/components/tooltip/index.js +110 -0
- package/src/components/tooltip/tooltip.module.css +39 -0
- package/src/components/tooltip/tooltip.stories.js +26 -0
- package/src/components/typography/index.js +43 -36
- package/src/components/typography/typography.module.css +2 -7
- package/src/components/typography/typography.stories.js +3 -16
- package/src/index.js +1 -0
- package/src/utils/index.js +21 -0
- package/tui.config.js +61 -0
- package/src/components/button/button.module.css +0 -66
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaypay/tui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -46,12 +46,16 @@
|
|
|
46
46
|
"styled-components": "^5.3.5"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
+
"classnames": "^2.3.1",
|
|
49
50
|
"react": "17 - 18",
|
|
50
51
|
"react-dom": "17 - 18",
|
|
51
|
-
"styled-components": "^5.3.5"
|
|
52
|
-
"classnames": "^2.3.1"
|
|
52
|
+
"styled-components": "^5.3.5"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"lodash": "^4.17.21",
|
|
59
|
+
"react-icons": "^4.7.1"
|
|
56
60
|
}
|
|
57
61
|
}
|
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {Button
|
|
2
|
+
import {Button} from './index';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
component: Button,
|
|
6
6
|
title: 'Components/Button',
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
const Template = (args) => <Button label='Button'
|
|
9
|
+
const Template = (args) => <Button label='Button' {...args}/>;
|
|
10
10
|
|
|
11
|
-
export const Default = Template.bind({});
|
|
12
|
-
Default.args = {
|
|
13
|
-
theme: ButtonTheme.DEFAULT,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const Primary = Template.bind({});
|
|
17
|
-
Primary.args = {
|
|
18
|
-
theme: ButtonTheme.PRIMARY,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const Large = Template.bind({});
|
|
22
|
-
Large.args = {
|
|
23
|
-
size: ButtonSize.LARGE,
|
|
24
|
-
theme: ButtonTheme.DEFAULT,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const Small = Template.bind({});
|
|
28
|
-
Small.args = {
|
|
29
|
-
size: ButtonSize.SMALL,
|
|
30
|
-
backgroundColor: '#ff0000',
|
|
31
|
-
theme: ButtonTheme.DEFAULT,
|
|
32
|
-
};
|
|
11
|
+
export const Default = Template.bind({});
|
|
@@ -1,51 +1,85 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
-
import
|
|
4
|
+
import { compereConfigs } from './../../utils';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export const Button = ({
|
|
7
|
+
type,
|
|
8
|
+
color,
|
|
9
|
+
label,
|
|
10
|
+
width,
|
|
11
|
+
height,
|
|
12
|
+
cursor,
|
|
13
|
+
border,
|
|
14
|
+
outline,
|
|
15
|
+
padding,
|
|
16
|
+
onClick,
|
|
17
|
+
fontSize,
|
|
18
|
+
disabled,
|
|
19
|
+
className,
|
|
20
|
+
boxSizing,
|
|
21
|
+
transition,
|
|
22
|
+
contentWidth,
|
|
23
|
+
borderRadius,
|
|
24
|
+
backgroundColor,
|
|
25
|
+
disabledThemeColor,
|
|
26
|
+
disabledThemeBgColor,
|
|
27
|
+
disabledThemeLineColor,
|
|
28
|
+
...props
|
|
29
|
+
}) => {
|
|
9
30
|
|
|
10
|
-
|
|
11
|
-
BUTTON: 'button',
|
|
12
|
-
RESET: 'reset',
|
|
13
|
-
SUBMIT: 'submit',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const ButtonTheme = {
|
|
17
|
-
DEFAULT: 'content-size',
|
|
18
|
-
PRIMARY: 'full-size',
|
|
19
|
-
SUCCESS: 'btn-success',
|
|
20
|
-
INFO: 'btn-info',
|
|
21
|
-
WARNING: 'btn-warning',
|
|
22
|
-
DANGER: 'btn-danger',
|
|
23
|
-
LINK: 'btn-link',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const ButtonSize = {
|
|
27
|
-
SMALL: 'small',
|
|
28
|
-
MEDIUM: 'medium',
|
|
29
|
-
LARGE: 'large',
|
|
30
|
-
};
|
|
31
|
+
const [isHover, setIsHover] = useState(false);
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!label) {
|
|
35
|
+
alert('Button component: label prop is required, please add it!!!');
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
33
38
|
|
|
39
|
+
const configStyles = compereConfigs();
|
|
34
40
|
const classProps = classnames(
|
|
35
|
-
styles.btn,
|
|
36
|
-
styles[theme],
|
|
37
|
-
styles[size],
|
|
38
|
-
outline ? styles['type-outline'] : styles['type-filled'],
|
|
39
41
|
className,
|
|
40
|
-
'button-rem'
|
|
41
42
|
);
|
|
42
|
-
|
|
43
|
+
|
|
44
|
+
const handleMouseEnter = () => {
|
|
45
|
+
setIsHover(true);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleMouseLeave = () => {
|
|
49
|
+
setIsHover(false);
|
|
50
|
+
};
|
|
51
|
+
|
|
43
52
|
return (
|
|
44
53
|
<button
|
|
45
|
-
|
|
54
|
+
style={{
|
|
55
|
+
height: height ? height : configStyles.BUTTON.height,
|
|
56
|
+
padding: padding ? padding : configStyles.BUTTON.padding,
|
|
57
|
+
fontSize: fontSize ? fontSize : configStyles.BUTTON.fontSize,
|
|
58
|
+
boxSizing: boxSizing ? boxSizing : configStyles.BUTTON.boxSizing,
|
|
59
|
+
transition: transition ? transition : configStyles.BUTTON.transition,
|
|
60
|
+
border: outline ? 'none' : border ? border : configStyles.BUTTON.border,
|
|
61
|
+
width: contentWidth ? 'auto' : width ? width : configStyles.BUTTON.width,
|
|
62
|
+
borderRadius: borderRadius ? borderRadius : configStyles.BUTTON.borderRadius,
|
|
63
|
+
cursor: disabled ? 'not-allowed' : cursor ? cursor : configStyles.BUTTON.cursor,
|
|
64
|
+
backgroundColor:
|
|
65
|
+
(outline || !outline) && disabled ? disabledThemeBgColor ? disabledThemeBgColor : configStyles.BUTTON.disabledThemeBgColor :
|
|
66
|
+
outline && !disabled ? isHover ? backgroundColor ? backgroundColor : configStyles.BUTTON.bgColor : '#ffffff' : backgroundColor ? backgroundColor : configStyles.BUTTON.bgColor,
|
|
67
|
+
boxShadow:
|
|
68
|
+
outline ?
|
|
69
|
+
disabled ?
|
|
70
|
+
`inset 0 0 0 2px ${disabledThemeLineColor ? disabledThemeLineColor : configStyles.BUTTON.disabledThemeLineColor}` :
|
|
71
|
+
`inset 0 0 0 2px ${backgroundColor ? backgroundColor : configStyles.BUTTON.bgColor}` :
|
|
72
|
+
'none',
|
|
73
|
+
color:
|
|
74
|
+
(outline || !outline) && disabled ? disabledThemeColor ? disabledThemeColor : configStyles.BUTTON.disabledThemeColor :
|
|
75
|
+
outline && !disabled ? isHover ? color ? color : configStyles.BUTTON.color : backgroundColor ? backgroundColor : configStyles.BUTTON.bgColor : color ? color : configStyles.BUTTON.color
|
|
76
|
+
}}
|
|
77
|
+
type={type ? type : configStyles.BUTTON.type}
|
|
78
|
+
disabled={disabled ? disabled : configStyles.BUTTON.disabled}
|
|
79
|
+
onClick={disabled ? _ => _ : type !== 'submit' ? onClick ? onClick : _ => alert('Add click event handler on Button component') : _ => _}
|
|
80
|
+
onMouseEnter={handleMouseEnter}
|
|
81
|
+
onMouseLeave={handleMouseLeave}
|
|
46
82
|
className={classProps}
|
|
47
|
-
style={backgroundColor && { backgroundColor }}
|
|
48
|
-
disabled={disabled ? 'disabled': ''}
|
|
49
83
|
{...props}
|
|
50
84
|
>
|
|
51
85
|
{label}
|
|
@@ -54,38 +88,25 @@ export const Button = ({ primary, backgroundColor, theme, size, className, disab
|
|
|
54
88
|
};
|
|
55
89
|
|
|
56
90
|
Button.propTypes = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* What background color to use
|
|
63
|
-
*/
|
|
64
|
-
backgroundColor: PropTypes.string,
|
|
65
|
-
/**
|
|
66
|
-
* How large should the button be?
|
|
67
|
-
*/
|
|
68
|
-
// size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
69
|
-
/**
|
|
70
|
-
* Button contents
|
|
71
|
-
*/
|
|
72
|
-
label: PropTypes.string.isRequired,
|
|
73
|
-
/**
|
|
74
|
-
* Optional click handler
|
|
75
|
-
*/
|
|
91
|
+
type: PropTypes.string,
|
|
92
|
+
color: PropTypes.string,
|
|
93
|
+
width: PropTypes.string,
|
|
94
|
+
outline: PropTypes.bool,
|
|
76
95
|
onClick: PropTypes.func,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
96
|
+
height: PropTypes.string,
|
|
97
|
+
cursor: PropTypes.string,
|
|
98
|
+
border: PropTypes.string,
|
|
80
99
|
disabled: PropTypes.bool,
|
|
100
|
+
padding: PropTypes.string,
|
|
101
|
+
fontSize: PropTypes.string,
|
|
102
|
+
boxSizing: PropTypes.string,
|
|
81
103
|
className: PropTypes.string,
|
|
82
|
-
|
|
104
|
+
transition: PropTypes.string,
|
|
105
|
+
contentWidth: PropTypes.bool,
|
|
106
|
+
borderRadius: PropTypes.string,
|
|
107
|
+
backgroundColor: PropTypes.string,
|
|
108
|
+
label: PropTypes.string.isRequired,
|
|
109
|
+
disabledThemeColor: PropTypes.string,
|
|
110
|
+
disabledThemeBgColor: PropTypes.string,
|
|
111
|
+
disabledThemeLineColor: PropTypes.string,
|
|
83
112
|
};
|
|
84
|
-
|
|
85
|
-
Button.defaultProps = {
|
|
86
|
-
backgroundColor: null,
|
|
87
|
-
primary: false,
|
|
88
|
-
size: 'medium',
|
|
89
|
-
onClick: undefined,
|
|
90
|
-
outline: false,
|
|
91
|
-
};
|
|
@@ -1,135 +1,189 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import classnames from "classnames";
|
|
4
|
+
import { Typography } from "../typography";
|
|
5
|
+
import { compereConfigs } from "./../../utils";
|
|
6
|
+
|
|
4
7
|
import styles from "./input.module.css";
|
|
5
|
-
import {Typography} from "../typography"
|
|
6
8
|
|
|
7
9
|
export const InputTypes = {
|
|
8
10
|
TEXT: "text",
|
|
9
11
|
PASSWORD: "password",
|
|
10
|
-
EMAIL: "email",
|
|
11
|
-
NUMBER: "number",
|
|
12
|
-
TEL: "tel",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const InputSizes = {
|
|
16
|
-
SMALL: "size-small",
|
|
17
|
-
MEDIUM: "size-medium",
|
|
18
|
-
LARGE: "size-large",
|
|
19
12
|
};
|
|
20
13
|
|
|
21
14
|
export const Input = ({
|
|
22
|
-
|
|
15
|
+
type,
|
|
16
|
+
name,
|
|
23
17
|
color,
|
|
24
|
-
className,
|
|
25
18
|
label,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
value,
|
|
20
|
+
width,
|
|
21
|
+
height,
|
|
22
|
+
radius,
|
|
23
|
+
border,
|
|
24
|
+
padding,
|
|
25
|
+
tooltip,
|
|
26
|
+
bgColor,
|
|
27
|
+
leftIcon,
|
|
28
|
+
fontSize,
|
|
29
29
|
required,
|
|
30
|
-
showEye,
|
|
31
30
|
disabled,
|
|
32
|
-
type,
|
|
33
|
-
tooltip,
|
|
34
31
|
onChange,
|
|
35
|
-
|
|
32
|
+
iconWidth,
|
|
33
|
+
rightIcon,
|
|
34
|
+
className,
|
|
35
|
+
boxSizing,
|
|
36
|
+
boxShadow,
|
|
37
|
+
errorMesage,
|
|
38
|
+
borderColor,
|
|
39
|
+
placeholder,
|
|
40
|
+
autoComplete,
|
|
41
|
+
boxShadowHover,
|
|
36
42
|
...props
|
|
37
43
|
}) => {
|
|
38
|
-
const [
|
|
39
|
-
const [
|
|
44
|
+
const [show, setShow] = useState(false);
|
|
45
|
+
const [isHover, setIsHover] = useState(false);
|
|
40
46
|
const [tooltipStatus, setTooltipStatus] = useState(false);
|
|
47
|
+
|
|
48
|
+
const random = Math.floor((Math.random() * 1000) + 1);
|
|
49
|
+
const configStyles = compereConfigs();
|
|
50
|
+
const classProps = classnames(
|
|
51
|
+
className
|
|
52
|
+
);
|
|
53
|
+
|
|
41
54
|
const handleChange = (event) => {
|
|
42
|
-
|
|
43
|
-
onChange ? onChange(event.target.value) : "";
|
|
55
|
+
onChange ? onChange(event.target.value) : _ => _;
|
|
44
56
|
};
|
|
45
|
-
document.onmouseup = () => {
|
|
46
|
-
setEyeStatus("");
|
|
47
|
-
};
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
setInputValue(value);
|
|
50
|
-
}, [value]);
|
|
51
|
-
|
|
52
|
-
let eMessage = "";
|
|
53
|
-
if (errorMesage) {
|
|
54
|
-
eMessage = errorMesage;
|
|
55
|
-
} else if (regexp) {
|
|
56
|
-
const regex = new RegExp(regexp);
|
|
57
|
-
eMessage = regex.test(inputValue) ? "" : regexpError;
|
|
58
|
-
}
|
|
59
57
|
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
const handleMouseEnter = () => {
|
|
59
|
+
setIsHover(true);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const handleMouseLeave = () => {
|
|
63
|
+
setIsHover(false);
|
|
64
|
+
};
|
|
65
|
+
|
|
67
66
|
return (
|
|
68
|
-
<div className={`${styles["input-wrap"]}
|
|
69
|
-
{
|
|
70
|
-
<label className={`${styles["input-title"]}
|
|
67
|
+
<div className={`${styles["input-wrap"]}`}>
|
|
68
|
+
{
|
|
69
|
+
label ? <label className={`${styles["input-title"]}`}>
|
|
71
70
|
{label} {required && <sup style={{ color: "#ee0000" }}>*</sup>}
|
|
72
71
|
</label>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
72
|
+
: ''
|
|
73
|
+
}
|
|
74
|
+
<div
|
|
75
|
+
className={`${styles["input-content"]}`}
|
|
76
|
+
style={{
|
|
77
|
+
borderRadius: radius ? radius : configStyles.INPUT.radius,
|
|
78
|
+
boxShadow: isHover ? boxShadowHover ? boxShadowHover : configStyles.INPUT.boxShadowHover : boxShadow ? boxShadow : configStyles.INPUT.boxShadow
|
|
79
|
+
}}
|
|
80
|
+
onMouseEnter={handleMouseEnter}
|
|
81
|
+
onMouseLeave={handleMouseLeave}
|
|
82
|
+
>
|
|
83
|
+
{
|
|
84
|
+
leftIcon && leftIcon.length > 0 ?
|
|
85
|
+
<div
|
|
86
|
+
onMouseUp={type === 'password' ? _ => setShow(false) : _ => _}
|
|
87
|
+
onMouseDown={type === 'password' ? _ => setShow(true) : _ => _}
|
|
88
|
+
onMouseOut={type === 'password' ? _ => setShow(false) : _ => _}
|
|
89
|
+
style={{
|
|
90
|
+
cursor: type === 'password' ? 'pointer' : 'default',
|
|
91
|
+
height: height ? height : configStyles.INPUT.height,
|
|
92
|
+
padding: padding ? padding : configStyles.INPUT.padding,
|
|
93
|
+
width: iconWidth ? iconWidth : configStyles.INPUT.iconWidth,
|
|
94
|
+
boxSizing: boxSizing ? boxSizing : configStyles.INPUT.boxSizing,
|
|
95
|
+
borderTopLeftRadius: radius ? radius : configStyles.INPUT.radius,
|
|
96
|
+
borderBottomLeftRadius: radius ? radius : configStyles.INPUT.radius,
|
|
97
|
+
backgroundColor: disabled ? '#FBFBFB' : bgColor ? bgColor : configStyles.INPUT.bgColor,
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
{type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]}
|
|
101
|
+
</div> : ''
|
|
102
|
+
}
|
|
103
|
+
<input
|
|
104
|
+
{...props}
|
|
105
|
+
value={value}
|
|
106
|
+
className={classProps}
|
|
107
|
+
onChange={handleChange}
|
|
108
|
+
type={show ? 'text' : type}
|
|
109
|
+
disabled={disabled ? disabled : ""}
|
|
110
|
+
name={name ? name : `tui_${random}_tui`}
|
|
111
|
+
placeholder={placeholder ? placeholder : ''}
|
|
112
|
+
autoComplete={autoComplete ? autoComplete : configStyles.INPUT.autoComplete}
|
|
113
|
+
style={{
|
|
114
|
+
border: 'none',
|
|
115
|
+
outline: 'none',
|
|
116
|
+
pointerEvents: disabled ? 'none' : 'auto',
|
|
117
|
+
width: width ? width : configStyles.INPUT.width,
|
|
118
|
+
height: height ? height : configStyles.INPUT.height,
|
|
119
|
+
padding: padding ? padding : configStyles.INPUT.padding,
|
|
120
|
+
borderRadius: radius ? radius : configStyles.INPUT.radius,
|
|
121
|
+
fontSize: fontSize ? fontSize : configStyles.INPUT.fontSize,
|
|
122
|
+
boxSizing: boxSizing ? boxSizing : configStyles.INPUT.boxSizing,
|
|
123
|
+
color: errorMesage ? 'rgba(238, 0, 0, 1)' : color ? color : configStyles.INPUT.color,
|
|
124
|
+
backgroundColor: disabled ? '#FBFBFB' : bgColor ? bgColor : configStyles.INPUT.bgColor,
|
|
90
125
|
}}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
126
|
+
/>
|
|
127
|
+
{
|
|
128
|
+
rightIcon && rightIcon.length > 0 ?
|
|
129
|
+
<div
|
|
130
|
+
onMouseUp={type === 'password' ? _ => setShow(false) : _ => _}
|
|
131
|
+
onMouseDown={type === 'password' ? _ => setShow(true) : _ => _}
|
|
132
|
+
onMouseOut={type === 'password' ? _ => setShow(false) : _ => _}
|
|
133
|
+
style={{
|
|
134
|
+
cursor: type === 'password' ? 'pointer' : 'default',
|
|
135
|
+
border: border ? border : configStyles.INPUT.border,
|
|
136
|
+
height: height ? height : configStyles.INPUT.height,
|
|
137
|
+
padding: padding ? padding : configStyles.INPUT.padding,
|
|
138
|
+
width: iconWidth ? iconWidth : configStyles.INPUT.iconWidth,
|
|
139
|
+
boxSizing: boxSizing ? boxSizing : configStyles.INPUT.boxSizing,
|
|
140
|
+
borderTopRightRadius: radius ? radius : configStyles.INPUT.radius,
|
|
141
|
+
borderBottomRightRadius: radius ? radius : configStyles.INPUT.radius,
|
|
142
|
+
backgroundColor: disabled ? '#FBFBFB' : bgColor ? bgColor : configStyles.INPUT.bgColor,
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
{type === 'password' ? show ? rightIcon[1] : rightIcon[0] : rightIcon[0]}
|
|
146
|
+
</div> : ''
|
|
147
|
+
}
|
|
148
|
+
</div>
|
|
149
|
+
{
|
|
150
|
+
tooltip ? <Typography variant="p" onClick={()=> setTooltipStatus(!tooltipStatus)}>
|
|
151
|
+
ⓘ
|
|
152
|
+
</Typography> : null
|
|
153
|
+
}
|
|
103
154
|
{tooltipStatus ? <p>{tooltip}</p> : null}
|
|
104
|
-
{
|
|
155
|
+
{errorMesage ? <span className={styles.inputErrorMessages}>{errorMesage}</span> : ""}
|
|
105
156
|
</div>
|
|
106
157
|
);
|
|
107
158
|
};
|
|
108
159
|
|
|
109
160
|
Input.propTypes = {
|
|
110
|
-
|
|
111
|
-
size: PropTypes.oneOf(Object.values(InputSizes)),
|
|
161
|
+
name: PropTypes.string,
|
|
112
162
|
color: PropTypes.string,
|
|
113
|
-
|
|
163
|
+
value: PropTypes.string,
|
|
164
|
+
width: PropTypes.string,
|
|
165
|
+
label: PropTypes.string,
|
|
114
166
|
onChange: PropTypes.func,
|
|
115
167
|
required: PropTypes.bool,
|
|
116
|
-
errorMesage: PropTypes.string,
|
|
117
|
-
regexp: PropTypes.string,
|
|
118
|
-
regexpError: PropTypes.string,
|
|
119
|
-
label: PropTypes.string.isRequired,
|
|
120
168
|
disabled: PropTypes.bool,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
169
|
+
height: PropTypes.string,
|
|
170
|
+
radius: PropTypes.string,
|
|
171
|
+
bgColor: PropTypes.string,
|
|
172
|
+
fontSize: PropTypes.string,
|
|
173
|
+
tooltip: PropTypes.element,
|
|
174
|
+
className: PropTypes.string,
|
|
175
|
+
iconWidth: PropTypes.string,
|
|
176
|
+
boxSizing: PropTypes.string,
|
|
177
|
+
boxShadow: PropTypes.string,
|
|
178
|
+
placeholder: PropTypes.string,
|
|
179
|
+
errorMesage: PropTypes.string,
|
|
180
|
+
autoComplete: PropTypes.string,
|
|
181
|
+
boxShadowHover: PropTypes.string,
|
|
182
|
+
leftIcon: PropTypes.arrayOf(PropTypes.element),
|
|
183
|
+
rightIcon: PropTypes.arrayOf(PropTypes.element),
|
|
184
|
+
type: PropTypes.oneOf(Object.values(InputTypes)),
|
|
124
185
|
};
|
|
125
186
|
|
|
126
187
|
Input.defaultProps = {
|
|
127
|
-
label: "",
|
|
128
|
-
color: null,
|
|
129
|
-
size: InputSizes.MEDIUM,
|
|
130
|
-
onChange: undefined,
|
|
131
|
-
required: false,
|
|
132
|
-
errorMesage: "",
|
|
133
188
|
type: "text",
|
|
134
|
-
value: ""
|
|
135
189
|
};
|
|
@@ -1,98 +1,30 @@
|
|
|
1
|
-
/*.inputs{*/
|
|
2
|
-
/*display: flex;*/
|
|
3
|
-
/*flex-direction: column;*/
|
|
4
|
-
/*}*/
|
|
5
|
-
/*.inp {*/
|
|
6
|
-
/*border-radius: 4px;*/
|
|
7
|
-
/*box-sizing: border-box;*/
|
|
8
|
-
/*}*/
|
|
9
|
-
|
|
10
|
-
/*.inputErrorMessages {*/
|
|
11
|
-
/*color: red;*/
|
|
12
|
-
/*font-size: 10px;*/
|
|
13
|
-
/*}*/
|
|
14
|
-
|
|
15
1
|
.input-wrap {
|
|
16
|
-
position: relative;
|
|
17
|
-
max-width: 400px;
|
|
18
|
-
}
|
|
19
|
-
.input {
|
|
20
|
-
font-size: 16px;
|
|
21
|
-
line-height: 20px;
|
|
22
|
-
border-radius: 6px;
|
|
23
|
-
color: rgba(60, 57, 62, 1);
|
|
24
|
-
box-shadow: 0 0 0 2px rgba(209, 209, 209, 1) inset;
|
|
25
|
-
border: none;
|
|
26
|
-
outline: none;
|
|
27
|
-
box-sizing: border-box;
|
|
28
|
-
transition: background-color 240ms, color 240ms;
|
|
29
|
-
overflow: hidden;
|
|
30
|
-
cursor: text;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.input.full-size {
|
|
34
2
|
width: 100%;
|
|
35
3
|
}
|
|
36
4
|
|
|
37
|
-
.input
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.input.size-medium {
|
|
42
|
-
min-height: 46px;
|
|
43
|
-
padding: 12px 15px;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.input.with-icon {
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.input:hover {
|
|
51
|
-
box-shadow: 0 0 0 2px rgba(60, 57, 62, 1) inset;
|
|
5
|
+
.input-content {
|
|
6
|
+
display: flex;
|
|
7
|
+
width: 100%;
|
|
52
8
|
}
|
|
53
9
|
|
|
54
|
-
.input
|
|
55
|
-
|
|
10
|
+
.input-title {
|
|
11
|
+
display: block;
|
|
12
|
+
font-size: 16px;
|
|
13
|
+
color: #3c393e;
|
|
14
|
+
font-weight: 500;
|
|
15
|
+
line-height: 22px;
|
|
16
|
+
margin-bottom: 6px;
|
|
56
17
|
}
|
|
57
18
|
|
|
58
19
|
.inputErrorMessages {
|
|
59
|
-
position: absolute;
|
|
60
20
|
font-size: 14px;
|
|
61
21
|
line-height: 19px;
|
|
62
|
-
bottom: 0;
|
|
63
|
-
left: 0;
|
|
64
|
-
transform: scale3d(0,0,0);
|
|
65
22
|
color: rgba(238, 0, 0, 1);
|
|
66
|
-
animation: error-message-show 240ms forwards;
|
|
67
|
-
z-index: 1;
|
|
68
|
-
}
|
|
69
|
-
.labelInput{
|
|
70
|
-
color: black;
|
|
71
|
-
}
|
|
72
|
-
.input.state-disabled {
|
|
73
|
-
background-color: #FBFBFB;
|
|
74
|
-
pointer-events: none;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.input.error-message {
|
|
78
|
-
box-shadow: 0 0 0 2px rgba(238, 0, 0, 1) inset;
|
|
79
23
|
}
|
|
80
24
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
color:
|
|
86
|
-
display: block;
|
|
87
|
-
font-size: 16px;
|
|
88
|
-
font-weight: 500;
|
|
89
|
-
line-height: 22px;
|
|
90
|
-
margin-bottom: 6px;
|
|
91
|
-
text-transform: none;
|
|
25
|
+
input:-webkit-autofill,
|
|
26
|
+
input:-webkit-autofill:hover,
|
|
27
|
+
input:-webkit-autofill:focus,
|
|
28
|
+
input:-webkit-autofill:active {
|
|
29
|
+
background-color: inherit !important;
|
|
92
30
|
}
|
|
93
|
-
@keyframes error-message-show {
|
|
94
|
-
100% {
|
|
95
|
-
bottom: -20px;
|
|
96
|
-
transform: scale3d(1,1,1);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Input, InputTypes
|
|
2
|
+
import { Input, InputTypes } from "./index";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
component: Input,
|
|
@@ -10,7 +10,6 @@ const Template = (args) => <Input {...args} />;
|
|
|
10
10
|
|
|
11
11
|
export const Default = Template.bind({});
|
|
12
12
|
Default.args = {
|
|
13
|
-
size: InputSizes.MEDIUM,
|
|
14
13
|
type: InputTypes.TEXT,
|
|
15
14
|
onChange: (val) => {}
|
|
16
15
|
};
|
|
@@ -18,22 +17,4 @@ Default.args = {
|
|
|
18
17
|
export const PASSWORD = Template.bind({});
|
|
19
18
|
PASSWORD.args = {
|
|
20
19
|
type: InputTypes.PASSWORD,
|
|
21
|
-
regexp: "('A'-'Z')",
|
|
22
|
-
regexpError: "Գաղտնաբառը պետք է պարունակի մեկ մեծատառ",
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const EMAIL = Template.bind({});
|
|
26
|
-
EMAIL.args = {
|
|
27
|
-
type: InputTypes.EMAIL,
|
|
28
|
-
errorMesage: "Գոյություն չունեցող էլ. հասցե",
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const TEL = Template.bind({});
|
|
32
|
-
TEL.args = {
|
|
33
|
-
type: InputTypes.TEL,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const NUMBER = Template.bind({});
|
|
37
|
-
NUMBER.args = {
|
|
38
|
-
type: InputTypes.NUMBER,
|
|
39
20
|
};
|