@visulima/tui 1.0.7 → 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 +4 -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,48 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
type Props = {
|
|
3
|
-
/** @default "" */
|
|
4
|
-
readonly defaultValue?: string;
|
|
5
|
-
/**
|
|
6
|
-
* When true, all input is ignored and text is dimmed.
|
|
7
|
-
* @default false
|
|
8
|
-
*/
|
|
9
|
-
readonly isDisabled?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* When true, renders asterisks instead of the actual characters.
|
|
12
|
-
* @default false
|
|
13
|
-
*/
|
|
14
|
-
readonly mask?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Fires on every keystroke with the updated text.
|
|
17
|
-
*/
|
|
18
|
-
readonly onChange?: (value: string) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Fires when the user presses Enter.
|
|
21
|
-
*/
|
|
22
|
-
readonly onSubmit?: (value: string) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Greyed-out text shown when the input is empty.
|
|
25
|
-
*/
|
|
26
|
-
readonly placeholder?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Autocomplete candidates. The first case-sensitive prefix match is shown
|
|
29
|
-
* dimmed after the current input. Press right-arrow or Enter to accept.
|
|
30
|
-
*/
|
|
31
|
-
readonly suggestions?: ReadonlyArray<string>;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* A single-line text input with cursor navigation, optional placeholder,
|
|
35
|
-
* autocomplete suggestions, and password masking.
|
|
36
|
-
*
|
|
37
|
-
* Supports arrow keys, Home/End, Ctrl+A/E, Ctrl+U/K/W, Backspace, Delete.
|
|
38
|
-
*/
|
|
39
|
-
declare function TextInput({
|
|
40
|
-
defaultValue,
|
|
41
|
-
isDisabled,
|
|
42
|
-
mask,
|
|
43
|
-
onChange,
|
|
44
|
-
onSubmit,
|
|
45
|
-
placeholder,
|
|
46
|
-
suggestions
|
|
47
|
-
}: Props): ReactElement;
|
|
48
|
-
export { Props, TextInput, type Props as TextInputProps, TextInput as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as f,jsxs as w}from"react/jsx-runtime";import{useState as q,useRef as k,useCallback as L}from"react";import N from"../ink/hooks/use-input.js";import{i as O}from"../packem_shared/input-utils-BSWCb4F_.js";import{Box as I}from"./box.js";import{Text as h}from"./text.js";const P=/\S+\s*$/,S=(n,r)=>n.length===0||!r?void 0:r.find(t=>t.startsWith(n))?.slice(n.length)??void 0,y=-1,T=(n,r,t,e)=>r.leftArrow?Math.max(0,t-1):r.home||r.ctrl&&n==="a"?0:r.end||r.ctrl&&n==="e"?e:y,V=(n,r,t,e)=>{if(r.backspace&&e>0)return[t.slice(0,e-1)+t.slice(e),e-1];if(r.delete&&e<t.length)return[t.slice(0,e)+t.slice(e+1),e];if(r.ctrl&&n==="u")return[t.slice(e),0];if(r.ctrl&&n==="k")return[t.slice(0,e),e];if(r.ctrl&&n==="w"){const m=t.slice(0,e).replace(P,"");return[m+t.slice(e),m.length]}};function U({defaultValue:n="",isDisabled:r=!1,mask:t=!1,onChange:e,onSubmit:m,placeholder:x,suggestions:b}){const[o,v]=q(n),[d,u]=q(n.length),A=k(o);A.current=o;const M=k(d);M.current=d;const g=k(e);g.current=e;const j=k(m);j.current=m;const B=S(o,b),z=L((p,a)=>{const{current:s}=M,c=A.current;if(a.return){const i=S(c,b),l=i?c+i:c;i&&(v(l),u(l.length),g.current?.(l)),j.current?.(l);return}if(a.escape)return;if(a.rightArrow){const i=S(c,b);if(s===c.length&&i){const l=c+i;v(l),u(l.length),g.current?.(l);return}u(Math.min(c.length,s+1));return}const D=T(p,a,s,c.length);if(D!==y){u(D);return}const R=V(p,a,c,s);if(R){const[i,l]=R;v(i),u(l),g.current?.(i);return}if(O(p,a)){const i=c.slice(0,s)+p+c.slice(s);v(i),u(s+p.length),g.current?.(i)}},[b]);N(z,{isActive:!r});const C=t?"*".repeat(o.length):o,E=C.slice(0,d),F=C[d],H=C.slice(d+1);return r?f(I,{children:f(h,{dimColor:!0,children:C||x||""})}):o.length===0&&x?w(I,{children:[f(h,{dimColor:!0,inverse:!0,children:x[0]}),f(h,{dimColor:!0,children:x.slice(1)})]}):w(I,{children:[w(h,{children:[E,f(h,{inverse:!0,children:F??" "}),H]}),B?f(h,{dimColor:!0,children:B}):void 0]})}export{U as TextInput,U as default};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
type Props = {
|
|
3
|
-
/** @default "" */
|
|
4
|
-
readonly defaultValue?: string;
|
|
5
|
-
/**
|
|
6
|
-
* When true, all input is ignored and text is dimmed.
|
|
7
|
-
* @default false
|
|
8
|
-
*/
|
|
9
|
-
readonly isDisabled?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* When true, the component responds to keyboard input.
|
|
12
|
-
* @default true
|
|
13
|
-
*/
|
|
14
|
-
readonly isFocused?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Maximum visible rows before viewport scrolling kicks in.
|
|
17
|
-
* When set, the textarea will grow from `rows` to `maxRows` before scrolling.
|
|
18
|
-
*/
|
|
19
|
-
readonly maxRows?: number;
|
|
20
|
-
/**
|
|
21
|
-
* Fires on every edit with the updated text.
|
|
22
|
-
*/
|
|
23
|
-
readonly onChange?: (value: string) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Fires when the user presses Meta+Enter or Ctrl+Enter.
|
|
26
|
-
*/
|
|
27
|
-
readonly onSubmit?: (value: string) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Greyed-out text shown when the textarea is empty.
|
|
30
|
-
*/
|
|
31
|
-
readonly placeholder?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Number of visible rows (viewport height).
|
|
34
|
-
* @default 5
|
|
35
|
-
*/
|
|
36
|
-
readonly rows?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Show line numbers in the left gutter.
|
|
39
|
-
* @default false
|
|
40
|
-
*/
|
|
41
|
-
readonly showLineNumbers?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Number of spaces inserted for a Tab key press.
|
|
44
|
-
* @default 2
|
|
45
|
-
*/
|
|
46
|
-
readonly tabSize?: number;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* A multi-line text input with cursor navigation, selection, clipboard, undo/redo,
|
|
50
|
-
* paste support, and viewport scrolling.
|
|
51
|
-
*
|
|
52
|
-
* ```tsx
|
|
53
|
-
* <Textarea defaultValue="Hello\nWorld" rows={10} onChange={setValue} onSubmit={handleSubmit} />
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
declare function Textarea({
|
|
57
|
-
defaultValue,
|
|
58
|
-
isDisabled,
|
|
59
|
-
isFocused,
|
|
60
|
-
maxRows,
|
|
61
|
-
onChange,
|
|
62
|
-
onSubmit,
|
|
63
|
-
placeholder,
|
|
64
|
-
rows,
|
|
65
|
-
showLineNumbers,
|
|
66
|
-
tabSize
|
|
67
|
-
}: Props): ReactElement;
|
|
68
|
-
export { Props, Textarea, type Props as TextareaProps, Textarea as default };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{jsx as l,jsxs as m,Fragment as x}from"react/jsx-runtime";import{useRef as T,useState as I,useEffect as B,useMemo as W,useCallback as F}from"react";import G from"../ink/hooks/use-clipboard.js";import H from"../ink/hooks/use-input.js";import N from"../ink/hooks/use-paste.js";import O from"../ink/hooks/use-text-buffer.js";import{i as P}from"../packem_shared/input-utils-BSWCb4F_.js";import{Box as C}from"./box.js";import{Text as o}from"./text.js";const Q=(i,c)=>c.line<i.line||c.line===i.line&&c.col<i.col?{endCol:i.col,endLine:i.line,startCol:c.col,startLine:c.line}:{endCol:c.col,endLine:c.line,startCol:i.col,startLine:i.line};function rr({defaultValue:i="",isDisabled:c=!1,isFocused:g=!0,maxRows:d,onChange:v,onSubmit:h,placeholder:p,rows:a=5,showLineNumbers:f=!1,tabSize:L=2}){const n=O(i),S=T(n);S.current=n;const{copy:u}=G(),[s,A]=I(0),E=T(v);E.current=v;const k=T(h);k.current=h;const D=T(i);B(()=>{n.value!==D.current&&(D.current=n.value,E.current?.(n.value))},[n.value]);const w=W(()=>d?Math.min(Math.max(a,n.lines.length),d):a,[a,d,n.lines.length]);B(()=>{A(t=>n.cursor.line<t?n.cursor.line:n.cursor.line>=t+w?n.cursor.line-w+1:t)},[n.cursor.line,w]);const M=F((t,r)=>{const e=S.current;if(r.return&&(r.meta||r.ctrl)){k.current?.(e.value);return}if(r.return){e.newline();return}if(r.escape){e.clearSelection();return}if(r.tab){e.insert(" ".repeat(L));return}if(r.ctrl&&t==="z"){e.undo();return}if(r.ctrl&&(t==="y"||r.shift&&t==="Z")){e.redo();return}if(r.ctrl&&t==="c"&&e.hasSelection()){u(e.getSelectedText());return}if(r.ctrl&&(t==="A"||t==="a"&&r.shift)){e.selectAll();return}if(r.upArrow){e.moveCursor("up",r.shift);return}if(r.downArrow){e.moveCursor("down",r.shift);return}if(r.leftArrow){e.moveCursor("left",r.shift);return}if(r.rightArrow){e.moveCursor("right",r.shift);return}if(r.home){r.ctrl?e.moveToStart(r.shift):e.moveToLineStart(r.shift);return}if(r.end){r.ctrl?e.moveToEnd(r.shift):e.moveToLineEnd(r.shift);return}if(r.ctrl&&t==="a"){e.moveToLineStart(r.shift);return}if(r.ctrl&&t==="e"){e.moveToLineEnd(r.shift);return}if(r.backspace){e.deleteBack();return}if(r.delete){e.deleteForward();return}if(r.ctrl&&t==="u"){e.deleteToLineStart();return}if(r.ctrl&&t==="k"){e.deleteToLineEnd();return}if(r.ctrl&&t==="w"){e.deleteWord();return}P(t,r)&&(e.hasSelection()?e.replaceSelection(t):e.insert(t))},[u,L]);H(M,{isActive:g&&!c});const R=F(t=>{const r=S.current;r.hasSelection()?r.replaceSelection(t):r.insert(t)},[]);N(R,{isActive:g&&!c});const z=n.lines.slice(s,s+w),b=f?String(n.lines.length).length+1:0,j=n.anchor?Q(n.cursor,n.anchor):null;if(c)return l(C,{flexDirection:"column",children:z.map((t,r)=>{const e=s+r;return m(C,{children:[f?m(o,{dimColor:!0,children:[String(e+1).padStart(b)," "]}):void 0,l(o,{dimColor:!0,children:t||(e===0&&p?p:"")})]},e)})});if(n.value.length===0&&p){const t=p.split(`
|
|
2
|
-
`).slice(0,w);return l(C,{flexDirection:"column",children:t.map((r,e)=>m(C,{children:[f?m(o,{dimColor:!0,children:[String(e+1).padStart(b)," "]}):void 0,e===0?m(o,{children:[l(o,{dimColor:!0,inverse:!0,children:r[0]??" "}),l(o,{dimColor:!0,children:r.slice(1)})]}):l(o,{dimColor:!0,children:r})]},e))})}return l(C,{flexDirection:"column",children:z.map((t,r)=>{const e=s+r,y=e===n.cursor.line;return m(C,{children:[f?m(o,{dimColor:!y,children:[String(e+1).padStart(b)," "]}):void 0,l(o,{children:U(t,e,n.cursor,j)})]},e)})})}function U(i,c,g,d){const v=c===g.line,h=v?g.col:-1,p=d&&c>=d.startLine&&c<=d.endLine;if(!p&&!v)return l(x,{children:i});if(!p){const u=i.slice(0,h),s=i[h],A=i.slice(h+1);return m(x,{children:[u,l(o,{inverse:!0,children:s??" "}),A]})}const a=c===d.startLine?d.startCol:0,f=c===d.endLine?d.endCol:i.length,L=i.slice(0,a),n=i.slice(a,f),S=i.slice(f);if(v&&(h<a||h>=f)){const u=[];let s=0;return h<a?(u.push(l(o,{children:i.slice(0,h)},s++)),u.push(l(o,{inverse:!0,children:i[h]??" "},s++)),u.push(l(o,{children:i.slice(h+1,a)},s++)),u.push(l(o,{inverse:!0,children:n},s++)),u.push(l(o,{children:S},s++))):(u.push(l(o,{children:L},s++)),u.push(l(o,{inverse:!0,children:n},s++)),u.push(l(o,{children:i.slice(f,h)},s++)),u.push(l(o,{inverse:!0,children:i[h]??" "},s++)),u.push(l(o,{children:i.slice(h+1)},s++))),l(x,{children:u})}return m(x,{children:[L,l(o,{inverse:!0,children:n}),S]})}export{rr as Textarea,rr as default};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Ref, ReactElement } from 'react';
|
|
2
|
-
import { UseTimerResult } from "../ink/hooks/use-timer.js";
|
|
3
|
-
type TimerRef = Omit<UseTimerResult, "isFinished" | "isRunning" | "remaining">;
|
|
4
|
-
type Props = {
|
|
5
|
-
/**
|
|
6
|
-
* Whether to start the timer immediately.
|
|
7
|
-
* @default false
|
|
8
|
-
*/
|
|
9
|
-
readonly autoStart?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Make the rendered text bold.
|
|
12
|
-
*/
|
|
13
|
-
readonly bold?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Text color for the rendered time.
|
|
16
|
-
*/
|
|
17
|
-
readonly color?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Total countdown duration in milliseconds.
|
|
20
|
-
*/
|
|
21
|
-
readonly duration: number;
|
|
22
|
-
/**
|
|
23
|
-
* Custom formatter for the remaining time.
|
|
24
|
-
* Receives remaining milliseconds, returns a display string.
|
|
25
|
-
* @default formatDuration (MM:SS or HH:MM:SS)
|
|
26
|
-
*/
|
|
27
|
-
readonly format?: (remaining: number) => string;
|
|
28
|
-
/**
|
|
29
|
-
* Tick interval in milliseconds.
|
|
30
|
-
* @default 1000
|
|
31
|
-
*/
|
|
32
|
-
readonly interval?: number;
|
|
33
|
-
/**
|
|
34
|
-
* Called once when the timer reaches zero.
|
|
35
|
-
*/
|
|
36
|
-
readonly onTimeout?: () => void;
|
|
37
|
-
readonly ref?: Ref<TimerRef>;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* A countdown timer component.
|
|
41
|
-
*
|
|
42
|
-
* Exposes `start`, `stop`, `toggle`, and `reset` methods via ref.
|
|
43
|
-
*
|
|
44
|
-
* ```tsx
|
|
45
|
-
* const ref = useRef<TimerRef>(null);
|
|
46
|
-
* <Timer ref={ref} duration={60_000} autoStart />
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
declare const Timer: ({
|
|
50
|
-
autoStart,
|
|
51
|
-
bold,
|
|
52
|
-
color,
|
|
53
|
-
duration,
|
|
54
|
-
format,
|
|
55
|
-
interval,
|
|
56
|
-
onTimeout,
|
|
57
|
-
ref
|
|
58
|
-
}: Props) => ReactElement;
|
|
59
|
-
export { Props, Timer, type Props as TimerProps, TimerRef, Timer as default };
|
package/dist/components/timer.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as l}from"react/jsx-runtime";import{useImperativeHandle as f}from"react";import p from"../ink/hooks/use-timer.js";import{f as u}from"../packem_shared/format-time-fjoQHMxD.js";import{Text as d}from"./text.js";const b=({autoStart:o,bold:r,color:e,duration:a,format:i=u,interval:m,onTimeout:s,ref:n})=>{const t=p({autoStart:o,duration:a,interval:m,onTimeout:s});return f(n,()=>({reset:t.reset,start:t.start,stop:t.stop,toggle:t.toggle}),[t.reset,t.start,t.stop,t.toggle]),l(d,{bold:r,color:e,children:i(t.remaining)})};export{b as Timer,b as default};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { V as Variant } from "../packem_shared/variant-config.d-D5NnrrQK.js";
|
|
3
|
-
type ToastVariant = Variant;
|
|
4
|
-
type Props = {
|
|
5
|
-
/**
|
|
6
|
-
* Toast body.
|
|
7
|
-
*/
|
|
8
|
-
readonly children: ReactNode;
|
|
9
|
-
/**
|
|
10
|
-
* Milliseconds to display before auto-dismissing. Use `0` to disable.
|
|
11
|
-
* @default 4000
|
|
12
|
-
*/
|
|
13
|
-
readonly duration?: number;
|
|
14
|
-
/**
|
|
15
|
-
* Called after the toast dismisses itself.
|
|
16
|
-
*/
|
|
17
|
-
readonly onDismiss?: () => void;
|
|
18
|
-
/**
|
|
19
|
-
* Optional title rendered before the body.
|
|
20
|
-
*/
|
|
21
|
-
readonly title?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Visual variant determining the icon and border color.
|
|
24
|
-
* @default "info"
|
|
25
|
-
*/
|
|
26
|
-
readonly variant?: ToastVariant;
|
|
27
|
-
/**
|
|
28
|
-
* Manually control visibility. When provided, `duration` is ignored.
|
|
29
|
-
*/
|
|
30
|
-
readonly visible?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Optional width override.
|
|
33
|
-
*/
|
|
34
|
-
readonly width?: number;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Ephemeral notification. Disappears automatically after `duration` ms.
|
|
38
|
-
* @returns A bordered `ReactElement` while visible; `null` once dismissed.
|
|
39
|
-
*/
|
|
40
|
-
declare function Toast({
|
|
41
|
-
children,
|
|
42
|
-
duration,
|
|
43
|
-
onDismiss,
|
|
44
|
-
title,
|
|
45
|
-
variant,
|
|
46
|
-
visible,
|
|
47
|
-
width
|
|
48
|
-
}: Props): ReactElement | null;
|
|
49
|
-
export { Props, Toast, type Props as ToastProps, ToastVariant, Toast as default };
|
package/dist/components/toast.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsxs as c,jsx as t}from"react/jsx-runtime";import{useState as v,useRef as T,useEffect as w}from"react";import{Box as u}from"./box.js";import{Text as i}from"./text.js";import{o as g}from"../packem_shared/variant-config-BJqpNo7H.js";function B({children:f,duration:r=4e3,onDismiss:n,title:l,variant:m="info",visible:o,width:a}){const[p,h]=v(!0),e=o??p,d=T(n);if(d.current=n,w(()=>{if(o!==void 0||r<=0||!e)return;const b=setTimeout(()=>{h(!1),d.current?.()},r);return()=>{clearTimeout(b)}},[r,o,e]),!e)return null;const{color:s,icon:x}=g[m];return c(u,{borderColor:s,borderStyle:"round",gap:1,paddingX:1,width:a,children:[t(i,{color:s,children:x}),c(u,{flexDirection:"column",flexGrow:1,children:[l===void 0?void 0:t(i,{bold:!0,children:l}),t(i,{children:f})]})]})}export{B as Toast,B as default};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
-
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from 'type-fest';
|
|
4
|
-
type TooltipPlacement = "bottom" | "left" | "right" | "top";
|
|
5
|
-
type Props = {
|
|
6
|
-
/**
|
|
7
|
-
* The element the tooltip is attached to.
|
|
8
|
-
*/
|
|
9
|
-
readonly children: ReactNode;
|
|
10
|
-
/**
|
|
11
|
-
* Border color.
|
|
12
|
-
* @default "gray"
|
|
13
|
-
*/
|
|
14
|
-
readonly color?: LiteralUnion<AnsiColors, string>;
|
|
15
|
-
/**
|
|
16
|
-
* Tooltip body content.
|
|
17
|
-
*/
|
|
18
|
-
readonly content: ReactNode;
|
|
19
|
-
/**
|
|
20
|
-
* Controls whether the tooltip is rendered.
|
|
21
|
-
* @default true
|
|
22
|
-
*/
|
|
23
|
-
readonly isVisible?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Relative position. Terminal rendering does not support floating layers,
|
|
26
|
-
* so the tooltip is placed inline next to (or above / below) the anchor.
|
|
27
|
-
* @default "right"
|
|
28
|
-
*/
|
|
29
|
-
readonly placement?: TooltipPlacement;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Renders supplementary text next to an anchor. Because terminals don't have
|
|
33
|
-
* a floating-layer concept, the tooltip lives inline in the layout. Hide it
|
|
34
|
-
* by toggling `isVisible`.
|
|
35
|
-
*/
|
|
36
|
-
declare function Tooltip({
|
|
37
|
-
children,
|
|
38
|
-
color,
|
|
39
|
-
content,
|
|
40
|
-
isVisible,
|
|
41
|
-
placement
|
|
42
|
-
}: Props): ReactElement;
|
|
43
|
-
export { Props, Tooltip, TooltipPlacement, type Props as TooltipProps, Tooltip as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as o,jsxs as f}from"react/jsx-runtime";import{Box as t}from"./box.js";import{Text as a}from"./text.js";const m={bottom:{flexDirection:"column",orderFirst:!1},left:{flexDirection:"row",orderFirst:!0},right:{flexDirection:"row",orderFirst:!1},top:{flexDirection:"column",orderFirst:!0}};function p({children:c,color:i="gray",content:r,isVisible:s=!0,placement:e="right"}){const{flexDirection:d,orderFirst:n}=m[e],l=s?o(t,{borderColor:i,borderStyle:"round",flexShrink:0,marginLeft:e==="right"?1:0,marginRight:e==="left"?1:0,paddingX:1,children:typeof r=="string"?o(a,{color:i,children:r}):r}):void 0;return f(t,{alignItems:"center",flexDirection:d,children:[n?l:void 0,o(t,{children:c}),n?void 0:l]})}export{p as Tooltip,p as default};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
type TransitionPreset = "fade" | "reveal" | "slide-down" | "slide-left" | "slide-right" | "slide-up";
|
|
3
|
-
type TransitionPhase = "entered" | "entering" | "exited" | "exiting";
|
|
4
|
-
type Props = {
|
|
5
|
-
/**
|
|
6
|
-
* Content to animate.
|
|
7
|
-
*/
|
|
8
|
-
readonly children: ReactNode;
|
|
9
|
-
/**
|
|
10
|
-
* For slide presets, how many characters of offset to animate across.
|
|
11
|
-
* For the `reveal` preset, the maximum row count to scale through.
|
|
12
|
-
* @default 4
|
|
13
|
-
*/
|
|
14
|
-
readonly distance?: number;
|
|
15
|
-
/**
|
|
16
|
-
* Duration of both enter and exit transitions, in milliseconds.
|
|
17
|
-
* @default 240
|
|
18
|
-
*/
|
|
19
|
-
readonly duration?: number;
|
|
20
|
-
/**
|
|
21
|
-
* Called once the exit animation finishes (i.e. the component has fully
|
|
22
|
-
* transitioned out). AnimatePresence uses this to unmount the wrapper.
|
|
23
|
-
*/
|
|
24
|
-
readonly onExit?: () => void;
|
|
25
|
-
/**
|
|
26
|
-
* Animation preset controlling how the content appears/disappears.
|
|
27
|
-
* @default "fade"
|
|
28
|
-
*/
|
|
29
|
-
readonly preset?: TransitionPreset;
|
|
30
|
-
/**
|
|
31
|
-
* Controls the target phase. `true` drives towards `entered`, `false`
|
|
32
|
-
* drives towards `exited`. Flip the value to trigger animation.
|
|
33
|
-
* @default true
|
|
34
|
-
*/
|
|
35
|
-
readonly show?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Tick interval in milliseconds. Lower values yield smoother animation
|
|
38
|
-
* at the cost of CPU.
|
|
39
|
-
* @default 30
|
|
40
|
-
*/
|
|
41
|
-
readonly tickInterval?: number;
|
|
42
|
-
};
|
|
43
|
-
type TransitionComponent = ((props: Props) => ReactElement | null) & {
|
|
44
|
-
isAnimatable: true;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Animate a child's entry and exit using a TUI-friendly preset. Drive via
|
|
48
|
-
* `show`; the component toggles between enter and exit, fires `onExit` once
|
|
49
|
-
* the exit animation completes.
|
|
50
|
-
*
|
|
51
|
-
* **Fade preset note:** `dimColor` is only applied when the child is a plain
|
|
52
|
-
* string. Non-string children (Box trees, other components) pass through
|
|
53
|
-
* untouched during the transition — wrap them in `<Text>` if you need the
|
|
54
|
-
* fade effect.
|
|
55
|
-
* @returns A `ReactElement` rendering the transitioning child, or `null`
|
|
56
|
-
* once a hidden transition has fully completed.
|
|
57
|
-
*/
|
|
58
|
-
declare function Transition({
|
|
59
|
-
children,
|
|
60
|
-
distance,
|
|
61
|
-
duration,
|
|
62
|
-
onExit,
|
|
63
|
-
preset,
|
|
64
|
-
show,
|
|
65
|
-
tickInterval
|
|
66
|
-
}: Props): ReactElement | null;
|
|
67
|
-
/**
|
|
68
|
-
* Static marker used by `AnimatePresence` to recognize Transition children
|
|
69
|
-
* even when the consumer hasn't explicitly passed a `show` prop. Consumers
|
|
70
|
-
* can apply the same marker to their own wrappers (`MyWrapper.isAnimatable
|
|
71
|
-
* = true`) to opt them into animation orchestration.
|
|
72
|
-
*/
|
|
73
|
-
declare const TransitionWithMarker: TransitionComponent;
|
|
74
|
-
export { Props, Transition, TransitionPhase, TransitionPreset, type Props as TransitionProps, TransitionWithMarker as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useState as w,useRef as d,useEffect as D}from"react";import{Box as c}from"./box.js";import{Text as b}from"./text.js";const j=(t,r)=>t>=1?e(c,{children:r}):t<=0?e(c,{}):e(c,{children:typeof r=="string"?e(b,{dimColor:t<.7,children:r}):r}),y=(t,r)=>Math.max(0,Math.min(r,Math.round((1-t)*r))),f=(t,r)=>(i,u,h)=>{const n=y(i,h);return i>=1?e(c,{children:u}):i<=0?e(c,{}):t==="x"?e(c,{paddingLeft:r===1?n:0,paddingRight:r===-1?n:0,children:u}):e(c,{flexDirection:"column",paddingBottom:r===-1?n:0,paddingTop:r===1?n:0,children:u})},A=(t,r,i)=>{if(t>=1)return e(c,{children:r});if(t<=0)return e(c,{});const u=Math.max(0,Math.min(i,Math.round(t*i)));return e(c,{flexDirection:"column",height:u,overflowY:"hidden",children:r})},C={fade:j,reveal:A,"slide-down":f("y",-1),"slide-left":f("x",-1),"slide-right":f("x",1),"slide-up":f("y",1)},O=(t,r)=>t?r>=1?"entered":"entering":r<=0?"exited":"exiting";function K({children:t,distance:r=4,duration:i=240,onExit:u,preset:h="fade",show:n=!0,tickInterval:g=30}){const[m,I]=w(n?1:0),x=d(n?1:0),M=d(Date.now()),s=d(n?1:0),a=d(!n),p=d(u);p.current=u;const[k,B]=w(0);if(D(()=>{const o=n?1:0;x.current!==o&&(x.current=o,M.current=Date.now(),s.current=m,a.current=!1,B(l=>l+1))},[n]),D(()=>{const o=x.current;if(s.current===o){o===0&&!a.current&&(a.current=!0,p.current?.());return}const l=setInterval(()=>{const R=Date.now()-M.current,v=i<=0?1:Math.min(1,R/i),T=s.current+(o-s.current)*v;I(T),v>=1&&(clearInterval(l),o===0&&!a.current&&(a.current=!0,p.current?.()))},g);return()=>{clearInterval(l)}},[k,i,g]),O(n,m)==="exited"&&!n)return null;const E=C[h];return E(m,t,r)}const Y=Object.assign(K,{isAnimatable:!0});export{K as Transition,Y as default};
|