@kud/ink-ui 0.13.1 → 0.14.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/index.d.ts +63 -41
- package/dist/index.js +41 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
type BannerProps = {
|
|
4
5
|
title: string;
|
|
5
6
|
subtitle?: string;
|
|
6
7
|
icon?: string;
|
|
7
8
|
};
|
|
8
|
-
declare const Banner: ({ title, subtitle, icon }: BannerProps) =>
|
|
9
|
+
declare const Banner: ({ title, subtitle, icon }: BannerProps) => React__default.JSX.Element;
|
|
9
10
|
|
|
10
11
|
type BadgeVariant = "success" | "error" | "warning" | "info";
|
|
11
12
|
type BadgeProps = {
|
|
12
13
|
children: string;
|
|
13
14
|
variant?: BadgeVariant;
|
|
14
15
|
};
|
|
15
|
-
declare const Badge: ({ children, variant }: BadgeProps) =>
|
|
16
|
+
declare const Badge: ({ children, variant }: BadgeProps) => React__default.JSX.Element;
|
|
16
17
|
|
|
17
18
|
type HeaderProps = {
|
|
18
19
|
children: string;
|
|
19
20
|
subtitle?: string;
|
|
20
21
|
};
|
|
21
|
-
declare const Header: ({ children, subtitle }: HeaderProps) =>
|
|
22
|
+
declare const Header: ({ children, subtitle }: HeaderProps) => React__default.JSX.Element;
|
|
22
23
|
|
|
23
24
|
type SpinnerProps = {
|
|
24
25
|
label?: string;
|
|
25
26
|
};
|
|
26
|
-
declare const Spinner: ({ label }: SpinnerProps) =>
|
|
27
|
+
declare const Spinner: ({ label }: SpinnerProps) => React__default.JSX.Element;
|
|
27
28
|
|
|
28
29
|
type Column<T extends Record<string, unknown>> = {
|
|
29
30
|
key: keyof T & string;
|
|
@@ -34,25 +35,25 @@ type TableProps<T extends Record<string, unknown>> = {
|
|
|
34
35
|
data: T[];
|
|
35
36
|
columns: Column<T>[];
|
|
36
37
|
};
|
|
37
|
-
declare const Table: <T extends Record<string, unknown>>({ data, columns, }: TableProps<T>) =>
|
|
38
|
+
declare const Table: <T extends Record<string, unknown>>({ data, columns, }: TableProps<T>) => React__default.JSX.Element;
|
|
38
39
|
|
|
39
40
|
type Hint = [key: string, label: string];
|
|
40
41
|
type FooterHintsProps = {
|
|
41
42
|
hints: Hint[];
|
|
42
43
|
};
|
|
43
|
-
declare const FooterHints: ({ hints }: FooterHintsProps) =>
|
|
44
|
+
declare const FooterHints: ({ hints }: FooterHintsProps) => React__default.JSX.Element;
|
|
44
45
|
|
|
45
46
|
type KeyValueProps = {
|
|
46
47
|
label: string;
|
|
47
|
-
value:
|
|
48
|
+
value: React__default.ReactNode;
|
|
48
49
|
labelWidth?: number;
|
|
49
50
|
};
|
|
50
|
-
declare const KeyValue: ({ label, value, labelWidth }: KeyValueProps) =>
|
|
51
|
+
declare const KeyValue: ({ label, value, labelWidth }: KeyValueProps) => React__default.JSX.Element;
|
|
51
52
|
|
|
52
53
|
type LoadingScreenProps = {
|
|
53
54
|
label: string;
|
|
54
55
|
};
|
|
55
|
-
declare const LoadingScreen: ({ label }: LoadingScreenProps) =>
|
|
56
|
+
declare const LoadingScreen: ({ label }: LoadingScreenProps) => React__default.JSX.Element;
|
|
56
57
|
|
|
57
58
|
type PanelProps = {
|
|
58
59
|
/** Optional title shown in the panel's header row. */
|
|
@@ -66,21 +67,21 @@ type PanelProps = {
|
|
|
66
67
|
flexGrow?: number;
|
|
67
68
|
children: ReactNode;
|
|
68
69
|
};
|
|
69
|
-
declare const Panel: ({ title, color, focused, width, height, flexGrow, children, }: PanelProps) =>
|
|
70
|
+
declare const Panel: ({ title, color, focused, width, height, flexGrow, children, }: PanelProps) => React__default.JSX.Element;
|
|
70
71
|
|
|
71
72
|
type ColumnsProps = {
|
|
72
73
|
/** Horizontal gap between columns (character cells). Defaults to 1. */
|
|
73
74
|
gap?: number;
|
|
74
75
|
children: ReactNode;
|
|
75
76
|
};
|
|
76
|
-
declare const Columns: ({ gap, children }: ColumnsProps) =>
|
|
77
|
+
declare const Columns: ({ gap, children }: ColumnsProps) => React__default.JSX.Element;
|
|
77
78
|
|
|
78
79
|
type SelectableRowProps = {
|
|
79
80
|
active?: boolean;
|
|
80
81
|
marker?: string;
|
|
81
|
-
children:
|
|
82
|
+
children: React__default.ReactNode;
|
|
82
83
|
};
|
|
83
|
-
declare const SelectableRow: ({ active, marker, children, }: SelectableRowProps) =>
|
|
84
|
+
declare const SelectableRow: ({ active, marker, children, }: SelectableRowProps) => React__default.JSX.Element;
|
|
84
85
|
|
|
85
86
|
type SelectOption<T extends string = string> = {
|
|
86
87
|
label: string;
|
|
@@ -94,7 +95,7 @@ type SelectProps<T extends string> = {
|
|
|
94
95
|
isDisabled?: boolean;
|
|
95
96
|
visibleOptionCount?: number;
|
|
96
97
|
};
|
|
97
|
-
declare const Select: <T extends string>({ options, onChange, onSubmit, defaultValue, isDisabled, visibleOptionCount, }: SelectProps<T>) =>
|
|
98
|
+
declare const Select: <T extends string>({ options, onChange, onSubmit, defaultValue, isDisabled, visibleOptionCount, }: SelectProps<T>) => React__default.JSX.Element;
|
|
98
99
|
|
|
99
100
|
type MultiSelectProps<T extends string> = {
|
|
100
101
|
options: SelectOption<T>[];
|
|
@@ -104,7 +105,7 @@ type MultiSelectProps<T extends string> = {
|
|
|
104
105
|
isDisabled?: boolean;
|
|
105
106
|
visibleOptionCount?: number;
|
|
106
107
|
};
|
|
107
|
-
declare const MultiSelect: <T extends string>({ options, onChange, onSubmit, defaultValue, isDisabled, visibleOptionCount, }: MultiSelectProps<T>) =>
|
|
108
|
+
declare const MultiSelect: <T extends string>({ options, onChange, onSubmit, defaultValue, isDisabled, visibleOptionCount, }: MultiSelectProps<T>) => React__default.JSX.Element;
|
|
108
109
|
|
|
109
110
|
type TextInputProps = {
|
|
110
111
|
placeholder?: string;
|
|
@@ -113,7 +114,7 @@ type TextInputProps = {
|
|
|
113
114
|
onSubmit?: (value: string) => void;
|
|
114
115
|
isDisabled?: boolean;
|
|
115
116
|
};
|
|
116
|
-
declare const TextInput: ({ placeholder, defaultValue, onChange, onSubmit, isDisabled, }: TextInputProps) =>
|
|
117
|
+
declare const TextInput: ({ placeholder, defaultValue, onChange, onSubmit, isDisabled, }: TextInputProps) => React__default.JSX.Element;
|
|
117
118
|
|
|
118
119
|
type EmailInputProps = {
|
|
119
120
|
placeholder?: string;
|
|
@@ -123,7 +124,7 @@ type EmailInputProps = {
|
|
|
123
124
|
onSubmit?: (value: string) => void;
|
|
124
125
|
isDisabled?: boolean;
|
|
125
126
|
};
|
|
126
|
-
declare const EmailInput: ({ placeholder, defaultValue, domains, onChange, onSubmit, isDisabled, }: EmailInputProps) =>
|
|
127
|
+
declare const EmailInput: ({ placeholder, defaultValue, domains, onChange, onSubmit, isDisabled, }: EmailInputProps) => React__default.JSX.Element;
|
|
127
128
|
|
|
128
129
|
type PasswordInputProps = {
|
|
129
130
|
placeholder?: string;
|
|
@@ -132,7 +133,7 @@ type PasswordInputProps = {
|
|
|
132
133
|
onSubmit?: (value: string) => void;
|
|
133
134
|
isDisabled?: boolean;
|
|
134
135
|
};
|
|
135
|
-
declare const PasswordInput: ({ placeholder, mask, onChange, onSubmit, isDisabled, }: PasswordInputProps) =>
|
|
136
|
+
declare const PasswordInput: ({ placeholder, mask, onChange, onSubmit, isDisabled, }: PasswordInputProps) => React__default.JSX.Element;
|
|
136
137
|
|
|
137
138
|
type ConfirmInputProps = {
|
|
138
139
|
defaultChoice?: "confirm" | "cancel";
|
|
@@ -140,27 +141,27 @@ type ConfirmInputProps = {
|
|
|
140
141
|
onCancel?: () => void;
|
|
141
142
|
isDisabled?: boolean;
|
|
142
143
|
};
|
|
143
|
-
declare const ConfirmInput: ({ defaultChoice, onConfirm, onCancel, isDisabled, }: ConfirmInputProps) =>
|
|
144
|
+
declare const ConfirmInput: ({ defaultChoice, onConfirm, onCancel, isDisabled, }: ConfirmInputProps) => React__default.JSX.Element;
|
|
144
145
|
|
|
145
146
|
type ItemProps$1 = {
|
|
146
|
-
children:
|
|
147
|
+
children: React__default.ReactNode;
|
|
147
148
|
};
|
|
148
149
|
type UnorderedListProps = {
|
|
149
|
-
children:
|
|
150
|
+
children: React__default.ReactNode;
|
|
150
151
|
};
|
|
151
|
-
declare const UnorderedList: (({ children }: UnorderedListProps) =>
|
|
152
|
-
Item: ({ children }: ItemProps$1) =>
|
|
152
|
+
declare const UnorderedList: (({ children }: UnorderedListProps) => React__default.JSX.Element) & {
|
|
153
|
+
Item: ({ children }: ItemProps$1) => React__default.JSX.Element;
|
|
153
154
|
};
|
|
154
155
|
|
|
155
156
|
type ItemProps = {
|
|
156
|
-
children:
|
|
157
|
+
children: React__default.ReactNode;
|
|
157
158
|
_index?: number;
|
|
158
159
|
};
|
|
159
160
|
type OrderedListProps = {
|
|
160
|
-
children:
|
|
161
|
+
children: React__default.ReactNode;
|
|
161
162
|
};
|
|
162
|
-
declare const OrderedList: (({ children }: OrderedListProps) =>
|
|
163
|
-
Item: ({ children, _index }: ItemProps) =>
|
|
163
|
+
declare const OrderedList: (({ children }: OrderedListProps) => React__default.JSX.Element) & {
|
|
164
|
+
Item: ({ children, _index }: ItemProps) => React__default.JSX.Element;
|
|
164
165
|
};
|
|
165
166
|
|
|
166
167
|
type Span = {
|
|
@@ -183,7 +184,7 @@ type ScrollViewProps = {
|
|
|
183
184
|
initialStart?: number;
|
|
184
185
|
isActive?: boolean;
|
|
185
186
|
};
|
|
186
|
-
declare const ScrollView: ({ lines, showIndicator, initialStart, isActive, }: ScrollViewProps) =>
|
|
187
|
+
declare const ScrollView: ({ lines, showIndicator, initialStart, isActive, }: ScrollViewProps) => React__default.JSX.Element;
|
|
187
188
|
|
|
188
189
|
type TabItem<T extends string = string> = {
|
|
189
190
|
value: T;
|
|
@@ -194,7 +195,28 @@ type TabsProps<T extends string> = {
|
|
|
194
195
|
active: T;
|
|
195
196
|
items: TabItem<T>[];
|
|
196
197
|
};
|
|
197
|
-
declare const Tabs: <T extends string>({ active, items }: TabsProps<T>) =>
|
|
198
|
+
declare const Tabs: <T extends string>({ active, items }: TabsProps<T>) => React__default.JSX.Element;
|
|
199
|
+
|
|
200
|
+
type UseTabsOptions<T extends string> = {
|
|
201
|
+
initial?: T;
|
|
202
|
+
isActive?: boolean;
|
|
203
|
+
};
|
|
204
|
+
declare const useTabs: <T extends string>(items: TabItem<T>[], { initial, isActive }?: UseTabsOptions<T>) => {
|
|
205
|
+
active: T | undefined;
|
|
206
|
+
setActive: React.Dispatch<React.SetStateAction<T | undefined>>;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
type UseListCursorOptions = {
|
|
210
|
+
initial?: number;
|
|
211
|
+
wrap?: boolean;
|
|
212
|
+
vimKeys?: boolean;
|
|
213
|
+
isActive?: boolean;
|
|
214
|
+
};
|
|
215
|
+
declare const useListCursor: (length: number, { initial, wrap, vimKeys, isActive, }?: UseListCursorOptions) => {
|
|
216
|
+
cursor: number;
|
|
217
|
+
setCursor: React.Dispatch<React.SetStateAction<number>>;
|
|
218
|
+
moveCursor: (delta: number) => void;
|
|
219
|
+
};
|
|
198
220
|
|
|
199
221
|
type SwitchValue = "left" | "right";
|
|
200
222
|
type SwitchProps = {
|
|
@@ -203,14 +225,14 @@ type SwitchProps = {
|
|
|
203
225
|
value: SwitchValue;
|
|
204
226
|
color?: string;
|
|
205
227
|
};
|
|
206
|
-
declare const Switch: ({ left, right, value, color, }: SwitchProps) =>
|
|
228
|
+
declare const Switch: ({ left, right, value, color, }: SwitchProps) => React__default.JSX.Element;
|
|
207
229
|
|
|
208
230
|
type ToggleProps = {
|
|
209
231
|
label: string;
|
|
210
232
|
on: boolean;
|
|
211
233
|
color?: string;
|
|
212
234
|
};
|
|
213
|
-
declare const Toggle: ({ label, on, color }: ToggleProps) =>
|
|
235
|
+
declare const Toggle: ({ label, on, color }: ToggleProps) => React__default.JSX.Element;
|
|
214
236
|
|
|
215
237
|
type ToggleSwitchProps = {
|
|
216
238
|
on: boolean;
|
|
@@ -218,7 +240,7 @@ type ToggleSwitchProps = {
|
|
|
218
240
|
onColor?: string;
|
|
219
241
|
offColor?: string;
|
|
220
242
|
};
|
|
221
|
-
declare const ToggleSwitch: ({ on, label, onColor, offColor, }: ToggleSwitchProps) =>
|
|
243
|
+
declare const ToggleSwitch: ({ on, label, onColor, offColor, }: ToggleSwitchProps) => React__default.JSX.Element;
|
|
222
244
|
|
|
223
245
|
type UpdateBannerProps = {
|
|
224
246
|
name: string;
|
|
@@ -229,7 +251,7 @@ type UpdateBannerProps = {
|
|
|
229
251
|
onDecline: () => void;
|
|
230
252
|
focused?: boolean;
|
|
231
253
|
};
|
|
232
|
-
declare const UpdateBanner: ({ name, current, latest, command, onConfirm, onDecline, focused, }: UpdateBannerProps) =>
|
|
254
|
+
declare const UpdateBanner: ({ name, current, latest, command, onConfirm, onDecline, focused, }: UpdateBannerProps) => React__default.JSX.Element;
|
|
233
255
|
|
|
234
256
|
type ProgressBarProps = {
|
|
235
257
|
value: number;
|
|
@@ -237,22 +259,22 @@ type ProgressBarProps = {
|
|
|
237
259
|
color?: string;
|
|
238
260
|
trackColor?: string;
|
|
239
261
|
};
|
|
240
|
-
declare const ProgressBar: ({ value, width, color, trackColor, }: ProgressBarProps) =>
|
|
262
|
+
declare const ProgressBar: ({ value, width, color, trackColor, }: ProgressBarProps) => React__default.JSX.Element;
|
|
241
263
|
|
|
242
264
|
type StatusVariant = "success" | "error" | "warning" | "info";
|
|
243
265
|
|
|
244
266
|
type StatusMessageProps = {
|
|
245
267
|
variant?: StatusVariant;
|
|
246
|
-
children:
|
|
268
|
+
children: React__default.ReactNode;
|
|
247
269
|
};
|
|
248
|
-
declare const StatusMessage: ({ variant, children, }: StatusMessageProps) =>
|
|
270
|
+
declare const StatusMessage: ({ variant, children, }: StatusMessageProps) => React__default.JSX.Element;
|
|
249
271
|
|
|
250
272
|
type AlertProps = {
|
|
251
273
|
variant?: StatusVariant;
|
|
252
274
|
title?: string;
|
|
253
|
-
children:
|
|
275
|
+
children: React__default.ReactNode;
|
|
254
276
|
};
|
|
255
|
-
declare const Alert: ({ variant, title, children }: AlertProps) =>
|
|
277
|
+
declare const Alert: ({ variant, title, children }: AlertProps) => React__default.JSX.Element;
|
|
256
278
|
|
|
257
279
|
type ToastProps = {
|
|
258
280
|
message: string;
|
|
@@ -260,7 +282,7 @@ type ToastProps = {
|
|
|
260
282
|
duration?: number;
|
|
261
283
|
onDone?: () => void;
|
|
262
284
|
};
|
|
263
|
-
declare const Toast: ({ message, variant, duration, onDone, }: ToastProps) =>
|
|
285
|
+
declare const Toast: ({ message, variant, duration, onDone, }: ToastProps) => React__default.JSX.Element | null;
|
|
264
286
|
|
|
265
287
|
type IconMode = "text" | "nerd";
|
|
266
288
|
declare const setIconMode: (mode: IconMode) => void;
|
|
@@ -290,4 +312,4 @@ declare const spacing: {
|
|
|
290
312
|
};
|
|
291
313
|
type Spacing = (typeof spacing)[keyof typeof spacing];
|
|
292
314
|
|
|
293
|
-
export { Alert, Badge, type BadgeVariant, Banner, type Color, type Column, Columns, ConfirmInput, EmailInput, FooterHints, Header, type Hint, type IconMode, KeyValue, LoadingScreen, MultiSelect, type NotifyOptions, OrderedList, Panel, PasswordInput, ProgressBar, ScrollView, Select, type SelectOption, SelectableRow, type Spacing, type Span, Spinner, StatusMessage, type StatusVariant, type StyledLine, Switch, type SwitchValue, type TabItem, Table, Tabs, TextInput, Toast, Toggle, ToggleSwitch, UnorderedList, UpdateBanner, colors, getIconMode, notify, setIconMode, spacing };
|
|
315
|
+
export { Alert, Badge, type BadgeVariant, Banner, type Color, type Column, Columns, ConfirmInput, EmailInput, FooterHints, Header, type Hint, type IconMode, KeyValue, LoadingScreen, MultiSelect, type NotifyOptions, OrderedList, Panel, PasswordInput, ProgressBar, ScrollView, Select, type SelectOption, SelectableRow, type Spacing, type Span, Spinner, StatusMessage, type StatusVariant, type StyledLine, Switch, type SwitchValue, type TabItem, Table, Tabs, TextInput, Toast, Toggle, ToggleSwitch, UnorderedList, UpdateBanner, colors, getIconMode, notify, setIconMode, spacing, useListCursor, useTabs };
|
package/dist/index.js
CHANGED
|
@@ -104,7 +104,7 @@ var SelectableRow = ({
|
|
|
104
104
|
marker = "\u276F",
|
|
105
105
|
children
|
|
106
106
|
}) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
107
|
-
/* @__PURE__ */ jsx(Text, { color: colors.info, children: active ? ` ${marker} ` : " " }),
|
|
107
|
+
/* @__PURE__ */ jsx(Box, { flexShrink: 0, children: /* @__PURE__ */ jsx(Text, { color: colors.info, children: active ? ` ${marker} ` : " " }) }),
|
|
108
108
|
isTextValue2(children) ? /* @__PURE__ */ jsx(Text, { bold: active, children }) : children
|
|
109
109
|
] });
|
|
110
110
|
var windowStart = (cursor, total, count) => {
|
|
@@ -545,6 +545,45 @@ var Tabs = ({ active, items }) => {
|
|
|
545
545
|
/* @__PURE__ */ jsx(Box, { gap: 2, children: cells.map((cell) => /* @__PURE__ */ jsx(Text, { color: colors.accent, children: cell.isActive ? "\u2500".repeat(cell.text.length) : " ".repeat(cell.text.length) }, cell.key)) })
|
|
546
546
|
] });
|
|
547
547
|
};
|
|
548
|
+
var useTabs = (items, { initial, isActive = true } = {}) => {
|
|
549
|
+
const [active, setActive] = useState(
|
|
550
|
+
initial ?? items[0]?.value
|
|
551
|
+
);
|
|
552
|
+
useInput(
|
|
553
|
+
(_input, key) => {
|
|
554
|
+
if (!key.tab || items.length === 0) return;
|
|
555
|
+
const current2 = items.findIndex((item) => item.value === active);
|
|
556
|
+
const next = (current2 + (key.shift ? -1 : 1) + items.length) % items.length;
|
|
557
|
+
setActive(items[next].value);
|
|
558
|
+
},
|
|
559
|
+
{ isActive }
|
|
560
|
+
);
|
|
561
|
+
return { active, setActive };
|
|
562
|
+
};
|
|
563
|
+
var useListCursor = (length, {
|
|
564
|
+
initial = 0,
|
|
565
|
+
wrap = false,
|
|
566
|
+
vimKeys = true,
|
|
567
|
+
isActive = true
|
|
568
|
+
} = {}) => {
|
|
569
|
+
const [cursor, setCursor] = useState(initial);
|
|
570
|
+
const moveCursor = (delta) => {
|
|
571
|
+
if (length === 0) return;
|
|
572
|
+
setCursor((current2) => {
|
|
573
|
+
const next = current2 + delta;
|
|
574
|
+
if (wrap) return (next + length) % length;
|
|
575
|
+
return Math.min(length - 1, Math.max(0, next));
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
useInput(
|
|
579
|
+
(input, key) => {
|
|
580
|
+
if (key.upArrow || vimKeys && input === "k") moveCursor(-1);
|
|
581
|
+
if (key.downArrow || vimKeys && input === "j") moveCursor(1);
|
|
582
|
+
},
|
|
583
|
+
{ isActive }
|
|
584
|
+
);
|
|
585
|
+
return { cursor, setCursor, moveCursor };
|
|
586
|
+
};
|
|
548
587
|
var Switch = ({
|
|
549
588
|
left,
|
|
550
589
|
right,
|
|
@@ -766,4 +805,4 @@ var notify = (message, options = {}) => {
|
|
|
766
805
|
child.unref();
|
|
767
806
|
};
|
|
768
807
|
|
|
769
|
-
export { Alert, Badge, Banner, Columns, ConfirmInput, EmailInput, FooterHints, Header, KeyValue, LoadingScreen, MultiSelect, OrderedList, Panel, PasswordInput, ProgressBar, ScrollView, Select, SelectableRow, Spinner, StatusMessage, Switch, Table, Tabs, TextInput, Toast, Toggle, ToggleSwitch, UnorderedList, UpdateBanner, colors, getIconMode, notify, setIconMode, spacing };
|
|
808
|
+
export { Alert, Badge, Banner, Columns, ConfirmInput, EmailInput, FooterHints, Header, KeyValue, LoadingScreen, MultiSelect, OrderedList, Panel, PasswordInput, ProgressBar, ScrollView, Select, SelectableRow, Spinner, StatusMessage, Switch, Table, Tabs, TextInput, Toast, Toggle, ToggleSwitch, UnorderedList, UpdateBanner, colors, getIconMode, notify, setIconMode, spacing, useListCursor, useTabs };
|