fix(types): improve Schema type for useForm

This commit is contained in:
Divlo 2022-09-21 09:33:09 +02:00
parent d213893d5d
commit fcc2b2ea77
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
7 changed files with 4083 additions and 5221 deletions

1012
example/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,26 +11,26 @@
"test:dev": "start-server-and-test \"dev\" \"http://localhost:3000\" \"cypress open\"" "test:dev": "start-server-and-test \"dev\" \"http://localhost:3000\" \"cypress open\""
}, },
"dependencies": { "dependencies": {
"@sinclair/typebox": "0.24.28", "@sinclair/typebox": "0.24.42",
"clsx": "1.2.1", "clsx": "1.2.1",
"next": "12.2.5", "next": "12.3.1",
"next-themes": "0.2.0", "next-themes": "0.2.1",
"next-translate": "1.5.0", "next-translate": "1.6.0",
"react": "18.2.0", "react": "18.2.0",
"react-component-form": "file:..", "react-component-form": "file:..",
"react-dom": "18.2.0" "react-dom": "18.2.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "18.7.13", "@types/node": "18.7.18",
"@types/react": "18.0.17", "@types/react": "18.0.20",
"@types/react-dom": "18.0.6", "@types/react-dom": "18.0.6",
"autoprefixer": "10.4.8", "autoprefixer": "10.4.12",
"cypress": "10.6.0", "cypress": "10.8.0",
"eslint": "8.22.0", "eslint": "8.23.1",
"eslint-config-next": "12.2.5", "eslint-config-next": "12.3.1",
"postcss": "8.4.16", "postcss": "8.4.16",
"start-server-and-test": "1.14.0", "start-server-and-test": "1.14.0",
"tailwindcss": "3.1.8", "tailwindcss": "3.1.8",
"typescript": "4.8.2" "typescript": "4.8.3"
} }
} }

View File

@ -1,9 +1,9 @@
import type { AppProps } from 'next/app' import type { AppType } from 'next/app'
import { ThemeProvider } from 'next-themes' import { ThemeProvider } from 'next-themes'
import '../styles/globals.css' import '../styles/globals.css'
const MyApp = ({ Component, pageProps }: AppProps): JSX.Element => { const MyApp: AppType = ({ Component, pageProps }) => {
return ( return (
<ThemeProvider attribute='class' defaultTheme='dark'> <ThemeProvider attribute='class' defaultTheme='dark'>
<Component {...pageProps} /> <Component {...pageProps} />

8223
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -37,37 +37,37 @@
"react": ">=16" "react": ">=16"
}, },
"dependencies": { "dependencies": {
"@sinclair/typebox": "0.24.28", "@sinclair/typebox": "0.24.42",
"ajv": "8.11.0", "ajv": "8.11.0",
"ajv-formats": "2.1.1" "ajv-formats": "2.1.1"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "17.0.3", "@commitlint/cli": "17.1.2",
"@commitlint/config-conventional": "17.0.3", "@commitlint/config-conventional": "17.1.0",
"@testing-library/react": "13.3.0", "@testing-library/react": "13.4.0",
"@types/jest": "28.1.8", "@types/jest": "29.0.3",
"@types/react": "18.0.17", "@types/react": "18.0.20",
"@types/react-dom": "18.0.6", "@types/react-dom": "18.0.6",
"@typescript-eslint/eslint-plugin": "5.35.1", "@typescript-eslint/eslint-plugin": "5.38.0",
"@typescript-eslint/parser": "5.35.1", "@typescript-eslint/parser": "5.38.0",
"editorconfig-checker": "4.0.2", "editorconfig-checker": "4.0.2",
"esbuild": "0.15.5", "esbuild": "0.15.8",
"esbuild-jest": "0.5.0", "esbuild-jest": "0.5.0",
"eslint": "8.22.0", "eslint": "8.23.1",
"eslint-config-conventions": "3.0.0", "eslint-config-conventions": "4.0.1",
"eslint-config-prettier": "8.5.0", "eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0", "eslint-plugin-import": "2.26.0",
"eslint-plugin-prettier": "4.2.1", "eslint-plugin-prettier": "4.2.1",
"eslint-plugin-promise": "6.0.1", "eslint-plugin-promise": "6.0.1",
"eslint-plugin-unicorn": "43.0.2", "eslint-plugin-unicorn": "43.0.2",
"jest": "29.0.0", "jest": "29.0.3",
"jest-environment-jsdom": "29.0.0", "jest-environment-jsdom": "29.0.3",
"markdownlint-cli2": "0.5.1", "markdownlint-cli2": "0.5.1",
"prettier": "2.7.1", "prettier": "2.7.1",
"react": "18.2.0", "react": "18.2.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"semantic-release": "19.0.5", "semantic-release": "19.0.5",
"tsup": "6.2.2", "tsup": "6.2.3",
"typescript": "4.7.4" "typescript": "4.8.3"
} }
} }

View File

@ -1,7 +1,8 @@
import React from 'react' import React from 'react'
import { render, cleanup, fireEvent } from '@testing-library/react' import { render, cleanup, fireEvent } from '@testing-library/react'
import { Form, HandleForm } from '..' import type { HandleForm } from '..'
import { Form } from '..'
afterEach(cleanup) afterEach(cleanup)

View File

@ -1,14 +1,18 @@
import { useMemo, useState } from 'react' import { useMemo, useState } from 'react'
import { SchemaOptions, Static, TObject, Type } from '@sinclair/typebox' import type { Static, TObject } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
import type { ErrorObject } from 'ajv' import type { ErrorObject } from 'ajv'
import type { HandleForm } from '../components/Form' import type { HandleForm } from '../components/Form'
import { FetchState, useFetchState } from './useFetchState' import type { FetchState } from './useFetchState'
import { useFetchState } from './useFetchState'
import { ajv } from '../utils/ajv' import { ajv } from '../utils/ajv'
import { handleCheckboxBoolean } from '../utils/handleCheckboxBoolean' import { handleCheckboxBoolean } from '../utils/handleCheckboxBoolean'
import { handleOptionalEmptyStringToNull } from '../utils/handleOptionalEmptyStringToNull' import { handleOptionalEmptyStringToNull } from '../utils/handleOptionalEmptyStringToNull'
export type Schema = SchemaOptions export interface Schema {
[property: string]: any
}
export type Error = ErrorObject export type Error = ErrorObject