@optique/clack 1.4.0-dev.2729 → 1.4.0-dev.2731

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/dist/index.cjs CHANGED
@@ -134,7 +134,7 @@ async function executePromptRaw(config, context) {
134
134
  if ("prompter" in cfg && cfg.prompter != null) result = await cfg.prompter(context);
135
135
  else {
136
136
  if (context.previousValidationMessage !== void 0) prompts.logError((0, __optique_core_message.formatMessage)(context.previousValidationMessage));
137
- const disabled = cfg.type === "autocomplete-multiselect" ? new Set(normalizeOptions(cfg.options).filter((option) => option.disabled).map((option) => option.value)) : void 0;
137
+ const disabled = cfg.type === "autocomplete-multiselect" ? getDisabledOptionValues(normalizeOptions(cfg.options)) : void 0;
138
138
  while (true) {
139
139
  result = await executeClackPromptWithSignal(cfg, prompts, context.signal);
140
140
  if (cfg.type !== "autocomplete-multiselect" || disabled === void 0 || !Array.isArray(result)) break;
@@ -221,6 +221,7 @@ function executeClackPrompt(cfg, prompts, signal) {
221
221
  });
222
222
  case "autocomplete": {
223
223
  const options = normalizeOptions(cfg.options);
224
+ const disabled = getDisabledOptionValues(options);
224
225
  return prompts.autocomplete({
225
226
  message: cfg.message,
226
227
  options,
@@ -232,7 +233,7 @@ function executeClackPrompt(cfg, prompts, signal) {
232
233
  ...cfg.filter === void 0 ? {} : { filter: cfg.filter },
233
234
  validate: (value) => {
234
235
  if (typeof value !== "string") return "No option selected.";
235
- if (options.some((option) => option.value === value && option.disabled)) return "Option is unavailable.";
236
+ if (disabled.has(value)) return "Option is unavailable.";
236
237
  return cfg.validate?.(value) ?? void 0;
237
238
  }
238
239
  });
@@ -282,6 +283,11 @@ function parseNumberPromptValue(value) {
282
283
  const parsed = Number(value);
283
284
  return Number.isFinite(parsed) ? parsed : null;
284
285
  }
286
+ function getDisabledOptionValues(options) {
287
+ const disabled = new Set(options.filter((option) => option.disabled).map((option) => option.value));
288
+ for (const option of options) if (!option.disabled) disabled.delete(option.value);
289
+ return disabled;
290
+ }
285
291
  function normalizeOptions(options) {
286
292
  return options.map((option) => {
287
293
  if (typeof option === "string") return {
package/dist/index.js CHANGED
@@ -111,7 +111,7 @@ async function executePromptRaw(config, context) {
111
111
  if ("prompter" in cfg && cfg.prompter != null) result = await cfg.prompter(context);
112
112
  else {
113
113
  if (context.previousValidationMessage !== void 0) prompts.logError(formatMessage(context.previousValidationMessage));
114
- const disabled = cfg.type === "autocomplete-multiselect" ? new Set(normalizeOptions(cfg.options).filter((option) => option.disabled).map((option) => option.value)) : void 0;
114
+ const disabled = cfg.type === "autocomplete-multiselect" ? getDisabledOptionValues(normalizeOptions(cfg.options)) : void 0;
115
115
  while (true) {
116
116
  result = await executeClackPromptWithSignal(cfg, prompts, context.signal);
117
117
  if (cfg.type !== "autocomplete-multiselect" || disabled === void 0 || !Array.isArray(result)) break;
@@ -198,6 +198,7 @@ function executeClackPrompt(cfg, prompts, signal) {
198
198
  });
199
199
  case "autocomplete": {
200
200
  const options = normalizeOptions(cfg.options);
201
+ const disabled = getDisabledOptionValues(options);
201
202
  return prompts.autocomplete({
202
203
  message: cfg.message,
203
204
  options,
@@ -209,7 +210,7 @@ function executeClackPrompt(cfg, prompts, signal) {
209
210
  ...cfg.filter === void 0 ? {} : { filter: cfg.filter },
210
211
  validate: (value) => {
211
212
  if (typeof value !== "string") return "No option selected.";
212
- if (options.some((option) => option.value === value && option.disabled)) return "Option is unavailable.";
213
+ if (disabled.has(value)) return "Option is unavailable.";
213
214
  return cfg.validate?.(value) ?? void 0;
214
215
  }
215
216
  });
@@ -259,6 +260,11 @@ function parseNumberPromptValue(value) {
259
260
  const parsed = Number(value);
260
261
  return Number.isFinite(parsed) ? parsed : null;
261
262
  }
263
+ function getDisabledOptionValues(options) {
264
+ const disabled = new Set(options.filter((option) => option.disabled).map((option) => option.value));
265
+ for (const option of options) if (!option.disabled) disabled.delete(option.value);
266
+ return disabled;
267
+ }
262
268
  function normalizeOptions(options) {
263
269
  return options.map((option) => {
264
270
  if (typeof option === "string") return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/clack",
3
- "version": "1.4.0-dev.2729",
3
+ "version": "1.4.0-dev.2731",
4
4
  "description": "Interactive prompt support for Optique via Clack",
5
5
  "keywords": [
6
6
  "CLI",
@@ -62,12 +62,12 @@
62
62
  "sideEffects": false,
63
63
  "dependencies": {
64
64
  "@clack/prompts": "^1.6.0",
65
- "@optique/core": "1.4.0-dev.2729+72048695",
66
- "@optique/prompt": "1.4.0-dev.2729+72048695"
65
+ "@optique/core": "1.4.0-dev.2731+078a644e",
66
+ "@optique/prompt": "1.4.0-dev.2731+078a644e"
67
67
  },
68
68
  "devDependencies": {
69
- "@optique/env": "1.4.0-dev.2729+72048695",
70
- "@optique/run": "1.4.0-dev.2729+72048695",
69
+ "@optique/env": "1.4.0-dev.2731+078a644e",
70
+ "@optique/run": "1.4.0-dev.2731+078a644e",
71
71
  "@types/node": "^24.0.0",
72
72
  "fast-check": "^4.7.0",
73
73
  "tsdown": "^0.13.0",