@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,55 +1,65 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveCtx } from '../resolve-ctx.js';
|
|
2
|
+
import { formatFormTitle, writeValidationError, terminalRenderer, formDispatch, createStyledFn } from './form-utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Prompt the user for multi-line text input.
|
|
5
|
+
*
|
|
6
|
+
* In interactive TTY mode, renders a scrollable editor with cursor
|
|
7
|
+
* navigation, optional line numbers, and a character count status bar.
|
|
8
|
+
* Falls back to a single-line question for pipe and accessible modes.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Textarea field configuration.
|
|
11
|
+
* @returns The entered text (newline-joined), or the default/empty string on cancel.
|
|
12
|
+
*/
|
|
2
13
|
export async function textarea(options) {
|
|
3
|
-
const ctx = options.ctx
|
|
4
|
-
|
|
5
|
-
if (mode === 'interactive' && ctx.runtime.stdinIsTTY) {
|
|
6
|
-
return interactiveTextarea(options, ctx);
|
|
7
|
-
}
|
|
8
|
-
return fallbackTextarea(options, mode, ctx);
|
|
14
|
+
const ctx = resolveCtx(options.ctx);
|
|
15
|
+
return formDispatch(ctx, (c) => interactiveTextarea(options, c), (c) => fallbackTextarea(options, c));
|
|
9
16
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Non-interactive textarea fallback that reads a single line of input.
|
|
19
|
+
*
|
|
20
|
+
* Used when the terminal is not a TTY or the mode is pipe/accessible.
|
|
21
|
+
* Runs required-field and custom validation checks after input.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Textarea field configuration.
|
|
24
|
+
* @param ctx - Bijou context.
|
|
25
|
+
* @returns The trimmed input or default value.
|
|
26
|
+
*/
|
|
27
|
+
async function fallbackTextarea(options, ctx) {
|
|
28
|
+
ctx.io.write(formatFormTitle(options.title, ctx) + '\n');
|
|
29
|
+
const prompt = ctx.mode === 'accessible'
|
|
30
|
+
? 'Enter text: '
|
|
21
31
|
: '> ';
|
|
22
32
|
const answer = await ctx.io.question(prompt);
|
|
23
33
|
const value = answer.trim() || options.defaultValue || '';
|
|
24
34
|
if (options.required && value === '') {
|
|
25
|
-
|
|
26
|
-
if (noColor || mode === 'accessible') {
|
|
27
|
-
ctx.io.write(msg + '\n');
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
ctx.io.write(styledFn(ctx.theme.theme.semantic.error, msg) + '\n');
|
|
31
|
-
}
|
|
35
|
+
writeValidationError('This field is required.', ctx);
|
|
32
36
|
}
|
|
33
37
|
if (options.validate) {
|
|
34
38
|
const result = options.validate(value);
|
|
35
39
|
if (!result.valid && result.message) {
|
|
36
|
-
|
|
37
|
-
ctx.io.write(result.message + '\n');
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
ctx.io.write(styledFn(ctx.theme.theme.semantic.error, result.message) + '\n');
|
|
41
|
-
}
|
|
40
|
+
writeValidationError(result.message, ctx);
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
return value;
|
|
45
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Render a full interactive textarea editor using raw terminal input.
|
|
47
|
+
*
|
|
48
|
+
* Supports arrow-key cursor movement, scrolling, line wrapping,
|
|
49
|
+
* optional line numbers, placeholder text, and a max-length guard.
|
|
50
|
+
* Ctrl+D submits; Ctrl+C or Escape cancels.
|
|
51
|
+
*
|
|
52
|
+
* @param options - Textarea field configuration.
|
|
53
|
+
* @param ctx - Bijou context.
|
|
54
|
+
* @returns The entered text (newline-joined), or the default value on cancel.
|
|
55
|
+
*/
|
|
46
56
|
async function interactiveTextarea(options, ctx) {
|
|
47
|
-
const noColor = ctx.theme.noColor;
|
|
48
57
|
const t = ctx.theme;
|
|
49
|
-
const styledFn = (
|
|
58
|
+
const styledFn = createStyledFn(ctx);
|
|
50
59
|
const height = options.height ?? 6;
|
|
51
60
|
const renderWidth = options.width ?? 80;
|
|
52
61
|
const showLineNumbers = options.showLineNumbers ?? false;
|
|
62
|
+
const term = terminalRenderer(ctx);
|
|
53
63
|
let lines = [''];
|
|
54
64
|
let cursorRow = 0;
|
|
55
65
|
let cursorCol = 0;
|
|
@@ -64,12 +74,10 @@ async function interactiveTextarea(options, ctx) {
|
|
|
64
74
|
scrollY = cursorRow - height + 1;
|
|
65
75
|
}
|
|
66
76
|
function render() {
|
|
67
|
-
const label =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
ctx.io.write(`\x1b[?25l`);
|
|
72
|
-
ctx.io.write(`\r\x1b[K${label}${hint}\n`);
|
|
77
|
+
const label = formatFormTitle(options.title, ctx);
|
|
78
|
+
const hint = styledFn(t.theme.semantic.muted, ' (Ctrl+D to submit, Ctrl+C/Esc to cancel)');
|
|
79
|
+
term.hideCursor();
|
|
80
|
+
term.writeLine(`${label}${hint}`);
|
|
73
81
|
const vis = visibleLines();
|
|
74
82
|
const prefixWidth = showLineNumbers ? 6 : 2; // " 1 │ " or " "
|
|
75
83
|
const contentWidth = Math.max(1, renderWidth - prefixWidth);
|
|
@@ -97,23 +105,19 @@ async function interactiveTextarea(options, ctx) {
|
|
|
97
105
|
}
|
|
98
106
|
function clearRender() {
|
|
99
107
|
const totalLines = height + 2; // header + visible lines + status
|
|
100
|
-
|
|
108
|
+
term.moveUp(totalLines);
|
|
101
109
|
}
|
|
102
110
|
function cleanup(submitted) {
|
|
103
111
|
clearRender();
|
|
104
112
|
const totalLines = height + 2;
|
|
105
|
-
|
|
106
|
-
ctx.io.write(`\x1b[K\n`);
|
|
107
|
-
ctx.io.write(`\x1b[${totalLines}A`);
|
|
113
|
+
term.clearBlock(totalLines);
|
|
108
114
|
const value = submitted ? lines.join('\n') : '';
|
|
109
115
|
const summary = value
|
|
110
116
|
? (value.includes('\n') ? `${value.split('\n').length} lines` : value)
|
|
111
117
|
: '(cancelled)';
|
|
112
|
-
const label =
|
|
113
|
-
? `? ${options.title} ${summary}`
|
|
114
|
-
: styledFn(t.theme.semantic.info, '? ') + ctx.style.bold(options.title) + ' ' + styledFn(t.theme.semantic.info, summary);
|
|
118
|
+
const label = formatFormTitle(options.title, ctx) + ' ' + styledFn(t.theme.semantic.info, summary);
|
|
115
119
|
ctx.io.write(`\x1b[K${label}\n`);
|
|
116
|
-
|
|
120
|
+
term.showCursor();
|
|
117
121
|
}
|
|
118
122
|
render();
|
|
119
123
|
return new Promise((resolve) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../../src/core/forms/textarea.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../../src/core/forms/textarea.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAoBxH;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAwB;IACrD,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEpC,OAAO,YAAY,CACjB,GAAG,EACH,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAC,EACtC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,CACpC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,KAAK,UAAU,gBAAgB,CAAC,OAAwB,EAAE,GAAiB;IACzE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,KAAK,YAAY;QACtC,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,IAAI,CAAC;IACT,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,QAAQ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,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,32 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of a field validation check.
|
|
3
|
+
*/
|
|
1
4
|
export interface ValidationResult {
|
|
5
|
+
/** Whether the value passed validation. */
|
|
2
6
|
valid: boolean;
|
|
7
|
+
/** Human-readable error message when validation fails. */
|
|
3
8
|
message?: string;
|
|
4
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Validate a field value and return a {@link ValidationResult}.
|
|
12
|
+
*
|
|
13
|
+
* @typeParam T - Type of the value being validated.
|
|
14
|
+
*/
|
|
5
15
|
export type Validator<T> = (value: T) => ValidationResult;
|
|
16
|
+
/**
|
|
17
|
+
* Base options shared by all form field types.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam T - Type of the field's value.
|
|
20
|
+
*/
|
|
6
21
|
export interface FieldOptions<T> {
|
|
7
22
|
/** Prompt title shown to the user. */
|
|
8
23
|
title: string;
|
|
9
|
-
/** Default value. */
|
|
24
|
+
/** Default value returned when the user provides no input. */
|
|
10
25
|
defaultValue?: T;
|
|
11
26
|
/** Whether the field is required. Default: false. */
|
|
12
27
|
required?: boolean;
|
|
13
|
-
/** Validation function. */
|
|
28
|
+
/** Validation function applied to the field value after input. */
|
|
14
29
|
validate?: Validator<T>;
|
|
15
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Single selectable option used in select and multiselect fields.
|
|
33
|
+
*
|
|
34
|
+
* @typeParam T - Type of the option's value.
|
|
35
|
+
*/
|
|
16
36
|
export interface SelectOption<T = string> {
|
|
37
|
+
/** Display label shown in the option list. */
|
|
17
38
|
label: string;
|
|
39
|
+
/** Value returned when this option is selected. */
|
|
18
40
|
value: T;
|
|
41
|
+
/** Optional description displayed beside the label. */
|
|
19
42
|
description?: string;
|
|
20
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Options for select-style fields that present a list of choices.
|
|
46
|
+
*
|
|
47
|
+
* @typeParam T - Type of each option's value.
|
|
48
|
+
*/
|
|
21
49
|
export interface SelectFieldOptions<T = string> extends FieldOptions<T> {
|
|
50
|
+
/** List of selectable options. */
|
|
22
51
|
options: SelectOption<T>[];
|
|
23
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for a yes/no confirmation field.
|
|
55
|
+
*/
|
|
24
56
|
export interface ConfirmFieldOptions extends FieldOptions<boolean> {
|
|
25
57
|
/** Which option is the default. Default: true (yes). */
|
|
26
58
|
defaultValue?: boolean;
|
|
27
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Result returned by {@link group} and {@link wizard} form combinators.
|
|
62
|
+
*
|
|
63
|
+
* @typeParam T - Record type mapping field keys to their collected values.
|
|
64
|
+
*/
|
|
28
65
|
export interface GroupFieldResult<T extends Record<string, unknown>> {
|
|
66
|
+
/** Collected values keyed by field name. */
|
|
29
67
|
values: T;
|
|
68
|
+
/** Whether the user cancelled the form before completion. */
|
|
30
69
|
cancelled: boolean;
|
|
31
70
|
}
|
|
32
71
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/forms/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,gBAAgB,CAAC;AAE1D,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/forms/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,gBAAgB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,MAAM;IACtC,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,KAAK,EAAE,CAAC,CAAC;IACT,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,MAAM,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;IACrE,kCAAkC;IAClC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,YAAY,CAAC,OAAO,CAAC;IAChE,wDAAwD;IACxD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,4CAA4C;IAC5C,MAAM,EAAE,CAAC,CAAC;IACV,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import type { GroupFieldResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Single step in a multi-step wizard form.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - Record type of the wizard's accumulated values.
|
|
6
|
+
* @typeParam K - Key within T that this step populates.
|
|
7
|
+
*/
|
|
2
8
|
export interface WizardStep<T, K extends keyof T = keyof T> {
|
|
9
|
+
/** Key in the result record where this step's value is stored. */
|
|
3
10
|
key: K;
|
|
11
|
+
/** Async field function that receives previously collected values and returns this step's value. */
|
|
4
12
|
field: (values: Partial<T>) => Promise<T[K]>;
|
|
13
|
+
/** Predicate that, when returning `true`, causes this step to be skipped. */
|
|
5
14
|
skip?: (values: Partial<T>) => boolean;
|
|
6
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for a multi-step wizard form.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam T - Record type of the wizard's accumulated values.
|
|
20
|
+
*/
|
|
7
21
|
export interface WizardOptions<T extends Record<string, unknown>> {
|
|
22
|
+
/** Ordered list of wizard steps to execute. */
|
|
8
23
|
steps: WizardStep<T>[];
|
|
9
24
|
}
|
|
10
25
|
/**
|
|
@@ -12,6 +27,10 @@ export interface WizardOptions<T extends Record<string, unknown>> {
|
|
|
12
27
|
* values to each step's `field` function. Steps can be conditionally skipped
|
|
13
28
|
* via the `skip` predicate.
|
|
14
29
|
*
|
|
30
|
+
* @typeParam T - Record type mapping step keys to their value types.
|
|
31
|
+
* @param options - Wizard configuration containing the ordered step list.
|
|
32
|
+
* @returns A {@link GroupFieldResult} containing all collected values.
|
|
33
|
+
*
|
|
15
34
|
* @example
|
|
16
35
|
* ```ts
|
|
17
36
|
* const result = await wizard<{ mode: string; details: string }>({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wizard.d.ts","sourceRoot":"","sources":["../../../src/core/forms/wizard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,WAAW,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC;IACxD,GAAG,EAAE,CAAC,CAAC;IACP,KAAK,EAAE,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"}
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* values to each step's `field` function. Steps can be conditionally skipped
|
|
4
4
|
* via the `skip` predicate.
|
|
5
5
|
*
|
|
6
|
+
* @typeParam T - Record type mapping step keys to their value types.
|
|
7
|
+
* @param options - Wizard configuration containing the ordered step list.
|
|
8
|
+
* @returns A {@link GroupFieldResult} containing all collected values.
|
|
9
|
+
*
|
|
6
10
|
* @example
|
|
7
11
|
* ```ts
|
|
8
12
|
* const result = await wizard<{ mode: string; details: string }>({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wizard.js","sourceRoot":"","sources":["../../../src/core/forms/wizard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wizard.js","sourceRoot":"","sources":["../../../src/core/forms/wizard.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAyB;IAEzB,MAAM,MAAM,GAAG,EAAO,CAAC;IAEvB,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACvC,MAAkC,CAAC,IAAI,CAAC,GAAa,CAAC,GAAG,MAAM,CAAC;IACnE,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared context resolution helpers used by all bijou components.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { BijouContext } from '../ports/context.js';
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the provided context or fall back to the global default.
|
|
9
|
+
*
|
|
10
|
+
* This is the standard resolver used by most components. It throws if no
|
|
11
|
+
* context is provided and no default has been configured via
|
|
12
|
+
* {@link setDefaultContext}.
|
|
13
|
+
*
|
|
14
|
+
* @param ctx - Optional context override.
|
|
15
|
+
* @returns The resolved {@link BijouContext}.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveCtx(ctx?: BijouContext): BijouContext;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a BijouContext, falling back to the global default.
|
|
20
|
+
*
|
|
21
|
+
* Unlike {@link resolveCtx}, this variant returns `undefined` instead of
|
|
22
|
+
* throwing when no context is provided and no default is configured. This
|
|
23
|
+
* allows components to degrade gracefully (e.g. before bijou-node
|
|
24
|
+
* initialisation).
|
|
25
|
+
*
|
|
26
|
+
* @param ctx - Optional explicit context.
|
|
27
|
+
* @returns The resolved {@link BijouContext}, or `undefined` if unavailable.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveSafeCtx(ctx?: BijouContext): BijouContext | undefined;
|
|
30
|
+
//# sourceMappingURL=resolve-ctx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-ctx.d.ts","sourceRoot":"","sources":["../../src/core/resolve-ctx.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,YAAY,GAAG,YAAY,CAG3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,GAAG,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,CAO3E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared context resolution helpers used by all bijou components.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { getDefaultContext } from '../context.js';
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the provided context or fall back to the global default.
|
|
9
|
+
*
|
|
10
|
+
* This is the standard resolver used by most components. It throws if no
|
|
11
|
+
* context is provided and no default has been configured via
|
|
12
|
+
* {@link setDefaultContext}.
|
|
13
|
+
*
|
|
14
|
+
* @param ctx - Optional context override.
|
|
15
|
+
* @returns The resolved {@link BijouContext}.
|
|
16
|
+
*/
|
|
17
|
+
export function resolveCtx(ctx) {
|
|
18
|
+
if (ctx)
|
|
19
|
+
return ctx;
|
|
20
|
+
return getDefaultContext();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a BijouContext, falling back to the global default.
|
|
24
|
+
*
|
|
25
|
+
* Unlike {@link resolveCtx}, this variant returns `undefined` instead of
|
|
26
|
+
* throwing when no context is provided and no default is configured. This
|
|
27
|
+
* allows components to degrade gracefully (e.g. before bijou-node
|
|
28
|
+
* initialisation).
|
|
29
|
+
*
|
|
30
|
+
* @param ctx - Optional explicit context.
|
|
31
|
+
* @returns The resolved {@link BijouContext}, or `undefined` if unavailable.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveSafeCtx(ctx) {
|
|
34
|
+
if (ctx)
|
|
35
|
+
return ctx;
|
|
36
|
+
try {
|
|
37
|
+
return getDefaultContext();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=resolve-ctx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-ctx.js","sourceRoot":"","sources":["../../src/core/resolve-ctx.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,GAAkB;IAC3C,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IACpB,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,GAAkB;IAC/C,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,iBAAiB,EAAE,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grapheme-aware text clipping for terminal display.
|
|
3
|
+
*
|
|
4
|
+
* Clips a string to a maximum visible width, preserving ANSI escapes.
|
|
5
|
+
* Won't split multi-codepoint grapheme clusters (emoji, CJK, ZWJ sequences).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Clip a string to a maximum visible width, preserving ANSI escapes.
|
|
9
|
+
*
|
|
10
|
+
* Grapheme-cluster aware: won't split multi-codepoint sequences.
|
|
11
|
+
* Appends a reset sequence (`\x1b[0m`) when clipping text that contains ANSI style escapes.
|
|
12
|
+
*
|
|
13
|
+
* O(n): pre-segments stripped text once, then walks the original string
|
|
14
|
+
* with a grapheme pointer instead of re-segmenting per character.
|
|
15
|
+
*
|
|
16
|
+
* @param str - Input string, may contain ANSI escape sequences.
|
|
17
|
+
* @param maxWidth - Maximum visible width in terminal columns.
|
|
18
|
+
* @returns The clipped string, with ANSI escapes intact and a reset appended if needed.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clipToWidth(str: string, maxWidth: number): string;
|
|
21
|
+
//# sourceMappingURL=clip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../src/core/text/clip.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAsDjE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grapheme-aware text clipping for terminal display.
|
|
3
|
+
*
|
|
4
|
+
* Clips a string to a maximum visible width, preserving ANSI escapes.
|
|
5
|
+
* Won't split multi-codepoint grapheme clusters (emoji, CJK, ZWJ sequences).
|
|
6
|
+
*/
|
|
7
|
+
import { segmentGraphemes, graphemeClusterWidth } from './grapheme.js';
|
|
8
|
+
/**
|
|
9
|
+
* Pattern matching ANSI SGR escape sequences (e.g. `\x1b[31m`).
|
|
10
|
+
*
|
|
11
|
+
* Used to strip style escapes before measuring visible width.
|
|
12
|
+
*/
|
|
13
|
+
const ANSI_RE = new RegExp('\x1b\\[[0-9;]*m', 'g');
|
|
14
|
+
/**
|
|
15
|
+
* Clip a string to a maximum visible width, preserving ANSI escapes.
|
|
16
|
+
*
|
|
17
|
+
* Grapheme-cluster aware: won't split multi-codepoint sequences.
|
|
18
|
+
* Appends a reset sequence (`\x1b[0m`) when clipping text that contains ANSI style escapes.
|
|
19
|
+
*
|
|
20
|
+
* O(n): pre-segments stripped text once, then walks the original string
|
|
21
|
+
* with a grapheme pointer instead of re-segmenting per character.
|
|
22
|
+
*
|
|
23
|
+
* @param str - Input string, may contain ANSI escape sequences.
|
|
24
|
+
* @param maxWidth - Maximum visible width in terminal columns.
|
|
25
|
+
* @returns The clipped string, with ANSI escapes intact and a reset appended if needed.
|
|
26
|
+
*/
|
|
27
|
+
export function clipToWidth(str, maxWidth) {
|
|
28
|
+
if (maxWidth <= 0)
|
|
29
|
+
return '';
|
|
30
|
+
const stripped = str.replace(ANSI_RE, '');
|
|
31
|
+
const graphemes = segmentGraphemes(stripped);
|
|
32
|
+
let result = '';
|
|
33
|
+
let visible = 0;
|
|
34
|
+
let inEscape = false;
|
|
35
|
+
let escBuf = '';
|
|
36
|
+
let hasStyle = false;
|
|
37
|
+
let gi = 0;
|
|
38
|
+
let i = 0;
|
|
39
|
+
while (i < str.length) {
|
|
40
|
+
const ch = str[i];
|
|
41
|
+
if (ch === '\x1b') {
|
|
42
|
+
inEscape = true;
|
|
43
|
+
escBuf = ch;
|
|
44
|
+
i++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (inEscape) {
|
|
48
|
+
escBuf += ch;
|
|
49
|
+
if (ch === 'm') {
|
|
50
|
+
inEscape = false;
|
|
51
|
+
result += escBuf;
|
|
52
|
+
escBuf = '';
|
|
53
|
+
hasStyle = true;
|
|
54
|
+
}
|
|
55
|
+
i++;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
// Visible character — consume next pre-segmented grapheme
|
|
59
|
+
if (gi >= graphemes.length)
|
|
60
|
+
break;
|
|
61
|
+
const grapheme = graphemes[gi];
|
|
62
|
+
const gWidth = graphemeClusterWidth(grapheme);
|
|
63
|
+
if (visible + gWidth > maxWidth) {
|
|
64
|
+
if (hasStyle)
|
|
65
|
+
result += '\x1b[0m';
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
result += grapheme;
|
|
69
|
+
visible += gWidth;
|
|
70
|
+
gi++;
|
|
71
|
+
i += grapheme.length;
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=clip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clip.js","sourceRoot":"","sources":["../../../src/core/text/clip.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEvE;;;;GAIG;AACH,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,QAAgB;IACvD,IAAI,QAAQ,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAE7B,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,gBAAgB,CAAC,QA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Q,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* lookup for East Asian Wide / emoji display widths.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Determine whether a Unicode code point occupies two terminal columns.
|
|
9
9
|
*
|
|
10
10
|
* Covers:
|
|
11
11
|
* - CJK Unified Ideographs (U+4E00–U+9FFF)
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
* - CJK Compatibility (U+FE30–U+FE4F)
|
|
20
20
|
* - Hangul Syllables (U+AC00–U+D7A3)
|
|
21
21
|
* - Emoji (most U+1F000+)
|
|
22
|
+
*
|
|
23
|
+
* @param cp - Unicode code point to test.
|
|
24
|
+
* @returns `true` if the code point renders as two columns wide.
|
|
22
25
|
*/
|
|
23
26
|
export declare function isWideChar(cp: number): boolean;
|
|
24
27
|
/**
|
|
@@ -26,6 +29,9 @@ export declare function isWideChar(cp: number): boolean;
|
|
|
26
29
|
*
|
|
27
30
|
* Each element is a single user-perceived character (handles combining
|
|
28
31
|
* marks, ZWJ sequences, flag pairs, skin tones, etc.).
|
|
32
|
+
*
|
|
33
|
+
* @param str - Input string to segment.
|
|
34
|
+
* @returns Array of grapheme cluster strings.
|
|
29
35
|
*/
|
|
30
36
|
export declare function segmentGraphemes(str: string): string[];
|
|
31
37
|
/**
|
|
@@ -38,17 +44,23 @@ export declare function segmentGraphemes(str: string): string[];
|
|
|
38
44
|
*
|
|
39
45
|
* Zero-width characters (combining marks, ZWJ, variation selectors)
|
|
40
46
|
* don't add width on their own — they're part of the cluster.
|
|
47
|
+
*
|
|
48
|
+
* @param grapheme - A single grapheme cluster string.
|
|
49
|
+
* @returns Display width: 1 for narrow characters, 2 for wide/emoji.
|
|
41
50
|
*/
|
|
42
51
|
export declare function graphemeClusterWidth(grapheme: string): number;
|
|
43
52
|
/**
|
|
44
53
|
* Compute the terminal display width of a string.
|
|
45
54
|
*
|
|
46
|
-
*
|
|
47
|
-
* and
|
|
55
|
+
* Strip ANSI escape sequences, segment into grapheme clusters,
|
|
56
|
+
* and sum display widths. Correctly handles:
|
|
48
57
|
* - Multi-codepoint emoji (flags, ZWJ families, skin tones)
|
|
49
58
|
* - East Asian Wide characters (CJK, fullwidth forms)
|
|
50
59
|
* - Combining marks (accented characters)
|
|
51
60
|
* - ANSI escape sequences (ignored)
|
|
61
|
+
*
|
|
62
|
+
* @param str - Input string, may contain ANSI escape sequences.
|
|
63
|
+
* @returns Total display width in terminal columns.
|
|
52
64
|
*/
|
|
53
65
|
export declare function graphemeWidth(str: string): number;
|
|
54
66
|
//# sourceMappingURL=grapheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grapheme.d.ts","sourceRoot":"","sources":["../../../src/core/text/grapheme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"grapheme.d.ts","sourceRoot":"","sources":["../../../src/core/text/grapheme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAgD9C;AAMD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAOtD;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAc7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUjD"}
|