-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5188d00
commit 0ef57a7
Showing
8 changed files
with
128 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 14 additions & 5 deletions
19
packages/haring-react-hook-form/src/types/form-dynamic-zone.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
import type { IBaseBlock, IBaseBlockButton } from '@smile/haring-react'; | ||
import type { IOmitRespectIndexSignature } from '@smile/haring-react-shared'; | ||
import type { ReactElement } from 'react'; | ||
import type { UseFormRegister } from 'react-hook-form/dist/types/form'; | ||
|
||
export interface IFormField extends IBaseBlock { | ||
// fieldName: string; | ||
// fieldId: string; | ||
value?: string; | ||
} | ||
|
||
export type IFormRegisterFunc<T extends IFormField = IFormField> = | ||
UseFormRegister<Record<string, Omit<T, 'id'>[]>>; | ||
export interface IFormFieldWithoutId | ||
extends IOmitRespectIndexSignature<IFormField, 'id'> { | ||
id?: never; // forbid property "id" from being declared, to never override the internal IBaseBlock.id which is only used by useFieldArray() | ||
} | ||
|
||
export type IFormRegisterFunc< | ||
T extends IFormFieldWithoutId = IFormFieldWithoutId, | ||
> = UseFormRegister<Record<string, T[]>>; | ||
|
||
export interface IFormDynBlock { | ||
block: Omit<IFormField, 'id'>; | ||
block: IFormFieldWithoutId; | ||
button: IBaseBlockButton; | ||
renderFunc: ( | ||
block: IBaseBlock, | ||
block: IFormField, | ||
index: number, | ||
registerFunc: IFormRegisterFunc, | ||
registerName: string, | ||
) => ReactElement; | ||
} | ||
|
||
export type IFormDynSubmit = Record<string, IFormFieldWithoutId[]>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './form-dynamic-zone'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type IOmitRespectIndexSignature<T, K extends PropertyKey> = { | ||
[P in keyof T as Exclude<P, K>]: T[P]; | ||
}; |