@inquirer/checkbox
Advanced tools
Comparing version 0.0.10-alpha.0 to 0.0.11-alpha.0
@@ -11,4 +11,4 @@ const checkbox = require('.'); | ||
{ name: 'yarn', value: 'yarn' }, | ||
{ name: 'jspm', value: 'jspm', disabled: true } | ||
] | ||
{ name: 'jspm', value: 'jspm', disabled: true }, | ||
], | ||
}); | ||
@@ -45,6 +45,6 @@ console.log('Answer:', answer); | ||
{ value: 'Y' }, | ||
{ value: 'Z' } | ||
] | ||
{ value: 'Z' }, | ||
], | ||
}); | ||
console.log('Answer:', answer); | ||
})(); |
24
index.js
@@ -9,3 +9,3 @@ const { createPrompt } = require('@inquirer/core'); | ||
module.exports = createPrompt( | ||
readline => ({ | ||
(readline) => ({ | ||
onKeypress: (value, key, { cursorPosition = 0, choices }, setState) => { | ||
@@ -33,16 +33,16 @@ let newCursorPosition = cursorPosition; | ||
return choice; | ||
}) | ||
}), | ||
}); | ||
} else if (key.name === 'a') { | ||
const selectAll = Boolean(choices.find(choice => !choice.checked)); | ||
const selectAll = Boolean(choices.find((choice) => !choice.checked)); | ||
setState({ | ||
choices: choices.map(choice => | ||
choices: choices.map((choice) => | ||
Object.assign({}, choice, { checked: selectAll }) | ||
) | ||
), | ||
}); | ||
} else if (key.name === 'i') { | ||
setState({ | ||
choices: choices.map(choice => | ||
choices: choices.map((choice) => | ||
Object.assign({}, choice, { checked: !choice.checked }) | ||
) | ||
), | ||
}); | ||
@@ -66,3 +66,3 @@ } else if (isNumberKey(key)) { | ||
return choice; | ||
}) | ||
}), | ||
}); | ||
@@ -72,5 +72,5 @@ } | ||
mapStateToValue: ({ choices }) => { | ||
return choices.filter(choice => choice.checked).map(choice => choice.value); | ||
return choices.filter((choice) => choice.checked).map((choice) => choice.value); | ||
}, | ||
paginator: new Paginator(readline) | ||
paginator: new Paginator(readline), | ||
}), | ||
@@ -83,3 +83,3 @@ (state, { paginator }) => { | ||
const selection = choices | ||
.filter(choice => choice.checked) | ||
.filter((choice) => choice.checked) | ||
.map(({ name, value }) => name || value); | ||
@@ -94,3 +94,3 @@ return `${prefix} ${message} ${chalk.cyan(selection.join(', '))}`; | ||
`${chalk.cyan.bold('<a>')} to toggle all`, | ||
`${chalk.cyan.bold('<i>')} to invert selection` | ||
`${chalk.cyan.bold('<i>')} to invert selection`, | ||
]; | ||
@@ -97,0 +97,0 @@ helpTip = ` (Press ${keys.join(', ')})`; |
{ | ||
"name": "@inquirer/checkbox", | ||
"version": "0.0.10-alpha.0", | ||
"version": "0.0.11-alpha.0", | ||
"description": "Inquirer checkbox prompt", | ||
@@ -17,4 +17,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@inquirer/core": "^0.0.10-alpha.0", | ||
"chalk": "^3.0.0", | ||
"@inquirer/core": "^0.0.11-alpha.0", | ||
"chalk": "^4.1.0", | ||
"figures": "^3.0.0" | ||
@@ -25,3 +25,3 @@ }, | ||
}, | ||
"gitHead": "7a699cc7566b4b6bc9a1e8d93490d3f5a01685ef" | ||
"gitHead": "434228aba4908e22063eef37869a427bb605337b" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6427
+ Added@inquirer/core@0.0.11-alpha.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcli-width@3.0.0(transitive)
- Removed@inquirer/core@0.0.10-alpha.0(transitive)
- Removedchalk@3.0.0(transitive)
- Removedcli-width@2.2.1(transitive)
Updatedchalk@^4.1.0