@textui/widgets 0.5.0 → 0.7.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/dist/chart/line-chart.d.ts.map +1 -1
- package/dist/chart/line-chart.js +3 -2
- package/dist/control/select.d.ts.map +1 -1
- package/dist/control/select.js +4 -2
- package/dist/control/switch.d.ts.map +1 -1
- package/dist/control/switch.js +7 -2
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +3 -2
- package/dist/data/list.d.ts.map +1 -1
- package/dist/data/list.js +3 -2
- package/dist/data/log-viewer.d.ts.map +1 -1
- package/dist/data/log-viewer.js +7 -2
- package/dist/data/markdown-view.d.ts.map +1 -1
- package/dist/data/markdown-view.js +3 -2
- package/dist/data/pagination.d.ts.map +1 -1
- package/dist/data/pagination.js +3 -2
- package/dist/display/error-state.d.ts.map +1 -1
- package/dist/display/error-state.js +4 -3
- package/dist/form/danger-zone.d.ts.map +1 -1
- package/dist/form/danger-zone.js +7 -3
- package/dist/form/form-actions.d.ts.map +1 -1
- package/dist/form/form-actions.js +3 -2
- package/dist/navigation/menu.d.ts.map +1 -1
- package/dist/navigation/menu.js +3 -2
- package/dist/overlay/command-palette.d.ts +0 -14
- package/dist/overlay/command-palette.d.ts.map +1 -1
- package/dist/overlay/command-palette.js +127 -38
- package/dist/overlay/dialog.d.ts +11 -0
- package/dist/overlay/dialog.d.ts.map +1 -1
- package/dist/overlay/dialog.js +24 -1
- package/dist/overlay/index.d.ts.map +1 -1
- package/dist/overlay/index.js +11 -19
- package/dist/overlay/path-picker.d.ts.map +1 -1
- package/dist/overlay/path-picker.js +19 -11
- package/dist/overlay/prompt-dialog.d.ts.map +1 -1
- package/dist/overlay/prompt-dialog.js +5 -4
- package/dist/panel/index.d.ts.map +1 -1
- package/dist/panel/index.js +8 -7
- package/dist/panel/resource-panel.d.ts.map +1 -1
- package/dist/panel/resource-panel.js +9 -5
- package/dist/surface/mount-view.d.ts.map +1 -1
- package/dist/surface/mount-view.js +3 -2
- package/package.json +2 -2
- package/src/chart/line-chart.ts +3 -2
- package/src/control/select.ts +4 -2
- package/src/control/switch.ts +9 -2
- package/src/data/index.ts +3 -1
- package/src/data/list.ts +3 -1
- package/src/data/log-viewer.ts +7 -1
- package/src/data/markdown-view.ts +7 -1
- package/src/data/pagination.ts +3 -2
- package/src/display/error-state.ts +4 -3
- package/src/form/danger-zone.ts +7 -3
- package/src/form/form-actions.ts +5 -2
- package/src/navigation/menu.ts +3 -2
- package/src/overlay/command-palette.ts +152 -29
- package/src/overlay/dialog.ts +37 -1
- package/src/overlay/index.ts +11 -19
- package/src/overlay/path-picker.ts +23 -10
- package/src/overlay/prompt-dialog.ts +5 -4
- package/src/panel/index.ts +9 -7
- package/src/panel/resource-panel.ts +9 -4
- package/src/surface/mount-view.ts +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, escapeSegment, h, useEffect, useFocusScope, useRef, useRuntime, useStoreValue, useTask, } from '@textui/core';
|
|
1
|
+
import { defineComponent, escapeSegment, h, useEffect, useFocusScope, useI18n, useRef, useRuntime, useStoreValue, useTask, } from '@textui/core';
|
|
2
2
|
import { EmptyState, ErrorState, Spinner } from '../display/index.js';
|
|
3
3
|
import { LOOSE, PanelContext } from './shared.js';
|
|
4
4
|
/** Every panel's remembered state. */
|
|
@@ -67,6 +67,7 @@ export function defaultRenderer(renderers) {
|
|
|
67
67
|
*/
|
|
68
68
|
export const ResourcePanel = defineComponent('ResourcePanel', (props) => {
|
|
69
69
|
const runtime = useRuntime();
|
|
70
|
+
const i18n = useI18n();
|
|
70
71
|
const { id: named, uri, renderer, mode, rendererProps, fallbackComponent, autoFocus, emptyTitle, ...rest } = props;
|
|
71
72
|
const app = runtime.app();
|
|
72
73
|
const scope = useFocusScope({
|
|
@@ -178,20 +179,23 @@ export const ResourcePanel = defineComponent('ResourcePanel', (props) => {
|
|
|
178
179
|
runtime.store.set(panelClaimPath(id), 0);
|
|
179
180
|
}, [id, claim, chosen?.id ?? null]);
|
|
180
181
|
if (!uri)
|
|
181
|
-
return h(EmptyState, { title: emptyTitle ?? 'Nothing selected', ...rest });
|
|
182
|
+
return h(EmptyState, { title: emptyTitle ?? i18n.t('textui.resourcePanel.empty', undefined, 'Nothing selected'), ...rest });
|
|
182
183
|
if (!app)
|
|
183
184
|
return null;
|
|
184
185
|
if (task.status === 'running' || task.status === 'idle') {
|
|
185
|
-
return h(Spinner, { label: 'Loading…', ...rest });
|
|
186
|
+
return h(Spinner, { label: i18n.t('textui.resourcePanel.loading', undefined, 'Loading…'), ...rest });
|
|
186
187
|
}
|
|
187
188
|
if (task.status === 'error')
|
|
188
189
|
return h(ErrorState, { error: task.error, ...rest });
|
|
189
190
|
if (!resource)
|
|
190
|
-
return h(EmptyState, { title: 'Not found', message: uri, ...rest });
|
|
191
|
+
return h(EmptyState, { title: i18n.t('textui.resourcePanel.notFound', undefined, 'Not found'), message: uri, ...rest });
|
|
191
192
|
if (!chosen) {
|
|
192
193
|
return h('box', { direction: 'column', flex: 1, id: scope, ...rest }, fallbackComponent
|
|
193
194
|
? { component: fallbackComponent, resource, uri }
|
|
194
|
-
: h(EmptyState, {
|
|
195
|
+
: h(EmptyState, {
|
|
196
|
+
title: i18n.t('textui.resourcePanel.noRenderer', undefined, 'No renderer'),
|
|
197
|
+
message: resource.kind,
|
|
198
|
+
}));
|
|
195
199
|
}
|
|
196
200
|
const node = {
|
|
197
201
|
component: chosen.component,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-view.d.ts","sourceRoot":"","sources":["../../src/surface/mount-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,QAAQ,EAAiB,KAAK,EAAE,MAAM,cAAc,CAAC;AAIhF,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,KAAK,EAAE,KAAK,CAAC;CACd;AAED,+EAA+E;AAC/E,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"mount-view.d.ts","sourceRoot":"","sources":["../../src/surface/mount-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,QAAQ,EAAiB,KAAK,EAAE,MAAM,cAAc,CAAC;AAIhF,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,KAAK,EAAE,KAAK,CAAC;CACd;AAED,+EAA+E;AAC/E,eAAO,MAAM,SAAS,gEAqBpB,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { defineComponent, h, useRuntime } from '@textui/core';
|
|
1
|
+
import { defineComponent, h, useI18n, useRuntime } from '@textui/core';
|
|
2
2
|
import { EmptyState } from '../display/index.js';
|
|
3
3
|
/** Renders one mount's target - an inline node, or a node read from a path. */
|
|
4
4
|
export const MountView = defineComponent('MountView', ({ mount, ...rest }) => {
|
|
5
5
|
const runtime = useRuntime();
|
|
6
|
+
const i18n = useI18n();
|
|
6
7
|
const target = mount.target;
|
|
7
8
|
const node = 'component' in target
|
|
8
9
|
? target
|
|
9
10
|
: (runtime.store.get(target.path) ?? null);
|
|
10
11
|
if (!node) {
|
|
11
|
-
return h(EmptyState, { title: 'Nothing mounted', ...rest });
|
|
12
|
+
return h(EmptyState, { title: i18n.t('textui.mountView.empty', undefined, 'Nothing mounted'), ...rest });
|
|
12
13
|
}
|
|
13
14
|
// A mount's data context makes relative paths inside it resolve against the
|
|
14
15
|
// record it was opened for.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textui/widgets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The TextUI component catalog - layout, display, controls, data, overlays and charts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"terminal",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"test": "vitest run"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@textui/core": "^0.
|
|
49
|
+
"@textui/core": "^0.7.0"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
package/src/chart/line-chart.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PaintSurface, RenderContext } from '@textui/core';
|
|
2
|
-
import { defineComponent, fitTo, h, stringWidth, useTheme } from '@textui/core';
|
|
2
|
+
import { defineComponent, fitTo, h, stringWidth, useI18n, useTheme } from '@textui/core';
|
|
3
3
|
import type { LineChartProps } from './shared.js';
|
|
4
4
|
import { TONE, bounds, resample } from './shared.js';
|
|
5
5
|
|
|
@@ -9,6 +9,7 @@ import { TONE, bounds, resample } from './shared.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export const LineChart = defineComponent<LineChartProps>('LineChart', (props) => {
|
|
11
11
|
const theme = useTheme();
|
|
12
|
+
const i18n = useI18n();
|
|
12
13
|
const {
|
|
13
14
|
series, min, max, chartWidth, chartHeight = 8,
|
|
14
15
|
axis = true, area = false, format, ...rest
|
|
@@ -83,7 +84,7 @@ export const LineChart = defineComponent<LineChartProps>('LineChart', (props) =>
|
|
|
83
84
|
...series.map((s, i) =>
|
|
84
85
|
h('box', { key: i, direction: 'row', gap: 1 },
|
|
85
86
|
h('text', { content: theme.glyphs.bulletFilled, fg: TONE[s.tone ?? (i === 0 ? 'accent' : 'secondary')] }),
|
|
86
|
-
h('text', { content: s.label ??
|
|
87
|
+
h('text', { content: s.label ?? i18n.t('textui.lineChart.series', { n: i + 1 }, 'series {n}'), fg: 'muted' }))))
|
|
87
88
|
: null,
|
|
88
89
|
);
|
|
89
90
|
});
|
package/src/control/select.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BoxProps, ComponentNode, RenderOutput } from '@textui/core';
|
|
2
2
|
import {
|
|
3
|
-
defineComponent, h, useApp, useEffect, useFocus, useInput, useMeasure, useState, useTheme,
|
|
3
|
+
defineComponent, h, useApp, useEffect, useFocus, useI18n, useInput, useMeasure, useState, useTheme,
|
|
4
4
|
} from '@textui/core';
|
|
5
5
|
|
|
6
6
|
export interface SelectOption {
|
|
@@ -46,6 +46,7 @@ export interface SelectProps extends BoxProps {
|
|
|
46
46
|
|
|
47
47
|
export const Select = defineComponent<SelectProps>('Select', (props) => {
|
|
48
48
|
const theme = useTheme();
|
|
49
|
+
const i18n = useI18n();
|
|
49
50
|
const {
|
|
50
51
|
options, value, onChange, label, placeholder,
|
|
51
52
|
open: openProp, visibleRows = 6, disabled, mode = 'inline', ...rest
|
|
@@ -54,7 +55,8 @@ export const Select = defineComponent<SelectProps>('Select', (props) => {
|
|
|
54
55
|
const app = useApp();
|
|
55
56
|
const focus = useFocus({ disabled });
|
|
56
57
|
const measured = useMeasure();
|
|
57
|
-
const empty = placeholder
|
|
58
|
+
const empty = placeholder
|
|
59
|
+
?? i18n.t('textui.select.placeholder', { ellipsis: theme.glyphs.ellipsis }, 'Select{ellipsis}');
|
|
58
60
|
const [open, setOpen] = useState(openProp ?? false);
|
|
59
61
|
const index = Math.max(0, options.findIndex((o) => o.value === value));
|
|
60
62
|
const [highlight, setHighlight] = useState(index);
|
package/src/control/switch.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoxProps } from '@textui/core';
|
|
2
|
-
import { defineComponent, h, useFocus, useInput } from '@textui/core';
|
|
2
|
+
import { defineComponent, h, useFocus, useI18n, useInput } from '@textui/core';
|
|
3
3
|
|
|
4
4
|
export interface SwitchProps extends BoxProps {
|
|
5
5
|
label?: string;
|
|
@@ -10,7 +10,14 @@ export interface SwitchProps extends BoxProps {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const Switch = defineComponent<SwitchProps>('Switch', (props) => {
|
|
13
|
-
const
|
|
13
|
+
const i18n = useI18n();
|
|
14
|
+
const {
|
|
15
|
+
label, value = false, onChange, disabled, ...rest
|
|
16
|
+
} = props;
|
|
17
|
+
const labels = props.labels ?? [
|
|
18
|
+
i18n.t('textui.switch.off', undefined, 'off'),
|
|
19
|
+
i18n.t('textui.switch.on', undefined, 'on'),
|
|
20
|
+
];
|
|
14
21
|
const focus = useFocus({ disabled });
|
|
15
22
|
|
|
16
23
|
useInput(
|
package/src/data/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
h,
|
|
7
7
|
stringWidth,
|
|
8
8
|
useFocus,
|
|
9
|
+
useI18n,
|
|
9
10
|
useInput,
|
|
10
11
|
useMeasure,
|
|
11
12
|
useState,
|
|
@@ -79,9 +80,10 @@ export interface TableProps<T extends object = Record<string, unknown>> extends
|
|
|
79
80
|
*/
|
|
80
81
|
const TableImpl = defineComponent<TableProps<Record<string, unknown>>>('Table', (props) => {
|
|
81
82
|
const theme = useTheme();
|
|
83
|
+
const i18n = useI18n();
|
|
82
84
|
const {
|
|
83
85
|
columns, rows, rowKey = 'id', selectedKey, onSelect, onActivate,
|
|
84
|
-
visibleRows, showHeader = true, emptyMessage = 'No rows',
|
|
86
|
+
visibleRows, showHeader = true, emptyMessage = i18n.t('textui.table.empty', undefined, 'No rows'),
|
|
85
87
|
focusable = true, responsive = true, width, ...rest
|
|
86
88
|
} = props;
|
|
87
89
|
|
package/src/data/list.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
defineComponent,
|
|
5
5
|
h,
|
|
6
6
|
useFocus,
|
|
7
|
+
useI18n,
|
|
7
8
|
useInput,
|
|
8
9
|
useMeasure,
|
|
9
10
|
useState,
|
|
@@ -98,9 +99,10 @@ export interface ListProps<T extends ListItem = ListItem> extends BoxProps {
|
|
|
98
99
|
|
|
99
100
|
function ListView<T extends ListItem>(props: ListProps<T>): RenderOutput {
|
|
100
101
|
const theme = useTheme();
|
|
102
|
+
const i18n = useI18n();
|
|
101
103
|
const {
|
|
102
104
|
items, selectedId, onSelect, onActivate, visibleRows,
|
|
103
|
-
emptyMessage = 'Nothing here', marker = true, focusable = true,
|
|
105
|
+
emptyMessage = i18n.t('textui.list.empty', undefined, 'Nothing here'), marker = true, focusable = true,
|
|
104
106
|
autoFocus, focusId, renderItem, itemHeight = 1, ...rest
|
|
105
107
|
} = props;
|
|
106
108
|
|
package/src/data/log-viewer.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
defineComponent,
|
|
5
5
|
h,
|
|
6
6
|
useFocus,
|
|
7
|
+
useI18n,
|
|
7
8
|
useInput,
|
|
8
9
|
useMeasure,
|
|
9
10
|
useState,
|
|
@@ -45,6 +46,7 @@ export const LogViewer = defineComponent<LogViewerProps>('LogViewer', (props) =>
|
|
|
45
46
|
lines, visibleRows: visibleRowsProp, follow: followProp, showTime = true,
|
|
46
47
|
showLevel = true, onFollowChange, ...rest
|
|
47
48
|
} = props;
|
|
49
|
+
const i18n = useI18n();
|
|
48
50
|
|
|
49
51
|
const focus = useFocus({});
|
|
50
52
|
const measured = useMeasure();
|
|
@@ -99,7 +101,11 @@ export const LogViewer = defineComponent<LogViewerProps>('LogViewer', (props) =>
|
|
|
99
101
|
h('text', { content: line.message, flex: 1, truncate: 'end' }),
|
|
100
102
|
)),
|
|
101
103
|
!follow
|
|
102
|
-
? h('text', {
|
|
104
|
+
? h('text', {
|
|
105
|
+
content: ` ${i18n.t('textui.logViewer.paused', undefined, 'paused - end to follow')}`,
|
|
106
|
+
fg: 'warning',
|
|
107
|
+
dim: true,
|
|
108
|
+
})
|
|
103
109
|
: null,
|
|
104
110
|
);
|
|
105
111
|
});
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
h,
|
|
5
5
|
layoutMarkdown,
|
|
6
6
|
repeatToWidth,
|
|
7
|
+
useI18n,
|
|
7
8
|
useMeasure,
|
|
8
9
|
useMemo,
|
|
9
10
|
useTheme,
|
|
@@ -52,6 +53,7 @@ export const MarkdownView = defineComponent<MarkdownViewProps>('MarkdownView', (
|
|
|
52
53
|
// a document with no search over it carries no extra prop per run.
|
|
53
54
|
const hit = match ? { match } : {};
|
|
54
55
|
const theme = useTheme();
|
|
56
|
+
const i18n = useI18n();
|
|
55
57
|
const measured = useMeasure();
|
|
56
58
|
const width = measured.width > 0 ? measured.width : 0;
|
|
57
59
|
const ruled = theme.border !== 'none';
|
|
@@ -221,7 +223,11 @@ export const MarkdownView = defineComponent<MarkdownViewProps>('MarkdownView', (
|
|
|
221
223
|
return h('box', { role: 'document', direction: 'column', ...rest },
|
|
222
224
|
...out,
|
|
223
225
|
hidden > 0
|
|
224
|
-
? h('text', { content:
|
|
226
|
+
? h('text', { content: i18n.t(
|
|
227
|
+
'textui.markdown.moreLines',
|
|
228
|
+
{ glyph: theme.glyphs.ellipsis, count: hidden },
|
|
229
|
+
'{glyph} {count} more lines',
|
|
230
|
+
), fg: 'subtle' })
|
|
225
231
|
: null,
|
|
226
232
|
);
|
|
227
233
|
});
|
package/src/data/pagination.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoxProps } from '@textui/core';
|
|
2
|
-
import { defineComponent, h, useFocus, useInput, useTheme } from '@textui/core';
|
|
2
|
+
import { defineComponent, h, useFocus, useI18n, useInput, useTheme } from '@textui/core';
|
|
3
3
|
|
|
4
4
|
export interface PaginationProps extends BoxProps {
|
|
5
5
|
page: number;
|
|
@@ -10,6 +10,7 @@ export interface PaginationProps extends BoxProps {
|
|
|
10
10
|
|
|
11
11
|
export const Pagination = defineComponent<PaginationProps>('Pagination', (props) => {
|
|
12
12
|
const theme = useTheme();
|
|
13
|
+
const i18n = useI18n();
|
|
13
14
|
const { page, pageCount, total, onChange, ...rest } = props;
|
|
14
15
|
const focus = useFocus({});
|
|
15
16
|
|
|
@@ -26,6 +27,6 @@ export const Pagination = defineComponent<PaginationProps>('Pagination', (props)
|
|
|
26
27
|
h('text', { content: theme.glyphs.chevronLeft, fg: page > 1 ? 'accent' : 'disabled' }),
|
|
27
28
|
h('text', { content: `${page} / ${pageCount}`, bold: focus.focused }),
|
|
28
29
|
h('text', { content: theme.glyphs.chevronRight, fg: page < pageCount ? 'accent' : 'disabled' }),
|
|
29
|
-
total !== undefined ? h('text', { content:
|
|
30
|
+
total !== undefined ? h('text', { content: i18n.t('textui.pagination.total', { total }, '{total} items'), fg: 'muted' }) : null,
|
|
30
31
|
);
|
|
31
32
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoxProps } from '@textui/core';
|
|
2
|
-
import { defineComponent, h, useTheme } from '@textui/core';
|
|
2
|
+
import { defineComponent, h, useI18n, useTheme } from '@textui/core';
|
|
3
3
|
|
|
4
4
|
export interface ErrorStateProps extends BoxProps {
|
|
5
5
|
title?: string;
|
|
@@ -10,7 +10,8 @@ export interface ErrorStateProps extends BoxProps {
|
|
|
10
10
|
|
|
11
11
|
export const ErrorState = defineComponent<ErrorStateProps>('ErrorState', (props) => {
|
|
12
12
|
const theme = useTheme();
|
|
13
|
-
const
|
|
13
|
+
const i18n = useI18n();
|
|
14
|
+
const { title = i18n.t('textui.errorState.title', undefined, 'Something went wrong'), error, onRetry, ...rest } = props;
|
|
14
15
|
const message = error instanceof Error ? error.message : String(error);
|
|
15
16
|
|
|
16
17
|
return h('box', { role: 'alert', direction: 'column', gap: 1, padding: 1, ...rest },
|
|
@@ -18,6 +19,6 @@ export const ErrorState = defineComponent<ErrorStateProps>('ErrorState', (props)
|
|
|
18
19
|
h('text', { content: theme.glyphs.cross, fg: 'danger' }),
|
|
19
20
|
h('text', { content: title, bold: true, fg: 'danger' })),
|
|
20
21
|
h('text', { content: message, fg: 'muted', wrap: 'word' }),
|
|
21
|
-
onRetry ? h('text', { content: 'r retry', fg: 'subtle' }) : null,
|
|
22
|
+
onRetry ? h('text', { content: i18n.t('textui.errorState.retry', undefined, 'r retry'), fg: 'subtle' }) : null,
|
|
22
23
|
);
|
|
23
24
|
});
|
package/src/form/danger-zone.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoxProps } from '@textui/core';
|
|
2
|
-
import { defineComponent, h, useTheme } from '@textui/core';
|
|
2
|
+
import { defineComponent, h, useI18n, useTheme } from '@textui/core';
|
|
3
3
|
import { Button } from '../control/index.js';
|
|
4
4
|
|
|
5
5
|
export interface DangerZoneProps extends BoxProps {
|
|
@@ -13,8 +13,9 @@ export interface DangerZoneProps extends BoxProps {
|
|
|
13
13
|
|
|
14
14
|
export const DangerZone = defineComponent<DangerZoneProps>('DangerZone', (props) => {
|
|
15
15
|
const theme = useTheme();
|
|
16
|
+
const i18n = useI18n();
|
|
16
17
|
const {
|
|
17
|
-
title = 'Danger zone', description, actionLabel, onAction, confirmText, ...rest
|
|
18
|
+
title = i18n.t('textui.dangerZone.title', undefined, 'Danger zone'), description, actionLabel, onAction, confirmText, ...rest
|
|
18
19
|
} = props;
|
|
19
20
|
|
|
20
21
|
return h('box', {
|
|
@@ -26,7 +27,10 @@ export const DangerZone = defineComponent<DangerZoneProps>('DangerZone', (props)
|
|
|
26
27
|
},
|
|
27
28
|
description ? h('text', { content: description, fg: 'muted', wrap: 'word' }) : null,
|
|
28
29
|
confirmText
|
|
29
|
-
? h('text', {
|
|
30
|
+
? h('text', {
|
|
31
|
+
content: i18n.t('textui.dangerZone.confirm', { text: confirmText }, 'Type "{text}" to confirm.'),
|
|
32
|
+
fg: 'subtle',
|
|
33
|
+
})
|
|
30
34
|
: null,
|
|
31
35
|
h('box', { direction: 'row', justify: 'end' },
|
|
32
36
|
h(Button, { label: actionLabel, tone: 'danger', variant: 'outline', onPress: onAction })),
|
package/src/form/form-actions.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoxProps, SemanticVariant } from '@textui/core';
|
|
2
|
-
import { defineComponent, h, useTheme } from '@textui/core';
|
|
2
|
+
import { defineComponent, h, useI18n, useTheme } from '@textui/core';
|
|
3
3
|
import { Button } from '../control/index.js';
|
|
4
4
|
import { useFormContext } from './shared.js';
|
|
5
5
|
|
|
@@ -14,9 +14,12 @@ export interface FormActionsProps extends BoxProps {
|
|
|
14
14
|
|
|
15
15
|
export const FormActions = defineComponent<FormActionsProps>('FormActions', (props) => {
|
|
16
16
|
const theme = useTheme();
|
|
17
|
+
const i18n = useI18n();
|
|
17
18
|
const form = useFormContext();
|
|
18
19
|
const {
|
|
19
|
-
submitLabel = '
|
|
20
|
+
submitLabel = i18n.t('textui.formActions.submit', undefined, 'Submit'),
|
|
21
|
+
cancelLabel = i18n.t('textui.formActions.cancel', undefined, 'Cancel'),
|
|
22
|
+
onCancel,
|
|
20
23
|
tone = 'primary', requireDirty = false, ...rest
|
|
21
24
|
} = props;
|
|
22
25
|
|
package/src/navigation/menu.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoxProps, SemanticVariant } from '@textui/core';
|
|
2
|
-
import { defineComponent, h, stringWidth, useFocus, useInput, useState, useTheme } from '@textui/core';
|
|
2
|
+
import { defineComponent, h, stringWidth, useFocus, useI18n, useInput, useState, useTheme } from '@textui/core';
|
|
3
3
|
import { Marquee } from '../display/index.js';
|
|
4
4
|
import { TONE } from '../tone.js';
|
|
5
5
|
|
|
@@ -63,6 +63,7 @@ export interface MenuProps extends BoxProps {
|
|
|
63
63
|
|
|
64
64
|
export const Menu = defineComponent<MenuProps>('Menu', (props) => {
|
|
65
65
|
const theme = useTheme();
|
|
66
|
+
const i18n = useI18n();
|
|
66
67
|
const {
|
|
67
68
|
items, onSelect, visibleRows, activeId, autoFocus, interactive = true,
|
|
68
69
|
descriptions = 'inline', ...rest
|
|
@@ -188,7 +189,7 @@ export const Menu = defineComponent<MenuProps>('Menu', (props) => {
|
|
|
188
189
|
: [row];
|
|
189
190
|
}),
|
|
190
191
|
selectable.length === 0
|
|
191
|
-
? h('text', { content: '
|
|
192
|
+
? h('text', { content: ` ${i18n.t('textui.menu.noMatch', undefined, 'no matches')}`, fg: 'subtle' })
|
|
192
193
|
: null,
|
|
193
194
|
);
|
|
194
195
|
});
|