@cutting/react-hook-form-components 0.1.1
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/README.md +9 -0
- package/dist/esm/components/FormComponents/FormComponents.d.ts +17 -0
- package/dist/esm/components/FormComponents/FormComponents.d.ts.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +70 -0
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @cutting/react-hook-form-components
|
|
2
|
+
|
|
3
|
+
Components from [@cutting/component-library](https://github.com/dagda1/cuttingedge/tree/main/packages/component-library) ready to be added to any [react-hook-form](https://react-hook-form.com/).
|
|
4
|
+
|
|
5
|
+
## install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @cutting/react-hook-form-components
|
|
9
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { FormInput, FormTextArea } from '@cutting/component-library';
|
|
3
|
+
import type { UseFormRegister, UseFormReturn } from 'react-hook-form';
|
|
4
|
+
declare module 'react' {
|
|
5
|
+
function forwardRef<T, P = Record<string, unknown>>(render: (props: P, ref: React.Ref<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
|
|
6
|
+
}
|
|
7
|
+
declare type Controls = typeof FormInput | typeof FormTextArea;
|
|
8
|
+
export declare type FormProps<C extends Controls, E> = ComponentProps<C> & {
|
|
9
|
+
required?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
errors?: E;
|
|
12
|
+
} & ReturnType<UseFormRegister<any>> & Partial<Pick<UseFormReturn<any>, 'setValue'>>;
|
|
13
|
+
export declare function createFormComponent(Component: Controls): <F extends HTMLElement>(props: FormProps<Controls, any> & import("react").RefAttributes<F>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
|
|
14
|
+
export declare const Input: <F extends HTMLElement>(props: FormProps<Controls, any> & import("react").RefAttributes<F>) => React.ReactElement | null;
|
|
15
|
+
export declare const TextArea: <F extends HTMLElement>(props: FormProps<Controls, any> & import("react").RefAttributes<F>) => React.ReactElement | null;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=FormComponents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormComponents.d.ts","sourceRoot":"","sources":["../../../../src/components/FormComponents/FormComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAO,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,QAAQ,OAAO,CAAC;IACrB,SAAS,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChD,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,GACjE,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;CACrE;AAED,aAAK,QAAQ,GAAG,OAAO,SAAS,GAAG,OAAO,YAAY,CAAC;AAEvD,oBAAY,SAAS,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG;IACjE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,CAAC;CAGZ,GAAG,UAAU,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAElC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;AAGhD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,QAAQ,gMAmBtD;AAED,eAAO,MAAM,KAAK,iGArC0B,kBAAkB,GAAG,IAqCd,CAAC;AACpD,eAAO,MAAM,QAAQ,iGAtCuB,kBAAkB,GAAG,IAsCR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4CAA4C,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as n}from"react/jsx-runtime";import{forwardRef as r}from"react";import{FormInput as e,FormTextArea as o}from"@cutting/component-library";function t(e){return r((function({onChange:r,onBlur:o,name:t,label:a,className:m,...c},i){return n(e,{innerRef:i,className:m,label:a,name:t,onChange:r,onBlur:o,...c})}))}const a=t(e),m=t(o);export{a as Input,m as TextArea,t as createFormComponent};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/components/FormComponents/FormComponents.tsx"],"sourcesContent":["import type { ComponentProps, Ref } from 'react';\nimport { forwardRef } from 'react';\nimport { FormInput, FormTextArea } from '@cutting/component-library';\nimport type { UseFormRegister, UseFormReturn } from 'react-hook-form';\n\ndeclare module 'react' {\n function forwardRef<T, P = Record<string, unknown>>(\n render: (props: P, ref: React.Ref<T>) => React.ReactElement | null,\n ): (props: P & React.RefAttributes<T>) => React.ReactElement | null;\n}\n\ntype Controls = typeof FormInput | typeof FormTextArea;\n\nexport type FormProps<C extends Controls, E> = ComponentProps<C> & {\n required?: boolean;\n className?: string;\n errors?: E;\n // TODO: remove any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & ReturnType<UseFormRegister<any>> &\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Partial<Pick<UseFormReturn<any>, 'setValue'>>;\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function createFormComponent(Component: Controls) {\n return forwardRef(function ReactHookFormComponent<F extends HTMLElement>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n { onChange, onBlur, name, label, className, ...props }: FormProps<typeof Component, any>,\n ref: Ref<F>,\n ): JSX.Element {\n return (\n <Component\n innerRef={ref}\n className={className}\n label={label}\n name={name}\n onChange={onChange}\n onBlur={onBlur}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(props as any)}\n />\n );\n });\n}\n\nexport const Input = createFormComponent(FormInput);\nexport const TextArea = createFormComponent(FormTextArea);\n"],"names":["createFormComponent","Component","forwardRef","onChange","onBlur","name","label","className","props","ref","_jsx","innerRef","Input","FormInput","TextArea","FormTextArea"],"mappings":"oJAwBM,SAAUA,EAAoBC,GAClC,OAAOC,GAAW,UAEhBC,SAAEA,EAAQC,OAAEA,EAAMC,KAAEA,EAAIC,MAAEA,EAAKC,UAAEA,KAAcC,GAC/CC,GAEA,OACEC,EAACT,EAAS,CACRU,SAAUF,EACVF,UAAWA,EACXD,MAAOA,EACPD,KAAMA,EACNF,SAAUA,EACVC,OAAQA,KAEHI,GAGX,GACF,OAEaI,EAAQZ,EAAoBa,GAC5BC,EAAWd,EAAoBe"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cutting/react-hook-form-components",
|
|
3
|
+
"description": "components for react-hook-form.",
|
|
4
|
+
"version": "0.1.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/dagda1/cuttingedge.git"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@cutting/component-library": "5.32.0",
|
|
19
|
+
"@cutting/util": "4.55.1",
|
|
20
|
+
"assert-ts": "^0.3.4",
|
|
21
|
+
"react-hook-form": "7.39.1"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@cutting/devtools": "4.60.0",
|
|
25
|
+
"@cutting/eslint-config": "4.42.0",
|
|
26
|
+
"@cutting/tsconfig": "4.38.0",
|
|
27
|
+
"@cutting/useful-types": "4.38.0",
|
|
28
|
+
"@types/react": "18.0.21",
|
|
29
|
+
"@vanilla-extract/css": "^1.9.1",
|
|
30
|
+
"eslint": "8.24.0",
|
|
31
|
+
"react": "18.2.0",
|
|
32
|
+
"react-dom": "18.2.0",
|
|
33
|
+
"react-syntax-highlighter": "15.5.0",
|
|
34
|
+
"typescript": "4.8.4"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": ">= 18.x.x",
|
|
38
|
+
"react-dom": ">= 18.x.x"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"react-hook-form",
|
|
42
|
+
"focus",
|
|
43
|
+
"react",
|
|
44
|
+
"reactjs",
|
|
45
|
+
"reactnative",
|
|
46
|
+
"hooks",
|
|
47
|
+
"hook",
|
|
48
|
+
"hooks"
|
|
49
|
+
],
|
|
50
|
+
"volta": {
|
|
51
|
+
"extends": "../../package.json"
|
|
52
|
+
},
|
|
53
|
+
"exports": {
|
|
54
|
+
"import": "./dist/esm/index.js"
|
|
55
|
+
},
|
|
56
|
+
"typesVersions": {
|
|
57
|
+
"*": {
|
|
58
|
+
"*": [
|
|
59
|
+
"dist/esm/index.d.ts"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"start": "echo no demo",
|
|
65
|
+
"test": "echo no tests yet",
|
|
66
|
+
"lint": "eslint ./src/**/*.{ts,tsx} --fix",
|
|
67
|
+
"lint:fix": "pnpm lint --fix",
|
|
68
|
+
"build": "NODE_ENV=production devtools rollup"
|
|
69
|
+
}
|
|
70
|
+
}
|