@flyingrobots/bijou 0.9.0 → 1.0.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/adapters/test/assertions.d.ts +51 -0
- package/dist/adapters/test/assertions.d.ts.map +1 -0
- package/dist/adapters/test/assertions.js +67 -0
- package/dist/adapters/test/assertions.js.map +1 -0
- package/dist/adapters/test/audit-style.d.ts +28 -7
- package/dist/adapters/test/audit-style.d.ts.map +1 -1
- package/dist/adapters/test/audit-style.js +61 -4
- package/dist/adapters/test/audit-style.js.map +1 -1
- package/dist/adapters/test/index.d.ts +36 -1
- package/dist/adapters/test/index.d.ts.map +1 -1
- package/dist/adapters/test/index.js +12 -1
- package/dist/adapters/test/index.js.map +1 -1
- package/dist/adapters/test/io.d.ts +27 -0
- package/dist/adapters/test/io.d.ts.map +1 -1
- package/dist/adapters/test/io.js +56 -0
- package/dist/adapters/test/io.js.map +1 -1
- package/dist/adapters/test/runtime.d.ts +17 -0
- package/dist/adapters/test/runtime.d.ts.map +1 -1
- package/dist/adapters/test/runtime.js +14 -0
- package/dist/adapters/test/runtime.js.map +1 -1
- package/dist/adapters/test/style.d.ts +9 -0
- package/dist/adapters/test/style.d.ts.map +1 -1
- package/dist/adapters/test/style.js +54 -0
- package/dist/adapters/test/style.js.map +1 -1
- package/dist/context.d.ts +21 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +21 -0
- package/dist/context.js.map +1 -1
- package/dist/core/bg-fill.d.ts +32 -0
- package/dist/core/bg-fill.d.ts.map +1 -0
- package/dist/core/bg-fill.js +42 -0
- package/dist/core/bg-fill.js.map +1 -0
- package/dist/core/components/accordion.d.ts +20 -0
- package/dist/core/components/accordion.d.ts.map +1 -1
- package/dist/core/components/accordion.js +13 -6
- package/dist/core/components/accordion.js.map +1 -1
- package/dist/core/components/alert.d.ts +16 -0
- package/dist/core/components/alert.d.ts.map +1 -1
- package/dist/core/components/alert.js +17 -6
- package/dist/core/components/alert.js.map +1 -1
- package/dist/core/components/badge.d.ts +18 -0
- package/dist/core/components/badge.d.ts.map +1 -1
- package/dist/core/components/badge.js +15 -11
- package/dist/core/components/badge.js.map +1 -1
- package/dist/core/components/box.d.ts +33 -0
- package/dist/core/components/box.d.ts.map +1 -1
- package/dist/core/components/box.js +72 -23
- package/dist/core/components/box.js.map +1 -1
- package/dist/core/components/breadcrumb.d.ts +15 -0
- package/dist/core/components/breadcrumb.d.ts.map +1 -1
- package/dist/core/components/breadcrumb.js +13 -6
- package/dist/core/components/breadcrumb.js.map +1 -1
- package/dist/core/components/dag-source.d.ts +52 -9
- package/dist/core/components/dag-source.d.ts.map +1 -1
- package/dist/core/components/dag-source.js +53 -9
- package/dist/core/components/dag-source.js.map +1 -1
- package/dist/core/components/dag-stats.d.ts +2 -0
- package/dist/core/components/dag-stats.d.ts.map +1 -1
- package/dist/core/components/dag-stats.js.map +1 -1
- package/dist/core/components/dag.d.ts +88 -1
- package/dist/core/components/dag.d.ts.map +1 -1
- package/dist/core/components/dag.js +127 -6
- package/dist/core/components/dag.js.map +1 -1
- package/dist/core/components/enumerated-list.d.ts +30 -0
- package/dist/core/components/enumerated-list.d.ts.map +1 -1
- package/dist/core/components/enumerated-list.js +50 -11
- package/dist/core/components/enumerated-list.js.map +1 -1
- package/dist/core/components/hyperlink.d.ts +16 -0
- package/dist/core/components/hyperlink.d.ts.map +1 -1
- package/dist/core/components/hyperlink.js +22 -11
- package/dist/core/components/hyperlink.js.map +1 -1
- package/dist/core/components/index.d.ts +7 -0
- package/dist/core/components/index.d.ts.map +1 -1
- package/dist/core/components/index.js +7 -0
- package/dist/core/components/index.js.map +1 -1
- package/dist/core/components/kbd.d.ts +14 -0
- package/dist/core/components/kbd.d.ts.map +1 -1
- package/dist/core/components/kbd.js +13 -6
- package/dist/core/components/kbd.js.map +1 -1
- package/dist/core/components/log.d.ts +20 -0
- package/dist/core/components/log.d.ts.map +1 -1
- package/dist/core/components/log.js +24 -11
- package/dist/core/components/log.js.map +1 -1
- package/dist/core/components/logo.d.ts +32 -0
- package/dist/core/components/logo.d.ts.map +1 -1
- package/dist/core/components/logo.js +38 -0
- package/dist/core/components/logo.js.map +1 -1
- package/dist/core/components/markdown.d.ts +7 -1
- package/dist/core/components/markdown.d.ts.map +1 -1
- package/dist/core/components/markdown.js +76 -0
- package/dist/core/components/markdown.js.map +1 -1
- package/dist/core/components/paginator.d.ts +16 -0
- package/dist/core/components/paginator.d.ts.map +1 -1
- package/dist/core/components/paginator.js +12 -6
- package/dist/core/components/paginator.js.map +1 -1
- package/dist/core/components/progress.d.ts +55 -0
- package/dist/core/components/progress.d.ts.map +1 -1
- package/dist/core/components/progress.js +37 -6
- package/dist/core/components/progress.js.map +1 -1
- package/dist/core/components/separator.d.ts +16 -0
- package/dist/core/components/separator.d.ts.map +1 -1
- package/dist/core/components/separator.js +12 -6
- package/dist/core/components/separator.js.map +1 -1
- package/dist/core/components/skeleton.d.ts +15 -0
- package/dist/core/components/skeleton.d.ts.map +1 -1
- package/dist/core/components/skeleton.js +12 -6
- package/dist/core/components/skeleton.js.map +1 -1
- package/dist/core/components/spinner.d.ts +37 -0
- package/dist/core/components/spinner.d.ts.map +1 -1
- package/dist/core/components/spinner.js +26 -6
- package/dist/core/components/spinner.js.map +1 -1
- package/dist/core/components/stepper.d.ts +20 -0
- package/dist/core/components/stepper.d.ts.map +1 -1
- package/dist/core/components/stepper.js +16 -6
- package/dist/core/components/stepper.js.map +1 -1
- package/dist/core/components/table.d.ts +20 -0
- package/dist/core/components/table.d.ts.map +1 -1
- package/dist/core/components/table.js +31 -6
- package/dist/core/components/table.js.map +1 -1
- package/dist/core/components/tabs.d.ts +19 -0
- package/dist/core/components/tabs.d.ts.map +1 -1
- package/dist/core/components/tabs.js +19 -6
- package/dist/core/components/tabs.js.map +1 -1
- package/dist/core/components/timeline.d.ts +19 -0
- package/dist/core/components/timeline.d.ts.map +1 -1
- package/dist/core/components/timeline.js +20 -6
- package/dist/core/components/timeline.js.map +1 -1
- package/dist/core/components/tree.d.ts +19 -0
- package/dist/core/components/tree.d.ts.map +1 -1
- package/dist/core/components/tree.js +49 -11
- package/dist/core/components/tree.js.map +1 -1
- package/dist/core/detect/index.d.ts +8 -2
- package/dist/core/detect/index.d.ts.map +1 -1
- package/dist/core/detect/index.js +7 -1
- package/dist/core/detect/index.js.map +1 -1
- package/dist/core/detect/tty.d.ts +36 -0
- package/dist/core/detect/tty.d.ts.map +1 -1
- package/dist/core/detect/tty.js +34 -0
- package/dist/core/detect/tty.js.map +1 -1
- package/dist/core/forms/confirm.d.ts +14 -0
- package/dist/core/forms/confirm.d.ts.map +1 -1
- package/dist/core/forms/confirm.js +15 -5
- package/dist/core/forms/confirm.js.map +1 -1
- package/dist/core/forms/filter.d.ts +30 -0
- package/dist/core/forms/filter.d.ts.map +1 -1
- package/dist/core/forms/filter.js +67 -49
- package/dist/core/forms/filter.js.map +1 -1
- package/dist/core/forms/form-utils.d.ts +103 -0
- package/dist/core/forms/form-utils.d.ts.map +1 -0
- package/dist/core/forms/form-utils.js +135 -0
- package/dist/core/forms/form-utils.js.map +1 -0
- package/dist/core/forms/group.d.ts +12 -0
- package/dist/core/forms/group.d.ts.map +1 -1
- package/dist/core/forms/group.js +7 -0
- package/dist/core/forms/group.js.map +1 -1
- package/dist/core/forms/index.d.ts +6 -0
- package/dist/core/forms/index.d.ts.map +1 -1
- package/dist/core/forms/index.js +6 -0
- package/dist/core/forms/index.js.map +1 -1
- package/dist/core/forms/input.d.ts +17 -0
- package/dist/core/forms/input.d.ts.map +1 -1
- package/dist/core/forms/input.js +27 -15
- package/dist/core/forms/input.js.map +1 -1
- package/dist/core/forms/multiselect.d.ts +16 -0
- package/dist/core/forms/multiselect.d.ts.map +1 -1
- package/dist/core/forms/multiselect.js +54 -38
- package/dist/core/forms/multiselect.js.map +1 -1
- package/dist/core/forms/select.d.ts +17 -0
- package/dist/core/forms/select.d.ts.map +1 -1
- package/dist/core/forms/select.js +51 -37
- package/dist/core/forms/select.js.map +1 -1
- package/dist/core/forms/textarea.d.ts +19 -0
- package/dist/core/forms/textarea.d.ts.map +1 -1
- package/dist/core/forms/textarea.js +51 -47
- package/dist/core/forms/textarea.js.map +1 -1
- package/dist/core/forms/types.d.ts +41 -2
- package/dist/core/forms/types.d.ts.map +1 -1
- package/dist/core/forms/wizard.d.ts +19 -0
- package/dist/core/forms/wizard.d.ts.map +1 -1
- package/dist/core/forms/wizard.js +4 -0
- package/dist/core/forms/wizard.js.map +1 -1
- package/dist/core/resolve-ctx.d.ts +30 -0
- package/dist/core/resolve-ctx.d.ts.map +1 -0
- package/dist/core/resolve-ctx.js +43 -0
- package/dist/core/resolve-ctx.js.map +1 -0
- package/dist/core/text/clip.d.ts +21 -0
- package/dist/core/text/clip.d.ts.map +1 -0
- package/dist/core/text/clip.js +75 -0
- package/dist/core/text/clip.js.map +1 -0
- package/dist/core/text/grapheme.d.ts +15 -3
- package/dist/core/text/grapheme.d.ts.map +1 -1
- package/dist/core/text/grapheme.js +21 -3
- package/dist/core/text/grapheme.js.map +1 -1
- package/dist/core/text/index.d.ts +8 -0
- package/dist/core/text/index.d.ts.map +1 -1
- package/dist/core/text/index.js +8 -0
- package/dist/core/text/index.js.map +1 -1
- package/dist/core/theme/color.d.ts +47 -8
- package/dist/core/theme/color.d.ts.map +1 -1
- package/dist/core/theme/color.js +77 -8
- package/dist/core/theme/color.js.map +1 -1
- package/dist/core/theme/downsample.d.ts +24 -6
- package/dist/core/theme/downsample.d.ts.map +1 -1
- package/dist/core/theme/downsample.js +41 -10
- package/dist/core/theme/downsample.js.map +1 -1
- package/dist/core/theme/dtcg.d.ts +28 -2
- package/dist/core/theme/dtcg.d.ts.map +1 -1
- package/dist/core/theme/dtcg.js +112 -9
- package/dist/core/theme/dtcg.js.map +1 -1
- package/dist/core/theme/extend.d.ts +14 -0
- package/dist/core/theme/extend.d.ts.map +1 -1
- package/dist/core/theme/extend.js +14 -0
- package/dist/core/theme/extend.js.map +1 -1
- package/dist/core/theme/gradient.d.ts +16 -0
- package/dist/core/theme/gradient.d.ts.map +1 -1
- package/dist/core/theme/gradient.js +13 -0
- package/dist/core/theme/gradient.js.map +1 -1
- package/dist/core/theme/index.d.ts +7 -0
- package/dist/core/theme/index.d.ts.map +1 -1
- package/dist/core/theme/index.js +7 -0
- package/dist/core/theme/index.js.map +1 -1
- package/dist/core/theme/presets.d.ts +6 -1
- package/dist/core/theme/presets.d.ts.map +1 -1
- package/dist/core/theme/presets.js +34 -1
- package/dist/core/theme/presets.js.map +1 -1
- package/dist/core/theme/resolve.d.ts +59 -13
- package/dist/core/theme/resolve.d.ts.map +1 -1
- package/dist/core/theme/resolve.js +36 -9
- package/dist/core/theme/resolve.js.map +1 -1
- package/dist/core/theme/styled.d.ts +12 -0
- package/dist/core/theme/styled.d.ts.map +1 -1
- package/dist/core/theme/styled.js +12 -0
- package/dist/core/theme/styled.js.map +1 -1
- package/dist/core/theme/tokens.d.ts +29 -0
- package/dist/core/theme/tokens.d.ts.map +1 -1
- package/dist/factory.d.ts +18 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +11 -0
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/ports/context.d.ts +11 -0
- package/dist/ports/context.d.ts.map +1 -1
- package/dist/ports/index.d.ts +6 -1
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js +5 -0
- package/dist/ports/index.js.map +1 -1
- package/dist/ports/io.d.ts +66 -2
- package/dist/ports/io.d.ts.map +1 -1
- package/dist/ports/runtime.d.ts +11 -0
- package/dist/ports/runtime.d.ts.map +1 -1
- package/dist/ports/style.d.ts +14 -0
- package/dist/ports/style.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveCtx } from '../resolve-ctx.js';
|
|
2
|
+
import { formatFormTitle, renderNumberedOptions, terminalRenderer, formDispatch, createStyledFn, createBoldFn } from './form-utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Default case-insensitive substring matcher for filter options.
|
|
5
|
+
*
|
|
6
|
+
* Check the option label first, then fall back to keyword matches.
|
|
7
|
+
*
|
|
8
|
+
* @param query - User's search input.
|
|
9
|
+
* @param option - Option to test against.
|
|
10
|
+
* @returns `true` if the query matches the label or any keyword.
|
|
11
|
+
*/
|
|
2
12
|
function defaultMatch(query, option) {
|
|
3
13
|
const q = query.toLowerCase();
|
|
4
14
|
if (option.label.toLowerCase().includes(q))
|
|
@@ -8,33 +18,41 @@ function defaultMatch(query, option) {
|
|
|
8
18
|
}
|
|
9
19
|
return false;
|
|
10
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Prompt the user to choose one item from a filterable list.
|
|
23
|
+
*
|
|
24
|
+
* In interactive TTY mode, renders a search input that narrows the
|
|
25
|
+
* option list in real time. Falls back to a numbered list with
|
|
26
|
+
* text-based matching for pipe and accessible modes.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam T - Type of each option's value.
|
|
29
|
+
* @param options - Filter field configuration.
|
|
30
|
+
* @returns The value of the selected option.
|
|
31
|
+
* @throws {Error} If no options are provided and no defaultValue is set.
|
|
32
|
+
*/
|
|
11
33
|
export async function filter(options) {
|
|
12
34
|
if (options.options.length === 0) {
|
|
13
35
|
if (options.defaultValue !== undefined)
|
|
14
36
|
return options.defaultValue;
|
|
15
37
|
throw new Error('filter() requires at least one option, or a defaultValue');
|
|
16
38
|
}
|
|
17
|
-
const ctx = options.ctx
|
|
18
|
-
|
|
19
|
-
if (mode === 'interactive' && ctx.runtime.stdinIsTTY) {
|
|
20
|
-
return interactiveFilter(options, ctx);
|
|
21
|
-
}
|
|
22
|
-
return fallbackFilter(options, mode, ctx);
|
|
39
|
+
const ctx = resolveCtx(options.ctx);
|
|
40
|
+
return formDispatch(ctx, (c) => interactiveFilter(options, c), (c) => fallbackFilter(options, c));
|
|
23
41
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const prompt = mode === 'accessible' ? 'Enter number or search: ' : '> ';
|
|
42
|
+
/**
|
|
43
|
+
* Display options as a numbered list and accept numeric or text input.
|
|
44
|
+
*
|
|
45
|
+
* Tries numeric selection first, then falls back to text matching.
|
|
46
|
+
* Used as the fallback for non-interactive or accessible modes.
|
|
47
|
+
*
|
|
48
|
+
* @param options - Filter field configuration.
|
|
49
|
+
* @param ctx - Bijou context.
|
|
50
|
+
* @returns The value of the matched or selected option.
|
|
51
|
+
*/
|
|
52
|
+
async function fallbackFilter(options, ctx) {
|
|
53
|
+
ctx.io.write(formatFormTitle(options.title, ctx) + '\n');
|
|
54
|
+
renderNumberedOptions(options.options, ctx);
|
|
55
|
+
const prompt = ctx.mode === 'accessible' ? 'Enter number or search: ' : '> ';
|
|
38
56
|
const answer = await ctx.io.question(prompt);
|
|
39
57
|
const trimmed = answer.trim();
|
|
40
58
|
// Try numeric selection first
|
|
@@ -51,12 +69,24 @@ async function fallbackFilter(options, mode, ctx) {
|
|
|
51
69
|
}
|
|
52
70
|
return options.defaultValue ?? options.options[0].value;
|
|
53
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Render a keyboard-navigable filter select using raw terminal input.
|
|
74
|
+
*
|
|
75
|
+
* Typing narrows the visible options in real time. Arrow keys navigate,
|
|
76
|
+
* Enter confirms, Backspace edits the query, Ctrl+C or Escape cancels.
|
|
77
|
+
*
|
|
78
|
+
* @param options - Filter field configuration.
|
|
79
|
+
* @param ctx - Bijou context.
|
|
80
|
+
* @returns The value of the selected (or default/first) option.
|
|
81
|
+
*/
|
|
54
82
|
async function interactiveFilter(options, ctx) {
|
|
55
83
|
const noColor = ctx.theme.noColor;
|
|
56
84
|
const t = ctx.theme;
|
|
57
|
-
const styledFn = (
|
|
85
|
+
const styledFn = createStyledFn(ctx);
|
|
86
|
+
const boldFn = createBoldFn(ctx);
|
|
58
87
|
const matchFn = options.match ?? defaultMatch;
|
|
59
88
|
const maxVisible = options.maxVisible ?? 7;
|
|
89
|
+
const term = terminalRenderer(ctx);
|
|
60
90
|
let query = '';
|
|
61
91
|
let cursor = 0;
|
|
62
92
|
let filtered = [...options.options];
|
|
@@ -76,11 +106,9 @@ async function interactiveFilter(options, ctx) {
|
|
|
76
106
|
return 2 + Math.min(filtered.length, maxVisible) + 1; // header + filter input + items + status
|
|
77
107
|
}
|
|
78
108
|
function render() {
|
|
79
|
-
const label =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
ctx.io.write(`\x1b[?25l`);
|
|
83
|
-
ctx.io.write(`\r\x1b[K${label}\n`);
|
|
109
|
+
const label = formatFormTitle(options.title, ctx);
|
|
110
|
+
term.hideCursor();
|
|
111
|
+
term.writeLine(label);
|
|
84
112
|
// Filter input
|
|
85
113
|
const filterDisplay = query || (options.placeholder ? styledFn(t.theme.semantic.muted, options.placeholder) : '');
|
|
86
114
|
ctx.io.write(`\x1b[K ${styledFn(t.theme.semantic.info, '/')} ${filterDisplay}\n`);
|
|
@@ -91,7 +119,7 @@ async function interactiveFilter(options, ctx) {
|
|
|
91
119
|
const isCurrent = i === cursor;
|
|
92
120
|
const prefix = isCurrent ? '❯' : ' ';
|
|
93
121
|
if (isCurrent && !noColor) {
|
|
94
|
-
ctx.io.write(`\x1b[K ${styledFn(t.theme.semantic.info, prefix)} ${
|
|
122
|
+
ctx.io.write(`\x1b[K ${styledFn(t.theme.semantic.info, prefix)} ${boldFn(opt.label)}\n`);
|
|
95
123
|
}
|
|
96
124
|
else {
|
|
97
125
|
ctx.io.write(`\x1b[K ${prefix} ${opt.label}\n`);
|
|
@@ -103,22 +131,22 @@ async function interactiveFilter(options, ctx) {
|
|
|
103
131
|
}
|
|
104
132
|
function clearRender() {
|
|
105
133
|
const total = renderLineCount();
|
|
106
|
-
|
|
134
|
+
term.moveUp(total);
|
|
135
|
+
}
|
|
136
|
+
function clearAndRerender(prevLineCount) {
|
|
137
|
+
term.moveUp(prevLineCount);
|
|
138
|
+
term.clearBlock(prevLineCount);
|
|
139
|
+
render();
|
|
107
140
|
}
|
|
108
141
|
function cleanup() {
|
|
109
142
|
const total = renderLineCount();
|
|
110
|
-
// Move up and clear all rendered lines
|
|
111
143
|
clearRender();
|
|
112
|
-
|
|
113
|
-
ctx.io.write(`\x1b[K\n`);
|
|
114
|
-
ctx.io.write(`\x1b[${total}A`);
|
|
144
|
+
term.clearBlock(total);
|
|
115
145
|
const selected = filtered[cursor];
|
|
116
146
|
const selectedLabel = selected ? selected.label : '(none)';
|
|
117
|
-
const label =
|
|
118
|
-
? `? ${options.title} ${selectedLabel}`
|
|
119
|
-
: styledFn(t.theme.semantic.info, '? ') + ctx.style.bold(options.title) + ' ' + styledFn(t.theme.semantic.info, selectedLabel);
|
|
147
|
+
const label = formatFormTitle(options.title, ctx) + ' ' + styledFn(t.theme.semantic.info, selectedLabel);
|
|
120
148
|
ctx.io.write(`\x1b[K${label}\n`);
|
|
121
|
-
|
|
149
|
+
term.showCursor();
|
|
122
150
|
}
|
|
123
151
|
render();
|
|
124
152
|
return new Promise((resolve) => {
|
|
@@ -175,12 +203,7 @@ async function interactiveFilter(options, ctx) {
|
|
|
175
203
|
const prevLineCount = renderLineCount();
|
|
176
204
|
query = query.slice(0, -1);
|
|
177
205
|
applyFilter();
|
|
178
|
-
|
|
179
|
-
ctx.io.write(`\x1b[${prevLineCount}A`);
|
|
180
|
-
for (let i = 0; i < prevLineCount; i++)
|
|
181
|
-
ctx.io.write(`\x1b[K\n`);
|
|
182
|
-
ctx.io.write(`\x1b[${prevLineCount}A`);
|
|
183
|
-
render();
|
|
206
|
+
clearAndRerender(prevLineCount);
|
|
184
207
|
}
|
|
185
208
|
return;
|
|
186
209
|
}
|
|
@@ -189,12 +212,7 @@ async function interactiveFilter(options, ctx) {
|
|
|
189
212
|
const prevLineCount = renderLineCount();
|
|
190
213
|
query += key;
|
|
191
214
|
applyFilter();
|
|
192
|
-
|
|
193
|
-
ctx.io.write(`\x1b[${prevLineCount}A`);
|
|
194
|
-
for (let i = 0; i < prevLineCount; i++)
|
|
195
|
-
ctx.io.write(`\x1b[K\n`);
|
|
196
|
-
ctx.io.write(`\x1b[${prevLineCount}A`);
|
|
197
|
-
render();
|
|
215
|
+
clearAndRerender(prevLineCount);
|
|
198
216
|
}
|
|
199
217
|
});
|
|
200
218
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/core/forms/filter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/core/forms/filter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAkCvI;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAI,KAAa,EAAE,MAAuB;IAC7D,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAC9B,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACxD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAI,OAAyB;IACvD,IAAI,O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C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;gBACnC,MAAM,aAAa,GAAG,eAAe,EAAE,CAAC;gBACxC,KAAK,IAAI,GAAG,CAAC;gBACb,WAAW,EAAE,CAAC;gBACd,gBAAgB,CAAC,aAAa,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared form utilities extracted from duplicated patterns across
|
|
3
|
+
* select, multiselect, filter, textarea, input, and confirm.
|
|
4
|
+
*
|
|
5
|
+
* These are internal helpers — not exported from the public barrel.
|
|
6
|
+
*
|
|
7
|
+
* @module core/forms/form-utils
|
|
8
|
+
*/
|
|
9
|
+
import type { BijouContext } from '../../ports/context.js';
|
|
10
|
+
import type { TokenValue } from '../theme/tokens.js';
|
|
11
|
+
/**
|
|
12
|
+
* Format a form title with the `?` prefix and theme-aware styling.
|
|
13
|
+
*
|
|
14
|
+
* Returns `? title` with styling in color mode, or plain `? title`
|
|
15
|
+
* in noColor/accessible modes. The `?` prefix is always included
|
|
16
|
+
* for visual parity across modes.
|
|
17
|
+
*
|
|
18
|
+
* @param title - The form prompt text.
|
|
19
|
+
* @param ctx - Bijou context for styling and mode detection.
|
|
20
|
+
* @returns The formatted title string (no trailing newline).
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatFormTitle(title: string, ctx: BijouContext): string;
|
|
23
|
+
/**
|
|
24
|
+
* Write a styled validation error message to the output.
|
|
25
|
+
*
|
|
26
|
+
* Applies `semantic.error` styling in color mode, plain text in
|
|
27
|
+
* noColor/accessible modes.
|
|
28
|
+
*
|
|
29
|
+
* @param message - The error message to display.
|
|
30
|
+
* @param ctx - Bijou context for styling and mode detection.
|
|
31
|
+
*/
|
|
32
|
+
export declare function writeValidationError(message: string, ctx: BijouContext): void;
|
|
33
|
+
/**
|
|
34
|
+
* Render a numbered list of options to the output.
|
|
35
|
+
*
|
|
36
|
+
* Used by form fallback modes (select, multiselect, filter) when
|
|
37
|
+
* interactive arrow-key navigation is unavailable.
|
|
38
|
+
*
|
|
39
|
+
* @param options - Array of options with `label` and optional `description`.
|
|
40
|
+
* @param ctx - Bijou context for output.
|
|
41
|
+
*/
|
|
42
|
+
export declare function renderNumberedOptions(options: ReadonlyArray<{
|
|
43
|
+
label: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
}>, ctx: BijouContext): void;
|
|
46
|
+
/**
|
|
47
|
+
* ANSI terminal rendering utilities for interactive form components.
|
|
48
|
+
*
|
|
49
|
+
* Provides cursor control helpers that replace the duplicated raw ANSI
|
|
50
|
+
* escape sequences scattered across form interactive modes.
|
|
51
|
+
*/
|
|
52
|
+
export interface TerminalRenderer {
|
|
53
|
+
/** Hide the terminal cursor. */
|
|
54
|
+
hideCursor(): void;
|
|
55
|
+
/** Show the terminal cursor. */
|
|
56
|
+
showCursor(): void;
|
|
57
|
+
/** Clear the current line and write text followed by a newline. */
|
|
58
|
+
writeLine(text: string): void;
|
|
59
|
+
/** Move the cursor up by the given number of lines. */
|
|
60
|
+
moveUp(lines: number): void;
|
|
61
|
+
/** Clear a block of N lines and return the cursor to the top of the block. */
|
|
62
|
+
clearBlock(lineCount: number): void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a {@link TerminalRenderer} that writes ANSI escape sequences
|
|
66
|
+
* to `ctx.io`.
|
|
67
|
+
*
|
|
68
|
+
* @param ctx - Bijou context for I/O access.
|
|
69
|
+
* @returns A renderer with cursor control methods.
|
|
70
|
+
*/
|
|
71
|
+
export declare function terminalRenderer(ctx: BijouContext): TerminalRenderer;
|
|
72
|
+
/**
|
|
73
|
+
* Create a noColor-safe styling function.
|
|
74
|
+
*
|
|
75
|
+
* Returns an identity function `(token, text) => text` when `noColor`
|
|
76
|
+
* is true or mode is `accessible`, or `ctx.style.styled` otherwise.
|
|
77
|
+
* Eliminates per-callsite `noColor ? text : styledFn(token, text)` guards.
|
|
78
|
+
*
|
|
79
|
+
* @param ctx - Bijou context for noColor/accessible detection and style access.
|
|
80
|
+
* @returns A function `(token, text) => string`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function createStyledFn(ctx: BijouContext): (token: TokenValue, text: string) => string;
|
|
83
|
+
/**
|
|
84
|
+
* Create a noColor-safe bold function.
|
|
85
|
+
*
|
|
86
|
+
* Returns an identity function when `noColor` is true or mode is
|
|
87
|
+
* `accessible`, or `ctx.style.bold` otherwise.
|
|
88
|
+
*
|
|
89
|
+
* @param ctx - Bijou context for noColor/accessible detection and style access.
|
|
90
|
+
* @returns A function `(text) => string`.
|
|
91
|
+
*/
|
|
92
|
+
export declare function createBoldFn(ctx: BijouContext): (text: string) => string;
|
|
93
|
+
/**
|
|
94
|
+
* Route a form to its interactive or fallback handler based on
|
|
95
|
+
* output mode and TTY state.
|
|
96
|
+
*
|
|
97
|
+
* @param ctx - Resolved bijou context.
|
|
98
|
+
* @param interactive - Handler for interactive TTY mode.
|
|
99
|
+
* @param fallback - Handler for non-interactive / pipe / static / accessible modes.
|
|
100
|
+
* @returns The result from whichever handler was selected.
|
|
101
|
+
*/
|
|
102
|
+
export declare function formDispatch<T>(ctx: BijouContext, interactive: (ctx: BijouContext) => Promise<T>, fallback: (ctx: BijouContext) => Promise<T>): Promise<T>;
|
|
103
|
+
//# sourceMappingURL=form-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-utils.d.ts","sourceRoot":"","sources":["../../../src/core/forms/form-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAA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CAAC,CAAC,CAAC,CAKZ"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared form utilities extracted from duplicated patterns across
|
|
3
|
+
* select, multiselect, filter, textarea, input, and confirm.
|
|
4
|
+
*
|
|
5
|
+
* These are internal helpers — not exported from the public barrel.
|
|
6
|
+
*
|
|
7
|
+
* @module core/forms/form-utils
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Format a form title with the `?` prefix and theme-aware styling.
|
|
11
|
+
*
|
|
12
|
+
* Returns `? title` with styling in color mode, or plain `? title`
|
|
13
|
+
* in noColor/accessible modes. The `?` prefix is always included
|
|
14
|
+
* for visual parity across modes.
|
|
15
|
+
*
|
|
16
|
+
* @param title - The form prompt text.
|
|
17
|
+
* @param ctx - Bijou context for styling and mode detection.
|
|
18
|
+
* @returns The formatted title string (no trailing newline).
|
|
19
|
+
*/
|
|
20
|
+
export function formatFormTitle(title, ctx) {
|
|
21
|
+
if (ctx.theme.noColor || ctx.mode === 'accessible') {
|
|
22
|
+
return `? ${title}`;
|
|
23
|
+
}
|
|
24
|
+
return ctx.style.styled(ctx.theme.theme.semantic.info, '? ') + ctx.style.bold(title);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Write a styled validation error message to the output.
|
|
28
|
+
*
|
|
29
|
+
* Applies `semantic.error` styling in color mode, plain text in
|
|
30
|
+
* noColor/accessible modes.
|
|
31
|
+
*
|
|
32
|
+
* @param message - The error message to display.
|
|
33
|
+
* @param ctx - Bijou context for styling and mode detection.
|
|
34
|
+
*/
|
|
35
|
+
export function writeValidationError(message, ctx) {
|
|
36
|
+
if (ctx.theme.noColor || ctx.mode === 'accessible') {
|
|
37
|
+
ctx.io.write(message + '\n');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
ctx.io.write(ctx.style.styled(ctx.theme.theme.semantic.error, message) + '\n');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Render a numbered list of options to the output.
|
|
45
|
+
*
|
|
46
|
+
* Used by form fallback modes (select, multiselect, filter) when
|
|
47
|
+
* interactive arrow-key navigation is unavailable.
|
|
48
|
+
*
|
|
49
|
+
* @param options - Array of options with `label` and optional `description`.
|
|
50
|
+
* @param ctx - Bijou context for output.
|
|
51
|
+
*/
|
|
52
|
+
export function renderNumberedOptions(options, ctx) {
|
|
53
|
+
for (let i = 0; i < options.length; i++) {
|
|
54
|
+
const opt = options[i];
|
|
55
|
+
const desc = opt.description ? ` \u2014 ${opt.description}` : '';
|
|
56
|
+
ctx.io.write(` ${i + 1}. ${opt.label}${desc}\n`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a {@link TerminalRenderer} that writes ANSI escape sequences
|
|
61
|
+
* to `ctx.io`.
|
|
62
|
+
*
|
|
63
|
+
* @param ctx - Bijou context for I/O access.
|
|
64
|
+
* @returns A renderer with cursor control methods.
|
|
65
|
+
*/
|
|
66
|
+
export function terminalRenderer(ctx) {
|
|
67
|
+
return {
|
|
68
|
+
hideCursor() {
|
|
69
|
+
ctx.io.write('\x1b[?25l');
|
|
70
|
+
},
|
|
71
|
+
showCursor() {
|
|
72
|
+
ctx.io.write('\x1b[?25h');
|
|
73
|
+
},
|
|
74
|
+
writeLine(text) {
|
|
75
|
+
ctx.io.write(`\r\x1b[K${text}\n`);
|
|
76
|
+
},
|
|
77
|
+
moveUp(lines) {
|
|
78
|
+
if (lines <= 0)
|
|
79
|
+
return;
|
|
80
|
+
ctx.io.write(`\x1b[${lines}A`);
|
|
81
|
+
},
|
|
82
|
+
clearBlock(lineCount) {
|
|
83
|
+
if (lineCount <= 0)
|
|
84
|
+
return;
|
|
85
|
+
for (let i = 0; i < lineCount; i++)
|
|
86
|
+
ctx.io.write('\x1b[K\n');
|
|
87
|
+
ctx.io.write(`\x1b[${lineCount}A`);
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a noColor-safe styling function.
|
|
93
|
+
*
|
|
94
|
+
* Returns an identity function `(token, text) => text` when `noColor`
|
|
95
|
+
* is true or mode is `accessible`, or `ctx.style.styled` otherwise.
|
|
96
|
+
* Eliminates per-callsite `noColor ? text : styledFn(token, text)` guards.
|
|
97
|
+
*
|
|
98
|
+
* @param ctx - Bijou context for noColor/accessible detection and style access.
|
|
99
|
+
* @returns A function `(token, text) => string`.
|
|
100
|
+
*/
|
|
101
|
+
export function createStyledFn(ctx) {
|
|
102
|
+
if (ctx.theme.noColor || ctx.mode === 'accessible')
|
|
103
|
+
return (_token, text) => text;
|
|
104
|
+
return (token, text) => ctx.style.styled(token, text);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create a noColor-safe bold function.
|
|
108
|
+
*
|
|
109
|
+
* Returns an identity function when `noColor` is true or mode is
|
|
110
|
+
* `accessible`, or `ctx.style.bold` otherwise.
|
|
111
|
+
*
|
|
112
|
+
* @param ctx - Bijou context for noColor/accessible detection and style access.
|
|
113
|
+
* @returns A function `(text) => string`.
|
|
114
|
+
*/
|
|
115
|
+
export function createBoldFn(ctx) {
|
|
116
|
+
if (ctx.theme.noColor || ctx.mode === 'accessible')
|
|
117
|
+
return (text) => text;
|
|
118
|
+
return (text) => ctx.style.bold(text);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Route a form to its interactive or fallback handler based on
|
|
122
|
+
* output mode and TTY state.
|
|
123
|
+
*
|
|
124
|
+
* @param ctx - Resolved bijou context.
|
|
125
|
+
* @param interactive - Handler for interactive TTY mode.
|
|
126
|
+
* @param fallback - Handler for non-interactive / pipe / static / accessible modes.
|
|
127
|
+
* @returns The result from whichever handler was selected.
|
|
128
|
+
*/
|
|
129
|
+
export function formDispatch(ctx, interactive, fallback) {
|
|
130
|
+
if (ctx.mode === 'interactive' && ctx.runtime.stdinIsTTY && ctx.runtime.stdoutIsTTY) {
|
|
131
|
+
return interactive(ctx);
|
|
132
|
+
}
|
|
133
|
+
return fallback(ctx);
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=form-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-utils.js","sourceRoot":"","sources":["../../../src/core/forms/form-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,GAAiB;IAC9D,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACnD,OAAO,KAAK,KAAK,EAAE,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,GAAiB;IACrE,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACnD,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA+D,EAC/D,GAAiB;IAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EA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,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,CAAC,MAAkB,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC;IACtG,OAAO,CAAC,KAAiB,EAAE,IAAY,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,GAAiB;IAC5C,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC;IAClF,OAAO,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAiB,EACjB,WAA8C,EAC9C,QAA2C;IAE3C,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACpF,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import type { GroupFieldResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Async factory that produces a single field value.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - Type of the value produced.
|
|
6
|
+
*/
|
|
2
7
|
type FieldFn<T> = () => Promise<T>;
|
|
3
8
|
/**
|
|
4
9
|
* Chain multiple form fields together, collecting results into an object.
|
|
5
10
|
*
|
|
11
|
+
* Fields are executed sequentially in key order. Each field function runs
|
|
12
|
+
* independently and its return value is stored under the corresponding key.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam T - Record type mapping field keys to their value types.
|
|
15
|
+
* @param fields - Map of field keys to async factory functions.
|
|
16
|
+
* @returns A {@link GroupFieldResult} containing all collected values.
|
|
17
|
+
*
|
|
6
18
|
* @example
|
|
7
19
|
* ```ts
|
|
8
20
|
* const result = await group({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../src/core/forms/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,KAAK,OAAO,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnC
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../src/core/forms/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;GAIG;AACH,KAAK,OAAO,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,MAAM,EAAE;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACxC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAS9B"}
|
package/dist/core/forms/group.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Chain multiple form fields together, collecting results into an object.
|
|
3
3
|
*
|
|
4
|
+
* Fields are executed sequentially in key order. Each field function runs
|
|
5
|
+
* independently and its return value is stored under the corresponding key.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam T - Record type mapping field keys to their value types.
|
|
8
|
+
* @param fields - Map of field keys to async factory functions.
|
|
9
|
+
* @returns A {@link GroupFieldResult} containing all collected values.
|
|
10
|
+
*
|
|
4
11
|
* @example
|
|
5
12
|
* ```ts
|
|
6
13
|
* const result = await group({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../../src/core/forms/group.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../../src/core/forms/group.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,MAAyC;IAEzC,MAAM,MAAM,GAAG,EAAO,CAAC;IAEvB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAmB,EAAE,CAAC;QACxD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forms module -- interactive CLI prompts (input, select, multiselect,
|
|
3
|
+
* confirm, textarea, filter) and combinators (group, wizard).
|
|
4
|
+
*
|
|
5
|
+
* @module core/forms
|
|
6
|
+
*/
|
|
1
7
|
export type { ValidationResult, Validator, FieldOptions, SelectOption, SelectFieldOptions, ConfirmFieldOptions, GroupFieldResult, } from './types.js';
|
|
2
8
|
export { input } from './input.js';
|
|
3
9
|
export type { InputOptions } from './input.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/forms/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,O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OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/core/forms/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forms module -- interactive CLI prompts (input, select, multiselect,
|
|
3
|
+
* confirm, textarea, filter) and combinators (group, wizard).
|
|
4
|
+
*
|
|
5
|
+
* @module core/forms
|
|
6
|
+
*/
|
|
1
7
|
export { input } from './input.js';
|
|
2
8
|
export { select } from './select.js';
|
|
3
9
|
export { multiselect } from './multiselect.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/forms/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/forms/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import type { FieldOptions } from './types.js';
|
|
2
2
|
import type { BijouContext } from '../../ports/context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for the text input field.
|
|
5
|
+
*/
|
|
3
6
|
export interface InputOptions extends FieldOptions<string> {
|
|
7
|
+
/** Placeholder text shown when the input is empty. */
|
|
4
8
|
placeholder?: string;
|
|
9
|
+
/** Bijou context for IO, styling, and mode detection. */
|
|
5
10
|
ctx?: BijouContext;
|
|
6
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Prompt the user for a single-line text input.
|
|
14
|
+
*
|
|
15
|
+
* Display adapts to the current output mode (interactive, accessible, pipe).
|
|
16
|
+
* Runs validation and required-field checks after the user responds.
|
|
17
|
+
*
|
|
18
|
+
* @remarks Validation is non-blocking — errors are written to output but the
|
|
19
|
+
* entered value is always returned.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Input field configuration.
|
|
22
|
+
* @returns The trimmed user input, or the default value if none was provided.
|
|
23
|
+
*/
|
|
7
24
|
export declare function input(options: InputOptions): Promise<string>;
|
|
8
25
|
//# sourceMappingURL=input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/core/forms/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/core/forms/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,YAAY,CAAC,MAAM,CAAC;IACxD,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBlE"}
|