@toptal/picasso-file-input 2.0.6 → 2.0.8
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/dist-package/src/FileInput/FileInput.d.ts.map +1 -1
- package/dist-package/src/FileInput/FileInput.js +3 -7
- package/dist-package/src/FileInput/FileInput.js.map +1 -1
- package/package.json +3 -3
- package/src/FileInput/FileInput.tsx +3 -9
- package/dist-package/src/FileInput/styles.d.ts +0 -3
- package/dist-package/src/FileInput/styles.d.ts.map +0 -1
- package/dist-package/src/FileInput/styles.js +0 -16
- package/dist-package/src/FileInput/styles.js.map +0 -1
- package/src/FileInput/styles.ts +0 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAA6B,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAA6B,MAAM,OAAO,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAOvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gDAAgD;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,4JAA4J;IAC5J,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,qCAAqC;IACrC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAA;IACpB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAC/D,mDAAmD;IACnD,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACpD,0BAA0B;IAC1B,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;IAC3C,yBAAyB;IACzB,MAAM,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;CAC3C;AAED,eAAO,MAAM,SAAS,gFAuDpB,CAAA;AASF,eAAe,SAAS,CAAA"}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import React, { forwardRef, useRef } from 'react';
|
|
2
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
3
2
|
import { Container } from '@toptal/picasso-container';
|
|
4
3
|
import { Button } from '@toptal/picasso-button';
|
|
5
4
|
import { FormHint } from '@toptal/picasso-form';
|
|
6
5
|
import { useCombinedRefs } from '@toptal/picasso-utils';
|
|
7
6
|
import { FileList } from '../FileList';
|
|
8
|
-
import styles from './styles';
|
|
9
|
-
const useStyles = makeStyles(styles, { name: 'FileInputContent' });
|
|
10
7
|
export const FileInput = forwardRef(function FileInput(props, ref) {
|
|
11
8
|
const { accept, disabled, value, buttonLabel, hint, maxFiles = 1, onChange, onRemove, onFocus, onBlur, } = props;
|
|
12
|
-
const classes = useStyles();
|
|
13
9
|
const isUnlimitedFiles = maxFiles === null;
|
|
14
10
|
const preventAddingNewFiles = !isUnlimitedFiles && value && value.length === maxFiles;
|
|
15
11
|
// if `ref` is null then we need a ref to control the input
|
|
16
12
|
// so we create another ref manually if needed and merge both of them
|
|
17
13
|
const inputRef = useCombinedRefs(ref, useRef(null));
|
|
18
|
-
return (React.createElement(Container, { onFocus: onFocus, onBlur: onBlur, className:
|
|
14
|
+
return (React.createElement(Container, { onFocus: onFocus, onBlur: onBlur, className: 'max-w-[300px]' },
|
|
19
15
|
React.createElement(Button, { size: 'small', variant: 'secondary', disabled: Boolean(disabled || preventAddingNewFiles), onClick: () => inputRef.current && inputRef.current.click() }, buttonLabel),
|
|
20
|
-
React.createElement("input", { type: 'file', className:
|
|
21
|
-
hint && React.createElement(FormHint, { className:
|
|
16
|
+
React.createElement("input", { type: 'file', className: 'hidden', ref: inputRef, accept: accept, onChange: onChange, multiple: isUnlimitedFiles }),
|
|
17
|
+
hint && React.createElement(FormHint, { className: '[&>*]:leading-4' }, hint),
|
|
22
18
|
value && value.length > 0 && (React.createElement(Container, { top: 'xsmall' },
|
|
23
19
|
React.createElement(FileList, { files: value, disabled: disabled, onItemRemove: onRemove })))));
|
|
24
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AA0BtC,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAA0B,SAAS,SAAS,CAC7E,KAAK,EACL,GAAG;IAEH,MAA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AACH,CAAC,CAAC,CAAA;AAEF,SAAS,CAAC,YAAY,GAAG;IACvB,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,aAAa;CAC3B,CAAA;AAED,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA;AAEnC,eAAe,SAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-file-input",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Toptal UI components library - FileInput",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@toptal/picasso-button": "3.0.
|
|
25
|
+
"@toptal/picasso-button": "3.0.7",
|
|
26
26
|
"@toptal/picasso-container": "2.0.0",
|
|
27
|
-
"@toptal/picasso-form": "4.1.
|
|
27
|
+
"@toptal/picasso-form": "4.1.3",
|
|
28
28
|
"@toptal/picasso-icons": "1.6.0",
|
|
29
29
|
"@toptal/picasso-loader": "2.0.0",
|
|
30
30
|
"@toptal/picasso-shared": "15.0.0",
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { FocusEventHandler } from 'react'
|
|
2
2
|
import React, { forwardRef, useRef } from 'react'
|
|
3
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
4
|
-
import { makeStyles } from '@material-ui/core/styles'
|
|
5
3
|
import type { BaseProps } from '@toptal/picasso-shared'
|
|
6
4
|
import { Container } from '@toptal/picasso-container'
|
|
7
5
|
import { Button } from '@toptal/picasso-button'
|
|
@@ -10,7 +8,6 @@ import { useCombinedRefs } from '@toptal/picasso-utils'
|
|
|
10
8
|
|
|
11
9
|
import { FileList } from '../FileList'
|
|
12
10
|
import type { FileUpload } from './types'
|
|
13
|
-
import styles from './styles'
|
|
14
11
|
|
|
15
12
|
export interface Props extends BaseProps {
|
|
16
13
|
/** A string that defines the file types the file input should accept */
|
|
@@ -35,8 +32,6 @@ export interface Props extends BaseProps {
|
|
|
35
32
|
onBlur?: FocusEventHandler<HTMLDivElement>
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
const useStyles = makeStyles<Theme>(styles, { name: 'FileInputContent' })
|
|
39
|
-
|
|
40
35
|
export const FileInput = forwardRef<HTMLInputElement, Props>(function FileInput(
|
|
41
36
|
props,
|
|
42
37
|
ref
|
|
@@ -54,7 +49,6 @@ export const FileInput = forwardRef<HTMLInputElement, Props>(function FileInput(
|
|
|
54
49
|
onBlur,
|
|
55
50
|
} = props
|
|
56
51
|
|
|
57
|
-
const classes = useStyles()
|
|
58
52
|
const isUnlimitedFiles = maxFiles === null
|
|
59
53
|
const preventAddingNewFiles =
|
|
60
54
|
!isUnlimitedFiles && value && value.length === maxFiles
|
|
@@ -67,7 +61,7 @@ export const FileInput = forwardRef<HTMLInputElement, Props>(function FileInput(
|
|
|
67
61
|
)
|
|
68
62
|
|
|
69
63
|
return (
|
|
70
|
-
<Container onFocus={onFocus} onBlur={onBlur} className=
|
|
64
|
+
<Container onFocus={onFocus} onBlur={onBlur} className='max-w-[300px]'>
|
|
71
65
|
<Button
|
|
72
66
|
size='small'
|
|
73
67
|
variant='secondary'
|
|
@@ -79,13 +73,13 @@ export const FileInput = forwardRef<HTMLInputElement, Props>(function FileInput(
|
|
|
79
73
|
|
|
80
74
|
<input
|
|
81
75
|
type='file'
|
|
82
|
-
className=
|
|
76
|
+
className='hidden'
|
|
83
77
|
ref={inputRef}
|
|
84
78
|
accept={accept}
|
|
85
79
|
onChange={onChange}
|
|
86
80
|
multiple={isUnlimitedFiles}
|
|
87
81
|
/>
|
|
88
|
-
{hint && <FormHint className=
|
|
82
|
+
{hint && <FormHint className='[&>*]:leading-4'>{hint}</FormHint>}
|
|
89
83
|
{value && value.length > 0 && (
|
|
90
84
|
<Container top='xsmall'>
|
|
91
85
|
<FileList files={value} disabled={disabled} onItemRemove={onRemove} />
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/FileInput/styles.ts"],"names":[],"mappings":";AAGA,wBAaI"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createStyles } from '@material-ui/core/styles';
|
|
2
|
-
import { rem } from '@toptal/picasso-shared';
|
|
3
|
-
export default () => createStyles({
|
|
4
|
-
root: {
|
|
5
|
-
maxWidth: '300px',
|
|
6
|
-
},
|
|
7
|
-
hint: {
|
|
8
|
-
'& > *': {
|
|
9
|
-
lineHeight: rem('16px'),
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
nativeInput: {
|
|
13
|
-
display: 'none',
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/FileInput/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AAE5C,eAAe,GAAG,EAAE,CAClB,YAAY,CAAC;IACX,IAAI,EAAE;QACJ,QAAQ,EAAE,OAAO;KAClB;IACD,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC;SACxB;KACF;IACD,WAAW,EAAE;QACX,OAAO,EAAE,MAAM;KAChB;CACF,CAAC,CAAA"}
|
package/src/FileInput/styles.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createStyles } from '@material-ui/core/styles'
|
|
2
|
-
import { rem } from '@toptal/picasso-shared'
|
|
3
|
-
|
|
4
|
-
export default () =>
|
|
5
|
-
createStyles({
|
|
6
|
-
root: {
|
|
7
|
-
maxWidth: '300px',
|
|
8
|
-
},
|
|
9
|
-
hint: {
|
|
10
|
-
'& > *': {
|
|
11
|
-
lineHeight: rem('16px'),
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
nativeInput: {
|
|
15
|
-
display: 'none',
|
|
16
|
-
},
|
|
17
|
-
})
|