@kud/ink-ui 0.3.0 → 0.4.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 +5 -1
- package/dist/index.js +33 -9
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -162,6 +162,10 @@ type ToastProps = {
|
|
|
162
162
|
};
|
|
163
163
|
declare const Toast: ({ message, variant, duration, onDone, }: ToastProps) => React.JSX.Element | null;
|
|
164
164
|
|
|
165
|
+
type IconMode = "text" | "nerd";
|
|
166
|
+
declare const setIconMode: (mode: IconMode) => void;
|
|
167
|
+
declare const getIconMode: () => IconMode;
|
|
168
|
+
|
|
165
169
|
type NotifyOptions = {
|
|
166
170
|
title?: string;
|
|
167
171
|
subtitle?: string;
|
|
@@ -186,4 +190,4 @@ declare const spacing: {
|
|
|
186
190
|
};
|
|
187
191
|
type Spacing = (typeof spacing)[keyof typeof spacing];
|
|
188
192
|
|
|
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 };
|
|
193
|
+
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, type TabItem, Table, Tabs, TextInput, Toast, 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
|
|
@@ -334,25 +335,48 @@ var ProgressBar = ({ value, width = 20 }) => {
|
|
|
334
335
|
] });
|
|
335
336
|
};
|
|
336
337
|
|
|
338
|
+
// src/icon-mode.ts
|
|
339
|
+
var current = "text";
|
|
340
|
+
var setIconMode = (mode) => {
|
|
341
|
+
current = mode;
|
|
342
|
+
};
|
|
343
|
+
var getIconMode = () => current;
|
|
344
|
+
|
|
337
345
|
// src/components/status-variants.ts
|
|
338
|
-
var
|
|
339
|
-
success:
|
|
340
|
-
error:
|
|
341
|
-
warning:
|
|
342
|
-
info:
|
|
346
|
+
var UNICODE = {
|
|
347
|
+
success: "\u2713",
|
|
348
|
+
error: "\u2717",
|
|
349
|
+
warning: "\u26A0",
|
|
350
|
+
info: "\u2139"
|
|
351
|
+
};
|
|
352
|
+
var NERD = {
|
|
353
|
+
success: glyphs.check,
|
|
354
|
+
error: glyphs.cross,
|
|
355
|
+
warning: glyphs.warning,
|
|
356
|
+
info: glyphs.info
|
|
357
|
+
};
|
|
358
|
+
var COLOR = {
|
|
359
|
+
success: colors.success,
|
|
360
|
+
error: colors.error,
|
|
361
|
+
warning: colors.warning,
|
|
362
|
+
info: colors.info
|
|
343
363
|
};
|
|
364
|
+
var statusVariant = (variant) => ({
|
|
365
|
+
icon: (getIconMode() === "nerd" ? NERD : UNICODE)[variant],
|
|
366
|
+
color: COLOR[variant]
|
|
367
|
+
});
|
|
344
368
|
var StatusMessage = ({
|
|
345
369
|
variant = "info",
|
|
346
370
|
children
|
|
347
371
|
}) => {
|
|
348
|
-
const { icon, color } =
|
|
372
|
+
const { icon, color } = statusVariant(variant);
|
|
349
373
|
return /* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
350
374
|
/* @__PURE__ */ jsx(Text, { color, children: icon }),
|
|
351
375
|
/* @__PURE__ */ jsx(Text, { children })
|
|
352
376
|
] });
|
|
353
377
|
};
|
|
354
378
|
var Alert = ({ variant = "info", title, children }) => {
|
|
355
|
-
const { icon, color } =
|
|
379
|
+
const { icon, color } = statusVariant(variant);
|
|
356
380
|
return /* @__PURE__ */ jsxs(
|
|
357
381
|
Box,
|
|
358
382
|
{
|
|
@@ -385,7 +409,7 @@ var Toast = ({
|
|
|
385
409
|
return () => clearTimeout(timer);
|
|
386
410
|
}, [duration]);
|
|
387
411
|
if (!visible) return null;
|
|
388
|
-
const { icon, color } =
|
|
412
|
+
const { icon, color } = statusVariant(variant);
|
|
389
413
|
return /* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
390
414
|
/* @__PURE__ */ jsx(Text, { color, children: icon }),
|
|
391
415
|
/* @__PURE__ */ jsx(Text, { children: message })
|
|
@@ -411,4 +435,4 @@ var notify = (message, options = {}) => {
|
|
|
411
435
|
child.unref();
|
|
412
436
|
};
|
|
413
437
|
|
|
414
|
-
export { Alert, Badge, Banner, ConfirmInput, FooterHints, Header, KeyValue, LoadingScreen, MultiSelect, ProgressBar, ScrollView, Select, SelectableRow, Spinner, StatusMessage, Table, Tabs, TextInput, Toast, colors, notify, spacing };
|
|
438
|
+
export { Alert, Badge, Banner, ConfirmInput, FooterHints, Header, KeyValue, LoadingScreen, MultiSelect, ProgressBar, ScrollView, Select, SelectableRow, Spinner, StatusMessage, Table, Tabs, TextInput, Toast, 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.4.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
|
},
|