@toptal/picasso 20.0.1 → 20.1.0
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/FileInput/FileInput.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { FocusEventHandler } from 'react';
|
|
2
2
|
import { BaseProps } from '@toptal/picasso-shared';
|
|
3
3
|
import { FileUpload } from './types';
|
|
4
4
|
export interface Props extends BaseProps {
|
|
@@ -16,6 +16,10 @@ export interface Props extends BaseProps {
|
|
|
16
16
|
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
17
|
/** Callback invoked when a file item is removed */
|
|
18
18
|
onRemove?: (fileName: string, index: number) => void;
|
|
19
|
+
/** Focus event handler */
|
|
20
|
+
onFocus?: FocusEventHandler<HTMLDivElement>;
|
|
21
|
+
/** Blur event handler */
|
|
22
|
+
onBlur?: FocusEventHandler<HTMLDivElement>;
|
|
19
23
|
}
|
|
20
24
|
export declare const FileInput: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
21
25
|
export default FileInput;
|
package/FileInput/FileInput.js
CHANGED
|
@@ -8,14 +8,14 @@ import { useCombinedRefs } from '../utils';
|
|
|
8
8
|
import styles from './styles';
|
|
9
9
|
const useStyles = makeStyles(styles, { name: 'FileInputContent' });
|
|
10
10
|
export const FileInput = forwardRef(function FileInput(props, ref) {
|
|
11
|
-
const { accept, disabled, value, hint, maxFiles = 1, onChange, onRemove } = props;
|
|
11
|
+
const { accept, disabled, value, hint, maxFiles = 1, onChange, onRemove, onFocus, onBlur } = props;
|
|
12
12
|
const classes = useStyles();
|
|
13
13
|
const isUnlimitedFiles = maxFiles === null;
|
|
14
14
|
const preventAddingNewFiles = !isUnlimitedFiles && value && value.length === maxFiles;
|
|
15
15
|
// if `ref` is null then we need a ref to control the input
|
|
16
16
|
// so we create another ref manually if needed and merge both of them
|
|
17
17
|
const inputRef = useCombinedRefs(ref, useRef(null));
|
|
18
|
-
return (React.createElement(Container, { className: classes.root },
|
|
18
|
+
return (React.createElement(Container, { onFocus: onFocus, onBlur: onBlur, className: classes.root },
|
|
19
19
|
React.createElement(Button, { size: 'small', variant: 'secondary', disabled: Boolean(disabled || preventAddingNewFiles), onClick: () => inputRef.current && inputRef.current.click() }, "Choose File"),
|
|
20
20
|
React.createElement("input", { type: 'file', className: classes.nativeInput, ref: inputRef, accept: accept, onChange: onChange, multiple: isUnlimitedFiles }),
|
|
21
21
|
hint && React.createElement(FormHint, { className: classes.hint }, hint),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAqB,MAAM,OAAO,CAAA;AACpE,OAAO,EAAE,UAAU,EAAS,MAAM,0BAA0B,CAAA;AAG5D,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,SAAS,MAAM,cAAc,CAAA;AACpC,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,MAAM,MAAM,UAAU,CAAA;AAuB7B,MAAM,SAAS,GAAG,UAAU,CAAQ,MAAM,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAA;AAEzE,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAA0B,SAAS,SAAS,CAC7E,KAAK,EACL,GAAG;IAEH,MAAM,EACJ,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,QAAQ,GAAG,CAAC,E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