@textui/widgets 0.1.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/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/chart/area-chart.d.ts +4 -0
- package/dist/chart/area-chart.d.ts.map +1 -0
- package/dist/chart/area-chart.js +3 -0
- package/dist/chart/bar-chart.d.ts +32 -0
- package/dist/chart/bar-chart.d.ts.map +1 -0
- package/dist/chart/bar-chart.js +32 -0
- package/dist/chart/gauge.d.ts +26 -0
- package/dist/chart/gauge.d.ts.map +1 -0
- package/dist/chart/gauge.js +26 -0
- package/dist/chart/heatmap.d.ts +13 -0
- package/dist/chart/heatmap.d.ts.map +1 -0
- package/dist/chart/heatmap.js +27 -0
- package/dist/chart/histogram.d.ts +12 -0
- package/dist/chart/histogram.d.ts.map +1 -0
- package/dist/chart/histogram.js +22 -0
- package/dist/chart/index.d.ts +20 -0
- package/dist/chart/index.d.ts.map +1 -0
- package/dist/chart/index.js +32 -0
- package/dist/chart/line-chart.d.ts +7 -0
- package/dist/chart/line-chart.d.ts.map +1 -0
- package/dist/chart/line-chart.js +75 -0
- package/dist/chart/shared.d.ts +34 -0
- package/dist/chart/shared.d.ts.map +1 -0
- package/dist/chart/shared.js +78 -0
- package/dist/chart/sparkline.d.ts +15 -0
- package/dist/chart/sparkline.d.ts.map +1 -0
- package/dist/chart/sparkline.js +22 -0
- package/dist/control/button.d.ts +27 -0
- package/dist/control/button.d.ts.map +1 -0
- package/dist/control/button.js +130 -0
- package/dist/control/checkbox.d.ts +10 -0
- package/dist/control/checkbox.d.ts.map +1 -0
- package/dist/control/checkbox.js +31 -0
- package/dist/control/index.d.ts +20 -0
- package/dist/control/index.d.ts.map +1 -0
- package/dist/control/index.js +36 -0
- package/dist/control/radio-group.d.ts +17 -0
- package/dist/control/radio-group.d.ts.map +1 -0
- package/dist/control/radio-group.js +32 -0
- package/dist/control/search-box.d.ts +7 -0
- package/dist/control/search-box.d.ts.map +1 -0
- package/dist/control/search-box.js +3 -0
- package/dist/control/select.d.ts +42 -0
- package/dist/control/select.d.ts.map +1 -0
- package/dist/control/select.js +166 -0
- package/dist/control/shared.d.ts +41 -0
- package/dist/control/shared.d.ts.map +1 -0
- package/dist/control/shared.js +1 -0
- package/dist/control/slider.d.ts +14 -0
- package/dist/control/slider.d.ts.map +1 -0
- package/dist/control/slider.js +45 -0
- package/dist/control/switch.d.ts +10 -0
- package/dist/control/switch.d.ts.map +1 -0
- package/dist/control/switch.js +32 -0
- package/dist/control/text-area.d.ts +87 -0
- package/dist/control/text-area.d.ts.map +1 -0
- package/dist/control/text-area.js +299 -0
- package/dist/control/text-input.d.ts +10 -0
- package/dist/control/text-input.d.ts.map +1 -0
- package/dist/control/text-input.js +129 -0
- package/dist/data/code-viewer.d.ts +71 -0
- package/dist/data/code-viewer.d.ts.map +1 -0
- package/dist/data/code-viewer.js +232 -0
- package/dist/data/feed.d.ts +43 -0
- package/dist/data/feed.d.ts.map +1 -0
- package/dist/data/feed.js +178 -0
- package/dist/data/index.d.ts +54 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +187 -0
- package/dist/data/list.d.ts +31 -0
- package/dist/data/list.d.ts.map +1 -0
- package/dist/data/list.js +104 -0
- package/dist/data/log-viewer.d.ts +26 -0
- package/dist/data/log-viewer.d.ts.map +1 -0
- package/dist/data/log-viewer.js +69 -0
- package/dist/data/markdown-view.d.ts +31 -0
- package/dist/data/markdown-view.d.ts.map +1 -0
- package/dist/data/markdown-view.js +139 -0
- package/dist/data/pagination.d.ts +9 -0
- package/dist/data/pagination.d.ts.map +1 -0
- package/dist/data/pagination.js +18 -0
- package/dist/data/scroll-thumb.d.ts +15 -0
- package/dist/data/scroll-thumb.d.ts.map +1 -0
- package/dist/data/scroll-thumb.js +32 -0
- package/dist/data/shared.d.ts +12 -0
- package/dist/data/shared.d.ts.map +1 -0
- package/dist/data/shared.js +17 -0
- package/dist/data/tree.d.ts +35 -0
- package/dist/data/tree.d.ts.map +1 -0
- package/dist/data/tree.js +158 -0
- package/dist/decorations.d.ts +88 -0
- package/dist/decorations.d.ts.map +1 -0
- package/dist/decorations.js +135 -0
- package/dist/display/alert.d.ts +8 -0
- package/dist/display/alert.d.ts.map +1 -0
- package/dist/display/alert.js +12 -0
- package/dist/display/badge.d.ts +10 -0
- package/dist/display/badge.d.ts.map +1 -0
- package/dist/display/badge.js +21 -0
- package/dist/display/card.d.ts +8 -0
- package/dist/display/card.d.ts.map +1 -0
- package/dist/display/card.js +12 -0
- package/dist/display/empty-state.d.ts +10 -0
- package/dist/display/empty-state.d.ts.map +1 -0
- package/dist/display/empty-state.js +5 -0
- package/dist/display/error-state.d.ts +9 -0
- package/dist/display/error-state.d.ts.map +1 -0
- package/dist/display/error-state.js +7 -0
- package/dist/display/heading.d.ts +6 -0
- package/dist/display/heading.d.ts.map +1 -0
- package/dist/display/heading.js +8 -0
- package/dist/display/index.d.ts +25 -0
- package/dist/display/index.d.ts.map +1 -0
- package/dist/display/index.js +52 -0
- package/dist/display/key-value.d.ts +14 -0
- package/dist/display/key-value.d.ts.map +1 -0
- package/dist/display/key-value.js +11 -0
- package/dist/display/label.d.ts +6 -0
- package/dist/display/label.d.ts.map +1 -0
- package/dist/display/label.js +3 -0
- package/dist/display/marquee.d.ts +36 -0
- package/dist/display/marquee.d.ts.map +1 -0
- package/dist/display/marquee.js +55 -0
- package/dist/display/progress.d.ts +39 -0
- package/dist/display/progress.d.ts.map +1 -0
- package/dist/display/progress.js +46 -0
- package/dist/display/skeleton.d.ts +20 -0
- package/dist/display/skeleton.d.ts.map +1 -0
- package/dist/display/skeleton.js +20 -0
- package/dist/display/spinner.d.ts +7 -0
- package/dist/display/spinner.d.ts.map +1 -0
- package/dist/display/spinner.js +9 -0
- package/dist/display/status-dot.d.ts +8 -0
- package/dist/display/status-dot.d.ts.map +1 -0
- package/dist/display/status-dot.js +13 -0
- package/dist/display/timeline.d.ts +12 -0
- package/dist/display/timeline.d.ts.map +1 -0
- package/dist/display/timeline.js +22 -0
- package/dist/find.d.ts +74 -0
- package/dist/find.d.ts.map +1 -0
- package/dist/find.js +102 -0
- package/dist/form/danger-zone.d.ts +11 -0
- package/dist/form/danger-zone.d.ts.map +1 -0
- package/dist/form/danger-zone.js +15 -0
- package/dist/form/field.d.ts +19 -0
- package/dist/form/field.d.ts.map +1 -0
- package/dist/form/field.js +35 -0
- package/dist/form/form-actions.d.ts +11 -0
- package/dist/form/form-actions.d.ts.map +1 -0
- package/dist/form/form-actions.js +16 -0
- package/dist/form/form-section.d.ts +7 -0
- package/dist/form/form-section.d.ts.map +1 -0
- package/dist/form/form-section.js +5 -0
- package/dist/form/form.d.ts +7 -0
- package/dist/form/form.d.ts.map +1 -0
- package/dist/form/form.js +3 -0
- package/dist/form/index.d.ts +42 -0
- package/dist/form/index.d.ts.map +1 -0
- package/dist/form/index.js +140 -0
- package/dist/form/shared.d.ts +25 -0
- package/dist/form/shared.d.ts.map +1 -0
- package/dist/form/shared.js +9 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/layout/center.d.ts +7 -0
- package/dist/layout/center.d.ts.map +1 -0
- package/dist/layout/center.js +8 -0
- package/dist/layout/column.d.ts +3 -0
- package/dist/layout/column.d.ts.map +1 -0
- package/dist/layout/column.js +2 -0
- package/dist/layout/divider.d.ts +11 -0
- package/dist/layout/divider.d.ts.map +1 -0
- package/dist/layout/divider.js +13 -0
- package/dist/layout/grid.d.ts +10 -0
- package/dist/layout/grid.d.ts.map +1 -0
- package/dist/layout/grid.js +22 -0
- package/dist/layout/index.d.ts +19 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +36 -0
- package/dist/layout/panel.d.ts +37 -0
- package/dist/layout/panel.d.ts.map +1 -0
- package/dist/layout/panel.js +71 -0
- package/dist/layout/row.d.ts +7 -0
- package/dist/layout/row.d.ts.map +1 -0
- package/dist/layout/row.js +2 -0
- package/dist/layout/scroll-view.d.ts +27 -0
- package/dist/layout/scroll-view.d.ts.map +1 -0
- package/dist/layout/scroll-view.js +93 -0
- package/dist/layout/splitter.d.ts +10 -0
- package/dist/layout/splitter.d.ts.map +1 -0
- package/dist/layout/splitter.js +9 -0
- package/dist/layout/stack.d.ts +7 -0
- package/dist/layout/stack.d.ts.map +1 -0
- package/dist/layout/stack.js +5 -0
- package/dist/navigation/breadcrumb.d.ts +14 -0
- package/dist/navigation/breadcrumb.d.ts.map +1 -0
- package/dist/navigation/breadcrumb.js +24 -0
- package/dist/navigation/index.d.ts +17 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +30 -0
- package/dist/navigation/key-hints.d.ts +11 -0
- package/dist/navigation/key-hints.d.ts.map +1 -0
- package/dist/navigation/key-hints.js +13 -0
- package/dist/navigation/menu.d.ts +35 -0
- package/dist/navigation/menu.d.ts.map +1 -0
- package/dist/navigation/menu.js +88 -0
- package/dist/navigation/status-bar.d.ts +18 -0
- package/dist/navigation/status-bar.d.ts.map +1 -0
- package/dist/navigation/status-bar.js +12 -0
- package/dist/navigation/tabs.d.ts +20 -0
- package/dist/navigation/tabs.d.ts.map +1 -0
- package/dist/navigation/tabs.js +41 -0
- package/dist/navigation/toolbar.d.ts +14 -0
- package/dist/navigation/toolbar.d.ts.map +1 -0
- package/dist/navigation/toolbar.js +10 -0
- package/dist/navigation/wizard.d.ts +15 -0
- package/dist/navigation/wizard.d.ts.map +1 -0
- package/dist/navigation/wizard.js +17 -0
- package/dist/overlay/command-palette.d.ts +63 -0
- package/dist/overlay/command-palette.d.ts.map +1 -0
- package/dist/overlay/command-palette.js +415 -0
- package/dist/overlay/dialog.d.ts +16 -0
- package/dist/overlay/dialog.d.ts.map +1 -0
- package/dist/overlay/dialog.js +44 -0
- package/dist/overlay/index.d.ts +84 -0
- package/dist/overlay/index.d.ts.map +1 -0
- package/dist/overlay/index.js +157 -0
- package/dist/overlay/layer-scope.d.ts +21 -0
- package/dist/overlay/layer-scope.d.ts.map +1 -0
- package/dist/overlay/layer-scope.js +5 -0
- package/dist/overlay/path-picker.d.ts +14 -0
- package/dist/overlay/path-picker.d.ts.map +1 -0
- package/dist/overlay/path-picker.js +200 -0
- package/dist/overlay/prompt-dialog.d.ts +12 -0
- package/dist/overlay/prompt-dialog.d.ts.map +1 -0
- package/dist/overlay/prompt-dialog.js +29 -0
- package/dist/overlay/shared.d.ts +17 -0
- package/dist/overlay/shared.d.ts.map +1 -0
- package/dist/overlay/shared.js +17 -0
- package/dist/overlay/toast-host.d.ts +8 -0
- package/dist/overlay/toast-host.d.ts.map +1 -0
- package/dist/overlay/toast-host.js +19 -0
- package/dist/overlay/toast.d.ts +9 -0
- package/dist/overlay/toast.d.ts.map +1 -0
- package/dist/overlay/toast.js +20 -0
- package/dist/overlay/tooltip.d.ts +6 -0
- package/dist/overlay/tooltip.d.ts.map +1 -0
- package/dist/overlay/tooltip.js +11 -0
- package/dist/panel/index.d.ts +79 -0
- package/dist/panel/index.d.ts.map +1 -0
- package/dist/panel/index.js +256 -0
- package/dist/panel/resource-panel.d.ts +93 -0
- package/dist/panel/resource-panel.d.ts.map +1 -0
- package/dist/panel/resource-panel.js +213 -0
- package/dist/panel/shared.d.ts +6 -0
- package/dist/panel/shared.d.ts.map +1 -0
- package/dist/panel/shared.js +4 -0
- package/dist/shells/console-shell.d.ts +8 -0
- package/dist/shells/console-shell.d.ts.map +1 -0
- package/dist/shells/console-shell.js +30 -0
- package/dist/shells/index.d.ts +20 -0
- package/dist/shells/index.d.ts.map +1 -0
- package/dist/shells/index.js +61 -0
- package/dist/shells/paper-shell.d.ts +9 -0
- package/dist/shells/paper-shell.d.ts.map +1 -0
- package/dist/shells/paper-shell.js +23 -0
- package/dist/shells/plain-shell.d.ts +3 -0
- package/dist/shells/plain-shell.d.ts.map +1 -0
- package/dist/shells/plain-shell.js +11 -0
- package/dist/shells/shared.d.ts +12 -0
- package/dist/shells/shared.d.ts.map +1 -0
- package/dist/shells/shared.js +21 -0
- package/dist/shells/workbench-shell.d.ts +9 -0
- package/dist/shells/workbench-shell.d.ts.map +1 -0
- package/dist/shells/workbench-shell.js +43 -0
- package/dist/surface/bar-layout.d.ts +4 -0
- package/dist/surface/bar-layout.d.ts.map +1 -0
- package/dist/surface/bar-layout.js +7 -0
- package/dist/surface/index.d.ts +58 -0
- package/dist/surface/index.d.ts.map +1 -0
- package/dist/surface/index.js +48 -0
- package/dist/surface/inline-layout.d.ts +4 -0
- package/dist/surface/inline-layout.d.ts.map +1 -0
- package/dist/surface/inline-layout.js +7 -0
- package/dist/surface/mount-view.d.ts +7 -0
- package/dist/surface/mount-view.d.ts.map +1 -0
- package/dist/surface/mount-view.js +19 -0
- package/dist/surface/rail-layout.d.ts +4 -0
- package/dist/surface/rail-layout.d.ts.map +1 -0
- package/dist/surface/rail-layout.js +19 -0
- package/dist/surface/shared.d.ts +7 -0
- package/dist/surface/shared.d.ts.map +1 -0
- package/dist/surface/shared.js +1 -0
- package/dist/surface/single-layout.d.ts +4 -0
- package/dist/surface/single-layout.d.ts.map +1 -0
- package/dist/surface/single-layout.js +18 -0
- package/dist/surface/split-layout.d.ts +4 -0
- package/dist/surface/split-layout.d.ts.map +1 -0
- package/dist/surface/split-layout.js +7 -0
- package/dist/surface/stack-layout.d.ts +4 -0
- package/dist/surface/stack-layout.d.ts.map +1 -0
- package/dist/surface/stack-layout.js +22 -0
- package/dist/surface/surface-area.d.ts +16 -0
- package/dist/surface/surface-area.d.ts.map +1 -0
- package/dist/surface/surface-area.js +32 -0
- package/dist/surface/tabs-layout.d.ts +4 -0
- package/dist/surface/tabs-layout.d.ts.map +1 -0
- package/dist/surface/tabs-layout.js +24 -0
- package/dist/tone.d.ts +16 -0
- package/dist/tone.d.ts.map +1 -0
- package/dist/tone.js +45 -0
- package/dist/viewport.d.ts +30 -0
- package/dist/viewport.d.ts.map +1 -0
- package/dist/viewport.js +17 -0
- package/package.json +54 -0
- package/src/chart/area-chart.ts +9 -0
- package/src/chart/bar-chart.ts +74 -0
- package/src/chart/gauge.ts +60 -0
- package/src/chart/heatmap.ts +49 -0
- package/src/chart/histogram.ts +36 -0
- package/src/chart/index.ts +36 -0
- package/src/chart/line-chart.ts +100 -0
- package/src/chart/shared.ts +112 -0
- package/src/chart/sparkline.ts +46 -0
- package/src/control/button.ts +184 -0
- package/src/control/checkbox.ts +48 -0
- package/src/control/index.ts +40 -0
- package/src/control/radio-group.ts +60 -0
- package/src/control/search-box.ts +15 -0
- package/src/control/select.ts +230 -0
- package/src/control/shared.ts +41 -0
- package/src/control/slider.ts +63 -0
- package/src/control/switch.ts +39 -0
- package/src/control/text-area.ts +390 -0
- package/src/control/text-input.ts +150 -0
- package/src/data/code-viewer.ts +337 -0
- package/src/data/feed.ts +204 -0
- package/src/data/index.ts +243 -0
- package/src/data/list.ts +149 -0
- package/src/data/log-viewer.ts +105 -0
- package/src/data/markdown-view.ts +182 -0
- package/src/data/pagination.ts +31 -0
- package/src/data/scroll-thumb.ts +40 -0
- package/src/data/shared.ts +23 -0
- package/src/data/tree.ts +215 -0
- package/src/decorations.ts +176 -0
- package/src/display/alert.ts +28 -0
- package/src/display/badge.ts +40 -0
- package/src/display/card.ts +23 -0
- package/src/display/empty-state.ts +21 -0
- package/src/display/error-state.ts +23 -0
- package/src/display/heading.ts +17 -0
- package/src/display/index.ts +55 -0
- package/src/display/key-value.ts +32 -0
- package/src/display/label.ts +11 -0
- package/src/display/marquee.ts +88 -0
- package/src/display/progress.ts +92 -0
- package/src/display/skeleton.ts +34 -0
- package/src/display/spinner.ts +20 -0
- package/src/display/status-dot.ts +24 -0
- package/src/display/timeline.ts +47 -0
- package/src/find.ts +138 -0
- package/src/form/danger-zone.ts +34 -0
- package/src/form/field.ts +61 -0
- package/src/form/form-actions.ts +35 -0
- package/src/form/form-section.ts +16 -0
- package/src/form/form.ts +13 -0
- package/src/form/index.ts +191 -0
- package/src/form/shared.ts +36 -0
- package/src/index.ts +63 -0
- package/src/layout/center.ts +17 -0
- package/src/layout/column.ts +6 -0
- package/src/layout/divider.ts +31 -0
- package/src/layout/grid.ts +34 -0
- package/src/layout/index.ts +39 -0
- package/src/layout/panel.ts +114 -0
- package/src/layout/row.ts +11 -0
- package/src/layout/scroll-view.ts +115 -0
- package/src/layout/splitter.ts +24 -0
- package/src/layout/stack.ts +12 -0
- package/src/navigation/breadcrumb.ts +43 -0
- package/src/navigation/index.ts +33 -0
- package/src/navigation/key-hints.ts +25 -0
- package/src/navigation/menu.ts +134 -0
- package/src/navigation/status-bar.ts +43 -0
- package/src/navigation/tabs.ts +73 -0
- package/src/navigation/toolbar.ts +25 -0
- package/src/navigation/wizard.ts +43 -0
- package/src/overlay/command-palette.ts +485 -0
- package/src/overlay/dialog.ts +65 -0
- package/src/overlay/index.ts +232 -0
- package/src/overlay/layer-scope.ts +26 -0
- package/src/overlay/path-picker.ts +215 -0
- package/src/overlay/prompt-dialog.ts +45 -0
- package/src/overlay/shared.ts +19 -0
- package/src/overlay/toast-host.ts +30 -0
- package/src/overlay/toast.ts +35 -0
- package/src/overlay/tooltip.ts +17 -0
- package/src/panel/index.ts +317 -0
- package/src/panel/resource-panel.ts +304 -0
- package/src/panel/shared.ts +8 -0
- package/src/shells/console-shell.ts +47 -0
- package/src/shells/index.ts +66 -0
- package/src/shells/paper-shell.ts +31 -0
- package/src/shells/plain-shell.ts +19 -0
- package/src/shells/shared.ts +24 -0
- package/src/shells/workbench-shell.ts +62 -0
- package/src/surface/bar-layout.ts +11 -0
- package/src/surface/index.ts +53 -0
- package/src/surface/inline-layout.ts +11 -0
- package/src/surface/mount-view.ts +30 -0
- package/src/surface/rail-layout.ts +27 -0
- package/src/surface/shared.ts +7 -0
- package/src/surface/single-layout.ts +25 -0
- package/src/surface/split-layout.ts +11 -0
- package/src/surface/stack-layout.ts +32 -0
- package/src/surface/surface-area.ts +46 -0
- package/src/surface/tabs-layout.ts +30 -0
- package/src/tone.ts +48 -0
- package/src/viewport.ts +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divider.d.ts","sourceRoot":"","sources":["../../src/layout/divider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/D,gEAAgE;IAChE,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACtC,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,OAAO,8DAkBlB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineComponent, h, useTheme } from '@textui/core';
|
|
2
|
+
export const Divider = defineComponent('Divider', (props) => {
|
|
3
|
+
const theme = useTheme();
|
|
4
|
+
const { direction = 'horizontal', label, labelAlign = 'left', char, ...rest } = props;
|
|
5
|
+
const chars = theme.borderChars();
|
|
6
|
+
if (direction === 'vertical') {
|
|
7
|
+
return h('box', { role: 'separator', width: 1, fill: char ?? chars.left, fg: 'border', ...rest });
|
|
8
|
+
}
|
|
9
|
+
if (!label) {
|
|
10
|
+
return h('box', { role: 'separator', height: 1, fill: char ?? chars.top, fg: 'border', ...rest });
|
|
11
|
+
}
|
|
12
|
+
return h('box', { direction: 'row', gap: 1, height: 1, ...rest }, labelAlign !== 'left' ? h('box', { flex: 1, fill: char ?? chars.top, fg: 'border' }) : null, h('text', { content: label, fg: 'muted' }), labelAlign !== 'right' ? h('box', { flex: 1, fill: char ?? chars.top, fg: 'border' }) : null);
|
|
13
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BoxProps } from '@textui/core';
|
|
2
|
+
export interface GridProps extends BoxProps {
|
|
3
|
+
columns: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A grid is rows of equal-flex cells. Terminals have no sub-cell measurement,
|
|
7
|
+
* so an even split is the honest primitive; anything else is a Row with widths.
|
|
8
|
+
*/
|
|
9
|
+
export declare const Grid: (props: GridProps) => import("@textui/core").RenderOutput;
|
|
10
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/layout/grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,2DAsBf,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineComponent, h } from '@textui/core';
|
|
2
|
+
/**
|
|
3
|
+
* A grid is rows of equal-flex cells. Terminals have no sub-cell measurement,
|
|
4
|
+
* so an even split is the honest primitive; anything else is a Row with widths.
|
|
5
|
+
*/
|
|
6
|
+
export const Grid = defineComponent('Grid', ({ columns, columnGap, rowGap, children, ...props }) => {
|
|
7
|
+
const items = Array.isArray(children) ? children : children === undefined ? [] : [children];
|
|
8
|
+
const rows = [];
|
|
9
|
+
for (let i = 0; i < items.length; i += columns)
|
|
10
|
+
rows.push(items.slice(i, i + columns));
|
|
11
|
+
return h('box', { direction: 'column', gap: rowGap ?? props.gap ?? 0, ...props }, ...rows.map((row, i) => h('box', { key: i, direction: 'row', gap: columnGap ?? props.gap ?? 1 },
|
|
12
|
+
// `basis: 0` is what makes the columns *equal* rather than merely
|
|
13
|
+
// flexible. Without it a cell starts at the width its content asked
|
|
14
|
+
// for and only the space left over is shared - so a pane holding one
|
|
15
|
+
// long unwrapped line takes two thirds of the row and the one beside
|
|
16
|
+
// it is squeezed to a column of single words. Equal columns is what
|
|
17
|
+
// this component says it is for; anything that wants to be sized by
|
|
18
|
+
// its content wants a `Row`.
|
|
19
|
+
...row.map((cell, j) => h('box', { key: j, flex: 1, basis: 0, minWidth: 0 }, cell)),
|
|
20
|
+
// Pad the last row so its cells keep the same width as the others.
|
|
21
|
+
...Array.from({ length: columns - row.length }, (_, k) => h('box', { key: `pad${k}`, flex: 1, basis: 0 })))));
|
|
22
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentDefinition } from '@textui/core';
|
|
2
|
+
/**
|
|
3
|
+
* Layout and containers.
|
|
4
|
+
*
|
|
5
|
+
* Every one of these is `box` with an opinion. That is the point: the layout
|
|
6
|
+
* engine only ever sees the primitive, so a new container costs a function
|
|
7
|
+
* rather than a new case in the engine.
|
|
8
|
+
*/
|
|
9
|
+
export * from './center.js';
|
|
10
|
+
export * from './column.js';
|
|
11
|
+
export * from './divider.js';
|
|
12
|
+
export * from './grid.js';
|
|
13
|
+
export * from './panel.js';
|
|
14
|
+
export * from './row.js';
|
|
15
|
+
export * from './scroll-view.js';
|
|
16
|
+
export * from './splitter.js';
|
|
17
|
+
export * from './stack.js';
|
|
18
|
+
export declare const LAYOUT_COMPONENTS: ComponentDefinition[];
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAWxD;;;;;;GAMG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAE3B,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,EAUlD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Center } from './center.js';
|
|
2
|
+
import { Column } from './column.js';
|
|
3
|
+
import { Divider } from './divider.js';
|
|
4
|
+
import { Grid } from './grid.js';
|
|
5
|
+
import { Panel } from './panel.js';
|
|
6
|
+
import { Row } from './row.js';
|
|
7
|
+
import { ScrollView } from './scroll-view.js';
|
|
8
|
+
import { Splitter } from './splitter.js';
|
|
9
|
+
import { Stack } from './stack.js';
|
|
10
|
+
/**
|
|
11
|
+
* Layout and containers.
|
|
12
|
+
*
|
|
13
|
+
* Every one of these is `box` with an opinion. That is the point: the layout
|
|
14
|
+
* engine only ever sees the primitive, so a new container costs a function
|
|
15
|
+
* rather than a new case in the engine.
|
|
16
|
+
*/
|
|
17
|
+
export * from './center.js';
|
|
18
|
+
export * from './column.js';
|
|
19
|
+
export * from './divider.js';
|
|
20
|
+
export * from './grid.js';
|
|
21
|
+
export * from './panel.js';
|
|
22
|
+
export * from './row.js';
|
|
23
|
+
export * from './scroll-view.js';
|
|
24
|
+
export * from './splitter.js';
|
|
25
|
+
export * from './stack.js';
|
|
26
|
+
export const LAYOUT_COMPONENTS = [
|
|
27
|
+
{ component: 'Row', category: 'layout', renderer: { kind: 'function', render: Row }, description: 'Horizontal flex container.' },
|
|
28
|
+
{ component: 'Column', category: 'layout', renderer: { kind: 'function', render: Column }, description: 'Vertical flex container.' },
|
|
29
|
+
{ component: 'Center', category: 'layout', renderer: { kind: 'function', render: Center }, description: 'Centres its children.' },
|
|
30
|
+
{ component: 'Grid', category: 'layout', renderer: { kind: 'function', render: Grid }, description: 'Equal-width columns, wrapping into rows.' },
|
|
31
|
+
{ component: 'Panel', category: 'layout', renderer: { kind: 'function', render: Panel }, description: 'Titled region. Bordered or airy, following the theme.', variants: ['bordered', 'plain'], role: 'region' },
|
|
32
|
+
{ component: 'Divider', category: 'layout', renderer: { kind: 'function', render: Divider }, description: 'A rule, optionally labelled.', role: 'separator' },
|
|
33
|
+
{ component: 'Stack', category: 'layout', renderer: { kind: 'function', render: Stack }, description: 'Column with themed spacing.' },
|
|
34
|
+
{ component: 'ScrollView', category: 'layout', renderer: { kind: 'function', render: ScrollView }, description: 'Scrolling viewport with keyboard and wheel support.' },
|
|
35
|
+
{ component: 'Splitter', category: 'layout', renderer: { kind: 'function', render: Splitter }, description: 'Two panes with a divider.' },
|
|
36
|
+
];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BorderSpec, BoxProps, StyleColor } from '@textui/core';
|
|
2
|
+
export interface PanelProps extends BoxProps {
|
|
3
|
+
/** Section heading drawn into the border, or above a borderless panel. */
|
|
4
|
+
title?: string;
|
|
5
|
+
subtitle?: string;
|
|
6
|
+
/** Accent colour for the title. */
|
|
7
|
+
tone?: StyleColor;
|
|
8
|
+
/** Overrides the theme's default border. `'none'` gives an airy panel. */
|
|
9
|
+
border?: BorderSpec;
|
|
10
|
+
/**
|
|
11
|
+
* Right-aligned text beside the title, on the same row.
|
|
12
|
+
*
|
|
13
|
+
* The short thing that belongs next to a heading rather than under it: a
|
|
14
|
+
* count, a state, the shortcut that opens it. Optional, and most panels do
|
|
15
|
+
* not have one.
|
|
16
|
+
*/
|
|
17
|
+
rightTitle?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Right-aligned text on the *bottom* rule, where there is one.
|
|
20
|
+
*
|
|
21
|
+
* Not the title row - which is what this said for a long time while doing
|
|
22
|
+
* something else. A bordered panel put it in the footer and a borderless one
|
|
23
|
+
* put it beside the title, so the same prop meant two places depending on a
|
|
24
|
+
* different prop. `rightTitle` is the title row, in both; this is the
|
|
25
|
+
* bottom, and on a borderless panel there is no bottom to put it on.
|
|
26
|
+
*/
|
|
27
|
+
meta?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The workhorse container.
|
|
31
|
+
*
|
|
32
|
+
* A panel is the one component that has to look right in all three house
|
|
33
|
+
* styles, so it renders its title into the border when it has one and as a
|
|
34
|
+
* heading row when it does not - rather than forcing a border to have a title.
|
|
35
|
+
*/
|
|
36
|
+
export declare const Panel: (props: PanelProps) => import("@textui/core").RenderOutput;
|
|
37
|
+
//# sourceMappingURL=panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/layout/panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGrE,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC1C,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,4DA2EhB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { defineComponent, h, resolveEdges, useTheme } from '@textui/core';
|
|
2
|
+
/**
|
|
3
|
+
* The workhorse container.
|
|
4
|
+
*
|
|
5
|
+
* A panel is the one component that has to look right in all three house
|
|
6
|
+
* styles, so it renders its title into the border when it has one and as a
|
|
7
|
+
* heading row when it does not - rather than forcing a border to have a title.
|
|
8
|
+
*/
|
|
9
|
+
export const Panel = defineComponent('Panel', (props) => {
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const { title, subtitle, tone, meta, rightTitle, children, padding, ...rest } = props;
|
|
12
|
+
/*
|
|
13
|
+
* Padding is about the *body*, and a subtitle is not the body.
|
|
14
|
+
*
|
|
15
|
+
* It used to be one box: the border or the heading row, then the subtitle
|
|
16
|
+
* and the children together inside whatever padding the caller asked for. So
|
|
17
|
+
* `padding={1}` put a blank row between the title and its own caption and
|
|
18
|
+
* left the caption sitting directly on top of the content it was not part
|
|
19
|
+
* of - the subtitle read as the first line of the body. On a borderless
|
|
20
|
+
* panel it pushed the title down as well.
|
|
21
|
+
*
|
|
22
|
+
* Split, then: the horizontal padding stays outside and applies to
|
|
23
|
+
* everything, because a subtitle indented differently from the body under it
|
|
24
|
+
* is worse than either; the vertical padding wraps the children alone.
|
|
25
|
+
*
|
|
26
|
+
* Only when there is a subtitle to protect. Without one there is nothing to
|
|
27
|
+
* separate the padding from, and a panel that gained a box would be a panel
|
|
28
|
+
* whose layout changed for no reason.
|
|
29
|
+
*/
|
|
30
|
+
const pad = resolveEdges(padding);
|
|
31
|
+
const split = subtitle !== undefined && (pad.top > 0 || pad.bottom > 0);
|
|
32
|
+
const outerPad = split ? { left: pad.left, right: pad.right } : padding;
|
|
33
|
+
const body = split
|
|
34
|
+
? h('box', { direction: 'column', padding: { top: pad.top, bottom: pad.bottom } }, children)
|
|
35
|
+
: children;
|
|
36
|
+
const border = props.border ?? theme.border;
|
|
37
|
+
const borderless = border === 'none' || (typeof border === 'object' && border.style === 'none');
|
|
38
|
+
// A panel is a pane, so it fills its row rather than floating in the middle
|
|
39
|
+
// of it. `Row` centres its children by default, which is right for a row of
|
|
40
|
+
// labels and wrong for a row of panels sitting next to a taller one.
|
|
41
|
+
const fill = { alignSelf: 'stretch' };
|
|
42
|
+
if (!borderless) {
|
|
43
|
+
// Two rules, two labels: `rightTitle` on the top one beside the title, and
|
|
44
|
+
// `meta` on the bottom one. The border painter gives the right label its
|
|
45
|
+
// width first, so a long title truncates rather than running into it.
|
|
46
|
+
return h('box', {
|
|
47
|
+
role: 'region',
|
|
48
|
+
border,
|
|
49
|
+
title,
|
|
50
|
+
...(rightTitle !== undefined ? { rightTitle } : {}),
|
|
51
|
+
footer: meta,
|
|
52
|
+
footerAlign: 'right',
|
|
53
|
+
...fill,
|
|
54
|
+
...(outerPad === undefined ? {} : { padding: outerPad }),
|
|
55
|
+
...rest,
|
|
56
|
+
}, subtitle !== undefined ? h('text', { content: subtitle, fg: 'muted' }) : null, body);
|
|
57
|
+
}
|
|
58
|
+
return h('box', {
|
|
59
|
+
role: 'region',
|
|
60
|
+
direction: 'column',
|
|
61
|
+
...fill,
|
|
62
|
+
...(outerPad === undefined ? {} : { padding: outerPad }),
|
|
63
|
+
...rest,
|
|
64
|
+
border: 'none',
|
|
65
|
+
}, title
|
|
66
|
+
? h('box', { direction: 'row', gap: 1 }, h('text', { content: title, bold: true, fg: tone ?? 'text', flex: 1, truncate: 'end' }),
|
|
67
|
+
// No border to write on, so the same two labels share the heading
|
|
68
|
+
// row - `rightTitle` first, because it is the one that must survive.
|
|
69
|
+
rightTitle ? h('text', { content: rightTitle, fg: 'muted' }) : null, meta ? h('text', { content: meta, fg: 'muted' }) : null)
|
|
70
|
+
: null, subtitle !== undefined ? h('text', { content: subtitle, fg: 'muted' }) : null, body);
|
|
71
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BoxProps } from '@textui/core';
|
|
2
|
+
export interface RowProps extends BoxProps {
|
|
3
|
+
/** Shorthand for `align`, which reads better on a row. */
|
|
4
|
+
vAlign?: BoxProps['align'];
|
|
5
|
+
}
|
|
6
|
+
export declare const Row: (props: RowProps) => import("@textui/core").RenderOutput;
|
|
7
|
+
//# sourceMappingURL=row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.d.ts","sourceRoot":"","sources":["../../src/layout/row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACxC,0DAA0D;IAC1D,MAAM,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,GAAG,0DAEf,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BoxProps } from '@textui/core';
|
|
2
|
+
export interface ScrollViewProps extends BoxProps {
|
|
3
|
+
/** Controlled offset. Omit to let the view manage its own. */
|
|
4
|
+
offset?: number;
|
|
5
|
+
onScroll?(offset: number): void;
|
|
6
|
+
/** Draw a scrollbar on the right when the content overflows. */
|
|
7
|
+
scrollbar?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* A tab stop, so the keys that scroll it can reach it.
|
|
10
|
+
*
|
|
11
|
+
* On by default: a viewport had the arrow handlers all along and registered
|
|
12
|
+
* nothing, so unless the caller happened to make it focusable itself the
|
|
13
|
+
* only way to scroll was the wheel - which is to say, on a keyboard, not at
|
|
14
|
+
* all. Turn it off for a view that scrolls inside something already focused.
|
|
15
|
+
*/
|
|
16
|
+
focusable?: boolean;
|
|
17
|
+
autoFocus?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A scrolling viewport.
|
|
21
|
+
*
|
|
22
|
+
* Scroll position is a number of cells, not a fraction: a terminal cannot
|
|
23
|
+
* scroll by half a line, and pretending otherwise makes a list jitter as it
|
|
24
|
+
* rounds.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ScrollView: (props: ScrollViewProps) => import("@textui/core").RenderOutput;
|
|
27
|
+
//# sourceMappingURL=scroll-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-view.d.ts","sourceRoot":"","sources":["../../src/layout/scroll-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAa7C,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gEAAgE;IAChE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,iEA4ErB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { chorded, defineComponent, h, useFocus, useInput, useMeasure, useScrollExtent, useState, } from '@textui/core';
|
|
2
|
+
import { ScrollThumb } from '../data/scroll-thumb.js';
|
|
3
|
+
/**
|
|
4
|
+
* A scrolling viewport.
|
|
5
|
+
*
|
|
6
|
+
* Scroll position is a number of cells, not a fraction: a terminal cannot
|
|
7
|
+
* scroll by half a line, and pretending otherwise makes a list jitter as it
|
|
8
|
+
* rounds.
|
|
9
|
+
*/
|
|
10
|
+
export const ScrollView = defineComponent('ScrollView', (props) => {
|
|
11
|
+
const { offset, onScroll, scrollbar = true, focusable = true, autoFocus, id, children, ...rest } = props;
|
|
12
|
+
const focus = useFocus({ disabled: !focusable, autoFocus });
|
|
13
|
+
const [internal, setInternal] = useState(0);
|
|
14
|
+
const top = offset ?? internal;
|
|
15
|
+
// How far down this can go before the last line leaves the bottom. Written
|
|
16
|
+
// by the viewport during its render, read here when a key arrives - so a
|
|
17
|
+
// limit that changed with the terminal's height needs no round trip.
|
|
18
|
+
const measured = useMeasure();
|
|
19
|
+
const extent = useScrollExtent();
|
|
20
|
+
// How far the top can go before the last line leaves the bottom of the view.
|
|
21
|
+
// Zero when everything fits, which is also what makes the arrows do nothing
|
|
22
|
+
// in a viewport that has nothing to scroll.
|
|
23
|
+
const limit = Math.max(0, (extent?.height ?? 0) - measured.height);
|
|
24
|
+
const scrollTo = (next) => {
|
|
25
|
+
const clamped = Math.max(0, Math.min(next, limit));
|
|
26
|
+
if (offset === undefined)
|
|
27
|
+
setInternal(clamped);
|
|
28
|
+
onScroll?.(clamped);
|
|
29
|
+
};
|
|
30
|
+
useInput((event) => {
|
|
31
|
+
if (chorded(event))
|
|
32
|
+
return false;
|
|
33
|
+
if (event.name === 'up') {
|
|
34
|
+
scrollTo(top - 1);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (event.name === 'down') {
|
|
38
|
+
scrollTo(top + 1);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (event.name === 'pageup') {
|
|
42
|
+
scrollTo(top - 10);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
if (event.name === 'pagedown') {
|
|
46
|
+
scrollTo(top + 10);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (event.name === 'home') {
|
|
50
|
+
scrollTo(0);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}, { focusId: focus.id, enabled: focusable });
|
|
55
|
+
// The outer box holds the viewport beside the scrollbar and does not scroll
|
|
56
|
+
// itself. It used to say `overflow: 'scroll'` with a `scrollTop`, on a row -
|
|
57
|
+
// where the scrolling axis is horizontal, so the offset did nothing and the
|
|
58
|
+
// only real effect was to stop the viewport being clamped to the width it
|
|
59
|
+
// had. That made the row report *its own* sideways overflow as this view's
|
|
60
|
+
// scroll extent: a number about a different box on a different axis.
|
|
61
|
+
return h('box', {
|
|
62
|
+
id: id ?? focus.id,
|
|
63
|
+
role: 'region',
|
|
64
|
+
...rest,
|
|
65
|
+
overflow: 'hidden',
|
|
66
|
+
direction: 'row',
|
|
67
|
+
onMouse: (event) => {
|
|
68
|
+
if (event.action !== 'wheel')
|
|
69
|
+
return false;
|
|
70
|
+
scrollTo(top + (event.wheel ?? 0) * 3);
|
|
71
|
+
return true;
|
|
72
|
+
},
|
|
73
|
+
}, h('box', { flex: 1, direction: 'column', scrollTop: Math.min(top, limit), overflow: 'scroll' }, children),
|
|
74
|
+
// `ScrollThumb`, which is what every other viewport in the library draws -
|
|
75
|
+
// its own comment says so: "two components drawing their own would drift".
|
|
76
|
+
// This one drew a different thing, a one-cell column filled with a border
|
|
77
|
+
// glyph, that took the offset as a prop and ignored it. So it said nothing
|
|
78
|
+
// about where you were or how much there was, and against a bordered child
|
|
79
|
+
// it was indistinguishable from another border. A scrollbar that cannot be
|
|
80
|
+
// told from a frame is not a scrollbar.
|
|
81
|
+
//
|
|
82
|
+
// And only when there is something to scroll. `limit` is zero when it all
|
|
83
|
+
// fits, which is exactly when a bar is a lie - the prop has always been
|
|
84
|
+
// documented that way and was drawn unconditionally.
|
|
85
|
+
scrollbar && limit > 0
|
|
86
|
+
? h(ScrollThumb, {
|
|
87
|
+
total: extent?.height ?? measured.height,
|
|
88
|
+
rows: measured.height,
|
|
89
|
+
offset: Math.min(top, limit),
|
|
90
|
+
focused: focus.focused,
|
|
91
|
+
})
|
|
92
|
+
: null);
|
|
93
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BoxProps, Dimension } from '@textui/core';
|
|
2
|
+
export interface SplitterProps extends BoxProps {
|
|
3
|
+
direction?: 'row' | 'column';
|
|
4
|
+
/** Size of the first pane, in cells or percent. */
|
|
5
|
+
size?: Dimension;
|
|
6
|
+
/** Cells the divider occupies. 0 hides it. */
|
|
7
|
+
dividerSize?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const Splitter: (props: SplitterProps) => import("@textui/core").RenderOutput;
|
|
10
|
+
//# sourceMappingURL=splitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitter.d.ts","sourceRoot":"","sources":["../../src/layout/splitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIxD,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC7B,mDAAmD;IACnD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,QAAQ,+DAWnB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineComponent, h } from '@textui/core';
|
|
2
|
+
import { Divider } from './divider.js';
|
|
3
|
+
export const Splitter = defineComponent('Splitter', (props) => {
|
|
4
|
+
const { direction = 'row', size = '50%', dividerSize = 1, children, ...rest } = props;
|
|
5
|
+
const panes = Array.isArray(children) ? children : [children];
|
|
6
|
+
return h('box', { direction, ...rest }, h('box', { [direction === 'row' ? 'width' : 'height']: size }, panes[0]), dividerSize > 0
|
|
7
|
+
? h(Divider, { direction: direction === 'row' ? 'vertical' : 'horizontal' })
|
|
8
|
+
: null, h('box', { flex: 1 }, panes[1]));
|
|
9
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BoxProps } from '@textui/core';
|
|
2
|
+
export interface StackProps extends BoxProps {
|
|
3
|
+
/** Space between children, from the theme's scale. */
|
|
4
|
+
spacing?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
5
|
+
}
|
|
6
|
+
export declare const Stack: (props: StackProps) => import("@textui/core").RenderOutput;
|
|
7
|
+
//# sourceMappingURL=stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../src/layout/stack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC1C,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CACrD;AAED,eAAO,MAAM,KAAK,4DAGhB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BoxProps } from '@textui/core';
|
|
2
|
+
export interface BreadcrumbProps extends BoxProps {
|
|
3
|
+
items: {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
}[];
|
|
8
|
+
onSelect?(id: string): void;
|
|
9
|
+
separator?: string;
|
|
10
|
+
/** Collapse the middle when it does not fit. */
|
|
11
|
+
maxItems?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const Breadcrumb: (props: BreadcrumbProps) => import("@textui/core").RenderOutput;
|
|
14
|
+
//# sourceMappingURL=breadcrumb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumb.d.ts","sourceRoot":"","sources":["../../src/navigation/breadcrumb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,QAAQ,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,iEA+BrB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineComponent, h, useTheme } from '@textui/core';
|
|
2
|
+
export const Breadcrumb = defineComponent('Breadcrumb', (props) => {
|
|
3
|
+
const theme = useTheme();
|
|
4
|
+
const { items, onSelect, separator, maxItems, ...rest } = props;
|
|
5
|
+
const sep = separator ?? theme.glyphs.breadcrumb;
|
|
6
|
+
const shown = maxItems && items.length > maxItems
|
|
7
|
+
? [
|
|
8
|
+
items[0],
|
|
9
|
+
{ id: '__ellipsis__', label: theme.glyphs.ellipsis },
|
|
10
|
+
...items.slice(items.length - (maxItems - 2)),
|
|
11
|
+
]
|
|
12
|
+
: items;
|
|
13
|
+
return h('box', { role: 'navigation', direction: 'row', gap: 1, ...rest }, ...shown.flatMap((item, i) => {
|
|
14
|
+
const last = i === shown.length - 1;
|
|
15
|
+
const crumb = h('box', {
|
|
16
|
+
key: item.id,
|
|
17
|
+
direction: 'row',
|
|
18
|
+
gap: item.icon ? 1 : 0,
|
|
19
|
+
onClick: () => { if (item.id !== '__ellipsis__')
|
|
20
|
+
onSelect?.(item.id); },
|
|
21
|
+
}, item.icon ? h('text', { content: item.icon }) : null, h('text', { content: item.label, fg: last ? 'text' : 'muted', bold: last }));
|
|
22
|
+
return last ? [crumb] : [crumb, h('text', { key: `${item.id}-s`, content: sep, fg: 'subtle' })];
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentDefinition } from '@textui/core';
|
|
2
|
+
/**
|
|
3
|
+
* Navigation chrome.
|
|
4
|
+
*
|
|
5
|
+
* These are the components a shell is made of, which is why they all take
|
|
6
|
+
* their own items rather than reading a surface: the same `Tabs` serves a tab
|
|
7
|
+
* strip in a workbench and a segmented control inside a panel.
|
|
8
|
+
*/
|
|
9
|
+
export * from './breadcrumb.js';
|
|
10
|
+
export * from './key-hints.js';
|
|
11
|
+
export * from './menu.js';
|
|
12
|
+
export * from './status-bar.js';
|
|
13
|
+
export * from './tabs.js';
|
|
14
|
+
export * from './toolbar.js';
|
|
15
|
+
export * from './wizard.js';
|
|
16
|
+
export declare const NAVIGATION_COMPONENTS: ComponentDefinition[];
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AASxD;;;;;;GAMG;AACH,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,EAQtD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Breadcrumb } from './breadcrumb.js';
|
|
2
|
+
import { KeyHints } from './key-hints.js';
|
|
3
|
+
import { Menu } from './menu.js';
|
|
4
|
+
import { StatusBar } from './status-bar.js';
|
|
5
|
+
import { Tabs } from './tabs.js';
|
|
6
|
+
import { Toolbar } from './toolbar.js';
|
|
7
|
+
import { Wizard } from './wizard.js';
|
|
8
|
+
/**
|
|
9
|
+
* Navigation chrome.
|
|
10
|
+
*
|
|
11
|
+
* These are the components a shell is made of, which is why they all take
|
|
12
|
+
* their own items rather than reading a surface: the same `Tabs` serves a tab
|
|
13
|
+
* strip in a workbench and a segmented control inside a panel.
|
|
14
|
+
*/
|
|
15
|
+
export * from './breadcrumb.js';
|
|
16
|
+
export * from './key-hints.js';
|
|
17
|
+
export * from './menu.js';
|
|
18
|
+
export * from './status-bar.js';
|
|
19
|
+
export * from './tabs.js';
|
|
20
|
+
export * from './toolbar.js';
|
|
21
|
+
export * from './wizard.js';
|
|
22
|
+
export const NAVIGATION_COMPONENTS = [
|
|
23
|
+
{ component: 'Tabs', category: 'navigation', renderer: { kind: 'function', render: Tabs }, role: 'tablist', variants: ['underline', 'solid', 'plain'], description: 'Tab strip or segmented control.' },
|
|
24
|
+
{ component: 'Breadcrumb', category: 'navigation', renderer: { kind: 'function', render: Breadcrumb }, role: 'navigation', description: 'Where you are, collapsing in the middle when narrow.' },
|
|
25
|
+
{ component: 'Menu', category: 'navigation', renderer: { kind: 'function', render: Menu }, role: 'menu', description: 'Keyboard-driven list of actions.' },
|
|
26
|
+
{ component: 'StatusBar', category: 'chrome', renderer: { kind: 'function', render: StatusBar }, role: 'contentinfo', description: 'One line, segments left and right.' },
|
|
27
|
+
{ component: 'Toolbar', category: 'chrome', renderer: { kind: 'function', render: Toolbar }, role: 'toolbar', description: 'A row of actions.' },
|
|
28
|
+
{ component: 'KeyHints', category: 'chrome', renderer: { kind: 'function', render: KeyHints }, description: 'What the keys do, right now.' },
|
|
29
|
+
{ component: 'Wizard', category: 'navigation', renderer: { kind: 'function', render: Wizard }, description: 'Ordered steps with progress.' },
|
|
30
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BoxProps } from '@textui/core';
|
|
2
|
+
export interface KeyHintsProps extends BoxProps {
|
|
3
|
+
hints: {
|
|
4
|
+
keys: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
7
|
+
separator?: string;
|
|
8
|
+
}
|
|
9
|
+
/** The footer line every TUI needs: what the keys do, right now. */
|
|
10
|
+
export declare const KeyHints: (props: KeyHintsProps) => import("@textui/core").RenderOutput;
|
|
11
|
+
//# sourceMappingURL=key-hints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-hints.d.ts","sourceRoot":"","sources":["../../src/navigation/key-hints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oEAAoE;AACpE,eAAO,MAAM,QAAQ,+DAenB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineComponent, h, useTheme } from '@textui/core';
|
|
2
|
+
/** The footer line every TUI needs: what the keys do, right now. */
|
|
3
|
+
export const KeyHints = defineComponent('KeyHints', (props) => {
|
|
4
|
+
const theme = useTheme();
|
|
5
|
+
const { hints, separator, ...rest } = props;
|
|
6
|
+
const sep = separator ?? ` ${theme.glyphs.separator} `;
|
|
7
|
+
return h('box', { direction: 'row', height: 1, ...rest }, ...hints.flatMap((hint, i) => {
|
|
8
|
+
const item = h('box', { key: hint.keys, direction: 'row', gap: 1 }, h('text', { content: hint.keys, fg: 'accent', bold: true }), h('text', { content: hint.label, fg: 'muted' }));
|
|
9
|
+
return i === hints.length - 1
|
|
10
|
+
? [item]
|
|
11
|
+
: [item, h('text', { key: `${hint.keys}-s`, content: sep, fg: 'subtle' })];
|
|
12
|
+
}));
|
|
13
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BoxProps, SemanticVariant } from '@textui/core';
|
|
2
|
+
export interface MenuItem {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
/** Keyboard hint shown right-aligned. */
|
|
7
|
+
shortcut?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
tone?: SemanticVariant;
|
|
11
|
+
separatorBefore?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* A switch, and whether it is on. Absent means the row is not a switch, so
|
|
14
|
+
* a menu of ordinary commands keeps its left edge rather than indenting
|
|
15
|
+
* every label to make room for a mark nothing uses.
|
|
16
|
+
*/
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
children?: MenuItem[];
|
|
19
|
+
}
|
|
20
|
+
export interface MenuProps extends BoxProps {
|
|
21
|
+
items: MenuItem[];
|
|
22
|
+
onSelect?(id: string, item: MenuItem): void;
|
|
23
|
+
/** Rows shown at once. */
|
|
24
|
+
visibleRows?: number;
|
|
25
|
+
activeId?: string;
|
|
26
|
+
autoFocus?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Take focus and handle keys. Off when something else drives the selection -
|
|
29
|
+
* a command palette, where typing belongs to the search field and the list
|
|
30
|
+
* only follows.
|
|
31
|
+
*/
|
|
32
|
+
interactive?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare const Menu: (props: MenuProps) => import("@textui/core").RenderOutput;
|
|
35
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/navigation/menu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK9D,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,QAAQ,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5C,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,IAAI,2DA8Ff,CAAC"}
|