@ainias42/react-bootstrap-mobile 0.2.2 → 0.2.3
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/bin/updateCopies.js +1 -1
- package/dist/bootstrapReactMobile.js +26 -23
- package/dist/bootstrapReactMobile.js.map +1 -1
- package/dist/src/Components/FormElements/Input/FileInput/FileInput.d.ts +1 -0
- package/dist/src/Components/FormElements/Input/FileInput/MultipleFileInput.d.ts +2 -1
- package/package.json +1 -1
- package/src/Components/FormElements/Input/FileInput/FileInput.tsx +9 -10
- package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +24 -19
- package/src/Components/FormElements/Input/Input.tsx +5 -2
|
@@ -8,5 +8,6 @@ export type FileInputProps<OnChangeFileData> = RbmComponentProps<Override<Omit<M
|
|
|
8
8
|
value?: FileType;
|
|
9
9
|
mimeType?: string;
|
|
10
10
|
required?: boolean;
|
|
11
|
+
"data-test-id"?: string;
|
|
11
12
|
} & Listener<'onChangeFile', OnChangeFileData, FileType | undefined>>>;
|
|
12
13
|
export declare const FileInput: <OnChangeData>({ value, mimeType, required, ...otherProps }: FileInputProps<OnChangeData>) => React.JSX.Element;
|
|
@@ -14,5 +14,6 @@ export type MultipleFileInputProps<OnChangeFilesData> = RbmComponentProps<Overri
|
|
|
14
14
|
allowOverride?: boolean;
|
|
15
15
|
showDeleteButton?: boolean;
|
|
16
16
|
error?: string;
|
|
17
|
+
"data-test-id"?: string;
|
|
17
18
|
} & Listener<'onChangeFiles', OnChangeFilesData, FileType[]>>>;
|
|
18
|
-
export declare const MultipleFileInput: <OnChangeData>({ className, style, value, label, mimeTypes, maxFiles, maxSizePerFile, allowOverride, onError, showDeleteButton, error, ...otherProps }: MultipleFileInputProps<OnChangeData>) => React.JSX.Element;
|
|
19
|
+
export declare const MultipleFileInput: <OnChangeData>({ className, style, value, label, mimeTypes, maxFiles, maxSizePerFile, allowOverride, onError, showDeleteButton, error, "data-test-id": testId, ...otherProps }: MultipleFileInputProps<OnChangeData>) => React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {RbmComponentProps} from '../../../RbmComponentProps';
|
|
3
|
-
import {Override} from '../../../../TypeHelpers';
|
|
4
|
-
import {useCallback, useMemo} from 'react';
|
|
5
|
-
import {Listener, useListenerWithExtractedProps} from '../../../Hooks/useListener';
|
|
6
|
-
|
|
2
|
+
import { RbmComponentProps } from '../../../RbmComponentProps';
|
|
3
|
+
import { Override } from '../../../../TypeHelpers';
|
|
4
|
+
import { useCallback, useMemo } from 'react';
|
|
5
|
+
import { Listener, useListenerWithExtractedProps } from '../../../Hooks/useListener';
|
|
7
6
|
import styles from './fileInput.scss';
|
|
8
|
-
import {withMemo} from '../../../../helper/withMemo';
|
|
9
|
-
import {FileType} from "./FileType";
|
|
10
|
-
import {MultipleFileInput, MultipleFileInputProps} from "./MultipleFileInput";
|
|
7
|
+
import { withMemo } from '../../../../helper/withMemo';
|
|
8
|
+
import { FileType } from "./FileType";
|
|
9
|
+
import { MultipleFileInput, MultipleFileInputProps } from "./MultipleFileInput";
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
export type FileInputProps<OnChangeFileData> = RbmComponentProps<
|
|
14
13
|
Override<
|
|
15
|
-
Omit<MultipleFileInputProps<unknown>, "onChangeFiles" | "maxFiles" | "onChangeFilesData" | "mimeTypes"|"showDeleteButton">, {
|
|
14
|
+
Omit<MultipleFileInputProps<unknown>, "onChangeFiles" | "maxFiles" | "onChangeFilesData" | "mimeTypes" | "showDeleteButton">, {
|
|
16
15
|
value?: FileType,
|
|
17
16
|
mimeType?: string,
|
|
18
17
|
required?: boolean,
|
|
18
|
+
"data-test-id"?: string;
|
|
19
19
|
} & Listener<'onChangeFile', OnChangeFileData, FileType | undefined>>
|
|
20
20
|
>;
|
|
21
21
|
|
|
22
|
-
// TODO use MultipleFileInput internal
|
|
23
22
|
export const FileInput = withMemo(function FileInput<OnChangeData>({
|
|
24
23
|
value,
|
|
25
24
|
mimeType,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {RbmComponentProps} from '../../../RbmComponentProps';
|
|
3
|
-
import {Override} from '../../../../TypeHelpers';
|
|
4
|
-
import {ChangeEventHandler, DragEvent, InputHTMLAttributes, useCallback, useRef} from 'react';
|
|
5
|
-
import {Listener, useListenerWithExtractedProps} from '../../../Hooks/useListener';
|
|
2
|
+
import { RbmComponentProps } from '../../../RbmComponentProps';
|
|
3
|
+
import { Override } from '../../../../TypeHelpers';
|
|
4
|
+
import { ChangeEventHandler, DragEvent, InputHTMLAttributes, useCallback, useRef } from 'react';
|
|
5
|
+
import { Listener, useListenerWithExtractedProps } from '../../../Hooks/useListener';
|
|
6
6
|
import styles from './fileInput.scss';
|
|
7
|
-
import {withMemo} from '../../../../helper/withMemo';
|
|
7
|
+
import { withMemo } from '../../../../helper/withMemo';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
-
import {Block} from '../../../Layout/Block';
|
|
10
|
-
import {Text} from '../../../Text/Text';
|
|
11
|
-
import {Flex} from '../../../Layout/Flex';
|
|
12
|
-
import {Grow} from '../../../Layout/Grow';
|
|
13
|
-
import {Icon} from '../../../Icon/Icon';
|
|
14
|
-
import {faFile, faPlus, faTimesCircle} from '@fortawesome/free-solid-svg-icons';
|
|
15
|
-
import {Image} from '../../../Image/Image';
|
|
16
|
-
import {Clickable} from '../../../Clickable/Clickable';
|
|
17
|
-
import {Inline} from '../../../Layout/Inline';
|
|
18
|
-
import {FileType} from "./FileType";
|
|
9
|
+
import { Block } from '../../../Layout/Block';
|
|
10
|
+
import { Text } from '../../../Text/Text';
|
|
11
|
+
import { Flex } from '../../../Layout/Flex';
|
|
12
|
+
import { Grow } from '../../../Layout/Grow';
|
|
13
|
+
import { Icon } from '../../../Icon/Icon';
|
|
14
|
+
import { faFile, faPlus, faTimesCircle } from '@fortawesome/free-solid-svg-icons';
|
|
15
|
+
import { Image } from '../../../Image/Image';
|
|
16
|
+
import { Clickable } from '../../../Clickable/Clickable';
|
|
17
|
+
import { Inline } from '../../../Layout/Inline';
|
|
18
|
+
import { FileType } from "./FileType";
|
|
19
19
|
import { InlineBlock } from "../../../Layout/InlineBlock";
|
|
20
20
|
|
|
21
21
|
|
|
@@ -32,6 +32,7 @@ export type MultipleFileInputProps<OnChangeFilesData> = RbmComponentProps<
|
|
|
32
32
|
allowOverride?: boolean
|
|
33
33
|
showDeleteButton?: boolean
|
|
34
34
|
error?: string,
|
|
35
|
+
"data-test-id"?: string;
|
|
35
36
|
} & Listener<'onChangeFiles', OnChangeFilesData, FileType[]>
|
|
36
37
|
>
|
|
37
38
|
>;
|
|
@@ -47,7 +48,8 @@ export const MultipleFileInput = withMemo(function MultipleImageInput<OnChangeDa
|
|
|
47
48
|
allowOverride = maxFiles === 1,
|
|
48
49
|
onError,
|
|
49
50
|
showDeleteButton = true,
|
|
50
|
-
|
|
51
|
+
error,
|
|
52
|
+
"data-test-id": testId,
|
|
51
53
|
...otherProps
|
|
52
54
|
}: MultipleFileInputProps<OnChangeData>) {
|
|
53
55
|
// Variables
|
|
@@ -78,7 +80,7 @@ export const MultipleFileInput = withMemo(function MultipleImageInput<OnChangeDa
|
|
|
78
80
|
[mimeTypes]
|
|
79
81
|
);
|
|
80
82
|
|
|
81
|
-
const [onChangeFiles,
|
|
83
|
+
const [onChangeFiles, props] = useListenerWithExtractedProps('onChangeFiles', otherProps);
|
|
82
84
|
const getBase64 = useCallback((inputFiles: Blob[]) => {
|
|
83
85
|
const promises = inputFiles.map(
|
|
84
86
|
(file) =>
|
|
@@ -220,6 +222,7 @@ export const MultipleFileInput = withMemo(function MultipleImageInput<OnChangeDa
|
|
|
220
222
|
<span
|
|
221
223
|
className={classNames(styles.fileInput, className)}
|
|
222
224
|
style={style}
|
|
225
|
+
data-test-id={testId}
|
|
223
226
|
>
|
|
224
227
|
<Flex horizontal={true}>
|
|
225
228
|
{!!label && (
|
|
@@ -248,13 +251,15 @@ export const MultipleFileInput = withMemo(function MultipleImageInput<OnChangeDa
|
|
|
248
251
|
>
|
|
249
252
|
{renderFile(file)}
|
|
250
253
|
{showDeleteButton &&
|
|
251
|
-
<Clickable className={styles.previewRemove} onClick={removeFile}
|
|
254
|
+
<Clickable className={styles.previewRemove} onClick={removeFile}
|
|
255
|
+
onClickData={index}>
|
|
252
256
|
<Icon icon={faTimesCircle}/>
|
|
253
257
|
</Clickable>}
|
|
254
258
|
</Clickable>
|
|
255
259
|
</Grow>;
|
|
256
260
|
})}
|
|
257
|
-
<Grow className={classNames(styles.addFile, {[styles.hidden]: value.length >= maxFiles})}
|
|
261
|
+
<Grow className={classNames(styles.addFile, {[styles.hidden]: value.length >= maxFiles})}
|
|
262
|
+
center={true}>
|
|
258
263
|
<Clickable
|
|
259
264
|
className={styles.addFileButton}
|
|
260
265
|
onDrop={onDrop}
|
|
@@ -19,6 +19,7 @@ import { useOnChangeDone } from '../hooks/useOnChangeDone';
|
|
|
19
19
|
import { InlineBlock } from "../../Layout/InlineBlock";
|
|
20
20
|
import { Text } from "../../Text/Text";
|
|
21
21
|
import { useSendFormContext } from "../Controller/SendFormContext";
|
|
22
|
+
import { useDebounced } from "../../Hooks/useDebounced";
|
|
22
23
|
|
|
23
24
|
export type InputProps<OnChangeData, OnBlurData, OnChangeDoneData> = RbmComponentProps<
|
|
24
25
|
Override<
|
|
@@ -119,10 +120,12 @@ export const Input = withForwardRef(function Input<OnChangeData, OnBlurData, OnC
|
|
|
119
120
|
otherPropsWithoutOnchange
|
|
120
121
|
);
|
|
121
122
|
|
|
122
|
-
const [
|
|
123
|
+
const [onChangeDoneWithoutDeboune, otherPropsWithoutData] = useListenerWithExtractedProps<'onChangeDone', OnChangeDoneData>(
|
|
123
124
|
'onChangeDone',
|
|
124
125
|
otherPropsWithoutBlur
|
|
125
126
|
);
|
|
127
|
+
const onChangeDone = useDebounced(onChangeDoneWithoutDeboune, [onChangeDoneWithoutDeboune]);
|
|
128
|
+
|
|
126
129
|
|
|
127
130
|
const realOnKeyDown = useCallback(
|
|
128
131
|
(e: KeyboardEvent<HTMLInputElement>) => {
|
|
@@ -156,7 +159,7 @@ export const Input = withForwardRef(function Input<OnChangeData, OnBlurData, OnC
|
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
},
|
|
159
|
-
[onKeyDown,
|
|
162
|
+
[onKeyDown, onEnter, otherProps.type, otherProps.step, otherProps.max, otherProps.min, onChange]
|
|
160
163
|
);
|
|
161
164
|
|
|
162
165
|
// Effects
|