React Dialog component
npm install @hauke5/dialognpx to run an example of the dialog component in a NextJS app:
$ npx hauke5/dialogexample
`
This will start a next development server.
Point a browser to http://localhost:3001/dialog to run the app.
Or 2) use
git clone to install the component along with a usage example app in NextJS:
`
$ git clone https://github.com/Hauke5/DialogExample.git
`
This will install the required typescript components and support libraries, along with the usage example in app/dialog/DialogExample.tsx
To run the example manually, follow the git clone command with:
`
cd DialogExample # change into the newly created folder
npm i # install dependencies
npm run dev # run the development server
`
Again, point a browser to http://localhost:3001/dialog to run the app.Usage
$3
A dialog is defined by the DialogConfig structure, consisting of
- a leading title to explain the purpose of the dialog to the user
- an optional description, accepting a ReactNode
- an optional list of dialog items, each consisting of a DialogItemConfig structure
- and a list of buttons to perform actions.If not provided by the
DialogConfig, A Cancel button will be automatically added by the component.A simplest version of a dialog configuration might look like this:
`typescript
{
title: 'Simple Dialog Example:',
buttons:[
{ id:'OK'},
]
}
`

The
ids for items and buttons are by default used as their labels. Alternatively, an optional label field can be specified:
`typescript
{
title: 'Example:',
items:[
{ id:'ValidItem', type:'number', initial: 0, label:'Enter Valid Number'}},
],
buttons:[
{ id:'OkButton', label:'OK'}},
]
}
`
Integrating Dialogs into Components
Add a