Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solid-cli/ui

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-cli/ui - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

435

dist/index.js

@@ -1,417 +0,20 @@

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
S_BAR: () => S_BAR,
S_BAR_END: () => S_BAR_END,
S_BAR_H: () => S_BAR_H,
S_BAR_START: () => S_BAR_START,
S_CHECKBOX_ACTIVE: () => S_CHECKBOX_ACTIVE,
S_CHECKBOX_INACTIVE: () => S_CHECKBOX_INACTIVE,
S_CHECKBOX_SELECTED: () => S_CHECKBOX_SELECTED,
S_CONNECT_LEFT: () => S_CONNECT_LEFT,
S_CORNER_BOTTOM_RIGHT: () => S_CORNER_BOTTOM_RIGHT,
S_CORNER_TOP_RIGHT: () => S_CORNER_TOP_RIGHT,
S_ERROR: () => S_ERROR,
S_INFO: () => S_INFO,
S_PASSWORD_MASK: () => S_PASSWORD_MASK,
S_RADIO_ACTIVE: () => S_RADIO_ACTIVE,
S_RADIO_INACTIVE: () => S_RADIO_INACTIVE,
S_STEP_ACTIVE: () => S_STEP_ACTIVE,
S_STEP_CANCEL: () => S_STEP_CANCEL,
S_STEP_ERROR: () => S_STEP_ERROR,
S_STEP_SUBMIT: () => S_STEP_SUBMIT,
S_SUCCESS: () => S_SUCCESS,
S_WARN: () => S_WARN,
autocomplete: () => autocomplete,
box: () => box,
cancelable: () => cancelable,
form: () => form,
spinnerify: () => spinnerify,
strip: () => strip
});
module.exports = __toCommonJS(src_exports);
// src/components/autocomplete/index.ts
var import_core2 = require("@clack/core");
// src/components/autocomplete/utils.ts
var import_core = require("@clack/core");
var import_prompts = require("@clack/prompts");
var import_picocolors = __toESM(require("picocolors"));
var S_STEP_ACTIVE = "\u25C6";
var S_STEP_CANCEL = "\u25A0";
var S_STEP_ERROR = "\u25B2";
var S_STEP_SUBMIT = "\u25C7";
var S_BAR_START = "\u250C";
var S_BAR = "\u2502";
var S_BAR_END = "\u2514";
var S_RADIO_ACTIVE = "\u25CF";
var S_RADIO_INACTIVE = "\u25CB";
var S_CHECKBOX_ACTIVE = "\u25FB";
var S_CHECKBOX_SELECTED = "\u25FC";
var S_CHECKBOX_INACTIVE = "\u25FB";
var S_PASSWORD_MASK = "\u25AA";
var S_BAR_H = "\u2500";
var S_CORNER_TOP_RIGHT = "\u256E";
var S_CONNECT_LEFT = "\u251C";
var S_CORNER_BOTTOM_RIGHT = "\u256F";
var S_INFO = "\u25CF";
var S_SUCCESS = "\u25C6";
var S_WARN = "\u25B2";
var S_ERROR = "\u25A0";
function ansiRegex() {
const pattern = [
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
].join("|");
return new RegExp(pattern, "g");
}
var strip = (str) => str.replace(ansiRegex(), "");
var box = (message = "", title = "") => {
const lines = `
${message}
`.split("\n");
const len = Math.max(
lines.reduce((sum, ln) => {
ln = strip(ln);
return ln.length > sum ? ln.length : sum;
}, 0),
strip(title).length
) + 2;
const msg = lines.map((ln) => `${import_picocolors.default.gray(S_BAR)} ${import_picocolors.default.dim(ln)}${" ".repeat(len - strip(ln).length)}${import_picocolors.default.gray(S_BAR)}`).join("\n");
return `${import_picocolors.default.gray(S_BAR)}
${import_picocolors.default.green(S_STEP_SUBMIT)} ${import_picocolors.default.reset(title)} ${import_picocolors.default.gray(
S_BAR_H.repeat(Math.max(len - title.length - 1, 1)) + S_CORNER_TOP_RIGHT
)}
${msg}
${import_picocolors.default.gray(S_CONNECT_LEFT + S_BAR_H.repeat(len + 2) + S_CORNER_BOTTOM_RIGHT)}
`;
};
var cancelable = async (prompt, cancelMessage = "Canceled") => {
const value = await prompt;
if ((0, import_core.isCancel)(value)) {
import_prompts.log.warn(cancelMessage);
process.exit(0);
}
return value;
};
// src/components/autocomplete/index.ts
var import_picocolors2 = __toESM(require("picocolors"));
var import_reactivity = require("@solid-cli/reactivity");
var import_utils2 = require("@solid-cli/utils");
var buildRegex = (str) => {
let s = "";
for (let i = 0; i < str.length; i++) {
s += str[i] + ".*";
}
s = ".*" + s;
return RegExp(s);
};
var search = (values, lookFor) => {
const group = lookFor.match(/(\w+)\/(\w+)?/);
if (group) {
const groupData = values.filter((option) => option.group && option.group.includes(group[1]));
const sp = group[2];
if (!sp)
return groupData;
const r2 = buildRegex(sp);
return groupData.filter((v) => r2.test((v.label ?? v.value).toLowerCase()));
}
const r = buildRegex(lookFor);
return !lookFor.length ? values : values.filter((v) => r.test((v.label ?? v.value).toLowerCase()));
};
var sortByGroup = (options) => {
return [...options].sort((a, b) => {
if (a.group && b.group)
return 0;
if (a.group && !b.group)
return 1;
return -1;
});
};
var opt = (option, state) => {
const label = option.label ?? String(option.value);
if (state === "active") {
return `${import_picocolors2.default.cyan(S_CHECKBOX_ACTIVE)} ${label} ${option.hint ? import_picocolors2.default.dim(`(${option.hint})`) : ""}`;
} else if (state === "selected") {
return `${import_picocolors2.default.green(S_CHECKBOX_SELECTED)} ${import_picocolors2.default.dim(label)}`;
} else if (state === "cancelled") {
return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(label))}`;
} else if (state === "active-selected") {
return `${import_picocolors2.default.green(S_CHECKBOX_SELECTED)} ${label} ${option.hint ? import_picocolors2.default.dim(`(${option.hint})`) : ""}`;
} else if (state === "submitted") {
return `${import_picocolors2.default.dim(label)}`;
}
return `${import_picocolors2.default.dim(S_CHECKBOX_INACTIVE)} ${import_picocolors2.default.dim(label)}`;
};
var aliases = /* @__PURE__ */ new Map([
["k", "up"],
["j", "down"],
["h", "left"],
["l", "right"]
]);
var AutocompleteText = class extends import_core2.Prompt {
valueWithCursor = "";
options;
get __cursor() {
return this._cursor;
}
cursor = 0;
filteredOptions;
selected;
mode = "explore";
toggleValue() {
const cursorOption = this.filteredOptions[this.cursor];
const selected = this.selected.find((v) => v.value === cursorOption.value) !== void 0;
this.selected = selected ? this.selected.filter((v) => v.value !== cursorOption.value) : [...this.selected, cursorOption];
}
constructor(opts) {
super(opts);
this.options = opts.options();
this.filteredOptions = opts.options();
this.selected = [];
if (this.mode === "explore")
this.value = this.options;
(0, import_reactivity.createEffect)(() => {
this.options = opts.options();
this.filteredOptions = sortByGroup(search(opts.options(), ""));
this.value = this.options;
this.render();
});
this.customKeyPress = this.customKeyPress.bind(this);
this.on("finalize", () => {
if (!this.value) {
this.value = opts.defaultValue;
}
this.valueWithCursor = this.value;
this.value = this.selected;
});
this.on("value", () => {
if (this.value[this.value.length - 1] === "/" && this.mode === "explore") {
this.rl.clearLine();
this.value = "";
this.mode = "search";
return;
}
if (this.mode === "explore")
return;
const value = this.value;
if (this._cursor >= value.length) {
this.valueWithCursor = `${value}${import_picocolors2.default.inverse(import_picocolors2.default.hidden("_"))}`;
} else {
const s1 = value.slice(0, this._cursor);
const s2 = value.slice(this._cursor);
this.valueWithCursor = `${s1}${import_picocolors2.default.inverse(s2)}${s2.slice(1)}`;
}
const indexSelector = value.match(/:(\d+)/);
const last = value[value.length - 1];
if (last === ":") {
const tillSelector = value.slice(0, value.length - 1);
if (tillSelector.length > 0) {
this.filteredOptions = sortByGroup(search(this.options, tillSelector));
} else {
this.filteredOptions = sortByGroup(this.options);
}
return;
}
if (indexSelector && indexSelector[1]) {
const index = Number(indexSelector[1]);
if (this.filteredOptions.length > 1 && index > this.filteredOptions.length - 1) {
this.state = "error";
return;
}
this.cursor = index;
return;
}
const before = this.filteredOptions.length;
this.filteredOptions = sortByGroup(search(this.options, value.toLowerCase()));
const after = this.filteredOptions.length;
if (before !== after) {
this.cursor = 0;
}
});
this.on("cursor", (key) => {
if (this.mode === "explore" && key === "/")
return;
switch (key) {
case "left":
case "up":
this.cursor = this.cursor === 0 ? this.filteredOptions.length - 1 : this.cursor - 1;
break;
case "down":
case "right":
this.cursor = this.cursor === this.filteredOptions.length - 1 ? 0 : this.cursor + 1;
break;
case "tab":
this.toggleValue();
break;
}
});
this.input.on("keypress", this.customKeyPress);
}
customKeyPress(char, key) {
if (this.mode === "explore" && key?.name && aliases.has(key.name)) {
this.emit("cursor", aliases.get(key.name));
}
if (key?.name === "tab") {
const focusedOption = this.filteredOptions[this.cursor];
const selected = this.selected.find((v) => v?.value === focusedOption?.value) !== void 0;
if (selected) {
this.selected = this.selected.filter((v) => v !== focusedOption);
} else {
this.selected = this.filteredOptions?.length === 0 ? this.selected : [...this.selected, focusedOption];
}
this.rl.clearLine();
} else if (key?.name === "escape") {
if (this.mode === "search") {
this.mode = "explore";
return;
}
}
}
};
var BULLET = "\u2022";
var instructions = import_picocolors2.default.gray(
`\u2193/j down ${BULLET} \u2191/k up ${BULLET} tab select ${BULLET} Ctrl-C cancel ${BULLET} / filter`
);
var searchInstructions = import_picocolors2.default.gray(
`tab select ${BULLET} ESC cancel filter ${BULLET} :<number> to highlight by index`
);
var autocomplete = (opts) => {
return new AutocompleteText({
options: opts.options,
message: opts.message,
validate: opts.validate,
placeholder: opts.placeholder,
defaultValue: opts.defaultValue,
initialValue: opts.initialValue,
render() {
const selected = this.selected.length === 0 ? import_picocolors2.default.gray(import_utils2.t.NOTHING_SELECTED) : this.selected.map((option, i) => `${import_picocolors2.default.red(option.label)}`).join(" ");
const placeholder = opts.placeholder ? import_picocolors2.default.inverse(opts.placeholder[0]) + import_picocolors2.default.dim(opts.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_"));
const value = typeof this.value === "string" ? !this.value ? placeholder : this.valueWithCursor : "";
const textView = `${import_picocolors2.default.cyan("?")} Filter: ` + value + "\n";
const noResults = import_picocolors2.default.red(import_utils2.t.AUTOCOMPLETE_NO_RESULTS);
let uniqueGroups = /* @__PURE__ */ new Set();
let start = Math.max(0, this.cursor - 11);
const filteredOptions = this.filteredOptions.map((option, i) => {
if (i < start || i > start + 11)
return;
const selected2 = this.selected.find((v) => v.value === option.value) !== void 0;
const has = option.group && uniqueGroups.has(option.group);
if (!has && option.group) {
uniqueGroups.add(option.group);
}
const isFocused = this.cursor === i;
const active = i === 0 && this.mode === "search" || this.mode === "explore" && isFocused;
const state = selected2 ? "selected" : active ? "active" : "inactive";
const spacing = i > 9 ? " " : " ";
const groupView = `${has || !option.group ? "" : `
${import_picocolors2.default.cyan(S_BAR)}${import_picocolors2.default.bgBlue(import_picocolors2.default.black(option.group))}`} ${!has && option.group ? `
${import_picocolors2.default.cyan(S_BAR)} ` : ""}`;
return groupView + `${i}:${spacing}` + (isFocused ? import_picocolors2.default.bgBlack(opt(option, state)) : opt(option, state));
}).filter(Boolean).join(`
${import_picocolors2.default.cyan(S_BAR)} `);
const options = `${import_picocolors2.default.cyan(S_BAR)} ${this.filteredOptions.length ? filteredOptions : noResults}
${import_picocolors2.default.cyan(S_BAR_END)}
`;
return `${import_picocolors2.default.cyan(S_BAR)}
${import_picocolors2.default.cyan(S_BAR)} ${import_picocolors2.default.yellow(S_CHECKBOX_SELECTED)} ${import_utils2.t.AUTOCOMPLETE_SELECTED}: ${selected}
${import_picocolors2.default.cyan(S_BAR)}
` + (this.mode === "search" ? `${import_picocolors2.default.cyan(S_BAR)} ` + textView : "") + options + "\n" + (this.mode === "search" ? searchInstructions : instructions);
}
}).prompt();
};
// src/components/form/index.ts
var import_prompts2 = require("@clack/prompts");
var form = async (fields) => {
let returns = [];
for (const field of fields) {
if (field.render) {
const r2 = await field.render.bind(field)();
if (r2) {
returns.push({ name: field.name, value: r2 });
}
continue;
}
const r = await (0, import_prompts2.text)({ ...field });
returns.push({ name: field.name, value: r });
}
return returns;
};
// src/components/spinnerify/index.ts
var import_prompts3 = require("@clack/prompts");
async function spinnerify(spinners) {
if (!Array.isArray(spinners))
spinners = [spinners];
let results = [];
const s = (0, import_prompts3.spinner)();
for (const { startText, finishText, fn } of spinners) {
s.start(startText);
results.push(await fn());
s.stop(finishText);
}
return results.length === 1 ? results[0] : results;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
S_BAR,
S_BAR_END,
S_BAR_H,
S_BAR_START,
S_CHECKBOX_ACTIVE,
S_CHECKBOX_INACTIVE,
S_CHECKBOX_SELECTED,
S_CONNECT_LEFT,
S_CORNER_BOTTOM_RIGHT,
S_CORNER_TOP_RIGHT,
S_ERROR,
S_INFO,
S_PASSWORD_MASK,
S_RADIO_ACTIVE,
S_RADIO_INACTIVE,
S_STEP_ACTIVE,
S_STEP_CANCEL,
S_STEP_ERROR,
S_STEP_SUBMIT,
S_SUCCESS,
S_WARN,
autocomplete,
box,
cancelable,
form,
spinnerify,
strip
});
"use strict";var k=Object.create;var g=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var ee=(s,t)=>{for(var e in t)g(s,e,{get:t[e],enumerable:!0})},b=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of J(t))!Y.call(s,i)&&i!==e&&g(s,i,{get:()=>t[i],enumerable:!(n=q(t,i))||n.enumerable});return s};var w=(s,t,e)=>(e=s!=null?k(Q(s)):{},b(t||!s||!s.__esModule?g(e,"default",{value:s,enumerable:!0}):e,s)),te=s=>b(g({},"__esModule",{value:!0}),s);var Se={};ee(Se,{S_BAR:()=>l,S_BAR_END:()=>x,S_BAR_H:()=>S,S_BAR_START:()=>ie,S_CHECKBOX_ACTIVE:()=>E,S_CHECKBOX_INACTIVE:()=>v,S_CHECKBOX_SELECTED:()=>f,S_CONNECT_LEFT:()=>V,S_CORNER_BOTTOM_RIGHT:()=>L,S_CORNER_TOP_RIGHT:()=>N,S_ERROR:()=>de,S_INFO:()=>ae,S_PASSWORD_MASK:()=>le,S_RADIO_ACTIVE:()=>oe,S_RADIO_INACTIVE:()=>ce,S_STEP_ACTIVE:()=>se,S_STEP_CANCEL:()=>re,S_STEP_ERROR:()=>ne,S_STEP_SUBMIT:()=>P,S_SUCCESS:()=>he,S_WARN:()=>ue,autocomplete:()=>_e,box:()=>fe,cancelable:()=>me,form:()=>Oe,spinnerify:()=>$e,strip:()=>T});module.exports=te(Se);var M=require("@clack/core");var I=require("@clack/core"),B=require("@clack/prompts"),u=w(require("picocolors")),se="\u25C6",re="\u25A0",ne="\u25B2",P="\u25C7",ie="\u250C",l="\u2502",x="\u2514",oe="\u25CF",ce="\u25CB",E="\u25FB",f="\u25FC",v="\u25FB",le="\u25AA",S="\u2500",N="\u256E",V="\u251C",L="\u256F",ae="\u25CF",he="\u25C6",ue="\u25B2",de="\u25A0";function pe(){let s=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(s,"g")}var T=s=>s.replace(pe(),""),fe=(s="",t="")=>{let e=`
${s}
`.split(`
`),n=Math.max(e.reduce((o,h)=>(h=T(h),h.length>o?h.length:o),0),T(t).length)+2,i=e.map(o=>`${u.default.gray(l)} ${u.default.dim(o)}${" ".repeat(n-T(o).length)}${u.default.gray(l)}`).join(`
`);return`${u.default.gray(l)}
${u.default.green(P)} ${u.default.reset(t)} ${u.default.gray(S.repeat(Math.max(n-t.length-1,1))+N)}
${i}
${u.default.gray(V+S.repeat(n+2)+L)}
`};var me=async(s,t="Canceled")=>{let e=await s;return(0,I.isCancel)(e)&&(B.log.warn(t),process.exit(0)),e};var r=w(require("picocolors")),W=require("@solid-cli/reactivity"),O=require("@solid-cli/utils"),K=s=>{let t="";for(let e=0;e<s.length;e++)t+=s[e]+".*";return t=".*"+t,RegExp(t)},y=(s,t)=>{let e=t.match(/(\w+)\/(\w+)?/);if(e){let i=s.filter(c=>c.group&&c.group.includes(e[1])),o=e[2];if(!o)return i;let h=K(o);return i.filter(c=>h.test((c.label??c.value).toLowerCase()))}let n=K(t);return t.length?s.filter(i=>n.test((i.label??i.value).toLowerCase())):s},_=s=>[...s].sort((t,e)=>t.group&&e.group?0:t.group&&!e.group?1:-1),D=(s,t)=>{let e=s.label??String(s.value);return t==="active"?`${r.default.cyan(E)} ${e} ${s.hint?r.default.dim(`(${s.hint})`):""}`:t==="selected"?`${r.default.green(f)} ${r.default.dim(e)}`:t==="cancelled"?`${r.default.strikethrough(r.default.dim(e))}`:t==="active-selected"?`${r.default.green(f)} ${e} ${s.hint?r.default.dim(`(${s.hint})`):""}`:t==="submitted"?`${r.default.dim(e)}`:`${r.default.dim(v)} ${r.default.dim(e)}`},H=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),C=class extends M.Prompt{valueWithCursor="";options;get __cursor(){return this._cursor}cursor=0;filteredOptions;selected;mode="explore";toggleValue(){let t=this.filteredOptions[this.cursor],e=this.selected.find(n=>n.value===t.value)!==void 0;this.selected=e?this.selected.filter(n=>n.value!==t.value):[...this.selected,t]}constructor(t){super(t),this.options=t.options(),this.filteredOptions=t.options(),this.selected=[],this.mode==="explore"&&(this.value=this.options),(0,W.createEffect)(()=>{this.options=t.options(),this.filteredOptions=_(y(t.options(),"")),this.value=this.options,this.render()}),this.customKeyPress=this.customKeyPress.bind(this),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.valueWithCursor=this.value,this.value=this.selected}),this.on("value",()=>{if(this.value[this.value.length-1]==="/"&&this.mode==="explore"){this.rl.clearLine(),this.value="",this.mode="search";return}if(this.mode==="explore")return;let e=this.value;if(this._cursor>=e.length)this.valueWithCursor=`${e}${r.default.inverse(r.default.hidden("_"))}`;else{let c=e.slice(0,this._cursor),m=e.slice(this._cursor);this.valueWithCursor=`${c}${r.default.inverse(m)}${m.slice(1)}`}let n=e.match(/:(\d+)/);if(e[e.length-1]===":"){let c=e.slice(0,e.length-1);c.length>0?this.filteredOptions=_(y(this.options,c)):this.filteredOptions=_(this.options);return}if(n&&n[1]){let c=Number(n[1]);if(this.filteredOptions.length>1&&c>this.filteredOptions.length-1){this.state="error";return}this.cursor=c;return}let o=this.filteredOptions.length;this.filteredOptions=_(y(this.options,e.toLowerCase()));let h=this.filteredOptions.length;o!==h&&(this.cursor=0)}),this.on("cursor",e=>{if(!(this.mode==="explore"&&e==="/"))switch(e){case"left":case"up":this.cursor=this.cursor===0?this.filteredOptions.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.filteredOptions.length-1?0:this.cursor+1;break;case"tab":this.toggleValue();break}}),this.input.on("keypress",this.customKeyPress)}customKeyPress(t,e){if(this.mode==="explore"&&e?.name&&H.has(e.name)&&this.emit("cursor",H.get(e.name)),e?.name==="tab"){let n=this.filteredOptions[this.cursor];this.selected.find(o=>o?.value===n?.value)!==void 0?this.selected=this.selected.filter(o=>o!==n):this.selected=this.filteredOptions?.length===0?this.selected:[...this.selected,n],this.rl.clearLine()}else if(e?.name==="escape"&&this.mode==="search"){this.mode="explore";return}}},p="\u2022",ge=r.default.gray(`\u2193/j down ${p} \u2191/k up ${p} tab select ${p} Ctrl-C cancel ${p} / filter`),Te=r.default.gray(`tab select ${p} ESC cancel filter ${p} :<number> to highlight by index`),_e=s=>new C({options:s.options,message:s.message,validate:s.validate,placeholder:s.placeholder,defaultValue:s.defaultValue,initialValue:s.initialValue,render(){let t=this.selected.length===0?r.default.gray(O.t.NOTHING_SELECTED):this.selected.map((a,d)=>`${r.default.yellow(a.label)}`).join(" "),e=s.placeholder?r.default.inverse(s.placeholder[0])+r.default.dim(s.placeholder.slice(1)):r.default.inverse(r.default.hidden("_")),n=typeof this.value=="string"?this.value?this.valueWithCursor:e:"",i=`${r.default.cyan("?")} Filter: `+n+`
`,o=r.default.red(O.t.AUTOCOMPLETE_NO_RESULTS),h=new Set,c=Math.max(0,this.cursor-11),m=this.filteredOptions.map((a,d)=>{if(d<c||d>c+11)return;let X=this.selected.find(Z=>Z.value===a.value)!==void 0,$=a.group&&h.has(a.group);!$&&a.group&&h.add(a.group);let A=this.cursor===d,G=d===0&&this.mode==="search"||this.mode==="explore"&&A,R=X?"selected":G?"active":"inactive",z=d>9?" ":" ";return`${$||!a.group?"":`
${r.default.cyan(l)}${r.default.bgBlue(r.default.black(a.group))}`} ${!$&&a.group?`
${r.default.cyan(l)} `:""}`+`${d}:${z}`+(A?r.default.bgBlack(D(a,R)):D(a,R))}).filter(Boolean).join(`
${r.default.cyan(l)} `),U=`${r.default.cyan(l)} ${this.filteredOptions.length?m:o}
${r.default.cyan(x)}
`;return`${r.default.cyan(l)}
${r.default.cyan(l)} ${r.default.yellow(f)} ${O.t.AUTOCOMPLETE_SELECTED}: ${t}
${r.default.cyan(l)}
`+(this.mode==="search"?`${r.default.cyan(l)} `+i:"")+U+`
`+(this.mode==="search"?Te:ge)}}).prompt();var j=require("@clack/prompts"),Oe=async s=>{let t=[];for(let e of s){if(e.render){let i=await e.render.bind(e)();i&&t.push({name:e.name,value:i});continue}let n=await(0,j.text)({...e});t.push({name:e.name,value:n})}return t};var F=require("@clack/prompts");async function $e(s){Array.isArray(s)||(s=[s]);let t=[],e=(0,F.spinner)();for(let{startText:n,finishText:i,fn:o}of s)e.start(n),t.push(await o()),e.stop(i);return t.length===1?t[0]:t}0&&(module.exports={S_BAR,S_BAR_END,S_BAR_H,S_BAR_START,S_CHECKBOX_ACTIVE,S_CHECKBOX_INACTIVE,S_CHECKBOX_SELECTED,S_CONNECT_LEFT,S_CORNER_BOTTOM_RIGHT,S_CORNER_TOP_RIGHT,S_ERROR,S_INFO,S_PASSWORD_MASK,S_RADIO_ACTIVE,S_RADIO_INACTIVE,S_STEP_ACTIVE,S_STEP_CANCEL,S_STEP_ERROR,S_STEP_SUBMIT,S_SUCCESS,S_WARN,autocomplete,box,cancelable,form,spinnerify,strip});
//# sourceMappingURL=index.js.map

6

package.json
{
"name": "@solid-cli/ui",
"version": "0.0.5",
"version": "0.0.6",
"license": "MIT",

@@ -33,4 +33,4 @@ "homepage": "https://solid-cli.netlify.app",

"picocolors": "^1.0.0",
"@solid-cli/reactivity": "0.0.8",
"@solid-cli/utils": "0.0.5"
"@solid-cli/reactivity": "0.0.10",
"@solid-cli/utils": "0.0.6"
},

@@ -37,0 +37,0 @@ "scripts": {

@@ -229,13 +229,2 @@ import { Key } from "node:readline";

const getTerminalSize = () => {
const stdout = process.stdout.getWindowSize();
return {
width: stdout[0],
height: stdout[1],
};
};
const space = (n: number) => ` `.repeat(n);
const BULLET = "•";

@@ -263,3 +252,3 @@

? color.gray(t.NOTHING_SELECTED)
: this.selected.map((option, i) => `${color.red(option.label)}`).join(" ");
: this.selected.map((option, i) => `${color.yellow(option.label)}`).join(" ");
const placeholder = opts.placeholder

@@ -266,0 +255,0 @@ ? color.inverse(opts.placeholder[0]) + color.dim(opts.placeholder.slice(1))

@@ -9,3 +9,4 @@ import { defineConfig } from "tsup";

sourcemap: true,
minify: true,
clean: true,
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc