@visulima/tui-kit 1.0.2 → 1.0.4
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/CHANGELOG.md +15 -0
- package/dist/accordion.js +1 -1
- package/dist/alert.js +1 -1
- package/dist/animate-presence.js +1 -1
- package/dist/approval-prompt.js +1 -1
- package/dist/area-chart.js +1 -1
- package/dist/badge.js +1 -1
- package/dist/bar-chart.js +1 -1
- package/dist/big-text.js +1 -1
- package/dist/blink-dot.js +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar.js +1 -1
- package/dist/card.js +1 -1
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/code.js +2 -2
- package/dist/collapsible.js +1 -1
- package/dist/color-picker.js +1 -1
- package/dist/command-block.js +4 -4
- package/dist/command-palette.js +1 -1
- package/dist/confirm-dialog.js +1 -1
- package/dist/confirm-input.js +1 -1
- package/dist/console-overlay.js +1 -1
- package/dist/content-switcher.js +1 -1
- package/dist/controlled-scroll-view.d.ts +43 -3
- package/dist/controlled-scroll-view.js +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/definition-list.js +1 -1
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.js +1 -1
- package/dist/diff-view.js +1 -1
- package/dist/digits.js +1 -1
- package/dist/directory-tree.js +1 -1
- package/dist/divider.js +1 -1
- package/dist/drawer.js +1 -1
- package/dist/file-change.js +1 -1
- package/dist/file-picker-entry.d.ts +92 -2
- package/dist/file-picker-entry.js +1 -1
- package/dist/form.js +1 -1
- package/dist/gauge.js +1 -1
- package/dist/gradient.js +1 -1
- package/dist/grid.js +1 -1
- package/dist/heading.js +1 -1
- package/dist/heatmap.js +1 -1
- package/dist/help.js +1 -1
- package/dist/histogram.js +1 -1
- package/dist/image.js +1 -1
- package/dist/index.d.ts +25 -9
- package/dist/index.js +1 -1
- package/dist/json.js +1 -1
- package/dist/kbd.js +1 -1
- package/dist/line-chart.js +1 -1
- package/dist/link.js +1 -1
- package/dist/loading-indicator.js +1 -1
- package/dist/log.js +1 -1
- package/dist/markdown.js +1 -1
- package/dist/masked-input.js +1 -1
- package/dist/menu.js +1 -1
- package/dist/message-bubble.js +1 -1
- package/dist/model-badge.js +1 -1
- package/dist/model-selector.js +1 -1
- package/dist/multi-progress.js +1 -1
- package/dist/multi-select.js +1 -1
- package/dist/notification-badge.js +1 -1
- package/dist/number-input.js +1 -1
- package/dist/operation-tree.js +1 -1
- package/dist/option-list.js +1 -1
- package/dist/ordered-list.js +1 -1
- package/dist/packem_shared/ControlledScrollView-soZtm3m7.js +1 -0
- package/dist/packem_shared/FilePicker-KGAg6v5x.js +1 -0
- package/dist/packem_shared/ScrollBar-arHRP6OT.js +1 -0
- package/dist/packem_shared/ScrollBarBox-C8wZ_Slk.js +1 -0
- package/dist/packem_shared/ScrollList-BCqHHps6.js +1 -0
- package/dist/packem_shared/ScrollView-Dt5E9Yl7.js +1 -0
- package/dist/packem_shared/TreeNodeMap-BK7nRlt0.js +1 -0
- package/dist/packem_shared/TreeView-BEZAFOfr.js +1 -0
- package/dist/packem_shared/controlled-scroll-view-BHCYjiKa.js +1 -0
- package/dist/packem_shared/line-chart-BqOUjZTt.js +1 -0
- package/dist/packem_shared/treeViewTheme-DuCcyBDe.js +1 -0
- package/dist/packem_shared/useTreeView-Dt_iWxVs.js +1 -0
- package/dist/packem_shared/useTreeViewState-aHwNZhIE.js +1 -0
- package/dist/packem_shared/{variant-config-BJqpNo7H.js → variant-config-BnAmf1rP.js} +1 -1
- package/dist/paginator.js +1 -1
- package/dist/paragraph.js +1 -1
- package/dist/path-input.js +1 -1
- package/dist/pie-chart.js +1 -1
- package/dist/placeholder.js +1 -1
- package/dist/popover.js +1 -1
- package/dist/progress-bar.js +1 -1
- package/dist/progress-circle.js +1 -1
- package/dist/qr-code.js +1 -1
- package/dist/r/registry.json +9 -0
- package/dist/r/reset.d.json +22 -0
- package/dist/radio-group.js +1 -1
- package/dist/scatter-plot.js +1 -1
- package/dist/scroll-bar-box.d.ts +13 -3
- package/dist/scroll-bar-box.js +1 -1
- package/dist/scroll-bar.d.ts +18 -3
- package/dist/scroll-bar.js +1 -1
- package/dist/scroll-list.d.ts +12 -3
- package/dist/scroll-list.js +1 -1
- package/dist/scroll-view.d.ts +98 -3
- package/dist/scroll-view.js +1 -1
- package/dist/search-input.js +1 -1
- package/dist/select-input-indicator.js +1 -1
- package/dist/select-input-item.js +1 -1
- package/dist/select-input.js +1 -1
- package/dist/shimmer-text.js +1 -1
- package/dist/sidebar.js +1 -1
- package/dist/slider.js +1 -1
- package/dist/sparkline.js +1 -1
- package/dist/spinner.js +1 -1
- package/dist/status-line.js +1 -1
- package/dist/status-message.js +1 -1
- package/dist/stepper.js +1 -1
- package/dist/stopwatch.js +1 -1
- package/dist/streaming-text.js +1 -1
- package/dist/switch.js +1 -1
- package/dist/tab.js +1 -1
- package/dist/table.js +1 -1
- package/dist/tabs.js +1 -1
- package/dist/tag-input.js +1 -1
- package/dist/tag.js +1 -1
- package/dist/text-input.js +1 -1
- package/dist/textarea.js +2 -2
- package/dist/thinking-block.js +1 -1
- package/dist/time-picker.js +1 -1
- package/dist/timer.js +1 -1
- package/dist/toast.js +1 -1
- package/dist/token-usage.js +1 -1
- package/dist/tool-call.js +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/transition.js +1 -1
- package/dist/tree-select.js +1 -1
- package/dist/tree-view-entry.d.ts +314 -4
- package/dist/tree-view-entry.js +1 -1
- package/dist/unordered-list.js +1 -1
- package/dist/use-linked-scroll.d.ts +1 -1
- package/dist/use-linked-scroll.js +1 -1
- package/package.json +8 -8
- package/dist/packem_shared/ControlledScrollView-BzlbIUph.js +0 -1
- package/dist/packem_shared/FilePicker-V5H2fb-v.js +0 -1
- package/dist/packem_shared/ScrollBar-C9i3z3Ft.js +0 -1
- package/dist/packem_shared/ScrollBarBox-DZEC8YnV.js +0 -1
- package/dist/packem_shared/ScrollList-Djtb2vVy.js +0 -1
- package/dist/packem_shared/ScrollView-ESxpl6Hy.js +0 -1
- package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +0 -1
- package/dist/packem_shared/TreeView-q0l446NV.js +0 -1
- package/dist/packem_shared/controlled-scroll-view-DerVKKv6.js +0 -1
- package/dist/packem_shared/controlled-scroll-view.d-D3kZZzjI.d.ts +0 -43
- package/dist/packem_shared/file-picker.d-CH7pccC7.d.ts +0 -92
- package/dist/packem_shared/line-chart-BbhMhcZg.js +0 -1
- package/dist/packem_shared/scroll-bar-box.d-CpTYEcTZ.d.ts +0 -13
- package/dist/packem_shared/scroll-bar.d-B4sD1hBR.d.ts +0 -18
- package/dist/packem_shared/scroll-list.d-CPCF0RwC.d.ts +0 -12
- package/dist/packem_shared/scroll-view.d-GZcgAHl4.d.ts +0 -98
- package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +0 -1
- package/dist/packem_shared/use-tree-view.d-DeMQ6G2r.d.ts +0 -314
- package/dist/packem_shared/useTreeView-D0JEqT6W.js +0 -1
- package/dist/packem_shared/useTreeViewState-BiTJakkh.js +0 -1
package/dist/multi-select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as f,jsxs as j}from"react/jsx-runtime";import y from"@visulima/tui/components/box";import m from"@visulima/tui/components/text";import O from"@visulima/tui/hooks/use-input";import k from"@visulima/tui/hooks/use-window-size";import{useReducer as z,useState as B,useRef as x,useMemo as D,useCallback as g}from"react";const P=[],U=(r,i)=>{switch(i.type){case"focus":return{...r,focusedIndex:i.index};case"focus-next":{const o=r.focusedIndex+1,t=o>=r.visibleFrom+i.limit;return{...r,focusedIndex:o,visibleFrom:t?r.visibleFrom+1:r.visibleFrom}}case"focus-prev":{const o=r.focusedIndex-1,t=o<r.visibleFrom;return{...r,focusedIndex:o,visibleFrom:t?r.visibleFrom-1:r.visibleFrom}}default:return r}};function K({accentColor:r="blue",defaultColor:i,defaultValue:o=P,isDisabled:t=!1,isFocused:v=!0,limit:R,onChange:S,onSubmit:w,options:c}){const{rows:E}=k(),u=Math.min(typeof R=="number"?R:E,c.length),[s,p]=z(U,{focusedIndex:0,visibleFrom:0}),[b,A]=B(o),T=x(b);T.current=b;const C=x(w);C.current=w;const a=x(S);a.current=S;const h=x(s);h.current=s;const L=D(()=>c.slice(s.visibleFrom,s.visibleFrom+u),[c,s.visibleFrom,u]),M=g(()=>{const e=c[h.current.focusedIndex]?.value;e&&A(l=>{const n=l.includes(e)?l.filter(d=>d!==e):[...l,e];return a.current?.(n),n})},[c]),V=g(()=>{A(e=>{const l=e.length===c.length?[]:c.map(n=>n.value);return a.current?.(l),l})},[c]);return O(g((e,l)=>{const{focusedIndex:n}=h.current;(l.downArrow||e==="j")&&n<c.length-1&&p({limit:u,type:"focus-next"}),(l.upArrow||e==="k")&&n>0&&p({limit:u,type:"focus-prev"}),e===" "&&M(),e==="a"&&V(),l.return&&C.current?.(T.current)},[c.length,u,M,V]),{isActive:!t&&v}),f(y,{flexDirection:"column",children:L.map((e,l)=>{const d=s.visibleFrom+l===s.focusedIndex,I=b.includes(e.value);let F=i;return I?F="green":d&&(F=r),j(y,{gap:1,children:[d?f(m,{color:r,dimColor:!v,children:"▸"}):f(m,{children:" "}),j(m,{color:F,dimColor:t,children:[I?"◼":"◻"," ",e.label]}),I?f(m,{color:"green",dimColor:!v,children:"✓"}):void 0]},e.key??e.value)})})}export{K as MultiSelect,K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as a,jsx as e}from"react/jsx-runtime";import t from"@visulima/tui/components/box";import c from"@visulima/tui/components/text";function x({children:r,color:l="red",count:o,max:i=99,showZero:n=!1,textColor:d="white"}){const f=o>0||n,s=o>i?`${i}+`:String(o);return a(t,{children:[r,f?e(t,{marginLeft:r===void 0?0:1,children:e(c,{backgroundColor:l,color:d,children:` ${s} `})}):void 0]})}export{x as NotificationBadge,x as default};
|
package/dist/number-input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as L,jsx as b}from"react/jsx-runtime";import
|
|
1
|
+
import{jsxs as L,jsx as b}from"react/jsx-runtime";import E from"@visulima/tui/components/box";import A from"@visulima/tui/components/text";import M from"@visulima/tui/hooks/use-focus";import O from"@visulima/tui/hooks/use-input";import{useState as P,useRef as U,useCallback as w}from"react";const x=(t,o,f)=>{let e=t;return o!==void 0&&e<o&&(e=o),f!==void 0&&e>f&&(e=f),e},B=(t,o)=>{const f=10**o;return Math.round(t*f)/f},X=/^\d$/;function C(t,o){return o>0?t.toFixed(o):String(t)}function W({accentColor:t="blue",autoFocus:o=!1,defaultValue:f,isDisabled:e=!1,max:v,min:i,onChange:I,onSubmit:N,placeholder:S="0",precision:n=0,showControls:G=!0,step:m=1,value:$}){const{isFocused:F}=M({autoFocus:o,isActive:!e}),d=$!==void 0,[T,g]=P(f===void 0?"":C(f,n)),p=U(I);p.current=I;const u=d?C($,n):T,a=w(s=>{const r=x(B(s,n),i,v);return d||g(C(r,n)),p.current?.(r),r},[d,v,i,n]),c=w(s=>{const r=Number.parseFloat(s);return Number.isFinite(r)?r:0},[]),H=w((s,r)=>{if(r.upArrow){a(c(u)+m);return}if(r.downArrow){a(c(u)-m);return}if(r.pageUp){a(c(u)+m*10);return}if(r.pageDown){a(c(u)-m*10);return}if(r.return){N?.(a(c(u)));return}const h=d?u:T;if(r.backspace||r.delete){const l=h.slice(0,-1);d||g(l),p.current?.(x(B(c(l),n),i,v));return}if(s==="-"&&h.length===0&&(i===void 0||i<0)){d||g("-");return}if(s==="."&&n>0&&!h.includes(".")){d||g(h.length===0?"0.":`${h}.`);return}if(X.test(s)){const l=`${h}${s}`,j=l.indexOf(".");if(j!==-1&&l.length-j-1>n)return;d||g(l),p.current?.(x(B(c(l),n),i,v))}},[T,a,u,d,v,i,N,c,n,m]);O(H,{isActive:F&&!e});const R=u.length===0||u==="-";return L(E,{borderColor:F?t:void 0,borderStyle:"round",paddingX:1,children:[R?b(A,{dimColor:!0,children:S}):b(A,{color:e?void 0:t,dimColor:e,children:u}),F&&!R?b(A,{color:t,children:"▏"}):void 0,G?b(E,{marginLeft:1,children:b(A,{dimColor:!0,children:"▲▼"})}):void 0]})}export{W as NumberInput,W as default};
|
package/dist/operation-tree.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as c,Fragment as C}from"react/jsx-runtime";import l from"@visulima/tui/components/box";import i from"@visulima/tui/components/text";import{Spinner as S}from"./spinner.js";const y={completed:"green",error:"red",pending:"gray",running:"cyan",skipped:"yellow"},k={completed:"✔",error:"✖",pending:"○",skipped:"⊘"},T=n=>{if(n<1e3)return`${Math.round(n)}ms`;if(n<6e4)return`${(n/1e3).toFixed(1)}s`;const r=Math.round(n/1e3),e=Math.floor(r/60),o=r%60;return`${e}m ${o}s`},u=({isLast:n,node:r,prefix:e,showSpinner:o})=>{const a=y[r.status],h=n?"└─ ":"├─ ",p=e.length===0?"":h,s=e+(n?" ":"│ "),m=o?t(S,{type:"dots"}):"…",f=r.status==="running"?m:k[r.status];return c(C,{children:[c(l,{children:[t(i,{dimColor:!0,children:e}),t(i,{dimColor:!0,children:p}),t(l,{flexShrink:0,children:t(i,{color:a,children:f})}),t(i,{children:" "}),t(l,{flexGrow:1,flexShrink:1,minWidth:0,children:t(i,{bold:r.status==="running",color:r.status==="pending"?"gray":void 0,dimColor:r.status==="skipped",wrap:"truncate-end",children:r.label})}),r.durationMs===void 0?void 0:t(l,{flexShrink:0,children:c(i,{dimColor:!0,children:[" ",T(r.durationMs)]})})]}),r.details===void 0?void 0:c(l,{children:[t(i,{dimColor:!0,children:s}),t(i,{dimColor:!0,children:r.details})]}),r.children?.map((d,g,x)=>t(u,{isLast:g===x.length-1,node:d,prefix:s,showSpinner:o},d.id))]})};function b({nodes:n,showSpinner:r=!0}){return t(l,{flexDirection:"column",children:n.map((e,o)=>t(u,{isLast:o===n.length-1,node:e,prefix:"",showSpinner:r},e.id))})}export{b as OperationTree,b as default};
|
package/dist/option-list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r,jsxs as o}from"react/jsx-runtime";import e from"@visulima/tui/components/box";import d from"@visulima/tui/components/text";function v({accentColor:h="blue",bordered:f=!1,currentId:a,iconColumnWidth:l=2,options:s}){const c=r(e,{flexDirection:"column",children:s.map(i=>{const n=i.id===a,t=n?h:void 0;return o(e,{flexDirection:"column",children:[o(e,{children:[r(e,{flexShrink:0,width:l,children:r(d,{color:t,children:i.icon??(n?"▸":" ")})}),r(e,{flexGrow:1,flexShrink:1,minWidth:0,children:r(d,{bold:n,color:t,wrap:"truncate-end",children:i.label})}),i.trailing===void 0?void 0:r(e,{flexShrink:0,children:i.trailing})]}),i.description===void 0?void 0:r(e,{marginLeft:l,children:r(d,{dimColor:!0,wrap:"truncate-end",children:i.description})})]},i.id)})});return f?r(e,{borderStyle:"round",paddingX:1,children:c}):c}export{v as OptionList,v as default};
|
package/dist/ordered-list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as n,jsxs as d}from"react/jsx-runtime";import t from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";const c=(r,a)=>{const h=String(r.length).length;return n(t,{flexDirection:"column",children:r.map((e,o)=>{const m=`${String(o+1).padStart(h)}.`,i=`${a}${m}`;return d(t,{gap:1,children:[n(l,{dimColor:!0,children:i}),d(t,{flexDirection:"column",children:[n(l,{children:e.label}),e.children?c(e.children,i):void 0]})]},o)})})};function f({items:r}){return c(r,"")}export{f as OrderedList,f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as r}from"./controlled-scroll-view-BHCYjiKa.js";export{r as ControlledScrollView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as m,jsx as w}from"react/jsx-runtime";import A from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";import b from"@visulima/tui/hooks/use-input";import{useState as D,useRef as B,useEffect as _,useCallback as v}from"react";import{Spinner as G}from"../spinner.js";import{readdir as W,stat as Y}from"node:fs/promises";import{resolve as j,dirname as q,join as y,extname as J}from"node:path";function N(r){const i=d=>`${d&4?"r":"-"}${d&2?"w":"-"}${d&1?"x":"-"}`;return`${i(r>>6&7)}${i(r>>3&7)}${i(r&7)}`}function O(r,i){if(!(i.showHidden??!1)&&r.isHidden||!(i.showDirectories??!0)&&r.isDirectory||!(i.showFiles??!0)&&!r.isDirectory)return!1;if(i.extensions&&i.extensions.length>0&&!r.isDirectory){const d=J(r.name);if(!i.extensions.includes(d))return!1}return!0}function Q(r){const{filter:i,initialPath:d}=r,[p,M]=D(()=>j(d)),[$,c]=D([]),[P,E]=D(!0),[C,F]=D(),[L,t]=D(0),I=B(i);I.current=i,_(()=>{let n=!1;return(async()=>{E(!0),F(void 0);try{const f=await W(p,{withFileTypes:!0}),T=await Promise.all(f.map(async e=>{try{return await Y(y(p,e.name))}catch{return}})),o=f.map((e,h)=>{const R=y(p,e.name),S=e.isDirectory(),H=e.name.startsWith("."),z=T[h],K=z?.size??0,U=z?N(z.mode):"---------";return{isDirectory:S,isHidden:H,name:e.name,path:R,permissions:U,size:K}});if(n)return;const s=o.filter(e=>O(e,I.current));s.sort((e,h)=>e.isDirectory!==h.isDirectory?e.isDirectory?-1:1:e.name.localeCompare(h.name,void 0,{sensitivity:"base"})),c(s)}catch(f){n||(F(f instanceof Error?f.message:String(f)),c([]))}finally{n||E(!1)}})().catch(()=>{}),()=>{n=!0}},[p,L]);const a=v(n=>{M(j(n))},[]),x=v(()=>{M(n=>{const u=q(n);return u===n?n:u})},[]),g=v(()=>{t(n=>n+1)},[]);return{currentPath:p,entries:$,error:C,goUp:x,isLoading:P,navigateTo:a,refresh:g}}function V(r){return r<1024?`${r}B`:r<1024*1024?`${(r/1024).toFixed(1)}K`:r<1024*1024*1024?`${(r/(1024*1024)).toFixed(1)}M`:`${(r/(1024*1024*1024)).toFixed(1)}G`}const X={},Z=()=>process.cwd(),ce=({accentColor:r="cyan",directoryColor:i="blue",fileColor:d="white",filter:p=X,initialPath:M,isFocused:$=!0,limit:c=10,onCancel:P,onSelect:E,showPermissions:C=!1,showSize:F=!1})=>{const L=M??Z(),t=Q({filter:p,initialPath:L}),[I,a]=D(0),x=Math.max(0,t.entries.length-1),g=Math.min(I,x);b(v((o,s)=>{if(s.upArrow)a(e=>Math.max(0,e-1));else if(s.downArrow)a(e=>Math.min(x,e+1));else if(s.return){const e=t.entries[g];e&&(e.isDirectory?(t.navigateTo(e.path),a(0)):E?.(e))}else s.backspace||s.leftArrow?(t.goUp(),a(0)):s.escape?P?.():o==="."?t.refresh():s.pageUp?a(e=>Math.max(0,e-c)):s.pageDown?a(e=>Math.min(x,e+c)):s.home?a(0):s.end&&a(x)},[x,g,t,c,E,P]),{isActive:$});const n=Math.floor(c/2);let u=Math.max(0,g-n);const f=Math.min(t.entries.length,u+c);u=Math.max(0,f-c);const T=t.entries.slice(u,f);return m(A,{flexDirection:"column",children:[w(l,{bold:!0,dimColor:!0,children:t.currentPath}),t.isLoading&&m(A,{children:[w(G,{}),w(l,{children:" Loading..."})]}),t.error&&m(l,{color:"red",children:["Error:",t.error]}),!t.isLoading&&!t.error&&t.entries.length===0&&w(l,{dimColor:!0,children:"(empty directory)"}),T.map((o,s)=>{const h=u+s===g,R=o.isDirectory?"📁 ":"📄 ",S=o.isDirectory?i:d;return m(A,{children:[w(l,{color:h?r:void 0,children:h?"▸ ":" "}),w(l,{children:R}),m(l,{bold:o.isDirectory,color:h?r:S,children:[o.name,o.isDirectory?"/":""]}),F&&!o.isDirectory&&m(l,{dimColor:!0,children:[" ",V(o.size)]}),C&&m(l,{dimColor:!0,children:[" ",o.permissions]})]},o.name)}),t.entries.length>c&&m(l,{dimColor:!0,children:[g+1,"/",t.entries.length]})]})};export{ce as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as m,jsxs as O}from"react/jsx-runtime";import D from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";import{useMemo as P}from"react";const E={arrow:{lowerThumb:"╽",thumb:"┃",track:"|",upperThumb:"╿"},block:{thumb:"█",track:"░"},bold:{lowerThumb:"╿",thumb:"│",track:"┃",upperThumb:"╽"},classic:{thumb:"┃",track:"|"},dots:{thumb:"●",track:"·"},double:{thumb:"┃",track:"║"},doubleSingle:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},line:{thumb:"│",track:" "},round:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},single:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},singleDouble:{thumb:"┃",track:"║"},thick:{thumb:"┃",track:"╏"}},j={arrow:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},bold:{bottomLeft:"┗",bottomRight:"┛",topLeft:"┏",topRight:"┓"},classic:{bottomLeft:"+",bottomRight:"+",topLeft:"+",topRight:"+"},double:{bottomLeft:"╚",bottomRight:"╝",topLeft:"╔",topRight:"╗"},doubleSingle:{bottomLeft:"╘",bottomRight:"╛",topLeft:"╒",topRight:"╕"},round:{bottomLeft:"╰",bottomRight:"╯",topLeft:"╭",topRight:"╮"},single:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},singleDouble:{bottomLeft:"╙",bottomRight:"╜",topLeft:"╓",topRight:"╖"}},Y=t=>E[typeof t=="string"?t:"single"]??E.single??{thumb:"┃",track:"│"},q=t=>j[typeof t=="string"?t:"single"]??j.single??{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},K=({autoHide:t=!1,color:h,contentHeight:k,dimColor:u,placement:c="right",scrollOffset:L,style:i,thumbChar:T,trackChar:d,viewportHeight:e})=>{const f=P(()=>{const r=Math.max(k,e);if(t&&r<=e)return null;const o=Y(i),a=T??o.thumb,H=d??o.track,x=e*2,I=Math.min(e/r,1),S=Math.max(2,Math.round(x*I)),w=r-e,_=w>0?Math.min(Math.max(L/w,0),1):0,N=x-S,p=Math.round(_*N),C=p+S,n=[];for(let b=0;b<e;b+=1){const M=b*2,y=b*2+1,g=M>=p&&M<C,R=y>=p&&y<C;g&&R?n.push(a):g&&!R?n.push(o.lowerThumb??a):!g&&R?n.push(o.upperThumb??a):n.push(H)}return n},[k,e,L,i,T,d,t]);if(f===null)return null;if(c==="inset")return m(D,{flexDirection:"column",flexShrink:0,width:1,children:f.map((r,o)=>m(l,{color:h,dimColor:u,children:r},o))});const s=q(i),A=c==="left"?s.topLeft:s.topRight,B=c==="left"?s.bottomLeft:s.bottomRight;return O(D,{flexDirection:"column",flexShrink:0,width:1,children:[m(l,{color:h,dimColor:u,children:A}),f.map((r,o)=>m(l,{color:h,dimColor:u,children:r},o)),m(l,{color:h,dimColor:u,children:B})]})};export{K as ScrollBar};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as P,jsx as c}from"react/jsx-runtime";import B from"@visulima/tui/components/box";import{ScrollBar as p}from"./ScrollBar-arHRP6OT.js";const v=({borderColor:l,borderDimColor:r,borderLeftColor:d,borderLeftDimColor:g,borderRightColor:j,borderRightDimColor:w,borderStyle:t="single",children:L,contentHeight:s,height:h,scrollBarAutoHide:e=!1,scrollBarPosition:u="right",scrollOffset:i,thumbChar:n,viewportHeight:a,...G})=>{const o=u==="left",f=o?"left":"right",m=o?d??l:j??l,x=o?g??r:w??r;return P(B,{flexDirection:"row",height:h,...G,children:[o&&c(p,{autoHide:e,color:m,contentHeight:s,dimColor:x,placement:f,scrollOffset:i,style:t,thumbChar:n,viewportHeight:a}),c(B,{borderColor:l,borderDimColor:r,borderLeft:!o,borderRight:o,borderStyle:t,flexGrow:1,overflow:"hidden",children:L}),!o&&c(p,{autoHide:e,color:m,contentHeight:s,dimColor:x,placement:f,scrollOffset:i,style:t,thumbChar:n,viewportHeight:a})]})};export{v as ScrollBarBox};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as K}from"react/jsx-runtime";import N from"@visulima/tui/hooks/use-scroll-input";import{useRef as w,useState as Q,useEffect as P,useCallback as a,useImperativeHandle as U}from"react";import{C as X}from"./controlled-scroll-view-BHCYjiKa.js";const ot=R=>{const{children:y,keyboard:Y=!1,onContentHeightChange:V,onItemHeightChange:M,onScroll:B,onViewportSizeChange:T,overscan:z,ref:A,scrollAlignment:m="auto",selectedIndex:p,vimBindings:F=!1,virtualize:j,...E}=R,n=w(null),[s,L]=Q(0),H=w(0);P(()=>{H.current=s},[s]);const r=a(t=>{t!==H.current&&(L(t),B?.(t))},[B]),h=w(p);h.current=p;const b=a(()=>{const t=h.current;if(t===void 0||t<0)return null;const e=n.current?.getItemPosition(t);if(!e)return null;const c=n.current?.getViewportHeight()??0,l=n.current?.getContentHeight()??0;let o=e.top+e.height-c,i=e.top;o>i&&([o,i]=[i,o]);const x=Math.max(0,l-c);return{max:Math.min(x,i),min:Math.max(0,o)}},[]),g=a(t=>{const e=n.current?.getContentHeight()??0,c=n.current?.getViewportHeight()??0,l=Math.max(0,e-c);let o=Math.max(0,Math.min(t,l));const i=b();return i&&(o=Math.max(i.min,Math.min(o,i.max))),o},[b]),u=a((t,e,c,l)=>{const o=n.current?.getItemPosition(t);if(!o)return e;const i=l??n.current?.getViewportHeight()??0,x=n.current?.getContentHeight()??0;let f=e;switch(c){case"bottom":{f=o.top+o.height-i;break}case"center":{f=o.top+o.height/2-i/2;break}case"top":{f=o.top;break}default:{const v=o.top+o.height;o.top<=e&&v>=e+i?f=e:o.top<e?f=o.top:v>e+i&&(f=v-i)}}const J=Math.max(0,x-i);return Math.max(0,Math.min(f,J))},[]);let d=s;p!==void 0&&p>=0&&(d=u(p,s,m)),P(()=>{d!==s&&r(d)},[d,s,r]);const O=a((t,e)=>{if(h.current!==void 0&&h.current>=0){const c=u(h.current,s,m,t.height);r(c)}T?.(t,e)},[T,u,s,m,r]),W=a((t,e,c)=>{const l=h.current;if(l!==void 0&&l>=0){if(t<l){const o=g(s+(e-c));r(o)}else if(t===l){const o=u(t,s,m);r(o)}}M?.(t,e,c)},[M,u,m,s,g,r]),q=a((t,e)=>{if(h.current!==void 0&&h.current>=0){const c=u(h.current,s,m);r(c)}V?.(t,e)},[V,u,s,m,r]),k=w(0),C=a(t=>{const e=H.current,c=g(e+t);r(c)},[g,r]),S=a(()=>{const t=n.current?.getContentHeight()??0,e=n.current?.getViewportHeight()??0,c=Math.max(0,t-e),l=g(c);r(l)},[g,r]),I=a(()=>{const t=g(0);r(t)},[g,r]),D=a(()=>k.current,[]);N({getViewportHeight:D,isActive:Y,scrollBy:C,scrollToBottom:S,scrollToTop:I,vimBindings:F}),U(A,()=>({getBottomOffset:()=>n.current?.getBottomOffset()??0,getContentHeight:()=>n.current?.getContentHeight()??0,getItemHeight:t=>n.current?.getItemHeight(t)??0,getItemPosition:t=>n.current?.getItemPosition(t)??null,getScrollOffset:()=>H.current,getViewportHeight:()=>n.current?.getViewportHeight()??0,remeasure:()=>n.current?.remeasure(),remeasureItem:t=>n.current?.remeasureItem(t),scrollBy:C,scrollTo:t=>{const e=g(t);r(e)},scrollToBottom:S,scrollToTop:I}),[g,r,C,S,I]);const G=a((t,e)=>{k.current=t.height,O(t,e)},[O]);return K(X,{onContentHeightChange:q,onItemHeightChange:W,onViewportSizeChange:G,overscan:z,ref:n,scrollOffset:d,virtualize:j,...E,children:y})};export{ot as ScrollList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as z,jsx as b}from"react/jsx-runtime";import E from"@visulima/tui/components/box";import P from"@visulima/tui/hooks/use-scroll-input";import{useRef as u,useState as J,useCallback as o,useImperativeHandle as tt}from"react";import{u as et,C as K}from"./controlled-scroll-view-BHCYjiKa.js";import{ScrollBar as rt}from"./ScrollBar-arHRP6OT.js";const mt=({children:M,debug:y=!1,followOutput:T=!1,followThreshold:V=3,keyboard:L=!1,onContentHeightChange:v,onItemHeightChange:N,onReachEnd:g,onReachStart:S,onScroll:O,onViewportSizeChange:k,overscan:R,reachThreshold:i=5,ref:Q,scrollbar:U=!1,scrollbarColor:W,scrollbarStyle:X="line",vimBindings:Y=!1,virtualize:G,...f})=>{const[x,j,n]=et(0),s=u(null),a=u(0),c=u(0),[A,Z]=J(0),[w,_]=J(0),H=u(!1),h=u(!1),l=o(()=>Math.max(0,a.current-c.current),[]),F=o(t=>{const r=l();g&&t>=r-i&&!H.current?(H.current=!0,g()):t<r-i&&(H.current=!1),S&&t<=i&&!h.current?(h.current=!0,S()):t>i&&(h.current=!1)},[g,S,i,l]),e=o(t=>{t!==n()&&(j(t),O?.(t),F(t))},[n,j,O,F]),D=o((t,r)=>{const m=n()>=l()-V;if(a.current=t,Z(t),v?.(t,r),T&&m&&t>r){const p=Math.max(0,t-c.current);e(p)}else{const p=Math.max(0,t-c.current);n()>p&&e(p)}},[v,T,V,n,l,e]),d=o((t,r)=>{c.current=t.height,_(t.height),k?.(t,r)},[k]),B=o(t=>{if(typeof t!="number"||Number.isNaN(t))return;const r=Math.max(0,a.current-c.current),m=Math.max(0,Math.min(n()+t,r));e(m)},[n,e]),q=o(t=>{if(typeof t!="number"||Number.isNaN(t))return;const r=Math.max(0,a.current-c.current),m=Math.max(0,Math.min(t,r));e(m)},[e]),C=o(()=>{const t=l();e(t)},[l,e]),I=o(()=>{e(0)},[e]),$=o(()=>c.current,[]);return P({getViewportHeight:$,isActive:L,scrollBy:B,scrollToBottom:C,scrollToTop:I,vimBindings:Y}),tt(Q,()=>({getBottomOffset:l,getContentHeight:()=>a.current,getItemHeight:t=>s.current?.getItemHeight(t)??0,getItemPosition:t=>s.current?.getItemPosition(t)??null,getScrollOffset:n,getViewportHeight:()=>c.current,remeasure:()=>s.current?.remeasure(),remeasureItem:t=>s.current?.remeasureItem(t),scrollBy:B,scrollTo:q,scrollToBottom:C,scrollToTop:I}),[l,n,B,q,C,I]),U&&A>w&&w>0?z(E,{flexDirection:"row",flexGrow:f.flexGrow,flexShrink:f.flexShrink,overflow:"hidden",children:[b(K,{children:M,debug:y,onContentHeightChange:D,onItemHeightChange:N,onViewportSizeChange:d,overscan:R,ref:s,scrollOffset:x,virtualize:G,...f,flexGrow:1}),b(rt,{color:W,contentHeight:A,placement:"inset",scrollOffset:x,style:X,viewportHeight:w})]}):b(K,{children:M,debug:y,onContentHeightChange:D,onItemHeightChange:N,onViewportSizeChange:d,overscan:R,ref:s,scrollOffset:x,virtualize:G,...f})};export{mt as ScrollView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class c{orderedIds;rootIds;map;constructor(n){this.map=new Map,this.orderedIds=[],this.rootIds=[],this.buildFromData(n)}entries(){return this.map.entries()}get(n){return this.map.get(n)}get size(){return this.map.size}getVisibleIds(n){const s=[],i=[];for(let t=this.rootIds.length-1;t>=0;t--)i.push(this.rootIds[t]);for(;i.length>0;){const t=i.pop();s.push(t);const r=this.map.get(t);if(r&&n.has(t)&&r.childrenIds.length>0)for(let e=r.childrenIds.length-1;e>=0;e--)i.push(r.childrenIds[e])}return s}isDescendantOf(n,s){let i=n;for(;i!==void 0;){const t=this.map.get(i);if(!t)return!1;if(t.parentId===s)return!0;i=t.parentId}return!1}withChildren(n,s){if(!this.map.get(n))return this;const t=e=>{const d=this.map.get(e);return e===n?{...d.node,children:s}:d.childrenIds.length>0?{...d.node,children:d.childrenIds.map(o=>t(o))}:d.node},r=this.rootIds.map(e=>t(e));return new c(r)}buildFromData(n){const s=[];for(let t=n.length-1;t>=0;t--)s.push({depth:0,node:n[t],parentId:void 0,siblingIndex:t,siblings:n});for(const t of n)this.rootIds.push(t.id);let i=0;for(;s.length>0;){const t=s.pop(),{depth:r,node:e,parentId:d,siblingIndex:o,siblings:a}=t;if(this.map.has(e.id))throw new Error(`TreeView: Duplicate node id '${e.id}' found. All node ids must be unique.`);const l=e.children??[],p=l.length>0||e.isParent===!0,u=l.map(h=>h.id),g=o>0?a[o-1].id:void 0,I=o<a.length-1?a[o+1].id:void 0,f={childrenIds:u,depth:r,flatIndex:i,hasChildren:p,nextSiblingId:I,node:e,parentId:d,previousSiblingId:g,siblingCount:a.length,siblingIndex:o};if(this.map.set(e.id,f),this.orderedIds.push(e.id),i++,p)for(let h=l.length-1;h>=0;h--)s.push({depth:r+1,node:l[h],parentId:e.id,siblingIndex:h,siblings:l})}}}export{c as TreeNodeMap};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{theme as A}from"./treeViewTheme-DuCcyBDe.js";import"./TreeNodeMap-BK7nRlt0.js";import{jsxs as m,jsx as o}from"react/jsx-runtime";import w from"@visulima/tui/components/box";import n from"@visulima/tui/components/text";import R from"@visulima/tui/hooks/use-is-screen-reader-enabled";import{useTreeView as F}from"./useTreeView-Dt_iWxVs.js";import{useTreeViewState as $}from"./useTreeViewState-aHwNZhIE.js";const j="❯",G="▾",V="▸",_="☒",B="☐",D="✔",H="⟳";function L(t,l,i,d){const{depth:c,hasChildren:b,isExpanded:r,isLoading:p,isSelected:f}=l,a=[t,`item ${i} of ${d}`];return c>0&&a.push(`depth ${c}`),b&&a.push(r?"expanded":"collapsed"),p&&a.push("loading"),f&&a.push("selected"),a.join(", ")}function O(t,l){const i={};return t.hasChildren&&(i.expanded=t.isExpanded),l!=="none"&&(i.selected=t.isSelected),Object.keys(i).length>0?i:void 0}function K({isScreenReaderEnabled:t,node:l,nodeState:i,selectionMode:d,siblingCount:c,siblingPosition:b,styles:r}){const{depth:p,hasChildren:f,isExpanded:a,isFocused:h,isLoading:s,isSelected:x}=i;let e=" ";s?e=H:f&&(e=a?G:V);const I=t?L(l.label,i,b,c):void 0;return m(w,{...r.node({isFocused:h}),"aria-role":"listitem","aria-state":O(i,d),children:[I&&o(n,{"aria-label":I}),h&&o(n,{...r.focusIndicator(),"aria-hidden":!0,children:j}),p>0&&o(w,{...r.indent({depth:p}),"aria-hidden":!0}),d==="multiple"&&o(n,{...r.selectedIndicator(),"aria-hidden":!0,children:x?_:B}),o(n,{...s?r.loadingIndicator():r.expandIndicator({isExpanded:a}),"aria-hidden":!0,children:e}),o(n,{...r.label({isFocused:h,isSelected:x}),children:l.label}),d==="single"&&x&&m(n,{...r.selectedIndicator(),"aria-hidden":!0,children:[" ",D]})]})}function J({ariaLabel:t="Tree view",data:l,defaultExpanded:i,defaultSelected:d,isDisabled:c=!1,loadChildren:b,onExpandChange:r,onFocusChange:p,onLoadError:f,onSelectChange:a,renderNode:h,selectionMode:s="none",visibleNodeCount:x}){const e=$({data:l,defaultExpanded:i,defaultSelected:d,onExpandChange:r,onFocusChange:p,onSelectChange:a,selectionMode:s,visibleNodeCount:x});F({isDisabled:c,loadChildren:b,onLoadError:f,selectionMode:s,state:e});const{styles:I}=A,T=R();return m(w,{...I.container(),"aria-role":"list",children:[T&&o(n,{"aria-label":t}),e.hasScrollUp&&m(n,{"aria-label":`${e.viewportFromIndex} more items above`,dimColor:!0,children:[" ","↑",e.viewportFromIndex," ","more above"]}),e.viewportNodes.map(({node:u,state:C})=>{const v=e.nodeMap.get(u.id),g=v?v.siblingIndex+1:1,E=v?v.siblingCount:1;if(h){const N=T?L(u.label,C,g,E):void 0;return m(w,{"aria-role":"listitem","aria-state":O(C,s),children:[N&&o(n,{"aria-label":N}),h({node:u,state:C})]},u.id)}return o(K,{isScreenReaderEnabled:T,node:u,nodeState:C,selectionMode:s,siblingCount:E,siblingPosition:g,styles:I},u.id)}),e.hasScrollDown&&m(n,{"aria-label":`${e.visibleCount-e.viewportToIndex} more items below`,dimColor:!0,children:[" ","↓",e.visibleCount-e.viewportToIndex," ","more below"]})]})}export{J as TreeView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as S,jsxs as rt}from"react/jsx-runtime";import{measureElement as W}from"@visulima/tui";import M from"@visulima/tui/components/box";import{useState as X,useRef as y,useCallback as z,useLayoutEffect as _,isValidElement as C,useImperativeHandle as nt,Fragment as Q}from"react";const U=c=>{const[m,g]=X(c),l=y(c),K=z(H=>{const A=typeof H=="function"?H(l.current):H;l.current=A,g(A)},[]),I=z(()=>l.current,[]);return[m,K,I]},ct=({children:c,index:m,measureKey:g,onMeasure:l,width:K})=>{const I=y(null);return _(()=>{if(I.current){const{height:H}=W(I.current);l(m,H)}},[m,l,K,g,c]),S(M,{flexDirection:"column",flexShrink:0,ref:I,width:"100%",children:c})},T=c=>{if(c==null)return[];if(Array.isArray(c)){const m=[];for(let g=0;g<c.length;g+=1){const l=c[g];C(l)&&l.type===Q?m.push(...T(l.props.children)):m.push(l)}return m}return C(c)&&c.type===Q?T(c.props.children):[c]},ft=({children:c,debug:m=!1,onContentHeightChange:g,onItemHeightChange:l,onViewportSizeChange:K,overscan:I=3,ref:H,scrollOffset:A,virtualize:Y=!1,...Z})=>{const O=y(!1),[q,G,V]=U({height:0,width:0}),[d,j,E]=U(0),[$,J]=X({}),B=y(null),D=y(0);_(()=>{d!==D.current&&(g?.(d,D.current),D.current=d)},[d,g]);const o=y({}),i=y([]),p=y([]),h=y(0),x=z((t,e)=>{const r=i.current[t]??t;if(o.current[r]!==e){const f=o.current[r]??0;o.current={...o.current,[r]:e};let n=0;for(let u=0;u<i.current.length;u+=1){const k=i.current[u];k!=null&&(n+=o.current[k]??0)}const s=E();n!==s&&j(n),l?.(t,e,f),h.current=Math.min(h.current,t+1)}},[l,E,j]),F=z(()=>{if(B.current){const{height:t,width:e}=W(B.current),r=V();(e!==r.width||t!==r.height)&&(K?.({height:t,width:e},r),G({height:t,width:e}))}},[B,K,V,G]);_(()=>{F()});const N=y(null);if(N.current!==c){N.current=c;const t=[],e={};T(c).forEach((s,u)=>{if(!s)return;const R=(C(s)?s.key:null)??u;t[u]=R;const et=o.current[R]??0;e[R]=et}),o.current=e,i.current=t,p.current=Array.from({length:t.length}).fill(0),h.current=0;let f=0;t.forEach(s=>{f+=e[s]??0});const n=E();f!==n&&j(f)}nt(H,()=>({getBottomOffset:()=>Math.max(0,E()-V().height),getContentHeight:E,getItemHeight:t=>{const e=i.current[t]??t;return o.current[e]??0},getItemPosition:t=>{if(t<0||t>=i.current.length)return null;if(t>=h.current){let n=0,s=0;if(h.current>0){s=h.current;const u=s-1,k=i.current[u]??u,R=o.current[k]??0;n=(p.current[u]??0)+R}for(let u=s;u<=t;u+=1){p.current[u]=n;const k=i.current[u]??u,R=o.current[k]??0;n+=R}h.current=t+1}const e=p.current[t]??0,r=i.current[t]??t;return{height:o.current[r]??0,top:e}},getViewportHeight:()=>V().height,remeasure:F,remeasureItem:t=>{J(e=>({...e,[t]:(e[t]??0)+1}))}}),[F,E,V,J]);const v=T(c);!O.current&&d>0&&(O.current=!0);let w=0,a=v.length-1,L=0,P=0;const tt=v.length>0&&v.every((t,e)=>{const r=i.current[e]??e;return(o.current[r]??0)>0}),b=Y&&O.current&&tt;if(b){const t=i.current.length;if(h.current<t){let r=0,f=0;if(h.current>0){f=h.current;const n=f-1,s=i.current[n]??n,u=o.current[s]??0;r=(p.current[n]??0)+u}for(let n=f;n<t;n+=1){p.current[n]=r;const s=i.current[n]??n;r+=o.current[s]??0}h.current=t}const e=A+q.height;w=v.length,a=-1;for(let r=0;r<t;r+=1){const f=p.current[r]??0,n=i.current[r]??r,s=o.current[n]??0;f+s>A&&f<e&&(r<w&&(w=r),a=r)}if(w>a&&(w=0,a=-1),w=Math.max(0,w-I),a=Math.min(v.length-1,Math.max(-1,a)+I),L=p.current[w]??0,a<v.length-1){const r=i.current[a]??a,f=(p.current[a]??0)+(o.current[r]??0);P=d-f}}return S(M,{...Z,children:S(M,{ref:B,width:"100%",children:S(M,{overflow:m?void 0:"hidden",width:"100%",children:rt(M,{flexDirection:"column",marginTop:-A,width:"100%",children:[b&&L>0&&S(M,{height:L}),v.map((t,e)=>!t||b&&(e<w||e>a)?null:S(ct,{index:e,measureKey:$[e],onMeasure:x,width:q.width,children:t},C(t)?t.key??e:e)),b&&P>0&&S(M,{height:P})]})})})})};export{ft as C,U as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as y,jsx as M}from"react/jsx-runtime";import{createBrailleGrid as h}from"@visulima/tui/canvas";import p from"@visulima/tui/components/box";import T from"@visulima/tui/components/canvas";import N from"@visulima/tui/components/text";import{useMemo as f}from"react";const E=["cyan","magenta","yellow","green","blue","red"],d=r=>r.length===0?[]:typeof r[0]=="number"?r.map((e,s)=>({x:s,y:e})):r,b=(r,n,e)=>r.color??e[n%e.length]??"cyan",_=r=>{let n=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(const{points:l}of r)for(const o of l)o.x<n&&(n=o.x),o.x>e&&(e=o.x),o.y<s&&(s=o.y),o.y>a&&(a=o.y);return{xMax:e,xMin:n,yMax:a,yMin:s}},F=E,u=(r,n,e,s)=>{const a=n.xMax-n.xMin||1,l=n.yMax-n.yMin||1,o=(r.x-n.xMin)/a,c=(r.y-n.yMin)/l;return{px:Math.max(0,Math.min(e-1,Math.round(o*(e-1)))),py:Math.max(0,Math.min(s-1,Math.round((1-c)*(s-1))))}},L=(r,n,e)=>{r.clear();const{axisColor:s,seriesList:a}=e,l=Math.max(1,r.width*2),o=Math.max(1,r.height*4);for(let c=0;c<r.width;c+=2)r.setCell(c,r.height-1,"·",{color:s,dim:!0});for(const{color:c,points:x}of a){if(x.length===0)continue;const I=h(r.width,r.height);if(n==="scatter")for(const t of x){const i=u(t,e,l,o);I.plotPoint(i.px,i.py)}else{let t=u(x[0],e,l,o);I.plotPoint(t.px,t.py);for(let i=1;i<x.length;i+=1){const m=u(x[i],e,l,o);I.plotLine(t.px,t.py,m.px,m.py),t=m}}I.flush(r,{color:c})}};function w({axisColor:r="gray",height:n=10,maxY:e,minY:s,palette:a=F,series:l,showLegend:o=!0,width:c=40}){const x=f(()=>{const I=l.map((i,m)=>({color:b(i,m,a),points:d(i.data),series:i})),t=_(I);return{axisColor:r,palette:a,seriesList:I,xMax:t.xMax===Number.NEGATIVE_INFINITY?1:t.xMax,xMin:t.xMin===Number.POSITIVE_INFINITY?0:t.xMin,yMax:e??(t.yMax===Number.NEGATIVE_INFINITY?1:t.yMax),yMin:s??(t.yMin===Number.POSITIVE_INFINITY?0:t.yMin)}},[l,r,a,s,e]);return y(p,{flexDirection:"column",children:[M(T,{draw:I=>{L(I,"line",x)},height:n,version:[l,c,n,s,e,r,a],width:c}),o?M(p,{gap:2,marginTop:1,children:x.seriesList.map(({color:I,series:t},i)=>y(p,{gap:1,children:[M(N,{color:I,children:"●"}),M(N,{children:t.label??`Series ${i+1}`})]},`${i}:${t.label??""}`))}):void 0]})}export{E as D,w as L,u as a,_ as c,L as d,b as p,d as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o={styles:{container:()=>({flexDirection:"column"}),expandIndicator:r=>({color:"gray"}),focusIndicator:()=>({color:"blue"}),indent:({depth:r})=>({width:(r??0)*2}),label:({isFocused:r,isSelected:n})=>{let e;return n&&(e="green"),r&&(e="blue"),{color:e}},loadingIndicator:()=>({color:"yellow"}),node:({isFocused:r})=>({gap:1,paddingLeft:r?0:2}),selectedIndicator:()=>({color:"green"})}};export{o as theme};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import p from"@visulima/tui/hooks/use-input";import{useRef as o,useCallback as w}from"react";function E({isDisabled:g=!1,loadChildren:i,onLoadError:l,selectionMode:d,state:r}){const s=o(new Set),c=o(r);c.current=r;const t=o(i);t.current=i;const h=o(l);h.current=l;const x=w(async e=>{if(s.current.has(e))return;const n=t.current;if(!n)return;const f=c.current.nodeMap.get(e);if(!(!f||f.childrenIds.length>0)){s.current.add(e),c.current.setLoading(e,!0);try{const u=await n(f.node);c.current.insertChildren(e,u),c.current.expandNode(e)}catch(u){const a=u instanceof Error?u:new Error(String(u));c.current.setChildrenError(e),h.current?.(e,a)}finally{c.current.setLoading(e,!1),s.current.delete(e)}}},[]);p((e,n)=>{if(n.downArrow){r.focusNext();return}if(n.upArrow){r.focusPrevious();return}if(n.rightArrow){if(r.focusedId&&r.expandedIds.has(r.focusedId))r.focusFirstChild();else if(r.focusedId){if(i){const f=r.nodeMap.get(r.focusedId);if(f&&f.hasChildren&&f.childrenIds.length===0){x(r.focusedId).catch(()=>{});return}}r.expand()}return}if(n.leftArrow){r.focusedId&&r.expandedIds.has(r.focusedId)?r.collapse():r.focusParent();return}if(n.return){d==="none"?r.toggleExpanded():r.select();return}if(e===" "){d==="multiple"?r.select():r.toggleExpanded();return}if(e==="\x1B[H"||e==="\x1B[1~"||e==="\x1BOH"){r.focusFirst();return}(e==="\x1B[F"||e==="\x1B[4~"||e==="\x1BOF")&&r.focusLast()},{isActive:!g})}export{E as useTreeView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useReducer as H,useState as J,useRef as h,useEffect as b,useMemo as K,useCallback as I}from"react";import{TreeNodeMap as Q}from"./TreeNodeMap-BK7nRlt0.js";function x(e){const s=new Map;for(const[d,n]of e.entries())s.set(n,d);return s}function t(e,s){if(e.visibleNodeCount>=e.visibleIds.length)return{viewportFromIndex:0,viewportToIndex:e.visibleIds.length};let d=e.viewportFromIndex,n=e.viewportToIndex;return s>=n&&(n=s+1,d=n-e.visibleNodeCount),s<d&&(d=s,n=d+e.visibleNodeCount),{viewportFromIndex:Math.max(0,d),viewportToIndex:Math.min(e.visibleIds.length,n)}}function a(e,s){if(e.visibleNodeCount>=s.length)return{viewportFromIndex:0,viewportToIndex:s.length};const d=e.focusedId?s.indexOf(e.focusedId):-1;if(d<0)return{viewportFromIndex:0,viewportToIndex:Math.min(e.visibleNodeCount,s.length)};let n=Math.min(e.viewportToIndex,s.length),i=Math.max(0,n-e.visibleNodeCount);return d>=n&&(n=d+1,i=n-e.visibleNodeCount),d<i&&(i=d,n=i+e.visibleNodeCount),{viewportFromIndex:Math.max(0,i),viewportToIndex:Math.min(s.length,n)}}function v(e,s){switch(s.type){case"collapse":return e.focusedId?v(e,{nodeId:e.focusedId,type:"collapse-node"}):e;case"collapse-all":{const d=new Set,n=e.nodeMap.getVisibleIds(d);return{...e,expandedIds:d,focusedId:n[0],previousExpandedIds:e.expandedIds,viewportFromIndex:0,viewportToIndex:Math.min(e.visibleNodeCount,n.length),visibleIdIndex:x(n),visibleIds:n}}case"collapse-node":{const{nodeId:d}=s;if(!e.expandedIds.has(d))return e;const n=new Set(e.expandedIds);n.delete(d);const i=e.nodeMap.getVisibleIds(n);let c=e.focusedId;return c!==void 0&&c!==d&&e.nodeMap.isDescendantOf(c,d)&&(c=d),{...e,expandedIds:n,focusedId:c,previousExpandedIds:e.expandedIds,visibleIdIndex:x(i),visibleIds:i,...a({...e,focusedId:c},i)}}case"expand":return e.focusedId?v(e,{nodeId:e.focusedId,type:"expand-node"}):e;case"expand-all":{const d=new Set;for(const[i,c]of e.nodeMap.entries())c.hasChildren&&d.add(i);const n=e.nodeMap.getVisibleIds(d);return{...e,expandedIds:d,previousExpandedIds:e.expandedIds,visibleIdIndex:x(n),visibleIds:n,...a({...e},n)}}case"expand-node":{const{nodeId:d}=s;if(!e.nodeMap.get(d)?.hasChildren||e.expandedIds.has(d))return e;const i=new Set(e.expandedIds);i.add(d);const c=e.nodeMap.getVisibleIds(i);return{...e,expandedIds:i,previousExpandedIds:e.expandedIds,visibleIdIndex:x(c),visibleIds:c,...a({...e},c)}}case"focus-first":return e.visibleIds.length===0?e:{...e,focusedId:e.visibleIds[0],viewportFromIndex:0,viewportToIndex:Math.min(e.visibleNodeCount,e.visibleIds.length)};case"focus-first-child":{if(!e.focusedId)return e;const d=e.nodeMap.get(e.focusedId);if(!d||d.childrenIds.length===0||!e.expandedIds.has(e.focusedId))return e;const n=d.childrenIds[0],i=e.visibleIdIndex.get(n)??-1;return i<0?e:{...e,focusedId:n,...t(e,i)}}case"focus-last":{if(e.visibleIds.length===0)return e;const d=e.visibleIds.length-1;return{...e,focusedId:e.visibleIds[d],...t(e,d)}}case"focus-next":{if(!e.focusedId)return e;const d=e.visibleIdIndex.get(e.focusedId)??-1;if(d<0||d>=e.visibleIds.length-1)return e;const n=e.visibleIds[d+1];return{...e,focusedId:n,...t(e,d+1)}}case"focus-parent":{if(!e.focusedId)return e;const d=e.nodeMap.get(e.focusedId);if(!d?.parentId)return e;const n=e.visibleIdIndex.get(d.parentId)??-1;return n<0?e:{...e,focusedId:d.parentId,...t(e,n)}}case"focus-previous":{if(!e.focusedId)return e;const d=e.visibleIdIndex.get(e.focusedId)??-1;if(d<=0)return e;const n=e.visibleIds[d-1];return{...e,focusedId:n,...t(e,d-1)}}case"insert-children":{if(!e.nodeMap.get(s.parentId))return e;const n=e.nodeMap.withChildren(s.parentId,s.children),i=n.getVisibleIds(e.expandedIds);return{...e,nodeMap:n,visibleIdIndex:x(i),visibleIds:i}}case"reset":return s.state;case"select":{if(!e.focusedId||e.selectionMode==="none")return e;if(e.selectionMode==="single"){const n=new Set([e.focusedId]);return{...e,previousSelectedIds:e.selectedIds,selectedIds:n}}const d=new Set(e.selectedIds);return d.has(e.focusedId)?d.delete(e.focusedId):d.add(e.focusedId),{...e,previousSelectedIds:e.selectedIds,selectedIds:d}}case"set-children-error":{const d=new Set(e.loadingIds);return d.delete(s.nodeId),{...e,loadingIds:d}}case"set-loading":{const d=new Set(e.loadingIds);return s.isLoading?d.add(s.nodeId):d.delete(s.nodeId),{...e,loadingIds:d}}case"toggle-expanded":return e.focusedId?e.expandedIds.has(e.focusedId)?v(e,{type:"collapse"}):v(e,{type:"expand"}):e;default:return e}}function C({data:e,defaultExpanded:s,defaultSelected:d,selectionMode:n,visibleNodeCount:i}){const c=new Q(e);let p;if(s==="all"){p=new Set;for(const[w,g]of c.entries())g.hasChildren&&p.add(w)}else s?p=new Set(s):p=new Set;const u=c.getVisibleIds(p),o=n!=="none"&&d?new Set(d):new Set,r=Math.min(i,u.length);return{expandedIds:p,focusedId:u[0],loadingIds:new Set,nodeMap:c,previousExpandedIds:p,previousSelectedIds:o,selectedIds:o,selectionMode:n,viewportFromIndex:0,viewportToIndex:r,visibleIdIndex:x(u),visibleIds:u,visibleNodeCount:i}}function Y({data:e,defaultExpanded:s,defaultSelected:d,onExpandChange:n,onFocusChange:i,onSelectChange:c,selectionMode:p="none",visibleNodeCount:u=1/0}){const[o,r]=H(v,{data:e,defaultExpanded:s,defaultSelected:d,selectionMode:p,visibleNodeCount:u},C),[w,g]=J(e);e!==w&&(r({state:C({data:e,defaultExpanded:s,defaultSelected:d,selectionMode:p,visibleNodeCount:u}),type:"reset"}),g(e));const m=h(i);m.current=i;const M=h(n);M.current=n;const S=h(c);S.current=c;const y=h(!0);b(()=>{if(y.current){y.current=!1;return}o.focusedId&&m.current?.(o.focusedId)},[o.focusedId]),b(()=>{o.expandedIds!==o.previousExpandedIds&&M.current?.(o.expandedIds)},[o.expandedIds,o.previousExpandedIds]),b(()=>{o.selectedIds!==o.previousSelectedIds&&S.current?.(o.selectedIds)},[o.selectedIds,o.previousSelectedIds]);const F=K(()=>o.visibleIds.slice(o.viewportFromIndex,o.viewportToIndex).map(l=>{const f=o.nodeMap.get(l);return{node:f.node,state:{depth:f.depth,hasChildren:f.hasChildren,isExpanded:o.expandedIds.has(l),isFocused:l===o.focusedId,isLoading:o.loadingIds.has(l),isSelected:o.selectedIds.has(l)}}}),[o.visibleIds,o.viewportFromIndex,o.viewportToIndex,o.focusedId,o.expandedIds,o.selectedIds,o.nodeMap,o.loadingIds]),T=I(()=>{r({type:"focus-next"})},[]),N=I(()=>{r({type:"focus-previous"})},[]),E=I(()=>{r({type:"focus-first"})},[]),V=I(()=>{r({type:"focus-last"})},[]),L=I(()=>{r({type:"expand"})},[]),D=I(l=>{r({nodeId:l,type:"expand-node"})},[]),R=I(()=>{r({type:"collapse"})},[]),P=I(l=>{r({nodeId:l,type:"collapse-node"})},[]),j=I(()=>{r({type:"toggle-expanded"})},[]),A=I(()=>{r({type:"expand-all"})},[]),O=I(()=>{r({type:"collapse-all"})},[]),k=I(()=>{r({type:"select"})},[]),U=I(()=>{r({type:"focus-parent"})},[]),q=I(()=>{r({type:"focus-first-child"})},[]),z=I((l,f)=>{r({isLoading:f,nodeId:l,type:"set-loading"})},[]),B=I(l=>{r({nodeId:l,type:"set-children-error"})},[]),G=I((l,f)=>{r({children:f,parentId:l,type:"insert-children"})},[]);return{collapse:R,collapseAll:O,collapseNode:P,expand:L,expandAll:A,expandedIds:o.expandedIds,expandNode:D,focusedId:o.focusedId,focusFirst:E,focusFirstChild:q,focusLast:V,focusNext:T,focusParent:U,focusPrevious:N,hasScrollDown:o.viewportToIndex<o.visibleIds.length,hasScrollUp:o.viewportFromIndex>0,insertChildren:G,loadingIds:o.loadingIds,nodeMap:o.nodeMap,select:k,selectedIds:o.selectedIds,setChildrenError:B,setLoading:z,toggleExpanded:j,viewportFromIndex:o.viewportFromIndex,viewportNodes:F,viewportToIndex:o.viewportToIndex,visibleCount:o.visibleIds.length}}export{C as createDefaultState,v as reducer,Y as useTreeViewState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const o={error:{color:"red",icon:"✖"},info:{color:"blue",icon:"ℹ"},success:{color:"green",icon:"✔"},warning:{color:"yellow",icon:"⚠"}};export{o};
|
|
1
|
+
const o={error:{color:"red",icon:"✖"},info:{color:"blue",icon:"ℹ"},success:{color:"green",icon:"✔"},warning:{color:"yellow",icon:"⚠"}};export{o as V};
|
package/dist/paginator.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as h,jsx as t}from"react/jsx-runtime";import g from"@visulima/tui/components/box";import r from"@visulima/tui/components/text";import _ from"@visulima/tui/hooks/use-input";import{useState as b,useCallback as C}from"react";const B=({color:c,currentPage:s,style:u,totalPages:a})=>{if(u==="fraction")return h(r,{children:[t(r,{color:c,children:s+1}),h(r,{dimColor:!0,children:["/",a]})]});if(u==="numeric"){const d=s>0?t(r,{color:c,children:"‹ "}):t(r,{dimColor:!0,children:"‹ "}),i=s<a-1?t(r,{color:c,children:" ›"}):t(r,{dimColor:!0,children:" ›"});return h(g,{children:[d,t(r,{color:c,children:s+1}),h(r,{dimColor:!0,children:[" ","/",a]}),i]})}const l=Array.from({length:a},(d,i)=>i===s?t(r,{color:c,children:"●"},i):t(r,{dimColor:!0,children:"○"},i));return t(g,{gap:1,children:l})},E=({children:c,defaultPage:s=0,indicatorColor:u="cyan",isFocused:a=!0,items:l,onChange:d,page:i,pageSize:f,style:I="dots"})=>{const p=i!==void 0,[w,v]=b(s),P=p?i:w,n=Math.max(1,Math.ceil(l.length/f)),o=Math.max(0,Math.min(P,n-1)),m=C(A=>{const e=Math.max(0,Math.min(A,n-1));p||v(e),d?.(e)},[n,p,d]);_(C((A,e)=>{e.leftArrow||e.pageUp?m(o-1):e.rightArrow||e.pageDown?m(o+1):e.home?m(0):e.end&&m(n-1)},[o,n,m]),{isActive:a});const x=o*f,M=Math.min(x+f,l.length),j=l.slice(x,M),D={currentPage:o,endIndex:M,isFirstPage:o===0,isLastPage:o===n-1,startIndex:x,totalPages:n};return h(g,{flexDirection:"column",children:[c(j,D),n>1&&t(B,{color:u,currentPage:o,style:I,totalPages:n})]})};export{E as Paginator,E as default};
|
package/dist/paragraph.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import m from"@visulima/tui/components/box";import a from"@visulima/tui/components/text";function x({children:o,color:t,dimColor:e=!1,marginBottom:f=1,marginTop:i=0}){return r(m,{flexDirection:"column",marginBottom:f,marginTop:i,children:r(a,{color:t,dimColor:e,children:o})})}export{x as Paragraph,x as default};
|
package/dist/path-input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as f,jsx as
|
|
1
|
+
import{jsxs as f,jsx as u}from"react/jsx-runtime";import{readdirSync as T,statSync as E}from"node:fs";import{basename as P,dirname as F,join as H}from"node:path";import g from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";import M from"@visulima/tui/hooks/use-focus";import N from"@visulima/tui/hooks/use-input";import{useState as X,useRef as $,useMemo as _,useCallback as b}from"react";const B=/\/$/,D=e=>{const s=e.endsWith("/")?e:F(e),p=e.endsWith("/")?"":P(e);try{return T(s.length===0?".":s).filter(o=>o.startsWith(p)).map(o=>{const r=H(s,o);try{return E(r).isDirectory()?`${r}/`:r}catch{return r}}).toSorted((o,r)=>o.localeCompare(r))}catch{return[]}},x=5;function Y({accentColor:e="blue",autoFocus:s=!1,defaultValue:p="",getCompletions:o=D,isDisabled:r=!1,onChange:S,onSubmit:v,placeholder:R="Enter a path…",showSuggestions:W=!0,value:A}){const{isFocused:a}=M({autoFocus:s,isActive:!r}),C=A!==void 0,[j,G]=X(p),t=A??j,d=$(null),I=$(S);I.current=S;const c=_(()=>o(t),[o,t]),m=b(n=>{C||G(n),I.current?.(n)},[C]),L=b((n,i)=>{if(i.tab){d.current??={index:0,matches:c};const{index:y,matches:h}=d.current;h.length>0&&(d.current={index:y+1,matches:h},m(h[y%h.length]));return}if(i.return){v?.(t);return}if(i.backspace||i.delete){d.current=null,m(t.slice(0,-1));return}n.length>0&&n.codePointAt(0)>=32&&(d.current=null,m(`${t}${n}`))},[c,v,t,m]);return N(L,{isActive:a&&!r}),f(g,{flexDirection:"column",children:[f(g,{borderColor:a?e:void 0,borderStyle:"round",paddingX:1,children:[u(l,{color:e,children:"📁 "}),t.length===0?u(l,{dimColor:!0,children:R}):u(l,{dimColor:r,children:t}),a&&t.length>0?u(l,{color:e,children:"▏"}):void 0]}),W&&a&&c.length>0?f(g,{flexDirection:"column",marginLeft:1,children:[c.slice(0,x).map((n,i)=>f(l,{dimColor:!0,children:[P(n.replace(B,"")),n.endsWith("/")?"/":""]},i)),c.length>x?u(l,{dimColor:!0,children:`…and ${c.length-x} more`}):void 0]}):void 0]})}export{Y as PathInput,Y as default};
|
package/dist/pie-chart.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as F,jsx as f}from"react/jsx-runtime";import{createBrailleGrid as b}from"@visulima/tui/canvas";import x from"@visulima/tui/components/box";import j from"@visulima/tui/components/canvas";import T from"@visulima/tui/components/text";import{useMemo as B}from"react";const A=["cyan","magenta","yellow","green","blue","red"],D=(n,c,l)=>l.color??c[n%c.length]??"cyan",G=(n,c)=>`${n.label??""} ${n.value} (${c.toFixed(0)}%)`.trim();function z({data:n,formatLegend:c=G,palette:l=A,showLegend:I=!0,size:L=8}){const s=B(()=>n.filter(o=>o.value>0),[n]),a=B(()=>s.reduce((o,i)=>o+i.value,0),[s]),m=Math.max(2,L),M=Math.max(2,Math.round(m*4/2/2));return F(x,{flexDirection:"row",gap:2,children:[f(j,{draw:o=>{if(o.clear(),a<=0)return;const i=o.width*2,v=o.height*4,w=i/2,y=v/2,P=Math.max(1,Math.min(w,y)-1),d=[];let g=0;s.forEach((t,r)=>{const e=g/a*Math.PI*2;g+=t.value;const h=g/a*Math.PI*2;d.push({color:D(r,l,t),end:h,start:e})});const p=new Map,$=t=>{const r=p.get(t);if(r!==void 0)return r;const e=b(o.width,o.height);return p.set(t,e),e};for(let t=0;t<v;t+=1)for(let r=0;r<i;r+=1){const e=r-w,h=t-y;if(e*e+h*h>P*P)continue;let u=Math.atan2(e,-h);u<0&&(u+=Math.PI*2);const C=d.find(E=>u>=E.start&&u<E.end)??d[d.length-1];C&&$(C.color).plotPoint(r,t)}for(const[t,r]of p)r.flush(o,{color:t})},height:m,version:[n,a,l,m,M],width:M}),I&&s.length>0?f(x,{flexDirection:"column",children:s.map((o,i)=>F(x,{gap:1,children:[f(T,{color:D(i,l,o),children:"●"}),f(T,{dimColor:!0,children:c(o,o.value/a*100)})]},i))}):void 0]})}export{z as PieChart,z as default};
|
package/dist/placeholder.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import c from"@visulima/tui/components/box";import g from"@visulima/tui/components/text";import A from"@visulima/tui/hooks/use-animation";import W from"@visulima/tui/hooks/use-window-size";const D=[1,.85,.6];function b({animated:r=!0,character:m="█",color:a="gray",interval:l=500,rows:f=3,width:e,widths:t=D}){const{frame:s}=A({interval:l,isActive:r}),{columns:u}=W(),h=r&&s%2===0,d=e??Math.max(1,u);return o(c,{flexDirection:"column",width:e,children:Array.from({length:f},(M,n)=>{const p=t.length>0?t[n%t.length]??1:1,i=Math.max(1,Math.round(d*p)),x=m.repeat(i);return o(c,{width:i,children:o(g,{color:a,dimColor:h,wrap:"truncate-end",children:x})},n)})})}export{b as Placeholder,b as default};
|
package/dist/popover.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as m,jsxs as p}from"react/jsx-runtime";import e from"@visulima/tui/components/box";import c from"@visulima/tui/hooks/use-input";import{useCallback as s}from"react";function j({accentColor:n="blue",anchor:d,children:l,isOpen:o,onClose:t,placement:r="bottom"}){const u=s((a,f)=>{f.escape&&t?.()},[t]);c(u,{isActive:o});const i=o?m(e,{alignSelf:"flex-start",borderColor:n,borderStyle:"round",paddingX:1,children:l}):void 0;return p(e,{flexDirection:"column",children:[r==="top"?i:void 0,d,r==="bottom"?i:void 0]})}export{j as Popover,j as default};
|
package/dist/progress-bar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as f}from"react/jsx-runtime";import
|
|
1
|
+
import{jsx as f}from"react/jsx-runtime";import p from"@visulima/tui/components/text";import u from"@visulima/tui/hooks/use-window-size";function b({character:o="█",columns:r=0,left:n=0,percent:s=1,right:a=0,rightPad:m=!1,...c}){const{columns:i}=u(),t=Math.max(0,(r||i||80)-a-n),e=Math.min(Math.floor(t*Math.max(0,Math.min(1,s))),t),l=o.repeat(e)+(m?" ".repeat(t-e):"");return f(p,{...c,children:l})}export{b as ProgressBar,b as default};
|
package/dist/progress-circle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as C,jsx as n}from"react/jsx-runtime";import{createBrailleGrid as w}from"@visulima/tui/canvas";import x from"@visulima/tui/components/box";import D from"@visulima/tui/components/canvas";import F from"@visulima/tui/components/text";const H=r=>`${Math.round(r*100)}%`;function A({color:r="cyan",formatValue:P=H,max:e=100,min:o=0,showValue:y=!0,size:c=8,trackColor:d="gray",value:l}){const I=e-o||1,M=Math.max(0,Math.min(1,(l-o)/I)),h=Math.max(3,c),G=Math.max(3,Math.round(h*4/2/2));return C(x,{alignItems:"center",flexDirection:"column",children:[n(D,{draw:t=>{t.clear();const j=t.width*2,v=t.height*4,m=j/2,p=v/2,i=Math.max(1,Math.min(m,p)-1),u=w(t.width,t.height),f=w(t.width,t.height),s=Math.max(64,Math.round(Math.PI*2*i)),B=Math.round(M*s);for(let a=0;a<s;a+=1){const g=a/s*Math.PI*2-Math.PI/2,T=Math.round(m+i*Math.cos(g)),b=Math.round(p+i*Math.sin(g));(a<B?f:u).plotPoint(T,b)}u.flush(t,{color:d}),f.flush(t,{color:r})},height:h,version:[l,o,e,c,r,d],width:G}),y?n(x,{marginTop:-Math.ceil(h/2)-1,children:n(F,{bold:!0,color:r,children:P(M)})}):void 0]})}export{A as ProgressCircle,A as default};
|
package/dist/qr-code.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as h}from"react/jsx-runtime";import
|
|
1
|
+
import{jsx as h}from"react/jsx-runtime";import x from"@visulima/tui/components/box";import b from"@visulima/tui/components/text";import{useState as g,useEffect as y,useMemo as k}from"react";const B="▀",M=(d,e)=>{if(e<=0)return d.map(o=>[...o]);let c=0;for(const o of d)c=Math.max(c,o.length);const p=c+e*2,n=()=>{const o=[];for(let t=0;t<p;t+=1)o.push(!1);return o},i=[];for(let o=0;o<e;o+=1)i.push(n());for(const o of d){const t=n();o.forEach((f,a)=>{t[a+e]=f}),i.push(t)}for(let o=0;o<e;o+=1)i.push(n());return i};function A({darkColor:d="black",lightColor:e="white",matrix:c,quietZone:p=2,value:n}){const[i,o]=g(void 0);y(()=>{if(c!==void 0||n===void 0)return;let r=!1;return(async()=>{try{const m=await import("qrcode"),{modules:s}=m.create(n),u=[];for(let l=0;l<s.size;l+=1){const E=[];for(let w=0;w<s.size;w+=1)E.push(!!s.data[l*s.size+w]);u.push(E)}r||o(u)}catch{}})().catch(()=>{}),()=>{r=!0}},[c,n]);const t=c??i,f=k(()=>{if(t!==void 0)return M(t,p)},[p,t]);if(f===void 0)return h(x,{children:h(b,{dimColor:!0,children:n===void 0?"":"Encoding…"})});const a=[];for(let r=0;r<f.length;r+=2){const v=f[r]??[],m=f[r+1]??[],s=[];for(const[u,l]of v.entries())s.push(h(b,{backgroundColor:m[u]?d:e,color:l?d:e,children:B},u));a.push(h(x,{children:s},r))}return h(x,{flexDirection:"column",children:a})}export{A as QrCode,A as default};
|
package/dist/r/registry.json
CHANGED
|
@@ -678,6 +678,15 @@
|
|
|
678
678
|
"title": "Radio Group",
|
|
679
679
|
"type": "registry:ui"
|
|
680
680
|
},
|
|
681
|
+
{
|
|
682
|
+
"categories": [
|
|
683
|
+
"ui"
|
|
684
|
+
],
|
|
685
|
+
"description": "Reset.d component for @visulima/tui.",
|
|
686
|
+
"name": "reset.d",
|
|
687
|
+
"title": "Reset.d",
|
|
688
|
+
"type": "registry:ui"
|
|
689
|
+
},
|
|
681
690
|
{
|
|
682
691
|
"categories": [
|
|
683
692
|
"ui"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "reset.d",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"title": "Reset.d",
|
|
6
|
+
"description": "Reset.d component for @visulima/tui.",
|
|
7
|
+
"categories": [
|
|
8
|
+
"ui"
|
|
9
|
+
],
|
|
10
|
+
"dependencies": [
|
|
11
|
+
"@visulima/tui"
|
|
12
|
+
],
|
|
13
|
+
"registryDependencies": [],
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"content": "// Do not add any other lines of code to this file!\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport \"@total-typescript/ts-reset\";\n",
|
|
17
|
+
"path": "registry/ui/reset.d.ts",
|
|
18
|
+
"target": "components/ui/reset.d.ts",
|
|
19
|
+
"type": "registry:ui"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
package/dist/radio-group.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as h,jsxs as
|
|
1
|
+
import{jsx as h,jsxs as B}from"react/jsx-runtime";import z from"@visulima/tui/components/box";import j from"@visulima/tui/components/text";import G from"@visulima/tui/hooks/use-focus";import P from"@visulima/tui/hooks/use-input";import{useState as b,useRef as S,useCallback as g}from"react";const T=(I,f)=>{if(f===void 0)return 0;const l=I.findIndex(w=>w.value===f);return Math.max(l,0)};function L({accentColor:I="blue",autoFocus:f=!1,commitOnNavigate:l=!0,defaultValue:w,isDisabled:i=!1,onChange:C,onSubmit:M,options:t,orientation:u="vertical",value:a}){const{isFocused:s}=G({autoFocus:f,isActive:!i}),[A,p]=b(w??t[0]?.value),m=a??A,[F,R]=b(()=>T(t,m)),o=S(F);o.current=F;const d=g(r=>{const e=t[r];if(!e)return;const n=a??A;e.value!==n&&(a===void 0&&p(e.value),C?.(e.value))},[t,a,A,C]);return P(g((r,e)=>{if(!s)return;const n=t.length;if(n===0)return;const x=e.downArrow&&u==="vertical"||e.rightArrow&&u==="horizontal"||r==="j",v=e.upArrow&&u==="vertical"||e.leftArrow&&u==="horizontal"||r==="k";if(x){const c=Math.min(n-1,o.current+1);R(c),l&&d(c);return}if(v){const c=Math.max(0,o.current-1);R(c),l&&d(c);return}if(r===" "){d(o.current);return}if(e.return){l||d(o.current);const c=t[o.current]?.value??m;c!==void 0&&M?.(c)}},[s,t,u,d,l,m,M]),{isActive:!i&&s}),h(z,{flexDirection:u==="vertical"?"column":"row",gap:u==="vertical"?0:2,children:t.map((r,e)=>{const n=r.value===m,x=s&&e===F,v=(n||x)&&s?I:void 0;return B(z,{gap:1,children:[h(j,{color:v,dimColor:i,children:n?"●":"○"}),h(j,{bold:x,color:v,dimColor:i,children:r.label}),r.description===void 0?void 0:h(j,{dimColor:!0,children:r.description})]},r.key??r.value)})})}export{L as RadioGroup,L as default};
|
package/dist/scatter-plot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as M,jsx as t}from"react/jsx-runtime";import m from"@visulima/tui/components/box";import u from"@visulima/tui/components/canvas";import f from"@visulima/tui/components/text";import{useMemo as d}from"react";import{t as y,p as A,c as _,D as b,d as F}from"./packem_shared/line-chart-BqOUjZTt.js";const L=b;function O({axisColor:n="gray",height:N=10,maxX:a,maxY:i,minX:c,minY:I,palette:s=L,series:T,showLegend:l=!0,width:x=40}){const E=d(()=>{const e=T.map((o,p)=>({color:A(o,p,s),points:y(o.data),series:o})),r=_(e);return{axisColor:n,palette:s,seriesList:e,xMax:a??(r.xMax===Number.NEGATIVE_INFINITY?1:r.xMax),xMin:c??(r.xMin===Number.POSITIVE_INFINITY?0:r.xMin),yMax:i??(r.yMax===Number.NEGATIVE_INFINITY?1:r.yMax),yMin:I??(r.yMin===Number.POSITIVE_INFINITY?0:r.yMin)}},[T,n,s,c,a,I,i]);return M(m,{flexDirection:"column",children:[t(u,{draw:e=>{F(e,"scatter",E)},height:N,version:[T,x,N,c,a,I,i,n,s],width:x}),l?t(m,{gap:2,marginTop:1,children:E.seriesList.map(({color:e,series:r},o)=>M(m,{gap:1,children:[t(f,{color:e,children:"●"}),t(f,{children:r.label??`Series ${o+1}`})]},`${o}:${r.label??""}`))}):void 0]})}export{O as ScatterPlot,O as default};
|
package/dist/scroll-bar-box.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
|
|
1
|
+
import { Props } from '@visulima/tui/components/box';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface ScrollBarBoxProps extends Props {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
contentHeight: number;
|
|
6
|
+
scrollBarAutoHide?: boolean;
|
|
7
|
+
scrollBarPosition?: "left" | "right";
|
|
8
|
+
scrollOffset: number;
|
|
9
|
+
thumbChar?: string;
|
|
10
|
+
viewportHeight: number;
|
|
11
|
+
}
|
|
12
|
+
declare const ScrollBarBox: ({ borderColor, borderDimColor, borderLeftColor, borderLeftDimColor, borderRightColor, borderRightDimColor, borderStyle, children, contentHeight, height, scrollBarAutoHide, scrollBarPosition, scrollOffset, thumbChar, viewportHeight, ...boxProps }: ScrollBarBoxProps) => React.JSX.Element;
|
|
13
|
+
export { ScrollBarBox, type ScrollBarBoxProps };
|
package/dist/scroll-bar-box.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ScrollBarBox as l}from"./packem_shared/ScrollBarBox-
|
|
1
|
+
import{ScrollBarBox as l}from"./packem_shared/ScrollBarBox-C8wZ_Slk.js";export{l as ScrollBarBox};
|
package/dist/scroll-bar.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
|
|
1
|
+
import { Props } from '@visulima/tui/components/box';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type ScrollBarPlacement = "inset" | "left" | "right";
|
|
4
|
+
type ScrollBarStyle = Props["borderStyle"] | "block" | "line" | "thick" | "dots";
|
|
5
|
+
interface ScrollBarProps {
|
|
6
|
+
autoHide?: boolean;
|
|
7
|
+
color?: string;
|
|
8
|
+
contentHeight: number;
|
|
9
|
+
dimColor?: boolean;
|
|
10
|
+
placement?: ScrollBarPlacement;
|
|
11
|
+
scrollOffset: number;
|
|
12
|
+
style?: ScrollBarStyle;
|
|
13
|
+
thumbChar?: string;
|
|
14
|
+
trackChar?: string;
|
|
15
|
+
viewportHeight: number;
|
|
16
|
+
}
|
|
17
|
+
declare const ScrollBar: React.FC<ScrollBarProps>;
|
|
18
|
+
export { ScrollBar, type ScrollBarPlacement, type ScrollBarProps, type ScrollBarStyle };
|
package/dist/scroll-bar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ScrollBar as l}from"./packem_shared/ScrollBar-
|
|
1
|
+
import{ScrollBar as l}from"./packem_shared/ScrollBar-arHRP6OT.js";export{l as ScrollBar};
|
package/dist/scroll-list.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import "./packem_shared/scroll-view.d-GZcgAHl4.js";
|
|
1
|
+
import React, { Ref } from 'react';
|
|
2
|
+
import { ScrollViewProps, ScrollViewRef } from "./scroll-view.js";
|
|
4
3
|
import '@visulima/tui/components/box';
|
|
4
|
+
type ScrollAlignment = "auto" | "bottom" | "center" | "top";
|
|
5
|
+
interface ScrollListProps extends ScrollViewProps {
|
|
6
|
+
readonly scrollAlignment?: ScrollAlignment;
|
|
7
|
+
readonly selectedIndex?: number;
|
|
8
|
+
}
|
|
9
|
+
type ScrollListRef = ScrollViewRef;
|
|
10
|
+
declare const ScrollList: (props: ScrollListProps & {
|
|
11
|
+
ref?: Ref<ScrollListRef>;
|
|
12
|
+
}) => React.JSX.Element;
|
|
13
|
+
export { type ScrollAlignment, ScrollList, type ScrollListProps, type ScrollListRef };
|
package/dist/scroll-list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ScrollList as l}from"./packem_shared/ScrollList-
|
|
1
|
+
import{ScrollList as l}from"./packem_shared/ScrollList-BCqHHps6.js";export{l as ScrollList};
|
package/dist/scroll-view.d.ts
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
|
|
1
|
+
import { Props } from '@visulima/tui/components/box';
|
|
2
|
+
import React, { ReactNode, Ref } from 'react';
|
|
3
|
+
interface ScrollViewProps extends Props {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Auto-scroll to bottom when content grows and user is at/near the bottom.
|
|
8
|
+
* Pauses when user scrolls away from bottom; resumes when they return.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
followOutput?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Number of lines from bottom that still counts as "at bottom" for followOutput.
|
|
14
|
+
* @default 3
|
|
15
|
+
*/
|
|
16
|
+
followThreshold?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Enable built-in keyboard navigation (arrows, page up/down, home/end, ctrl+u/d).
|
|
19
|
+
* When enabled, the component becomes focusable.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
keyboard?: boolean;
|
|
23
|
+
onContentHeightChange?: (height: number, previousHeight: number) => void;
|
|
24
|
+
onItemHeightChange?: (index: number, height: number, previousHeight: number) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Fires when scrolled within `reachThreshold` lines of the end.
|
|
27
|
+
* Only fires once per entry into the threshold zone.
|
|
28
|
+
*/
|
|
29
|
+
onReachEnd?: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Fires when scrolled within `reachThreshold` lines of the start.
|
|
32
|
+
* Only fires once per entry into the threshold zone.
|
|
33
|
+
*/
|
|
34
|
+
onReachStart?: () => void;
|
|
35
|
+
onScroll?: (scrollOffset: number) => void;
|
|
36
|
+
onViewportSizeChange?: (size: {
|
|
37
|
+
height: number;
|
|
38
|
+
width: number;
|
|
39
|
+
}, previousSize: {
|
|
40
|
+
height: number;
|
|
41
|
+
width: number;
|
|
42
|
+
}) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Number of extra items to render above/below the viewport when virtualized.
|
|
45
|
+
* @default 3
|
|
46
|
+
*/
|
|
47
|
+
overscan?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Distance in lines from the edge to trigger onReachEnd/onReachStart.
|
|
50
|
+
* @default 5
|
|
51
|
+
*/
|
|
52
|
+
reachThreshold?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Show a scrollbar track when content overflows the viewport.
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
scrollbar?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Color of the scrollbar thumb and track.
|
|
60
|
+
*/
|
|
61
|
+
scrollbarColor?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Scrollbar visual style.
|
|
64
|
+
* @default "line"
|
|
65
|
+
*/
|
|
66
|
+
scrollbarStyle?: "arrow" | "block" | "bold" | "classic" | "dots" | "double" | "doubleSingle" | "line" | "round" | "single" | "singleDouble" | "thick";
|
|
67
|
+
/**
|
|
68
|
+
* Enable vim-style keybindings (j/k/g/G/u/d). Requires `keyboard` to be true.
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
vimBindings?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Only render items visible in the viewport plus overscan. Requires items to be measured first.
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
virtualize?: boolean;
|
|
77
|
+
}
|
|
78
|
+
interface ScrollViewRef {
|
|
79
|
+
getBottomOffset: () => number;
|
|
80
|
+
getContentHeight: () => number;
|
|
81
|
+
getItemHeight: (index: number) => number;
|
|
82
|
+
getItemPosition: (index: number) => {
|
|
83
|
+
height: number;
|
|
84
|
+
top: number;
|
|
85
|
+
} | null;
|
|
86
|
+
getScrollOffset: () => number;
|
|
87
|
+
getViewportHeight: () => number;
|
|
88
|
+
remeasure: () => void;
|
|
89
|
+
remeasureItem: (index: number) => void;
|
|
90
|
+
scrollBy: (delta: number) => void;
|
|
91
|
+
scrollTo: (offset: number) => void;
|
|
92
|
+
scrollToBottom: () => void;
|
|
93
|
+
scrollToTop: () => void;
|
|
94
|
+
}
|
|
95
|
+
declare const ScrollView: ({ children, debug, followOutput, followThreshold, keyboard, onContentHeightChange, onItemHeightChange, onReachEnd, onReachStart, onScroll, onViewportSizeChange, overscan, reachThreshold, ref, scrollbar, scrollbarColor, scrollbarStyle: scrollbarStyleProp, vimBindings, virtualize, ...boxProps }: ScrollViewProps & {
|
|
96
|
+
ref?: Ref<ScrollViewRef>;
|
|
97
|
+
}) => React.JSX.Element;
|
|
98
|
+
export { ScrollView, type ScrollViewProps, type ScrollViewRef };
|
package/dist/scroll-view.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ScrollView as e}from"./packem_shared/ScrollView-
|
|
1
|
+
import{ScrollView as e}from"./packem_shared/ScrollView-Dt5E9Yl7.js";export{e as ScrollView};
|
package/dist/search-input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as m,jsx as r}from"react/jsx-runtime";import e from"@visulima/tui/components/box";import u from"@visulima/tui/components/text";import{TextInput as x}from"./text-input.js";function b({accentColor:o="blue",defaultValue:t="",icon:d="⌕",isDisabled:i=!1,onChange:l,onSubmit:n,placeholder:p="Search...",suggestions:f}){return m(e,{borderColor:o,borderStyle:"round",gap:1,paddingX:1,children:[r(u,{color:o,children:d}),r(e,{flexGrow:1,children:r(x,{defaultValue:t,isDisabled:i,onChange:l,onSubmit:n,placeholder:p,suggestions:f})})]})}export{b as SearchInput,b as default};
|