From d48415475eb02e4592ee86123dada62d96c8e86c Mon Sep 17 00:00:00 2001 From: david0xd Date: Fri, 6 Sep 2024 16:34:47 +0200 Subject: [PATCH] Add small refactoring changes --- .../snaps-sdk/src/jsx/validation.test.tsx | 5 +++ packages/snaps-sdk/src/jsx/validation.ts | 44 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/packages/snaps-sdk/src/jsx/validation.test.tsx b/packages/snaps-sdk/src/jsx/validation.test.tsx index ca8c6ed83d..5b7b538d29 100644 --- a/packages/snaps-sdk/src/jsx/validation.test.tsx +++ b/packages/snaps-sdk/src/jsx/validation.test.tsx @@ -256,6 +256,11 @@ describe('FieldStruct', () => { Hello , + + Hello + + Hello + , diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index 51a6497685..a29941472b 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -285,28 +285,6 @@ export const FileInputStruct: Describe = element( }, ); -export const BoxChildrenStruct = children( - // eslint-disable-next-line @typescript-eslint/no-use-before-define - [lazy(() => BoxChildStruct)], -) as unknown as Struct, null>; - -/** - * A struct for the {@link BoxElement} type. - */ -export const BoxStruct: Describe = element('Box', { - children: BoxChildrenStruct, - direction: optional(nullUnion([literal('horizontal'), literal('vertical')])), - alignment: optional( - nullUnion([ - literal('start'), - literal('center'), - literal('end'), - literal('space-between'), - literal('space-around'), - ]), - ), -}); - /** * A subset of JSX elements that represent the tuple Box + Input of the Field children. */ @@ -449,6 +427,28 @@ export const AddressStruct: Describe = element('Address', { address: nullUnion([HexChecksumAddressStruct, CaipAccountIdStruct]), }); +export const BoxChildrenStruct = children( + // eslint-disable-next-line @typescript-eslint/no-use-before-define + [lazy(() => BoxChildStruct)], +) as unknown as Struct, null>; + +/** + * A struct for the {@link BoxElement} type. + */ +export const BoxStruct: Describe = element('Box', { + children: BoxChildrenStruct, + direction: optional(nullUnion([literal('horizontal'), literal('vertical')])), + alignment: optional( + nullUnion([ + literal('start'), + literal('center'), + literal('end'), + literal('space-between'), + literal('space-around'), + ]), + ), +}); + const FooterButtonStruct = refine(ButtonStruct, 'FooterButton', (value) => { if ( typeof value.props.children === 'string' ||