@lobehub/cli-ui
Advanced tools
+1
-1
@@ -1,1 +0,1 @@ | ||
| import{consola as E}from"consola";import D from"node:process";import{jsx as t,jsxs as L}from"react/jsx-runtime";import{Box as g,Text as y,useInput as W,useApp as _,render as z}from"ink";import{memo as I,useState as j,useRef as G,useEffect as U,useCallback as J,useMemo as $,createElement as V}from"react";import A from"arr-rotate";import K from"fast-deep-equal";import X from"figures";import{Badge as F,extendTheme as Y,defaultTheme as Z,ThemeProvider as H}from"@inkjs/ui";var ee={error:(o,e)=>{E.error(o),e&&D.exit(1)},info:(o,e)=>{E.info(o),e&&D.exit(0)},success:(o,e)=>{E.success(o),e&&D.exit(0)},warn:(o,e)=>{E.warn(o),e&&D.exit(0)}};const oe={blue:"#8ae8ff",cyan:"#95f3d9",geekblue:"#369eff",gold:"#ffcb47",gray:"#777777",green:"#55b467",lime:"#c4f042",magenta:"#e34ba9",orange:"#ff802b",pink:"#eb2f96",purple:"#bd54c6",red:"#f04f88",volcano:"#ec5e41",yellow:"#ffef5c"},re={colorError:"red",colorInfo:"blue",colorPrimary:"cyan",colorSuccess:"green",colorWarning:"yellow"};var te={colorBgContainer:"#111111",colorBgElevated:"#222222",colorBgLayout:"#000000",colorBgSpotlight:"#444444",colorBorder:"#333333",colorBorderSecondary:"#2d2d2d",colorText:"#ffffff",colorTextDescription:"#6f6f6f",colorTextPlaceholder:"#555555",colorTextQuaternary:"#555555",colorTextSecondary:"#aaaaaa",colorTextTertiary:"#6f6f6f",...re,...oe};const v=()=>te,ne=I(({show:o=!0,children:e,footer:c,reverse:r=!1,header:l,headerConfig:a,footerConfig:h,bodyConfig:d,title:s,...S})=>{const n=v();if(!o)return;const i=(s||l)&&t(g,{borderColor:n.colorBorder,borderLeft:!1,borderRight:!1,borderStyle:"bold",borderTop:!1,flexDirection:"row",justifyContent:"center",paddingLeft:1,paddingRight:1,...a,children:s?t(y,{bold:!0,children:s.toUpperCase()}):l}),m=t(g,{flexDirection:"column",paddingLeft:1,paddingRight:1,...d,children:e}),f=c&&t(g,{borderBottom:r,borderColor:n.colorBorder,borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!r,flexDirection:"row",paddingLeft:1,paddingRight:1,...h,children:c});return L(g,{alignItems:"stretch",borderColor:n.colorBorder,borderStyle:"bold",flexDirection:"column",...S,children:[i,r?f:m,r?m:f]})});var N=ne;const ce=I(({highlightColor:o,isSelected:e=!1})=>t(g,{marginRight:1,children:e?t(y,{color:o,children:X.pointer}):t(y,{children:" "})}));var le=ce;const ae=I(({highlightColor:o,isSelected:e=!1,label:c})=>t(y,{color:e?o:void 0,children:c}));var se=ae;const de=I(({highlightColor:o,items:e=[],isFocused:c=!0,initialIndex:r=0,indicatorComponent:l=le,itemComponent:a=se,limit:h,onSelect:d,onHighlight:s})=>{const S=v(),n=typeof h=="number"&&e.length>h,i=n?Math.min(h,e.length):e.length,m=i-1,[f,u]=j(r>m?m-r:0),[p,T]=j(r?r>m?m:r:0),k=G(e);U(()=>{K(k.current.map(b=>b.value),e.map(b=>b.value))||(u(0),T(0)),k.current=e},[e]),W(J((b,C)=>{if(C.upArrow){const x=(n?i:e.length)-1,B=p===0,w=n?p:x,P=B?f+1:f,R=B?w:p-1;u(P),T(R);const Q=n?A(e,P).slice(0,i):e;typeof s=="function"&&s(Q[R])}if(C.downArrow){const x=p===(n?i:e.length)-1,B=n?p:0,w=x?f-1:f,P=x?B:p+1;u(w),T(P);const R=n?A(e,w).slice(0,i):e;typeof s=="function"&&s(R[P])}if(C.return){const x=n?A(e,f).slice(0,i):e;typeof d=="function"&&d(x[p])}},[n,i,f,p,e,d,s]),{isActive:c});const q=$(()=>n?A(e,f).slice(0,i):e,[n,f,i]);return t(g,{flexDirection:"column",children:q.map((b,C)=>{const x=C===p;return L(g,{children:[V(l,{highlightColor:o??S.colorPrimary,isSelected:x}),V(a,{...b,highlightColor:o??S.colorPrimary,isSelected:x})]},b.key??b.value)})})});var M=de;const ie=I(({maxLength:o=30,defaultValue:e,label:c,showValue:r=!0,value:l})=>{const a=v(),h=$(()=>c+Array.from({length:o-c.length}).fill("").join(" "),[c,o]),d=$(()=>e===l,[e,l]);return L(y,{children:[h,e?t(F,{color:d?a.colorText:a.colorInfo,children:r?l:d?"DEFAULT":"CUSTOM"}):t(F,{color:d?a.colorError:a.colorSuccess,children:r?l:d?"UNSET":"SET"})]})});var fe=ie;const ue=I(({active:o,setActive:e,maxLength:c=30,show:r=!0,items:l,logo:a,title:h,...d})=>{const[s,S]=j(),n=v(),{exit:i}=_(),m=$(()=>[...l.map(u=>({label:t(fe,{defaultValue:u.defaultValue,label:u.label,maxLength:c,showValue:u.showValue,value:u.value}),value:u.key})),{label:"Exit",value:"exit"}],[l]),f=u=>{u.value==="exit"&&i();const p=l.find(T=>T.key===u.value);p&&(S(p),e?.(u.value))};if(r)return o&&s?t(N,{footer:s.desc&&L(y,{color:n.colorTextDescription,children:[t(y,{bold:!0,children:"\u{1F449}NOTE: "}),s.desc]}),title:[a,s.label].filter(Boolean).join(" "),...d,children:s.children}):t(N,{show:!o,title:[a,h].filter(Boolean).join(" "),...d,children:t(M,{items:m,onSelect:f})})});var pe=ue;const he=I(({children:o})=>{const e=v();U(()=>{},[]);const c=Y(Z,{components:{Select:{styles:{focusIndicator:()=>({color:e.colorInfo}),label({isFocused:r,isSelected:l}){let a;return l?a=e.colorSuccess:r&&(a=e.colorPrimary),{color:a}},selectedIndicator:()=>({color:e.colorPrimary})}}}});return t(H,{theme:c,children:o})});var O=he;const me=o=>z(t(O,{children:o}));var xe=me;const be=I(({children:o,direction:e="top",...c})=>{const r=v();return t(g,{borderBottom:e!=="top",borderColor:r.colorBorder,borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:e==="top",flexDirection:"column",...c,children:o})});var ge=be;export{pe as ConfigPanel,N as Panel,M as SelectInput,ge as SplitView,O as ThemeProvider,ee as alert,xe as render,v as useTheme}; | ||
| var _=Object.defineProperty;var h=(o,e)=>_(o,"name",{value:e,configurable:!0});import{consola as D}from"consola";import L from"node:process";import{jsx as t,jsxs as A}from"react/jsx-runtime";import{Box as y,Text as T,useInput as z,useApp as G,render as J}from"ink";import{memo as I,useState as k,useRef as K,useEffect as M,useCallback as X,useMemo as j,createElement as O}from"react";import N from"arr-rotate";import Y from"fast-deep-equal";import Z from"figures";import{Badge as V,extendTheme as H,defaultTheme as ee,ThemeProvider as oe}from"@inkjs/ui";var re={error:h((o,e)=>{D.error(o),e&&L.exit(1)},"error"),info:h((o,e)=>{D.info(o),e&&L.exit(0)},"info"),success:h((o,e)=>{D.success(o),e&&L.exit(0)},"success"),warn:h((o,e)=>{D.warn(o),e&&L.exit(0)},"warn")};const te={blue:"#8ae8ff",cyan:"#95f3d9",geekblue:"#369eff",gold:"#ffcb47",gray:"#777777",green:"#55b467",lime:"#c4f042",magenta:"#e34ba9",orange:"#ff802b",pink:"#eb2f96",purple:"#bd54c6",red:"#f04f88",volcano:"#ec5e41",yellow:"#ffef5c"},ce={colorError:"red",colorInfo:"blue",colorPrimary:"cyan",colorSuccess:"green",colorWarning:"yellow"};var ne={colorBgContainer:"#111111",colorBgElevated:"#222222",colorBgLayout:"#000000",colorBgSpotlight:"#444444",colorBorder:"#333333",colorBorderSecondary:"#2d2d2d",colorText:"#ffffff",colorTextDescription:"#6f6f6f",colorTextPlaceholder:"#555555",colorTextQuaternary:"#555555",colorTextSecondary:"#aaaaaa",colorTextTertiary:"#6f6f6f",...ce,...te};const S=h(()=>ne,"useTheme"),U=I(({show:o=!0,children:e,footer:n,reverse:r=!1,header:l,headerConfig:s,footerConfig:x,bodyConfig:a,title:d,...v})=>{const c=S();if(!o)return;const f=(d||l)&&t(y,{borderColor:c.colorBorder,borderLeft:!1,borderRight:!1,borderStyle:"bold",borderTop:!1,flexDirection:"row",justifyContent:"center",paddingLeft:1,paddingRight:1,...s,children:d?t(T,{bold:!0,children:d.toUpperCase()}):l}),m=t(y,{flexDirection:"column",paddingLeft:1,paddingRight:1,...a,children:e}),i=n&&t(y,{borderBottom:r,borderColor:c.colorBorder,borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!r,flexDirection:"row",paddingLeft:1,paddingRight:1,...x,children:n});return A(y,{alignItems:"stretch",borderColor:c.colorBorder,borderStyle:"bold",flexDirection:"column",...v,children:[f,r?i:m,r?m:i]})}),le=I(({highlightColor:o,isSelected:e=!1})=>t(y,{marginRight:1,children:e?t(T,{color:o,children:Z.pointer}):t(T,{children:" "})})),se=I(({highlightColor:o,isSelected:e=!1,label:n})=>t(T,{color:e?o:void 0,children:n})),$=I(({highlightColor:o,items:e=[],isFocused:n=!0,initialIndex:r=0,indicatorComponent:l=le,itemComponent:s=se,limit:x,onSelect:a,onHighlight:d})=>{const v=S(),c=typeof x=="number"&&e.length>x,f=c?Math.min(x,e.length):e.length,m=f-1,[i,u]=k(r>m?m-r:0),[p,B]=k(r?r>m?m:r:0),F=K(e);M(()=>{Y(F.current.map(g=>g.value),e.map(g=>g.value))||(u(0),B(0)),F.current=e},[e]),z(X((g,C)=>{if(C.upArrow){const b=(c?f:e.length)-1,R=p===0,E=c?p:b,w=R?i+1:i,P=R?E:p-1;u(w),B(P);const W=c?N(e,w).slice(0,f):e;typeof d=="function"&&d(W[P])}if(C.downArrow){const b=p===(c?f:e.length)-1,R=c?p:0,E=b?i-1:i,w=b?R:p+1;u(E),B(w);const P=c?N(e,E).slice(0,f):e;typeof d=="function"&&d(P[w])}if(C.return){const b=c?N(e,i).slice(0,f):e;typeof a=="function"&&a(b[p])}},[c,f,i,p,e,a,d]),{isActive:n});const Q=j(()=>c?N(e,i).slice(0,f):e,[c,i,f]);return t(y,{flexDirection:"column",children:Q.map((g,C)=>{const b=C===p;return A(y,{children:[O(l,{highlightColor:o??v.colorPrimary,isSelected:b}),O(s,{...g,highlightColor:o??v.colorPrimary,isSelected:b})]},g.key??g.value)})})}),de=I(({maxLength:o=30,defaultValue:e,label:n,showValue:r=!0,value:l})=>{const s=S(),x=j(()=>n+Array.from({length:o-n.length}).fill("").join(" "),[n,o]),a=j(()=>e===l,[e,l]);return A(T,{children:[x,e?t(V,{color:a?s.colorText:s.colorInfo,children:r?l:a?"DEFAULT":"CUSTOM"}):t(V,{color:a?s.colorError:s.colorSuccess,children:r?l:a?"UNSET":"SET"})]})}),ae=I(({active:o,setActive:e,maxLength:n=30,show:r=!0,items:l,logo:s,title:x,...a})=>{const[d,v]=k(),c=S(),{exit:f}=G(),m=j(()=>[...l.map(u=>({label:t(de,{defaultValue:u.defaultValue,label:u.label,maxLength:n,showValue:u.showValue,value:u.value}),value:u.key})),{label:"Exit",value:"exit"}],[l]),i=h(u=>{u.value==="exit"&&f();const p=l.find(B=>B.key===u.value);p&&(v(p),e?.(u.value))},"handleSelect");if(r)return o&&d?t(U,{footer:d.desc&&A(T,{color:c.colorTextDescription,children:[t(T,{bold:!0,children:"\u{1F449}NOTE: "}),d.desc]}),title:[s,d.label].filter(Boolean).join(" "),...a,children:d.children}):t(U,{show:!o,title:[s,x].filter(Boolean).join(" "),...a,children:t($,{items:m,onSelect:i})})}),q=I(({children:o})=>{const e=S();M(()=>{},[]);const n=H(ee,{components:{Select:{styles:{focusIndicator:h(()=>({color:e.colorInfo}),"focusIndicator"),label({isFocused:r,isSelected:l}){let s;return l?s=e.colorSuccess:r&&(s=e.colorPrimary),{color:s}},selectedIndicator:h(()=>({color:e.colorPrimary}),"selectedIndicator")}}}});return t(oe,{theme:n,children:o})}),fe=h(o=>J(t(q,{children:o})),"render"),ie=I(({children:o,direction:e="top",...n})=>{const r=S();return t(y,{borderBottom:e!=="top",borderColor:r.colorBorder,borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:e==="top",flexDirection:"column",...n,children:o})});export{ae as ConfigPanel,U as Panel,$ as SelectInput,ie as SplitView,q as ThemeProvider,re as alert,fe as render,S as useTheme}; |
+4
-6
| { | ||
| "name": "@lobehub/cli-ui", | ||
| "version": "1.10.0", | ||
| "version": "1.10.1", | ||
| "description": "Lobe CLI uikits", | ||
@@ -45,10 +45,8 @@ "homepage": "https://github.comlobehub/lobe-cli-toolbox/tree/master/packages/lobe-cli-ui", | ||
| "figures": "^6", | ||
| "ink": "^4.2", | ||
| "react": "^18" | ||
| "ink": "^4.4.1", | ||
| "react": "^18.3.1" | ||
| }, | ||
| "peerDependencies": { | ||
| "@inkjs/ui": ">=1", | ||
| "consola": ">=3", | ||
| "ink": ">=4", | ||
| "react": ">=18" | ||
| "consola": ">=3" | ||
| }, | ||
@@ -55,0 +53,0 @@ "engines": { |
16209
0.27%9
-18.18%Updated
Updated