0.2.0 • Published 7 months ago

@fenisoft/fsdialog v0.2.0

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

@fenisoft/fsdialog

npm version

Simple JS library for modal with html5 <dialog> element

Install

npm install @fenisoft/fsdialog

usage as esm module

//  css
//  <link href="dist/fsdialogs.css" rel="stylesheet">

import {fsDialog,fsPrompt} from '@fsdialog/fsdialog';

/* fsDialog */
const buttons = [
    { text: `<b>YES</b>`, value: 'YES', class: "btn btn-success btn-sm" },
    { text: `<b>NO</b>`, value: 'NO', class: "btn btn-dark btn-sm" }
];

const options = {
    headClass: "bg-danger text-white",
    closeButton: true,
}

const response = await fsDialog(buttons, 'Are you sure ?', 'Confirm dialog', options);
// return a Promise
//response  = 'YES' if button 'YES' clicked
//response = 'NO' if button 'NO' clicked

/* fsPrompt */
const value = '';
const response = await fsPrompt(value, 'Insert value:', 'Prompt Dialog', { headClass: 'bg-warning text-white bg-gradient', });
// return a Promise
//response  = {button:'OK', 'value:?'}
if (response.button == 'OK') {
    result.textContent = response.value;
}


// see index.html app.js for examples

usage as global

<head>
    <link href="dist/fsdialogs.css" rel="stylesheet">
</head>
<script src="dist/fsdialog.global.js"></script>

<script>
  const buttons = [
    { text: `<b>YES</b>`, value: 'YES', class: "btn btn-success btn-sm" },
    { text: `<b>NO</b>`, value: 'NO', class: "btn btn-dark btn-sm" }
    ];

    const options = {
        headClass: "bg-danger text-white",
        closeButton: true,
    }

const response = await fsdialog.fsDialog(buttons, 'Are you sure ?', 'Confirm dialog', options);

</script>

OPTIONS

// fsModal options default
 const options  = {
    headClass :  '',  //  type <string>
    closeButton: false, //  <boolean>;
    width: '400px', // 'auto' = autosize type<string>
    container: body // type<HTMLElement>
 }

// fsPrompt options default
const options = {
    inputType: 'text',  // 'number' or 'text' or 'date' 
    headClass: '', // type <string>
    min: '',  // only inputType == 'number'  type <string|number>
    max: '',  // only inputType == 'number'  type <string|number>
    step: '', // only inputType == 'number'  type <string|number>
    buttonOkInnerHTML: 'OK', //type <string>
    buttonCloseInnerHTML: 'CLOSE', //type <string>
    buttonOkClass: 'btn btn-primary btn-sm', //class fron bootstrap  type <string>
    buttonCloseClass: 'btn btn-secondary btn-sm', //class from bootstrap type <string>
    inputClass:'fs-dialog-input', // fs-dialog-input definited in fsdialog.css
    width: '400px', // 'auto' = autosize type<string>
    placeholder: '', // placehiolder input type<string>
    container: body // type<HTMLElement>
};
0.2.0

7 months ago

0.1.9

7 months ago

0.1.8

7 months ago

0.1.7

7 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago