@inquirer/expand 2.3.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -120,14 +120,14 @@ You can theme a prompt by passing a `theme` object option. The theme object only
120
120
 
121
121
  ```ts
122
122
  type Theme = {
123
- prefix: string;
123
+ prefix: string | { idle: string; done: string };
124
124
  spinner: {
125
125
  interval: number;
126
126
  frames: string[];
127
127
  };
128
128
  style: {
129
129
  answer: (text: string) => string;
130
- message: (text: string) => string;
130
+ message: (text: string, status: 'idle' | 'done' | 'loading') => string;
131
131
  error: (text: string) => string;
132
132
  defaultAnswer: (text: string) => string;
133
133
  highlight: (text: string) => string;
package/dist/cjs/index.js CHANGED
@@ -29,12 +29,12 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
29
29
  var _a;
30
30
  const { default: defaultKey = 'h' } = config;
31
31
  const choices = (0, core_1.useMemo)(() => normalizeChoices(config.choices), [config.choices]);
32
- const [status, setStatus] = (0, core_1.useState)('pending');
32
+ const [status, setStatus] = (0, core_1.useState)('idle');
33
33
  const [value, setValue] = (0, core_1.useState)('');
34
34
  const [expanded, setExpanded] = (0, core_1.useState)((_a = config.expanded) !== null && _a !== void 0 ? _a : false);
35
35
  const [errorMsg, setError] = (0, core_1.useState)();
36
36
  const theme = (0, core_1.makeTheme)(config.theme);
37
- const prefix = (0, core_1.usePrefix)({ theme });
37
+ const prefix = (0, core_1.usePrefix)({ theme, status });
38
38
  (0, core_1.useKeypress)((event, rl) => {
39
39
  if ((0, core_1.isEnterKey)(event)) {
40
40
  const answer = (value || defaultKey).toLowerCase();
@@ -62,7 +62,7 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
62
62
  setError(undefined);
63
63
  }
64
64
  });
65
- const message = theme.style.message(config.message);
65
+ const message = theme.style.message(config.message, status);
66
66
  if (status === 'done') {
67
67
  // If the prompt is done, it's safe to assume there is a selected value.
68
68
  const selectedChoice = choices.find((choice) => !core_1.Separator.isSeparator(choice) && choice.key === value.toLowerCase());
@@ -18,6 +18,8 @@ declare const _default: <Value>(config: {
18
18
  default?: (Key | "h") | undefined;
19
19
  expanded?: boolean | undefined;
20
20
  theme?: PartialDeep<Theme> | undefined;
21
- }, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value>;
21
+ }, context?: import("@inquirer/type").Context) => Promise<Value> & {
22
+ cancel: () => void;
23
+ };
22
24
  export default _default;
23
25
  export { Separator } from '@inquirer/core';
@@ -22,12 +22,12 @@ const helpChoice = {
22
22
  export default createPrompt((config, done) => {
23
23
  const { default: defaultKey = 'h' } = config;
24
24
  const choices = useMemo(() => normalizeChoices(config.choices), [config.choices]);
25
- const [status, setStatus] = useState('pending');
25
+ const [status, setStatus] = useState('idle');
26
26
  const [value, setValue] = useState('');
27
27
  const [expanded, setExpanded] = useState(config.expanded ?? false);
28
28
  const [errorMsg, setError] = useState();
29
29
  const theme = makeTheme(config.theme);
30
- const prefix = usePrefix({ theme });
30
+ const prefix = usePrefix({ theme, status });
31
31
  useKeypress((event, rl) => {
32
32
  if (isEnterKey(event)) {
33
33
  const answer = (value || defaultKey).toLowerCase();
@@ -55,7 +55,7 @@ export default createPrompt((config, done) => {
55
55
  setError(undefined);
56
56
  }
57
57
  });
58
- const message = theme.style.message(config.message);
58
+ const message = theme.style.message(config.message, status);
59
59
  if (status === 'done') {
60
60
  // If the prompt is done, it's safe to assume there is a selected value.
61
61
  const selectedChoice = choices.find((choice) => !Separator.isSeparator(choice) && choice.key === value.toLowerCase());
@@ -18,6 +18,8 @@ declare const _default: <Value>(config: {
18
18
  default?: (Key | "h") | undefined;
19
19
  expanded?: boolean | undefined;
20
20
  theme?: PartialDeep<Theme> | undefined;
21
- }, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value>;
21
+ }, context?: import("@inquirer/type").Context) => Promise<Value> & {
22
+ cancel: () => void;
23
+ };
22
24
  export default _default;
23
25
  export { Separator } from '@inquirer/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/expand",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "description": "Inquirer checkbox prompt",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "typings": "./dist/cjs/types/index.d.ts",
@@ -54,12 +54,12 @@
54
54
  "license": "MIT",
55
55
  "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/expand/README.md",
56
56
  "dependencies": {
57
- "@inquirer/core": "^9.1.0",
58
- "@inquirer/type": "^1.5.3",
57
+ "@inquirer/core": "^9.2.0",
58
+ "@inquirer/type": "^1.5.4",
59
59
  "yoctocolors-cjs": "^2.1.2"
60
60
  },
61
61
  "devDependencies": {
62
- "@inquirer/testing": "^2.1.32"
62
+ "@inquirer/testing": "^2.1.33"
63
63
  },
64
64
  "scripts": {
65
65
  "tsc": "yarn run tsc:esm && yarn run tsc:cjs",
@@ -86,5 +86,5 @@
86
86
  }
87
87
  },
88
88
  "sideEffects": false,
89
- "gitHead": "4937ea3a74152b59bf4198dbaa803119ed4ef8e2"
89
+ "gitHead": "5fe03a4686d349d0d6cf281f86f12a4f7c992ad4"
90
90
  }