Skip to content

Commit

Permalink
feat: more props for openFieldsDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Jan 18, 2025
1 parent db81f0a commit e5c40be
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const fields = {
},
};

const result = await openFieldsDialog(fields);
const result = await openFieldsDialog({ fields });
console.log(result); // -> { email: "..." }
```

Expand Down
25 changes: 20 additions & 5 deletions src/composables/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,36 @@ export function useDialog() {
* }
* }
*
* const result = await openFieldsDialog(fields)
* const result = await openFieldsDialog({ fields })
* console.log(result) // -> { email: "..." }
* ```
*/
function openFieldsDialog(fields: Record<string, any>) {
function openFieldsDialog(props: {
/** @default "medium" */
size?: string;
submitButton?: string | Record<string, any>;
text?: string;
/**
* Empty state message if no fields are defined
*/
empty?: string;
/**
* An array or object with all available fields
*/
fields?: Record<string, any> | Record<string, any>[];
/**
* An object with all values for the fields
*/
value?: Record<string, any>;
}) {
let result: any;

return new Promise<any>((resolve) => {
const panel = usePanel();

panel.dialog.open({
component: "k-form-dialog",
props: {
fields,
},
props,
on: {
// Close event will always be triggered, even on submit
close: () => {
Expand Down

0 comments on commit e5c40be

Please sign in to comment.