@@ -5,7 +5,15 @@ import { InputTypeType } from '@/components/input';
5
5
import { useId } from '@/hooks' ;
6
6
import { pickAriaProps } from '@/utils/aria/aria' ;
7
7
8
- import { IconContainerStyled , PillInputStyled , PillLabelStyled , PillStyled } from './pill.styled' ;
8
+ import { Text , TextComponentType } from '../text' ;
9
+ import {
10
+ IconContainerStyled ,
11
+ LabelContainerStyled ,
12
+ ParentContainerStyled ,
13
+ PillInputStyled ,
14
+ PillLabelStyled ,
15
+ PillStyled ,
16
+ } from './pill.styled' ;
9
17
import { IPillStandAlone } from './types' ;
10
18
import { getPillState } from './utils' ;
11
19
@@ -37,52 +45,65 @@ const PillStandAloneComponent = (
37
45
const stateStyles = styles [ state ] ;
38
46
39
47
return (
40
- < PillStyled
41
- ref = { ref }
42
- data-testid = { dataTestId }
43
- styles = { stateStyles }
44
- tabIndex = { tabIndex }
45
- onKeyDown = { onKeyDown ?.( value || '' ) }
46
- >
47
- < PillInputStyled
48
- aria-checked = { selected }
49
- { ...ariaProps }
50
- checked = { selected }
51
- data-testid = { `${ dataTestId } Input` }
52
- disabled = { disabled }
53
- id = { id }
54
- name = { name }
48
+ < ParentContainerStyled styles = { stateStyles } >
49
+ < PillStyled
50
+ ref = { ref }
51
+ data-testid = { dataTestId }
55
52
styles = { stateStyles }
56
- tabIndex = { - 1 }
57
- type = { component }
58
- value = { value }
59
- onChange = { onPillChange }
60
- onFocus = { onFocus }
61
- />
62
- { decorativeIcon && (
63
- < IconContainerStyled styles = { stateStyles } >
53
+ tabIndex = { tabIndex }
54
+ onKeyDown = { onKeyDown ?.( value || '' ) }
55
+ >
56
+ < PillInputStyled
57
+ aria-checked = { selected }
58
+ { ...ariaProps }
59
+ checked = { selected }
60
+ data-testid = { `${ dataTestId } Input` }
61
+ disabled = { disabled }
62
+ id = { id }
63
+ name = { name }
64
+ styles = { stateStyles }
65
+ tabIndex = { - 1 }
66
+ type = { component }
67
+ value = { value }
68
+ onChange = { onPillChange }
69
+ onFocus = { onFocus }
70
+ />
71
+ { decorativeIcon && (
72
+ < IconContainerStyled styles = { stateStyles } >
73
+ < ElementOrIcon
74
+ color = { stateStyles ?. decorativeIcon ?. color }
75
+ dataTestId = { dataTestId + 'DecorativeIcon' }
76
+ height = { stateStyles ?. decorativeIcon ?. height }
77
+ width = { stateStyles ?. decorativeIcon ?. width }
78
+ { ...decorativeIcon }
79
+ />
80
+ </ IconContainerStyled >
81
+ ) }
82
+ < PillLabelStyled htmlFor = { id } styles = { stateStyles } >
83
+ { children }
84
+ </ PillLabelStyled >
85
+ { selectedIcon && selected && (
64
86
< ElementOrIcon
65
- color = { stateStyles ?. decorativeIcon ?. color }
66
- dataTestId = { dataTestId + 'DecorativeIcon ' }
67
- height = { stateStyles ?. decorativeIcon ?. height }
68
- width = { stateStyles ?. decorativeIcon ?. width }
69
- { ...decorativeIcon }
87
+ color = { stateStyles ?. selectedIcon ?. color }
88
+ dataTestId = { dataTestId + 'SelectedIcon ' }
89
+ height = { stateStyles ?. selectedIcon ?. height }
90
+ width = { stateStyles ?. selectedIcon ?. width }
91
+ { ...selectedIcon }
70
92
/>
71
- </ IconContainerStyled >
72
- ) }
73
- < PillLabelStyled htmlFor = { id } styles = { stateStyles } >
74
- { children }
75
- </ PillLabelStyled >
76
- { selectedIcon && selected && (
77
- < ElementOrIcon
78
- color = { stateStyles ?. selectedIcon ?. color }
79
- dataTestId = { dataTestId + 'SelectedIcon' }
80
- height = { stateStyles ?. selectedIcon ?. height }
81
- width = { stateStyles ?. selectedIcon ?. width }
82
- { ...selectedIcon }
83
- />
93
+ ) }
94
+ </ PillStyled >
95
+ { props . label ?. content && props . label . content !== null && (
96
+ < LabelContainerStyled styles = { stateStyles } >
97
+ < Text
98
+ component = { TextComponentType . PARAGRAPH }
99
+ customTypography = { stateStyles ?. labelContent }
100
+ { ...props . label }
101
+ >
102
+ { props . label . content }
103
+ </ Text >
104
+ </ LabelContainerStyled >
84
105
) }
85
- </ PillStyled >
106
+ </ ParentContainerStyled >
86
107
) ;
87
108
} ;
88
109
0 commit comments