@kud/ink-ui 0.4.0 → 0.6.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 +19 -2
- package/dist/index.js +43 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -119,8 +119,9 @@ type StyledLine = {
|
|
|
119
119
|
type ScrollViewProps = {
|
|
120
120
|
lines: StyledLine[];
|
|
121
121
|
showIndicator?: boolean;
|
|
122
|
+
initialStart?: number;
|
|
122
123
|
};
|
|
123
|
-
declare const ScrollView: ({ lines, showIndicator, }: ScrollViewProps) => React.JSX.Element;
|
|
124
|
+
declare const ScrollView: ({ lines, showIndicator, initialStart, }: ScrollViewProps) => React.JSX.Element;
|
|
124
125
|
|
|
125
126
|
type TabItem<T extends string = string> = {
|
|
126
127
|
value: T;
|
|
@@ -133,6 +134,22 @@ type TabsProps<T extends string> = {
|
|
|
133
134
|
};
|
|
134
135
|
declare const Tabs: <T extends string>({ active, items }: TabsProps<T>) => React.JSX.Element;
|
|
135
136
|
|
|
137
|
+
type SwitchValue = "left" | "right";
|
|
138
|
+
type SwitchProps = {
|
|
139
|
+
left: string;
|
|
140
|
+
right: string;
|
|
141
|
+
value: SwitchValue;
|
|
142
|
+
color?: string;
|
|
143
|
+
};
|
|
144
|
+
declare const Switch: ({ left, right, value, color, }: SwitchProps) => React.JSX.Element;
|
|
145
|
+
|
|
146
|
+
type ToggleProps = {
|
|
147
|
+
label: string;
|
|
148
|
+
on: boolean;
|
|
149
|
+
color?: string;
|
|
150
|
+
};
|
|
151
|
+
declare const Toggle: ({ label, on, color }: ToggleProps) => React.JSX.Element;
|
|
152
|
+
|
|
136
153
|
type ProgressBarProps = {
|
|
137
154
|
value: number;
|
|
138
155
|
width?: number;
|
|
@@ -190,4 +207,4 @@ declare const spacing: {
|
|
|
190
207
|
};
|
|
191
208
|
type Spacing = (typeof spacing)[keyof typeof spacing];
|
|
192
209
|
|
|
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 };
|
|
210
|
+
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
|
@@ -251,11 +251,13 @@ var ConfirmInput = ({
|
|
|
251
251
|
};
|
|
252
252
|
var ScrollView = ({
|
|
253
253
|
lines,
|
|
254
|
-
showIndicator = true
|
|
254
|
+
showIndicator = true,
|
|
255
|
+
initialStart = 0
|
|
255
256
|
}) => {
|
|
256
257
|
const ref = useRef(null);
|
|
257
258
|
const [height, setHeight] = useState(1);
|
|
258
|
-
const [start, setStart] = useState(
|
|
259
|
+
const [start, setStart] = useState(initialStart);
|
|
260
|
+
useEffect(() => setStart(initialStart), [initialStart]);
|
|
259
261
|
useLayoutEffect(() => {
|
|
260
262
|
if (!ref.current) return;
|
|
261
263
|
const { height: h } = measureElement(ref.current);
|
|
@@ -326,6 +328,44 @@ var Tabs = ({ active, items }) => {
|
|
|
326
328
|
/* @__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)) })
|
|
327
329
|
] });
|
|
328
330
|
};
|
|
331
|
+
var Switch = ({
|
|
332
|
+
left,
|
|
333
|
+
right,
|
|
334
|
+
value,
|
|
335
|
+
color = colors.accent
|
|
336
|
+
}) => {
|
|
337
|
+
const leftActive = value === "left";
|
|
338
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
339
|
+
/* @__PURE__ */ jsx(
|
|
340
|
+
Text,
|
|
341
|
+
{
|
|
342
|
+
color: leftActive ? color : void 0,
|
|
343
|
+
bold: leftActive,
|
|
344
|
+
dimColor: !leftActive,
|
|
345
|
+
children: left
|
|
346
|
+
}
|
|
347
|
+
),
|
|
348
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
349
|
+
/* @__PURE__ */ jsx(Text, { color: leftActive ? color : colors.muted, children: leftActive ? "\u25CF" : "\u25CB" }),
|
|
350
|
+
/* @__PURE__ */ jsx(Text, { color: colors.muted, children: "\u2500" }),
|
|
351
|
+
/* @__PURE__ */ jsx(Text, { color: !leftActive ? color : colors.muted, children: !leftActive ? "\u25CF" : "\u25CB" }),
|
|
352
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
353
|
+
/* @__PURE__ */ jsx(
|
|
354
|
+
Text,
|
|
355
|
+
{
|
|
356
|
+
color: !leftActive ? color : void 0,
|
|
357
|
+
bold: !leftActive,
|
|
358
|
+
dimColor: leftActive,
|
|
359
|
+
children: right
|
|
360
|
+
}
|
|
361
|
+
)
|
|
362
|
+
] });
|
|
363
|
+
};
|
|
364
|
+
var Toggle = ({ label, on, color = colors.accent }) => /* @__PURE__ */ jsxs(Text, { color: on ? color : void 0, dimColor: !on, children: [
|
|
365
|
+
label,
|
|
366
|
+
" ",
|
|
367
|
+
on ? "\u25CF" : "\u25CB"
|
|
368
|
+
] });
|
|
329
369
|
var ProgressBar = ({ value, width = 20 }) => {
|
|
330
370
|
const clamped = Math.max(0, Math.min(100, value));
|
|
331
371
|
const filled = Math.round(clamped / 100 * width);
|
|
@@ -435,4 +475,4 @@ var notify = (message, options = {}) => {
|
|
|
435
475
|
child.unref();
|
|
436
476
|
};
|
|
437
477
|
|
|
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 };
|
|
478
|
+
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 };
|