Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove spacing from the normalized layouts
  • Loading branch information
oandregal committed Oct 23, 2025
commit 4c50413ceb2cad08901f4009fe90614a1ee4921c
14 changes: 2 additions & 12 deletions packages/dataviews/src/dataform-layouts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ const FORM_FIELD_LAYOUTS = [
{
type: 'regular',
component: FormRegularField,
wrapper: ( {
children,
}: {
children: React.ReactNode;
layout: Layout;
} ) => (
wrapper: ( { children }: { children: React.ReactNode } ) => (
<VStack className="dataforms-layouts__wrapper" spacing={ 4 }>
{ children }
</VStack>
Expand All @@ -42,12 +37,7 @@ const FORM_FIELD_LAYOUTS = [
{
type: 'card',
component: FormCardField,
wrapper: ( {
children,
}: {
children: React.ReactNode;
layout: Layout;
} ) => (
wrapper: ( { children }: { children: React.ReactNode } ) => (
<VStack className="dataforms-layouts__wrapper" spacing={ 6 }>
{ children }
</VStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ interface NormalizedFormField {
export const DEFAULT_LAYOUT: NormalizedLayout = {
type: 'regular',
labelPosition: 'top',
spacing: 4,
} as NormalizedRegularLayout;

const normalizeCardSummaryField = (
Expand Down Expand Up @@ -51,8 +50,6 @@ export function normalizeLayout( layout?: Layout ): NormalizedLayout {
normalizedLayout = {
type: 'regular',
labelPosition: layout?.labelPosition ?? 'top',
// Spacing is fixed for regular layout.
spacing: 4,
} satisfies NormalizedRegularLayout;
} else if ( layout?.type === 'panel' ) {
const summary = layout.summary ?? [];
Expand All @@ -75,8 +72,6 @@ export function normalizeLayout( layout?: Layout ): NormalizedLayout {
withHeader: false,
isOpened: true,
summary: [],
// Spacing is fixed for card layout.
spacing: 6,
} satisfies NormalizedCardLayout;
} else {
const summary = layout.summary ?? [];
Expand All @@ -89,8 +84,6 @@ export function normalizeLayout( layout?: Layout ): NormalizedLayout {
? layout.isOpened
: true,
summary: normalizeCardSummaryField( summary ),
// Spacing is fixed for card layout.
spacing: 6,
} satisfies NormalizedCardLayout;
}
} else if ( layout?.type === 'row' ) {
Expand Down
13 changes: 0 additions & 13 deletions packages/dataviews/src/test/normalize-form-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ describe( 'normalizeFormFields', () => {
layout: {
type: 'regular',
labelPosition: 'top',
spacing: 4,
},
},
{
id: 'field2',
layout: {
type: 'regular',
labelPosition: 'top',
spacing: 4,
},
},
] );
Expand All @@ -62,7 +60,6 @@ describe( 'normalizeFormFields', () => {
layout: {
type: 'regular',
labelPosition: 'top',
spacing: 4,
},
},
{
Expand All @@ -71,7 +68,6 @@ describe( 'normalizeFormFields', () => {
layout: {
type: 'regular',
labelPosition: 'top',
spacing: 4,
},
},
] );
Expand All @@ -91,7 +87,6 @@ describe( 'normalizeFormFields', () => {
layout: {
type: 'regular',
labelPosition: 'top',
spacing: 4,
},
},
] );
Expand All @@ -109,7 +104,6 @@ describe( 'normalizeFormFields', () => {
layout: {
type: 'regular',
labelPosition: 'side',
spacing: 4,
},
},
] );
Expand Down Expand Up @@ -167,7 +161,6 @@ describe( 'normalizeFormFields', () => {
withHeader: true,
isOpened: true,
summary: [],
spacing: 6,
},
},
] );
Expand All @@ -194,7 +187,6 @@ describe( 'normalizeFormFields', () => {
withHeader: false,
isOpened: true,
summary: [],
spacing: 6,
},
},
] );
Expand All @@ -219,7 +211,6 @@ describe( 'normalizeFormFields', () => {
withHeader: true,
isOpened: false,
summary: [ { id: 'field1', visibility: 'always' } ],
spacing: 6,
},
},
] );
Expand Down Expand Up @@ -250,7 +241,6 @@ describe( 'normalizeFormFields', () => {
{ id: 'field2', visibility: 'when-collapsed' },
{ id: 'field1', visibility: 'always' },
],
spacing: 6,
},
},
] );
Expand All @@ -276,7 +266,6 @@ describe( 'normalizeFormFields', () => {
layout: {
type: 'regular',
labelPosition: 'top',
spacing: 4,
},
},
{
Expand Down Expand Up @@ -311,7 +300,6 @@ describe( 'normalizeFormFields', () => {
withHeader: false,
isOpened: true,
summary: [],
spacing: 6,
},
},
{
Expand All @@ -321,7 +309,6 @@ describe( 'normalizeFormFields', () => {
withHeader: true,
isOpened: false,
summary: [],
spacing: 6,
},
},
] );
Expand Down
3 changes: 0 additions & 3 deletions packages/dataviews/src/types/dataform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export type RegularLayout = {
export type NormalizedRegularLayout = {
type: 'regular';
labelPosition: LabelPosition;
spacing: number;
};

export type PanelLayout = {
Expand Down Expand Up @@ -73,14 +72,12 @@ export type NormalizedCardLayout =
isOpened: true;
// Summary is an empty array
summary: [];
spacing: number;
}
| {
type: 'card';
withHeader: true;
isOpened: boolean;
summary: NormalizedCardSummaryField;
spacing: number;
};

export type RowLayout = {
Expand Down
Loading