@visulima/tui-kit 0.0.0 → 1.0.1
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 +13 -0
- package/LICENSE.md +2095 -0
- package/README.md +115 -29
- package/dist/accordion.d.ts +52 -0
- package/dist/accordion.js +1 -0
- package/dist/alert.d.ts +22 -0
- package/dist/alert.js +1 -0
- package/dist/animate-presence.d.ts +16 -0
- package/dist/animate-presence.js +1 -0
- package/dist/approval-prompt.d.ts +55 -0
- package/dist/approval-prompt.js +1 -0
- package/dist/area-chart.d.ts +56 -0
- package/dist/area-chart.js +1 -0
- package/dist/badge.d.ts +19 -0
- package/dist/badge.js +1 -0
- package/dist/bar-chart.d.ts +58 -0
- package/dist/bar-chart.js +1 -0
- package/dist/big-text.d.ts +71 -0
- package/dist/big-text.js +1 -0
- package/dist/blink-dot.d.ts +31 -0
- package/dist/blink-dot.js +1 -0
- package/dist/breadcrumb.d.ts +29 -0
- package/dist/breadcrumb.js +1 -0
- package/dist/button.d.ts +38 -0
- package/dist/button.js +1 -0
- package/dist/calendar.d.ts +60 -0
- package/dist/calendar.js +1 -0
- package/dist/card.d.ts +47 -0
- package/dist/card.js +1 -0
- package/dist/checkbox-group.d.ts +50 -0
- package/dist/checkbox-group.js +1 -0
- package/dist/checkbox.d.ts +40 -0
- package/dist/checkbox.js +1 -0
- package/dist/code.d.ts +41 -0
- package/dist/code.js +2 -0
- package/dist/collapsible.d.ts +44 -0
- package/dist/collapsible.js +1 -0
- package/dist/color-picker.d.ts +59 -0
- package/dist/color-picker.js +1 -0
- package/dist/command-block.d.ts +39 -0
- package/dist/command-block.js +4 -0
- package/dist/command-palette.d.ts +73 -0
- package/dist/command-palette.js +1 -0
- package/dist/confirm-dialog.d.ts +63 -0
- package/dist/confirm-dialog.js +1 -0
- package/dist/confirm-input.d.ts +32 -0
- package/dist/confirm-input.js +1 -0
- package/dist/console-overlay.d.ts +47 -0
- package/dist/console-overlay.js +1 -0
- package/dist/content-switcher.d.ts +49 -0
- package/dist/content-switcher.js +1 -0
- package/dist/controlled-scroll-view.d.ts +3 -0
- package/dist/controlled-scroll-view.js +1 -0
- package/dist/data-grid.d.ts +43 -0
- package/dist/data-grid.js +1 -0
- package/dist/date-picker.d.ts +54 -0
- package/dist/date-picker.js +1 -0
- package/dist/definition-list.d.ts +38 -0
- package/dist/definition-list.js +1 -0
- package/dist/dialog.d.ts +94 -0
- package/dist/dialog.js +1 -0
- package/dist/diff-view.d.ts +72 -0
- package/dist/diff-view.js +1 -0
- package/dist/digits.d.ts +26 -0
- package/dist/digits.js +1 -0
- package/dist/directory-tree.d.ts +44 -0
- package/dist/directory-tree.js +1 -0
- package/dist/divider.d.ts +41 -0
- package/dist/divider.js +1 -0
- package/dist/drawer.d.ts +45 -0
- package/dist/drawer.js +1 -0
- package/dist/file-change.d.ts +34 -0
- package/dist/file-change.js +1 -0
- package/dist/file-picker-entry.d.ts +2 -0
- package/dist/file-picker-entry.js +1 -0
- package/dist/form.d.ts +74 -0
- package/dist/form.js +1 -0
- package/dist/gauge.d.ts +76 -0
- package/dist/gauge.js +1 -0
- package/dist/gradient.d.ts +38 -0
- package/dist/gradient.js +1 -0
- package/dist/grid.d.ts +34 -0
- package/dist/grid.js +1 -0
- package/dist/heading.d.ts +28 -0
- package/dist/heading.js +1 -0
- package/dist/heatmap.d.ts +52 -0
- package/dist/heatmap.js +1 -0
- package/dist/help.d.ts +45 -0
- package/dist/help.js +1 -0
- package/dist/histogram.d.ts +52 -0
- package/dist/histogram.js +1 -0
- package/dist/image.d.ts +23 -0
- package/dist/image.js +1 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.js +1 -0
- package/dist/json.d.ts +51 -0
- package/dist/json.js +1 -0
- package/dist/kbd.d.ts +27 -0
- package/dist/kbd.js +1 -0
- package/dist/line-chart.d.ts +100 -0
- package/dist/line-chart.js +1 -0
- package/dist/link.d.ts +34 -0
- package/dist/link.js +1 -0
- package/dist/loading-indicator.d.ts +25 -0
- package/dist/loading-indicator.js +1 -0
- package/dist/log.d.ts +33 -0
- package/dist/log.js +1 -0
- package/dist/markdown.d.ts +35 -0
- package/dist/markdown.js +1 -0
- package/dist/masked-input.d.ts +42 -0
- package/dist/masked-input.js +1 -0
- package/dist/menu.d.ts +70 -0
- package/dist/menu.js +1 -0
- package/dist/message-bubble.d.ts +36 -0
- package/dist/message-bubble.js +1 -0
- package/dist/model-badge.d.ts +33 -0
- package/dist/model-badge.js +1 -0
- package/dist/model-selector.d.ts +45 -0
- package/dist/model-selector.js +1 -0
- package/dist/multi-progress.d.ts +48 -0
- package/dist/multi-progress.js +1 -0
- package/dist/multi-select.d.ts +55 -0
- package/dist/multi-select.js +1 -0
- package/dist/notification-badge.d.ts +40 -0
- package/dist/notification-badge.js +1 -0
- package/dist/number-input.d.ts +71 -0
- package/dist/number-input.js +1 -0
- package/dist/operation-tree.d.ts +46 -0
- package/dist/operation-tree.js +1 -0
- package/dist/option-list.d.ts +41 -0
- package/dist/option-list.js +1 -0
- package/dist/ordered-list.d.ts +22 -0
- package/dist/ordered-list.js +1 -0
- package/dist/packem_shared/ControlledScrollView-BzlbIUph.js +1 -0
- package/dist/packem_shared/FilePicker-V5H2fb-v.js +1 -0
- package/dist/packem_shared/ScrollBar-C9i3z3Ft.js +1 -0
- package/dist/packem_shared/ScrollBarBox-DZEC8YnV.js +1 -0
- package/dist/packem_shared/ScrollList-Djtb2vVy.js +1 -0
- package/dist/packem_shared/ScrollView-ESxpl6Hy.js +1 -0
- package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +1 -0
- package/dist/packem_shared/TreeView-q0l446NV.js +1 -0
- package/dist/packem_shared/controlled-scroll-view-DerVKKv6.js +1 -0
- package/dist/packem_shared/controlled-scroll-view.d-D3kZZzjI.d.ts +43 -0
- package/dist/packem_shared/file-picker.d-CH7pccC7.d.ts +92 -0
- package/dist/packem_shared/line-chart-BbhMhcZg.js +1 -0
- package/dist/packem_shared/scroll-bar-box.d-CpTYEcTZ.d.ts +13 -0
- package/dist/packem_shared/scroll-bar.d-B4sD1hBR.d.ts +18 -0
- package/dist/packem_shared/scroll-list.d-CPCF0RwC.d.ts +12 -0
- package/dist/packem_shared/scroll-view.d-GZcgAHl4.d.ts +98 -0
- package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +1 -0
- package/dist/packem_shared/use-tree-view.d-DeMQ6G2r.d.ts +314 -0
- package/dist/packem_shared/useTreeView-D0JEqT6W.js +1 -0
- package/dist/packem_shared/useTreeViewState-BiTJakkh.js +1 -0
- package/dist/packem_shared/variant-config-BJqpNo7H.js +1 -0
- package/dist/packem_shared/variant-config.d-D5NnrrQK.d.ts +2 -0
- package/dist/paginator.d.ts +59 -0
- package/dist/paginator.js +1 -0
- package/dist/paragraph.d.ts +32 -0
- package/dist/paragraph.js +1 -0
- package/dist/path-input.d.ts +56 -0
- package/dist/path-input.js +1 -0
- package/dist/pie-chart.d.ts +44 -0
- package/dist/pie-chart.js +1 -0
- package/dist/placeholder.d.ts +47 -0
- package/dist/placeholder.js +1 -0
- package/dist/popover.d.ts +39 -0
- package/dist/popover.js +1 -0
- package/dist/progress-bar.d.ts +43 -0
- package/dist/progress-bar.js +1 -0
- package/dist/progress-circle.d.ts +50 -0
- package/dist/progress-circle.js +1 -0
- package/dist/qr-code.d.ts +39 -0
- package/dist/qr-code.js +1 -0
- package/dist/r/accordion.json +24 -0
- package/dist/r/alert.json +24 -0
- package/dist/r/animate-presence.json +22 -0
- package/dist/r/approval-prompt.json +24 -0
- package/dist/r/area-chart.json +27 -0
- package/dist/r/badge.json +24 -0
- package/dist/r/bar-chart.json +24 -0
- package/dist/r/big-text.json +23 -0
- package/dist/r/blink-dot.json +24 -0
- package/dist/r/breadcrumb.json +24 -0
- package/dist/r/button.json +24 -0
- package/dist/r/calendar.json +24 -0
- package/dist/r/card.json +26 -0
- package/dist/r/chart-utils.json +24 -0
- package/dist/r/checkbox-group.json +24 -0
- package/dist/r/checkbox.json +24 -0
- package/dist/r/code.json +23 -0
- package/dist/r/collapsible.json +24 -0
- package/dist/r/color-picker.json +24 -0
- package/dist/r/command-block.json +26 -0
- package/dist/r/command-palette.json +24 -0
- package/dist/r/confirm-dialog.json +24 -0
- package/dist/r/confirm-input.json +22 -0
- package/dist/r/console-overlay.json +22 -0
- package/dist/r/content-switcher.json +24 -0
- package/dist/r/controlled-scroll-view.json +24 -0
- package/dist/r/data-grid.json +24 -0
- package/dist/r/date-picker.json +26 -0
- package/dist/r/definition-list.json +24 -0
- package/dist/r/dialog.json +24 -0
- package/dist/r/diff-view.json +24 -0
- package/dist/r/digits.json +24 -0
- package/dist/r/directory-tree.json +24 -0
- package/dist/r/divider.json +24 -0
- package/dist/r/drawer.json +24 -0
- package/dist/r/file-change.json +24 -0
- package/dist/r/file-picker.json +44 -0
- package/dist/r/form.json +24 -0
- package/dist/r/gauge.json +24 -0
- package/dist/r/gradient.json +24 -0
- package/dist/r/grid.json +22 -0
- package/dist/r/heading.json +24 -0
- package/dist/r/heatmap.json +24 -0
- package/dist/r/help.json +22 -0
- package/dist/r/histogram.json +26 -0
- package/dist/r/image.json +24 -0
- package/dist/r/json.json +24 -0
- package/dist/r/kbd.json +24 -0
- package/dist/r/line-chart.json +26 -0
- package/dist/r/link.json +23 -0
- package/dist/r/loading-indicator.json +27 -0
- package/dist/r/log.json +24 -0
- package/dist/r/markdown.json +29 -0
- package/dist/r/masked-input.json +22 -0
- package/dist/r/menu.json +24 -0
- package/dist/r/message-bubble.json +24 -0
- package/dist/r/model-badge.json +24 -0
- package/dist/r/model-selector.json +24 -0
- package/dist/r/multi-progress.json +24 -0
- package/dist/r/multi-select.json +24 -0
- package/dist/r/notification-badge.json +24 -0
- package/dist/r/number-input.json +24 -0
- package/dist/r/operation-tree.json +26 -0
- package/dist/r/option-list.json +24 -0
- package/dist/r/ordered-list.json +22 -0
- package/dist/r/paginator.json +22 -0
- package/dist/r/paragraph.json +24 -0
- package/dist/r/path-input.json +26 -0
- package/dist/r/pie-chart.json +24 -0
- package/dist/r/placeholder.json +24 -0
- package/dist/r/popover.json +24 -0
- package/dist/r/progress-bar.json +22 -0
- package/dist/r/progress-circle.json +24 -0
- package/dist/r/qr-code.json +24 -0
- package/dist/r/radio-group.json +24 -0
- package/dist/r/registry.json +1051 -0
- package/dist/r/scatter-plot.json +27 -0
- package/dist/r/scroll-bar-box.json +24 -0
- package/dist/r/scroll-bar.json +24 -0
- package/dist/r/scroll-list.json +24 -0
- package/dist/r/scroll-view.json +24 -0
- package/dist/r/scroll.json +58 -0
- package/dist/r/search-input.json +26 -0
- package/dist/r/select-input-indicator.json +24 -0
- package/dist/r/select-input-item.json +24 -0
- package/dist/r/select-input.json +28 -0
- package/dist/r/shimmer-text.json +24 -0
- package/dist/r/sidebar.json +24 -0
- package/dist/r/slider.json +24 -0
- package/dist/r/sparkline.json +24 -0
- package/dist/r/spinner.json +23 -0
- package/dist/r/status-line.json +24 -0
- package/dist/r/status-message.json +24 -0
- package/dist/r/stepper.json +24 -0
- package/dist/r/stopwatch.json +22 -0
- package/dist/r/streaming-text.json +24 -0
- package/dist/r/switch.json +24 -0
- package/dist/r/tab.json +22 -0
- package/dist/r/table.json +23 -0
- package/dist/r/tabs.json +26 -0
- package/dist/r/tag-input.json +24 -0
- package/dist/r/tag.json +24 -0
- package/dist/r/text-input.json +22 -0
- package/dist/r/textarea.json +22 -0
- package/dist/r/thinking-block.json +24 -0
- package/dist/r/time-picker.json +24 -0
- package/dist/r/timer.json +22 -0
- package/dist/r/toast.json +24 -0
- package/dist/r/token-usage.json +24 -0
- package/dist/r/tool-call.json +24 -0
- package/dist/r/tooltip.json +24 -0
- package/dist/r/transition.json +22 -0
- package/dist/r/tree-select.json +24 -0
- package/dist/r/tree-view.json +64 -0
- package/dist/r/unordered-list.json +22 -0
- package/dist/r/use-linked-scroll.json +24 -0
- package/dist/r/variant-config.json +22 -0
- package/dist/radio-group.d.ts +63 -0
- package/dist/radio-group.js +1 -0
- package/dist/scatter-plot.d.ts +24 -0
- package/dist/scatter-plot.js +1 -0
- package/dist/scroll-bar-box.d.ts +3 -0
- package/dist/scroll-bar-box.js +1 -0
- package/dist/scroll-bar.d.ts +3 -0
- package/dist/scroll-bar.js +1 -0
- package/dist/scroll-list.d.ts +4 -0
- package/dist/scroll-list.js +1 -0
- package/dist/scroll-view.d.ts +3 -0
- package/dist/scroll-view.js +1 -0
- package/dist/search-input.d.ts +46 -0
- package/dist/search-input.js +1 -0
- package/dist/select-input-indicator.d.ts +28 -0
- package/dist/select-input-indicator.js +1 -0
- package/dist/select-input-item.d.ts +35 -0
- package/dist/select-input-item.js +1 -0
- package/dist/select-input.d.ts +97 -0
- package/dist/select-input.js +1 -0
- package/dist/shimmer-text.d.ts +41 -0
- package/dist/shimmer-text.js +1 -0
- package/dist/sidebar.d.ts +40 -0
- package/dist/sidebar.js +1 -0
- package/dist/slider.d.ts +87 -0
- package/dist/slider.js +1 -0
- package/dist/sparkline.d.ts +36 -0
- package/dist/sparkline.js +1 -0
- package/dist/spinner.d.ts +15 -0
- package/dist/spinner.js +1 -0
- package/dist/status-line.d.ts +31 -0
- package/dist/status-line.js +1 -0
- package/dist/status-message.d.ts +18 -0
- package/dist/status-message.js +1 -0
- package/dist/stepper.d.ts +42 -0
- package/dist/stepper.js +1 -0
- package/dist/stopwatch.d.ts +42 -0
- package/dist/stopwatch.js +1 -0
- package/dist/streaming-text.d.ts +39 -0
- package/dist/streaming-text.js +1 -0
- package/dist/switch.d.ts +46 -0
- package/dist/switch.js +1 -0
- package/dist/tab.d.ts +17 -0
- package/dist/tab.js +1 -0
- package/dist/table.d.ts +118 -0
- package/dist/table.js +1 -0
- package/dist/tabs.d.ts +96 -0
- package/dist/tabs.js +1 -0
- package/dist/tag-input.d.ts +59 -0
- package/dist/tag-input.js +1 -0
- package/dist/tag.d.ts +30 -0
- package/dist/tag.js +1 -0
- package/dist/text-input.d.ts +40 -0
- package/dist/text-input.js +1 -0
- package/dist/textarea.d.ts +57 -0
- package/dist/textarea.js +2 -0
- package/dist/thinking-block.d.ts +48 -0
- package/dist/thinking-block.js +1 -0
- package/dist/time-picker.d.ts +57 -0
- package/dist/time-picker.js +1 -0
- package/dist/timer.d.ts +50 -0
- package/dist/timer.js +1 -0
- package/dist/toast.d.ts +41 -0
- package/dist/toast.js +1 -0
- package/dist/token-usage.d.ts +43 -0
- package/dist/token-usage.js +1 -0
- package/dist/tool-call.d.ts +28 -0
- package/dist/tool-call.js +1 -0
- package/dist/tooltip.d.ts +37 -0
- package/dist/tooltip.js +1 -0
- package/dist/transition.d.ts +66 -0
- package/dist/transition.js +1 -0
- package/dist/tree-select.d.ts +55 -0
- package/dist/tree-select.js +1 -0
- package/dist/tree-view-entry.d.ts +4 -0
- package/dist/tree-view-entry.js +1 -0
- package/dist/unordered-list.d.ts +27 -0
- package/dist/unordered-list.js +1 -0
- package/dist/use-linked-scroll.d.ts +42 -0
- package/dist/use-linked-scroll.js +1 -0
- package/package.json +553 -7
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
type FileChangeStatus = "added" | "deleted" | "modified" | "renamed";
|
|
3
|
+
type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* Number of added lines.
|
|
6
|
+
* @default 0
|
|
7
|
+
*/
|
|
8
|
+
readonly additions?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Total width of the +/- change bar in cells.
|
|
11
|
+
* @default 10
|
|
12
|
+
*/
|
|
13
|
+
readonly barWidth?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Number of removed lines.
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
18
|
+
readonly deletions?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The file path.
|
|
21
|
+
*/
|
|
22
|
+
readonly path: string;
|
|
23
|
+
/**
|
|
24
|
+
* Change status, shown as a colored one-letter badge.
|
|
25
|
+
* @default "modified"
|
|
26
|
+
*/
|
|
27
|
+
readonly status?: FileChangeStatus;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* A single git-style diff-stat row: a status badge, the path, the numeric
|
|
31
|
+
* add/remove counts, and a proportional ▰/▱ change bar.
|
|
32
|
+
*/
|
|
33
|
+
declare function FileChange({ additions, barWidth, deletions, path, status }: Props): ReactElement;
|
|
34
|
+
export { FileChange, type Props as FileChangeProps, FileChangeStatus, Props, FileChange as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as c,jsx as r}from"react/jsx-runtime";import m from"@visulima/tui/components/box";import e from"@visulima/tui/components/text";const u={added:{color:"green",mark:"A"},deleted:{color:"red",mark:"D"},modified:{color:"yellow",mark:"M"},renamed:{color:"blue",mark:"R"}};function k({additions:l=0,barWidth:o=10,deletions:t=0,path:h,status:s="modified"}){const n=u[s],d=l+t,i=d===0?0:Math.round(l/d*o),a=d===0?0:Math.min(o-i,Math.round(t/d*o));return c(m,{gap:1,children:[r(e,{bold:!0,color:n.color,children:n.mark}),r(e,{children:h}),r(e,{color:"green",children:`+${l}`}),r(e,{color:"red",children:`-${t}`}),c(m,{children:[r(e,{color:"green",children:"▰".repeat(i)}),r(e,{color:"red",children:"▰".repeat(a)}),r(e,{dimColor:!0,children:"▱".repeat(Math.max(0,o-i-a))})]})]})}export{k as FileChange,k as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as f,default as l}from"./packem_shared/FilePicker-V5H2fb-v.js";export{f as FilePicker,l as default};
|
package/dist/form.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
+
import { ReactNode, ReactElement } from 'react';
|
|
3
|
+
import { LiteralUnion } from 'type-fest';
|
|
4
|
+
type FormFieldProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The input element (TextInput, Checkbox, Select, …).
|
|
7
|
+
*/
|
|
8
|
+
readonly children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Optional helper text rendered beneath the input.
|
|
11
|
+
*/
|
|
12
|
+
readonly description?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Validation error — dimmed red below the input.
|
|
15
|
+
*/
|
|
16
|
+
readonly error?: string;
|
|
17
|
+
/**
|
|
18
|
+
* When true, the field's label and description are dim.
|
|
19
|
+
*/
|
|
20
|
+
readonly isDisabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Label rendered above the input.
|
|
23
|
+
*/
|
|
24
|
+
readonly label: string;
|
|
25
|
+
/**
|
|
26
|
+
* Mark the field as required (adds a trailing `*`).
|
|
27
|
+
*/
|
|
28
|
+
readonly required?: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Standard form field wrapper: label + input + helper/error.
|
|
32
|
+
*/
|
|
33
|
+
declare const FormField: ({ children, description, error, isDisabled, label, required }: FormFieldProps) => ReactElement;
|
|
34
|
+
type Props = {
|
|
35
|
+
/**
|
|
36
|
+
* Accent color for the form chrome.
|
|
37
|
+
* @default "blue"
|
|
38
|
+
*/
|
|
39
|
+
readonly accentColor?: LiteralUnion<AnsiColors, string>;
|
|
40
|
+
/**
|
|
41
|
+
* Render a border around the form.
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
readonly bordered?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Fields composed via `<FormField />`.
|
|
47
|
+
*/
|
|
48
|
+
readonly children: ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Optional description rendered under the title.
|
|
51
|
+
*/
|
|
52
|
+
readonly description?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Optional footer rendered below the fields (buttons, hints, summary).
|
|
55
|
+
*/
|
|
56
|
+
readonly footer?: ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Optional heading rendered at the top.
|
|
59
|
+
*/
|
|
60
|
+
readonly title?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Fixed width.
|
|
63
|
+
*/
|
|
64
|
+
readonly width?: number;
|
|
65
|
+
};
|
|
66
|
+
type FormComponent = ((props: Props) => ReactElement) & {
|
|
67
|
+
Field: typeof FormField;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Stateless form layout. Pair with the `useForm` hook for state management
|
|
71
|
+
* and `FormField` for consistent label/error styling.
|
|
72
|
+
*/
|
|
73
|
+
declare const Form: FormComponent;
|
|
74
|
+
export { Form, FormField, FormFieldProps, type Props as FormProps, Props, Form as default };
|
package/dist/form.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as m,jsx as r}from"react/jsx-runtime";import o from"@visulima/tui/components/box";import i from"@visulima/tui/components/text";const a=({children:e,description:d,error:l,isDisabled:n=!1,label:c,required:t=!1})=>m(o,{flexDirection:"column",marginBottom:1,children:[m(o,{children:[r(i,{bold:!0,dimColor:n,children:c}),t?r(i,{color:"red",children:" *"}):void 0]}),r(o,{marginTop:0,children:e}),l===void 0?d===void 0?void 0:r(i,{dimColor:!0,children:d}):r(i,{color:"red",children:l})]}),b=Object.assign(({accentColor:e="blue",bordered:d=!0,children:l,description:n,footer:c,title:t,width:h})=>{const s=m(o,{flexDirection:"column",children:[t===void 0?void 0:r(o,{marginBottom:1,children:r(i,{bold:!0,color:e,children:t})}),n===void 0?void 0:r(o,{marginBottom:1,children:r(i,{dimColor:!0,children:n})}),r(o,{flexDirection:"column",children:l}),c===void 0?void 0:r(o,{marginTop:1,children:c})]});return d?r(o,{borderColor:e,borderStyle:"round",flexDirection:"column",paddingX:1,paddingY:1,width:h,children:s}):r(o,{flexDirection:"column",width:h,children:s})},{Field:a});export{b as Form,a as FormField,b as default};
|
package/dist/gauge.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { LiteralUnion } from 'type-fest';
|
|
4
|
+
type GaugeThreshold = {
|
|
5
|
+
/**
|
|
6
|
+
* Color used for the arc segment and, when the current value falls into
|
|
7
|
+
* this segment, for the value readout.
|
|
8
|
+
*/
|
|
9
|
+
readonly color: LiteralUnion<AnsiColors, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Optional label used by the legend under the gauge.
|
|
12
|
+
*/
|
|
13
|
+
readonly label?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Upper bound of this threshold segment (inclusive). Segments are sorted
|
|
16
|
+
* ascending and painted in order.
|
|
17
|
+
*/
|
|
18
|
+
readonly max: number;
|
|
19
|
+
};
|
|
20
|
+
type GaugeSize = "large" | "medium" | "small";
|
|
21
|
+
type Props = {
|
|
22
|
+
/**
|
|
23
|
+
* Color of the arc background (the portion beyond `value`).
|
|
24
|
+
* @default "gray"
|
|
25
|
+
*/
|
|
26
|
+
readonly backgroundColor?: LiteralUnion<AnsiColors, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Format for the numeric readout. Defaults to rounding to an integer.
|
|
29
|
+
*/
|
|
30
|
+
readonly formatValue?: (value: number) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional label rendered above the readout.
|
|
33
|
+
*/
|
|
34
|
+
readonly label?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Upper bound of the range.
|
|
37
|
+
* @default 100
|
|
38
|
+
*/
|
|
39
|
+
readonly max?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Lower bound of the range.
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
44
|
+
readonly min?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Show a legend listing thresholds below the gauge.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
readonly showLegend?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Show a numeric readout in the middle of the gauge.
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
54
|
+
readonly showValue?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Overall dimension preset.
|
|
57
|
+
* @default "medium"
|
|
58
|
+
*/
|
|
59
|
+
readonly size?: GaugeSize;
|
|
60
|
+
/**
|
|
61
|
+
* Color threshold ramp. When provided, segments of the arc are painted in
|
|
62
|
+
* the corresponding colors and the value readout picks up the color for
|
|
63
|
+
* the segment `value` lands in.
|
|
64
|
+
*/
|
|
65
|
+
readonly thresholds?: ReadonlyArray<GaugeThreshold>;
|
|
66
|
+
/**
|
|
67
|
+
* Current value. Clamped into the `[min, max]` range.
|
|
68
|
+
*/
|
|
69
|
+
readonly value: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Semi-circular gauge rendered at 2x4 sub-cell resolution. Supports colored
|
|
73
|
+
* threshold segments and an optional needle.
|
|
74
|
+
*/
|
|
75
|
+
declare function Gauge({ backgroundColor, formatValue, label, max, min, showLegend, showValue, size, thresholds, value }: Props): ReactElement;
|
|
76
|
+
export { Gauge, type Props as GaugeProps, GaugeSize, GaugeThreshold, Props, Gauge as default };
|
package/dist/gauge.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as j,jsx as l}from"react/jsx-runtime";import{createBrailleGrid as U}from"@visulima/tui/canvas";import c from"@visulima/tui/components/box";import W from"@visulima/tui/components/canvas";import p from"@visulima/tui/components/text";import{useMemo as q}from"react";const X={large:{cols:40,rows:10},medium:{cols:24,rows:6},small:{cols:16,rows:4}},_=.9,T=2,Y=r=>String(Math.round(r)),z=(r,u,d,e)=>{const t=u+(d-u)*e;for(const f of r)if(t<=f.max)return f;return r[r.length-1]};function io({backgroundColor:r="gray",formatValue:u=Y,label:d,max:e=100,min:t=0,showLegend:f=!1,showValue:C=!0,size:b="medium",thresholds:i,value:P}){const{cols:A,rows:E}=X[b],I=Math.max(t,Math.min(e,P)),F=e-t||1,M=(I-t)/F,s=q(()=>{if(!(i===void 0||i.length===0))return[...i].toSorted((o,h)=>o.max-h.max)},[i]),D=q(()=>{if(s!==void 0)return z(s,t,e,M)},[s,t,e,M]),G=u(I);return j(c,{flexDirection:"column",children:[l(W,{draw:o=>{o.clear();const h=o.width*2,L=o.height*4,x=h/2,v=L-1,H=h/2-1,J=L-1,g=Math.max(1,Math.min(H,J)),y=new Map,S=n=>{const a=y.get(n);if(a!==void 0)return a;const m=U(o.width,o.height);return y.set(n,m),m},V=Math.max(32,Math.round(Math.PI*g)*T);for(let n=0;n<=V;n+=1){const a=n/V,m=Math.PI*(1-a),Q=Math.round(x+g*Math.cos(m)),R=Math.round(v-g*Math.sin(m));let w;a>M?w=r:s?w=z(s,t,e,a)?.color??"cyan":w="cyan",S(w).plotPoint(Q,R)}const k=g*_,B=Math.PI*(1-M),K=Math.round(x+k*Math.cos(B)),N=Math.round(v-k*Math.sin(B)),O=D?.color??"white";S(O).plotLine(Math.round(x),Math.round(v),K,N);for(const[n,a]of y)a.flush(o,{color:n})},height:E,version:[P,t,e,b,i,r],width:A}),C||d?j(c,{flexDirection:"column",children:[d===void 0?void 0:l(c,{justifyContent:"center",children:l(p,{dimColor:!0,children:d})}),C?l(c,{justifyContent:"center",children:l(p,{bold:!0,color:D?.color??"white",children:G})}):void 0]}):void 0,f&&i&&i.length>0?l(c,{gap:2,justifyContent:"center",marginTop:1,children:i.map((o,h)=>j(c,{gap:1,children:[l(p,{color:o.color,children:"●"}),l(p,{dimColor:!0,children:o.label??`≤ ${o.max}`})]},h))}):void 0]})}export{io as Gauge,io as default};
|
|
@@ -0,0 +1,38 @@
|
|
|
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({ children, colors, name }: Props): ReactElement | null;
|
|
38
|
+
export { Gradient, type GradientColors, type GradientName, type Props as GradientProps, Props, Gradient as default };
|
package/dist/gradient.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as s,Fragment as B}from"react/jsx-runtime";import{strip as F}from"@visulima/ansi";import{multilineGradient as k}from"@visulima/colorize/gradient";import C from"@visulima/tui/components/box";import S from"@visulima/tui/components/text";import b from"@visulima/tui/components/transform";import{useMemo as M,Children as g,isValidElement as T,cloneElement as y}from"react";const O={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"}}},j=o=>{let t=!1;const n=u=>{g.forEach(u,i=>{if(t||!T(i))return;if(i.type===C){t=!0;return}const f=i.props;Object.hasOwn(f,"children")&&n(f.children)})};return n(o),t},x=o=>Object.hasOwn(o,"children"),G=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(O[n].colors,O[n].options):k(t??[]),[n,t]),i=h=>u(F(h)),f=g.count(o);if(G(o))return s(b,{transform:i,children:o});if(f===1&&!j(o))return s(b,{transform:i,children:o});const m=h=>{const c=[];let l="",v=0;const w=()=>{const r=`gradient-node-${String(v)}`;return v+=1,r},a=(r,e)=>{c.push(s(b,{transform:i,children:r},e))},E=()=>{if(l==="")return;const r=l;l="",a(s(S,{children:r}),w())};return g.forEach(h,r=>{if(!N(r)){if(G(r)){l+=String(r);return}if(E(),T(r)){const e=r.key??w(),p=r.props;if(r.type===S){a(r,e);return}if(r.type===C){if(x(p)){const d=p.children;c.push(y(r,{key:e},m(d)));return}c.push(y(r,{key:e}));return}if(x(p)){const d=p.children;if(!j(d)){a(r,e);return}c.push(y(r,{key:e},m(d)));return}a(r,e);return}c.push(r)}}),E(),c};return s(B,{children:m(o)})}export{J as Gradient,J as default};
|
package/dist/grid.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
/**
|
|
4
|
+
* The grid cells, filled left-to-right, top-to-bottom.
|
|
5
|
+
*/
|
|
6
|
+
readonly children: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Horizontal gap between columns, in cells.
|
|
9
|
+
* @default 1
|
|
10
|
+
*/
|
|
11
|
+
readonly columnGap?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Number of columns. Children wrap into as many rows as needed.
|
|
14
|
+
* @default 2
|
|
15
|
+
*/
|
|
16
|
+
readonly columns?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Fixed width for every column, in cells. Omit to let columns size to
|
|
19
|
+
* their content.
|
|
20
|
+
*/
|
|
21
|
+
readonly columnWidth?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Vertical gap between rows, in cells.
|
|
24
|
+
* @default 0
|
|
25
|
+
*/
|
|
26
|
+
readonly rowGap?: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A simple 2D grid: children flow left-to-right into a fixed number of columns,
|
|
30
|
+
* wrapping to new rows. Column and row gaps are configurable, and columns can
|
|
31
|
+
* be given a fixed width for uniform cells.
|
|
32
|
+
*/
|
|
33
|
+
declare function Grid({ children, columnGap, columns, columnWidth, rowGap }: Props): ReactElement;
|
|
34
|
+
export { Grid, type Props as GridProps, Props, Grid as default };
|
package/dist/grid.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import n from"@visulima/tui/components/box";import{Children as u}from"react";function G({children:e,columnGap:a=1,columns:m=2,columnWidth:c,rowGap:h=0}){const i=u.toArray(e),l=[],t=Math.max(1,m);for(let r=0;r<i.length;r+=t)l.push(i.slice(r,r+t));return o(n,{flexDirection:"column",gap:h,children:l.map((r,p)=>o(n,{gap:a,children:r.map((d,f)=>o(n,{flexShrink:0,width:c,children:d},f))},p))})}export{G as Grid,G as default};
|
|
@@ -0,0 +1,28 @@
|
|
|
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({ children, color, level, underline }: Props): ReactElement;
|
|
28
|
+
export { Heading, HeadingLevel, type Props as HeadingProps, Props, Heading as default };
|
package/dist/heading.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as l,jsxs as t}from"react/jsx-runtime";import c from"@visulima/tui/components/box";import d from"@visulima/tui/components/text";const a={1:"blueBright",2:"cyanBright",3:"magentaBright",4:"yellowBright",5:"green",6:"white"},h={1:"# ",2:"## ",3:"### ",4:"#### ",5:"##### ",6:"###### "};function g({children:e,color:o,level:r=1,underline:i=!1}){const n=o??a[r];return l(c,{flexDirection:"column",children:t(d,{bold:r<=2,color:n,underline:i,children:[h[r],e]})})}export{g as Heading,g as default};
|
|
@@ -0,0 +1,52 @@
|
|
|
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({ cellWidth, character, columnLabels, data, max: maxOverride, min: minOverride, palette, rowLabels, textColor }: HeatmapProps): ReactElement;
|
|
52
|
+
export { Heatmap, HeatmapProps, Heatmap as default };
|
package/dist/heatmap.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as M,jsx as c}from"react/jsx-runtime";import m from"@visulima/tui/components/box";import k from"@visulima/tui/components/canvas";import C from"@visulima/tui/components/text";import{useMemo as A}from"react";const E=["#0b1e4f","#1f3b96","#3258c8","#4e84ec","#78b0ff"];function I({cellWidth:s=2,character:L="█",columnLabels:p,data:t,max:l,min:d,palette:x=E,rowLabels:g,textColor:W}){const{cols:w,colWidth:f,extent:j,rows:u}=A(()=>{const e=t.length,r=t.reduce((n,o)=>Math.max(n,o.length),0);let i=d??1/0,a=l??-1/0;if(d===void 0||l===void 0)for(const n of t)for(const o of n)d===void 0&&o<i&&(i=o),l===void 0&&o>a&&(a=o);return{cols:r,colWidth:s,extent:{max:a,min:i},rows:e}},[t,d,l,s]),D=w*f,H=u;return M(m,{children:[g===void 0?void 0:c(m,{flexDirection:"column",marginRight:1,children:Array.from({length:u},(e,r)=>c(C,{dimColor:!0,children:g[r]??""},r))}),M(m,{flexDirection:"column",children:[c(k,{draw:e=>{e.clear();const{max:r,min:i}=j,a=r-i||1,n=x.length-1;for(let o=0;o<u;o+=1)for(let h=0;h<w;h+=1){const b=t[o]?.[h],R=b===void 0?void 0:x[Math.max(0,Math.min(n,Math.round((b-i)/a*n)))];for(let v=0;v<f;v+=1)e.setCell(h*f+v,o,L,{background:R,color:W})}},height:H,version:[t,x,s,d,l],width:D}),p===void 0?void 0:c(m,{children:p.map((e,r)=>c(m,{width:f,children:c(C,{dimColor:!0,wrap:"truncate-end",children:e})},r))})]})]})}export{I as Heatmap,I as default};
|
package/dist/help.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { KeyBinding } from '@visulima/tui/hooks/use-key-bindings';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
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({ bindings, descriptionColor, keyColor, maxColumns, mode, separator }: Props): ReactElement;
|
|
45
|
+
export { Help, type Props as HelpProps, Props, Help as default };
|
package/dist/help.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as m}from"react/jsx-runtime";import u from"@visulima/tui/components/box";import i from"@visulima/tui/components/text";import x from"@visulima/tui/hooks/use-window-size";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}=x();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(u,{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(u,{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 a=[];c&&a.push(e(i,{bold:!0,children:c},"title"));for(const[k,h]of g.entries()){const w=C(h.key);a.push(m(u,{children:[e(i,{color:o.keyColor,children:w}),e(i,{children:" "}),o.descriptionColor?e(i,{color:o.descriptionColor,children:h.description}):e(i,{dimColor:!0,children:h.description})]},`b-${k}`))}p.push(e(u,{flexDirection:"column",width:l,children:a},`col-${d}`))}return e(u,{flexDirection:"row",children:p})}export{B as Help,B as default};
|
|
@@ -0,0 +1,52 @@
|
|
|
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({ bins, color, data, height, max: maxOverride, min: minOverride, showValues, thresholds, width }: Props): ReactElement;
|
|
52
|
+
export { Histogram, type Props as HistogramProps, Props, Histogram as default };
|
|
@@ -0,0 +1 @@
|
|
|
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/image.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AnsiColors } from '@visulima/colorize';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { LiteralUnion } from 'type-fest';
|
|
4
|
+
type Pixel = LiteralUnion<AnsiColors, string> | undefined;
|
|
5
|
+
type Props = {
|
|
6
|
+
/**
|
|
7
|
+
* Character drawn for a transparent (undefined) pixel; defaults to a space.
|
|
8
|
+
*/
|
|
9
|
+
readonly emptyChar?: string;
|
|
10
|
+
/**
|
|
11
|
+
* A row-major grid of colors, one entry per pixel. `undefined` is treated
|
|
12
|
+
* as transparent. Two vertical pixels share one character cell via the
|
|
13
|
+
* upper-half-block technique, so the rendered height is `ceil(rows / 2)`.
|
|
14
|
+
*/
|
|
15
|
+
readonly pixels: ReadonlyArray<ReadonlyArray<Pixel>>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Render a small pixel grid using the upper-half-block technique: each text
|
|
19
|
+
* cell packs two vertical pixels — the top pixel as the glyph's foreground and
|
|
20
|
+
* the bottom pixel as its background — doubling vertical resolution.
|
|
21
|
+
*/
|
|
22
|
+
declare function Image({ emptyChar, pixels }: Props): ReactElement;
|
|
23
|
+
export { Image, type Props as ImageProps, Props, Image as default };
|
package/dist/image.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import f from"@visulima/tui/components/box";import h from"@visulima/tui/components/text";const p="▀",a="▄";function y({emptyChar:u=" ",pixels:e}){let c=0;for(const o of e)c=Math.max(c,o.length);const s=[];for(let o=0;o<e.length;o+=2){const d=e[o]??[],m=e[o+1]??[],i=[];for(let r=0;r<c;r+=1){const n=d[r],l=m[r];if(n===void 0&&l===void 0){i.push(t(h,{children:u},r));continue}if(n===void 0){i.push(t(h,{color:l,children:a},r));continue}i.push(t(h,{backgroundColor:l,color:n,children:p},r))}s.push(t(f,{children:i},o))}return t(f,{flexDirection:"column",children:s})}export{y as Image,y as default};
|