@platformatic/ui-components 0.1.100 → 0.1.101

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.100",
4
+ "version": "0.1.101",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -4,7 +4,6 @@ import PropTypes from 'prop-types'
4
4
  import inputStyles from './Input.module.css'
5
5
  import styles from './InputWithSeparator.module.css'
6
6
  import commonStyles from '../Common.module.css'
7
- import PlatformaticIcon from '../PlatformaticIcon'
8
7
  import { BACKGROUND_COLOR_OPAQUE, MAIN_DARK_BLUE, MAIN_GREEN, MEDIUM, TRANSPARENT } from '../constants'
9
8
  import BorderedBox from '../BorderedBox'
10
9
  import ButtonFullRounded from '../ButtonFullRounded'
@@ -55,7 +54,6 @@ function InputWithSeparator ({ placeholder, name, borderColor, errorMessage, onC
55
54
  <div className={styles.chunkContent}>
56
55
  <span className={styles.chunkText}>{chunk}</span>
57
56
  <ButtonFullRounded
58
- className=''
59
57
  iconName='CircleCloseIcon'
60
58
  iconSize={MEDIUM}
61
59
  iconColor={MAIN_DARK_BLUE}
@@ -70,11 +68,25 @@ function InputWithSeparator ({ placeholder, name, borderColor, errorMessage, onC
70
68
  }
71
69
  return (
72
70
  <div className={inputStyles.container}>
73
- <div className={className}>
74
- {chunks.map((value, index) => renderChunk(value, index))}
75
- <input type='text' name={name} value={value} placeholder={placeholder} className={inputClassName} onChange={handleChange} disabled={disabled} />
71
+ <div className={styles.container}>
72
+ <div className={className}>
73
+ {chunks.map((value, index) => renderChunk(value, index))}
74
+ <input type='text' name={name} value={value} placeholder={placeholder} className={inputClassName} onChange={handleChange} disabled={disabled} />
75
+ </div>
76
+ {afterIcon &&
77
+ (
78
+ <ButtonFullRounded
79
+ className={styles.smallPadding}
80
+ iconName={afterIcon.iconName}
81
+ iconColor={afterIcon.color}
82
+ data-testid='after-icon'
83
+ onClick={afterIcon.handleClick}
84
+ iconSize={MEDIUM}
85
+ hoverEffect={BACKGROUND_COLOR_OPAQUE}
86
+ disabled={afterIcon.disabled}
87
+ />
88
+ )}
76
89
  </div>
77
- {afterIcon && <div className={styles.iconContainer}><PlatformaticIcon iconName={afterIcon.iconName} color={afterIcon.color} data-testid='after-icon' onClick={afterIcon.handleClick} /></div>}
78
90
  {showError && <span className={commonStyles['error-message']}>{errorMessage}</span>}
79
91
  </div>
80
92
  )
@@ -115,7 +127,8 @@ InputWithSeparator.propTypes = {
115
127
  afterIcon: PropTypes.shape({
116
128
  iconName: PropTypes.string,
117
129
  color: PropTypes.string,
118
- handleClick: PropTypes.func
130
+ handleClick: PropTypes.func,
131
+ disabled: PropTypes.bool
119
132
  })
120
133
  }
121
134
 
@@ -5,7 +5,7 @@
5
5
  @apply text-sm text-main-dark-blue;
6
6
  }
7
7
  .inputContainer {
8
- @apply flex min-h-[46px] border border-solid box-border rounded-md items-center gap-[0.1rem] flex-wrap relative;
8
+ @apply flex min-h-[46px] border border-solid box-border rounded-md items-center gap-[0.1rem] flex-wrap relative grow;
9
9
  }
10
10
  .smallPadding {
11
11
  @apply p-1 !important
@@ -21,4 +21,7 @@
21
21
  }
22
22
  .iconContainer {
23
23
  @apply absolute top-[14px] right-[0.5rem]
24
- }
24
+ }
25
+ .container {
26
+ @apply flex w-full items-center;
27
+ }
@@ -25,6 +25,8 @@ export default {
25
25
  const TemplateDefault = (args) => {
26
26
  const [value, setValue] = useState('')
27
27
  const [chunks, setChunks] = useState('')
28
+ const [errorMessage, setErrorMessage] = useState('')
29
+ // errorMessage: 'error message displayed just for to be see',
28
30
 
29
31
  function handleChange ({ value, chunks }) {
30
32
  setValue(value)
@@ -35,7 +37,8 @@ const TemplateDefault = (args) => {
35
37
  <>
36
38
  <p>Chunks: {chunks.toString()} </p>
37
39
  <p>Value inserted: {value} </p>
38
- <InputWithSeparator {...args} value={value} onChange={handleChange} />
40
+ <label>Add Error message: <input type='checkbox' onChange={() => setErrorMessage(errorMessage === '' ? 'custom message' : '')} /></label>
41
+ <InputWithSeparator {...args} value={value} onChange={handleChange} errorMessage={errorMessage} />
39
42
  </>
40
43
  )
41
44
  }