@visulima/tui 1.0.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/LICENSE.md +54 -2444
- package/MIGRATION-GUIDE.md +164 -0
- package/README.md +15 -12
- package/dist/components/box.d.ts +3 -4
- package/dist/components/canvas.d.ts +2 -2
- package/dist/components/canvas.js +1 -1
- package/dist/components/cursor.d.ts +3 -4
- package/dist/components/error-boundary.d.ts +16 -0
- package/dist/components/error-boundary.js +1 -0
- package/dist/components/error-overview.d.ts +8 -0
- package/dist/components/error-overview.js +1 -0
- package/dist/components/static-render.d.ts +3 -4
- package/dist/components/static.d.ts +1 -2
- package/dist/components/text.d.ts +1 -2
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.js +1 -1
- package/dist/ink/canvas/index.d.ts +24 -0
- package/dist/ink/canvas/index.js +1 -0
- package/dist/ink/hooks/use-app.d.ts +1 -32
- package/dist/ink/hooks/use-app.js +1 -1
- package/dist/ink/hooks/use-box-metrics.d.ts +3 -4
- package/dist/ink/hooks/use-cursor.d.ts +1 -1
- package/dist/ink/hooks/use-input.js +2 -2
- package/dist/ink/hooks/use-paste.js +1 -1
- package/dist/ink/hooks/use-persistent-state.js +2 -2
- package/dist/ink/hooks/use-text-selection.d.ts +4 -5
- package/dist/ink/hooks/use-window-size.js +1 -1
- package/dist/ink/index.d.ts +7 -7
- package/dist/ink/index.js +1 -1
- package/dist/ink/mouse/use-element-position.d.ts +3 -4
- package/dist/ink/mouse/use-on-mouse-click.d.ts +3 -4
- package/dist/ink/mouse/use-on-mouse-hover.d.ts +3 -4
- package/dist/ink/mouse/use-on-mouse-state.d.ts +3 -4
- package/dist/ink/public/cursor.d.ts +47 -0
- package/dist/ink/public/cursor.js +1 -0
- package/dist/ink/public/dom.d.ts +6 -0
- package/dist/ink/public/dom.js +0 -0
- package/dist/ink/public/highlighter.d.ts +54 -0
- package/dist/ink/public/highlighter.js +1 -0
- package/dist/ink/public/input.d.ts +14 -0
- package/dist/ink/public/input.js +1 -0
- package/dist/ink/public/styles.d.ts +4 -0
- package/dist/ink/public/styles.js +0 -0
- package/dist/ink/public/utils.d.ts +5 -0
- package/dist/ink/public/utils.js +1 -0
- package/dist/packem_chunks/devtools.js +1 -1
- package/dist/packem_shared/{DevTools-k6uiVzqv.js → DevTools-D9tfChBc.js} +1 -1
- package/dist/packem_shared/InputParser-CiBitCva.js +2 -0
- package/dist/packem_shared/TuiApp-DjIgv5Sk.js +1 -0
- package/dist/packem_shared/app-context-DTm1_XBA.js +1 -0
- package/dist/packem_shared/app-context.d-CG88lgkg.d.ts +56 -0
- package/dist/packem_shared/boxes-DyY_LXCi.js +1 -0
- package/dist/packem_shared/{buffer.d-EJkZr8uH.d.ts → buffer.d-j_dP5JyC.d.ts} +29 -1
- package/dist/packem_shared/buildCursorOnlySequence-CerkmjWt.js +1 -0
- package/dist/packem_shared/{braille-ch3O5D7I.js → createBrailleGrid-BTOQrujS.js} +1 -1
- package/dist/packem_shared/createCanvasBuffer-CL6sAM-A.js +1 -0
- package/dist/packem_shared/disposeHighlighter-D9OkrhwX.js +1 -0
- package/dist/packem_shared/{dom.d-B4kXbaVY.d.ts → dom.d-g-nsYquD.d.ts} +3 -4
- package/dist/packem_shared/formatDuration-Bdx4ZgRh.js +1 -0
- package/dist/packem_shared/index-Dl9I2_QH.js +75 -0
- package/dist/packem_shared/input.d-D-Yxqha8.d.ts +172 -0
- package/dist/packem_shared/{input-utils-BSWCb4F_.js → isControlCharacter-uDgBe_32.js} +1 -1
- package/dist/packem_shared/{reconciler-CFyBVf7l.js → reconciler-DhUGYWCr.js} +1 -1
- package/dist/packem_shared/render-D7aV_hO1.js +24 -0
- package/dist/packem_shared/{render-DFZ8NHlG.js → render-DMcWfI6-.js} +1 -1
- package/dist/packem_shared/{render.d-CBnYBDk2.d.ts → render.d-BvfwvSCx.d.ts} +20 -2
- package/dist/packem_shared/{renderToString-L_bpw4OQ.js → renderToString-DkTmJPaS.js} +1 -1
- package/dist/packem_shared/{renderToString-DwXFY8Qh.js → renderToString-DqLFFPvO.js} +1 -1
- package/dist/packem_shared/renderToken-DjiQ6dfv.js +1 -0
- package/dist/packem_shared/renderTreeToBuffer-BpSD0sBJ.js +2 -0
- package/dist/packem_shared/{renderer-k-xShm1P.js → renderer-Cs0KEr1o.js} +4 -4
- package/dist/packem_shared/{selection.d-CI3_p8wg.d.ts → selection.d-KWphH--_.d.ts} +1 -1
- package/dist/packem_shared/{styles.d-cMo36xQz.d.ts → styles.d-D7iZuNC-.d.ts} +97 -1
- package/dist/packem_shared/utils-C8l_3Dzw.js +1 -0
- package/dist/react/index.d.ts +1 -2
- package/dist/react/index.js +1 -1
- package/dist/testing/index.d.ts +5 -5
- package/dist/testing/index.js +1 -1
- package/index.js +26 -26
- package/package.json +49 -384
- package/dist/components/accordion.d.ts +0 -59
- package/dist/components/accordion.js +0 -1
- package/dist/components/alert.d.ts +0 -26
- package/dist/components/alert.js +0 -1
- package/dist/components/animate-presence.d.ts +0 -18
- package/dist/components/animate-presence.js +0 -1
- package/dist/components/approval-prompt.d.ts +0 -65
- package/dist/components/approval-prompt.js +0 -1
- package/dist/components/area-chart.d.ts +0 -66
- package/dist/components/area-chart.js +0 -1
- package/dist/components/badge.d.ts +0 -22
- package/dist/components/badge.js +0 -1
- package/dist/components/bar-chart.d.ts +0 -67
- package/dist/components/bar-chart.js +0 -1
- package/dist/components/big-text.d.ts +0 -81
- package/dist/components/big-text.js +0 -1
- package/dist/components/blink-dot.d.ts +0 -36
- package/dist/components/blink-dot.js +0 -1
- package/dist/components/breadcrumb.d.ts +0 -33
- package/dist/components/breadcrumb.js +0 -1
- package/dist/components/button.d.ts +0 -45
- package/dist/components/button.js +0 -1
- package/dist/components/calendar.d.ts +0 -72
- package/dist/components/calendar.js +0 -1
- package/dist/components/card.d.ts +0 -57
- package/dist/components/card.js +0 -1
- package/dist/components/checkbox.d.ts +0 -48
- package/dist/components/checkbox.js +0 -1
- package/dist/components/code.d.ts +0 -48
- package/dist/components/code.js +0 -2
- package/dist/components/collapsible.d.ts +0 -53
- package/dist/components/collapsible.js +0 -1
- package/dist/components/command-block.d.ts +0 -47
- package/dist/components/command-block.js +0 -4
- package/dist/components/command-palette.d.ts +0 -82
- package/dist/components/command-palette.js +0 -1
- package/dist/components/confirm-dialog.d.ts +0 -75
- package/dist/components/confirm-dialog.js +0 -1
- package/dist/components/confirm-input.d.ts +0 -38
- package/dist/components/confirm-input.js +0 -1
- package/dist/components/console-overlay.d.ts +0 -54
- package/dist/components/console-overlay.js +0 -1
- package/dist/components/content-switcher.d.ts +0 -57
- package/dist/components/content-switcher.js +0 -1
- package/dist/components/controlled-scroll-view.d.ts +0 -61
- package/dist/components/controlled-scroll-view.js +0 -1
- package/dist/components/date-picker.d.ts +0 -65
- package/dist/components/date-picker.js +0 -1
- package/dist/components/definition-list.d.ts +0 -44
- package/dist/components/definition-list.js +0 -1
- package/dist/components/dialog.d.ts +0 -117
- package/dist/components/dialog.js +0 -1
- package/dist/components/diff-view.d.ts +0 -85
- package/dist/components/diff-view.js +0 -1
- package/dist/components/divider.d.ts +0 -49
- package/dist/components/divider.js +0 -1
- package/dist/components/file-picker-entry.d.ts +0 -104
- package/dist/components/file-picker-entry.js +0 -1
- package/dist/components/form.d.ts +0 -81
- package/dist/components/form.js +0 -1
- package/dist/components/gauge.d.ts +0 -87
- package/dist/components/gauge.js +0 -1
- package/dist/components/gradient.d.ts +0 -42
- package/dist/components/gradient.js +0 -1
- package/dist/components/heading.d.ts +0 -33
- package/dist/components/heading.js +0 -1
- package/dist/components/heatmap.d.ts +0 -62
- package/dist/components/heatmap.js +0 -1
- package/dist/components/help.d.ts +0 -52
- package/dist/components/help.js +0 -1
- package/dist/components/histogram.d.ts +0 -62
- package/dist/components/histogram.js +0 -1
- package/dist/components/kbd.d.ts +0 -31
- package/dist/components/kbd.js +0 -1
- package/dist/components/line-chart.d.ts +0 -109
- package/dist/components/line-chart.js +0 -1
- package/dist/components/link.d.ts +0 -38
- package/dist/components/link.js +0 -1
- package/dist/components/loading-indicator.d.ts +0 -29
- package/dist/components/loading-indicator.js +0 -1
- package/dist/components/markdown.d.ts +0 -40
- package/dist/components/markdown.js +0 -1
- package/dist/components/masked-input.d.ts +0 -50
- package/dist/components/masked-input.js +0 -1
- package/dist/components/menu.d.ts +0 -78
- package/dist/components/menu.js +0 -1
- package/dist/components/message-bubble.d.ts +0 -43
- package/dist/components/message-bubble.js +0 -1
- package/dist/components/model-badge.d.ts +0 -39
- package/dist/components/model-badge.js +0 -1
- package/dist/components/multi-select.d.ts +0 -65
- package/dist/components/multi-select.js +0 -1
- package/dist/components/operation-tree.d.ts +0 -49
- package/dist/components/operation-tree.js +0 -1
- package/dist/components/option-list.d.ts +0 -47
- package/dist/components/option-list.js +0 -1
- package/dist/components/ordered-list.d.ts +0 -24
- package/dist/components/ordered-list.js +0 -1
- package/dist/components/paginator.d.ts +0 -69
- package/dist/components/paginator.js +0 -1
- package/dist/components/paragraph.d.ts +0 -38
- package/dist/components/paragraph.js +0 -1
- package/dist/components/placeholder.d.ts +0 -55
- package/dist/components/placeholder.js +0 -1
- package/dist/components/progress-bar.d.ts +0 -56
- package/dist/components/progress-bar.js +0 -1
- package/dist/components/radio-group.d.ts +0 -74
- package/dist/components/radio-group.js +0 -1
- package/dist/components/scatter-plot.d.ts +0 -35
- package/dist/components/scatter-plot.js +0 -1
- package/dist/components/scroll-bar-box.d.ts +0 -37
- package/dist/components/scroll-bar-box.js +0 -1
- package/dist/components/scroll-bar.d.ts +0 -25
- package/dist/components/scroll-bar.js +0 -1
- package/dist/components/scroll-list.d.ts +0 -20
- package/dist/components/scroll-list.js +0 -1
- package/dist/components/scroll-view.d.ts +0 -10
- package/dist/components/scroll-view.js +0 -1
- package/dist/components/search-input.d.ts +0 -55
- package/dist/components/search-input.js +0 -1
- package/dist/components/select-input-indicator.d.ts +0 -32
- package/dist/components/select-input-indicator.js +0 -1
- package/dist/components/select-input-item.d.ts +0 -41
- package/dist/components/select-input-item.js +0 -1
- package/dist/components/select-input.d.ts +0 -110
- package/dist/components/select-input.js +0 -1
- package/dist/components/shimmer-text.d.ts +0 -47
- package/dist/components/shimmer-text.js +0 -1
- package/dist/components/slider.d.ts +0 -103
- package/dist/components/slider.js +0 -1
- package/dist/components/sparkline.d.ts +0 -35
- package/dist/components/sparkline.js +0 -1
- package/dist/components/spinner.d.ts +0 -17
- package/dist/components/spinner.js +0 -1
- package/dist/components/status-line.d.ts +0 -37
- package/dist/components/status-line.js +0 -1
- package/dist/components/status-message.d.ts +0 -21
- package/dist/components/status-message.js +0 -1
- package/dist/components/stepper.d.ts +0 -48
- package/dist/components/stepper.js +0 -1
- package/dist/components/stopwatch.d.ts +0 -49
- package/dist/components/stopwatch.js +0 -1
- package/dist/components/streaming-text.d.ts +0 -46
- package/dist/components/streaming-text.js +0 -1
- package/dist/components/switch.d.ts +0 -55
- package/dist/components/switch.js +0 -1
- package/dist/components/tab.d.ts +0 -19
- package/dist/components/tab.js +0 -1
- package/dist/components/table.d.ts +0 -119
- package/dist/components/table.js +0 -1
- package/dist/components/tabs.d.ts +0 -107
- package/dist/components/tabs.js +0 -1
- package/dist/components/tag.d.ts +0 -35
- package/dist/components/tag.js +0 -1
- package/dist/components/text-input.d.ts +0 -48
- package/dist/components/text-input.js +0 -1
- package/dist/components/textarea.d.ts +0 -68
- package/dist/components/textarea.js +0 -2
- package/dist/components/timer.d.ts +0 -59
- package/dist/components/timer.js +0 -1
- package/dist/components/toast.d.ts +0 -49
- package/dist/components/toast.js +0 -1
- package/dist/components/tooltip.d.ts +0 -43
- package/dist/components/tooltip.js +0 -1
- package/dist/components/transition.d.ts +0 -74
- package/dist/components/transition.js +0 -1
- package/dist/components/tree-view-entry.d.ts +0 -357
- package/dist/components/tree-view-entry.js +0 -1
- package/dist/components/unordered-list.d.ts +0 -30
- package/dist/components/unordered-list.js +0 -1
- package/dist/ink/hooks/use-linked-scroll.d.ts +0 -49
- package/dist/ink/hooks/use-linked-scroll.js +0 -1
- package/dist/packem_shared/ControlledScrollView-Cn4byU2n.js +0 -1
- package/dist/packem_shared/FilePicker-BLS9nOPz.js +0 -1
- package/dist/packem_shared/InputParser-CtwkCbrQ.js +0 -2
- package/dist/packem_shared/ScrollBar-qa1IzDDv.js +0 -1
- package/dist/packem_shared/ScrollBarBox-DchESZWv.js +0 -1
- package/dist/packem_shared/ScrollList-BBAnRsrC.js +0 -1
- package/dist/packem_shared/ScrollView-CHAo7Epj.js +0 -1
- package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +0 -1
- package/dist/packem_shared/TreeView-BsvLCsf0.js +0 -1
- package/dist/packem_shared/TuiApp-BPL8v1i1.js +0 -1
- package/dist/packem_shared/app-context-BVpKlG1z.js +0 -1
- package/dist/packem_shared/controlled-scroll-view-BVg7ywNW.js +0 -1
- package/dist/packem_shared/cursor-helpers.d-BONB9tky.d.ts +0 -12
- package/dist/packem_shared/format-time-fjoQHMxD.js +0 -1
- package/dist/packem_shared/input.d-CgxV2e8U.d.ts +0 -90
- package/dist/packem_shared/line-chart-C7CUrvVs.js +0 -1
- package/dist/packem_shared/render-CuQecTAs.js +0 -24
- package/dist/packem_shared/renderTreeToBuffer-C8lS0lJ2.js +0 -2
- package/dist/packem_shared/scroll-view.d-DtpsgHLg.d.ts +0 -119
- package/dist/packem_shared/token-to-elements-D6J6-P2A.js +0 -1
- package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +0 -1
- package/dist/packem_shared/useTreeView-D5ifGwG3.js +0 -1
- package/dist/packem_shared/useTreeViewState-BiTJakkh.js +0 -1
- package/dist/packem_shared/utils-Bup8lyK8.js +0 -1
- package/dist/packem_shared/variant-config-BJqpNo7H.js +0 -1
- package/dist/packem_shared/variant-config.d-D5NnrrQK.d.ts +0 -2
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { multilineGradient } from '@visulima/colorize/gradient';
|
|
2
|
-
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* A color stop for the gradient — hex string, CSS color name, RGB tuple, RGB object, or positioned stop.
|
|
5
|
-
*/
|
|
6
|
-
type GradientStop = Parameters<typeof multilineGradient>[0][number];
|
|
7
|
-
/**
|
|
8
|
-
* Built-in gradient presets.
|
|
9
|
-
*/
|
|
10
|
-
type GradientName = "atlas" | "cristal" | "fruit" | "instagram" | "mind" | "morning" | "pastel" | "passion" | "rainbow" | "retro" | "summer" | "teen" | "vice";
|
|
11
|
-
/**
|
|
12
|
-
* Custom gradient colors — an array of color stops accepted by `@visulima/colorize`'s gradient API.
|
|
13
|
-
*/
|
|
14
|
-
type GradientColors = GradientStop[];
|
|
15
|
-
type Props = {
|
|
16
|
-
/**
|
|
17
|
-
* The content to colorize.
|
|
18
|
-
*
|
|
19
|
-
* Multiple `<Text>` children are treated as separate nodes, which preserves layout when `<Gradient>` is placed inside a `<Box flexDirection="column">`.
|
|
20
|
-
*
|
|
21
|
-
* If you want a continuous gradient across multiple lines, pass a single string or a single `<Text>` with `\n`.
|
|
22
|
-
*/
|
|
23
|
-
readonly children: ReactNode;
|
|
24
|
-
/**
|
|
25
|
-
* [Colors to use to make the gradient.](https://visulima.com/packages/colorize)
|
|
26
|
-
*
|
|
27
|
-
* Mutually exclusive with `name`.
|
|
28
|
-
*/
|
|
29
|
-
readonly colors?: GradientColors;
|
|
30
|
-
/**
|
|
31
|
-
* The name of a built-in gradient preset.
|
|
32
|
-
*
|
|
33
|
-
* Mutually exclusive with `colors`.
|
|
34
|
-
*/
|
|
35
|
-
readonly name?: GradientName;
|
|
36
|
-
};
|
|
37
|
-
declare function Gradient({
|
|
38
|
-
children,
|
|
39
|
-
colors,
|
|
40
|
-
name
|
|
41
|
-
}: Props): ReactElement | null;
|
|
42
|
-
export { Gradient, type GradientColors, type GradientName, type Props as GradientProps, Props, Gradient as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as c,Fragment as C}from"react/jsx-runtime";import{strip as F}from"@visulima/ansi";import{multilineGradient as k}from"@visulima/colorize/gradient";import{useMemo as M,Children as g,isValidElement as G,cloneElement as b}from"react";import{Box as B}from"./box.js";import{Text as x}from"./text.js";import{Transform as y}from"./transform.js";const S={atlas:{colors:["#feac5e","#c779d0","#4bc0c8"]},cristal:{colors:["#bdfff3","#4ac29a"]},fruit:{colors:["#ff4e50","#f9d423"]},instagram:{colors:["#833ab4","#fd1d1d","#fcb045"]},mind:{colors:["#473b7b","#3584a7","#30d2be"]},morning:{colors:["#ff5f6d","#ffc371"],options:{interpolation:"hsv"}},passion:{colors:["#f43b47","#453a94"]},pastel:{colors:["#74ebd5","#74ecd5"],options:{hsvSpin:"long",interpolation:"hsv"}},rainbow:{colors:["#ff0000","#ff0100"],options:{hsvSpin:"long",interpolation:"hsv"}},retro:{colors:["#3f51b1","#5a55ae","#7b5fac","#8f6aae","#a86aa4","#cc6b8e","#f18271","#f3a469","#f7c978"]},summer:{colors:["#fdbb2d","#22c1c3"]},teen:{colors:["#77a1d3","#79cbca","#e684ae"]},vice:{colors:["#5ee7df","#b490ca"],options:{interpolation:"hsv"}}},O=o=>{let t=!1;const n=u=>{g.forEach(u,s=>{if(t||!G(s))return;if(s.type===B){t=!0;return}const f=s.props;Object.hasOwn(f,"children")&&n(f.children)})};return n(o),t},T=o=>Object.hasOwn(o,"children"),j=o=>typeof o=="string"||typeof o=="number",N=o=>o==null||typeof o=="boolean";function J({children:o,colors:t,name:n}){if(n&&t)throw new Error("The `name` and `colors` props are mutually exclusive");if(!n&&!t)throw new Error("Either `name` or `colors` prop must be provided");const u=M(()=>n?k(S[n].colors,S[n].options):k(t??[]),[n,t]),s=h=>u(F(h)),f=g.count(o);if(j(o))return c(y,{transform:s,children:o});if(f===1&&!O(o))return c(y,{transform:s,children:o});const m=h=>{const i=[];let a="",v=0;const w=()=>{const r=`gradient-node-${String(v)}`;return v+=1,r},l=(r,e)=>{i.push(c(y,{transform:s,children:r},e))},E=()=>{if(a==="")return;const r=a;a="",l(c(x,{children:r}),w())};return g.forEach(h,r=>{if(!N(r)){if(j(r)){a+=String(r);return}if(E(),G(r)){const e=r.key??w(),p=r.props;if(r.type===x){l(r,e);return}if(r.type===B){if(T(p)){const d=p.children;i.push(b(r,{key:e},m(d)));return}i.push(b(r,{key:e}));return}if(T(p)){const d=p.children;if(!O(d)){l(r,e);return}i.push(b(r,{key:e},m(d)));return}l(r,e);return}i.push(r)}}),E(),i};return c(C,{children:m(o)})}export{J as Gradient,J as default};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
5
|
-
type Props = {
|
|
6
|
-
/**
|
|
7
|
-
* Heading content.
|
|
8
|
-
*/
|
|
9
|
-
readonly children: ReactNode;
|
|
10
|
-
/**
|
|
11
|
-
* Explicit color. By default the color is derived from the level.
|
|
12
|
-
*/
|
|
13
|
-
readonly color?: LiteralUnion<AnsiColors, string>;
|
|
14
|
-
/**
|
|
15
|
-
* Heading level controls decoration and color.
|
|
16
|
-
* @default 1
|
|
17
|
-
*/
|
|
18
|
-
readonly level?: HeadingLevel;
|
|
19
|
-
/**
|
|
20
|
-
* When true, renders an underline on a second line.
|
|
21
|
-
*/
|
|
22
|
-
readonly underline?: boolean;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Semantic heading with level-based styling.
|
|
26
|
-
*/
|
|
27
|
-
declare function Heading({
|
|
28
|
-
children,
|
|
29
|
-
color,
|
|
30
|
-
level,
|
|
31
|
-
underline
|
|
32
|
-
}: Props): ReactElement;
|
|
33
|
-
export { Heading, HeadingLevel, type Props as HeadingProps, Props, Heading as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as l,jsxs as t}from"react/jsx-runtime";import{Box as c}from"./box.js";import{Text as a}from"./text.js";const s={1:"blueBright",2:"cyanBright",3:"magentaBright",4:"yellowBright",5:"green",6:"white"},d={1:"# ",2:"## ",3:"### ",4:"#### ",5:"##### ",6:"###### "};function g({children:e,color:o,level:r=1,underline:n=!1}){const i=o??s[r];return l(c,{flexDirection:"column",children:t(a,{bold:r<=2,color:i,underline:n,children:[d[r],e]})})}export{g as Heading,g as default};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type HeatmapProps = {
|
|
5
|
-
/**
|
|
6
|
-
* Width of each cell in character columns.
|
|
7
|
-
* @default 2
|
|
8
|
-
*/
|
|
9
|
-
readonly cellWidth?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Glyph used to paint each heatmap cell. Defaults to `█` so the
|
|
12
|
-
* background color fills the cell.
|
|
13
|
-
* @default "█" (full block)
|
|
14
|
-
*/
|
|
15
|
-
readonly character?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Column labels rendered below the grid.
|
|
18
|
-
*/
|
|
19
|
-
readonly columnLabels?: ReadonlyArray<string>;
|
|
20
|
-
/**
|
|
21
|
-
* 2D matrix, rows × cols.
|
|
22
|
-
*/
|
|
23
|
-
readonly data: ReadonlyArray<ReadonlyArray<number>>;
|
|
24
|
-
/**
|
|
25
|
-
* Fixed maximum (for consistent scales across multiple heatmaps).
|
|
26
|
-
*/
|
|
27
|
-
readonly max?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Fixed minimum.
|
|
30
|
-
*/
|
|
31
|
-
readonly min?: number;
|
|
32
|
-
/**
|
|
33
|
-
* Color palette, lowest-to-highest intensity. Values are mapped into the
|
|
34
|
-
* palette by their position in the [min, max] range.
|
|
35
|
-
* @default ["#0b1e4f", "#1f3b96", "#3258c8", "#4e84ec", "#78b0ff"]
|
|
36
|
-
*/
|
|
37
|
-
readonly palette?: ReadonlyArray<string>;
|
|
38
|
-
/**
|
|
39
|
-
* Row labels rendered to the left of the grid.
|
|
40
|
-
*/
|
|
41
|
-
readonly rowLabels?: ReadonlyArray<string>;
|
|
42
|
-
/**
|
|
43
|
-
* Foreground color override (rarely needed since the character is a full block).
|
|
44
|
-
*/
|
|
45
|
-
readonly textColor?: LiteralUnion<AnsiColors, string>;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* 2D heatmap. Each cell's background color is derived from its value's
|
|
49
|
-
* position in the [min, max] range mapped into `palette`.
|
|
50
|
-
*/
|
|
51
|
-
declare function Heatmap({
|
|
52
|
-
cellWidth,
|
|
53
|
-
character,
|
|
54
|
-
columnLabels,
|
|
55
|
-
data,
|
|
56
|
-
max: maxOverride,
|
|
57
|
-
min: minOverride,
|
|
58
|
-
palette,
|
|
59
|
-
rowLabels,
|
|
60
|
-
textColor
|
|
61
|
-
}: HeatmapProps): ReactElement;
|
|
62
|
-
export { Heatmap, HeatmapProps, Heatmap as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsxs as C,jsx as a}from"react/jsx-runtime";import{useMemo as R}from"react";import{Box as m}from"./box.js";import{Canvas as A}from"./canvas.js";import{Text as M}from"./text.js";const B=["#0b1e4f","#1f3b96","#3258c8","#4e84ec","#78b0ff"];function G({cellWidth:s=2,character:k="█",columnLabels:p,data:t,max:c,min:l,palette:x=B,rowLabels:w,textColor:L}){const{cols:g,colWidth:f,extent:W,rows:u}=R(()=>{const e=t.length,r=t.reduce((n,o)=>Math.max(n,o.length),0);let i=l??1/0,d=c??-1/0;if(l===void 0||c===void 0)for(const n of t)for(const o of n)l===void 0&&o<i&&(i=o),c===void 0&&o>d&&(d=o);return{cols:r,colWidth:s,extent:{max:d,min:i},rows:e}},[t,l,c,s]),j=g*f,D=u;return C(m,{children:[w===void 0?void 0:a(m,{flexDirection:"column",marginRight:1,children:Array.from({length:u},(e,r)=>a(M,{dimColor:!0,children:w[r]??""},r))}),C(m,{flexDirection:"column",children:[a(A,{draw:e=>{e.clear();const{max:r,min:i}=W,d=r-i||1,n=x.length-1;for(let o=0;o<u;o+=1)for(let h=0;h<g;h+=1){const b=t[o]?.[h],H=b===void 0?void 0:x[Math.max(0,Math.min(n,Math.round((b-i)/d*n)))];for(let v=0;v<f;v+=1)e.setCell(h*f+v,o,k,{background:H,color:L})}},height:D,version:[t,x,s,l,c],width:j}),p===void 0?void 0:a(m,{children:p.map((e,r)=>a(m,{width:f,children:a(M,{dimColor:!0,wrap:"truncate-end",children:e})},r))})]})]})}export{G as Heatmap,G as default};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { KeyBinding } from "../ink/hooks/use-key-bindings.js";
|
|
3
|
-
type Props = {
|
|
4
|
-
/**
|
|
5
|
-
* Key bindings to display. Typically the `bindings` array returned by `useKeyBindings`.
|
|
6
|
-
*/
|
|
7
|
-
readonly bindings: ReadonlyArray<KeyBinding>;
|
|
8
|
-
/**
|
|
9
|
-
* Color for description text.
|
|
10
|
-
* @default undefined (uses dimColor)
|
|
11
|
-
*/
|
|
12
|
-
readonly descriptionColor?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Color for key labels.
|
|
15
|
-
* @default "cyan"
|
|
16
|
-
*/
|
|
17
|
-
readonly keyColor?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Maximum number of columns in full mode.
|
|
20
|
-
* @default 3
|
|
21
|
-
*/
|
|
22
|
-
readonly maxColumns?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Display mode.
|
|
25
|
-
* - `"short"`: Single-line horizontal bar, truncated to terminal width.
|
|
26
|
-
* - `"full"`: Multi-column layout grouped by `group` field.
|
|
27
|
-
* @default "short"
|
|
28
|
-
*/
|
|
29
|
-
readonly mode?: "full" | "short";
|
|
30
|
-
/**
|
|
31
|
-
* Separator between key-description pairs in short mode.
|
|
32
|
-
* @default " \u00b7 "
|
|
33
|
-
*/
|
|
34
|
-
readonly separator?: string;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Renders a keybinding help bar from an array of `KeyBinding` definitions.
|
|
38
|
-
*
|
|
39
|
-
* ```tsx
|
|
40
|
-
* <Help bindings={bindings} />
|
|
41
|
-
* <Help bindings={bindings} mode="full" />
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
declare function Help({
|
|
45
|
-
bindings,
|
|
46
|
-
descriptionColor,
|
|
47
|
-
keyColor,
|
|
48
|
-
maxColumns,
|
|
49
|
-
mode,
|
|
50
|
-
separator
|
|
51
|
-
}: Props): ReactElement;
|
|
52
|
-
export { Help, type Props as HelpProps, Props, Help as default };
|
package/dist/components/help.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e,jsxs as m}from"react/jsx-runtime";import w from"../ink/hooks/use-window-size.js";import{Box as a}from"./box.js";import{Text as i}from"./text.js";const f={backspace:"backspace",delete:"del",downArrow:"↓",end:"end",escape:"esc",home:"home",leftArrow:"←",pageDown:"pgdn",pageUp:"pgup",return:"enter",rightArrow:"→",tab:"tab",upArrow:"↑"};function y(r){const o=r.indexOf("+");if(o!==-1){const n=r.slice(0,o),t=r.slice(o+1);return`${n}+${f[t]??t}`}return f[r]??r}function C(r){return(typeof r=="string"?[r]:r).map(o=>y(o)).join("/")}function B({bindings:r,descriptionColor:o,keyColor:n="cyan",maxColumns:t=3,mode:s="short",separator:l=" · "}){const{columns:p}=w();return s==="full"?$(r,{columns:p,descriptionColor:o,keyColor:n,maxColumns:t}):b(r,{columns:p,descriptionColor:o,keyColor:n,separator:l})}function b(r,o){const n=[];let t=0;for(const[s,l]of r.entries()){const p=C(l.key),d=`${p} ${l.description}`,c=(s>0?o.separator.length:0)+d.length;if(t+c>o.columns&&n.length>0)break;s>0&&n.push(e(i,{dimColor:!0,children:o.separator},`sep-${s}`)),n.push(m(a,{children:[e(i,{color:o.keyColor,children:p}),e(i,{children:" "}),o.descriptionColor?e(i,{color:o.descriptionColor,children:l.description}):e(i,{dimColor:!0,children:l.description})]},`pair-${s}`)),t+=c}return e(a,{flexDirection:"row",children:n})}function $(r,o){const n=new Map;for(const d of r){const c=d.group??"";n.has(c)||n.set(c,[]),n.get(c).push(d)}const t=[...n.entries()],s=Math.min(o.maxColumns,t.length||1),l=Math.floor(o.columns/s),p=[];for(const[d,[c,g]]of t.entries()){const u=[];c&&u.push(e(i,{bold:!0,children:c},"title"));for(const[x,h]of g.entries()){const k=C(h.key);u.push(m(a,{children:[e(i,{color:o.keyColor,children:k}),e(i,{children:" "}),o.descriptionColor?e(i,{color:o.descriptionColor,children:h.description}):e(i,{dimColor:!0,children:h.description})]},`b-${x}`))}p.push(e(a,{flexDirection:"column",width:l,children:u},`col-${d}`))}return e(a,{flexDirection:"row",children:p})}export{B as Help,B as default};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type Props = {
|
|
5
|
-
/**
|
|
6
|
-
* Number of equal-width buckets. Ignored if `thresholds` is set.
|
|
7
|
-
* @default 10
|
|
8
|
-
*/
|
|
9
|
-
readonly bins?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Bar color.
|
|
12
|
-
*/
|
|
13
|
-
readonly color?: LiteralUnion<AnsiColors, string>;
|
|
14
|
-
/**
|
|
15
|
-
* Raw values to bin.
|
|
16
|
-
*/
|
|
17
|
-
readonly data: ReadonlyArray<number>;
|
|
18
|
-
/**
|
|
19
|
-
* Plot height in character rows.
|
|
20
|
-
* @default 10
|
|
21
|
-
*/
|
|
22
|
-
readonly height?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Optional fixed maximum.
|
|
25
|
-
*/
|
|
26
|
-
readonly max?: number;
|
|
27
|
-
/**
|
|
28
|
-
* Optional fixed minimum.
|
|
29
|
-
*/
|
|
30
|
-
readonly min?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Render a numeric count above each bucket.
|
|
33
|
-
* @default false
|
|
34
|
-
*/
|
|
35
|
-
readonly showValues?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Explicit bin edges. When provided, `bins`, `min`, and `max` are ignored.
|
|
38
|
-
* Must be strictly increasing.
|
|
39
|
-
*/
|
|
40
|
-
readonly thresholds?: ReadonlyArray<number>;
|
|
41
|
-
/**
|
|
42
|
-
* Plot width in character columns.
|
|
43
|
-
*/
|
|
44
|
-
readonly width?: number;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Histogram built on top of BarChart. Bins the raw values (via explicit
|
|
48
|
-
* thresholds or equal-width bins) and hands the counts off to BarChart.
|
|
49
|
-
* @returns A `ReactElement` rendering a BarChart of bucket counts.
|
|
50
|
-
*/
|
|
51
|
-
declare function Histogram({
|
|
52
|
-
bins,
|
|
53
|
-
color,
|
|
54
|
-
data,
|
|
55
|
-
height,
|
|
56
|
-
max: maxOverride,
|
|
57
|
-
min: minOverride,
|
|
58
|
-
showValues,
|
|
59
|
-
thresholds,
|
|
60
|
-
width
|
|
61
|
-
}: Props): ReactElement;
|
|
62
|
-
export { Histogram, type Props as HistogramProps, Props, Histogram as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as g}from"react/jsx-runtime";import{useMemo as d}from"react";import{BarChart as b}from"./bar-chart.js";const p=(l,t,o)=>{if(o<=0||l>=t)return[l,t];const s=(t-l)/o;return Array.from({length:o+1},(n,r)=>l+r*s)},c=(l,t)=>{if(t.length<2)return[];const o=Array.from({length:t.length-1}).fill(0),s=t[0],n=t[t.length-1];for(const r of l)if(!(r<s||r>n))for(let e=0;e<t.length-1;e+=1){const a=e===t.length-2,h=t[e+1];if(r<h||a&&r<=h){o[e]=(o[e]??0)+1;break}}return o.map((r,e)=>{const a=t[e],h=t[e+1];return{count:r,label:`${Math.round(a)}-${Math.round(h)}`}})};function x({bins:l=10,color:t,data:o,height:s=10,max:n,min:r,showValues:e=!1,thresholds:a,width:h}){const m=d(()=>{if(a&&a.length>=2)return c(o,a);if(o.length===0)return[];let i=r??1/0,f=n??-1/0;if(r===void 0||n===void 0)for(const u of o)r===void 0&&u<i&&(i=u),n===void 0&&u>f&&(f=u);return i===f?[{count:o.length,label:i.toString()}]:c(o,p(i,f,l))},[o,a,l,r,n]);return g(b,{data:m.map(i=>({color:t,label:i.label,value:i.count})),height:s,orientation:"vertical",showLabels:!0,showValues:e,width:h})}export{x as Histogram,x as default};
|
package/dist/components/kbd.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type Props = {
|
|
5
|
-
/**
|
|
6
|
-
* Key cap content.
|
|
7
|
-
*/
|
|
8
|
-
readonly children: ReactNode;
|
|
9
|
-
/**
|
|
10
|
-
* Background color of the key cap.
|
|
11
|
-
* @default "gray"
|
|
12
|
-
*/
|
|
13
|
-
readonly color?: LiteralUnion<AnsiColors, string>;
|
|
14
|
-
/**
|
|
15
|
-
* Visual style.
|
|
16
|
-
* - `solid` (default): background filled
|
|
17
|
-
* - `outline`: border only
|
|
18
|
-
* - `bare`: no decoration, just dimmed text
|
|
19
|
-
*/
|
|
20
|
-
readonly variant?: "bare" | "outline" | "solid";
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Render a keyboard key (e.g. `<Kbd>Enter</Kbd>`).
|
|
24
|
-
* @returns A `ReactElement` styled as a key cap (solid / outline / bare).
|
|
25
|
-
*/
|
|
26
|
-
declare function Kbd({
|
|
27
|
-
children,
|
|
28
|
-
color,
|
|
29
|
-
variant
|
|
30
|
-
}: Props): ReactElement;
|
|
31
|
-
export { Kbd, type Props as KbdProps, Props, Kbd as default };
|
package/dist/components/kbd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsxs as i,jsx as l}from"react/jsx-runtime";import{Box as n}from"./box.js";import{Text as d}from"./text.js";function s({children:r,color:o="gray",variant:e="solid"}){return e==="solid"?i(d,{backgroundColor:o,color:"black",children:[" ",r," "]}):e==="outline"?l(n,{borderColor:o,borderStyle:"round",paddingX:1,children:l(d,{color:o,children:r})}):l(d,{dimColor:!0,children:r})}export{s as Kbd,s as default};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
import { C as CanvasContext } from "../packem_shared/buffer.d-EJkZr8uH.js";
|
|
5
|
-
/**
|
|
6
|
-
* A single 2D data point.
|
|
7
|
-
*/
|
|
8
|
-
type Point = {
|
|
9
|
-
readonly x: number;
|
|
10
|
-
readonly y: number;
|
|
11
|
-
};
|
|
12
|
-
type LineSeries = {
|
|
13
|
-
/**
|
|
14
|
-
* Per-series color override. Falls back to the chart-level palette.
|
|
15
|
-
*/
|
|
16
|
-
readonly color?: LiteralUnion<AnsiColors, string>;
|
|
17
|
-
/**
|
|
18
|
-
* Numeric samples to plot. Pass either a list of y-values (x is the
|
|
19
|
-
* index) or {x, y} tuples.
|
|
20
|
-
*/
|
|
21
|
-
readonly data: ReadonlyArray<number> | ReadonlyArray<{
|
|
22
|
-
readonly x: number;
|
|
23
|
-
readonly y: number;
|
|
24
|
-
}>;
|
|
25
|
-
/**
|
|
26
|
-
* Optional label shown in the legend.
|
|
27
|
-
*/
|
|
28
|
-
readonly label?: string;
|
|
29
|
-
};
|
|
30
|
-
type LineChartProps = {
|
|
31
|
-
/**
|
|
32
|
-
* Color for axis ticks / labels.
|
|
33
|
-
* @default "gray"
|
|
34
|
-
*/
|
|
35
|
-
readonly axisColor?: LiteralUnion<AnsiColors, string>;
|
|
36
|
-
/**
|
|
37
|
-
* Chart body height in character rows.
|
|
38
|
-
* @default 10
|
|
39
|
-
*/
|
|
40
|
-
readonly height?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Upper bound for the y-axis. When omitted the chart auto-scales.
|
|
43
|
-
*/
|
|
44
|
-
readonly maxY?: number;
|
|
45
|
-
/**
|
|
46
|
-
* Lower bound for the y-axis. When omitted the chart auto-scales.
|
|
47
|
-
*/
|
|
48
|
-
readonly minY?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Fallback palette cycled through when a series does not set `color`.
|
|
51
|
-
* @default ["cyan", "magenta", "yellow", "green", "blue", "red"]
|
|
52
|
-
*/
|
|
53
|
-
readonly palette?: ReadonlyArray<LiteralUnion<AnsiColors, string>>;
|
|
54
|
-
/**
|
|
55
|
-
* One or more line series.
|
|
56
|
-
*/
|
|
57
|
-
readonly series: ReadonlyArray<LineSeries>;
|
|
58
|
-
/**
|
|
59
|
-
* Render the legend row under the plot.
|
|
60
|
-
* @default true
|
|
61
|
-
*/
|
|
62
|
-
readonly showLegend?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Chart body width in character columns.
|
|
65
|
-
* @default 40
|
|
66
|
-
*/
|
|
67
|
-
readonly width?: number;
|
|
68
|
-
};
|
|
69
|
-
type RenderConfig = {
|
|
70
|
-
readonly axisColor: LiteralUnion<AnsiColors, string>;
|
|
71
|
-
readonly palette: ReadonlyArray<LiteralUnion<AnsiColors, string>>;
|
|
72
|
-
readonly seriesList: ReadonlyArray<{
|
|
73
|
-
color: LiteralUnion<AnsiColors, string>;
|
|
74
|
-
points: ReadonlyArray<Point>;
|
|
75
|
-
series: LineSeries;
|
|
76
|
-
}>;
|
|
77
|
-
readonly xMax: number;
|
|
78
|
-
readonly xMin: number;
|
|
79
|
-
readonly yMax: number;
|
|
80
|
-
readonly yMin: number;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Project an (x, y) data point into pixel-grid coordinates for the given
|
|
84
|
-
* canvas size. Used by every chart that paints on top of a braille grid.
|
|
85
|
-
*/
|
|
86
|
-
declare const projectPoint: (point: Point, config: Pick<RenderConfig, "xMax" | "xMin" | "yMax" | "yMin">, pixelWidth: number, pixelHeight: number) => {
|
|
87
|
-
px: number;
|
|
88
|
-
py: number;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Shared drawing path used by LineChart and ScatterPlot. AreaChart wraps
|
|
92
|
-
* this with a fill pass.
|
|
93
|
-
*/
|
|
94
|
-
declare const drawSeriesOnCanvas: (context: CanvasContext, mode: "line" | "scatter", config: RenderConfig) => void;
|
|
95
|
-
/**
|
|
96
|
-
* Smooth multi-series line chart rendered at 2x4 sub-cell resolution using
|
|
97
|
-
* Unicode braille patterns. Auto-scales both axes by default.
|
|
98
|
-
*/
|
|
99
|
-
declare function LineChart({
|
|
100
|
-
axisColor,
|
|
101
|
-
height,
|
|
102
|
-
maxY,
|
|
103
|
-
minY,
|
|
104
|
-
palette,
|
|
105
|
-
series,
|
|
106
|
-
showLegend,
|
|
107
|
-
width
|
|
108
|
-
}: LineChartProps): ReactElement;
|
|
109
|
-
export { LineChart, LineChartProps, type RenderConfig as LineChartRenderConfig, LineSeries, LineChart as default, drawSeriesOnCanvas, projectPoint };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"react/jsx-runtime";import"react";import"../packem_shared/braille-ch3O5D7I.js";import"./box.js";import"./canvas.js";import{h as s,h as n,d,a as h}from"../packem_shared/line-chart-C7CUrvVs.js";import"./text.js";export{s as LineChart,n as default,d as drawSeriesOnCanvas,h as projectPoint};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
type Props = {
|
|
3
|
-
readonly children: ReactNode;
|
|
4
|
-
/**
|
|
5
|
-
* Determines whether the URL should be printed for unsupported terminals.
|
|
6
|
-
*
|
|
7
|
-
* - `true` (default): appends the URL after the text, e.g. `"My website https://example.com"`
|
|
8
|
-
* - `false`: renders just the text with no URL
|
|
9
|
-
* - `function`: custom fallback formatting, e.g. `(text, url) => \`[\${text}](\${url})\``
|
|
10
|
-
* @default true
|
|
11
|
-
*/
|
|
12
|
-
readonly fallback?: ((text: string, url: string) => string) | boolean;
|
|
13
|
-
/**
|
|
14
|
-
* The URL to link to.
|
|
15
|
-
*/
|
|
16
|
-
readonly url: string;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* An Ink component that creates clickable links in the terminal using OSC 8 hyperlink sequences.
|
|
20
|
-
*
|
|
21
|
-
* [Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda)
|
|
22
|
-
*
|
|
23
|
-
* For unsupported terminals, the link will be printed after the text: `My website https://example.com`.
|
|
24
|
-
*
|
|
25
|
-
* ```tsx
|
|
26
|
-
* import { Link, Text } from "@visulima/tui/ink";
|
|
27
|
-
*
|
|
28
|
-
* <Link url="https://example.com">
|
|
29
|
-
* <Text color="cyan">My Website</Text>
|
|
30
|
-
* </Link>
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare function Link({
|
|
34
|
-
children,
|
|
35
|
-
fallback,
|
|
36
|
-
url
|
|
37
|
-
}: Props): ReactElement;
|
|
38
|
-
export { Link, type Props as LinkProps, type Props, Link as default };
|
package/dist/components/link.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as i}from"react/jsx-runtime";import{hyperlink as u}from"@visulima/ansi";import{useCallback as c}from"react";import{Text as f}from"./text.js";import{Transform as a}from"./transform.js";let n;const m=()=>{if(!process.stdout.isTTY)return!1;const o=process.env.TERM_PROGRAM??"",r=process.env.TERM_PROGRAM_VERSION??"";if(o==="iTerm.app")return Number.parseInt(r.split(".")[0]??"0",10)>=3;if(o==="WezTerm"||o==="ghostty")return!0;if(o==="vscode"){const s=r.split("."),t=Number.parseInt(s[0]??"0",10),p=Number.parseInt(s[1]??"0",10);return t>1||t===1&&p>=72}if(process.env.WT_SESSION)return!0;const e=process.env.VTE_VERSION;if(e){const s=Number.parseInt(e,10);return s>=5e3&&s!==5e3}return!1},l=()=>process.env.FORCE_HYPERLINK?process.env.FORCE_HYPERLINK!=="0":(n!==void 0||(n=m()),n);function v({children:o,fallback:r=!0,url:e}){const s=c(t=>l()?u(t,e):r===!1?t:typeof r=="function"?r(t,e):`${t} ${e}`,[r,e]);return i(a,{transform:s,children:i(f,{children:o})})}export{v as Link,v as default};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { SpinnerName } from '@visulima/spinner';
|
|
3
|
-
import { ReactNode, ReactElement } from 'react';
|
|
4
|
-
import { LiteralUnion } from 'type-fest';
|
|
5
|
-
type Props = {
|
|
6
|
-
/**
|
|
7
|
-
* Optional message rendered after the spinner.
|
|
8
|
-
*/
|
|
9
|
-
readonly children?: ReactNode;
|
|
10
|
-
/**
|
|
11
|
-
* Color used for the spinner and label.
|
|
12
|
-
* @default "cyan"
|
|
13
|
-
*/
|
|
14
|
-
readonly color?: LiteralUnion<AnsiColors, string>;
|
|
15
|
-
/**
|
|
16
|
-
* Spinner preset.
|
|
17
|
-
* @default "dots"
|
|
18
|
-
*/
|
|
19
|
-
readonly type?: SpinnerName;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Compact spinner + label for loading states.
|
|
23
|
-
*/
|
|
24
|
-
declare function LoadingIndicator({
|
|
25
|
-
children,
|
|
26
|
-
color,
|
|
27
|
-
type
|
|
28
|
-
}: Props): ReactElement;
|
|
29
|
-
export { LoadingIndicator, type Props as LoadingIndicatorProps, Props, LoadingIndicator as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsxs as a,jsx as o}from"react/jsx-runtime";import{Box as c}from"./box.js";import{Spinner as d}from"./spinner.js";import{Text as i}from"./text.js";function m({children:r,color:n="cyan",type:t="dots"}){return a(c,{gap:1,children:[o(i,{color:n,children:o(d,{type:t})}),r===void 0?void 0:o(i,{color:n,children:r})]})}export{m as LoadingIndicator,m as default};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
type Props = {
|
|
3
|
-
/**
|
|
4
|
-
* The Markdown source string.
|
|
5
|
-
*/
|
|
6
|
-
readonly children: string;
|
|
7
|
-
/**
|
|
8
|
-
* Shiki theme for code block syntax highlighting.
|
|
9
|
-
* @default "github-dark-default"
|
|
10
|
-
*/
|
|
11
|
-
readonly codeTheme?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Maximum width for text wrapping. Defaults to terminal width.
|
|
14
|
-
*/
|
|
15
|
-
readonly maxWidth?: number;
|
|
16
|
-
/**
|
|
17
|
-
* Enable streaming mode for progressive rendering.
|
|
18
|
-
* When true, the component re-renders on every prop change and handles
|
|
19
|
-
* incomplete Markdown gracefully (e.g., unclosed code fences, partial lists).
|
|
20
|
-
* Useful for rendering AI-generated text arriving token-by-token.
|
|
21
|
-
* @default false
|
|
22
|
-
*/
|
|
23
|
-
readonly streaming?: boolean;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Render Markdown content as Ink terminal UI elements.
|
|
27
|
-
*
|
|
28
|
-
* ```tsx
|
|
29
|
-
* <Markdown>{"# Hello\n\nThis is **bold** and *italic*."}</Markdown>
|
|
30
|
-
* <Markdown codeTheme="github-dark-default">{"```js\nconst x = 1;\n```"}</Markdown>
|
|
31
|
-
* <Markdown streaming>{"# Streaming\n\nText arriving..."}</Markdown>
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
declare function Markdown({
|
|
35
|
-
children,
|
|
36
|
-
codeTheme,
|
|
37
|
-
maxWidth: maxWidthProp,
|
|
38
|
-
streaming
|
|
39
|
-
}: Props): ReactElement;
|
|
40
|
-
export { Markdown, type Props as MarkdownProps, Props, Markdown as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as r,jsxs as x}from"react/jsx-runtime";import{Lexer as C}from"marked";import k,{useMemo as b}from"react";import D from"../ink/hooks/use-window-size.js";import{Box as l}from"./box.js";import{Code as F}from"./code.js";import{Link as M}from"./link.js";import{Newline as w}from"./newline.js";import{OrderedList as j}from"./ordered-list.js";import{Table as v}from"./table.js";import{Text as m}from"./text.js";import{UnorderedList as B}from"./unordered-list.js";const q={1:"cyan",2:"green",3:"yellow",4:"blue",5:"magenta",6:"gray"};function p(c){return!c||c.length===0?null:c.map((a,t)=>{switch(a.type){case"br":return r(w,{},t);case"codespan":return x(m,{inverse:!0,children:[" ",a.text," "]},t);case"del":return r(m,{strikethrough:!0,children:p(a.tokens)},t);case"em":return r(m,{italic:!0,children:p(a.tokens)},t);case"escape":return r(k.Fragment,{children:a.text},t);case"image":{const e=a;return x(m,{dimColor:!0,children:["[image:"," ",e.text||e.href,"]"]},t)}case"link":{const e=a;return r(M,{url:e.href,children:p(e.tokens)??e.text},t)}case"strong":return r(m,{bold:!0,children:p(a.tokens)},t);case"text":return r(k.Fragment,{children:a.text},t);default:{const e="raw"in a?a.raw:"";return r(k.Fragment,{children:e},t)}}})}function T(c){return c.map(a=>{const t=a.tokens??[],e=t.find(i=>i.type==="text"),n=p(e?.tokens??t),h=t.find(i=>i.type==="list");return{children:h?T(h.items):void 0,label:n}})}function $(c,a,t){const e=[];for(const[n,h]of c.entries()){const i=h,s=n>0?1:0;switch(i.type){case"blockquote":{const o=i;e.push(r(l,{borderLeft:!0,borderLeftColor:"gray",marginTop:s,paddingLeft:1,children:r(l,{flexDirection:"column",children:$(o.tokens,a,t-3)})},n));break}case"code":{const o=i;e.push(r(l,{marginTop:s,children:r(F,{code:o.text,language:o.lang,theme:a})},n));break}case"heading":{const o=i,d=q[o.depth]??"white",g=`${"#".repeat(o.depth)} `;e.push(r(l,{marginTop:s,children:x(m,{bold:!0,color:d,children:[g,p(o.tokens)]})},n));break}case"hr":{e.push(r(l,{marginTop:s,children:r(m,{dimColor:!0,children:"─".repeat(Math.min(t,40))})},n));break}case"html":{const o=i.text.replaceAll(/<[^>]*>/g,"");o.trim()&&e.push(r(l,{marginTop:s,children:r(m,{dimColor:!0,children:o})},n));break}case"list":{const o=i,d=T(o.items);o.ordered?e.push(r(l,{marginTop:s,children:r(j,{items:d})},n)):e.push(r(l,{marginTop:s,children:r(B,{items:d})},n));break}case"paragraph":{const o=i;e.push(r(l,{marginTop:s,children:r(m,{wrap:"wrap",children:p(o.tokens)})},n));break}case"space":{e.push(r(w,{},n));break}case"table":{const o=i,d=(o.header??[]).map(u=>u.text),g=(o.rows??[]).map(u=>u.map(f=>f.text)).map(u=>{const f={};return d.forEach((y,L)=>{f[y]=u[L]??""}),f});e.push(r(l,{marginTop:s,children:r(v,{data:g})},n));break}default:{const o="raw"in i?i.raw:"",d="text"in i?i.text:o;d&&e.push(r(l,{marginTop:s,children:r(m,{children:d})},n));break}}}return e}function A(c,a){const t=C.lex(c);if(!a||c.length===0)return t;let e=0;for(const n of t)e+=n.raw?.length??0;if(e<c.length){const n=c.slice(e);n.trim().length>0&&t.push({raw:n,text:n,tokens:[{raw:n,text:n,type:"text"}],type:"paragraph"})}return t}function P({children:c,codeTheme:a="github-dark-default",maxWidth:t,streaming:e=!1}){const{columns:n}=D(),h=t??n??80,i=b(()=>A(c,e),[c,e]),s=b(()=>$(i,a,h),[i,a,h]);return r(l,{flexDirection:"column",children:s})}export{P as Markdown,P as default};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
type Props = {
|
|
3
|
-
/**
|
|
4
|
-
* Initial raw value (digits/characters only, without mask symbols).
|
|
5
|
-
*/
|
|
6
|
-
readonly defaultValue?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Disable input and dim the display.
|
|
9
|
-
*/
|
|
10
|
-
readonly isDisabled?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Mask definition. Each `#` is replaced with a user character; any other
|
|
13
|
-
* character is rendered literally. Example: `(###) ###-####`.
|
|
14
|
-
*/
|
|
15
|
-
readonly mask: string;
|
|
16
|
-
/**
|
|
17
|
-
* Called whenever the underlying raw value changes.
|
|
18
|
-
*/
|
|
19
|
-
readonly onChange?: (value: string) => void;
|
|
20
|
-
/**
|
|
21
|
-
* Called when the user presses Enter with the current raw value.
|
|
22
|
-
*/
|
|
23
|
-
readonly onSubmit?: (value: string) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Placeholder character used in the mask for empty positions.
|
|
26
|
-
* @default "_"
|
|
27
|
-
*/
|
|
28
|
-
readonly placeholderChar?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Sentinel character in the mask string used to mark editable positions.
|
|
31
|
-
* @default "#" (hash)
|
|
32
|
-
*/
|
|
33
|
-
readonly token?: string;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Input with a fixed-width mask. The mask token (`#` by default) marks
|
|
37
|
-
* positions where the user can type; every other character is preserved.
|
|
38
|
-
* Supports ←/→ to move within the mask, Home/End to jump, and
|
|
39
|
-
* Backspace/Delete to clear characters.
|
|
40
|
-
*/
|
|
41
|
-
declare function MaskedInput({
|
|
42
|
-
defaultValue,
|
|
43
|
-
isDisabled,
|
|
44
|
-
mask,
|
|
45
|
-
onChange,
|
|
46
|
-
onSubmit,
|
|
47
|
-
placeholderChar,
|
|
48
|
-
token
|
|
49
|
-
}: Props): ReactElement;
|
|
50
|
-
export { MaskedInput, type Props as MaskedInputProps, Props, MaskedInput as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsxs as T,jsx as x}from"react/jsx-runtime";import{useMemo as V,useState as M,useCallback as A}from"react";import B from"../ink/hooks/use-input.js";import{Box as D}from"./box.js";import{Text as C}from"./text.js";const I=(m,n)=>{const s=[];let i=0;for(const[l,o]of[...m].entries())o===n&&(s.push({maskColumn:l,rawPosition:i}),i+=1);return s},L=(m,n,s,i)=>{let l=0,o="";for(const f of n)if(f===s){const u=m[l];u===void 0?o+=i:(o+=u,l+=1)}else o+=f;return o};function F({defaultValue:m="",isDisabled:n=!1,mask:s,onChange:i,onSubmit:l,placeholderChar:o="_",token:f="#"}){const u=V(()=>I(s,f),[s,f]),h=u.length,b=m.slice(0,h),[e,v]=M(b),[t,d]=M(b.length),g=A((c,r)=>{v(c),d(Math.max(0,Math.min(h,r))),i?.(c)},[h,i]);B(A((c,r)=>{if(r.return){l?.(e);return}if(r.leftArrow){d(a=>Math.max(0,a-1));return}if(r.rightArrow){d(a=>Math.min(e.length,a+1));return}if(r.home||r.ctrl&&c==="a"){d(0);return}if(r.end||r.ctrl&&c==="e"){d(e.length);return}if(r.backspace){if(t===0)return;const a=e.slice(0,t-1)+e.slice(t);g(a,t-1);return}if(r.delete){if(t>=e.length)return;const a=e.slice(0,t)+e.slice(t+1);g(a,t);return}if(c.length!==1||e.length>=h)return;const S=e.slice(0,t)+c+e.slice(t);g(S,t+1)},[e,t,h,g,l]),{isActive:!n});const p=L(e,s,f,o),k=u[t]?.maskColumn??s.length,w=p.slice(0,k),j=p.charAt(k)||" ",P=p.slice(k+1);return T(D,{children:[x(C,{dimColor:n,children:w}),x(C,{dimColor:n,inverse:!n,children:j}),x(C,{dimColor:n,children:P})]})}export{F as MaskedInput,F as default};
|