@@ -14,8 +14,10 @@ import {
14
14
BaseProps ,
15
15
BlockStyleProps ,
16
16
CONTAINER_STYLES ,
17
+ ContainerStyleProps ,
17
18
extractStyles ,
18
19
PositionStyleProps ,
20
+ Props ,
19
21
Styles ,
20
22
tasty ,
21
23
} from '../../../tasty' ;
@@ -41,6 +43,7 @@ const FileInputElement = tasty(Action, {
41
43
radius : true ,
42
44
cursor : 'pointer' ,
43
45
overflow : 'hidden' ,
46
+ whiteSpace : 'nowrap' ,
44
47
45
48
Button : {
46
49
radius : true ,
@@ -64,10 +67,18 @@ const FileInputElement = tasty(Action, {
64
67
65
68
Placeholder : {
66
69
color : '#dark-02' ,
70
+ whiteSpace : 'nowrap' ,
71
+ textOverflow : 'ellipsis' ,
72
+ width : 'max 100%' ,
73
+ overflow : 'hidden' ,
67
74
} ,
68
75
69
76
Value : {
70
77
color : '#dark-02' ,
78
+ whiteSpace : 'nowrap' ,
79
+ textOverflow : 'ellipsis' ,
80
+ width : 'max 100%' ,
81
+ overflow : 'hidden' ,
71
82
} ,
72
83
73
84
Input : {
@@ -77,7 +88,7 @@ const FileInputElement = tasty(Action, {
77
88
bottom : 0 ,
78
89
left : 0 ,
79
90
radius : '@content-radius' ,
80
- // opacity: 0,
91
+ opacity : 0.01 ,
81
92
cursor : 'pointer' ,
82
93
zIndex : 10 ,
83
94
} ,
@@ -87,6 +98,7 @@ const FileInputElement = tasty(Action, {
87
98
export interface CubeFileInputProps
88
99
extends BaseProps ,
89
100
PositionStyleProps ,
101
+ ContainerStyleProps ,
90
102
BlockStyleProps ,
91
103
AriaTextFieldProps ,
92
104
FormFieldProps {
@@ -104,6 +116,8 @@ export interface CubeFileInputProps
104
116
* @default file
105
117
*/
106
118
type ?: 'file' | 'text' ;
119
+ /** Direct input props */
120
+ inputProps ?: Props ;
107
121
}
108
122
109
123
function extractContents ( element , callback ) {
@@ -147,6 +161,7 @@ function FileInput(props: CubeFileInputProps, ref) {
147
161
inputStyles,
148
162
labelSuffix,
149
163
type = 'file' ,
164
+ inputProps,
150
165
...otherProps
151
166
} = useProviderProps ( props ) ;
152
167
const [ value , setValue ] = useState ( ) ;
@@ -185,6 +200,11 @@ function FileInput(props: CubeFileInputProps, ref) {
185
200
} ,
186
201
} ) ) ;
187
202
203
+ const fileName =
204
+ typeof value === 'string'
205
+ ? ( value as string ) . split ( '\\' ) ?. pop ( )
206
+ : undefined ;
207
+
188
208
const fileInput = (
189
209
< FileInputElement
190
210
ref = { domRef }
@@ -218,10 +238,11 @@ function FileInput(props: CubeFileInputProps, ref) {
218
238
onDrop = { ( ) => {
219
239
setDragHover ( false ) ;
220
240
} }
241
+ { ...inputProps }
221
242
/>
222
243
< div data-element = "Button" > Choose file</ div >
223
- < div data-element = { ! ! value ? 'Value' : 'Placeholder' } >
224
- { value || placeholder || 'No file selected' }
244
+ < div data-element = { ! ! fileName ? 'Value' : 'Placeholder' } >
245
+ { fileName || placeholder || 'No file selected' }
225
246
</ div >
226
247
</ FileInputElement >
227
248
) ;
0 commit comments