1.1.5 • Published 7 months ago

@appinsource/material v1.1.5

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

React Dynamic Dialog View

Component extended @mui/dialog, dynamic dialog view controller.

Installation

  npm install @appinsource/material/dynamic-dialog

New Features

  Until version 1.0.14 content prop was setContent(<component>Content</component>), from version 1.1.1 content setContent( dialog => <component>Content</component>)

Features

  • High-performance
  • Lazy-load with a custom function
  • Ready to use

API Reference

  AISDialogActionViewController
PropertyTypeDescription
setLabelcompoent or stringRequired. Button label
setVariantButtonVariantType"contained","outlined","text"
setColorActionColorTypes"inherit", "action", "disabled", "primary", "secondary", "error", "info", "success", "warning"
setActionFunction"Callback Function returned ( button, dialog ):void "
setDisabledboolean"Disable/enable button"
setInProcessboolean"Show/hide button spinner"
removevoid"Remove button"

Get item

  AISDialogViewController
ParameterTypeDescription
setTitlecompoent or stringdialog title
setSubTitlecompoent or string"dialog subtitle"
setContentCallback Function"Return component or string setContent( dialog => { return Content})"
setActiondialogActionView"Instance of AISDialogActionViewController"
setActionsArray<dialogActionView>"Collection items instance of AISDialogActionViewController"
setDraggableboolean"Drag enable/disable"
setMaxWidthDialogMaxSizeType"xs", "sm", "md", "lg", "xl"
setStatecompoent state"dialog.setState({...dialog.state, newKey: newValue})"
showvoid"Show dialog"

Acknowledgements

Development

Create react app

  npm install @appinsource/material/dynamic-dialog

License

MIT

Authors

Süleyman Topaloglu Frontend/Backend developer since 2013

Usage/Examples

  • You have a complete working Demo
    import React from 'react';
    import logo from './logo.svg';
    import './App.css';
    import Button from "@mui/material/Button";
    import AISDialogViewController, { dialogActionView } from "@appinsource/material/dynamic-dialog";

    function App() {

        const handleClick = () => {

            const closeAction = new dialogActionView()
                    .setLabel('Close')
                    .setAction((button, dialog1) => {
                        // Example useState
                        // console.log('Added key in state', dialog1.state.newKey );
                        dialog1.close();
                    });

                const updateAction = new dialogActionView()
                    .setLabel('Update me')
                    .setVariant('contained')
                    .setColor('warning')
                    .setAction( (button, dialog) => {
                        dialog.setContent('Content updated and closing in 3 sec');
                        button.setInProcess(true).setDisabled( true ).setColor('success');
                        setTimeout(()=>{
                            dialog.setContent('Success');

                            button
                                .setLabel('Ok!')
                                .setDisabled(false)
                                .setInProcess(false)
                                .setVariant('text');

                            closeAction.remove();

                            button.setAction( ((button1, dialog1) => {
                                dialog1
                                    .setContent('Button Action changed another trigged will closing in 5 sec.');
                                button1.setLabel('Inline Clicked').setDisabled(true);
                                setTimeout(()=>{
                                    dialog1.setContent('Dialog closing in 3 sec');
                                    button1.setColor('warning').setDisabled(false);
                                    setTimeout(()=>{
                                        dialog1.close();
                                    }, 3000)
                                }, 5000)
                            }))
                        }, 3000 );
                    });

                const dialog = new AISDialogViewController();
                dialog
                    .setTitle('I\'m a dynamic dialog view')
                    .setDraggable(true)
                    .setContent( dialog1 => <div>Content</div> )
                    .setAction( closeAction )
                    .setAction( updateAction )
                    // Or 
                    // .setActions([ closeAction, updateAction ])
                    .setMaxWidth('md')
                    .show( dialog1 => {
                    // Example useState
                    // dialog1.setState({...dialog1.state, newKey: 'newValue'})
                    });


        }

        return (
            <div className="App">
                <Button variant={'contained'} onClick={handleClick}>
                    Open dynamic dialog
                </Button>
            </div>
        );
    }
    
    export default App;
1.1.5

7 months ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago