Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
22
node_modules/@inquirer/checkbox/LICENSE
generated
vendored
Normal file
22
node_modules/@inquirer/checkbox/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
Copyright (c) 2023 Simon Boudrias
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
160
node_modules/@inquirer/checkbox/README.md
generated
vendored
Normal file
160
node_modules/@inquirer/checkbox/README.md
generated
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
# `@inquirer/checkbox`
|
||||
|
||||
Simple interactive command line prompt to display a list of checkboxes (multi select).
|
||||
|
||||

|
||||
|
||||
# Installation
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>npm</th>
|
||||
<th>yarn</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
```sh
|
||||
npm install @inquirer/prompts
|
||||
```
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
```sh
|
||||
yarn add @inquirer/prompts
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colSpan="2" align="center">Or</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
```sh
|
||||
npm install @inquirer/checkbox
|
||||
```
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
```sh
|
||||
yarn add @inquirer/checkbox
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
# Usage
|
||||
|
||||
```js
|
||||
import { checkbox, Separator } from '@inquirer/prompts';
|
||||
// Or
|
||||
// import checkbox, { Separator } from '@inquirer/checkbox';
|
||||
|
||||
const answer = await checkbox({
|
||||
message: 'Select a package manager',
|
||||
choices: [
|
||||
{ name: 'npm', value: 'npm' },
|
||||
{ name: 'yarn', value: 'yarn' },
|
||||
new Separator(),
|
||||
{ name: 'pnpm', value: 'pnpm', disabled: true },
|
||||
{
|
||||
name: 'pnpm',
|
||||
value: 'pnpm',
|
||||
disabled: '(pnpm is not available)',
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
| Property | Type | Required | Description |
|
||||
| -------- | --------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| message | `string` | yes | The question to ask |
|
||||
| choices | `Choice[]` | yes | List of the available choices. |
|
||||
| pageSize | `number` | no | By default, lists of choice longer than 7 will be paginated. Use this option to control how many choices will appear on the screen at once. |
|
||||
| loop | `boolean` | no | Defaults to `true`. When set to `false`, the cursor will be constrained to the top and bottom of the choice list without looping. |
|
||||
| required | `boolean` | no | When set to `true`, ensures at least one choice must be selected. |
|
||||
| validate | `async (Choice[]) => boolean \| string` | no | On submit, validate the choices. When returning a string, it'll be used as the error message displayed to the user. Note: returning a rejected promise, we'll assume a code error happened and crash. |
|
||||
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |
|
||||
|
||||
`Separator` objects can be used in the `choices` array to render non-selectable lines in the choice list. By default it'll render a line, but you can provide the text as argument (`new Separator('-- Dependencies --')`). This option is often used to add labels to groups within long list of options.
|
||||
|
||||
### `Choice` object
|
||||
|
||||
The `Choice` object is typed as
|
||||
|
||||
```ts
|
||||
type Choice<Value> = {
|
||||
value: Value;
|
||||
name?: string;
|
||||
description?: string;
|
||||
short?: string;
|
||||
checked?: boolean;
|
||||
disabled?: boolean | string;
|
||||
};
|
||||
```
|
||||
|
||||
Here's each property:
|
||||
|
||||
- `value`: The value is what will be returned by `await checkbox()`.
|
||||
- `name`: This is the string displayed in the choice list.
|
||||
- `description`: Option for a longer description string that'll appear under the list when the cursor highlight a given choice.
|
||||
- `short`: Once the prompt is done (press enter), we'll use `short` if defined to render next to the question. By default we'll use `name`.
|
||||
- `checked`: If `true`, the option will be checked by default.
|
||||
- `disabled`: Disallow the option from being selected. If `disabled` is a string, it'll be used as a help tip explaining why the choice isn't available.
|
||||
|
||||
Also note the `choices` array can contain `Separator`s to help organize long lists.
|
||||
|
||||
`choices` can also be an array of string, in which case the string will be used both as the `value` and the `name`.
|
||||
|
||||
## Theming
|
||||
|
||||
You can theme a prompt by passing a `theme` object option. The theme object only need to includes the keys you wish to modify, we'll fallback on the defaults for the rest.
|
||||
|
||||
```ts
|
||||
type Theme = {
|
||||
prefix: string;
|
||||
spinner: {
|
||||
interval: number;
|
||||
frames: string[];
|
||||
};
|
||||
style: {
|
||||
answer: (text: string) => string;
|
||||
message: (text: string) => string;
|
||||
error: (text: string) => string;
|
||||
defaultAnswer: (text: string) => string;
|
||||
help: (text: string) => string;
|
||||
highlight: (text: string) => string;
|
||||
key: (text: string) => string;
|
||||
disabledChoice: (text: string) => string;
|
||||
description: (text: string) => string;
|
||||
renderSelectedChoices: <T>(
|
||||
selectedChoices: ReadonlyArray<Choice<T>>,
|
||||
allChoices: ReadonlyArray<Choice<T> | Separator>,
|
||||
) => string;
|
||||
};
|
||||
icon: {
|
||||
checked: string;
|
||||
unchecked: string;
|
||||
cursor: string;
|
||||
};
|
||||
helpMode: 'always' | 'never' | 'auto';
|
||||
};
|
||||
```
|
||||
|
||||
### `theme.helpMode`
|
||||
|
||||
- `auto` (default): Hide the help tips after an interaction occurs. The scroll tip will hide after any interactions, the selection tip will hide as soon as a first selection is done.
|
||||
- `always`: The help tips will always show and never hide.
|
||||
- `never`: The help tips will never show.
|
||||
|
||||
# License
|
||||
|
||||
Copyright (c) 2023 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))<br/>
|
||||
Licensed under the MIT license.
|
203
node_modules/@inquirer/checkbox/dist/cjs/index.js
generated
vendored
Normal file
203
node_modules/@inquirer/checkbox/dist/cjs/index.js
generated
vendored
Normal file
|
@ -0,0 +1,203 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Separator = void 0;
|
||||
const core_1 = require("@inquirer/core");
|
||||
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
||||
const figures_1 = __importDefault(require("@inquirer/figures"));
|
||||
const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
|
||||
const checkboxTheme = {
|
||||
icon: {
|
||||
checked: yoctocolors_cjs_1.default.green(figures_1.default.circleFilled),
|
||||
unchecked: figures_1.default.circle,
|
||||
cursor: figures_1.default.pointer,
|
||||
},
|
||||
style: {
|
||||
disabledChoice: (text) => yoctocolors_cjs_1.default.dim(`- ${text}`),
|
||||
renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(', '),
|
||||
description: (text) => yoctocolors_cjs_1.default.cyan(text),
|
||||
},
|
||||
helpMode: 'auto',
|
||||
};
|
||||
function isSelectable(item) {
|
||||
return !core_1.Separator.isSeparator(item) && !item.disabled;
|
||||
}
|
||||
function isChecked(item) {
|
||||
return isSelectable(item) && Boolean(item.checked);
|
||||
}
|
||||
function toggle(item) {
|
||||
return isSelectable(item) ? Object.assign(Object.assign({}, item), { checked: !item.checked }) : item;
|
||||
}
|
||||
function check(checked) {
|
||||
return function (item) {
|
||||
return isSelectable(item) ? Object.assign(Object.assign({}, item), { checked }) : item;
|
||||
};
|
||||
}
|
||||
function normalizeChoices(choices) {
|
||||
return choices.map((choice) => {
|
||||
var _a, _b, _c, _d;
|
||||
if (core_1.Separator.isSeparator(choice))
|
||||
return choice;
|
||||
if (typeof choice === 'string') {
|
||||
return {
|
||||
value: choice,
|
||||
name: choice,
|
||||
short: choice,
|
||||
disabled: false,
|
||||
checked: false,
|
||||
};
|
||||
}
|
||||
const name = (_a = choice.name) !== null && _a !== void 0 ? _a : String(choice.value);
|
||||
return {
|
||||
value: choice.value,
|
||||
name,
|
||||
short: (_b = choice.short) !== null && _b !== void 0 ? _b : name,
|
||||
description: choice.description,
|
||||
disabled: (_c = choice.disabled) !== null && _c !== void 0 ? _c : false,
|
||||
checked: (_d = choice.checked) !== null && _d !== void 0 ? _d : false,
|
||||
};
|
||||
});
|
||||
}
|
||||
exports.default = (0, core_1.createPrompt)((config, done) => {
|
||||
const { instructions, pageSize = 7, loop = true, required, validate = () => true, } = config;
|
||||
const theme = (0, core_1.makeTheme)(checkboxTheme, config.theme);
|
||||
const prefix = (0, core_1.usePrefix)({ theme });
|
||||
const firstRender = (0, core_1.useRef)(true);
|
||||
const [status, setStatus] = (0, core_1.useState)('pending');
|
||||
const [items, setItems] = (0, core_1.useState)(normalizeChoices(config.choices));
|
||||
const bounds = (0, core_1.useMemo)(() => {
|
||||
const first = items.findIndex(isSelectable);
|
||||
const last = items.findLastIndex(isSelectable);
|
||||
if (first < 0) {
|
||||
throw new core_1.ValidationError('[checkbox prompt] No selectable choices. All choices are disabled.');
|
||||
}
|
||||
return { first, last };
|
||||
}, [items]);
|
||||
const [active, setActive] = (0, core_1.useState)(bounds.first);
|
||||
const [showHelpTip, setShowHelpTip] = (0, core_1.useState)(true);
|
||||
const [errorMsg, setError] = (0, core_1.useState)();
|
||||
(0, core_1.useKeypress)((key) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
if ((0, core_1.isEnterKey)(key)) {
|
||||
const selection = items.filter(isChecked);
|
||||
const isValid = yield validate([...selection]);
|
||||
if (required && !items.some(isChecked)) {
|
||||
setError('At least one choice must be selected');
|
||||
}
|
||||
else if (isValid === true) {
|
||||
setStatus('done');
|
||||
done(selection.map((choice) => choice.value));
|
||||
}
|
||||
else {
|
||||
setError(isValid || 'You must select a valid value');
|
||||
}
|
||||
}
|
||||
else if ((0, core_1.isUpKey)(key) || (0, core_1.isDownKey)(key)) {
|
||||
if (loop ||
|
||||
((0, core_1.isUpKey)(key) && active !== bounds.first) ||
|
||||
((0, core_1.isDownKey)(key) && active !== bounds.last)) {
|
||||
const offset = (0, core_1.isUpKey)(key) ? -1 : 1;
|
||||
let next = active;
|
||||
do {
|
||||
next = (next + offset + items.length) % items.length;
|
||||
} while (!isSelectable(items[next]));
|
||||
setActive(next);
|
||||
}
|
||||
}
|
||||
else if ((0, core_1.isSpaceKey)(key)) {
|
||||
setError(undefined);
|
||||
setShowHelpTip(false);
|
||||
setItems(items.map((choice, i) => (i === active ? toggle(choice) : choice)));
|
||||
}
|
||||
else if (key.name === 'a') {
|
||||
const selectAll = items.some((choice) => isSelectable(choice) && !choice.checked);
|
||||
setItems(items.map(check(selectAll)));
|
||||
}
|
||||
else if (key.name === 'i') {
|
||||
setItems(items.map(toggle));
|
||||
}
|
||||
else if ((0, core_1.isNumberKey)(key)) {
|
||||
// Adjust index to start at 1
|
||||
const position = Number(key.name) - 1;
|
||||
const item = items[position];
|
||||
if (item != null && isSelectable(item)) {
|
||||
setActive(position);
|
||||
setItems(items.map((choice, i) => (i === position ? toggle(choice) : choice)));
|
||||
}
|
||||
}
|
||||
}));
|
||||
const message = theme.style.message(config.message);
|
||||
let description;
|
||||
const page = (0, core_1.usePagination)({
|
||||
items,
|
||||
active,
|
||||
renderItem({ item, isActive }) {
|
||||
if (core_1.Separator.isSeparator(item)) {
|
||||
return ` ${item.separator}`;
|
||||
}
|
||||
if (item.disabled) {
|
||||
const disabledLabel = typeof item.disabled === 'string' ? item.disabled : '(disabled)';
|
||||
return theme.style.disabledChoice(`${item.name} ${disabledLabel}`);
|
||||
}
|
||||
if (isActive) {
|
||||
description = item.description;
|
||||
}
|
||||
const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
|
||||
const color = isActive ? theme.style.highlight : (x) => x;
|
||||
const cursor = isActive ? theme.icon.cursor : ' ';
|
||||
return color(`${cursor}${checkbox} ${item.name}`);
|
||||
},
|
||||
pageSize,
|
||||
loop,
|
||||
});
|
||||
if (status === 'done') {
|
||||
const selection = items.filter(isChecked);
|
||||
const answer = theme.style.answer(theme.style.renderSelectedChoices(selection, items));
|
||||
return `${prefix} ${message} ${answer}`;
|
||||
}
|
||||
let helpTipTop = '';
|
||||
let helpTipBottom = '';
|
||||
if (theme.helpMode === 'always' ||
|
||||
(theme.helpMode === 'auto' &&
|
||||
showHelpTip &&
|
||||
(instructions === undefined || instructions))) {
|
||||
if (typeof instructions === 'string') {
|
||||
helpTipTop = instructions;
|
||||
}
|
||||
else {
|
||||
const keys = [
|
||||
`${theme.style.key('space')} to select`,
|
||||
`${theme.style.key('a')} to toggle all`,
|
||||
`${theme.style.key('i')} to invert selection`,
|
||||
`and ${theme.style.key('enter')} to proceed`,
|
||||
];
|
||||
helpTipTop = ` (Press ${keys.join(', ')})`;
|
||||
}
|
||||
if (items.length > pageSize &&
|
||||
(theme.helpMode === 'always' ||
|
||||
(theme.helpMode === 'auto' && firstRender.current))) {
|
||||
helpTipBottom = `\n${theme.style.help('(Use arrow keys to reveal more choices)')}`;
|
||||
firstRender.current = false;
|
||||
}
|
||||
}
|
||||
const choiceDescription = description
|
||||
? `\n${theme.style.description(description)}`
|
||||
: ``;
|
||||
let error = '';
|
||||
if (errorMsg) {
|
||||
error = `\n${theme.style.error(errorMsg)}`;
|
||||
}
|
||||
return `${prefix} ${message}${helpTipTop}\n${page}${helpTipBottom}${choiceDescription}${error}${ansi_escapes_1.default.cursorHide}`;
|
||||
});
|
||||
var core_2 = require("@inquirer/core");
|
||||
Object.defineProperty(exports, "Separator", { enumerable: true, get: function () { return core_2.Separator; } });
|
45
node_modules/@inquirer/checkbox/dist/cjs/types/index.d.ts
generated
vendored
Normal file
45
node_modules/@inquirer/checkbox/dist/cjs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { Separator, type Theme } from '@inquirer/core';
|
||||
import type { PartialDeep } from '@inquirer/type';
|
||||
type CheckboxTheme = {
|
||||
icon: {
|
||||
checked: string;
|
||||
unchecked: string;
|
||||
cursor: string;
|
||||
};
|
||||
style: {
|
||||
disabledChoice: (text: string) => string;
|
||||
renderSelectedChoices: <T>(selectedChoices: ReadonlyArray<NormalizedChoice<T>>, allChoices: ReadonlyArray<NormalizedChoice<T> | Separator>) => string;
|
||||
description: (text: string) => string;
|
||||
};
|
||||
helpMode: 'always' | 'never' | 'auto';
|
||||
};
|
||||
type Choice<Value> = {
|
||||
value: Value;
|
||||
name?: string;
|
||||
description?: string;
|
||||
short?: string;
|
||||
disabled?: boolean | string;
|
||||
checked?: boolean;
|
||||
type?: never;
|
||||
};
|
||||
type NormalizedChoice<Value> = {
|
||||
value: Value;
|
||||
name: string;
|
||||
description?: string;
|
||||
short: string;
|
||||
disabled: boolean | string;
|
||||
checked: boolean;
|
||||
};
|
||||
declare const _default: <Value>(config: {
|
||||
message: string;
|
||||
prefix?: string | undefined;
|
||||
pageSize?: number | undefined;
|
||||
instructions?: (string | boolean) | undefined;
|
||||
choices: readonly (string | Separator)[] | readonly (Separator | Choice<Value>)[];
|
||||
loop?: boolean | undefined;
|
||||
required?: boolean | undefined;
|
||||
validate?: ((choices: readonly Choice<Value>[]) => boolean | string | Promise<string | boolean>) | undefined;
|
||||
theme?: PartialDeep<Theme<CheckboxTheme>> | undefined;
|
||||
}, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value[]>;
|
||||
export default _default;
|
||||
export { Separator } from '@inquirer/core';
|
186
node_modules/@inquirer/checkbox/dist/esm/index.mjs
generated
vendored
Normal file
186
node_modules/@inquirer/checkbox/dist/esm/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,186 @@
|
|||
import { createPrompt, useState, useKeypress, usePrefix, usePagination, useRef, useMemo, makeTheme, isUpKey, isDownKey, isSpaceKey, isNumberKey, isEnterKey, ValidationError, Separator, } from '@inquirer/core';
|
||||
import colors from 'yoctocolors-cjs';
|
||||
import figures from '@inquirer/figures';
|
||||
import ansiEscapes from 'ansi-escapes';
|
||||
const checkboxTheme = {
|
||||
icon: {
|
||||
checked: colors.green(figures.circleFilled),
|
||||
unchecked: figures.circle,
|
||||
cursor: figures.pointer,
|
||||
},
|
||||
style: {
|
||||
disabledChoice: (text) => colors.dim(`- ${text}`),
|
||||
renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(', '),
|
||||
description: (text) => colors.cyan(text),
|
||||
},
|
||||
helpMode: 'auto',
|
||||
};
|
||||
function isSelectable(item) {
|
||||
return !Separator.isSeparator(item) && !item.disabled;
|
||||
}
|
||||
function isChecked(item) {
|
||||
return isSelectable(item) && Boolean(item.checked);
|
||||
}
|
||||
function toggle(item) {
|
||||
return isSelectable(item) ? { ...item, checked: !item.checked } : item;
|
||||
}
|
||||
function check(checked) {
|
||||
return function (item) {
|
||||
return isSelectable(item) ? { ...item, checked } : item;
|
||||
};
|
||||
}
|
||||
function normalizeChoices(choices) {
|
||||
return choices.map((choice) => {
|
||||
if (Separator.isSeparator(choice))
|
||||
return choice;
|
||||
if (typeof choice === 'string') {
|
||||
return {
|
||||
value: choice,
|
||||
name: choice,
|
||||
short: choice,
|
||||
disabled: false,
|
||||
checked: false,
|
||||
};
|
||||
}
|
||||
const name = choice.name ?? String(choice.value);
|
||||
return {
|
||||
value: choice.value,
|
||||
name,
|
||||
short: choice.short ?? name,
|
||||
description: choice.description,
|
||||
disabled: choice.disabled ?? false,
|
||||
checked: choice.checked ?? false,
|
||||
};
|
||||
});
|
||||
}
|
||||
export default createPrompt((config, done) => {
|
||||
const { instructions, pageSize = 7, loop = true, required, validate = () => true, } = config;
|
||||
const theme = makeTheme(checkboxTheme, config.theme);
|
||||
const prefix = usePrefix({ theme });
|
||||
const firstRender = useRef(true);
|
||||
const [status, setStatus] = useState('pending');
|
||||
const [items, setItems] = useState(normalizeChoices(config.choices));
|
||||
const bounds = useMemo(() => {
|
||||
const first = items.findIndex(isSelectable);
|
||||
const last = items.findLastIndex(isSelectable);
|
||||
if (first < 0) {
|
||||
throw new ValidationError('[checkbox prompt] No selectable choices. All choices are disabled.');
|
||||
}
|
||||
return { first, last };
|
||||
}, [items]);
|
||||
const [active, setActive] = useState(bounds.first);
|
||||
const [showHelpTip, setShowHelpTip] = useState(true);
|
||||
const [errorMsg, setError] = useState();
|
||||
useKeypress(async (key) => {
|
||||
if (isEnterKey(key)) {
|
||||
const selection = items.filter(isChecked);
|
||||
const isValid = await validate([...selection]);
|
||||
if (required && !items.some(isChecked)) {
|
||||
setError('At least one choice must be selected');
|
||||
}
|
||||
else if (isValid === true) {
|
||||
setStatus('done');
|
||||
done(selection.map((choice) => choice.value));
|
||||
}
|
||||
else {
|
||||
setError(isValid || 'You must select a valid value');
|
||||
}
|
||||
}
|
||||
else if (isUpKey(key) || isDownKey(key)) {
|
||||
if (loop ||
|
||||
(isUpKey(key) && active !== bounds.first) ||
|
||||
(isDownKey(key) && active !== bounds.last)) {
|
||||
const offset = isUpKey(key) ? -1 : 1;
|
||||
let next = active;
|
||||
do {
|
||||
next = (next + offset + items.length) % items.length;
|
||||
} while (!isSelectable(items[next]));
|
||||
setActive(next);
|
||||
}
|
||||
}
|
||||
else if (isSpaceKey(key)) {
|
||||
setError(undefined);
|
||||
setShowHelpTip(false);
|
||||
setItems(items.map((choice, i) => (i === active ? toggle(choice) : choice)));
|
||||
}
|
||||
else if (key.name === 'a') {
|
||||
const selectAll = items.some((choice) => isSelectable(choice) && !choice.checked);
|
||||
setItems(items.map(check(selectAll)));
|
||||
}
|
||||
else if (key.name === 'i') {
|
||||
setItems(items.map(toggle));
|
||||
}
|
||||
else if (isNumberKey(key)) {
|
||||
// Adjust index to start at 1
|
||||
const position = Number(key.name) - 1;
|
||||
const item = items[position];
|
||||
if (item != null && isSelectable(item)) {
|
||||
setActive(position);
|
||||
setItems(items.map((choice, i) => (i === position ? toggle(choice) : choice)));
|
||||
}
|
||||
}
|
||||
});
|
||||
const message = theme.style.message(config.message);
|
||||
let description;
|
||||
const page = usePagination({
|
||||
items,
|
||||
active,
|
||||
renderItem({ item, isActive }) {
|
||||
if (Separator.isSeparator(item)) {
|
||||
return ` ${item.separator}`;
|
||||
}
|
||||
if (item.disabled) {
|
||||
const disabledLabel = typeof item.disabled === 'string' ? item.disabled : '(disabled)';
|
||||
return theme.style.disabledChoice(`${item.name} ${disabledLabel}`);
|
||||
}
|
||||
if (isActive) {
|
||||
description = item.description;
|
||||
}
|
||||
const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
|
||||
const color = isActive ? theme.style.highlight : (x) => x;
|
||||
const cursor = isActive ? theme.icon.cursor : ' ';
|
||||
return color(`${cursor}${checkbox} ${item.name}`);
|
||||
},
|
||||
pageSize,
|
||||
loop,
|
||||
});
|
||||
if (status === 'done') {
|
||||
const selection = items.filter(isChecked);
|
||||
const answer = theme.style.answer(theme.style.renderSelectedChoices(selection, items));
|
||||
return `${prefix} ${message} ${answer}`;
|
||||
}
|
||||
let helpTipTop = '';
|
||||
let helpTipBottom = '';
|
||||
if (theme.helpMode === 'always' ||
|
||||
(theme.helpMode === 'auto' &&
|
||||
showHelpTip &&
|
||||
(instructions === undefined || instructions))) {
|
||||
if (typeof instructions === 'string') {
|
||||
helpTipTop = instructions;
|
||||
}
|
||||
else {
|
||||
const keys = [
|
||||
`${theme.style.key('space')} to select`,
|
||||
`${theme.style.key('a')} to toggle all`,
|
||||
`${theme.style.key('i')} to invert selection`,
|
||||
`and ${theme.style.key('enter')} to proceed`,
|
||||
];
|
||||
helpTipTop = ` (Press ${keys.join(', ')})`;
|
||||
}
|
||||
if (items.length > pageSize &&
|
||||
(theme.helpMode === 'always' ||
|
||||
(theme.helpMode === 'auto' && firstRender.current))) {
|
||||
helpTipBottom = `\n${theme.style.help('(Use arrow keys to reveal more choices)')}`;
|
||||
firstRender.current = false;
|
||||
}
|
||||
}
|
||||
const choiceDescription = description
|
||||
? `\n${theme.style.description(description)}`
|
||||
: ``;
|
||||
let error = '';
|
||||
if (errorMsg) {
|
||||
error = `\n${theme.style.error(errorMsg)}`;
|
||||
}
|
||||
return `${prefix} ${message}${helpTipTop}\n${page}${helpTipBottom}${choiceDescription}${error}${ansiEscapes.cursorHide}`;
|
||||
});
|
||||
export { Separator } from '@inquirer/core';
|
45
node_modules/@inquirer/checkbox/dist/esm/types/index.d.mts
generated
vendored
Normal file
45
node_modules/@inquirer/checkbox/dist/esm/types/index.d.mts
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { Separator, type Theme } from '@inquirer/core';
|
||||
import type { PartialDeep } from '@inquirer/type';
|
||||
type CheckboxTheme = {
|
||||
icon: {
|
||||
checked: string;
|
||||
unchecked: string;
|
||||
cursor: string;
|
||||
};
|
||||
style: {
|
||||
disabledChoice: (text: string) => string;
|
||||
renderSelectedChoices: <T>(selectedChoices: ReadonlyArray<NormalizedChoice<T>>, allChoices: ReadonlyArray<NormalizedChoice<T> | Separator>) => string;
|
||||
description: (text: string) => string;
|
||||
};
|
||||
helpMode: 'always' | 'never' | 'auto';
|
||||
};
|
||||
type Choice<Value> = {
|
||||
value: Value;
|
||||
name?: string;
|
||||
description?: string;
|
||||
short?: string;
|
||||
disabled?: boolean | string;
|
||||
checked?: boolean;
|
||||
type?: never;
|
||||
};
|
||||
type NormalizedChoice<Value> = {
|
||||
value: Value;
|
||||
name: string;
|
||||
description?: string;
|
||||
short: string;
|
||||
disabled: boolean | string;
|
||||
checked: boolean;
|
||||
};
|
||||
declare const _default: <Value>(config: {
|
||||
message: string;
|
||||
prefix?: string | undefined;
|
||||
pageSize?: number | undefined;
|
||||
instructions?: (string | boolean) | undefined;
|
||||
choices: readonly (string | Separator)[] | readonly (Separator | Choice<Value>)[];
|
||||
loop?: boolean | undefined;
|
||||
required?: boolean | undefined;
|
||||
validate?: ((choices: readonly Choice<Value>[]) => boolean | string | Promise<string | boolean>) | undefined;
|
||||
theme?: PartialDeep<Theme<CheckboxTheme>> | undefined;
|
||||
}, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value[]>;
|
||||
export default _default;
|
||||
export { Separator } from '@inquirer/core';
|
35
node_modules/@inquirer/checkbox/dist/types/index.d.ts
generated
vendored
Normal file
35
node_modules/@inquirer/checkbox/dist/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { Separator, type Theme } from '@inquirer/core';
|
||||
import type { PartialDeep } from '@inquirer/type';
|
||||
type CheckboxTheme = {
|
||||
icon: {
|
||||
checked: string;
|
||||
unchecked: string;
|
||||
cursor: string;
|
||||
};
|
||||
style: {
|
||||
disabledChoice: (text: string) => string;
|
||||
renderSelectedChoices: <T>(selectedChoices: ReadonlyArray<Choice<T>>, allChoices: ReadonlyArray<Choice<T> | Separator>) => string;
|
||||
};
|
||||
helpMode: 'always' | 'never' | 'auto';
|
||||
};
|
||||
type Choice<Value> = {
|
||||
name?: string;
|
||||
value: Value;
|
||||
disabled?: boolean | string;
|
||||
checked?: boolean;
|
||||
type?: never;
|
||||
};
|
||||
type Item<Value> = Separator | Choice<Value>;
|
||||
declare const _default: <Value>(config: {
|
||||
message: string;
|
||||
prefix?: string;
|
||||
pageSize?: number;
|
||||
instructions?: string | boolean;
|
||||
choices: readonly (Separator | Choice<Value>)[];
|
||||
loop?: boolean;
|
||||
required?: boolean;
|
||||
validate?: ((items: readonly Item<Value>[]) => boolean | string | Promise<string | boolean>) | undefined;
|
||||
theme?: PartialDeep<Theme<CheckboxTheme>>;
|
||||
}, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value[]>;
|
||||
export default _default;
|
||||
export { Separator } from '@inquirer/core';
|
92
node_modules/@inquirer/checkbox/package.json
generated
vendored
Normal file
92
node_modules/@inquirer/checkbox/package.json
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
{
|
||||
"name": "@inquirer/checkbox",
|
||||
"version": "2.5.0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"description": "Inquirer checkbox prompt",
|
||||
"main": "./dist/cjs/index.js",
|
||||
"typings": "./dist/cjs/types/index.d.ts",
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/SBoudrias/Inquirer.js.git"
|
||||
},
|
||||
"keywords": [
|
||||
"answer",
|
||||
"answers",
|
||||
"ask",
|
||||
"base",
|
||||
"cli",
|
||||
"command",
|
||||
"command-line",
|
||||
"confirm",
|
||||
"enquirer",
|
||||
"generate",
|
||||
"generator",
|
||||
"hyper",
|
||||
"input",
|
||||
"inquire",
|
||||
"inquirer",
|
||||
"interface",
|
||||
"iterm",
|
||||
"javascript",
|
||||
"menu",
|
||||
"node",
|
||||
"nodejs",
|
||||
"prompt",
|
||||
"promptly",
|
||||
"prompts",
|
||||
"question",
|
||||
"readline",
|
||||
"scaffold",
|
||||
"scaffolder",
|
||||
"scaffolding",
|
||||
"stdin",
|
||||
"stdout",
|
||||
"terminal",
|
||||
"tty",
|
||||
"ui",
|
||||
"yeoman",
|
||||
"yo",
|
||||
"zsh"
|
||||
],
|
||||
"author": "Simon Boudrias <admin@simonboudrias.com>",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/checkbox/README.md",
|
||||
"dependencies": {
|
||||
"@inquirer/core": "^9.1.0",
|
||||
"@inquirer/figures": "^1.0.5",
|
||||
"@inquirer/type": "^1.5.3",
|
||||
"ansi-escapes": "^4.3.2",
|
||||
"yoctocolors-cjs": "^2.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@inquirer/testing": "^2.1.32"
|
||||
},
|
||||
"scripts": {
|
||||
"tsc": "yarn run tsc:esm && yarn run tsc:cjs",
|
||||
"tsc:esm": "rm -rf dist/esm && tsc -p ./tsconfig.json",
|
||||
"tsc:cjs": "rm -rf dist/cjs && tsc -p ./tsconfig.cjs.json && node ../../tools/fix-ext.mjs",
|
||||
"attw": "attw --pack"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/esm/types/index.d.mts",
|
||||
"default": "./dist/esm/index.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/cjs/types/index.d.ts",
|
||||
"default": "./dist/cjs/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"gitHead": "0c039599ef88fe9eb804fe083ee386ec906a856f"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue