@inquirer/editor
Advanced tools
Comparing version 1.2.15 to 2.0.0
@@ -11,7 +11,3 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const external_editor_1 = require("external-editor"); | ||
@@ -21,5 +17,8 @@ const core_1 = require("@inquirer/core"); | ||
const { waitForUseInput = true, validate = () => true } = config; | ||
const theme = (0, core_1.makeTheme)(config.theme); | ||
const [status, setStatus] = (0, core_1.useState)('pending'); | ||
const [value, setValue] = (0, core_1.useState)(config.default || ''); | ||
const [errorMsg, setError] = (0, core_1.useState)(undefined); | ||
const isLoading = status === 'loading'; | ||
const prefix = (0, core_1.usePrefix)({ isLoading, theme }); | ||
function startEditor(rl) { | ||
@@ -64,17 +63,16 @@ rl.pause(); | ||
}); | ||
const isLoading = status === 'loading'; | ||
const prefix = (0, core_1.usePrefix)(isLoading); | ||
const message = chalk_1.default.bold(config.message); | ||
let helpTip; | ||
const message = theme.style.message(config.message); | ||
let helpTip = ''; | ||
if (status === 'loading') { | ||
helpTip = chalk_1.default.dim('Received'); | ||
helpTip = theme.style.help('Received'); | ||
} | ||
else if (status === 'pending') { | ||
helpTip = chalk_1.default.dim('Press <enter> to launch your preferred editor.'); | ||
const enterKey = theme.style.key('enter'); | ||
helpTip = theme.style.help(`Press ${enterKey} to launch your preferred editor.`); | ||
} | ||
let error = ''; | ||
if (errorMsg) { | ||
error = chalk_1.default.red(`> ${errorMsg}`); | ||
error = theme.style.error(errorMsg); | ||
} | ||
return [[prefix, message, helpTip].filter(Boolean).join(' '), error]; | ||
}); |
@@ -11,7 +11,3 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const external_editor_1 = require("external-editor"); | ||
@@ -21,5 +17,8 @@ const core_1 = require("@inquirer/core"); | ||
const { waitForUseInput = true, validate = () => true } = config; | ||
const theme = (0, core_1.makeTheme)(config.theme); | ||
const [status, setStatus] = (0, core_1.useState)('pending'); | ||
const [value, setValue] = (0, core_1.useState)(config.default || ''); | ||
const [errorMsg, setError] = (0, core_1.useState)(undefined); | ||
const isLoading = status === 'loading'; | ||
const prefix = (0, core_1.usePrefix)({ isLoading, theme }); | ||
function startEditor(rl) { | ||
@@ -64,17 +63,16 @@ rl.pause(); | ||
}); | ||
const isLoading = status === 'loading'; | ||
const prefix = (0, core_1.usePrefix)(isLoading); | ||
const message = chalk_1.default.bold(config.message); | ||
let helpTip; | ||
const message = theme.style.message(config.message); | ||
let helpTip = ''; | ||
if (status === 'loading') { | ||
helpTip = chalk_1.default.dim('Received'); | ||
helpTip = theme.style.help('Received'); | ||
} | ||
else if (status === 'pending') { | ||
helpTip = chalk_1.default.dim('Press <enter> to launch your preferred editor.'); | ||
const enterKey = theme.style.key('enter'); | ||
helpTip = theme.style.help(`Press ${enterKey} to launch your preferred editor.`); | ||
} | ||
let error = ''; | ||
if (errorMsg) { | ||
error = chalk_1.default.red(`> ${errorMsg}`); | ||
error = theme.style.error(errorMsg); | ||
} | ||
return [[prefix, message, helpTip].filter(Boolean).join(' '), error]; | ||
}); |
@@ -1,8 +0,12 @@ | ||
declare const _default: import("@inquirer/type").Prompt<string, { | ||
message: string | Promise<string> | (() => Promise<string>); | ||
default?: string | undefined; | ||
postfix?: string | undefined; | ||
waitForUseInput?: boolean | undefined; | ||
validate?: ((value: string) => string | boolean | Promise<string | boolean>) | undefined; | ||
}>; | ||
import { type Theme } from '@inquirer/core'; | ||
import type { PartialDeep } from '@inquirer/type'; | ||
type EditorConfig = { | ||
message: string; | ||
default?: string; | ||
postfix?: string; | ||
waitForUseInput?: boolean; | ||
validate?: (value: string) => boolean | string | Promise<string | boolean>; | ||
theme?: PartialDeep<Theme>; | ||
}; | ||
declare const _default: import("@inquirer/type").Prompt<string, EditorConfig>; | ||
export default _default; |
{ | ||
"name": "@inquirer/editor", | ||
"version": "1.2.15", | ||
"version": "2.0.0", | ||
"description": "Inquirer multiline editor prompt", | ||
@@ -57,5 +57,4 @@ "main": "./dist/cjs/index.js", | ||
"dependencies": { | ||
"@inquirer/core": "^6.0.0", | ||
"@inquirer/type": "^1.1.6", | ||
"chalk": "^4.1.2", | ||
"@inquirer/core": "^7.0.0", | ||
"@inquirer/type": "^1.2.0", | ||
"external-editor": "^3.1.0" | ||
@@ -72,3 +71,3 @@ }, | ||
"engines": { | ||
"node": ">=14.18.0" | ||
"node": ">=18" | ||
}, | ||
@@ -87,3 +86,3 @@ "exports": { | ||
}, | ||
"gitHead": "4dee2b11d89a7c8a698c9eeda546ba8092b84f64" | ||
"gitHead": "44016a40bc9e93455dfdb9fa6c25c27c1c109bd3" | ||
} |
@@ -32,3 +32,24 @@ # `@inquirer/editor` | ||
| waitForUseInput | `boolean` | no (default to `true`) | Open the editor automatically without waiting for the user to press enter. Note that this mean the user will not see the question! So make sure you have a default value that provide guidance if it's unclear what input is expected. | | ||
| theme | [See Theming](#Theming) | no | Customize look of the prompt. | | ||
## 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: { | ||
message: (text: string) => string; | ||
error: (text: string) => string; | ||
help: (text: string) => string; | ||
key: (text: string) => string; | ||
}; | ||
}; | ||
``` | ||
# License | ||
@@ -35,0 +56,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
15899
3
226
58
+ Added@inquirer/core@7.1.3(transitive)
+ Added@inquirer/figures@1.0.7(transitive)
- Removedchalk@^4.1.2
- Removed@inquirer/core@6.0.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedfigures@3.2.0(transitive)
- Removedrun-async@3.0.0(transitive)
Updated@inquirer/core@^7.0.0
Updated@inquirer/type@^1.2.0