react-hook-form-cloudscape 1.1.2 → 1.2.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/components/components/file-upload/file-upload.d.ts +12 -0
- package/components/components/file-upload/index.d.ts +1 -0
- package/components/file-upload/file-upload.d.ts +12 -0
- package/components/file-upload/file-upload.js +17 -0
- package/components/file-upload/file-upload.js.map +1 -0
- package/components/file-upload/index.d.ts +1 -0
- package/components/file-upload/index.js +2 -0
- package/components/file-upload/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FileUploadProps } from '@cloudscape-design/components';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Control, FieldValues, FieldPathValue, FieldPath, RegisterOptions } from 'react-hook-form';
|
|
4
|
+
export interface ControlledFileUploadProps<T extends FieldValues> extends Omit<FileUploadProps, 'value'> {
|
|
5
|
+
name: FieldPath<T>;
|
|
6
|
+
control?: Control<T>;
|
|
7
|
+
defaultValue?: FieldPathValue<T, FieldPath<T>>;
|
|
8
|
+
rules?: Omit<RegisterOptions<T, FieldPath<T>>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
|
|
9
|
+
shouldUnregister?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const CFileUpload: <TFieldValues extends FieldValues>({ name, control, defaultValue, rules, shouldUnregister, onChange, ...props }: ControlledFileUploadProps<TFieldValues>) => React.ReactElement;
|
|
12
|
+
export default CFileUpload;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CFileUpload } from './file-upload';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FileUploadProps } from '@cloudscape-design/components';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
import { Control, FieldValues, FieldPathValue, FieldPath, RegisterOptions } from 'react-hook-form';
|
|
4
|
+
export interface ControlledFileUploadProps<T extends FieldValues> extends Omit<FileUploadProps, 'value'> {
|
|
5
|
+
name: FieldPath<T>;
|
|
6
|
+
control?: Control<T>;
|
|
7
|
+
defaultValue?: FieldPathValue<T, FieldPath<T>>;
|
|
8
|
+
rules?: Omit<RegisterOptions<T, FieldPath<T>>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
|
|
9
|
+
shouldUnregister?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const CFileUpload: <TFieldValues extends FieldValues>({ name, control, defaultValue, rules, shouldUnregister, onChange, ...props }: ControlledFileUploadProps<TFieldValues>) => React.ReactElement;
|
|
12
|
+
export default CFileUpload;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { FileUpload } from '@cloudscape-design/components';
|
|
3
|
+
import React, { useCallback } from 'react';
|
|
4
|
+
import { Controller } from 'react-hook-form';
|
|
5
|
+
export const CFileUpload = (_a) => {
|
|
6
|
+
var { name, control, defaultValue, rules, shouldUnregister = false, onChange } = _a, props = __rest(_a, ["name", "control", "defaultValue", "rules", "shouldUnregister", "onChange"]);
|
|
7
|
+
const generateFilesArray = (files) => {
|
|
8
|
+
return (files === null || files === void 0 ? void 0 : files.length) ? files : [];
|
|
9
|
+
};
|
|
10
|
+
const handleOnChange = useCallback((formOnChange, e) => {
|
|
11
|
+
formOnChange(generateFilesArray(e.detail.value));
|
|
12
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
13
|
+
}, [onChange]);
|
|
14
|
+
return (React.createElement(Controller, { name: name, control: control, defaultValue: defaultValue, rules: rules, shouldUnregister: shouldUnregister, render: ({ field: { ref, onChange, value } }) => (React.createElement(FileUpload, Object.assign({ ref: ref, value: generateFilesArray(value), onChange: handleOnChange.bind(null, onChange) }, props))) }));
|
|
15
|
+
};
|
|
16
|
+
export default CFileUpload;
|
|
17
|
+
//# sourceMappingURL=file-upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-upload.js","sourceRoot":"","sources":["../../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,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,IACzC,KAAK,EACT,CACH,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CFileUpload } from './file-upload';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/file-upload/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-hook-form-cloudscape",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A React Hook Form wrapper designed for effortless integration of validations into Cloudscape forms and inputs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"react",
|
|
35
35
|
"react-hook-form",
|
|
36
36
|
"cloudscape",
|
|
37
|
-
"form",
|
|
38
|
-
"
|
|
37
|
+
"form-validation",
|
|
38
|
+
"react-component",
|
|
39
39
|
"typescript"
|
|
40
40
|
],
|
|
41
41
|
"peerDependencies": {
|