@toptal/picasso-file-input 2.0.7 → 2.0.9-alpha-fx-null-revert-tabs-b3f67a2fa.2
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/LICENSE +20 -0
- 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 +14 -13
- package/src/FileInput/FileInput.tsx +3 -9
- package/src/FileInput/__snapshots__/test.tsx.snap +4 -4
- 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
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2022 Toptal, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the “Software”), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -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,MAAM,EACJ,MAAM,EACN,QAAQ,EACR,KAAK,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,GAAG,CAAC,EACZ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,GACP,GAAG,KAAK,CAAA;IAET,MAAM,gBAAgB,GAAG,QAAQ,KAAK,IAAI,CAAA;IAC1C,MAAM,qBAAqB,GACzB,CAAC,gBAAgB,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
|
"name": "@toptal/picasso-file-input",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9-alpha-fx-null-revert-tabs-b3f67a2fa.2+b3f67a2fa",
|
|
4
4
|
"description": "Toptal UI components library - FileInput",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@toptal/picasso-button": "3.0.
|
|
26
|
-
"@toptal/picasso-container": "2.0.
|
|
27
|
-
"@toptal/picasso-form": "4.1.
|
|
28
|
-
"@toptal/picasso-icons": "1.6.
|
|
29
|
-
"@toptal/picasso-loader": "2.0.
|
|
30
|
-
"@toptal/picasso-shared": "15.0.
|
|
31
|
-
"@toptal/picasso-tooltip": "1.1.
|
|
32
|
-
"@toptal/picasso-typography": "3.0.
|
|
33
|
-
"@toptal/picasso-typography-overflow": "2.0.
|
|
34
|
-
"@toptal/picasso-utils": "1.0.
|
|
25
|
+
"@toptal/picasso-button": "3.0.8-alpha-fx-null-revert-tabs-b3f67a2fa.6+b3f67a2fa",
|
|
26
|
+
"@toptal/picasso-container": "2.0.1-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
|
27
|
+
"@toptal/picasso-form": "4.1.4-alpha-fx-null-revert-tabs-b3f67a2fa.6+b3f67a2fa",
|
|
28
|
+
"@toptal/picasso-icons": "1.6.1-alpha-fx-null-revert-tabs-b3f67a2fa.31+b3f67a2fa",
|
|
29
|
+
"@toptal/picasso-loader": "2.0.1-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
|
30
|
+
"@toptal/picasso-shared": "15.0.1-alpha-fx-null-revert-tabs-b3f67a2fa.124+b3f67a2fa",
|
|
31
|
+
"@toptal/picasso-tooltip": "1.1.5-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
|
32
|
+
"@toptal/picasso-typography": "3.0.1-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
|
33
|
+
"@toptal/picasso-typography-overflow": "2.0.5-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
|
34
|
+
"@toptal/picasso-utils": "1.0.4-alpha-fx-null-revert-tabs-b3f67a2fa.124+b3f67a2fa",
|
|
35
35
|
"classnames": "^2.5.1"
|
|
36
36
|
},
|
|
37
37
|
"sideEffects": [
|
|
@@ -47,11 +47,12 @@
|
|
|
47
47
|
".": "./dist-package/src/index.js"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@toptal/picasso-test-utils": "1.1.
|
|
50
|
+
"@toptal/picasso-test-utils": "1.1.2-alpha-fx-null-revert-tabs-b3f67a2fa.124+b3f67a2fa"
|
|
51
51
|
},
|
|
52
52
|
"files": [
|
|
53
53
|
"dist-package/**",
|
|
54
54
|
"!dist-package/tsconfig.tsbuildinfo",
|
|
55
55
|
"src"
|
|
56
|
-
]
|
|
56
|
+
],
|
|
57
|
+
"gitHead": "b3f67a2fa9c785bf8251fbfdcfe27163597835d0"
|
|
57
58
|
}
|
|
@@ -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} />
|
|
@@ -6,7 +6,7 @@ exports[`FileInput can change label 1`] = `
|
|
|
6
6
|
class="Picasso-root"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
|
-
class="
|
|
9
|
+
class="max-w"
|
|
10
10
|
>
|
|
11
11
|
<button
|
|
12
12
|
aria-disabled="false"
|
|
@@ -23,7 +23,7 @@ exports[`FileInput can change label 1`] = `
|
|
|
23
23
|
</span>
|
|
24
24
|
</button>
|
|
25
25
|
<input
|
|
26
|
-
class="
|
|
26
|
+
class="hidden"
|
|
27
27
|
type="file"
|
|
28
28
|
/>
|
|
29
29
|
</div>
|
|
@@ -37,7 +37,7 @@ exports[`FileInput renders 1`] = `
|
|
|
37
37
|
class="Picasso-root"
|
|
38
38
|
>
|
|
39
39
|
<div
|
|
40
|
-
class="
|
|
40
|
+
class="max-w"
|
|
41
41
|
>
|
|
42
42
|
<button
|
|
43
43
|
aria-disabled="false"
|
|
@@ -54,7 +54,7 @@ exports[`FileInput renders 1`] = `
|
|
|
54
54
|
</span>
|
|
55
55
|
</button>
|
|
56
56
|
<input
|
|
57
|
-
class="
|
|
57
|
+
class="hidden"
|
|
58
58
|
type="file"
|
|
59
59
|
/>
|
|
60
60
|
</div>
|
|
@@ -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
|
-
})
|