@inquirer/rawlist 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
@@ -103,14 +103,14 @@ You can theme a prompt by passing a `theme` object option. The theme object only
103
103
 
104
104
  ```ts
105
105
  type Theme = {
106
- prefix: string;
106
+ prefix: string | { idle: string; done: string };
107
107
  spinner: {
108
108
  interval: number;
109
109
  frames: string[];
110
110
  };
111
111
  style: {
112
112
  answer: (text: string) => string;
113
- message: (text: string) => string;
113
+ message: (text: string, status: 'idle' | 'done' | 'loading') => string;
114
114
  error: (text: string) => string;
115
115
  highlight: (text: string) => string;
116
116
  };
package/dist/cjs/index.js CHANGED
@@ -36,11 +36,11 @@ function normalizeChoices(choices) {
36
36
  }
37
37
  exports.default = (0, core_1.createPrompt)((config, done) => {
38
38
  const choices = (0, core_1.useMemo)(() => normalizeChoices(config.choices), [config.choices]);
39
- const [status, setStatus] = (0, core_1.useState)('pending');
39
+ const [status, setStatus] = (0, core_1.useState)('idle');
40
40
  const [value, setValue] = (0, core_1.useState)('');
41
41
  const [errorMsg, setError] = (0, core_1.useState)();
42
42
  const theme = (0, core_1.makeTheme)(config.theme);
43
- const prefix = (0, core_1.usePrefix)({ theme });
43
+ const prefix = (0, core_1.usePrefix)({ status, theme });
44
44
  (0, core_1.useKeypress)((key, rl) => {
45
45
  var _a, _b;
46
46
  if ((0, core_1.isEnterKey)(key)) {
@@ -69,7 +69,7 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
69
69
  setError(undefined);
70
70
  }
71
71
  });
72
- const message = theme.style.message(config.message);
72
+ const message = theme.style.message(config.message, status);
73
73
  if (status === 'done') {
74
74
  return `${prefix} ${message} ${theme.style.answer(value)}`;
75
75
  }
@@ -10,6 +10,8 @@ declare const _default: <Value>(config: {
10
10
  message: string;
11
11
  choices: readonly (string | Separator)[] | readonly (Separator | Choice<Value>)[];
12
12
  theme?: PartialDeep<Theme> | undefined;
13
- }, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value>;
13
+ }, context?: import("@inquirer/type").Context) => Promise<Value> & {
14
+ cancel: () => void;
15
+ };
14
16
  export default _default;
15
17
  export { Separator } from '@inquirer/core';
@@ -29,11 +29,11 @@ function normalizeChoices(choices) {
29
29
  }
30
30
  export default createPrompt((config, done) => {
31
31
  const choices = useMemo(() => normalizeChoices(config.choices), [config.choices]);
32
- const [status, setStatus] = useState('pending');
32
+ const [status, setStatus] = useState('idle');
33
33
  const [value, setValue] = useState('');
34
34
  const [errorMsg, setError] = useState();
35
35
  const theme = makeTheme(config.theme);
36
- const prefix = usePrefix({ theme });
36
+ const prefix = usePrefix({ status, theme });
37
37
  useKeypress((key, rl) => {
38
38
  if (isEnterKey(key)) {
39
39
  let selectedChoice;
@@ -61,7 +61,7 @@ export default createPrompt((config, done) => {
61
61
  setError(undefined);
62
62
  }
63
63
  });
64
- const message = theme.style.message(config.message);
64
+ const message = theme.style.message(config.message, status);
65
65
  if (status === 'done') {
66
66
  return `${prefix} ${message} ${theme.style.answer(value)}`;
67
67
  }
@@ -10,6 +10,8 @@ declare const _default: <Value>(config: {
10
10
  message: string;
11
11
  choices: readonly (string | Separator)[] | readonly (Separator | Choice<Value>)[];
12
12
  theme?: PartialDeep<Theme> | undefined;
13
- }, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value>;
13
+ }, context?: import("@inquirer/type").Context) => Promise<Value> & {
14
+ cancel: () => void;
15
+ };
14
16
  export default _default;
15
17
  export { Separator } from '@inquirer/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/rawlist",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "description": "Inquirer rawlist 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/rawlist/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": "0c039599ef88fe9eb804fe083ee386ec906a856f"
89
+ "gitHead": "5fe03a4686d349d0d6cf281f86f12a4f7c992ad4"
90
90
  }