@dnanpm/styleguide 1.8.0 → 1.8.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/build/cjs/components/AmountSelector/AmountSelector.js +8 -3
- package/build/cjs/components/Input/Input.js +4 -4
- package/build/cjs/components/Selectbox/Selectbox.d.ts +7 -4
- package/build/cjs/components/Selectbox/Selectbox.js +7 -7
- package/build/es/components/AmountSelector/AmountSelector.js +8 -3
- package/build/es/components/Input/Input.js +4 -4
- package/build/es/components/Selectbox/Selectbox.d.ts +7 -4
- package/build/es/components/Selectbox/Selectbox.js +7 -7
- package/package.json +1 -1
|
@@ -28,10 +28,14 @@ const Container = styled['default'].div `
|
|
|
28
28
|
input {
|
|
29
29
|
width: ${styledUtils.getMultipliedSize(theme['default'].base.baseWidth, 4)};
|
|
30
30
|
border: 0 none;
|
|
31
|
-
text-align:
|
|
31
|
+
text-align: center;
|
|
32
32
|
outline: none;
|
|
33
33
|
-webkit-appearance: none;
|
|
34
34
|
-moz-appearance: textfield;
|
|
35
|
+
&::-webkit-outer-spin-button,
|
|
36
|
+
&::-webkit-inner-spin-button {
|
|
37
|
+
display: none;
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
`;
|
|
37
41
|
const StyledButtonSecondary = styled['default'](ButtonSecondary['default']) `
|
|
@@ -69,10 +73,11 @@ const AmountSelector = ({ onChange, value = 1, step = 1, min = 1, max, disabled
|
|
|
69
73
|
}
|
|
70
74
|
};
|
|
71
75
|
return (React__default['default'].createElement(Container, { disabled: disabled, "data-testid": dataTestId, className: props.className },
|
|
72
|
-
React__default['default'].createElement(StyledButtonSecondary, { disabled: disabled, onClick: decrease
|
|
76
|
+
React__default['default'].createElement(StyledButtonSecondary, { disabled: disabled, onClick: decrease, "data-testid": dataTestId &&
|
|
77
|
+
`${dataTestId}${props.removable && isMinReached(value - step) ? '-remove' : '-decrease'}` },
|
|
73
78
|
React__default['default'].createElement(Icon['default'], { color: theme['default'].color.black, name: props.removable && isMinReached(value - step) ? 'hlTrash' : 'hlMinus' })),
|
|
74
79
|
React__default['default'].createElement("input", { id: props.id, name: props.name, type: "number", onChange: handleChange, value: value, readOnly: readonly || disabled, disabled: disabled }),
|
|
75
|
-
React__default['default'].createElement(StyledButtonSecondary, { disabled: disabled, onClick: increase },
|
|
80
|
+
React__default['default'].createElement(StyledButtonSecondary, { disabled: disabled, onClick: increase, "data-testid": dataTestId ? `${dataTestId}-increase` : undefined },
|
|
76
81
|
React__default['default'].createElement(Icon['default'], { color: theme['default'].color.black, name: "hlPlus" }))));
|
|
77
82
|
};
|
|
78
83
|
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var styled = require('../../themes/styled.js');
|
|
7
7
|
var styledUtils = require('../../utils/styledUtils.js');
|
|
8
|
-
var LabelText = require('../LabelText/LabelText.js');
|
|
9
8
|
var Icon = require('../Icon/Icon.js');
|
|
9
|
+
var LabelText = require('../LabelText/LabelText.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
12
|
|
|
@@ -19,7 +19,7 @@ const Tag = styled['default'].input `
|
|
|
19
19
|
padding: 0 ${props => styledUtils.getMultipliedSize(props.theme.base.baseWidth, 1)};
|
|
20
20
|
font-size: ${props => props.theme.fontSize.defaultFontSize};
|
|
21
21
|
width: 100%;
|
|
22
|
-
height:
|
|
22
|
+
height: ${props => styledUtils.getMultipliedSize(props.theme.base.baseHeight, 4)};
|
|
23
23
|
border: 1px solid ${props => props.theme.color.gray15};
|
|
24
24
|
&::-ms-clear,
|
|
25
25
|
&::-ms-reveal {
|
|
@@ -51,8 +51,8 @@ const FieldWrapper = styled['default'].div `
|
|
|
51
51
|
position: absolute;
|
|
52
52
|
z-index: 1;
|
|
53
53
|
top: 0;
|
|
54
|
-
right:
|
|
55
|
-
height:
|
|
54
|
+
right: ${props => styledUtils.getMultipliedSize(props.theme.base.baseWidth, 1)};
|
|
55
|
+
height: ${props => styledUtils.getMultipliedSize(props.theme.base.baseHeight, 4)};
|
|
56
56
|
}
|
|
57
57
|
`;
|
|
58
58
|
const FieldContainer = styled['default'].div `
|
|
@@ -9,23 +9,26 @@ interface DropDownIndicator {
|
|
|
9
9
|
iconSize?: string;
|
|
10
10
|
}
|
|
11
11
|
interface Props {
|
|
12
|
+
options: ReactSelectProps['options'];
|
|
13
|
+
onChange: (selectedItem: SelectboxItem) => void;
|
|
12
14
|
/** Allows to pass a custom className */
|
|
13
15
|
className?: string;
|
|
16
|
+
'data-testid'?: string;
|
|
14
17
|
label?: string;
|
|
15
18
|
inputId?: ReactSelectProps['inputId'];
|
|
16
19
|
placeholder?: ReactSelectProps['placeholder'];
|
|
17
|
-
|
|
18
|
-
options: ReactSelectProps['options'];
|
|
20
|
+
onInputChange?: ReactSelectProps['onInputChange'];
|
|
19
21
|
value?: ReactSelectProps['value'];
|
|
20
|
-
'data-testid'?: string;
|
|
21
22
|
dropDownIndicator?: DropDownIndicator;
|
|
22
23
|
noOptionsText?: string;
|
|
23
24
|
isSearchable?: boolean;
|
|
25
|
+
isClearable?: boolean;
|
|
26
|
+
isMulti?: boolean;
|
|
24
27
|
isLoading?: boolean;
|
|
25
28
|
isDisabled?: boolean;
|
|
26
29
|
isRequired?: boolean;
|
|
27
30
|
error?: boolean;
|
|
28
31
|
errorMessage?: string;
|
|
29
32
|
}
|
|
30
|
-
declare const SelectBox: ({
|
|
33
|
+
declare const SelectBox: ({ dropDownIndicator, "data-testid": dataTestId, isSearchable, isClearable, isMulti, noOptionsText, isLoading, isDisabled, isRequired, error, ...props }: Props) => JSX.Element;
|
|
31
34
|
export default SelectBox;
|
|
@@ -45,7 +45,7 @@ const selectBoxStyles = {
|
|
|
45
45
|
control: (styles, state) => {
|
|
46
46
|
const customControlStyles = {
|
|
47
47
|
...borderStyles,
|
|
48
|
-
height: '
|
|
48
|
+
height: styledUtils.getMultipliedSize(theme['default'].base.baseHeight, 4),
|
|
49
49
|
borderBottomColor: state.menuIsOpen ? theme['default'].color.white : 'inherit',
|
|
50
50
|
'&:hover': {
|
|
51
51
|
borderColor: theme['default'].color.gray25,
|
|
@@ -89,7 +89,7 @@ const selectBoxStyles = {
|
|
|
89
89
|
return { ...styles, ...customOptionStyles };
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
|
-
const SelectBox = ({
|
|
92
|
+
const SelectBox = ({ dropDownIndicator, 'data-testid': dataTestId, isSearchable = false, isClearable = false, isMulti = false, noOptionsText = '', isLoading = false, isDisabled = false, isRequired = false, error = false, ...props }) => {
|
|
93
93
|
const getNoOptionsText = () => noOptionsText;
|
|
94
94
|
const DropdownIndicator = (dropdownIndicatorProps) => {
|
|
95
95
|
const { color = isDisabled ? theme['default'].color.gray40 : theme['default'].color.black, iconSize = '1rem' } = {
|
|
@@ -106,13 +106,13 @@ const SelectBox = ({ className, label, onChange, options, value, inputId, dropDo
|
|
|
106
106
|
return (Select.components.DropdownIndicator && (React__default['default'].createElement(Select.components.DropdownIndicator, Object.assign({}, dropdownIndicatorProps),
|
|
107
107
|
React__default['default'].createElement(Icon['default'], { color: color, name: getIconName(), size: iconSize }))));
|
|
108
108
|
};
|
|
109
|
-
return (React__default['default'].createElement("div", { className: className, "data-testid": dataTestId }, !isLoading ? (React__default['default'].createElement(FieldContainer, { disabled: isDisabled, error: error },
|
|
110
|
-
label && (React__default['default'].createElement(LabelText.LabelText, { htmlFor: inputId },
|
|
111
|
-
label,
|
|
109
|
+
return (React__default['default'].createElement("div", { className: props.className, "data-testid": dataTestId }, !isLoading ? (React__default['default'].createElement(FieldContainer, { disabled: isDisabled, error: error },
|
|
110
|
+
props.label && (React__default['default'].createElement(LabelText.LabelText, { htmlFor: props.inputId },
|
|
111
|
+
props.label,
|
|
112
112
|
" ",
|
|
113
113
|
isRequired && React__default['default'].createElement(Mandatory, null, "*"))),
|
|
114
|
-
React__default['default'].createElement(Select__default['default'], { inputId: inputId, styles: selectBoxStyles, components: { DropdownIndicator }, options: options, classNamePrefix: "react_select", onChange: onChange, value: value, placeholder: placeholder, noOptionsMessage: getNoOptionsText, isSearchable: isSearchable, isDisabled: isDisabled }),
|
|
115
|
-
error && errorMessage && React__default['default'].createElement(ErrorMessage, null, errorMessage))) : (React__default['default'].createElement(PixelLoader.PixelLoader, null))));
|
|
114
|
+
React__default['default'].createElement(Select__default['default'], { inputId: props.inputId, styles: selectBoxStyles, components: { DropdownIndicator }, options: props.options, classNamePrefix: "react_select", onChange: props.onChange, onInputChange: props.onInputChange, value: props.value, placeholder: props.placeholder, noOptionsMessage: getNoOptionsText, isSearchable: isSearchable, isClearable: isClearable, isMulti: isMulti, isDisabled: isDisabled }),
|
|
115
|
+
error && props.errorMessage && (React__default['default'].createElement(ErrorMessage, null, props.errorMessage)))) : (React__default['default'].createElement(PixelLoader.PixelLoader, null))));
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
exports.default = SelectBox;
|
|
@@ -20,10 +20,14 @@ const Container = styled.div `
|
|
|
20
20
|
input {
|
|
21
21
|
width: ${getMultipliedSize(theme.base.baseWidth, 4)};
|
|
22
22
|
border: 0 none;
|
|
23
|
-
text-align:
|
|
23
|
+
text-align: center;
|
|
24
24
|
outline: none;
|
|
25
25
|
-webkit-appearance: none;
|
|
26
26
|
-moz-appearance: textfield;
|
|
27
|
+
&::-webkit-outer-spin-button,
|
|
28
|
+
&::-webkit-inner-spin-button {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
`;
|
|
29
33
|
const StyledButtonSecondary = styled(ButtonSecondary) `
|
|
@@ -61,10 +65,11 @@ const AmountSelector = ({ onChange, value = 1, step = 1, min = 1, max, disabled
|
|
|
61
65
|
}
|
|
62
66
|
};
|
|
63
67
|
return (React.createElement(Container, { disabled: disabled, "data-testid": dataTestId, className: props.className },
|
|
64
|
-
React.createElement(StyledButtonSecondary, { disabled: disabled, onClick: decrease
|
|
68
|
+
React.createElement(StyledButtonSecondary, { disabled: disabled, onClick: decrease, "data-testid": dataTestId &&
|
|
69
|
+
`${dataTestId}${props.removable && isMinReached(value - step) ? '-remove' : '-decrease'}` },
|
|
65
70
|
React.createElement(Icon, { color: theme.color.black, name: props.removable && isMinReached(value - step) ? 'hlTrash' : 'hlMinus' })),
|
|
66
71
|
React.createElement("input", { id: props.id, name: props.name, type: "number", onChange: handleChange, value: value, readOnly: readonly || disabled, disabled: disabled }),
|
|
67
|
-
React.createElement(StyledButtonSecondary, { disabled: disabled, onClick: increase },
|
|
72
|
+
React.createElement(StyledButtonSecondary, { disabled: disabled, onClick: increase, "data-testid": dataTestId ? `${dataTestId}-increase` : undefined },
|
|
68
73
|
React.createElement(Icon, { color: theme.color.black, name: "hlPlus" }))));
|
|
69
74
|
};
|
|
70
75
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from '../../themes/styled.js';
|
|
3
3
|
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
4
|
-
import { LabelText } from '../LabelText/LabelText.js';
|
|
5
4
|
import Icon from '../Icon/Icon.js';
|
|
5
|
+
import { LabelText } from '../LabelText/LabelText.js';
|
|
6
6
|
|
|
7
7
|
const Tag = styled.input `
|
|
8
8
|
position: relative;
|
|
@@ -11,7 +11,7 @@ const Tag = styled.input `
|
|
|
11
11
|
padding: 0 ${props => getMultipliedSize(props.theme.base.baseWidth, 1)};
|
|
12
12
|
font-size: ${props => props.theme.fontSize.defaultFontSize};
|
|
13
13
|
width: 100%;
|
|
14
|
-
height:
|
|
14
|
+
height: ${props => getMultipliedSize(props.theme.base.baseHeight, 4)};
|
|
15
15
|
border: 1px solid ${props => props.theme.color.gray15};
|
|
16
16
|
&::-ms-clear,
|
|
17
17
|
&::-ms-reveal {
|
|
@@ -43,8 +43,8 @@ const FieldWrapper = styled.div `
|
|
|
43
43
|
position: absolute;
|
|
44
44
|
z-index: 1;
|
|
45
45
|
top: 0;
|
|
46
|
-
right:
|
|
47
|
-
height:
|
|
46
|
+
right: ${props => getMultipliedSize(props.theme.base.baseWidth, 1)};
|
|
47
|
+
height: ${props => getMultipliedSize(props.theme.base.baseHeight, 4)};
|
|
48
48
|
}
|
|
49
49
|
`;
|
|
50
50
|
const FieldContainer = styled.div `
|
|
@@ -9,23 +9,26 @@ interface DropDownIndicator {
|
|
|
9
9
|
iconSize?: string;
|
|
10
10
|
}
|
|
11
11
|
interface Props {
|
|
12
|
+
options: ReactSelectProps['options'];
|
|
13
|
+
onChange: (selectedItem: SelectboxItem) => void;
|
|
12
14
|
/** Allows to pass a custom className */
|
|
13
15
|
className?: string;
|
|
16
|
+
'data-testid'?: string;
|
|
14
17
|
label?: string;
|
|
15
18
|
inputId?: ReactSelectProps['inputId'];
|
|
16
19
|
placeholder?: ReactSelectProps['placeholder'];
|
|
17
|
-
|
|
18
|
-
options: ReactSelectProps['options'];
|
|
20
|
+
onInputChange?: ReactSelectProps['onInputChange'];
|
|
19
21
|
value?: ReactSelectProps['value'];
|
|
20
|
-
'data-testid'?: string;
|
|
21
22
|
dropDownIndicator?: DropDownIndicator;
|
|
22
23
|
noOptionsText?: string;
|
|
23
24
|
isSearchable?: boolean;
|
|
25
|
+
isClearable?: boolean;
|
|
26
|
+
isMulti?: boolean;
|
|
24
27
|
isLoading?: boolean;
|
|
25
28
|
isDisabled?: boolean;
|
|
26
29
|
isRequired?: boolean;
|
|
27
30
|
error?: boolean;
|
|
28
31
|
errorMessage?: string;
|
|
29
32
|
}
|
|
30
|
-
declare const SelectBox: ({
|
|
33
|
+
declare const SelectBox: ({ dropDownIndicator, "data-testid": dataTestId, isSearchable, isClearable, isMulti, noOptionsText, isLoading, isDisabled, isRequired, error, ...props }: Props) => JSX.Element;
|
|
31
34
|
export default SelectBox;
|
|
@@ -36,7 +36,7 @@ const selectBoxStyles = {
|
|
|
36
36
|
control: (styles, state) => {
|
|
37
37
|
const customControlStyles = {
|
|
38
38
|
...borderStyles,
|
|
39
|
-
height:
|
|
39
|
+
height: getMultipliedSize(theme.base.baseHeight, 4),
|
|
40
40
|
borderBottomColor: state.menuIsOpen ? theme.color.white : 'inherit',
|
|
41
41
|
'&:hover': {
|
|
42
42
|
borderColor: theme.color.gray25,
|
|
@@ -80,7 +80,7 @@ const selectBoxStyles = {
|
|
|
80
80
|
return { ...styles, ...customOptionStyles };
|
|
81
81
|
},
|
|
82
82
|
};
|
|
83
|
-
const SelectBox = ({
|
|
83
|
+
const SelectBox = ({ dropDownIndicator, 'data-testid': dataTestId, isSearchable = false, isClearable = false, isMulti = false, noOptionsText = '', isLoading = false, isDisabled = false, isRequired = false, error = false, ...props }) => {
|
|
84
84
|
const getNoOptionsText = () => noOptionsText;
|
|
85
85
|
const DropdownIndicator = (dropdownIndicatorProps) => {
|
|
86
86
|
const { color = isDisabled ? theme.color.gray40 : theme.color.black, iconSize = '1rem' } = {
|
|
@@ -97,13 +97,13 @@ const SelectBox = ({ className, label, onChange, options, value, inputId, dropDo
|
|
|
97
97
|
return (components.DropdownIndicator && (React.createElement(components.DropdownIndicator, Object.assign({}, dropdownIndicatorProps),
|
|
98
98
|
React.createElement(Icon, { color: color, name: getIconName(), size: iconSize }))));
|
|
99
99
|
};
|
|
100
|
-
return (React.createElement("div", { className: className, "data-testid": dataTestId }, !isLoading ? (React.createElement(FieldContainer, { disabled: isDisabled, error: error },
|
|
101
|
-
label && (React.createElement(LabelText, { htmlFor: inputId },
|
|
102
|
-
label,
|
|
100
|
+
return (React.createElement("div", { className: props.className, "data-testid": dataTestId }, !isLoading ? (React.createElement(FieldContainer, { disabled: isDisabled, error: error },
|
|
101
|
+
props.label && (React.createElement(LabelText, { htmlFor: props.inputId },
|
|
102
|
+
props.label,
|
|
103
103
|
" ",
|
|
104
104
|
isRequired && React.createElement(Mandatory, null, "*"))),
|
|
105
|
-
React.createElement(Select, { inputId: inputId, styles: selectBoxStyles, components: { DropdownIndicator }, options: options, classNamePrefix: "react_select", onChange: onChange, value: value, placeholder: placeholder, noOptionsMessage: getNoOptionsText, isSearchable: isSearchable, isDisabled: isDisabled }),
|
|
106
|
-
error && errorMessage && React.createElement(ErrorMessage, null, errorMessage))) : (React.createElement(PixelLoader, null))));
|
|
105
|
+
React.createElement(Select, { inputId: props.inputId, styles: selectBoxStyles, components: { DropdownIndicator }, options: props.options, classNamePrefix: "react_select", onChange: props.onChange, onInputChange: props.onInputChange, value: props.value, placeholder: props.placeholder, noOptionsMessage: getNoOptionsText, isSearchable: isSearchable, isClearable: isClearable, isMulti: isMulti, isDisabled: isDisabled }),
|
|
106
|
+
error && props.errorMessage && (React.createElement(ErrorMessage, null, props.errorMessage)))) : (React.createElement(PixelLoader, null))));
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
export default SelectBox;
|