@jrichman/ink 6.3.1

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.
Files changed (141) hide show
  1. package/build/colorize.d.ts +3 -0
  2. package/build/colorize.js +48 -0
  3. package/build/colorize.js.map +1 -0
  4. package/build/components/AccessibilityContext.d.ts +3 -0
  5. package/build/components/AccessibilityContext.js +5 -0
  6. package/build/components/AccessibilityContext.js.map +1 -0
  7. package/build/components/App.d.ts +59 -0
  8. package/build/components/App.js +286 -0
  9. package/build/components/App.js.map +1 -0
  10. package/build/components/AppContext.d.ts +11 -0
  11. package/build/components/AppContext.js +11 -0
  12. package/build/components/AppContext.js.map +1 -0
  13. package/build/components/BackgroundContext.d.ts +4 -0
  14. package/build/components/BackgroundContext.js +3 -0
  15. package/build/components/BackgroundContext.js.map +1 -0
  16. package/build/components/Box.d.ts +122 -0
  17. package/build/components/Box.js +34 -0
  18. package/build/components/Box.js.map +1 -0
  19. package/build/components/ErrorOverview.d.ts +6 -0
  20. package/build/components/ErrorOverview.js +84 -0
  21. package/build/components/ErrorOverview.js.map +1 -0
  22. package/build/components/FocusContext.d.ts +16 -0
  23. package/build/components/FocusContext.js +17 -0
  24. package/build/components/FocusContext.js.map +1 -0
  25. package/build/components/Newline.d.ts +13 -0
  26. package/build/components/Newline.js +8 -0
  27. package/build/components/Newline.js.map +1 -0
  28. package/build/components/Spacer.d.ts +7 -0
  29. package/build/components/Spacer.js +11 -0
  30. package/build/components/Spacer.js.map +1 -0
  31. package/build/components/Static.d.ts +24 -0
  32. package/build/components/Static.js +28 -0
  33. package/build/components/Static.js.map +1 -0
  34. package/build/components/StderrContext.d.ts +15 -0
  35. package/build/components/StderrContext.js +13 -0
  36. package/build/components/StderrContext.js.map +1 -0
  37. package/build/components/StdinContext.d.ts +22 -0
  38. package/build/components/StdinContext.js +19 -0
  39. package/build/components/StdinContext.js.map +1 -0
  40. package/build/components/StdoutContext.d.ts +15 -0
  41. package/build/components/StdoutContext.js +13 -0
  42. package/build/components/StdoutContext.js.map +1 -0
  43. package/build/components/Text.d.ts +55 -0
  44. package/build/components/Text.js +50 -0
  45. package/build/components/Text.js.map +1 -0
  46. package/build/components/Transform.d.ts +16 -0
  47. package/build/components/Transform.js +15 -0
  48. package/build/components/Transform.js.map +1 -0
  49. package/build/devtools-window-polyfill.d.ts +1 -0
  50. package/build/devtools-window-polyfill.js +65 -0
  51. package/build/devtools-window-polyfill.js.map +1 -0
  52. package/build/devtools.d.ts +1 -0
  53. package/build/devtools.js +2 -0
  54. package/build/devtools.js.map +1 -0
  55. package/build/dom.d.ts +62 -0
  56. package/build/dom.js +123 -0
  57. package/build/dom.js.map +1 -0
  58. package/build/get-max-width.d.ts +3 -0
  59. package/build/get-max-width.js +10 -0
  60. package/build/get-max-width.js.map +1 -0
  61. package/build/hooks/use-app.d.ts +5 -0
  62. package/build/hooks/use-app.js +8 -0
  63. package/build/hooks/use-app.js.map +1 -0
  64. package/build/hooks/use-focus-manager.d.ts +28 -0
  65. package/build/hooks/use-focus-manager.js +17 -0
  66. package/build/hooks/use-focus-manager.js.map +1 -0
  67. package/build/hooks/use-focus.d.ts +29 -0
  68. package/build/hooks/use-focus.js +42 -0
  69. package/build/hooks/use-focus.js.map +1 -0
  70. package/build/hooks/use-input.d.ts +93 -0
  71. package/build/hooks/use-input.js +93 -0
  72. package/build/hooks/use-input.js.map +1 -0
  73. package/build/hooks/use-is-screen-reader-enabled.d.ts +5 -0
  74. package/build/hooks/use-is-screen-reader-enabled.js +11 -0
  75. package/build/hooks/use-is-screen-reader-enabled.js.map +1 -0
  76. package/build/hooks/use-stderr.d.ts +5 -0
  77. package/build/hooks/use-stderr.js +8 -0
  78. package/build/hooks/use-stderr.js.map +1 -0
  79. package/build/hooks/use-stdin.d.ts +5 -0
  80. package/build/hooks/use-stdin.js +8 -0
  81. package/build/hooks/use-stdin.js.map +1 -0
  82. package/build/hooks/use-stdout.d.ts +5 -0
  83. package/build/hooks/use-stdout.js +8 -0
  84. package/build/hooks/use-stdout.js.map +1 -0
  85. package/build/index.d.ts +28 -0
  86. package/build/index.js +17 -0
  87. package/build/index.js.map +1 -0
  88. package/build/ink.d.ts +43 -0
  89. package/build/ink.js +315 -0
  90. package/build/ink.js.map +1 -0
  91. package/build/instances.d.ts +3 -0
  92. package/build/instances.js +8 -0
  93. package/build/instances.js.map +1 -0
  94. package/build/log-update.d.ts +15 -0
  95. package/build/log-update.js +109 -0
  96. package/build/log-update.js.map +1 -0
  97. package/build/measure-element.d.ts +38 -0
  98. package/build/measure-element.js +118 -0
  99. package/build/measure-element.js.map +1 -0
  100. package/build/measure-text.d.ts +6 -0
  101. package/build/measure-text.js +21 -0
  102. package/build/measure-text.js.map +1 -0
  103. package/build/output.d.ts +36 -0
  104. package/build/output.js +191 -0
  105. package/build/output.js.map +1 -0
  106. package/build/parse-keypress.d.ts +14 -0
  107. package/build/parse-keypress.js +225 -0
  108. package/build/parse-keypress.js.map +1 -0
  109. package/build/reconciler.d.ts +4 -0
  110. package/build/reconciler.js +254 -0
  111. package/build/reconciler.js.map +1 -0
  112. package/build/render-background.d.ts +4 -0
  113. package/build/render-background.js +25 -0
  114. package/build/render-background.js.map +1 -0
  115. package/build/render-border.d.ts +4 -0
  116. package/build/render-border.js +73 -0
  117. package/build/render-border.js.map +1 -0
  118. package/build/render-node-to-output.d.ts +14 -0
  119. package/build/render-node-to-output.js +296 -0
  120. package/build/render-node-to-output.js.map +1 -0
  121. package/build/render.d.ts +87 -0
  122. package/build/render.js +50 -0
  123. package/build/render.js.map +1 -0
  124. package/build/renderer.d.ts +8 -0
  125. package/build/renderer.js +55 -0
  126. package/build/renderer.js.map +1 -0
  127. package/build/scroll.d.ts +8 -0
  128. package/build/scroll.js +35 -0
  129. package/build/scroll.js.map +1 -0
  130. package/build/squash-text-nodes.d.ts +3 -0
  131. package/build/squash-text-nodes.js +35 -0
  132. package/build/squash-text-nodes.js.map +1 -0
  133. package/build/styles.d.ts +260 -0
  134. package/build/styles.js +257 -0
  135. package/build/styles.js.map +1 -0
  136. package/build/wrap-text.d.ts +3 -0
  137. package/build/wrap-text.js +31 -0
  138. package/build/wrap-text.js.map +1 -0
  139. package/license +9 -0
  140. package/package.json +194 -0
  141. package/readme.md +2331 -0
