@platformatic/ui-components 0.1.116 → 0.1.117
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/package.json +1 -1
- package/src/components/Button.jsx +11 -2
- package/src/components/forms/Input.module.css +2 -1
- package/src/components/forms/Password.module.css +2 -1
- package/src/components/forms/RadioGroup.module.css +2 -1
- package/src/components/forms/Select.jsx +33 -3
- package/src/components/forms/Select.module.css +2 -1
- package/src/components/forms/TextArea.module.css +2 -1
package/package.json
CHANGED
|
@@ -18,6 +18,7 @@ function Button ({
|
|
|
18
18
|
bordered,
|
|
19
19
|
fullWidth,
|
|
20
20
|
platformaticIcon,
|
|
21
|
+
platformaticIconAfter,
|
|
21
22
|
selected,
|
|
22
23
|
...rest
|
|
23
24
|
}) {
|
|
@@ -46,8 +47,9 @@ function Button ({
|
|
|
46
47
|
if (selected) buttonClassName += ' ' + commonStyles[`selected-background-color-${color}`]
|
|
47
48
|
return (
|
|
48
49
|
<button className={buttonClassName} disabled={disabled} alt={label} {...rest}>
|
|
49
|
-
{platformaticIcon ? <PlatformaticIcon iconName={platformaticIcon.iconName} color={platformaticIcon.color} data-testid='button-icon' onClick={null} /> : null}
|
|
50
|
+
{platformaticIcon ? <PlatformaticIcon key='left' iconName={platformaticIcon.iconName} color={platformaticIcon.color} data-testid='button-icon' onClick={null} /> : null}
|
|
50
51
|
<span className={styles.label}>{label}</span>
|
|
52
|
+
{platformaticIconAfter ? <PlatformaticIcon key='right' iconName={platformaticIconAfter.iconName} color={platformaticIconAfter.color} data-testid='button-icon' onClick={null} /> : null}
|
|
51
53
|
</button>
|
|
52
54
|
)
|
|
53
55
|
}
|
|
@@ -94,12 +96,19 @@ Button.propTypes = {
|
|
|
94
96
|
*/
|
|
95
97
|
fullWidth: PropTypes.bool,
|
|
96
98
|
/**
|
|
97
|
-
* platformaticIcon: should be removed
|
|
99
|
+
* platformaticIcon: should be removed
|
|
98
100
|
*/
|
|
99
101
|
platformaticIcon: PropTypes.shape({
|
|
100
102
|
iconName: PropTypes.string,
|
|
101
103
|
color: PropTypes.string
|
|
102
104
|
}),
|
|
105
|
+
/**
|
|
106
|
+
* platformaticIconAfter: should be removed
|
|
107
|
+
*/
|
|
108
|
+
platformaticIconAfter: PropTypes.shape({
|
|
109
|
+
iconName: PropTypes.string,
|
|
110
|
+
color: PropTypes.string
|
|
111
|
+
}),
|
|
103
112
|
/**
|
|
104
113
|
* Selected: default false
|
|
105
114
|
*/
|
|
@@ -6,7 +6,20 @@ import commonStyles from '../Common.module.css'
|
|
|
6
6
|
import { MAIN_DARK_BLUE, MAIN_GREEN, SMALL } from '../constants'
|
|
7
7
|
import PlatformaticIcon from '../PlatformaticIcon'
|
|
8
8
|
|
|
9
|
-
function Select ({
|
|
9
|
+
function Select ({
|
|
10
|
+
placeholder,
|
|
11
|
+
name,
|
|
12
|
+
value,
|
|
13
|
+
options,
|
|
14
|
+
borderColor,
|
|
15
|
+
errorMessage,
|
|
16
|
+
onChange,
|
|
17
|
+
onSelect,
|
|
18
|
+
onClear,
|
|
19
|
+
disabled,
|
|
20
|
+
optionsIconColor,
|
|
21
|
+
optionSelected
|
|
22
|
+
}) {
|
|
10
23
|
const inputRef = useRef()
|
|
11
24
|
const [showOptions, setShowOptions] = useState(false)
|
|
12
25
|
const [isSelected, setIsSelected] = useState(false)
|
|
@@ -43,6 +56,12 @@ function Select ({ placeholder, name, value, options, borderColor, errorMessage,
|
|
|
43
56
|
}
|
|
44
57
|
}, [value])
|
|
45
58
|
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (optionSelected) {
|
|
61
|
+
setSelected(optionSelected)
|
|
62
|
+
}
|
|
63
|
+
}, [optionSelected])
|
|
64
|
+
|
|
46
65
|
function renderLi (option, index) {
|
|
47
66
|
return (
|
|
48
67
|
<li
|
|
@@ -169,7 +188,17 @@ Select.propTypes = {
|
|
|
169
188
|
/**
|
|
170
189
|
* optionsIconColor
|
|
171
190
|
*/
|
|
172
|
-
optionsIconColor: PropTypes.string
|
|
191
|
+
optionsIconColor: PropTypes.string,
|
|
192
|
+
/**
|
|
193
|
+
* optionSelected
|
|
194
|
+
*/
|
|
195
|
+
optionSelected: PropTypes.shape({
|
|
196
|
+
label: PropTypes.string,
|
|
197
|
+
value: PropTypes.oneOfType([
|
|
198
|
+
PropTypes.string,
|
|
199
|
+
PropTypes.number
|
|
200
|
+
])
|
|
201
|
+
})
|
|
173
202
|
}
|
|
174
203
|
|
|
175
204
|
Select.defaultProps = {
|
|
@@ -184,7 +213,8 @@ Select.defaultProps = {
|
|
|
184
213
|
onSelect: () => {},
|
|
185
214
|
onClear: () => {},
|
|
186
215
|
disabled: false,
|
|
187
|
-
optionsIconColor: MAIN_DARK_BLUE
|
|
216
|
+
optionsIconColor: MAIN_DARK_BLUE,
|
|
217
|
+
optionSelected: null
|
|
188
218
|
}
|
|
189
219
|
|
|
190
220
|
export default Select
|