@capillarytech/blaze-ui 0.1.3 → 0.1.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapInput/CapInput.js +67 -0
- package/CapInput/Number.js +38 -0
- package/CapInput/Search.js +32 -0
- package/CapInput/TextArea.js +45 -0
- package/CapInput/index.js +11 -0
- package/CapInput/loadable.js +9 -0
- package/CapInput/messages.js +27 -0
- package/CapInput/styles.js +81 -0
- package/index.js +6 -0
- package/package.json +7 -6
- package/styled/index.js +6 -0
- package/styled/variables.js +89 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Input } from 'antd';
|
|
4
|
+
import { WarningOutlined, CheckCircleOutlined } from '@ant-design/icons';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import * as styledVars from '../styled/variables';
|
|
7
|
+
|
|
8
|
+
const StyledIcon = styled.span`
|
|
9
|
+
color: ${(props) => props.status === "error" && styledVars.CAP_RED};
|
|
10
|
+
color: ${(props) => props.status === "success" && styledVars.CAP_PRIMARY.base};
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const CapInput = React.forwardRef((props, ref) => {
|
|
14
|
+
const {
|
|
15
|
+
alwaysShowFocus,
|
|
16
|
+
errorMessage,
|
|
17
|
+
isVerified,
|
|
18
|
+
suffix,
|
|
19
|
+
showSuffix = true,
|
|
20
|
+
...rest
|
|
21
|
+
} = props;
|
|
22
|
+
|
|
23
|
+
const inputRef = useRef(null);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (alwaysShowFocus && inputRef.current) {
|
|
27
|
+
inputRef.current.focus();
|
|
28
|
+
}
|
|
29
|
+
}, [alwaysShowFocus]);
|
|
30
|
+
|
|
31
|
+
const inputSuffix = (errorMessage && (
|
|
32
|
+
<StyledIcon status="error">
|
|
33
|
+
<WarningOutlined />
|
|
34
|
+
</StyledIcon>
|
|
35
|
+
)) || (isVerified && (
|
|
36
|
+
<StyledIcon status="success">
|
|
37
|
+
<CheckCircleOutlined />
|
|
38
|
+
</StyledIcon>
|
|
39
|
+
)) || suffix || null;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Input
|
|
43
|
+
{...rest}
|
|
44
|
+
ref={ref || inputRef}
|
|
45
|
+
suffix={showSuffix === false ? null : inputSuffix}
|
|
46
|
+
status={errorMessage ? 'error' : undefined}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
CapInput.displayName = 'CapInput';
|
|
52
|
+
|
|
53
|
+
CapInput.propTypes = {
|
|
54
|
+
alwaysShowFocus: PropTypes.bool,
|
|
55
|
+
errorMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
56
|
+
isVerified: PropTypes.bool,
|
|
57
|
+
size: PropTypes.oneOf(['large', 'middle', 'small']),
|
|
58
|
+
suffix: PropTypes.node,
|
|
59
|
+
showSuffix: PropTypes.bool,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
CapInput.defaultProps = {
|
|
63
|
+
size: 'large',
|
|
64
|
+
showSuffix: true,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default CapInput;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { InputNumber } from 'antd';
|
|
4
|
+
|
|
5
|
+
const CapInputNumber = React.forwardRef((props, ref) => {
|
|
6
|
+
const { size = 'large', ...rest } = props;
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<InputNumber
|
|
10
|
+
{...rest}
|
|
11
|
+
ref={ref}
|
|
12
|
+
size={size}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
CapInputNumber.displayName = 'CapInputNumber';
|
|
18
|
+
|
|
19
|
+
CapInputNumber.propTypes = {
|
|
20
|
+
size: PropTypes.oneOf(['large', 'middle', 'small']),
|
|
21
|
+
min: PropTypes.number,
|
|
22
|
+
max: PropTypes.number,
|
|
23
|
+
step: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
24
|
+
precision: PropTypes.number,
|
|
25
|
+
decimalSeparator: PropTypes.string,
|
|
26
|
+
formatter: PropTypes.func,
|
|
27
|
+
parser: PropTypes.func,
|
|
28
|
+
controls: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
29
|
+
keyboard: PropTypes.bool,
|
|
30
|
+
stringMode: PropTypes.bool,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
CapInputNumber.defaultProps = {
|
|
34
|
+
size: 'large',
|
|
35
|
+
keyboard: true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default CapInputNumber;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Input } from 'antd';
|
|
4
|
+
|
|
5
|
+
const { Search } = Input;
|
|
6
|
+
|
|
7
|
+
const CapInputSearch = React.forwardRef((props, ref) => {
|
|
8
|
+
const { size = 'large', ...rest } = props;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<Search
|
|
12
|
+
{...rest}
|
|
13
|
+
ref={ref}
|
|
14
|
+
size={size}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
CapInputSearch.displayName = 'CapInputSearch';
|
|
20
|
+
|
|
21
|
+
CapInputSearch.propTypes = {
|
|
22
|
+
size: PropTypes.oneOf(['large', 'middle', 'small']),
|
|
23
|
+
enterButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
24
|
+
loading: PropTypes.bool,
|
|
25
|
+
onSearch: PropTypes.func,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
CapInputSearch.defaultProps = {
|
|
29
|
+
size: 'large',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default CapInputSearch;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Input } from 'antd';
|
|
4
|
+
|
|
5
|
+
const { TextArea } = Input;
|
|
6
|
+
|
|
7
|
+
const CapInputTextArea = React.forwardRef((props, ref) => {
|
|
8
|
+
const { size = 'large', ...rest } = props;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<TextArea
|
|
12
|
+
{...rest}
|
|
13
|
+
ref={ref}
|
|
14
|
+
size={size}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
CapInputTextArea.displayName = 'CapInputTextArea';
|
|
20
|
+
|
|
21
|
+
CapInputTextArea.propTypes = {
|
|
22
|
+
size: PropTypes.oneOf(['large', 'middle', 'small']),
|
|
23
|
+
autoSize: PropTypes.oneOfType([
|
|
24
|
+
PropTypes.bool,
|
|
25
|
+
PropTypes.shape({
|
|
26
|
+
minRows: PropTypes.number,
|
|
27
|
+
maxRows: PropTypes.number,
|
|
28
|
+
}),
|
|
29
|
+
]),
|
|
30
|
+
rows: PropTypes.number,
|
|
31
|
+
maxLength: PropTypes.number,
|
|
32
|
+
showCount: PropTypes.oneOfType([
|
|
33
|
+
PropTypes.bool,
|
|
34
|
+
PropTypes.shape({
|
|
35
|
+
formatter: PropTypes.func,
|
|
36
|
+
}),
|
|
37
|
+
]),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
CapInputTextArea.defaultProps = {
|
|
41
|
+
size: 'large',
|
|
42
|
+
rows: 4,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default CapInputTextArea;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import CapInput from './CapInput';
|
|
2
|
+
import Search from './Search';
|
|
3
|
+
import TextArea from './TextArea';
|
|
4
|
+
import Number from './Number';
|
|
5
|
+
|
|
6
|
+
// Attach subcomponents to the main component
|
|
7
|
+
CapInput.Search = Search;
|
|
8
|
+
CapInput.TextArea = TextArea;
|
|
9
|
+
CapInput.Number = Number;
|
|
10
|
+
|
|
11
|
+
export default CapInput;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* CapInput Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the CapInput component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
const scope = 'blaze.components.CapInput';
|
|
9
|
+
|
|
10
|
+
export default defineMessages({
|
|
11
|
+
placeholder: {
|
|
12
|
+
id: `${scope}.placeholder`,
|
|
13
|
+
defaultMessage: 'Enter text...',
|
|
14
|
+
},
|
|
15
|
+
searchPlaceholder: {
|
|
16
|
+
id: `${scope}.searchPlaceholder`,
|
|
17
|
+
defaultMessage: 'Search...',
|
|
18
|
+
},
|
|
19
|
+
textAreaPlaceholder: {
|
|
20
|
+
id: `${scope}.textAreaPlaceholder`,
|
|
21
|
+
defaultMessage: 'Enter your text here...',
|
|
22
|
+
},
|
|
23
|
+
numberPlaceholder: {
|
|
24
|
+
id: `${scope}.numberPlaceholder`,
|
|
25
|
+
defaultMessage: 'Enter number...',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { css } from 'styled-components';
|
|
2
|
+
import * as styledVars from '../styled/variables';
|
|
3
|
+
|
|
4
|
+
export const inputStyles = css`
|
|
5
|
+
&.ant-input,
|
|
6
|
+
&.ant-input-affix-wrapper,
|
|
7
|
+
&.ant-input-number,
|
|
8
|
+
&.ant-input-textarea {
|
|
9
|
+
font-family: ${styledVars.FONT_FAMILY};
|
|
10
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
11
|
+
transition: ${styledVars.TRANSITION_ALL};
|
|
12
|
+
|
|
13
|
+
&:hover {
|
|
14
|
+
border-color: ${styledVars.CAP_G11};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:focus,
|
|
18
|
+
&.ant-input-affix-wrapper-focused {
|
|
19
|
+
border-color: ${styledVars.CAP_G01};
|
|
20
|
+
box-shadow: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.ant-input-status-error,
|
|
24
|
+
&.ant-input-affix-wrapper-status-error,
|
|
25
|
+
&.ant-input-number-status-error {
|
|
26
|
+
border-color: ${styledVars.CAP_RED};
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
border-color: ${styledVars.CAP_RED};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:focus,
|
|
33
|
+
&.ant-input-affix-wrapper-focused {
|
|
34
|
+
border-color: ${styledVars.CAP_RED};
|
|
35
|
+
box-shadow: none;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.ant-input-disabled,
|
|
40
|
+
&.ant-input-affix-wrapper-disabled {
|
|
41
|
+
background-color: ${styledVars.CAP_G08};
|
|
42
|
+
cursor: not-allowed;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Size variations */
|
|
47
|
+
&.ant-input-lg,
|
|
48
|
+
&.ant-input-affix-wrapper-lg {
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
padding: 10px 12px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* TextArea specific */
|
|
54
|
+
&.ant-input-textarea {
|
|
55
|
+
.ant-input {
|
|
56
|
+
font-family: ${styledVars.FONT_FAMILY};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Number input specific */
|
|
61
|
+
&.ant-input-number {
|
|
62
|
+
width: 100%;
|
|
63
|
+
|
|
64
|
+
.ant-input-number-handler-wrap {
|
|
65
|
+
opacity: 1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Search input specific */
|
|
70
|
+
&.ant-input-search {
|
|
71
|
+
.ant-input-search-button {
|
|
72
|
+
background-color: ${styledVars.CAP_PRIMARY.base};
|
|
73
|
+
border-color: ${styledVars.CAP_PRIMARY.base};
|
|
74
|
+
|
|
75
|
+
&:hover {
|
|
76
|
+
background-color: ${styledVars.CAP_PRIMARY.hover};
|
|
77
|
+
border-color: ${styledVars.CAP_PRIMARY.hover};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`;
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/blaze-ui",
|
|
3
3
|
"author": "Capillary Technologies",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4-alpha.1",
|
|
5
5
|
"description": "Capillary UI component library with Ant Design v5",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/esm/index.js",
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"files": [
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
21
|
+
"*",
|
|
22
|
+
"!*.test.js",
|
|
23
|
+
"!*.spec.js",
|
|
24
|
+
"!**/__tests__",
|
|
25
|
+
"!**/__snapshots__",
|
|
26
|
+
"!**/tests"
|
|
26
27
|
],
|
|
27
28
|
"homepage": "https://github.com/Capillary/blaze-ui",
|
|
28
29
|
"peerDependencies": {
|
package/styled/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* Color Palette */
|
|
2
|
+
//========================
|
|
3
|
+
|
|
4
|
+
// Primary colors
|
|
5
|
+
export const CAP_PRIMARY = {
|
|
6
|
+
base: "#47af46",
|
|
7
|
+
hover: "#1f9a1d",
|
|
8
|
+
disabled: "#a1d8a0",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Secondary colors
|
|
12
|
+
export const CAP_SECONDARY = {
|
|
13
|
+
base: "#2466ea",
|
|
14
|
+
light: 'rgba("#2466ea", 0.1)',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Custom colors
|
|
18
|
+
export const CAP_ORANGE = "#f87d23";
|
|
19
|
+
export const CAP_ORANGE01 = "#ffe5d2";
|
|
20
|
+
export const CAP_ORANGE02 = "#fa7d02";
|
|
21
|
+
export const CAP_YELLOW = "#fec52e";
|
|
22
|
+
export const CAP_YELLOW01 = "#e8bc25";
|
|
23
|
+
export const CAP_YELLOW02 = "#f9d438";
|
|
24
|
+
export const CAP_BLUE = "#23cccc";
|
|
25
|
+
export const CAP_PURPLE = "#8517e5";
|
|
26
|
+
export const CAP_PINK = "#e51fa3";
|
|
27
|
+
export const CAP_RED = "#ea213a";
|
|
28
|
+
export const CAP_ICON = "#7a869a";
|
|
29
|
+
export const CAP_PALE_GREY = "#e9f0fe";
|
|
30
|
+
export const CAP_BLUE01 = "#2466eb";
|
|
31
|
+
export const CAP_BLUE02 = "#1d61ee";
|
|
32
|
+
export const CAP_RED01 = "#e51fa3";
|
|
33
|
+
export const CAP_RED02 = "#f5222d";
|
|
34
|
+
export const CAP_RED03 = "#ed1b34";
|
|
35
|
+
export const CAP_PURPLE01 = "#6563ff";
|
|
36
|
+
export const CAP_PURPLE02 = "#a451ff";
|
|
37
|
+
export const CAP_PURPLE03 = "#f2e7fe";
|
|
38
|
+
export const CAP_PURPLE04 = "#d4e1fc";
|
|
39
|
+
export const CAP_GREEN01 = "#6bb56b";
|
|
40
|
+
export const CAP_GREEN02 = "#ecf7ec";
|
|
41
|
+
|
|
42
|
+
// Grey colors
|
|
43
|
+
export const CAP_G01 = "#091e42";
|
|
44
|
+
export const CAP_G02 = "#253858";
|
|
45
|
+
export const CAP_G03 = "#42526e";
|
|
46
|
+
export const CAP_G04 = "#5e6c84";
|
|
47
|
+
export const CAP_G05 = "#97a0af";
|
|
48
|
+
export const CAP_G06 = "#b3bac5";
|
|
49
|
+
export const CAP_G07 = "#dfe2e7";
|
|
50
|
+
export const CAP_G08 = "#ebecf0";
|
|
51
|
+
export const CAP_G09 = "#f4f5f7";
|
|
52
|
+
export const CAP_G10 = "#fafbfc";
|
|
53
|
+
export const CAP_G11 = "#7a869a";
|
|
54
|
+
export const CAP_G12 = "#e8e8e8";
|
|
55
|
+
export const CAP_G13 = "#ecece7";
|
|
56
|
+
export const CAP_G14 = "#e9f0fd";
|
|
57
|
+
export const CAP_G15 = "#efefef";
|
|
58
|
+
export const CAP_G16 = "#2a2a2a";
|
|
59
|
+
export const CAP_G17 = "#7F8185";
|
|
60
|
+
export const CAP_G18 = "#dcdee2";
|
|
61
|
+
export const CAP_G19 = "#8a9ab2";
|
|
62
|
+
export const CAP_G20 = "#c2c2c2";
|
|
63
|
+
|
|
64
|
+
export const CAP_WHITE = "#ffffff";
|
|
65
|
+
export const CAP_BLACK = "#000000";
|
|
66
|
+
|
|
67
|
+
/* Fonts */
|
|
68
|
+
// ==============
|
|
69
|
+
export const FONT_FAMILY = '"Roboto", sans-serif';
|
|
70
|
+
export const FONT_WEIGHT_REGULAR = 400;
|
|
71
|
+
export const FONT_WEIGHT_MEDIUM = 500;
|
|
72
|
+
|
|
73
|
+
/* Spacing */
|
|
74
|
+
// ==============
|
|
75
|
+
export const SPACING_04 = "4px";
|
|
76
|
+
export const SPACING_08 = "8px";
|
|
77
|
+
export const SPACING_12 = "12px";
|
|
78
|
+
export const SPACING_16 = "16px";
|
|
79
|
+
export const SPACING_24 = "24px";
|
|
80
|
+
export const SPACING_32 = "32px";
|
|
81
|
+
|
|
82
|
+
/* Border Radius */
|
|
83
|
+
// ==============
|
|
84
|
+
export const RADIUS_04 = "4px";
|
|
85
|
+
export const RADIUS_08 = "8px";
|
|
86
|
+
|
|
87
|
+
/* Transition */
|
|
88
|
+
// ==============
|
|
89
|
+
export const TRANSITION_ALL = "all 0.3s ease";
|