Skip to content

Commit 93e3a9e

Browse files
committed
chore: updates types using common
1 parent 71cb4be commit 93e3a9e

File tree

166 files changed

+782
-1494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+782
-1494
lines changed

packages/ui/src/components/organisms/Form/DynamicForm/DynamicForm.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useValues } from './hooks/internal/useValues';
1111
import { EventsProvider } from './providers/EventsProvider';
1212
import { TaskRunner } from './providers/TaskRunner';
1313
import { extendFieldsRepository, getFieldsRepository } from './repositories';
14-
import { IDynamicFormProps, IFormRef } from './types';
14+
import { IDynamicFormProps, IFormRef, TElementsMap } from './types';
1515
import { Toaster } from 'sonner';
1616
import { QueryClientProvider } from '@tanstack/react-query';
1717
import { HttpClientProvider } from './providers/HttpClientProvider';
@@ -70,7 +70,9 @@ export const DynamicFormV2 = forwardRef(
7070
values: valuesApi.values,
7171
submit,
7272
fieldHelpers,
73-
elementsMap: fieldExtends ? extendFieldsRepository(fieldExtends) : getFieldsRepository(),
73+
elementsMap: fieldExtends
74+
? (extendFieldsRepository(fieldExtends) as unknown as TElementsMap)
75+
: (getFieldsRepository() as unknown as TElementsMap),
7476
callbacks: {
7577
onEvent,
7678
},

packages/ui/src/components/organisms/Form/DynamicForm/DynamicForm.unit.test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import { useValidationSchema } from './hooks/internal/useValidationSchema';
1111
import { useValues } from './hooks/internal/useValues';
1212
import { EventsProvider } from './providers/EventsProvider';
1313
import { TaskRunner } from './providers/TaskRunner';
14-
import { ICommonFieldParams, IDynamicFormProps, IFormElement, IFormRef } from './types';
14+
import { IDynamicFormProps, IFormRef } from './types';
15+
import { TUIElement } from '@ballerine/common';
1516

1617
// Mock dependencies
1718
vi.mock('../../Renderer');
@@ -115,9 +116,7 @@ describe('DynamicFormV2', () => {
115116
});
116117

117118
it('should pass elements to useValidationSchema', () => {
118-
const elements = [{ id: 'test', element: 'textfield' }] as unknown as Array<
119-
IFormElement<string, ICommonFieldParams>
120-
>;
119+
const elements = [{ id: 'test', element: 'textfield' }] as unknown as Array<TUIElement>;
121120
render(<DynamicFormV2 {...mockProps} elements={elements} />);
122121
expect(useValidationSchema).toHaveBeenCalledWith(elements);
123122
});

packages/ui/src/components/organisms/Form/DynamicForm/_stories/ConditionalRenderingShowcase/schema.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { IFormElement } from '../../types';
1+
import { TUIElement } from '@ballerine/common';
22

3-
export const schema: Array<IFormElement<any, any>> = [
3+
export const schema: Array<TUIElement> = [
44
{
55
id: 'first-name',
66
element: 'textfield',
@@ -12,7 +12,6 @@ export const schema: Array<IFormElement<any, any>> = [
1212
validate: [
1313
{
1414
type: 'required',
15-
value: {},
1615
message: 'First name is required',
1716
applyWhen: {
1817
engine: 'json-logic',
@@ -57,7 +56,6 @@ export const schema: Array<IFormElement<any, any>> = [
5756
validate: [
5857
{
5958
type: 'required',
60-
value: {},
6159
message: 'Last name is required',
6260
applyWhen: {
6361
engine: 'json-logic',
@@ -73,7 +71,7 @@ export const schema: Array<IFormElement<any, any>> = [
7371
element: 'submitbutton',
7472
valueDestination: 'submit',
7573
params: {
76-
label: 'Submit',
74+
text: 'Submit',
7775
disableWhenFormIsInvalid: true,
7876
},
7977
},

packages/ui/src/components/organisms/Form/DynamicForm/_stories/CustomInputsShowcase/CustomInputsShowCase.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TODO: Implement typed custom input extends
2+
//@ts-nocheck
13
import { AnyObject } from '@/common';
24
import { Input } from '@/components/atoms';
35
import { useState } from 'react';

packages/ui/src/components/organisms/Form/DynamicForm/_stories/CustomValidatorsShowcase/CustomValidatorsShowcase.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
// TODO: Implement typed validator extends
2+
//@ts-nocheck
13
import { AnyObject } from '@/common';
24
import { useState } from 'react';
35
import { registerValidator, TValidator } from '../../../Validator';
46
import { JSONEditorComponent } from '../../../Validator/_stories/components/JsonEditor/JsonEditor';
57
import { DynamicFormV2 } from '../../DynamicForm';
6-
import { IFormElement } from '../../types';
78

89
const johnDoeCheckerValidator: TValidator<string, any, 'johnDoeChecker'> = (value, context) => {
910
if (value !== 'John Doe') {

packages/ui/src/components/organisms/Form/DynamicForm/_stories/FileUploadShowcase/FileUploadShowcase.tsx

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,31 @@ import { AnyObject } from '@/common';
22
import { useState } from 'react';
33
import { JSONEditorComponent } from '../../../Validator/_stories/components/JsonEditor/JsonEditor';
44
import { DynamicFormV2 } from '../../DynamicForm';
5-
import { IFormElement } from '../../types';
5+
import { TUIElement } from '@ballerine/common';
66

7-
const schema: Array<IFormElement<any, any>> = [
7+
const schema: Array<TUIElement> = [
88
{
99
id: 'FileField:Regular',
1010
element: 'filefield',
1111
valueDestination: 'file-regular',
1212
params: {
1313
label: 'Regular Upload',
1414
placeholder: 'Select File',
15-
uploadSettings: {
16-
url: 'http://localhost:3000/upload',
17-
resultPath: 'filename',
18-
method: 'POST',
15+
httpParams: {
16+
createDocument: {
17+
params: {},
18+
url: '',
19+
method: 'GET',
20+
resultPath: '',
21+
headers: {},
22+
},
23+
deleteDocument: {
24+
params: {},
25+
url: '',
26+
method: 'GET',
27+
resultPath: '',
28+
headers: {},
29+
},
1930
},
2031
},
2132
},
@@ -26,12 +37,20 @@ const schema: Array<IFormElement<any, any>> = [
2637
params: {
2738
label: 'Upload to protected endpoint',
2839
placeholder: 'Select File',
29-
uploadSettings: {
30-
url: 'http://localhost:3000/upload-protected',
31-
resultPath: 'filename',
32-
method: 'POST',
33-
headers: {
34-
Authorization: '{token}',
40+
httpParams: {
41+
createDocument: {
42+
params: {},
43+
url: '',
44+
method: 'GET',
45+
resultPath: '',
46+
headers: {},
47+
},
48+
deleteDocument: {
49+
params: {},
50+
url: '',
51+
method: 'GET',
52+
resultPath: '',
53+
headers: {},
3554
},
3655
},
3756
},
@@ -44,14 +63,15 @@ const schema: Array<IFormElement<any, any>> = [
4463
label: 'Upload on Submit',
4564
placeholder: 'Select File',
4665
uploadOn: 'submit',
47-
uploadSettings: {
48-
url: 'http://localhost:3000/upload',
49-
resultPath: 'filename',
50-
method: 'POST',
51-
},
66+
documentType: 'passport',
67+
documentVariant: 'passport',
5268
template: {
53-
id: 'document-1',
54-
pages: [],
69+
type: 'passport',
70+
category: 'passport',
71+
properties: {},
72+
issuer: { country: 'il' },
73+
issuingVersion: 1,
74+
version: 1,
5575
},
5676
},
5777
},
@@ -63,14 +83,15 @@ const schema: Array<IFormElement<any, any>> = [
6383
label: 'Upload on Submit-2',
6484
placeholder: 'Select File',
6585
uploadOn: 'submit',
66-
uploadSettings: {
67-
url: 'http://localhost:3000/upload',
68-
resultPath: 'filename',
69-
method: 'POST',
70-
},
86+
documentType: 'passport',
87+
documentVariant: 'passport',
7188
template: {
72-
id: 'document-2',
73-
pages: [],
89+
type: 'passport',
90+
category: 'passport',
91+
properties: {},
92+
issuer: { country: 'il' },
93+
issuingVersion: 1,
94+
version: 1,
7495
},
7596
},
7697
},
@@ -79,7 +100,7 @@ const schema: Array<IFormElement<any, any>> = [
79100
element: 'submitbutton',
80101
valueDestination: 'submitbutton',
81102
params: {
82-
label: 'Submit Button',
103+
text: 'Submit Button',
83104
},
84105
},
85106
];

0 commit comments

Comments
 (0)