@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,74 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type RadioOption = {
|
|
5
|
-
readonly description?: string;
|
|
6
|
-
readonly key?: string;
|
|
7
|
-
readonly label: string;
|
|
8
|
-
readonly value: string;
|
|
9
|
-
};
|
|
10
|
-
type Props = {
|
|
11
|
-
/**
|
|
12
|
-
* Accent color for the focused and selected indicator.
|
|
13
|
-
* @default "blue"
|
|
14
|
-
*/
|
|
15
|
-
readonly accentColor?: LiteralUnion<AnsiColors, string>;
|
|
16
|
-
/**
|
|
17
|
-
* Auto-focus when mounted.
|
|
18
|
-
*/
|
|
19
|
-
readonly autoFocus?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* When true, moving focus with arrow keys immediately updates the selected
|
|
22
|
-
* value (and fires `onChange`). When false, focus moves independently and
|
|
23
|
-
* selection commits only on Space or Enter.
|
|
24
|
-
* @default true
|
|
25
|
-
*/
|
|
26
|
-
readonly commitOnNavigate?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Initial selected value when uncontrolled.
|
|
29
|
-
*/
|
|
30
|
-
readonly defaultValue?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Disable input and dim labels.
|
|
33
|
-
*/
|
|
34
|
-
readonly isDisabled?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Called when selection changes.
|
|
37
|
-
*/
|
|
38
|
-
readonly onChange?: (value: string) => void;
|
|
39
|
-
/**
|
|
40
|
-
* Called when the user submits by pressing Enter.
|
|
41
|
-
*/
|
|
42
|
-
readonly onSubmit?: (value: string) => void;
|
|
43
|
-
/**
|
|
44
|
-
* Available options.
|
|
45
|
-
*/
|
|
46
|
-
readonly options: ReadonlyArray<RadioOption>;
|
|
47
|
-
/**
|
|
48
|
-
* Orientation of options.
|
|
49
|
-
* @default "vertical"
|
|
50
|
-
*/
|
|
51
|
-
readonly orientation?: "horizontal" | "vertical";
|
|
52
|
-
/**
|
|
53
|
-
* Controlled selected value.
|
|
54
|
-
*/
|
|
55
|
-
readonly value?: string;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Single-choice radio group with keyboard navigation. By default, navigation
|
|
59
|
-
* commits selection; set `commitOnNavigate={false}` to require an explicit
|
|
60
|
-
* Space/Enter commit.
|
|
61
|
-
*/
|
|
62
|
-
declare function RadioGroup({
|
|
63
|
-
accentColor,
|
|
64
|
-
autoFocus,
|
|
65
|
-
commitOnNavigate,
|
|
66
|
-
defaultValue,
|
|
67
|
-
isDisabled,
|
|
68
|
-
onChange,
|
|
69
|
-
onSubmit,
|
|
70
|
-
options,
|
|
71
|
-
orientation,
|
|
72
|
-
value
|
|
73
|
-
}: Props): ReactElement;
|
|
74
|
-
export { Props, RadioGroup, type Props as RadioGroupProps, RadioOption, RadioGroup as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as h,jsxs as D}from"react/jsx-runtime";import{useState as z,useRef as G,useCallback as F}from"react";import S from"../ink/hooks/use-focus.js";import T from"../ink/hooks/use-input.js";import{Box as M}from"./box.js";import{Text as w}from"./text.js";const $=(x,s)=>{if(s===void 0)return 0;const l=x.findIndex(b=>b.value===s);return Math.max(l,0)};function E({accentColor:x="blue",autoFocus:s=!1,commitOnNavigate:l=!0,defaultValue:b,isDisabled:d=!1,onChange:A,onSubmit:k,options:t,orientation:i="vertical",value:m}){const{isFocused:a}=S({autoFocus:s,isActive:!d}),[C,R]=z(b??t[0]?.value),v=m??C,[g,j]=z(()=>$(t,v)),u=G(g);u.current=g;const c=F(r=>{const o=t[r];if(!o)return;const n=m??C;o.value!==n&&(m===void 0&&R(o.value),A?.(o.value))},[t,m,C,A]);return T(F((r,o)=>{if(!a)return;const n=t.length;if(n===0)return;const f=o.downArrow&&i==="vertical"||o.rightArrow&&i==="horizontal"||r==="j",p=o.upArrow&&i==="vertical"||o.leftArrow&&i==="horizontal"||r==="k";if(f){const e=Math.min(n-1,u.current+1);j(e),l&&c(e);return}if(p){const e=Math.max(0,u.current-1);j(e),l&&c(e);return}if(r===" "){c(u.current);return}if(o.return){l||c(u.current);const e=t[u.current]?.value??v;e!==void 0&&k?.(e)}},[a,t,i,c,l,v,k]),{isActive:!d&&a}),h(M,{flexDirection:i==="vertical"?"column":"row",gap:i==="vertical"?0:2,children:t.map((r,o)=>{const n=r.value===v,f=a&&o===g,p=(n||f)&&a?x:void 0;return D(M,{gap:1,children:[h(w,{color:p,dimColor:d,children:n?"●":"○"}),h(w,{bold:f,color:p,dimColor:d,children:r.label}),r.description===void 0?void 0:h(w,{dimColor:!0,children:r.description})]},r.key??r.value)})})}export{E as RadioGroup,E as default};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
import { LineSeries } from "./line-chart.js";
|
|
5
|
-
import "../packem_shared/buffer.d-EJkZr8uH.js";
|
|
6
|
-
type Props = {
|
|
7
|
-
readonly axisColor?: LiteralUnion<AnsiColors, string>;
|
|
8
|
-
readonly height?: number;
|
|
9
|
-
readonly maxX?: number;
|
|
10
|
-
readonly maxY?: number;
|
|
11
|
-
readonly minX?: number;
|
|
12
|
-
readonly minY?: number;
|
|
13
|
-
readonly palette?: ReadonlyArray<LiteralUnion<AnsiColors, string>>;
|
|
14
|
-
readonly series: ReadonlyArray<LineSeries>;
|
|
15
|
-
readonly showLegend?: boolean;
|
|
16
|
-
readonly width?: number;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Scatter plot rendered on a braille pixel grid. Each sample lights one
|
|
20
|
-
* sub-cell pixel; overlapping points merge into denser braille glyphs.
|
|
21
|
-
* @returns A `ReactElement` containing the plot and an optional legend.
|
|
22
|
-
*/
|
|
23
|
-
declare function ScatterPlot({
|
|
24
|
-
axisColor,
|
|
25
|
-
height,
|
|
26
|
-
maxX,
|
|
27
|
-
maxY,
|
|
28
|
-
minX,
|
|
29
|
-
minY,
|
|
30
|
-
palette,
|
|
31
|
-
series,
|
|
32
|
-
showLegend,
|
|
33
|
-
width
|
|
34
|
-
}: Props): ReactElement;
|
|
35
|
-
export { Props, ScatterPlot, type Props as ScatterPlotProps, ScatterPlot as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsxs as T,jsx as t}from"react/jsx-runtime";import{useMemo as h}from"react";import{Box as c}from"./box.js";import{Canvas as E}from"./canvas.js";import{t as f,p as g,c as y,D as b,d as C}from"../packem_shared/line-chart-C7CUrvVs.js";import{Text as N}from"./text.js";const S=b;function P({axisColor:a="gray",height:I=10,maxX:o,maxY:n,minX:m,minY:x,palette:s=S,series:l,showLegend:u=!0,width:p=40}){const d=h(()=>{const r=l.map((i,M)=>({color:g(i,M,s),points:f(i.data),series:i})),e=y(r);return{axisColor:a,palette:s,seriesList:r,xMax:o??(e.xMax===Number.NEGATIVE_INFINITY?1:e.xMax),xMin:m??(e.xMin===Number.POSITIVE_INFINITY?0:e.xMin),yMax:n??(e.yMax===Number.NEGATIVE_INFINITY?1:e.yMax),yMin:x??(e.yMin===Number.POSITIVE_INFINITY?0:e.yMin)}},[l,a,s,m,o,x,n]);return T(c,{flexDirection:"column",children:[t(E,{draw:r=>{C(r,"scatter",d)},height:I,version:[l,p,I,m,o,x,n,a,s],width:p}),u?t(c,{gap:2,marginTop:1,children:d.seriesList.map(({color:r,series:e},i)=>T(c,{gap:1,children:[t(N,{color:r,children:"●"}),t(N,{children:e.label??`Series ${i+1}`})]},`${i}:${e.label??""}`))}):void 0]})}export{P as ScatterPlot,P as default};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { BoxProps as Props } from "./box.js";
|
|
3
|
-
import 'type-fest';
|
|
4
|
-
import "../packem_shared/dom.d-B4kXbaVY.js";
|
|
5
|
-
import 'yoga-layout';
|
|
6
|
-
import "../packem_shared/cursor-helpers.d-BONB9tky.js";
|
|
7
|
-
import '@visulima/colorize';
|
|
8
|
-
import 'cli-boxes';
|
|
9
|
-
import "../packem_shared/styles.d-cMo36xQz.js";
|
|
10
|
-
interface ScrollBarBoxProps extends Props {
|
|
11
|
-
children?: React.ReactNode;
|
|
12
|
-
contentHeight: number;
|
|
13
|
-
scrollBarAutoHide?: boolean;
|
|
14
|
-
scrollBarPosition?: "left" | "right";
|
|
15
|
-
scrollOffset: number;
|
|
16
|
-
thumbChar?: string;
|
|
17
|
-
viewportHeight: number;
|
|
18
|
-
}
|
|
19
|
-
declare const ScrollBarBox: ({
|
|
20
|
-
borderColor,
|
|
21
|
-
borderDimColor,
|
|
22
|
-
borderLeftColor,
|
|
23
|
-
borderLeftDimColor,
|
|
24
|
-
borderRightColor,
|
|
25
|
-
borderRightDimColor,
|
|
26
|
-
borderStyle,
|
|
27
|
-
children,
|
|
28
|
-
contentHeight,
|
|
29
|
-
height,
|
|
30
|
-
scrollBarAutoHide,
|
|
31
|
-
scrollBarPosition,
|
|
32
|
-
scrollOffset,
|
|
33
|
-
thumbChar,
|
|
34
|
-
viewportHeight,
|
|
35
|
-
...boxProps
|
|
36
|
-
}: ScrollBarBoxProps) => React.JSX.Element;
|
|
37
|
-
export { ScrollBarBox, type ScrollBarBoxProps };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ScrollBarBox as l}from"../packem_shared/ScrollBarBox-DchESZWv.js";export{l as ScrollBarBox};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { BoxProps as Props } from "./box.js";
|
|
3
|
-
import 'type-fest';
|
|
4
|
-
import "../packem_shared/dom.d-B4kXbaVY.js";
|
|
5
|
-
import 'yoga-layout';
|
|
6
|
-
import "../packem_shared/cursor-helpers.d-BONB9tky.js";
|
|
7
|
-
import '@visulima/colorize';
|
|
8
|
-
import 'cli-boxes';
|
|
9
|
-
import "../packem_shared/styles.d-cMo36xQz.js";
|
|
10
|
-
type ScrollBarPlacement = "inset" | "left" | "right";
|
|
11
|
-
type ScrollBarStyle = Props["borderStyle"] | "block" | "line" | "thick" | "dots";
|
|
12
|
-
interface ScrollBarProps {
|
|
13
|
-
autoHide?: boolean;
|
|
14
|
-
color?: string;
|
|
15
|
-
contentHeight: number;
|
|
16
|
-
dimColor?: boolean;
|
|
17
|
-
placement?: ScrollBarPlacement;
|
|
18
|
-
scrollOffset: number;
|
|
19
|
-
style?: ScrollBarStyle;
|
|
20
|
-
thumbChar?: string;
|
|
21
|
-
trackChar?: string;
|
|
22
|
-
viewportHeight: number;
|
|
23
|
-
}
|
|
24
|
-
declare const ScrollBar: React.FC<ScrollBarProps>;
|
|
25
|
-
export { ScrollBar, type ScrollBarPlacement, type ScrollBarProps, type ScrollBarStyle };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ScrollBar as l}from"../packem_shared/ScrollBar-qa1IzDDv.js";export{l as ScrollBar};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React, { Ref } from 'react';
|
|
2
|
-
import { a as ScrollViewProps, b as ScrollViewRef } from "../packem_shared/scroll-view.d-DtpsgHLg.js";
|
|
3
|
-
import "./box.js";
|
|
4
|
-
import 'type-fest';
|
|
5
|
-
import "../packem_shared/dom.d-B4kXbaVY.js";
|
|
6
|
-
import 'yoga-layout';
|
|
7
|
-
import "../packem_shared/cursor-helpers.d-BONB9tky.js";
|
|
8
|
-
import '@visulima/colorize';
|
|
9
|
-
import 'cli-boxes';
|
|
10
|
-
import "../packem_shared/styles.d-cMo36xQz.js";
|
|
11
|
-
type ScrollAlignment = "auto" | "bottom" | "center" | "top";
|
|
12
|
-
interface ScrollListProps extends ScrollViewProps {
|
|
13
|
-
readonly scrollAlignment?: ScrollAlignment;
|
|
14
|
-
readonly selectedIndex?: number;
|
|
15
|
-
}
|
|
16
|
-
type ScrollListRef = ScrollViewRef;
|
|
17
|
-
declare const ScrollList: (props: ScrollListProps & {
|
|
18
|
-
ref?: Ref<ScrollListRef>;
|
|
19
|
-
}) => React.JSX.Element;
|
|
20
|
-
export { type ScrollAlignment, ScrollList, type ScrollListProps, type ScrollListRef };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ScrollList as l}from"../packem_shared/ScrollList-BBAnRsrC.js";export{l as ScrollList};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { S as ScrollView, type a as ScrollViewProps, type b as ScrollViewRef } from "../packem_shared/scroll-view.d-DtpsgHLg.js";
|
|
2
|
-
import 'react';
|
|
3
|
-
import "./box.js";
|
|
4
|
-
import 'type-fest';
|
|
5
|
-
import "../packem_shared/dom.d-B4kXbaVY.js";
|
|
6
|
-
import 'yoga-layout';
|
|
7
|
-
import "../packem_shared/cursor-helpers.d-BONB9tky.js";
|
|
8
|
-
import '@visulima/colorize';
|
|
9
|
-
import 'cli-boxes';
|
|
10
|
-
import "../packem_shared/styles.d-cMo36xQz.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ScrollView as e}from"../packem_shared/ScrollView-CHAo7Epj.js";export{e as ScrollView};
|
|
@@ -1,55 +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
|
-
* Color of the accent elements (border, icon).
|
|
7
|
-
* @default "blue"
|
|
8
|
-
*/
|
|
9
|
-
readonly accentColor?: LiteralUnion<AnsiColors, string>;
|
|
10
|
-
/**
|
|
11
|
-
* Initial value.
|
|
12
|
-
*/
|
|
13
|
-
readonly defaultValue?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Node rendered before the input as a search affordance.
|
|
16
|
-
* @default "⌕" (telephone recorder)
|
|
17
|
-
*/
|
|
18
|
-
readonly icon?: ReactNode;
|
|
19
|
-
/**
|
|
20
|
-
* Disable the input.
|
|
21
|
-
*/
|
|
22
|
-
readonly isDisabled?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Fired whenever the value changes.
|
|
25
|
-
*/
|
|
26
|
-
readonly onChange?: (value: string) => void;
|
|
27
|
-
/**
|
|
28
|
-
* Fired when the user presses Enter.
|
|
29
|
-
*/
|
|
30
|
-
readonly onSubmit?: (value: string) => void;
|
|
31
|
-
/**
|
|
32
|
-
* Placeholder text shown when the input is empty.
|
|
33
|
-
* @default "Search..."
|
|
34
|
-
*/
|
|
35
|
-
readonly placeholder?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Autocomplete suggestions.
|
|
38
|
-
*/
|
|
39
|
-
readonly suggestions?: ReadonlyArray<string>;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Search-styled text input with an icon and bordered container.
|
|
43
|
-
* @returns A `ReactElement` wrapping `TextInput` with an icon column.
|
|
44
|
-
*/
|
|
45
|
-
declare function SearchInput({
|
|
46
|
-
accentColor,
|
|
47
|
-
defaultValue,
|
|
48
|
-
icon,
|
|
49
|
-
isDisabled,
|
|
50
|
-
onChange,
|
|
51
|
-
onSubmit,
|
|
52
|
-
placeholder,
|
|
53
|
-
suggestions
|
|
54
|
-
}: Props): ReactElement;
|
|
55
|
-
export { Props, SearchInput, type Props as SearchInputProps, SearchInput as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsxs as u,jsx as e}from"react/jsx-runtime";import{Box as r}from"./box.js";import{Text as c}from"./text.js";import{TextInput as p}from"./text-input.js";function b({accentColor:o="blue",defaultValue:a="",icon:l="⌕",isDisabled:n=!1,onChange:t,onSubmit:s,placeholder:i="Search...",suggestions:d}){return u(r,{borderColor:o,borderStyle:"round",gap:1,paddingX:1,children:[e(c,{color:o,children:l}),e(r,{flexGrow:1,children:e(p,{defaultValue:a,isDisabled:n,onChange:t,onSubmit:s,placeholder:i,suggestions:d})})]})}export{b as SearchInput,b as default};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type Props = {
|
|
5
|
-
/**
|
|
6
|
-
* Color of the indicator when selected.
|
|
7
|
-
* @default "blue"
|
|
8
|
-
*/
|
|
9
|
-
readonly accentColor?: LiteralUnion<AnsiColors, string>;
|
|
10
|
-
/**
|
|
11
|
-
* Whether the parent SelectInput has focus.
|
|
12
|
-
* When `false`, the indicator is dimmed even if the item is selected.
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
readonly isFocused?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Whether this indicator's item is currently selected.
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
readonly isSelected?: boolean;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Renders a pointer indicator next to the selected item, or a blank space otherwise.
|
|
24
|
-
* When unfocused, the indicator is rendered with `dimColor` to visually distinguish
|
|
25
|
-
* the active select input from inactive ones.
|
|
26
|
-
*/
|
|
27
|
-
declare function SelectInputIndicator({
|
|
28
|
-
accentColor,
|
|
29
|
-
isFocused,
|
|
30
|
-
isSelected
|
|
31
|
-
}: Props): ReactElement;
|
|
32
|
-
export { Props, SelectInputIndicator, type Props as SelectInputIndicatorProps, SelectInputIndicator as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{Box as c}from"./box.js";import{Text as e}from"./text.js";function s({accentColor:o="blue",isFocused:t=!0,isSelected:i=!1}){return r(c,{marginRight:1,children:i?r(e,{color:o,dimColor:!t,children:"❯"}):r(e,{children:" "})})}export{s as SelectInputIndicator,s as default};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type Props = {
|
|
5
|
-
/**
|
|
6
|
-
* Color of the label when selected.
|
|
7
|
-
* @default "blue"
|
|
8
|
-
*/
|
|
9
|
-
readonly accentColor?: LiteralUnion<AnsiColors, string>;
|
|
10
|
-
/**
|
|
11
|
-
* Color of the label when not selected.
|
|
12
|
-
*/
|
|
13
|
-
readonly defaultColor?: LiteralUnion<AnsiColors, string>;
|
|
14
|
-
/**
|
|
15
|
-
* Whether the parent SelectInput has focus.
|
|
16
|
-
* When `false`, the selected item is dimmed.
|
|
17
|
-
* @default true
|
|
18
|
-
*/
|
|
19
|
-
readonly isFocused?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Whether this item is currently selected.
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
readonly isSelected?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Text label to display for this item.
|
|
27
|
-
*/
|
|
28
|
-
readonly label: string;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Renders an item label, using `accentColor` when selected and `defaultColor` otherwise.
|
|
32
|
-
* When unfocused, selected items are rendered with `dimColor`.
|
|
33
|
-
*/
|
|
34
|
-
declare function SelectInputItem({
|
|
35
|
-
accentColor,
|
|
36
|
-
defaultColor,
|
|
37
|
-
isFocused,
|
|
38
|
-
isSelected,
|
|
39
|
-
label
|
|
40
|
-
}: Props): ReactElement;
|
|
41
|
-
export { Props, SelectInputItem, type Props as SelectInputItemProps, SelectInputItem as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as a}from"react/jsx-runtime";import{Text as c}from"./text.js";function i({accentColor:o="blue",defaultColor:t,isFocused:l=!0,isSelected:e=!1,label:r}){return a(c,{color:e?o:t,dimColor:e&&!l,children:r})}export{i as SelectInputItem,i as default};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { FC, ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
import { Props as Props$1 } from "./select-input-indicator.js";
|
|
5
|
-
import { Props as Props$2 } from "./select-input-item.js";
|
|
6
|
-
type Item<V> = {
|
|
7
|
-
/**
|
|
8
|
-
* Called automatically when this item is selected (via Enter or number key).
|
|
9
|
-
* Fires after `onSelect`. Useful for defining per-item behavior inline.
|
|
10
|
-
*/
|
|
11
|
-
readonly action?: () => void;
|
|
12
|
-
readonly key?: string;
|
|
13
|
-
readonly label: string;
|
|
14
|
-
readonly value: V;
|
|
15
|
-
};
|
|
16
|
-
type SeparatorItem = {
|
|
17
|
-
/**
|
|
18
|
-
* Marks this entry as a non-focusable separator line.
|
|
19
|
-
*/
|
|
20
|
-
readonly isSeparator: true;
|
|
21
|
-
readonly key?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Custom separator text. Defaults to `"───"`.
|
|
24
|
-
*/
|
|
25
|
-
readonly label?: string;
|
|
26
|
-
};
|
|
27
|
-
type SelectInputEntry<V> = Item<V> | SeparatorItem;
|
|
28
|
-
type Props<V> = {
|
|
29
|
-
/**
|
|
30
|
-
* Color used for the selected item and indicator.
|
|
31
|
-
* @default "blue"
|
|
32
|
-
*/
|
|
33
|
-
readonly accentColor?: LiteralUnion<AnsiColors, string>;
|
|
34
|
-
/**
|
|
35
|
-
* Color used for unselected items.
|
|
36
|
-
*/
|
|
37
|
-
readonly defaultColor?: LiteralUnion<AnsiColors, string>;
|
|
38
|
-
/**
|
|
39
|
-
* Controlled selected index. When provided, the component becomes controlled
|
|
40
|
-
* and `initialIndex` is ignored. Update this value in the `onHighlight` callback
|
|
41
|
-
* to track selection externally. If the index points to a separator, the nearest
|
|
42
|
-
* selectable item is highlighted instead.
|
|
43
|
-
*/
|
|
44
|
-
readonly index?: number;
|
|
45
|
-
/**
|
|
46
|
-
* Custom component to override the default indicator component.
|
|
47
|
-
*/
|
|
48
|
-
readonly indicatorComponent?: FC<Props$1>;
|
|
49
|
-
/**
|
|
50
|
-
* Index of initially-selected item in `items` array.
|
|
51
|
-
* Ignored when `index` is provided.
|
|
52
|
-
* When omitted (`undefined`), no item is highlighted until the user presses a key.
|
|
53
|
-
* If the index points to a separator, the nearest selectable item is used.
|
|
54
|
-
*/
|
|
55
|
-
readonly initialIndex?: number;
|
|
56
|
-
/**
|
|
57
|
-
* Whether the input is focused. Useful for when there are multiple
|
|
58
|
-
* inputs on the screen and you need to control which one captures input.
|
|
59
|
-
* @default true
|
|
60
|
-
*/
|
|
61
|
-
readonly isFocused?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Custom component to override the default item component.
|
|
64
|
-
*/
|
|
65
|
-
readonly itemComponent?: FC<Props$2>;
|
|
66
|
-
/** @default [] */
|
|
67
|
-
readonly items?: ReadonlyArray<SelectInputEntry<V>>;
|
|
68
|
-
/**
|
|
69
|
-
* Number of visible items. Useful if the list is long and you want
|
|
70
|
-
* to limit the display with a scrolling window.
|
|
71
|
-
*/
|
|
72
|
-
readonly limit?: number;
|
|
73
|
-
/**
|
|
74
|
-
* Called when the user highlights a new item via arrow keys or `j`/`k`.
|
|
75
|
-
* The second argument is the index of the highlighted item in the visible list.
|
|
76
|
-
*/
|
|
77
|
-
readonly onHighlight?: (item: Item<V>, index: number) => void;
|
|
78
|
-
/**
|
|
79
|
-
* Called when the user selects an item via Enter or a number key (1-9).
|
|
80
|
-
*/
|
|
81
|
-
readonly onSelect?: (item: Item<V>) => void;
|
|
82
|
-
/**
|
|
83
|
-
* Whether to reset the selection when items change.
|
|
84
|
-
* Set to `false` to preserve the current selection across item updates.
|
|
85
|
-
* @default true
|
|
86
|
-
*/
|
|
87
|
-
readonly resetOnItemsChange?: boolean;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* A select input component for terminal UIs.
|
|
91
|
-
*
|
|
92
|
-
* Renders a list of items with an indicator showing the currently highlighted item.
|
|
93
|
-
* Users can navigate with arrow keys or `j`/`k`, select with Enter, or jump to an
|
|
94
|
-
* item by pressing a number key (1-9).
|
|
95
|
-
*/
|
|
96
|
-
declare function SelectInput<V>({
|
|
97
|
-
accentColor,
|
|
98
|
-
defaultColor,
|
|
99
|
-
index,
|
|
100
|
-
indicatorComponent,
|
|
101
|
-
initialIndex,
|
|
102
|
-
isFocused,
|
|
103
|
-
itemComponent,
|
|
104
|
-
items,
|
|
105
|
-
limit: customLimit,
|
|
106
|
-
onHighlight,
|
|
107
|
-
onSelect,
|
|
108
|
-
resetOnItemsChange
|
|
109
|
-
}: Props<V>): ReactElement;
|
|
110
|
-
export { Item, Props, SelectInput, SelectInputEntry, type Item as SelectInputItemType, type Props as SelectInputProps, type SeparatorItem as SelectInputSeparator, SeparatorItem, SelectInput as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as ee}from"node:module";import{jsx as F,jsxs as re}from"react/jsx-runtime";import{useReducer as se,useRef as v,useMemo as ce,useEffect as V,useCallback as R,createElement as X}from"react";import ie from"../ink/hooks/use-input.js";import ae from"../ink/hooks/use-window-size.js";import{Box as D}from"./box.js";import{SelectInputIndicator as le}from"./select-input-indicator.js";import{SelectInputItem as de}from"./select-input-item.js";import{Text as ue}from"./text.js";const te=ee(import.meta.url),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=n=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[t,o]=M.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return M.getBuiltinModule(n)}return te(n)},{isDeepStrictEqual:oe}=ne("node:util"),h=n=>"isSeparator"in n&&n.isSeparator,fe=[],pe=/^[1-9]$/,l=-1,me="───",Ie=Symbol("separator"),xe=(n,t)=>{switch(t.type){case"navigate":return{rotateIndex:t.rotateIndex,selectedIndex:t.selectedIndex};case"reset":return{rotateIndex:0,selectedIndex:t.hasInitialSelection?t.initialIndex:l};case"set":return{rotateIndex:t.selectedIndex,selectedIndex:t.selectedIndex};default:return n}},ge=(n,t)=>{const{length:o}=n;if(o===0)return[];const u=(t%o+o)%o;return[...n.slice(u),...n.slice(0,u)]},b=(n,t,o,u)=>t?ge(n,o).slice(0,u):n,q=(n,t,o)=>{const{length:u}=n;for(let S=0;S<u;S+=1){const C=((t+(S+1)*o)%u+u)%u;if(!h(n[C]))return C}return l},Y=(n,t)=>{if(t<0||t>=n.length)return l;const o=n[t];return o&&!h(o)?t:q(n,t-1,1)};function Me({accentColor:n="blue",defaultColor:t,index:o,indicatorComponent:u=le,initialIndex:S,isFocused:C=!0,itemComponent:Z=de,items:r=fe,limit:E,onHighlight:f,onSelect:N,resetOnItemsChange:B=!0}){const{rows:Q}=ae(),H=typeof E=="number"?E:Q,s=r.length>H,d=s?Math.min(H,r.length):r.length,j=d-1,O=typeof o=="number"||typeof S=="number",P=typeof o=="number"?o:S??l,w=P===l?l:Y(r,Math.min(P,j)),[T,_]=se(xe,{rotateIndex:w>j?j-w:0,selectedIndex:w}),z=v(O),G=v(w),J=v(T);J.current=T;const A=v(N);A.current=N;const W=v(r),k=ce(()=>r.map(e=>h(e)?Ie:e.value),[r]),K=v(k);z.current=O,G.current=w,V(()=>{B&&!oe(K.current,k)&&_({hasInitialSelection:z.current,initialIndex:G.current,type:"reset"}),K.current=k,W.current=r},[r,k,B]),V(()=>{if(typeof o=="number"){const e=Y(r,Math.min(o,j));_({selectedIndex:e===l?0:e,type:"set"})}},[o,r,j]);const L=R((e,c)=>{const i=b(r,s,e,d);if(c===l){const x=q(i,0,-1);if(x===l)return;_({rotateIndex:e,selectedIndex:x,type:"navigate"}),typeof f=="function"&&f(i[x],x);return}const g=(s?d:r.length)-1,a=c===0,p=a?g:c-1,m=a&&s?e+1:e,y=b(r,s,m,d),I=h(y[p])?q(y,p,-1):p;I!==l&&(_({rotateIndex:m,selectedIndex:I,type:"navigate"}),typeof f=="function"&&f(y[I],I))},[s,d,r,f]),U=R((e,c)=>{const i=b(r,s,e,d);if(c===l){const x=q(i,i.length-1,1);if(x===l)return;_({rotateIndex:e,selectedIndex:x,type:"navigate"}),typeof f=="function"&&f(i[x],x);return}const g=(s?d:r.length)-1,a=c===g,p=a?0:c+1,m=a&&s?e-1:e,y=b(r,s,m,d),I=h(y[p])?q(y,p,1):p;I!==l&&(_({rotateIndex:m,selectedIndex:I,type:"navigate"}),typeof f=="function"&&f(y[I],I))},[s,d,r,f]);ie(R((e,c)=>{const{rotateIndex:i,selectedIndex:g}=J.current;if((e==="k"||c.upArrow)&&L(i,g),(e==="j"||c.downArrow)&&U(i,g),pe.test(e)){const a=Number.parseInt(e,10)-1,p=b(r,s,i,d);if(a>=0&&a<p.length){const m=p[a];m&&!h(m)&&(A.current?.(m),m.action?.())}}if(c.return&&g!==l){const a=b(r,s,i,d)[g];a&&!h(a)&&(A.current?.(a),a.action?.())}},[L,U,s,d,r]),{isActive:C});const $=b(r,s,T.rotateIndex,d);return F(D,{flexDirection:"column",children:$.map((e,c)=>{if(h(e))return F(D,{children:F(ue,{dimColor:!0,children:e.label??me})},e.key??`separator-${String(c)}`);const i=c===T.selectedIndex;return re(D,{children:[X(u,{accentColor:n,isFocused:C,isSelected:i}),X(Z,{...e,accentColor:n,defaultColor:t,isFocused:C,isSelected:i})]},e.key??String(e.value))})})}export{Me as SelectInput,Me as default};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type Props = {
|
|
5
|
-
/**
|
|
6
|
-
* Width of the highlighted band in characters.
|
|
7
|
-
* @default 3
|
|
8
|
-
*/
|
|
9
|
-
readonly bandWidth?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Base color of the non-highlighted text.
|
|
12
|
-
*/
|
|
13
|
-
readonly color?: LiteralUnion<AnsiColors, string>;
|
|
14
|
-
/**
|
|
15
|
-
* Highlight color of the sweeping band.
|
|
16
|
-
* @default "white"
|
|
17
|
-
*/
|
|
18
|
-
readonly highlightColor?: LiteralUnion<AnsiColors, string>;
|
|
19
|
-
/**
|
|
20
|
-
* Milliseconds between frames of the shimmer.
|
|
21
|
-
* @default 60
|
|
22
|
-
*/
|
|
23
|
-
readonly interval?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Text to render with a shimmer sweep.
|
|
26
|
-
*/
|
|
27
|
-
readonly text: string;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Text with an animated highlight band that sweeps across the characters.
|
|
31
|
-
* Perfect for "generating…" states.
|
|
32
|
-
* @param props Component props.
|
|
33
|
-
* @param props.bandWidth Number of characters in the bright band.
|
|
34
|
-
* @param props.color Color applied to characters outside the band.
|
|
35
|
-
* @param props.highlightColor Color applied to characters inside the band.
|
|
36
|
-
* @param props.interval Milliseconds between frames.
|
|
37
|
-
* @param props.text Content to shimmer.
|
|
38
|
-
* @returns A single `Text` element composed of per-character `Text` children.
|
|
39
|
-
*/
|
|
40
|
-
declare function ShimmerText({
|
|
41
|
-
bandWidth,
|
|
42
|
-
color,
|
|
43
|
-
highlightColor,
|
|
44
|
-
interval,
|
|
45
|
-
text
|
|
46
|
-
}: Props): ReactElement;
|
|
47
|
-
export { Props, ShimmerText, type Props as ShimmerTextProps, ShimmerText as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useMemo as f}from"react";import g from"../ink/hooks/use-animation.js";import{Text as i}from"./text.js";function j({bandWidth:m=3,color:r,highlightColor:a="white",interval:d=60,text:n}){const{frame:u}=g({interval:d}),t=f(()=>[...n],[n]),l=t.length,p=l+m,x=l===0?0:u%p,b=f(()=>t.map((o,c)=>e(i,{color:r,dimColor:r===void 0,children:o},c)),[t,r]);if(l===0)return e(i,{color:r,children:n});const h=[];for(const[o,c]of t.entries()){const s=x-o;if(!(s>=0&&s<m)){h.push(b[o]);continue}h.push(e(i,{bold:!0,color:a,children:c},`band-${o}`))}return e(i,{children:h})}export{j as ShimmerText,j as default};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type Props = {
|
|
5
|
-
/**
|
|
6
|
-
* Accent color for the filled portion of the track and thumb.
|
|
7
|
-
* @default "green"
|
|
8
|
-
*/
|
|
9
|
-
readonly accentColor?: LiteralUnion<AnsiColors, string>;
|
|
10
|
-
/**
|
|
11
|
-
* Color for the empty portion of the track.
|
|
12
|
-
* @default "gray"
|
|
13
|
-
*/
|
|
14
|
-
readonly defaultColor?: LiteralUnion<AnsiColors, string>;
|
|
15
|
-
/**
|
|
16
|
-
* Initial value when uncontrolled.
|
|
17
|
-
* @default 0
|
|
18
|
-
*/
|
|
19
|
-
readonly defaultValue?: number;
|
|
20
|
-
/**
|
|
21
|
-
* Character used for the empty portion of the track.
|
|
22
|
-
* @default "░"
|
|
23
|
-
*/
|
|
24
|
-
readonly emptyCharacter?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Character used for the filled portion of the track.
|
|
27
|
-
* @default "█"
|
|
28
|
-
*/
|
|
29
|
-
readonly filledCharacter?: string;
|
|
30
|
-
/**
|
|
31
|
-
* When true, all input is ignored and the slider is dimmed.
|
|
32
|
-
* @default false
|
|
33
|
-
*/
|
|
34
|
-
readonly isDisabled?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* When true, the component responds to keyboard input.
|
|
37
|
-
* @default true
|
|
38
|
-
*/
|
|
39
|
-
readonly isFocused?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Maximum value.
|
|
42
|
-
* @default 100
|
|
43
|
-
*/
|
|
44
|
-
readonly max?: number;
|
|
45
|
-
/**
|
|
46
|
-
* Minimum value.
|
|
47
|
-
* @default 0
|
|
48
|
-
*/
|
|
49
|
-
readonly min?: number;
|
|
50
|
-
/**
|
|
51
|
-
* Fires whenever the value changes.
|
|
52
|
-
*/
|
|
53
|
-
readonly onChange?: (value: number) => void;
|
|
54
|
-
/**
|
|
55
|
-
* Layout direction of the slider.
|
|
56
|
-
* @default "horizontal"
|
|
57
|
-
*/
|
|
58
|
-
readonly orientation?: "horizontal" | "vertical";
|
|
59
|
-
/**
|
|
60
|
-
* Increment size for arrow key presses.
|
|
61
|
-
* @default 1
|
|
62
|
-
*/
|
|
63
|
-
readonly step?: number;
|
|
64
|
-
/**
|
|
65
|
-
* Character used to indicate the current position.
|
|
66
|
-
* @default "●"
|
|
67
|
-
*/
|
|
68
|
-
readonly thumbCharacter?: string;
|
|
69
|
-
/**
|
|
70
|
-
* Controlled value. When provided, `defaultValue` is ignored.
|
|
71
|
-
*/
|
|
72
|
-
readonly value?: number;
|
|
73
|
-
/**
|
|
74
|
-
* Width of the slider track in columns (horizontal) or rows (vertical).
|
|
75
|
-
* @default 20
|
|
76
|
-
*/
|
|
77
|
-
readonly width?: number;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* A keyboard-driven slider / range input.
|
|
81
|
-
*
|
|
82
|
-
* ```tsx
|
|
83
|
-
* <Slider defaultValue={50} min={0} max={100} onChange={setValue} />
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
declare function Slider({
|
|
87
|
-
accentColor,
|
|
88
|
-
defaultColor,
|
|
89
|
-
defaultValue,
|
|
90
|
-
emptyCharacter,
|
|
91
|
-
filledCharacter,
|
|
92
|
-
isDisabled,
|
|
93
|
-
isFocused,
|
|
94
|
-
max,
|
|
95
|
-
min,
|
|
96
|
-
onChange,
|
|
97
|
-
orientation,
|
|
98
|
-
step,
|
|
99
|
-
thumbCharacter,
|
|
100
|
-
value: controlledValue,
|
|
101
|
-
width
|
|
102
|
-
}: Props): ReactElement;
|
|
103
|
-
export { Props, Slider, type Props as SliderProps, Slider as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as c,jsxs as H}from"react/jsx-runtime";import{useState as R,useRef as I,useCallback as J}from"react";import T from"../ink/hooks/use-input.js";import{Box as A}from"./box.js";import{Text as C}from"./text.js";const y=(u,d,x)=>Math.min(x,Math.max(d,u));function P({accentColor:u="green",defaultColor:d="gray",defaultValue:x=0,emptyCharacter:D="░",filledCharacter:j="█",isDisabled:e=!1,isFocused:K=!0,max:k=100,min:z=0,onChange:F,orientation:h="horizontal",step:m=1,thumbCharacter:N="●",value:q,width:L=20}){const o=Math.min(z,k),i=Math.max(z,k),b=q!==void 0,[O,Q]=R(y(x,o,i)),v=b?y(q,o,i):O,G=I(F);G.current=F;const s=I(v);s.current=v;const n=J(t=>{const r=y(t,o,i);b||Q(r),G.current?.(r)},[o,i,b]),w=m*10,f=i-o,S=J((t,r)=>{const M=h==="horizontal"?r.rightArrow:r.upArrow,p=h==="horizontal"?r.leftArrow:r.downArrow;if(M){n(s.current+m);return}if(p){n(s.current-m);return}if(r.pageUp){n(s.current+w);return}if(r.pageDown){n(s.current-w);return}if(r.home){n(o);return}if(r.end){n(i);return}if(t>="0"&&t<="9"){const E=Number.parseInt(t,10)/10;n(o+f*E)}},[m,w,o,i,f,h,n]);T(S,{isActive:K&&!e});const g=Math.max(1,L),V=f===0?0:(v-o)/f,l=Math.round(V*(g-1));if(h==="vertical"){const t=[];for(let r=g-1;r>=0;r--){const M=r===l,p=r<=l;t.push(c(A,{children:c(C,{color:e?void 0:p?u:d,dimColor:e,children:M?N:p?j:D})},r))}return c(A,{flexDirection:"column",children:t})}let a="";for(let t=0;t<g;t++)t===l?a+=N:t<l?a+=j:a+=D;const W=a.slice(0,l),$=a[l]??"",B=a.slice(l+1);return H(A,{children:[c(C,{color:e?void 0:u,dimColor:e,children:W}),c(C,{bold:!0,color:e?void 0:u,dimColor:e,children:$}),c(C,{color:e?void 0:d,dimColor:e,children:B})]})}export{P as Slider,P as default};
|