@saas-ui/forms 0.7.6 → 0.8.0-next.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,11 +33,27 @@ import { FormProps } from './form'
33
33
  export interface UseStepFormProps<
34
34
  TFieldValues extends FieldValues = FieldValues
35
35
  > extends UseStepperProps,
36
- FormProps<TFieldValues> {}
36
+ Omit<FormProps<TFieldValues>, 'children'> {
37
+ children:
38
+ | React.ReactNode
39
+ | ((stepper: UseStepFormReturn<TFieldValues>) => React.ReactElement)
40
+ }
41
+
42
+ export interface UseStepFormReturn<
43
+ TFieldValues extends FieldValues = FieldValues
44
+ > extends UseStepperReturn {
45
+ getFormProps(): {
46
+ onSubmit: SubmitHandler<TFieldValues>
47
+ schema?: any
48
+ resolver?: any
49
+ }
50
+ updateStep(step: any): void
51
+ steps: Record<string, any>
52
+ }
37
53
 
38
54
  export function useStepForm<TFieldValues extends FieldValues = FieldValues>(
39
55
  props: UseStepFormProps<TFieldValues>
40
- ) {
56
+ ): UseStepFormReturn<TFieldValues> {
41
57
  const stepper = useStepper(props)
42
58
 
43
59
  const { activeStep, isLastStep, nextStep } = stepper
@@ -64,20 +80,17 @@ export function useStepForm<TFieldValues extends FieldValues = FieldValues>(
64
80
  [activeStep, isLastStep]
65
81
  )
66
82
 
67
- const getFormProps = React.useCallback(
68
- (props) => {
69
- const step = steps[activeStep]
70
- return {
71
- onSubmit: onSubmitStep,
72
- schema: step?.schema,
73
- resolver: step?.resolver,
74
- }
75
- },
76
- [steps, onSubmitStep, activeStep]
77
- )
83
+ const getFormProps = React.useCallback(() => {
84
+ const step = steps[activeStep]
85
+ return {
86
+ onSubmit: onSubmitStep,
87
+ schema: step?.schema,
88
+ resolver: step?.resolver,
89
+ }
90
+ }, [steps, onSubmitStep, activeStep])
78
91
 
79
92
  const updateStep = React.useCallback(
80
- (step) => {
93
+ (step: StepState) => {
81
94
  updateSteps((steps) => {
82
95
  return {
83
96
  ...steps,
@@ -96,8 +109,6 @@ export function useStepForm<TFieldValues extends FieldValues = FieldValues>(
96
109
  }
97
110
  }
98
111
 
99
- export type UseStepFormReturn = ReturnType<typeof useStepForm>
100
-
101
112
  export interface UseFormStepProps {
102
113
  name: string
103
114
  schema?: any
package/yup/package.json CHANGED
@@ -4,17 +4,6 @@
4
4
  "version": "1.0.0",
5
5
  "private": true,
6
6
  "source": "./src/index.ts",
7
- "exports": {
8
- ".": {
9
- "development": "./src/index.ts",
10
- "require": "./../dist/yup/index.js",
11
- "types": "./../dist/yup/src/index.d.ts",
12
- "default": "./../dist/yup/index.modern.js"
13
- },
14
- "./src": {
15
- "default": "./src/index.ts"
16
- }
17
- },
18
7
  "main": "../dist/yup/index.js",
19
8
  "module": "../dist/yup/index.modern.js",
20
9
  "types": "../dist/yup/index.d.ts",
package/zod/package.json CHANGED
@@ -4,24 +4,13 @@
4
4
  "version": "1.0.0",
5
5
  "private": true,
6
6
  "source": "./src/index.ts",
7
- "exports": {
8
- ".": {
9
- "development": "./src/index.ts",
10
- "require": "./../dist/zod/index.js",
11
- "types": "./../dist/zod/src/index.d.ts",
12
- "default": "./../dist/zod/index.modern.js"
13
- },
14
- "./src": {
15
- "default": "./src/index.ts"
16
- }
17
- },
18
7
  "main": "../dist/zod/index.js",
19
8
  "module": "../dist/zod/index.modern.js",
20
9
  "types": "../dist/zod/index.d.ts",
21
10
  "author": "Eelco Wiersma <eelco@appulse.nl>",
22
11
  "license": "MIT",
23
12
  "peerDependencies": {
24
- "@chakra-ui/utils": "^1.10.4",
13
+ "@chakra-ui/utils": "^2.0.0-next.1",
25
14
  "@hookform/resolvers": "^2.8.3",
26
15
  "react-hook-form": "^7.22.0",
27
16
  "zod": "^3.14.4"
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../zod/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}