@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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@platformatic/ui-components",
3
3
  "description": "Platformatic UI Components",
4
- "version": "0.1.116",
4
+ "version": "0.1.117",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -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 once we use totally our icons
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
  */
@@ -40,5 +40,6 @@
40
40
  }
41
41
  .input.active,
42
42
  .input:focus {
43
- @apply shadow-main-dark-blue outline-none;
43
+ @apply shadow-main-dark-blue;
44
+ outline: none;
44
45
  }
@@ -30,5 +30,6 @@
30
30
  }
31
31
  .password.active,
32
32
  .password:focus {
33
- @apply shadow-main-dark-blue outline-none;
33
+ @apply shadow-main-dark-blue;
34
+ outline: none;
34
35
  }
@@ -17,7 +17,8 @@
17
17
  }
18
18
  .radio.active,
19
19
  .radio:focus {
20
- @apply shadow-main-dark-blue outline-none;
20
+ @apply shadow-main-dark-blue;
21
+ outline: none;
21
22
  }
22
23
 
23
24
  input[type="radio"] {
@@ -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 ({ placeholder, name, value, options, borderColor, errorMessage, onChange, onSelect, onClear, disabled, optionsIconColor }) {
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
@@ -9,7 +9,8 @@
9
9
  }
10
10
  .select.active,
11
11
  .select:focus {
12
- @apply shadow-main-dark-blue outline-none;
12
+ @apply shadow-main-dark-blue;
13
+ outline: none;
13
14
  }
14
15
  .options {
15
16
  @apply absolute left-0 top-[42px] bg-white w-full max-h-[216px] overflow-y-scroll z-20;
@@ -9,7 +9,8 @@
9
9
  }
10
10
  .textarea.active,
11
11
  .textarea:focus {
12
- @apply shadow-main-dark-blue outline-none;
12
+ @apply shadow-main-dark-blue;
13
+ outline: none;
13
14
  }
14
15
  .afterIcon {
15
16
  @apply absolute top-[1.25rem] right-[1.25rem]