@goodhood-web/nebenan-base 3.0.0-development.90 → 3.0.0-development.92

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.
@@ -0,0 +1,3 @@
1
+ import { AuthenticationFormProps } from './AuthenticationForm.types';
2
+ export declare const AuthenticationForm: ({ onSubmit }: AuthenticationFormProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default AuthenticationForm;
@@ -0,0 +1,13 @@
1
+ import { UseFormReturn } from 'react-hook-form';
2
+ import { OnSubmitFunction } from '../Forms/Form/Form.types';
3
+ export type AuthenticationFormData = {
4
+ email: string;
5
+ password: string;
6
+ };
7
+ export type AuthenticationFormSubmitData = {
8
+ data: AuthenticationFormData;
9
+ methods?: UseFormReturn<AuthenticationFormData>;
10
+ };
11
+ export type AuthenticationFormProps = {
12
+ onSubmit: OnSubmitFunction<AuthenticationFormData>;
13
+ };
@@ -12,11 +12,13 @@ export interface FeedItems {
12
12
  is_bookmarked: boolean;
13
13
  };
14
14
  }
15
+ declare const ALLOWED_POSITIONS: readonly [0, 1, 2, 3, 4, 5];
16
+ type Position = (typeof ALLOWED_POSITIONS)[number];
15
17
  export interface AdItem {
16
- block?: number;
18
+ block: number;
17
19
  content: React.ReactNode;
18
20
  id: string;
19
- position: number;
21
+ position?: Position;
20
22
  type?: string;
21
23
  }
22
24
  export interface GridFeedProps {
@@ -28,3 +30,4 @@ export interface GridFeedProps {
28
30
  export type ChunkItem = number | AdItem;
29
31
  export type ResultType = Array<ChunkItem[] | AdItem>;
30
32
  export type GridFeedMarketplaceItem = MarketplaceItemCardlessTypes | AdItem;
33
+ export {};
@@ -1,4 +1,4 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { DynamicFormProps } from './DynamicForm.types';
3
- export declare function DynamicForm({ fields, onSubmit }: PropsWithChildren<DynamicFormProps>): import("react/jsx-runtime").JSX.Element;
2
+ import { WizardStepT } from '../Wizard/Wizard.types';
3
+ export declare function DynamicForm({ fields, onSubmit }: PropsWithChildren<WizardStepT>): import("react/jsx-runtime").JSX.Element;
4
4
  export default DynamicForm;
@@ -1,4 +1,4 @@
1
1
  import { UseControllerProps } from 'react-hook-form';
2
2
  import { TextInputProps } from '../../../../../ui/src/lib/Atoms/Inputs/TextInput/TextInput.types';
3
3
  export type FormTextInputProps = UseControllerProps & Partial<TextInputProps>;
4
- export default function FormTextInput({ colorScheme, id, label, name, rules, size, value, }: FormTextInputProps): import("react/jsx-runtime").JSX.Element;
4
+ export default function FormTextInput({ colorScheme, id, label, name, rules, size, value, ...props }: FormTextInputProps): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,3 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { FieldValues } from 'react-hook-form';
2
2
  import { FormProps } from './Form.types';
3
- export default function Form({ children, className, initialValues, onSubmit, validationSchema, }: PropsWithChildren<FormProps>): import("react/jsx-runtime").JSX.Element;
3
+ export default function Form<FormData extends FieldValues>({ children, className, initialValues, onSubmit, validationSchema, }: FormProps<FormData>): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ import { DefaultValues, FieldValues, UseFormReturn } from 'react-hook-form';
1
3
  import { ZodType } from 'zod';
2
- export type FormProps = {
4
+ export type OnSubmitFunction<FormData extends FieldValues> = (arg: OnFormSubmitType<FormData>) => void;
5
+ export type OnFormSubmitType<FormData extends FieldValues> = {
6
+ data: FormData;
7
+ methods?: UseFormReturn<FormData>;
8
+ };
9
+ export type FormProps<FormData extends FieldValues> = {
10
+ children: ReactNode | ReactNode[];
3
11
  className?: string;
4
- initialValues?: object;
5
- onSubmit: (data: object) => void;
12
+ initialValues?: DefaultValues<FormData>;
13
+ onSubmit: OnSubmitFunction<FormData>;
6
14
  validationSchema?: ZodType<FormData>;
7
15
  };
@@ -1,3 +1,4 @@
1
- import { GridFormProps } from './GridForm.types';
2
- export declare const GridForm: ({ children, ...props }: GridFormProps) => import("react/jsx-runtime").JSX.Element;
1
+ import { FieldValues } from 'react-hook-form';
2
+ import { FormProps } from '../Form/Form.types';
3
+ export declare function GridForm<FormData extends FieldValues>({ children, ...props }: FormProps<FormData>): import("react/jsx-runtime").JSX.Element;
3
4
  export default GridForm;
@@ -1,13 +1,26 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { GridItemProps } from '../../Grids/Grid/GridItem/GridItem.types';
3
3
  import { FormTextInputProps } from '../Fields/FormTextInput';
4
+ import { FormProps } from '../Form/Form.types';
5
+ export type FieldValueMap = {
6
+ text: string;
7
+ };
8
+ export type StrictFormField = {
9
+ name: string;
10
+ type: keyof FieldValueMap;
11
+ };
12
+ type OnlyStrictFields<T extends readonly unknown[]> = Extract<T[number], StrictFormField>;
13
+ export type InferFormData<T extends readonly unknown[]> = {
14
+ [Field in OnlyStrictFields<T> as Field['name']]: FieldValueMap[Field['type']];
15
+ };
16
+ type StepType = 'text' | 'submit' | 'slot';
4
17
  export type StepField = {
5
18
  id: string;
6
19
  layout?: {
7
20
  desktop?: GridItemProps['desktop'];
8
21
  mobile?: GridItemProps['mobile'];
9
22
  };
10
- type: string;
23
+ type: StepType;
11
24
  };
12
25
  export type TextField = StepField & FormTextInputProps & {
13
26
  type: 'text';
@@ -21,15 +34,13 @@ export type SlotField = StepField & {
21
34
  }) => ReactNode;
22
35
  type: 'slot';
23
36
  };
24
- export type NextField = StepField & {
25
- type: 'next';
26
- };
27
- export type FormField = SubmitField | SlotField | TextField | NextField;
37
+ export type FormField = TextField | SubmitField | SlotField;
28
38
  export type WizardStepT = {
29
39
  fields: FormField[];
30
- id: string;
31
- onSubmit?: (data: object) => void;
40
+ id?: string;
41
+ onSubmit: FormProps<InferFormData<FormField[]>>['onSubmit'];
32
42
  };
33
43
  export type WizardProps = {
34
44
  steps: WizardStepT[];
35
45
  };
46
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodhood-web/nebenan-base",
3
- "version": "3.0.0-development.90",
3
+ "version": "3.0.0-development.92",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "repository": "https://github.com/good-hood-gmbh/goodhood-web",