Skip to content

Commit

Permalink
Remove 'layout' key from DataForms
Browse files Browse the repository at this point in the history
  • Loading branch information
louwie17 committed Sep 20, 2024
1 parent aae0488 commit 13f08a1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
20 changes: 9 additions & 11 deletions packages/dataviews/src/components/dataform/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,15 @@ export const CombinedFields = ( { type }: { type: 'panel' | 'regular' } ) => {

const form = {
fields: [ 'title', 'status_and_visibility', 'order', 'author' ],
layout: {
combinedFields: [
{
id: 'status_and_visibility',
label: 'Status & Visibility',
children: [ 'status', 'password' ],
direction: 'vertical',
render: ( { item } ) => item.status,
},
] as CombinedFormField< any >[],
},
combinedFields: [
{
id: 'status_and_visibility',
label: 'Status & Visibility',
children: [ 'status', 'password' ],
direction: 'vertical',
render: ( { item } ) => item.status,
},
] as CombinedFormField< any >[],
};

return (
Expand Down
4 changes: 2 additions & 2 deletions packages/dataviews/src/dataforms-layouts/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ export default function FormPanel< Item >( {
getVisibleFields< Item >(
fields,
form.fields,
form.layout?.combinedFields
form.combinedFields
)
),
[ fields, form.fields, form.layout?.combinedFields ]
[ fields, form.fields, form.combinedFields ]
);

return (
Expand Down
4 changes: 2 additions & 2 deletions packages/dataviews/src/dataforms-layouts/regular/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export default function FormRegular< Item >( {
getVisibleFields< Item >(
fields,
form.fields,
form.layout?.combinedFields
form.combinedFields
)
),
[ fields, form.fields, form.layout?.combinedFields ]
[ fields, form.fields, form.combinedFields ]
);

return (
Expand Down
10 changes: 4 additions & 6 deletions packages/dataviews/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,10 @@ export type NormalizedCombinedFormField< Item > = CombinedFormField< Item > & {
export type Form< Item > = {
type?: 'regular' | 'panel';
fields?: string[];
layout?: {
/**
* The fields to combine.
*/
combinedFields?: CombinedFormField< Item >[];
};
/**
* The fields to combine.
*/
combinedFields?: CombinedFormField< Item >[];
};

export interface DataFormProps< Item > {
Expand Down

0 comments on commit 13f08a1

Please sign in to comment.