coderaiser / smalltalk

Promise-based Alert, Confirm and Prompt replacement
MIT License
91 stars 20 forks source link

Multiple input #9

Closed YanDevDe closed 6 years ago

YanDevDe commented 6 years ago

Hey is there any way to add multiple inputs? It would be nice to have this features!

Thanks

coderaiser commented 6 years ago

No, it is not possible. How do you think API could look like?

YanDevDe commented 6 years ago

with array with json value?

smalltalk
    .prompt('MultiQuestion', 'Username and Password?', '10', [
      {
        key: "password",
        type: 'password'
      },
      {
        key: "username",
        type: 'text'
    ]
    )
    .then((value) => {
        //either value is a array or json
        console.log(value.username);
        console.log(value.password);
    .catch(() => {
        console.log('cancel');
    });
coderaiser commented 6 years ago

It is a good idea for a pull request :). I think the title is missing they should also be provided. And would be better if result would be an object.

So input can be:

const input = {
    name: {
       title: 'Name',
       type: 'text'
    },
    password: {
       title: 'Password',
       type: 'password',
    }
};

const output = {
    name: 'hello',
    password: 'world',
};
YanDevDe commented 6 years ago

I've barely time for pull request. :( But okay then! I hope someone could make it. :)

coderaiser commented 6 years ago

Closed due to long time of inactivity