termcast 1.3.48 → 1.3.49
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/dist/build.d.ts.map +1 -1
- package/dist/build.js +12 -0
- package/dist/build.js.map +1 -1
- package/dist/cli.js +5 -40
- package/dist/cli.js.map +1 -1
- package/dist/colors.d.ts +7 -7
- package/dist/colors.js +7 -7
- package/dist/compile.d.ts +6 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +45 -26
- package/dist/compile.js.map +1 -1
- package/dist/components/actions.js +1 -1
- package/dist/components/actions.js.map +1 -1
- package/dist/components/bar-chart.d.ts +38 -0
- package/dist/components/bar-chart.d.ts.map +1 -0
- package/dist/components/bar-chart.js +158 -0
- package/dist/components/bar-chart.js.map +1 -0
- package/dist/components/bar-graph.d.ts +41 -0
- package/dist/components/bar-graph.d.ts.map +1 -0
- package/dist/components/bar-graph.js +95 -0
- package/dist/components/bar-graph.js.map +1 -0
- package/dist/components/detail.d.ts.map +1 -1
- package/dist/components/detail.js +5 -7
- package/dist/components/detail.js.map +1 -1
- package/dist/components/footer.d.ts.map +1 -1
- package/dist/components/footer.js +8 -9
- package/dist/components/footer.js.map +1 -1
- package/dist/components/form/date-picker.d.ts.map +1 -1
- package/dist/components/form/date-picker.js +7 -1
- package/dist/components/form/date-picker.js.map +1 -1
- package/dist/components/form/dropdown.d.ts.map +1 -1
- package/dist/components/form/dropdown.js +10 -2
- package/dist/components/form/dropdown.js.map +1 -1
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/index.js +4 -5
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/form/use-form-navigation.d.ts.map +1 -1
- package/dist/components/form/use-form-navigation.js +6 -0
- package/dist/components/form/use-form-navigation.js.map +1 -1
- package/dist/components/graph.d.ts +111 -0
- package/dist/components/graph.d.ts.map +1 -0
- package/dist/components/graph.js +392 -0
- package/dist/components/graph.js.map +1 -0
- package/dist/components/icon.js +5 -5
- package/dist/components/icon.js.map +1 -1
- package/dist/components/list.d.ts +53 -5
- package/dist/components/list.d.ts.map +1 -1
- package/dist/components/list.js +125 -71
- package/dist/components/list.js.map +1 -1
- package/dist/components/loading-bar.js +3 -3
- package/dist/components/loading-bar.js.map +1 -1
- package/dist/components/loading-text.d.ts +1 -1
- package/dist/components/loading-text.d.ts.map +1 -1
- package/dist/components/loading-text.js +3 -1
- package/dist/components/loading-text.js.map +1 -1
- package/dist/components/metadata.js +2 -2
- package/dist/components/metadata.js.map +1 -1
- package/dist/components/row.d.ts +10 -0
- package/dist/components/row.d.ts.map +1 -0
- package/dist/components/row.js +12 -0
- package/dist/components/row.js.map +1 -0
- package/dist/components/table.d.ts +57 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +365 -0
- package/dist/components/table.js.map +1 -0
- package/dist/descendants.js +13 -13
- package/dist/descendants.js.map +1 -1
- package/dist/examples/bar-graph-weekly.d.ts +2 -0
- package/dist/examples/bar-graph-weekly.d.ts.map +1 -0
- package/dist/examples/bar-graph-weekly.js +95 -0
- package/dist/examples/bar-graph-weekly.js.map +1 -0
- package/dist/examples/components-weird-places.d.ts +2 -0
- package/dist/examples/components-weird-places.d.ts.map +1 -0
- package/dist/examples/components-weird-places.js +46 -0
- package/dist/examples/components-weird-places.js.map +1 -0
- package/dist/examples/graph-bar-chart.d.ts +2 -0
- package/dist/examples/graph-bar-chart.d.ts.map +1 -0
- package/dist/examples/graph-bar-chart.js +270 -0
- package/dist/examples/graph-bar-chart.js.map +1 -0
- package/dist/examples/graph-multi-series.d.ts +2 -0
- package/dist/examples/graph-multi-series.d.ts.map +1 -0
- package/dist/examples/graph-multi-series.js +23 -0
- package/dist/examples/graph-multi-series.js.map +1 -0
- package/dist/examples/graph-polymarket.d.ts +2 -0
- package/dist/examples/graph-polymarket.d.ts.map +1 -0
- package/dist/examples/graph-polymarket.js +109 -0
- package/dist/examples/graph-polymarket.js.map +1 -0
- package/dist/examples/graph-row.d.ts +2 -0
- package/dist/examples/graph-row.d.ts.map +1 -0
- package/dist/examples/graph-row.js +226 -0
- package/dist/examples/graph-row.js.map +1 -0
- package/dist/examples/graph-styles.d.ts +2 -0
- package/dist/examples/graph-styles.d.ts.map +1 -0
- package/dist/examples/graph-styles.js +316 -0
- package/dist/examples/graph-styles.js.map +1 -0
- package/dist/examples/list-accessory-table.d.ts +2 -0
- package/dist/examples/list-accessory-table.d.ts.map +1 -0
- package/dist/examples/list-accessory-table.js +46 -0
- package/dist/examples/list-accessory-table.js.map +1 -0
- package/dist/examples/list-item-accessories.d.ts +2 -0
- package/dist/examples/list-item-accessories.d.ts.map +1 -0
- package/dist/examples/list-item-accessories.js +27 -0
- package/dist/examples/list-item-accessories.js.map +1 -0
- package/dist/examples/list-no-actions.d.ts +2 -0
- package/dist/examples/list-no-actions.d.ts.map +1 -0
- package/dist/examples/list-no-actions.js +7 -0
- package/dist/examples/list-no-actions.js.map +1 -0
- package/dist/examples/simple-detail-table.d.ts +2 -0
- package/dist/examples/simple-detail-table.d.ts.map +1 -0
- package/dist/examples/simple-detail-table.js +45 -0
- package/dist/examples/simple-detail-table.js.map +1 -0
- package/dist/examples/simple-graph.d.ts +2 -0
- package/dist/examples/simple-graph.d.ts.map +1 -0
- package/dist/examples/simple-graph.js +32 -0
- package/dist/examples/simple-graph.js.map +1 -0
- package/dist/examples/simple-table-wrap.d.ts +2 -0
- package/dist/examples/simple-table-wrap.d.ts.map +1 -0
- package/dist/examples/simple-table-wrap.js +37 -0
- package/dist/examples/simple-table-wrap.js.map +1 -0
- package/dist/examples/table-edge-cases.d.ts +2 -0
- package/dist/examples/table-edge-cases.d.ts.map +1 -0
- package/dist/examples/table-edge-cases.js +70 -0
- package/dist/examples/table-edge-cases.js.map +1 -0
- package/dist/examples/table-flex-grow.d.ts +2 -0
- package/dist/examples/table-flex-grow.d.ts.map +1 -0
- package/dist/examples/table-flex-grow.js +18 -0
- package/dist/examples/table-flex-grow.js.map +1 -0
- package/dist/extensions/dev.d.ts.map +1 -1
- package/dist/extensions/dev.js +5 -1
- package/dist/extensions/dev.js.map +1 -1
- package/dist/globals.d.ts +1 -0
- package/dist/globals.d.ts.map +1 -1
- package/dist/globals.js +2 -0
- package/dist/globals.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/date-picker-widget.d.ts.map +1 -1
- package/dist/internal/date-picker-widget.js +4 -0
- package/dist/internal/date-picker-widget.js.map +1 -1
- package/dist/internal/providers.d.ts.map +1 -1
- package/dist/internal/providers.js +1 -3
- package/dist/internal/providers.js.map +1 -1
- package/dist/markdown-utils.d.ts +22 -1
- package/dist/markdown-utils.d.ts.map +1 -1
- package/dist/markdown-utils.js +66 -1
- package/dist/markdown-utils.js.map +1 -1
- package/dist/opentui.d.ts +4 -0
- package/dist/opentui.d.ts.map +1 -0
- package/dist/opentui.js +3 -0
- package/dist/opentui.js.map +1 -0
- package/dist/release.d.ts +2 -1
- package/dist/release.d.ts.map +1 -1
- package/dist/release.js +2 -1
- package/dist/release.js.map +1 -1
- package/dist/state.d.ts +1 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +1 -1
- package/dist/state.js.map +1 -1
- package/dist/theme.d.ts +1 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +13 -0
- package/dist/theme.js.map +1 -1
- package/dist/themes/nerv.json +227 -0
- package/dist/themes/termcast.json +72 -71
- package/dist/themes.d.ts +2 -1
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +7 -5
- package/dist/themes.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -0
- package/dist/utils.js.map +1 -1
- package/package.json +12 -4
- package/src/build.tsx +13 -0
- package/src/cli.tsx +5 -49
- package/src/colors.tsx +7 -7
- package/src/compile.tsx +52 -29
- package/src/components/actions.tsx +1 -1
- package/src/components/bar-chart.tsx +271 -0
- package/src/components/bar-graph.tsx +214 -0
- package/src/components/detail.tsx +7 -8
- package/src/components/footer.tsx +14 -15
- package/src/components/form/date-picker.tsx +9 -0
- package/src/components/form/dropdown.tsx +13 -3
- package/src/components/form/index.tsx +4 -6
- package/src/components/form/use-form-navigation.tsx +6 -0
- package/src/components/graph.tsx +506 -0
- package/src/components/icon.tsx +5 -5
- package/src/components/list.tsx +210 -102
- package/src/components/loading-bar.tsx +3 -3
- package/src/components/loading-text.tsx +4 -2
- package/src/components/metadata.tsx +2 -2
- package/src/components/row.tsx +31 -0
- package/src/components/table.tsx +511 -0
- package/src/descendants.tsx +13 -13
- package/src/examples/action-shortcut.vitest.tsx +1 -1
- package/src/examples/actions-context.vitest.tsx +1 -1
- package/src/examples/bar-graph-weekly.tsx +264 -0
- package/src/examples/bar-graph-weekly.vitest.tsx +275 -0
- package/src/examples/detail-metadata-showcase.vitest.tsx +8 -8
- package/src/examples/form-basic.vitest.tsx +239 -0
- package/src/examples/form-dropdown.vitest.tsx +29 -29
- package/src/examples/form-tagpicker.vitest.tsx +27 -27
- package/src/examples/github.vitest.tsx +4 -4
- package/src/examples/graph-bar-chart.tsx +408 -0
- package/src/examples/graph-bar-chart.vitest.tsx +283 -0
- package/src/examples/graph-multi-series.tsx +36 -0
- package/src/examples/graph-multi-series.vitest.tsx +89 -0
- package/src/examples/graph-polymarket.tsx +182 -0
- package/src/examples/graph-polymarket.vitest.tsx +130 -0
- package/src/examples/graph-row.tsx +347 -0
- package/src/examples/graph-row.vitest.tsx +295 -0
- package/src/examples/graph-styles.tsx +457 -0
- package/src/examples/graph-styles.vitest.tsx +322 -0
- package/src/examples/list-accessory-table.tsx +77 -0
- package/src/examples/list-detail-metadata.vitest.tsx +21 -21
- package/src/examples/list-dropdown-default.vitest.tsx +12 -12
- package/src/examples/list-item-accessories.tsx +106 -0
- package/src/examples/list-item-accessories.vitest.tsx +115 -0
- package/src/examples/list-no-actions.tsx +18 -0
- package/src/examples/list-no-actions.vitest.tsx +97 -0
- package/src/examples/list-spacing-mode.vitest.tsx +6 -6
- package/src/examples/list-with-detail.vitest.tsx +92 -92
- package/src/examples/list-with-dropdown.vitest.tsx +49 -6
- package/src/examples/list-with-sections.vitest.tsx +61 -56
- package/src/examples/simple-detail-markdown.vitest.tsx +21 -17
- package/src/examples/simple-detail-table.tsx +65 -0
- package/src/examples/simple-detail-table.vitest.tsx +200 -0
- package/src/examples/simple-graph.tsx +51 -0
- package/src/examples/simple-graph.vitest.tsx +124 -0
- package/src/examples/simple-grid.vitest.tsx +3 -3
- package/src/examples/simple-list-search.vitest.tsx +65 -0
- package/src/examples/simple-navigation.vitest.tsx +3 -3
- package/src/examples/simple-table-wrap.tsx +55 -0
- package/src/examples/simple-table-wrap.vitest.tsx +91 -0
- package/src/examples/store.vitest.tsx +1 -1
- package/src/examples/table-edge-cases.tsx +72 -0
- package/src/examples/table-edge-cases.vitest.tsx +307 -0
- package/src/examples/table-flex-grow.tsx +53 -0
- package/src/examples/table-flex-grow.vitest.tsx +124 -0
- package/src/extensions/dev.tsx +7 -1
- package/src/globals.ts +3 -0
- package/src/index.tsx +31 -0
- package/src/internal/date-picker-widget.tsx +4 -0
- package/src/internal/providers.tsx +1 -4
- package/src/markdown-utils.tsx +82 -1
- package/src/opentui.tsx +5 -0
- package/src/release.tsx +3 -0
- package/src/state.tsx +2 -1
- package/src/theme.tsx +14 -0
- package/src/themes/nerv.json +231 -0
- package/src/themes/termcast.json +75 -71
- package/src/themes.ts +8 -5
- package/src/utils.tsx +4 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: List.Item with all inline display features.
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates every property that renders inline in a list row:
|
|
5
|
+
* - icon (emoji before title)
|
|
6
|
+
* - title (main text)
|
|
7
|
+
* - subtitle (muted text after title)
|
|
8
|
+
* - accessories: text, text with color, tag, tag with color, date, date with color, icon+text combo
|
|
9
|
+
*/
|
|
10
|
+
import { renderWithProviders, Icon, Color } from 'termcast'
|
|
11
|
+
import List from 'termcast'
|
|
12
|
+
|
|
13
|
+
function ListItemAccessoriesExample() {
|
|
14
|
+
const yesterday = new Date(Date.now() - 86400_000)
|
|
15
|
+
const lastWeek = new Date(Date.now() - 7 * 86400_000)
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<List navigationTitle="List Item Accessories">
|
|
19
|
+
{/* 1. Title only */}
|
|
20
|
+
<List.Item id="title-only" title="Title Only" />
|
|
21
|
+
|
|
22
|
+
{/* 2. Title + subtitle */}
|
|
23
|
+
<List.Item id="with-subtitle" title="With Subtitle" subtitle="a subtitle" />
|
|
24
|
+
|
|
25
|
+
{/* 3. Icon + title */}
|
|
26
|
+
<List.Item id="with-icon" title="With Icon" icon={Icon.Star} />
|
|
27
|
+
|
|
28
|
+
{/* 4. Icon + title + subtitle */}
|
|
29
|
+
<List.Item
|
|
30
|
+
id="icon-subtitle"
|
|
31
|
+
title="Icon and Subtitle"
|
|
32
|
+
subtitle="description"
|
|
33
|
+
icon={Icon.Bookmark}
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
{/* 5. Text accessory (plain string) */}
|
|
37
|
+
<List.Item
|
|
38
|
+
id="text-accessory"
|
|
39
|
+
title="Text Accessory"
|
|
40
|
+
accessories={[{ text: 'info' }]}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
{/* 6. Text accessory with color */}
|
|
44
|
+
<List.Item
|
|
45
|
+
id="colored-text"
|
|
46
|
+
title="Colored Text"
|
|
47
|
+
accessories={[{ text: { value: 'orange', color: Color.Orange } }]}
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
{/* 7. Tag accessory (plain string) */}
|
|
51
|
+
<List.Item
|
|
52
|
+
id="tag-accessory"
|
|
53
|
+
title="Tag Accessory"
|
|
54
|
+
accessories={[{ tag: 'beta' }]}
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
{/* 8. Tag accessory with color */}
|
|
58
|
+
<List.Item
|
|
59
|
+
id="colored-tag"
|
|
60
|
+
title="Colored Tag"
|
|
61
|
+
accessories={[{ tag: { value: 'v2', color: Color.Green } }]}
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
{/* 9. Date accessory */}
|
|
65
|
+
<List.Item
|
|
66
|
+
id="date-accessory"
|
|
67
|
+
title="Date Accessory"
|
|
68
|
+
accessories={[{ date: yesterday }]}
|
|
69
|
+
/>
|
|
70
|
+
|
|
71
|
+
{/* 10. Date accessory with color */}
|
|
72
|
+
<List.Item
|
|
73
|
+
id="colored-date"
|
|
74
|
+
title="Colored Date"
|
|
75
|
+
accessories={[{ date: { value: lastWeek, color: Color.Purple } }]}
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
{/* 11. Multiple accessories combined */}
|
|
79
|
+
<List.Item
|
|
80
|
+
id="multiple"
|
|
81
|
+
title="Multiple Accessories"
|
|
82
|
+
subtitle="all types"
|
|
83
|
+
icon={Icon.Hammer}
|
|
84
|
+
accessories={[
|
|
85
|
+
{ text: 'note' },
|
|
86
|
+
{ tag: 'new' },
|
|
87
|
+
{ date: yesterday },
|
|
88
|
+
]}
|
|
89
|
+
/>
|
|
90
|
+
|
|
91
|
+
{/* 12. All colored accessories */}
|
|
92
|
+
<List.Item
|
|
93
|
+
id="all-colored"
|
|
94
|
+
title="All Colored"
|
|
95
|
+
icon={Icon.CircleFilled}
|
|
96
|
+
accessories={[
|
|
97
|
+
{ text: { value: 'red', color: Color.Red } },
|
|
98
|
+
{ tag: { value: 'blue', color: Color.Blue } },
|
|
99
|
+
{ date: { value: lastWeek, color: Color.Magenta } },
|
|
100
|
+
]}
|
|
101
|
+
/>
|
|
102
|
+
</List>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
await renderWithProviders(<ListItemAccessoriesExample />)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { test, expect, afterEach, beforeEach } from 'vitest'
|
|
2
|
+
import { launchTerminal, Session } from 'tuistory/src'
|
|
3
|
+
|
|
4
|
+
let session: Session
|
|
5
|
+
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
session = await launchTerminal({
|
|
8
|
+
command: 'bun',
|
|
9
|
+
args: ['src/examples/list-item-accessories.tsx'],
|
|
10
|
+
cols: 80,
|
|
11
|
+
rows: 25,
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
session?.close()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('shows all inline item features: icon, title, subtitle, text/tag/date accessories', async () => {
|
|
20
|
+
await session.text({
|
|
21
|
+
waitFor: (text) => {
|
|
22
|
+
return /Title Only/.test(text)
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const snapshot = await session.text()
|
|
27
|
+
expect(snapshot).toMatchInlineSnapshot(`
|
|
28
|
+
"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
List Item Accessories ────────────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
> Search...
|
|
34
|
+
|
|
35
|
+
›Title Only
|
|
36
|
+
With Subtitle a subtitle
|
|
37
|
+
★ With Icon
|
|
38
|
+
▷ Icon and Subtitle description
|
|
39
|
+
Text Accessory info
|
|
40
|
+
Colored Text orange
|
|
41
|
+
Tag Accessory beta
|
|
42
|
+
Colored Tag v2
|
|
43
|
+
Date Accessory 1d
|
|
44
|
+
Colored Date 1w
|
|
45
|
+
⊤ Multiple Accessories all types note new 1d
|
|
46
|
+
● All Colored red blue 1w
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
↑↓ navigate ^k actions powered by termcast.app
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
"
|
|
54
|
+
`)
|
|
55
|
+
|
|
56
|
+
// title-only item
|
|
57
|
+
expect(snapshot).toContain('Title Only')
|
|
58
|
+
// subtitle
|
|
59
|
+
expect(snapshot).toContain('a subtitle')
|
|
60
|
+
// text accessory
|
|
61
|
+
expect(snapshot).toContain('info')
|
|
62
|
+
// tag accessory
|
|
63
|
+
expect(snapshot).toContain('beta')
|
|
64
|
+
// colored tag
|
|
65
|
+
expect(snapshot).toContain('v2')
|
|
66
|
+
// date accessory renders relative time
|
|
67
|
+
expect(snapshot).toContain('1d')
|
|
68
|
+
// multiple accessories on one row
|
|
69
|
+
expect(snapshot).toContain('note')
|
|
70
|
+
expect(snapshot).toContain('new')
|
|
71
|
+
}, 15000)
|
|
72
|
+
|
|
73
|
+
test('navigation through all item types', async () => {
|
|
74
|
+
await session.text({
|
|
75
|
+
waitFor: (text) => {
|
|
76
|
+
return /Title Only/.test(text)
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
// Navigate to "With Icon" (3rd item)
|
|
81
|
+
await session.press('down')
|
|
82
|
+
await session.press('down')
|
|
83
|
+
|
|
84
|
+
const afterNav = await session.text()
|
|
85
|
+
expect(afterNav).toMatchInlineSnapshot(`
|
|
86
|
+
"
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
List Item Accessories ────────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
> Search...
|
|
92
|
+
|
|
93
|
+
Title Only
|
|
94
|
+
With Subtitle a subtitle
|
|
95
|
+
›★ With Icon
|
|
96
|
+
▷ Icon and Subtitle description
|
|
97
|
+
Text Accessory info
|
|
98
|
+
Colored Text orange
|
|
99
|
+
Tag Accessory beta
|
|
100
|
+
Colored Tag v2
|
|
101
|
+
Date Accessory 1d
|
|
102
|
+
Colored Date 1w
|
|
103
|
+
⊤ Multiple Accessories all types note new 1d
|
|
104
|
+
● All Colored red blue 1w
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
↑↓ navigate ^k actions powered by termcast.app
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
"
|
|
112
|
+
`)
|
|
113
|
+
// Icon item should be selected
|
|
114
|
+
expect(afterNav).toContain('›')
|
|
115
|
+
}, 15000)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: List with items that have no actions prop.
|
|
3
|
+
* Tests that ctrl+k still opens the built-in action panel (Change Theme, etc.)
|
|
4
|
+
* even when no extension-provided actions exist.
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react'
|
|
7
|
+
import { List, renderWithProviders } from 'termcast'
|
|
8
|
+
|
|
9
|
+
function ListNoActionsExample() {
|
|
10
|
+
return (
|
|
11
|
+
<List navigationTitle="No Actions Test">
|
|
12
|
+
<List.Item title="Item without actions" subtitle="Press ctrl+k" />
|
|
13
|
+
<List.Item title="Another item" subtitle="Also no actions" />
|
|
14
|
+
</List>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
await renderWithProviders(<ListNoActionsExample />)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2E tests for ctrl+k with no extension-provided actions.
|
|
3
|
+
* Verifies that the built-in action panel (Change Theme, Toggle Console Logs)
|
|
4
|
+
* is always accessible via ctrl+k, even when items have no actions prop.
|
|
5
|
+
*/
|
|
6
|
+
import { test, expect, afterEach, beforeEach } from 'vitest'
|
|
7
|
+
import { launchTerminal, Session } from 'tuistory/src'
|
|
8
|
+
|
|
9
|
+
let session: Session
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
session = await launchTerminal({
|
|
13
|
+
command: 'bun',
|
|
14
|
+
args: ['src/examples/list-no-actions.tsx'],
|
|
15
|
+
cols: 70,
|
|
16
|
+
rows: 20,
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
session?.close()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test('footer does not show stale action title from built-in actions', async () => {
|
|
25
|
+
const initial = await session.text({
|
|
26
|
+
waitFor: (text) => /Item without actions/.test(text),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// Footer should show ^k actions but NOT "↵ change theme..." — the useLayoutEffect
|
|
30
|
+
// in CurrentItemActionsOffscreen clears firstActionTitle for items without actions
|
|
31
|
+
expect(initial).toContain('^k')
|
|
32
|
+
expect(initial).not.toContain('change theme')
|
|
33
|
+
expect(initial).toMatchInlineSnapshot(`
|
|
34
|
+
"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
No Actions Test ────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
> Search...
|
|
40
|
+
|
|
41
|
+
›Item without actions Press ctrl+k
|
|
42
|
+
Another item Also no actions
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
↑↓ navigate ^k actions
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
"
|
|
55
|
+
`)
|
|
56
|
+
}, 30000)
|
|
57
|
+
|
|
58
|
+
test('ctrl+k opens built-in actions when item has no actions', async () => {
|
|
59
|
+
await session.text({
|
|
60
|
+
waitFor: (text) => /Item without actions/.test(text),
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// Press ctrl+k to open action panel
|
|
64
|
+
await session.press(['ctrl', 'k'])
|
|
65
|
+
|
|
66
|
+
const actionsPanel = await session.text({
|
|
67
|
+
waitFor: (text) => /Change Theme/.test(text),
|
|
68
|
+
timeout: 5000,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// Built-in actions should appear
|
|
72
|
+
expect(actionsPanel).toContain('Change Theme')
|
|
73
|
+
expect(actionsPanel).toContain('Console Logs')
|
|
74
|
+
expect(actionsPanel).toMatchInlineSnapshot(`
|
|
75
|
+
"
|
|
76
|
+
|
|
77
|
+
╭────────────────────────────────────────────────────────────────╮
|
|
78
|
+
│ │
|
|
79
|
+
│ Actions esc │
|
|
80
|
+
│ │
|
|
81
|
+
│ > Search actions... │
|
|
82
|
+
│ │
|
|
83
|
+
│ │
|
|
84
|
+
│ Settings │
|
|
85
|
+
│ ›Change Theme... │
|
|
86
|
+
│ Toggle Console Logs │
|
|
87
|
+
│ │
|
|
88
|
+
│ │
|
|
89
|
+
│ │
|
|
90
|
+
│ │
|
|
91
|
+
│ │
|
|
92
|
+
│ │
|
|
93
|
+
│ │
|
|
94
|
+
│ ↵ select ↑↓ navigate │
|
|
95
|
+
│ │"
|
|
96
|
+
`)
|
|
97
|
+
}, 30000)
|
|
@@ -39,11 +39,11 @@ describe('spacingMode default', () => {
|
|
|
39
39
|
> Search...
|
|
40
40
|
|
|
41
41
|
With Icons
|
|
42
|
-
›▯ Report Q4 financial summary
|
|
42
|
+
›▯ Report Q4 financial summary Draft
|
|
43
43
|
⟨⟩ API Docs REST endpoints guide v2.1
|
|
44
44
|
|
|
45
45
|
Without Icons
|
|
46
|
-
Meeting Notes Weekly standup points
|
|
46
|
+
Meeting Notes Weekly standup points Important
|
|
47
47
|
|
|
48
48
|
No Subtitle
|
|
49
49
|
★ Favorites
|
|
@@ -91,7 +91,7 @@ describe('spacingMode relaxed', () => {
|
|
|
91
91
|
> Search...
|
|
92
92
|
|
|
93
93
|
With Icons
|
|
94
|
-
›▯ Report
|
|
94
|
+
›▯ Report Draft
|
|
95
95
|
Q4 financial summary
|
|
96
96
|
|
|
97
97
|
⟨⟩ API Docs v2.1
|
|
@@ -99,7 +99,7 @@ describe('spacingMode relaxed', () => {
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
Without Icons
|
|
102
|
-
Meeting Notes
|
|
102
|
+
Meeting Notes Important
|
|
103
103
|
Weekly standup points
|
|
104
104
|
|
|
105
105
|
|
|
@@ -132,7 +132,7 @@ describe('spacingMode relaxed', () => {
|
|
|
132
132
|
> Search...
|
|
133
133
|
|
|
134
134
|
With Icons
|
|
135
|
-
▯ Report
|
|
135
|
+
▯ Report Draft
|
|
136
136
|
Q4 financial summary
|
|
137
137
|
|
|
138
138
|
›⟨⟩ API Docs v2.1
|
|
@@ -140,7 +140,7 @@ describe('spacingMode relaxed', () => {
|
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
Without Icons
|
|
143
|
-
Meeting Notes
|
|
143
|
+
Meeting Notes Important
|
|
144
144
|
Weekly standup points
|
|
145
145
|
|
|
146
146
|
|