@kud/ink-ui 0.3.0 → 0.5.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 +21 -1
- package/dist/index.js +71 -9
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -133,6 +133,22 @@ type TabsProps<T extends string> = {
|
|
|
133
133
|
};
|
|
134
134
|
declare const Tabs: <T extends string>({ active, items }: TabsProps<T>) => React.JSX.Element;
|
|
135
135
|
|
|
136
|
+
type SwitchValue = "left" | "right";
|
|
137
|
+
type SwitchProps = {
|
|
138
|
+
left: string;
|
|
139
|
+
right: string;
|
|
140
|
+
value: SwitchValue;
|
|
141
|
+
color?: string;
|
|
142
|
+
};
|
|
143
|
+
declare const Switch: ({ left, right, value, color, }: SwitchProps) => React.JSX.Element;
|
|
144
|
+
|
|
145
|
+
type ToggleProps = {
|
|
146
|
+
label: string;
|
|
147
|
+
on: boolean;
|
|
148
|
+
color?: string;
|
|
149
|
+
};
|
|
150
|
+
declare const Toggle: ({ label, on, color }: ToggleProps) => React.JSX.Element;
|
|
151
|
+
|
|
136
152
|
type ProgressBarProps = {
|
|
137
153
|
value: number;
|
|
138
154
|
width?: number;
|
|
@@ -162,6 +178,10 @@ type ToastProps = {
|
|
|
162
178
|
};
|
|
163
179
|
declare const Toast: ({ message, variant, duration, onDone, }: ToastProps) => React.JSX.Element | null;
|
|
164
180
|
|
|
181
|
+
type IconMode = "text" | "nerd";
|
|
182
|
+
declare const setIconMode: (mode: IconMode) => void;
|
|
183
|
+
declare const getIconMode: () => IconMode;
|
|
184
|
+
|
|
165
185
|
type NotifyOptions = {
|
|
166
186
|
title?: string;
|
|
167
187
|
subtitle?: string;
|
|
@@ -186,4 +206,4 @@ declare const spacing: {
|
|
|
186
206
|
};
|
|
187
207
|
type Spacing = (typeof spacing)[keyof typeof spacing];
|
|
188
208
|
|
|
189
|
-
export { Alert, Badge, type BadgeVariant, Banner, type Color, type Column, ConfirmInput, FooterHints, Header, type Hint, KeyValue, LoadingScreen, MultiSelect, type NotifyOptions, ProgressBar, ScrollView, Select, type SelectOption, SelectableRow, type Spacing, type Span, Spinner, StatusMessage, type StatusVariant, type StyledLine, type TabItem, Table, Tabs, TextInput, Toast, colors, notify, spacing };
|
|
209
|
+
export { Alert, Badge, type BadgeVariant, Banner, type Color, type Column, ConfirmInput, FooterHints, Header, type Hint, type IconMode, KeyValue, LoadingScreen, MultiSelect, type NotifyOptions, 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, colors, getIconMode, notify, setIconMode, spacing };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Box, Text, useInput, measureElement } from 'ink';
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useEffect, useRef, useLayoutEffect } from 'react';
|
|
4
4
|
import cliSpinners from 'cli-spinners';
|
|
5
|
+
import { glyphs } from '@kud/glyphs';
|
|
5
6
|
import { spawn } from 'child_process';
|
|
6
7
|
|
|
7
8
|
// src/components/Banner.tsx
|
|
@@ -325,6 +326,44 @@ var Tabs = ({ active, items }) => {
|
|
|
325
326
|
/* @__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)) })
|
|
326
327
|
] });
|
|
327
328
|
};
|
|
329
|
+
var Switch = ({
|
|
330
|
+
left,
|
|
331
|
+
right,
|
|
332
|
+
value,
|
|
333
|
+
color = colors.accent
|
|
334
|
+
}) => {
|
|
335
|
+
const leftActive = value === "left";
|
|
336
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
337
|
+
/* @__PURE__ */ jsx(
|
|
338
|
+
Text,
|
|
339
|
+
{
|
|
340
|
+
color: leftActive ? color : void 0,
|
|
341
|
+
bold: leftActive,
|
|
342
|
+
dimColor: !leftActive,
|
|
343
|
+
children: left
|
|
344
|
+
}
|
|
345
|
+
),
|
|
346
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
347
|
+
/* @__PURE__ */ jsx(Text, { color: leftActive ? color : colors.muted, children: leftActive ? "\u25CF" : "\u25CB" }),
|
|
348
|
+
/* @__PURE__ */ jsx(Text, { color: colors.muted, children: "\u2500" }),
|
|
349
|
+
/* @__PURE__ */ jsx(Text, { color: !leftActive ? color : colors.muted, children: !leftActive ? "\u25CF" : "\u25CB" }),
|
|
350
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
351
|
+
/* @__PURE__ */ jsx(
|
|
352
|
+
Text,
|
|
353
|
+
{
|
|
354
|
+
color: !leftActive ? color : void 0,
|
|
355
|
+
bold: !leftActive,
|
|
356
|
+
dimColor: leftActive,
|
|
357
|
+
children: right
|
|
358
|
+
}
|
|
359
|
+
)
|
|
360
|
+
] });
|
|
361
|
+
};
|
|
362
|
+
var Toggle = ({ label, on, color = colors.accent }) => /* @__PURE__ */ jsxs(Text, { color: on ? color : void 0, dimColor: !on, children: [
|
|
363
|
+
label,
|
|
364
|
+
" ",
|
|
365
|
+
on ? "\u25CF" : "\u25CB"
|
|
366
|
+
] });
|
|
328
367
|
var ProgressBar = ({ value, width = 20 }) => {
|
|
329
368
|
const clamped = Math.max(0, Math.min(100, value));
|
|
330
369
|
const filled = Math.round(clamped / 100 * width);
|
|
@@ -334,25 +373,48 @@ var ProgressBar = ({ value, width = 20 }) => {
|
|
|
334
373
|
] });
|
|
335
374
|
};
|
|
336
375
|
|
|
376
|
+
// src/icon-mode.ts
|
|
377
|
+
var current = "text";
|
|
378
|
+
var setIconMode = (mode) => {
|
|
379
|
+
current = mode;
|
|
380
|
+
};
|
|
381
|
+
var getIconMode = () => current;
|
|
382
|
+
|
|
337
383
|
// src/components/status-variants.ts
|
|
338
|
-
var
|
|
339
|
-
success:
|
|
340
|
-
error:
|
|
341
|
-
warning:
|
|
342
|
-
info:
|
|
384
|
+
var UNICODE = {
|
|
385
|
+
success: "\u2713",
|
|
386
|
+
error: "\u2717",
|
|
387
|
+
warning: "\u26A0",
|
|
388
|
+
info: "\u2139"
|
|
389
|
+
};
|
|
390
|
+
var NERD = {
|
|
391
|
+
success: glyphs.check,
|
|
392
|
+
error: glyphs.cross,
|
|
393
|
+
warning: glyphs.warning,
|
|
394
|
+
info: glyphs.info
|
|
395
|
+
};
|
|
396
|
+
var COLOR = {
|
|
397
|
+
success: colors.success,
|
|
398
|
+
error: colors.error,
|
|
399
|
+
warning: colors.warning,
|
|
400
|
+
info: colors.info
|
|
343
401
|
};
|
|
402
|
+
var statusVariant = (variant) => ({
|
|
403
|
+
icon: (getIconMode() === "nerd" ? NERD : UNICODE)[variant],
|
|
404
|
+
color: COLOR[variant]
|
|
405
|
+
});
|
|
344
406
|
var StatusMessage = ({
|
|
345
407
|
variant = "info",
|
|
346
408
|
children
|
|
347
409
|
}) => {
|
|
348
|
-
const { icon, color } =
|
|
410
|
+
const { icon, color } = statusVariant(variant);
|
|
349
411
|
return /* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
350
412
|
/* @__PURE__ */ jsx(Text, { color, children: icon }),
|
|
351
413
|
/* @__PURE__ */ jsx(Text, { children })
|
|
352
414
|
] });
|
|
353
415
|
};
|
|
354
416
|
var Alert = ({ variant = "info", title, children }) => {
|
|
355
|
-
const { icon, color } =
|
|
417
|
+
const { icon, color } = statusVariant(variant);
|
|
356
418
|
return /* @__PURE__ */ jsxs(
|
|
357
419
|
Box,
|
|
358
420
|
{
|
|
@@ -385,7 +447,7 @@ var Toast = ({
|
|
|
385
447
|
return () => clearTimeout(timer);
|
|
386
448
|
}, [duration]);
|
|
387
449
|
if (!visible) return null;
|
|
388
|
-
const { icon, color } =
|
|
450
|
+
const { icon, color } = statusVariant(variant);
|
|
389
451
|
return /* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
390
452
|
/* @__PURE__ */ jsx(Text, { color, children: icon }),
|
|
391
453
|
/* @__PURE__ */ jsx(Text, { children: message })
|
|
@@ -411,4 +473,4 @@ var notify = (message, options = {}) => {
|
|
|
411
473
|
child.unref();
|
|
412
474
|
};
|
|
413
475
|
|
|
414
|
-
export { Alert, Badge, Banner, ConfirmInput, FooterHints, Header, KeyValue, LoadingScreen, MultiSelect, ProgressBar, ScrollView, Select, SelectableRow, Spinner, StatusMessage, Table, Tabs, TextInput, Toast, colors, notify, spacing };
|
|
476
|
+
export { Alert, Badge, Banner, ConfirmInput, FooterHints, Header, KeyValue, LoadingScreen, MultiSelect, ProgressBar, ScrollView, Select, SelectableRow, Spinner, StatusMessage, Switch, Table, Tabs, TextInput, Toast, Toggle, colors, getIconMode, notify, setIconMode, spacing };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kud/ink-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React component library for Ink CLIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"react": ">=19"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@kud/glyphs": "0.1.1",
|
|
32
33
|
"cli-spinners": "3.4.0",
|
|
33
34
|
"figures": "6.1.0"
|
|
34
35
|
},
|