@@ -0,0 +1,3 @@
1
+ type ColorType = 'foreground' | 'background';
2
+ declare const colorize: (str: string, color: string | undefined, type: ColorType) => string;
3
+ export default colorize;
@@ -0,0 +1,48 @@
1
+ import chalk from 'chalk';
2
+ const rgbRegex = /^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/;
3
+ const ansiRegex = /^ansi256\(\s?(\d+)\s?\)$/;
4
+ const isNamedColor = (color) => {
5
+ return color in chalk;
6
+ };
7
+ const colorize = (str, color, type) => {
8
+ if (!color) {
9
+ return str;
10
+ }
11
+ if (isNamedColor(color)) {
12
+ if (type === 'foreground') {
13
+ return chalk[color](str);
14
+ }
15
+ const methodName = `bg${color[0].toUpperCase() + color.slice(1)}`;
16
+ return chalk[methodName](str);
17
+ }
18
+ if (color.startsWith('#')) {
19
+ return type === 'foreground'
20
+ ? chalk.hex(color)(str)
21
+ : chalk.bgHex(color)(str);
22
+ }
23
+ if (color.startsWith('ansi256')) {
24
+ const matches = ansiRegex.exec(color);
25
+ if (!matches) {
26
+ return str;
27
+ }
28
+ const value = Number(matches[1]);
29
+ return type === 'foreground'
30
+ ? chalk.ansi256(value)(str)
31
+ : chalk.bgAnsi256(value)(str);
32
+ }
33
+ if (color.startsWith('rgb')) {
34
+ const matches = rgbRegex.exec(color);
35
+ if (!matches) {
36
+ return str;
37
+ }
38
+ const firstValue = Number(matches[1]);
39
+ const secondValue = Number(matches[2]);
40
+ const thirdValue = Number(matches[3]);
41
+ return type === 'foreground'
42
+ ? chalk.rgb(firstValue, secondValue, thirdValue)(str)
43
+ : chalk.bgRgb(firstValue, secondValue, thirdValue)(str);
44
+ }
45
+ return str;
46
+ };
47
+ export default colorize;
48
+ //# sourceMappingURL=colorize.js.map
@@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OAAO,GAAG,CAAC;QACZ,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjC,OAAO,IAAI,KAAK,YAAY;YAC3B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;YAC3B,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAErC,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,GAAG,CAAC;QACZ,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,IAAI,KAAK,YAAY;YAC3B,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC;YACrD,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const accessibilityContext: import("react").Context<{
2
+ isScreenReaderEnabled: boolean;
3
+ }>;
@@ -0,0 +1,5 @@
1
+ import { createContext } from 'react';
2
+ export const accessibilityContext = createContext({
3
+ isScreenReaderEnabled: false,
4
+ });
5
+ //# sourceMappingURL=AccessibilityContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessibilityContext.js","sourceRoot":"","sources":["../../src/components/AccessibilityContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC;IACjD,qBAAqB,EAAE,KAAK;CAC5B,CAAC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import React, { PureComponent, type ReactNode } from 'react';
3
+ type Props = {
4
+ readonly children: ReactNode;
5
+ readonly stdin: NodeJS.ReadStream;
6
+ readonly stdout: NodeJS.WriteStream;
7
+ readonly stderr: NodeJS.WriteStream;
8
+ readonly writeToStdout: (data: string) => void;
9
+ readonly writeToStderr: (data: string) => void;
10
+ readonly exitOnCtrlC: boolean;
11
+ readonly onExit: (error?: Error) => void;
12
+ };
13
+ type State = {
14
+ readonly isFocusEnabled: boolean;
15
+ readonly activeFocusId?: string;
16
+ readonly focusables: Focusable[];
17
+ readonly error?: Error;
18
+ };
19
+ type Focusable = {
20
+ readonly id: string;
21
+ readonly isActive: boolean;
22
+ };
23
+ export default class App extends PureComponent<Props, State> {
24
+ static displayName: string;
25
+ static getDerivedStateFromError(error: Error): {
26
+ error: Error;
27
+ };
28
+ state: {
29
+ isFocusEnabled: boolean;
30
+ activeFocusId: undefined;
31
+ focusables: never[];
32
+ error: undefined;
33
+ };
34
+ rawModeEnabledCount: number;
35
+ internal_eventEmitter: EventEmitter<[never]>;
36
+ isRawModeSupported(): boolean;
37
+ render(): React.JSX.Element;
38
+ componentDidMount(): void;
39
+ componentWillUnmount(): void;
40
+ componentDidCatch(error: Error): void;
41
+ handleSetRawMode: (isEnabled: boolean) => void;
42
+ handleReadable: () => void;
43
+ handleInput: (input: string) => void;
44
+ handleExit: (error?: Error) => void;
45
+ enableFocus: () => void;
46
+ disableFocus: () => void;
47
+ focus: (id: string) => void;
48
+ focusNext: () => void;
49
+ focusPrevious: () => void;
50
+ addFocusable: (id: string, { autoFocus }: {
51
+ autoFocus: boolean;
52
+ }) => void;
53
+ removeFocusable: (id: string) => void;
54
+ activateFocusable: (id: string) => void;
55
+ deactivateFocusable: (id: string) => void;
56
+ findNextFocusable: (state: State) => string | undefined;
57
+ findPreviousFocusable: (state: State) => string | undefined;
58
+ }
59
+ export {};
@@ -0,0 +1,286 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import process from 'node:process';
3
+ import React, { PureComponent } from 'react';
4
+ import cliCursor from 'cli-cursor';
5
+ import AppContext from './AppContext.js';
6
+ import StdinContext from './StdinContext.js';
7
+ import StdoutContext from './StdoutContext.js';
8
+ import StderrContext from './StderrContext.js';
9
+ import FocusContext from './FocusContext.js';
10
+ import ErrorOverview from './ErrorOverview.js';
11
+ const tab = '\t';
12
+ const shiftTab = '\u001B[Z';
13
+ const escape = '\u001B';
14
+ // Root component for all Ink apps
15
+ // It renders stdin and stdout contexts, so that children can access them if needed
16
+ // It also handles Ctrl+C exiting and cursor visibility
17
+ export default class App extends PureComponent {
18
+ static displayName = 'InternalApp';
19
+ static getDerivedStateFromError(error) {
20
+ return { error };
21
+ }
22
+ state = {
23
+ isFocusEnabled: true,
24
+ activeFocusId: undefined,
25
+ focusables: [],
26
+ error: undefined,
27
+ };
28
+ // Count how many components enabled raw mode to avoid disabling
29
+ // raw mode until all components don't need it anymore
30
+ rawModeEnabledCount = 0;
31
+ // eslint-disable-next-line @typescript-eslint/naming-convention
32
+ internal_eventEmitter = new EventEmitter();
33
+ // Determines if TTY is supported on the provided stdin
34
+ isRawModeSupported() {
35
+ return this.props.stdin.isTTY;
36
+ }
37
+ render() {
38
+ return (React.createElement(AppContext.Provider
39
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
40
+ , {
41
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
42
+ value: {
43
+ exit: this.handleExit,
44
+ } },
45
+ React.createElement(StdinContext.Provider
46
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
47
+ , {
48
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
49
+ value: {
50
+ stdin: this.props.stdin,
51
+ setRawMode: this.handleSetRawMode,
52
+ isRawModeSupported: this.isRawModeSupported(),
53
+ // eslint-disable-next-line @typescript-eslint/naming-convention
54
+ internal_exitOnCtrlC: this.props.exitOnCtrlC,
55
+ // eslint-disable-next-line @typescript-eslint/naming-convention
56
+ internal_eventEmitter: this.internal_eventEmitter,
57
+ } },
58
+ React.createElement(StdoutContext.Provider
59
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
60
+ , {
61
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
62
+ value: {
63
+ stdout: this.props.stdout,
64
+ write: this.props.writeToStdout,
65
+ } },
66
+ React.createElement(StderrContext.Provider
67
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
68
+ , {
69
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
70
+ value: {
71
+ stderr: this.props.stderr,
72
+ write: this.props.writeToStderr,
73
+ } },
74
+ React.createElement(FocusContext.Provider
75
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
76
+ , {
77
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
78
+ value: {
79
+ activeId: this.state.activeFocusId,
80
+ add: this.addFocusable,
81
+ remove: this.removeFocusable,
82
+ activate: this.activateFocusable,
83
+ deactivate: this.deactivateFocusable,
84
+ enableFocus: this.enableFocus,
85
+ disableFocus: this.disableFocus,
86
+ focusNext: this.focusNext,
87
+ focusPrevious: this.focusPrevious,
88
+ focus: this.focus,
89
+ } }, this.state.error ? (React.createElement(ErrorOverview, { error: this.state.error })) : (this.props.children)))))));
90
+ }
91
+ componentDidMount() {
92
+ cliCursor.hide(this.props.stdout);
93
+ }
94
+ componentWillUnmount() {
95
+ cliCursor.show(this.props.stdout);
96
+ // ignore calling setRawMode on an handle stdin it cannot be called
97
+ if (this.isRawModeSupported()) {
98
+ this.handleSetRawMode(false);
99
+ }
100
+ }
101
+ componentDidCatch(error) {
102
+ this.handleExit(error);
103
+ }
104
+ handleSetRawMode = (isEnabled) => {
105
+ const { stdin } = this.props;
106
+ if (!this.isRawModeSupported()) {
107
+ if (stdin === process.stdin) {
108
+ throw new Error('Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported');
109
+ }
110
+ else {
111
+ throw new Error('Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported');
112
+ }
113
+ }
114
+ stdin.setEncoding('utf8');
115
+ if (isEnabled) {
116
+ // Ensure raw mode is enabled only once
117
+ if (this.rawModeEnabledCount === 0) {
118
+ stdin.ref();
119
+ stdin.setRawMode(true);
120
+ stdin.addListener('readable', this.handleReadable);
121
+ }
122
+ this.rawModeEnabledCount++;
123
+ return;
124
+ }
125
+ // Disable raw mode only when no components left that are using it
126
+ if (--this.rawModeEnabledCount === 0) {
127
+ stdin.setRawMode(false);
128
+ stdin.removeListener('readable', this.handleReadable);
129
+ stdin.unref();
130
+ }
131
+ };
132
+ handleReadable = () => {
133
+ let chunk;
134
+ // eslint-disable-next-line @typescript-eslint/ban-types
135
+ while ((chunk = this.props.stdin.read()) !== null) {
136
+ this.handleInput(chunk);
137
+ this.internal_eventEmitter.emit('input', chunk);
138
+ }
139
+ };
140
+ handleInput = (input) => {
141
+ // Exit on Ctrl+C
142
+ // eslint-disable-next-line unicorn/no-hex-escape
143
+ if (input === '\x03' && this.props.exitOnCtrlC) {
144
+ this.handleExit();
145
+ }
146
+ // Reset focus when there's an active focused component on Esc
147
+ if (input === escape && this.state.activeFocusId) {
148
+ this.setState({
149
+ activeFocusId: undefined,
150
+ });
151
+ }
152
+ if (this.state.isFocusEnabled && this.state.focusables.length > 0) {
153
+ if (input === tab) {
154
+ this.focusNext();
155
+ }
156
+ if (input === shiftTab) {
157
+ this.focusPrevious();
158
+ }
159
+ }
160
+ };
161
+ handleExit = (error) => {
162
+ if (this.isRawModeSupported()) {
163
+ this.handleSetRawMode(false);
164
+ }
165
+ this.props.onExit(error);
166
+ };
167
+ enableFocus = () => {
168
+ this.setState({
169
+ isFocusEnabled: true,
170
+ });
171
+ };
172
+ disableFocus = () => {
173
+ this.setState({
174
+ isFocusEnabled: false,
175
+ });
176
+ };
177
+ focus = (id) => {
178
+ this.setState(previousState => {
179
+ const hasFocusableId = previousState.focusables.some(focusable => focusable?.id === id);
180
+ if (!hasFocusableId) {
181
+ return previousState;
182
+ }
183
+ return { activeFocusId: id };
184
+ });
185
+ };
186
+ focusNext = () => {
187
+ this.setState(previousState => {
188
+ const firstFocusableId = previousState.focusables.find(focusable => focusable.isActive)?.id;
189
+ const nextFocusableId = this.findNextFocusable(previousState);
190
+ return {
191
+ activeFocusId: nextFocusableId ?? firstFocusableId,
192
+ };
193
+ });
194
+ };
195
+ focusPrevious = () => {
196
+ this.setState(previousState => {
197
+ const lastFocusableId = previousState.focusables.findLast(focusable => focusable.isActive)?.id;
198
+ const previousFocusableId = this.findPreviousFocusable(previousState);
199
+ return {
200
+ activeFocusId: previousFocusableId ?? lastFocusableId,
201
+ };
202
+ });
203
+ };
204
+ addFocusable = (id, { autoFocus }) => {
205
+ this.setState(previousState => {
206
+ let nextFocusId = previousState.activeFocusId;
207
+ if (!nextFocusId && autoFocus) {
208
+ nextFocusId = id;
209
+ }
210
+ return {
211
+ activeFocusId: nextFocusId,
212
+ focusables: [
213
+ ...previousState.focusables,
214
+ {
215
+ id,
216
+ isActive: true,
217
+ },
218
+ ],
219
+ };
220
+ });
221
+ };
222
+ removeFocusable = (id) => {
223
+ this.setState(previousState => ({
224
+ activeFocusId: previousState.activeFocusId === id
225
+ ? undefined
226
+ : previousState.activeFocusId,
227
+ focusables: previousState.focusables.filter(focusable => {
228
+ return focusable.id !== id;
229
+ }),
230
+ }));
231
+ };
232
+ activateFocusable = (id) => {
233
+ this.setState(previousState => ({
234
+ focusables: previousState.focusables.map(focusable => {
235
+ if (focusable.id !== id) {
236
+ return focusable;
237
+ }
238
+ return {
239
+ id,
240
+ isActive: true,
241
+ };
242
+ }),
243
+ }));
244
+ };
245
+ deactivateFocusable = (id) => {
246
+ this.setState(previousState => ({
247
+ activeFocusId: previousState.activeFocusId === id
248
+ ? undefined
249
+ : previousState.activeFocusId,
250
+ focusables: previousState.focusables.map(focusable => {
251
+ if (focusable.id !== id) {
252
+ return focusable;
253
+ }
254
+ return {
255
+ id,
256
+ isActive: false,
257
+ };
258
+ }),
259
+ }));
260
+ };
261
+ findNextFocusable = (state) => {
262
+ const activeIndex = state.focusables.findIndex(focusable => {
263
+ return focusable.id === state.activeFocusId;
264
+ });
265
+ for (let index = activeIndex + 1; index < state.focusables.length; index++) {
266
+ const focusable = state.focusables[index];
267
+ if (focusable?.isActive) {
268
+ return focusable.id;
269
+ }
270
+ }
271
+ return undefined;
272
+ };
273
+ findPreviousFocusable = (state) => {
274
+ const activeIndex = state.focusables.findIndex(focusable => {
275
+ return focusable.id === state.activeFocusId;
276
+ });
277
+ for (let index = activeIndex - 1; index >= 0; index--) {
278
+ const focusable = state.focusables[index];
279
+ if (focusable?.isActive) {
280
+ return focusable.id;
281
+ }
282
+ }
283
+ return undefined;
284
+ };
285
+ }
286
+ //# sourceMappingURL=App.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"App.js","sourceRoot":"","sources":["../../src/components/App.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,KAAK,EAAE,EAAC,aAAa,EAAiB,MAAM,OAAO,CAAC;AAC3D,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,YAAY,MAAM,mBAAmB,CAA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CAAC;gBACzB,OAAO,SAAS,CAAC,EAAE,CAAC;YACrB,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC;IAEF,qBAAqB,GAAG,CAAC,KAAY,EAAsB,EAAE;QAC5D,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;YAC1D,OAAO,SAAS,CAAC,EAAE,KAAK,KAAK,CAAC,aAAa,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,KAAK,IAAI,KAAK,GAAG,WAAW,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACvD,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAE1C,IAAI,SAAS,EAAE,QAAQ,EAAE,CAAC;gBACzB,OAAO,SAAS,CAAC,EAAE,CAAC;YACrB,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type Props = {
2
+ /**
3
+ Exit (unmount) the whole Ink app.
4
+ */
5
+ readonly exit: (error?: Error) => void;
6
+ };
7
+ /**
8
+ `AppContext` is a React context that exposes a method to manually exit the app (unmount).
9
+ */
10
+ declare const AppContext: import("react").Context<Props>;
11
+ export default AppContext;
@@ -0,0 +1,11 @@
1
+ import { createContext } from 'react';
2
+ /**
3
+ `AppContext` is a React context that exposes a method to manually exit the app (unmount).
4
+ */
5
+ // eslint-disable-next-line @typescript-eslint/naming-convention
6
+ const AppContext = createContext({
7
+ exit() { },
8
+ });
9
+ AppContext.displayName = 'InternalAppContext';
10
+ export default AppContext;
11
+ //# sourceMappingURL=AppContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppContext.js","sourceRoot":"","sources":["../../src/components/AppContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AASpC;;EAEE;AACF,gEAAgE;AAChE,MAAM,UAAU,GAAG,aAAa,CAAQ;IACvC,IAAI,KAAI,CAAC;CACT,CAAC,CAAC;AAEH,UAAU,CAAC,WAAW,GAAG,oBAAoB,CAAC;AAE9C,eAAe,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type LiteralUnion } from 'type-fest';
2
+ import { type ForegroundColorName } from 'ansi-styles';
3
+ export type BackgroundColor = LiteralUnion<ForegroundColorName, string>;
4
+ export declare const backgroundContext: import("react").Context<BackgroundColor | undefined>;
@@ -0,0 +1,3 @@
1
+ import { createContext } from 'react';
2
+ export const backgroundContext = createContext(undefined);
3
+ //# sourceMappingURL=BackgroundContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BackgroundContext.js","sourceRoot":"","sources":["../../src/components/BackgroundContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAMpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAC7C,SAAS,CACT,CAAC"}
@@ -0,0 +1,122 @@
1
+ import React from 'react';
2
+ import { type Except } from 'type-fest';
3
+ import { type Styles } from '../styles.js';
4
+ import { type DOMElement } from '../dom.js';
5
+ export type Props = Except<Styles, 'textWrap'> & {
6
+ /**
7
+ A label for the element for screen readers.
8
+ */
9
+ readonly 'aria-label'?: string;
10
+ /**
11
+ Hide the element from screen readers.
12
+ */
13
+ readonly 'aria-hidden'?: boolean;
14
+ /**
15
+ The role of the element.
16
+ */
17
+ readonly 'aria-role'?: 'button' | 'checkbox' | 'combobox' | 'list' | 'listbox' | 'listitem' | 'menu' | 'menuitem' | 'option' | 'progressbar' | 'radio' | 'radiogroup' | 'tab' | 'tablist' | 'table' | 'textbox' | 'timer' | 'toolbar';
18
+ /**
19
+ The state of the element.
20
+ */
21
+ readonly 'aria-state'?: {
22
+ readonly busy?: boolean;
23
+ readonly checked?: boolean;
24
+ readonly disabled?: boolean;
25
+ readonly expanded?: boolean;
26
+ readonly multiline?: boolean;
27
+ readonly multiselectable?: boolean;
28
+ readonly readonly?: boolean;
29
+ readonly required?: boolean;
30
+ readonly selected?: boolean;
31
+ };
32
+ };
33
+ /**
34
+ `<Box>` is an essential Ink component to build your layout. It's like `<div style="display: flex">` in the browser.
35
+ */
36
+ declare const Box: React.ForwardRefExoticComponent<{
37
+ readonly position?: "absolute" | "relative" | undefined;
38
+ readonly columnGap?: number | undefined;
39
+ readonly rowGap?: number | undefined;
40
+ readonly gap?: number | undefined;
41
+ readonly margin?: number | undefined;
42
+ readonly marginX?: number | undefined;
43
+ readonly marginY?: number | undefined;
44
+ readonly marginTop?: number | undefined;
45
+ readonly marginBottom?: number | undefined;
46
+ readonly marginLeft?: number | undefined;
47
+ readonly marginRight?: number | undefined;
48
+ readonly padding?: number | undefined;
49
+ readonly paddingX?: number | undefined;
50
+ readonly paddingY?: number | undefined;
51
+ readonly paddingTop?: number | undefined;
52
+ readonly paddingBottom?: number | undefined;
53
+ readonly paddingLeft?: number | undefined;
54
+ readonly paddingRight?: number | undefined;
55
+ readonly flexGrow?: number | undefined;
56
+ readonly flexShrink?: number | undefined;
57
+ readonly flexDirection?: "row" | "column" | "row-reverse" | "column-reverse" | undefined;
58
+ readonly flexBasis?: number | string | undefined;
59
+ readonly flexWrap?: "nowrap" | "wrap" | "wrap-reverse" | undefined;
60
+ readonly alignItems?: "flex-start" | "center" | "flex-end" | "stretch" | undefined;
61
+ readonly alignSelf?: "flex-start" | "center" | "flex-end" | "auto" | undefined;
62
+ readonly justifyContent?: "flex-start" | "flex-end" | "space-between" | "space-around" | "space-evenly" | "center" | undefined;
63
+ readonly width?: number | string | undefined;
64
+ readonly height?: number | string | undefined;
65
+ readonly minWidth?: number | string | undefined;
66
+ readonly minHeight?: number | string | undefined;
67
+ readonly maxWidth?: number | string | undefined;
68
+ readonly maxHeight?: number | string | undefined;
69
+ readonly display?: "flex" | "none" | undefined;
70
+ readonly borderStyle?: (keyof import("cli-boxes").Boxes | import("cli-boxes").BoxStyle) | undefined;
71
+ readonly borderTop?: boolean | undefined;
72
+ readonly borderBottom?: boolean | undefined;
73
+ readonly borderLeft?: boolean | undefined;
74
+ readonly borderRight?: boolean | undefined;
75
+ readonly borderColor?: import("type-fest").LiteralUnion<import("ansi-styles").ForegroundColorName, string> | undefined;
76
+ readonly borderTopColor?: import("type-fest").LiteralUnion<import("ansi-styles").ForegroundColorName, string> | undefined;
77
+ readonly borderBottomColor?: import("type-fest").LiteralUnion<import("ansi-styles").ForegroundColorName, string> | undefined;
78
+ readonly borderLeftColor?: import("type-fest").LiteralUnion<import("ansi-styles").ForegroundColorName, string> | undefined;
79
+ readonly borderRightColor?: import("type-fest").LiteralUnion<import("ansi-styles").ForegroundColorName, string> | undefined;
80
+ readonly borderDimColor?: boolean | undefined;
81
+ readonly borderTopDimColor?: boolean | undefined;
82
+ readonly borderBottomDimColor?: boolean | undefined;
83
+ readonly borderLeftDimColor?: boolean | undefined;
84
+ readonly borderRightDimColor?: boolean | undefined;
85
+ readonly overflow?: "visible" | "hidden" | "scroll" | undefined;
86
+ readonly overflowX?: "visible" | "hidden" | "scroll" | undefined;
87
+ readonly overflowY?: "visible" | "hidden" | "scroll" | undefined;
88
+ readonly backgroundColor?: import("type-fest").LiteralUnion<import("ansi-styles").ForegroundColorName, string> | undefined;
89
+ readonly scrollTop?: number | undefined;
90
+ readonly scrollLeft?: number | undefined;
91
+ readonly scrollbarThumbColor?: import("type-fest").LiteralUnion<import("ansi-styles").ForegroundColorName, string> | undefined;
92
+ } & {
93
+ /**
94
+ A label for the element for screen readers.
95
+ */
96
+ readonly 'aria-label'?: string;
97
+ /**
98
+ Hide the element from screen readers.
99
+ */
100
+ readonly 'aria-hidden'?: boolean;
101
+ /**
102
+ The role of the element.
103
+ */
104
+ readonly 'aria-role'?: "button" | "checkbox" | "combobox" | "list" | "listbox" | "listitem" | "menu" | "menuitem" | "option" | "progressbar" | "radio" | "radiogroup" | "tab" | "tablist" | "table" | "textbox" | "timer" | "toolbar";
105
+ /**
106
+ The state of the element.
107
+ */
108
+ readonly 'aria-state'?: {
109
+ readonly busy?: boolean;
110
+ readonly checked?: boolean;
111
+ readonly disabled?: boolean;
112
+ readonly expanded?: boolean;
113
+ readonly multiline?: boolean;
114
+ readonly multiselectable?: boolean;
115
+ readonly readonly?: boolean;
116
+ readonly required?: boolean;
117
+ readonly selected?: boolean;
118
+ };
119
+ } & {
120
+ children?: React.ReactNode | undefined;
121
+ } & React.RefAttributes<DOMElement>>;
122
+ export default Box;
@@ -0,0 +1,34 @@
1
+ import React, { forwardRef, useContext } from 'react';
2
+ import { accessibilityContext } from './AccessibilityContext.js';
3
+ import { backgroundContext } from './BackgroundContext.js';
4
+ /**
5
+ `<Box>` is an essential Ink component to build your layout. It's like `<div style="display: flex">` in the browser.
6
+ */
7
+ const Box = forwardRef(({ children, backgroundColor, 'aria-label': ariaLabel, 'aria-hidden': ariaHidden, 'aria-role': role, 'aria-state': ariaState, ...style }, ref) => {
8
+ const { isScreenReaderEnabled } = useContext(accessibilityContext);
9
+ const label = ariaLabel ? React.createElement("ink-text", null, ariaLabel) : undefined;
10
+ if (isScreenReaderEnabled && ariaHidden) {
11
+ return null;
12
+ }
13
+ const boxElement = (React.createElement("ink-box", { ref: ref, style: {
14
+ flexWrap: 'nowrap',
15
+ flexDirection: 'row',
16
+ flexGrow: 0,
17
+ flexShrink: 1,
18
+ ...style,
19
+ backgroundColor,
20
+ overflowX: style.overflowX ?? style.overflow ?? 'visible',
21
+ overflowY: style.overflowY ?? style.overflow ?? 'visible',
22
+ }, internal_accessibility: {
23
+ role,
24
+ state: ariaState,
25
+ } }, isScreenReaderEnabled && label ? label : children));
26
+ // If this Box has a background color, provide it to children via context
27
+ if (backgroundColor) {
28
+ return (React.createElement(backgroundContext.Provider, { value: backgroundColor }, boxElement));
29
+ }
30
+ return boxElement;
31
+ });
32
+ Box.displayName = 'Box';
33
+ export default Box;
34
+ //# sourceMappingURL=Box.js.map
@@ -0,0 +1 @@
1
+ {"version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,eAAe,EAAE,CAAC;QACrB,OAAO,CACN,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,IAChD,UAAU,CACiB,CAC7B,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC,CACD,CAAC;AAEF,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC;AAExB,eAAe,GAAG,CAAC"}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ type Props = {
3
+ readonly error: Error;
4
+ };
5
+ export default function ErrorOverview({ error }: Props): React.JSX.Element;
6
+ export {};