@jakubmazanec/cli 0.1.0-9029e49

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 (167) hide show
  1. package/LICENSE.md +840 -0
  2. package/README.md +38 -0
  3. package/dist/constants.d.ts +1 -0
  4. package/dist/constants.js +3 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/main.d.ts +2 -0
  7. package/dist/main.js +4 -0
  8. package/dist/main.js.map +1 -0
  9. package/dist/program/Command.d.ts +42 -0
  10. package/dist/program/Command.js +64 -0
  11. package/dist/program/Command.js.map +1 -0
  12. package/dist/program/CommandAction.d.ts +12 -0
  13. package/dist/program/CommandAction.js +3 -0
  14. package/dist/program/CommandAction.js.map +1 -0
  15. package/dist/program/CommandArguments.d.ts +5 -0
  16. package/dist/program/CommandArguments.js +3 -0
  17. package/dist/program/CommandArguments.js.map +1 -0
  18. package/dist/program/CommandOptions.d.ts +11 -0
  19. package/dist/program/CommandOptions.js +3 -0
  20. package/dist/program/CommandOptions.js.map +1 -0
  21. package/dist/program/Program.d.ts +40 -0
  22. package/dist/program/Program.js +105 -0
  23. package/dist/program/Program.js.map +1 -0
  24. package/dist/program/ProgramDetail.d.ts +9 -0
  25. package/dist/program/ProgramDetail.js +5 -0
  26. package/dist/program/ProgramDetail.js.map +1 -0
  27. package/dist/program/ProgramError.d.ts +4 -0
  28. package/dist/program/ProgramError.js +8 -0
  29. package/dist/program/ProgramError.js.map +1 -0
  30. package/dist/program/ProgramOptions.d.ts +13 -0
  31. package/dist/program/ProgramOptions.js +5 -0
  32. package/dist/program/ProgramOptions.js.map +1 -0
  33. package/dist/program/ProgramStreams.d.ts +9 -0
  34. package/dist/program/ProgramStreams.js +5 -0
  35. package/dist/program/ProgramStreams.js.map +1 -0
  36. package/dist/program/getProgramDetail.d.ts +6 -0
  37. package/dist/program/getProgramDetail.js +27 -0
  38. package/dist/program/getProgramDetail.js.map +1 -0
  39. package/dist/program.d.ts +10 -0
  40. package/dist/program.js +12 -0
  41. package/dist/program.js.map +1 -0
  42. package/dist/ui/ErrorDetail.d.ts +12 -0
  43. package/dist/ui/ErrorDetail.js +5 -0
  44. package/dist/ui/ErrorDetail.js.map +1 -0
  45. package/dist/ui/Failure.d.ts +15 -0
  46. package/dist/ui/Failure.js +65 -0
  47. package/dist/ui/Failure.js.map +1 -0
  48. package/dist/ui/Header.d.ts +15 -0
  49. package/dist/ui/Header.js +26 -0
  50. package/dist/ui/Header.js.map +1 -0
  51. package/dist/ui/Help.d.ts +13 -0
  52. package/dist/ui/Help.js +64 -0
  53. package/dist/ui/Help.js.map +1 -0
  54. package/dist/ui/Spinner.d.ts +4 -0
  55. package/dist/ui/Spinner.js +39 -0
  56. package/dist/ui/Spinner.js.map +1 -0
  57. package/dist/ui/colors.d.ts +10 -0
  58. package/dist/ui/colors.js +12 -0
  59. package/dist/ui/colors.js.map +1 -0
  60. package/dist/ui/form/Form.d.ts +9 -0
  61. package/dist/ui/form/Form.js +3 -0
  62. package/dist/ui/form/Form.js.map +1 -0
  63. package/dist/ui/form/FormConfig.d.ts +8 -0
  64. package/dist/ui/form/FormConfig.js +3 -0
  65. package/dist/ui/form/FormConfig.js.map +1 -0
  66. package/dist/ui/form/FormProps.d.ts +40 -0
  67. package/dist/ui/form/FormProps.js +3 -0
  68. package/dist/ui/form/FormProps.js.map +1 -0
  69. package/dist/ui/form/FormResult.d.ts +6 -0
  70. package/dist/ui/form/FormResult.js +3 -0
  71. package/dist/ui/form/FormResult.js.map +1 -0
  72. package/dist/ui/form/FormRow.d.ts +30 -0
  73. package/dist/ui/form/FormRow.js +59 -0
  74. package/dist/ui/form/FormRow.js.map +1 -0
  75. package/dist/ui/form/FormRowConfig.d.ts +14 -0
  76. package/dist/ui/form/FormRowConfig.js +5 -0
  77. package/dist/ui/form/FormRowConfig.js.map +1 -0
  78. package/dist/ui/form/FormRowsConfig.d.ts +5 -0
  79. package/dist/ui/form/FormRowsConfig.js +3 -0
  80. package/dist/ui/form/FormRowsConfig.js.map +1 -0
  81. package/dist/ui/form/FormValue.d.ts +9 -0
  82. package/dist/ui/form/FormValue.js +3 -0
  83. package/dist/ui/form/FormValue.js.map +1 -0
  84. package/dist/ui/form/FormValues.d.ts +8 -0
  85. package/dist/ui/form/FormValues.js +3 -0
  86. package/dist/ui/form/FormValues.js.map +1 -0
  87. package/dist/ui/form/SelectInput.d.ts +29 -0
  88. package/dist/ui/form/SelectInput.js +123 -0
  89. package/dist/ui/form/SelectInput.js.map +1 -0
  90. package/dist/ui/form/SelectInputItem.d.ts +9 -0
  91. package/dist/ui/form/SelectInputItem.js +5 -0
  92. package/dist/ui/form/SelectInputItem.js.map +1 -0
  93. package/dist/ui/form/TextInput.d.ts +30 -0
  94. package/dist/ui/form/TextInput.js +155 -0
  95. package/dist/ui/form/TextInput.js.map +1 -0
  96. package/dist/ui/form/createForm.d.ts +9 -0
  97. package/dist/ui/form/createForm.js +72 -0
  98. package/dist/ui/form/createForm.js.map +1 -0
  99. package/dist/ui/form.d.ts +13 -0
  100. package/dist/ui/form.js +15 -0
  101. package/dist/ui/form.js.map +1 -0
  102. package/dist/ui/getErrorDetail.d.ts +5 -0
  103. package/dist/ui/getErrorDetail.js +63 -0
  104. package/dist/ui/getErrorDetail.js.map +1 -0
  105. package/dist/ui/icons.d.ts +9 -0
  106. package/dist/ui/icons.js +13 -0
  107. package/dist/ui/icons.js.map +1 -0
  108. package/dist/ui/internals/Wrapper.d.ts +12 -0
  109. package/dist/ui/internals/Wrapper.js +26 -0
  110. package/dist/ui/internals/Wrapper.js.map +1 -0
  111. package/dist/ui/internals/programContext.d.ts +9 -0
  112. package/dist/ui/internals/programContext.js +6 -0
  113. package/dist/ui/internals/programContext.js.map +1 -0
  114. package/dist/ui/internals/rotate.d.ts +8 -0
  115. package/dist/ui/internals/rotate.js +17 -0
  116. package/dist/ui/internals/rotate.js.map +1 -0
  117. package/dist/ui/internals.d.ts +3 -0
  118. package/dist/ui/internals.js +5 -0
  119. package/dist/ui/internals.js.map +1 -0
  120. package/dist/ui/useProgram.d.ts +7 -0
  121. package/dist/ui/useProgram.js +24 -0
  122. package/dist/ui/useProgram.js.map +1 -0
  123. package/dist/ui.d.ts +10 -0
  124. package/dist/ui.js +12 -0
  125. package/dist/ui.js.map +1 -0
  126. package/package.json +61 -0
  127. package/src/constants.ts +1 -0
  128. package/src/main.ts +2 -0
  129. package/src/program/Command.ts +121 -0
  130. package/src/program/CommandAction.ts +23 -0
  131. package/src/program/CommandArguments.ts +9 -0
  132. package/src/program/CommandOptions.ts +17 -0
  133. package/src/program/Program.ts +136 -0
  134. package/src/program/ProgramDetail.ts +9 -0
  135. package/src/program/ProgramError.ts +9 -0
  136. package/src/program/ProgramOptions.ts +16 -0
  137. package/src/program/ProgramStreams.ts +8 -0
  138. package/src/program/getProgramDetail.ts +38 -0
  139. package/src/program.ts +10 -0
  140. package/src/ui/ErrorDetail.ts +12 -0
  141. package/src/ui/Failure.tsx +59 -0
  142. package/src/ui/Header.tsx +37 -0
  143. package/src/ui/Help.tsx +68 -0
  144. package/src/ui/Spinner.tsx +30 -0
  145. package/src/ui/colors.ts +13 -0
  146. package/src/ui/form/Form.ts +9 -0
  147. package/src/ui/form/FormConfig.ts +9 -0
  148. package/src/ui/form/FormProps.ts +67 -0
  149. package/src/ui/form/FormResult.ts +8 -0
  150. package/src/ui/form/FormRow.tsx +119 -0
  151. package/src/ui/form/FormRowConfig.ts +17 -0
  152. package/src/ui/form/FormRowsConfig.ts +6 -0
  153. package/src/ui/form/FormValue.ts +12 -0
  154. package/src/ui/form/FormValues.ts +9 -0
  155. package/src/ui/form/SelectInput.tsx +165 -0
  156. package/src/ui/form/SelectInputItem.ts +10 -0
  157. package/src/ui/form/TextInput.tsx +228 -0
  158. package/src/ui/form/createForm.tsx +89 -0
  159. package/src/ui/form.ts +13 -0
  160. package/src/ui/getErrorDetail.ts +73 -0
  161. package/src/ui/icons.ts +13 -0
  162. package/src/ui/internals/Wrapper.tsx +34 -0
  163. package/src/ui/internals/programContext.ts +12 -0
  164. package/src/ui/internals/rotate.ts +12 -0
  165. package/src/ui/internals.ts +3 -0
  166. package/src/ui/useProgram.ts +24 -0
  167. package/src/ui.ts +10 -0
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ import * as colors from './colors.js';
4
+ import { getErrorDetail } from './getErrorDetail.js';
5
+ import { Header } from './Header.js';
6
+ import * as icons from './icons.js';
7
+ /**
8
+ * A component that renders a failure state.
9
+ */ export function Failure({ error , errorDetail , ...boxProps }) {
10
+ let { label , description , stack , cause } = errorDetail ?? getErrorDetail(error);
11
+ return /*#__PURE__*/ _jsxs(Box, {
12
+ ...boxProps,
13
+ flexDirection: "column",
14
+ children: [
15
+ /*#__PURE__*/ _jsx(Header, {
16
+ icon: icons.error,
17
+ children: /*#__PURE__*/ _jsx(Text, {
18
+ color: colors.highlighted,
19
+ children: label
20
+ })
21
+ }),
22
+ description ? /*#__PURE__*/ _jsx(Box, {
23
+ flexDirection: "column",
24
+ marginLeft: 2,
25
+ children: /*#__PURE__*/ _jsx(Text, {
26
+ color: colors.failure,
27
+ children: description
28
+ })
29
+ }) : null,
30
+ stack ? /*#__PURE__*/ _jsx(Box, {
31
+ flexDirection: "column",
32
+ marginTop: 1,
33
+ marginLeft: 2,
34
+ children: /*#__PURE__*/ _jsx(Text, {
35
+ color: colors.muted,
36
+ children: stack
37
+ })
38
+ }) : null,
39
+ cause ? /*#__PURE__*/ _jsxs(_Fragment, {
40
+ children: [
41
+ /*#__PURE__*/ _jsx(Box, {
42
+ flexDirection: "column",
43
+ marginTop: 1,
44
+ marginLeft: 2,
45
+ children: /*#__PURE__*/ _jsx(Text, {
46
+ color: colors.muted,
47
+ children: cause.description
48
+ })
49
+ }),
50
+ cause.stack ? /*#__PURE__*/ _jsx(Box, {
51
+ flexDirection: "column",
52
+ marginTop: 1,
53
+ marginLeft: 2,
54
+ children: /*#__PURE__*/ _jsx(Text, {
55
+ color: colors.muted,
56
+ children: cause.stack
57
+ })
58
+ }) : null
59
+ ]
60
+ }) : null
61
+ ]
62
+ });
63
+ }
64
+
65
+ //# sourceMappingURL=Failure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ui/Failure.tsx"],"sourcesContent":["import {Box, Text, type BoxProps} from 'ink';\n\nimport * as colors from './colors.js';\nimport {type ErrorDetail} from './ErrorDetail.js';\nimport {getErrorDetail} from './getErrorDetail.js';\nimport {Header} from './Header.js';\nimport * as icons from './icons.js';\n\n/**\n * {@linkcode Failure} component props.\n */\nexport type FailureProps = BoxProps & {\n /** Error that describes a failure state. Function {@linkcode getErrorDetail} is used for getting all the information from the error; you can use it to implement own retrieval logic and pass the result as `errorDetail` prop. */\n error: Error;\n\n /** Information about the failure state. Overrides information retireved from `error` prop. */\n errorDetail?: ErrorDetail;\n};\n\n/**\n * A component that renders a failure state.\n */\nexport function Failure({error, errorDetail, ...boxProps}: FailureProps) {\n let {label, description, stack, cause} = errorDetail ?? getErrorDetail(error);\n\n return (\n <Box {...boxProps} flexDirection=\"column\">\n <Header icon={icons.error}>\n <Text color={colors.highlighted}>{label}</Text>\n </Header>\n\n {description ? (\n <Box flexDirection=\"column\" marginLeft={2}>\n <Text color={colors.failure}>{description}</Text>\n </Box>\n ) : null}\n\n {stack ? (\n <Box flexDirection=\"column\" marginTop={1} marginLeft={2}>\n <Text color={colors.muted}>{stack}</Text>\n </Box>\n ) : null}\n\n {cause ? (\n <>\n <Box flexDirection=\"column\" marginTop={1} marginLeft={2}>\n <Text color={colors.muted}>{cause.description}</Text>\n </Box>\n\n {cause.stack ? (\n <Box flexDirection=\"column\" marginTop={1} marginLeft={2}>\n <Text color={colors.muted}>{cause.stack}</Text>\n </Box>\n ) : null}\n </>\n ) : null}\n </Box>\n );\n}\n"],"names":["Box","Text","colors","getErrorDetail","Header","icons","Failure","error","errorDetail","boxProps","label","description","stack","cause","flexDirection","icon","color","highlighted","marginLeft","failure","marginTop","muted"],"mappings":";AAAA,SAAQA,GAAG,EAAEC,IAAI,QAAsB,MAAM;AAE7C,YAAYC,YAAY,cAAc;AAEtC,SAAQC,cAAc,QAAO,sBAAsB;AACnD,SAAQC,MAAM,QAAO,cAAc;AACnC,YAAYC,WAAW,aAAa;AAapC;;CAEC,GACD,OAAO,SAASC,QAAQ,EAACC,MAAK,EAAEC,YAAW,EAAE,GAAGC,UAAuB;IACrE,IAAI,EAACC,MAAK,EAAEC,YAAW,EAAEC,MAAK,EAAEC,MAAK,EAAC,GAAGL,eAAeL,eAAeI;IAEvE,qBACE,MAACP;QAAK,GAAGS,QAAQ;QAAEK,eAAc;;0BAC/B,KAACV;gBAAOW,MAAMV,MAAME;0BAClB,cAAA,KAACN;oBAAKe,OAAOd,OAAOe;8BAAcP;;;YAGnCC,4BACC,KAACX;gBAAIc,eAAc;gBAASI,YAAY;0BACtC,cAAA,KAACjB;oBAAKe,OAAOd,OAAOiB;8BAAUR;;iBAE9B;YAEHC,sBACC,KAACZ;gBAAIc,eAAc;gBAASM,WAAW;gBAAGF,YAAY;0BACpD,cAAA,KAACjB;oBAAKe,OAAOd,OAAOmB;8BAAQT;;iBAE5B;YAEHC,sBACC;;kCACE,KAACb;wBAAIc,eAAc;wBAASM,WAAW;wBAAGF,YAAY;kCACpD,cAAA,KAACjB;4BAAKe,OAAOd,OAAOmB;sCAAQR,MAAMF;;;oBAGnCE,MAAMD,sBACL,KAACZ;wBAAIc,eAAc;wBAASM,WAAW;wBAAGF,YAAY;kCACpD,cAAA,KAACjB;4BAAKe,OAAOd,OAAOmB;sCAAQR,MAAMD;;yBAElC;;iBAEJ;;;AAGV"}
@@ -0,0 +1,15 @@
1
+ import { type BoxProps } from 'ink';
2
+ import { type PropsWithChildren } from 'react';
3
+ /**
4
+ * {@linkcode Header} component props.
5
+ */
6
+ export type HeaderProps = BoxProps & {
7
+ /** Icon (recommended is 1 character) to render before the header itself. */
8
+ icon?: string;
9
+ /** Show spinner instead of the icon. */
10
+ showSpinner?: boolean;
11
+ };
12
+ /**
13
+ * Header component.
14
+ */
15
+ export declare function Header({ children, icon, showSpinner, ...boxProps }: PropsWithChildren<HeaderProps>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ import { Spinner } from './Spinner.js';
4
+ /**
5
+ * Header component.
6
+ */ export function Header({ children , icon , showSpinner =false , ...boxProps }) {
7
+ return /*#__PURE__*/ _jsxs(Box, {
8
+ ...boxProps,
9
+ children: [
10
+ icon || showSpinner ? /*#__PURE__*/ _jsxs(Box, {
11
+ marginRight: 1,
12
+ children: [
13
+ showSpinner ? /*#__PURE__*/ _jsx(Spinner, {}) : null,
14
+ !showSpinner && icon ? /*#__PURE__*/ _jsx(Text, {
15
+ children: icon
16
+ }) : null
17
+ ]
18
+ }) : null,
19
+ /*#__PURE__*/ _jsx(Box, {
20
+ children: children
21
+ })
22
+ ]
23
+ });
24
+ }
25
+
26
+ //# sourceMappingURL=Header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ui/Header.tsx"],"sourcesContent":["import {Box, type BoxProps, Text} from 'ink';\nimport {type PropsWithChildren} from 'react';\n\nimport {Spinner} from './Spinner.js';\n\n/**\n * {@linkcode Header} component props.\n */\nexport type HeaderProps = BoxProps & {\n /** Icon (recommended is 1 character) to render before the header itself. */\n icon?: string;\n\n /** Show spinner instead of the icon. */\n showSpinner?: boolean;\n};\n\n/**\n * Header component.\n */\nexport function Header({\n children,\n icon,\n showSpinner = false,\n ...boxProps\n}: PropsWithChildren<HeaderProps>) {\n return (\n <Box {...boxProps}>\n {icon || showSpinner ? (\n <Box marginRight={1}>\n {showSpinner ? <Spinner /> : null}\n {!showSpinner && icon ? <Text>{icon}</Text> : null}\n </Box>\n ) : null}\n <Box>{children}</Box>\n </Box>\n );\n}\n"],"names":["Box","Text","Spinner","Header","children","icon","showSpinner","boxProps","marginRight"],"mappings":";AAAA,SAAQA,GAAG,EAAiBC,IAAI,QAAO,MAAM;AAG7C,SAAQC,OAAO,QAAO,eAAe;AAarC;;CAEC,GACD,OAAO,SAASC,OAAO,EACrBC,SAAQ,EACRC,KAAI,EACJC,aAAc,MAAK,EACnB,GAAGC,UAC4B;IAC/B,qBACE,MAACP;QAAK,GAAGO,QAAQ;;YACdF,QAAQC,4BACP,MAACN;gBAAIQ,aAAa;;oBACfF,4BAAc,KAACJ,eAAa;oBAC5B,CAACI,eAAeD,qBAAO,KAACJ;kCAAMI;yBAAe;;iBAE9C;0BACJ,KAACL;0BAAKI;;;;AAGZ"}
@@ -0,0 +1,13 @@
1
+ import { type BoxProps } from 'ink';
2
+ import { type Program } from '../program.js';
3
+ /**
4
+ * {@linkcode Help} component props.
5
+ */
6
+ export type HelpProps = BoxProps & {
7
+ /** {@linkcode Program} instance. */
8
+ program: Program;
9
+ };
10
+ /**
11
+ * A component that renders help information.
12
+ */
13
+ export declare function Help({ program, ...boxProps }: HelpProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,64 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import chalk from 'chalk';
3
+ import { Box, Text } from 'ink';
4
+ import * as colors from './colors.js';
5
+ import { Header } from './Header.js';
6
+ import * as icons from './icons.js';
7
+ /**
8
+ * A component that renders help information.
9
+ */ export function Help({ program , ...boxProps }) {
10
+ return /*#__PURE__*/ _jsxs(Box, {
11
+ ...boxProps,
12
+ flexDirection: "column",
13
+ children: [
14
+ /*#__PURE__*/ _jsx(Text, {
15
+ children: `${chalk[colors.notice](program.name ?? '?')} ${chalk[colors.muted](program.version ?? '?')}`
16
+ }),
17
+ /*#__PURE__*/ _jsx(Text, {
18
+ color: colors.body,
19
+ children: program.description
20
+ }),
21
+ program.commands.length ? /*#__PURE__*/ _jsxs(_Fragment, {
22
+ children: [
23
+ /*#__PURE__*/ _jsx(Header, {
24
+ icon: icons.info,
25
+ marginTop: 1,
26
+ children: /*#__PURE__*/ _jsx(Text, {
27
+ color: colors.highlighted,
28
+ children: "Usage"
29
+ })
30
+ }),
31
+ program.commands.map((command)=>{
32
+ let line = `${chalk[colors.muted](program.bin ?? '?')} ${command.name}`;
33
+ if (command.parameters) {
34
+ if (command.parameters.some((parameterConfig)=>!!parameterConfig.required)) {
35
+ line += ` ${chalk[colors.muted]('<parameters>')}`;
36
+ } else {
37
+ line += ` ${chalk[colors.muted]('[<parameters>]')}`;
38
+ }
39
+ }
40
+ if (command.options) {
41
+ if (Object.entries(command.options).some(([, optionConfig])=>!!optionConfig.required)) {
42
+ line += ` ${chalk[colors.muted]('<options>')}`;
43
+ } else {
44
+ line += ` ${chalk[colors.muted]('[<options>]')}`;
45
+ }
46
+ }
47
+ if (command.description) {
48
+ line += ` ${command.description}`;
49
+ }
50
+ return /*#__PURE__*/ _jsx(Box, {
51
+ marginLeft: 2,
52
+ flexDirection: "column",
53
+ children: /*#__PURE__*/ _jsx(Text, {
54
+ children: line
55
+ })
56
+ }, command.name);
57
+ })
58
+ ]
59
+ }) : null
60
+ ]
61
+ });
62
+ }
63
+
64
+ //# sourceMappingURL=Help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ui/Help.tsx"],"sourcesContent":["import chalk from 'chalk';\nimport {Box, Text, type BoxProps} from 'ink';\n\nimport * as colors from './colors.js';\nimport {Header} from './Header.js';\nimport * as icons from './icons.js';\nimport {type Program} from '../program.js';\n\n/**\n * {@linkcode Help} component props.\n */\nexport type HelpProps = BoxProps & {\n /** {@linkcode Program} instance. */\n program: Program;\n};\n\n/**\n * A component that renders help information.\n */\nexport function Help({program, ...boxProps}: HelpProps) {\n return (\n <Box {...boxProps} flexDirection=\"column\">\n <Text>{`${chalk[colors.notice](program.name ?? '?')} ${chalk[colors.muted](\n program.version ?? '?',\n )}`}</Text>\n <Text color={colors.body}>{program.description}</Text>\n\n {program.commands.length ? (\n <>\n <Header icon={icons.info} marginTop={1}>\n <Text color={colors.highlighted}>Usage</Text>\n </Header>\n {program.commands.map((command) => {\n let line = `${chalk[colors.muted](program.bin ?? '?')} ${command.name}`;\n\n if (command.parameters) {\n if (command.parameters.some((parameterConfig) => !!parameterConfig.required)) {\n line += ` ${chalk[colors.muted]('<parameters>')}`;\n } else {\n line += ` ${chalk[colors.muted]('[<parameters>]')}`;\n }\n }\n\n if (command.options) {\n if (\n Object.entries(command.options).some(([, optionConfig]) => !!optionConfig.required)\n ) {\n line += ` ${chalk[colors.muted]('<options>')}`;\n } else {\n line += ` ${chalk[colors.muted]('[<options>]')}`;\n }\n }\n\n if (command.description) {\n line += ` ${command.description}`;\n }\n\n return (\n <Box key={command.name} marginLeft={2} flexDirection=\"column\">\n <Text>{line}</Text>\n </Box>\n );\n })}\n </>\n ) : null}\n </Box>\n );\n}\n"],"names":["chalk","Box","Text","colors","Header","icons","Help","program","boxProps","flexDirection","notice","name","muted","version","color","body","description","commands","length","icon","info","marginTop","highlighted","map","command","line","bin","parameters","some","parameterConfig","required","options","Object","entries","optionConfig","marginLeft"],"mappings":";AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAAQC,GAAG,EAAEC,IAAI,QAAsB,MAAM;AAE7C,YAAYC,YAAY,cAAc;AACtC,SAAQC,MAAM,QAAO,cAAc;AACnC,YAAYC,WAAW,aAAa;AAWpC;;CAEC,GACD,OAAO,SAASC,KAAK,EAACC,QAAO,EAAE,GAAGC,UAAoB;IACpD,qBACE,MAACP;QAAK,GAAGO,QAAQ;QAAEC,eAAc;;0BAC/B,KAACP;0BAAM,CAAC,EAAEF,KAAK,CAACG,OAAOO,OAAO,CAACH,QAAQI,QAAQ,KAAK,CAAC,EAAEX,KAAK,CAACG,OAAOS,MAAM,CACxEL,QAAQM,WAAW,KACnB,CAAC;;0BACH,KAACX;gBAAKY,OAAOX,OAAOY;0BAAOR,QAAQS;;YAElCT,QAAQU,SAASC,uBAChB;;kCACE,KAACd;wBAAOe,MAAMd,MAAMe;wBAAMC,WAAW;kCACnC,cAAA,KAACnB;4BAAKY,OAAOX,OAAOmB;sCAAa;;;oBAElCf,QAAQU,SAASM,IAAI,CAACC;wBACrB,IAAIC,OAAO,CAAC,EAAEzB,KAAK,CAACG,OAAOS,MAAM,CAACL,QAAQmB,OAAO,KAAK,CAAC,EAAEF,QAAQb,KAAK,CAAC;wBAEvE,IAAIa,QAAQG,YAAY;4BACtB,IAAIH,QAAQG,WAAWC,KAAK,CAACC,kBAAoB,CAAC,CAACA,gBAAgBC,WAAW;gCAC5EL,QAAQ,CAAC,CAAC,EAAEzB,KAAK,CAACG,OAAOS,MAAM,CAAC,gBAAgB,CAAC;4BACnD,OAAO;gCACLa,QAAQ,CAAC,CAAC,EAAEzB,KAAK,CAACG,OAAOS,MAAM,CAAC,kBAAkB,CAAC;4BACrD;wBACF;wBAEA,IAAIY,QAAQO,SAAS;4BACnB,IACEC,OAAOC,QAAQT,QAAQO,SAASH,KAAK,CAAC,GAAGM,aAAa,GAAK,CAAC,CAACA,aAAaJ,WAC1E;gCACAL,QAAQ,CAAC,CAAC,EAAEzB,KAAK,CAACG,OAAOS,MAAM,CAAC,aAAa,CAAC;4BAChD,OAAO;gCACLa,QAAQ,CAAC,CAAC,EAAEzB,KAAK,CAACG,OAAOS,MAAM,CAAC,eAAe,CAAC;4BAClD;wBACF;wBAEA,IAAIY,QAAQR,aAAa;4BACvBS,QAAQ,CAAC,CAAC,EAAED,QAAQR,YAAY,CAAC;wBACnC;wBAEA,qBACE,KAACf;4BAAuBkC,YAAY;4BAAG1B,eAAc;sCACnD,cAAA,KAACP;0CAAMuB;;2BADCD,QAAQb;oBAItB;;iBAEA;;;AAGV"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Spinner component.
3
+ */
4
+ export declare function Spinner(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Text } from 'ink';
3
+ import { useState, useEffect } from 'react';
4
+ const SPINNER = {
5
+ interval: 80,
6
+ frames: [
7
+ '⠋',
8
+ '⠙',
9
+ '⠹',
10
+ '⠸',
11
+ '⠼',
12
+ '⠴',
13
+ '⠦',
14
+ '⠧',
15
+ '⠇',
16
+ '⠏'
17
+ ]
18
+ };
19
+ /**
20
+ * Spinner component.
21
+ */ export function Spinner() {
22
+ let [frame, setFrame] = useState(0);
23
+ useEffect(()=>{
24
+ let timer = setInterval(()=>{
25
+ setFrame((previousFrame)=>{
26
+ let isLastFrame = previousFrame === SPINNER.frames.length - 1;
27
+ return isLastFrame ? 0 : previousFrame + 1;
28
+ });
29
+ }, SPINNER.interval);
30
+ return ()=>{
31
+ clearInterval(timer);
32
+ };
33
+ }, []);
34
+ return /*#__PURE__*/ _jsx(Text, {
35
+ children: SPINNER.frames[frame]
36
+ });
37
+ }
38
+
39
+ //# sourceMappingURL=Spinner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ui/Spinner.tsx"],"sourcesContent":["import {Text} from 'ink';\nimport {useState, useEffect} from 'react';\n\nconst SPINNER = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\n/**\n * Spinner component.\n */\nexport function Spinner() {\n let [frame, setFrame] = useState(0);\n\n useEffect(() => {\n let timer = setInterval(() => {\n setFrame((previousFrame) => {\n let isLastFrame = previousFrame === SPINNER.frames.length - 1;\n\n return isLastFrame ? 0 : previousFrame + 1;\n });\n }, SPINNER.interval);\n\n return () => {\n clearInterval(timer);\n };\n }, []);\n\n return <Text>{SPINNER.frames[frame]}</Text>;\n}\n"],"names":["Text","useState","useEffect","SPINNER","interval","frames","Spinner","frame","setFrame","timer","setInterval","previousFrame","isLastFrame","length","clearInterval"],"mappings":";AAAA,SAAQA,IAAI,QAAO,MAAM;AACzB,SAAQC,QAAQ,EAAEC,SAAS,QAAO,QAAQ;AAE1C,MAAMC,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA;;CAEC,GACD,OAAO,SAASC;IACd,IAAI,CAACC,OAAOC,SAAS,GAAGP,SAAS;IAEjCC,UAAU;QACR,IAAIO,QAAQC,YAAY;YACtBF,SAAS,CAACG;gBACR,IAAIC,cAAcD,kBAAkBR,QAAQE,OAAOQ,SAAS;gBAE5D,OAAOD,cAAc,IAAID,gBAAgB;YAC3C;QACF,GAAGR,QAAQC;QAEX,OAAO;YACLU,cAAcL;QAChB;IACF,GAAG,EAAE;IAEL,qBAAO,KAACT;kBAAMG,QAAQE,MAAM,CAACE,MAAM;;AACrC"}
@@ -0,0 +1,10 @@
1
+ export declare const body = "white";
2
+ export declare const highlighted = "whiteBright";
3
+ export declare const muted = "gray";
4
+ export declare const unselected = "gray";
5
+ export declare const selected = "greenBright";
6
+ export declare const notice = "magenta";
7
+ export declare const info = "cyan";
8
+ export declare const success = "green";
9
+ export declare const warning = "yellow";
10
+ export declare const failure = "red";
@@ -0,0 +1,12 @@
1
+ export const body = 'white';
2
+ export const highlighted = 'whiteBright';
3
+ export const muted = 'gray';
4
+ export const unselected = 'gray';
5
+ export const selected = 'greenBright';
6
+ export const notice = 'magenta';
7
+ export const info = 'cyan';
8
+ export const success = 'green';
9
+ export const warning = 'yellow';
10
+ export const failure = 'red';
11
+
12
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ui/colors.ts"],"sourcesContent":["export const body = 'white';\nexport const highlighted = 'whiteBright';\nexport const muted = 'gray';\n\nexport const unselected = 'gray';\nexport const selected = 'greenBright';\n\nexport const notice = 'magenta';\n\nexport const info = 'cyan';\nexport const success = 'green';\nexport const warning = 'yellow';\nexport const failure = 'red';\n"],"names":["body","highlighted","muted","unselected","selected","notice","info","success","warning","failure"],"mappings":"AAAA,OAAO,MAAMA,OAAO,QAAQ;AAC5B,OAAO,MAAMC,cAAc,cAAc;AACzC,OAAO,MAAMC,QAAQ,OAAO;AAE5B,OAAO,MAAMC,aAAa,OAAO;AACjC,OAAO,MAAMC,WAAW,cAAc;AAEtC,OAAO,MAAMC,SAAS,UAAU;AAEhC,OAAO,MAAMC,OAAO,OAAO;AAC3B,OAAO,MAAMC,UAAU,QAAQ;AAC/B,OAAO,MAAMC,UAAU,SAAS;AAChC,OAAO,MAAMC,UAAU,MAAM"}
@@ -0,0 +1,9 @@
1
+ import { type FC } from 'react';
2
+ import { type FormConfig } from './FormConfig.js';
3
+ import { type FormProps } from './FormProps.js';
4
+ /**
5
+ * Form component.
6
+ */
7
+ export type Form<C extends FormConfig> = FC<FormProps<C>> & {
8
+ config: C;
9
+ };
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=Form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/form/Form.ts"],"sourcesContent":["import {type FC} from 'react';\n\nimport {type FormConfig} from './FormConfig.js';\nimport {type FormProps} from './FormProps.js';\n\n/**\n * Form component.\n */\nexport type Form<C extends FormConfig> = FC<FormProps<C>> & {config: C};\n"],"names":[],"mappings":"AAAA,WAQwE"}
@@ -0,0 +1,8 @@
1
+ import { type FormRowsConfig } from './FormRowsConfig.js';
2
+ /**
3
+ * Form configuration.
4
+ */
5
+ export type FormConfig = {
6
+ /** Form rows configuration. */
7
+ rows: FormRowsConfig;
8
+ };
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=FormConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/form/FormConfig.ts"],"sourcesContent":["import {type FormRowsConfig} from './FormRowsConfig.js';\n\n/**\n * Form configuration.\n */\nexport type FormConfig = {\n /** Form rows configuration. */\n rows: FormRowsConfig;\n};\n"],"names":[],"mappings":"AAAA,WAQE"}
@@ -0,0 +1,40 @@
1
+ import { type BoxProps } from 'ink';
2
+ import { type FormConfig } from './FormConfig.js';
3
+ import { type FormRowConfig } from './FormRowConfig.js';
4
+ import { type FormValues } from './FormValues.js';
5
+ /** A type that creates string literal union type with names of rows that need some props. */
6
+ type FormRowWithPropsNames<C extends FormConfig> = {
7
+ [P in keyof C['rows']]: C['rows'][P]['type'] extends 'text' ? never : C['rows'][P]['type'] extends 'confirm' ? never : C['rows'][P]['type'] extends 'select' ? P : never;
8
+ }[keyof C['rows']];
9
+ type FormPropsRow<C extends FormRowConfig> = C['type'] extends 'text' ? never : C['type'] extends 'confirm' ? never : C['type'] extends 'select' ? {
10
+ choices: Array<{
11
+ value: string;
12
+ label: string;
13
+ }>;
14
+ } : never;
15
+ type FormPropsRows<C extends FormConfig> = Pick<{
16
+ [P in keyof C['rows']]: FormPropsRow<C['rows'][P]>;
17
+ }, FormRowWithPropsNames<C>>;
18
+ /**
19
+ * Form component props.
20
+ */
21
+ export type FormProps<C extends FormConfig> = FormPropsRows<C> extends Record<number | string | symbol, never> ? BoxProps & {
22
+ /** Props for each row. */
23
+ rows?: null | undefined;
24
+ /** Form values */
25
+ values: FormValues<C>;
26
+ /** Handler function that is called when value changes. */
27
+ onChange?: ((formResult: FormValues<C>) => void) | undefined;
28
+ /** Handler function that is called when the value is accepted. */
29
+ onComplete: (formResult: FormValues<C>) => void;
30
+ } : BoxProps & {
31
+ /** Props for each row. */
32
+ rows: FormPropsRows<C>;
33
+ /** Form values */
34
+ values: FormValues<C>;
35
+ /** Handler function that is called when value changes. */
36
+ onChange?: ((formResult: FormValues<C>) => void) | undefined;
37
+ /** Handler function that is called when the value is accepted. */
38
+ onComplete: (formResult: FormValues<C>) => void;
39
+ };
40
+ export {};
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=FormProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/form/FormProps.ts"],"sourcesContent":["import {type BoxProps} from 'ink';\n\nimport {type FormConfig} from './FormConfig.js';\nimport {type FormRowConfig} from './FormRowConfig.js';\nimport {type FormValues} from './FormValues.js';\n\n/** A type that creates string literal union type with names of rows that need some props. */\ntype FormRowWithPropsNames<C extends FormConfig> = {\n [P in keyof C['rows']]: C['rows'][P]['type'] extends 'text'\n ? never\n : C['rows'][P]['type'] extends 'confirm'\n ? never\n : C['rows'][P]['type'] extends 'select'\n ? P\n : never;\n}[keyof C['rows']];\n\ntype FormPropsRow<C extends FormRowConfig> = C['type'] extends 'text'\n ? never\n : C['type'] extends 'confirm'\n ? never\n : C['type'] extends 'select'\n ? {\n choices: Array<{value: string; label: string}>;\n }\n : never;\n\ntype FormPropsRows<C extends FormConfig> = Pick<\n {\n [P in keyof C['rows']]: FormPropsRow<C['rows'][P]>;\n },\n FormRowWithPropsNames<C>\n>;\n\n/**\n * Form component props.\n */\nexport type FormProps<C extends FormConfig> = FormPropsRows<C> extends Record<\n number | string | symbol,\n never\n>\n ? BoxProps & {\n /** Props for each row. */\n rows?: null | undefined;\n\n /** Form values */\n values: FormValues<C>;\n\n /** Handler function that is called when value changes. */\n onChange?: ((formResult: FormValues<C>) => void) | undefined;\n\n /** Handler function that is called when the value is accepted. */\n onComplete: (formResult: FormValues<C>) => void;\n }\n : BoxProps & {\n /** Props for each row. */\n rows: FormPropsRows<C>;\n\n /** Form values */\n values: FormValues<C>;\n\n /** Handler function that is called when value changes. */\n onChange?: ((formResult: FormValues<C>) => void) | undefined;\n\n /** Handler function that is called when the value is accepted. */\n onComplete: (formResult: FormValues<C>) => void;\n };\n"],"names":[],"mappings":"AAAA,WAkEM"}
@@ -0,0 +1,6 @@
1
+ import { type Form } from './Form.js';
2
+ import { type FormValues } from './FormValues.js';
3
+ /**
4
+ * Form result. It is the value of all form rows after the last one is accepted.
5
+ */
6
+ export type FormResult<F extends Pick<Form<any>, 'config'>> = FormValues<F['config']>;
@@ -0,0 +1,3 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any -- needed */ export { };
2
+
3
+ //# sourceMappingURL=FormResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/form/FormResult.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- needed */\nimport {type Form} from './Form.js';\nimport {type FormValues} from './FormValues.js';\n\n/**\n * Form result. It is the value of all form rows after the last one is accepted.\n */\nexport type FormResult<F extends Pick<Form<any>, 'config'>> = FormValues<F['config']>;\n"],"names":[],"mappings":"AAAA,+DAA+D,GAC/D,WAMsF"}
@@ -0,0 +1,30 @@
1
+ import { type BoxProps } from 'ink';
2
+ import { type FormConfig } from './FormConfig.js';
3
+ import { type FormProps } from './FormProps.js';
4
+ import { type FormRowConfig } from './FormRowConfig.js';
5
+ /**
6
+ * Form row component props.
7
+ */
8
+ type FormRowProps<C extends FormConfig> = BoxProps & {
9
+ /** Form row configuration. */
10
+ config: FormRowConfig;
11
+ /** Props of all form rows. */
12
+ rows: FormProps<C>['rows'] | null;
13
+ /** Row name. */
14
+ rowName: keyof C['rows'];
15
+ /** Value. */
16
+ value: unknown;
17
+ /** Should component listen to Listen to user's input? Useful in case there are multiple input components at the same time and input must be "routed" to a specific component. */
18
+ focus: boolean;
19
+ /** Handler function that is called when value changes. */
20
+ onChange: (value: unknown, inputName: keyof C['rows']) => void;
21
+ /** Handler function that is called when the value is accepted. */
22
+ onComplete: (value: unknown, inputName: keyof C['rows']) => void;
23
+ /** Indicates whether value has been accepted. Component in the row then doesn't accept more input. */
24
+ isComplete: boolean;
25
+ };
26
+ /**
27
+ * Form row component.
28
+ */
29
+ export declare function FormRow<C extends FormConfig>({ rowName, config, rows, value, focus, isComplete, onChange, onComplete, ...boxProps }: FormRowProps<C>): import("react/jsx-runtime").JSX.Element | null;
30
+ export {};
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import { SelectInput } from './SelectInput.js';
4
+ import { TextInput } from './TextInput.js';
5
+ /**
6
+ * Form row component.
7
+ */ export function FormRow({ rowName , config , rows , value , focus , isComplete , onChange , onComplete , ...boxProps }) {
8
+ // TODO: Each input component handles values and events differently; the APIs should be adjusted.
9
+ let handleChange = useCallback((newValue)=>{
10
+ onChange(newValue, rowName);
11
+ }, [
12
+ rowName,
13
+ onChange
14
+ ]);
15
+ let handleFinish = useCallback((newValue)=>{
16
+ onComplete(newValue, rowName);
17
+ }, [
18
+ rowName,
19
+ onComplete
20
+ ]);
21
+ let handleSelectFinish = useCallback((item)=>{
22
+ onComplete(item.value, rowName);
23
+ }, [
24
+ rowName,
25
+ onComplete
26
+ ]);
27
+ switch(config.type){
28
+ case 'text':
29
+ {
30
+ return /*#__PURE__*/ _jsx(TextInput, {
31
+ label: config.label ?? '',
32
+ validate: config.validate,
33
+ value: value,
34
+ focus: focus,
35
+ isComplete: isComplete,
36
+ onChange: handleChange,
37
+ onSubmit: handleFinish,
38
+ ...boxProps
39
+ }, String(rowName));
40
+ }
41
+ case 'select':
42
+ {
43
+ return /*#__PURE__*/ _jsx(SelectInput, {
44
+ label: config.label ?? '',
45
+ items: rows ? rows[rowName].choices : [],
46
+ focus: focus,
47
+ isComplete: isComplete,
48
+ onSelect: handleSelectFinish,
49
+ ...boxProps
50
+ }, String(rowName));
51
+ }
52
+ default:
53
+ {
54
+ return null;
55
+ }
56
+ }
57
+ }
58
+
59
+ //# sourceMappingURL=FormRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/form/FormRow.tsx"],"sourcesContent":["import {type BoxProps} from 'ink';\nimport {useCallback} from 'react';\n\nimport {type FormConfig} from './FormConfig.js';\nimport {type FormProps} from './FormProps.js';\nimport {type FormRowConfig} from './FormRowConfig.js';\nimport {SelectInput} from './SelectInput.js';\nimport {TextInput} from './TextInput.js';\n\n/**\n * Form row component props.\n */\ntype FormRowProps<C extends FormConfig> = BoxProps & {\n /** Form row configuration. */\n config: FormRowConfig;\n\n // TODO: Should all rows props be passed to each row?\n /** Props of all form rows. */\n rows: FormProps<C>['rows'] | null;\n\n /** Row name. */\n rowName: keyof C['rows'];\n\n /** Value. */\n value: unknown;\n\n /** Should component listen to Listen to user's input? Useful in case there are multiple input components at the same time and input must be \"routed\" to a specific component. */\n focus: boolean;\n\n /** Handler function that is called when value changes. */\n onChange: (value: unknown, inputName: keyof C['rows']) => void;\n\n /** Handler function that is called when the value is accepted. */\n onComplete: (value: unknown, inputName: keyof C['rows']) => void;\n\n /** Indicates whether value has been accepted. Component in the row then doesn't accept more input. */\n isComplete: boolean;\n};\n\n/**\n * Form row component.\n */\nexport function FormRow<C extends FormConfig>({\n rowName,\n config,\n rows,\n value,\n focus,\n isComplete,\n onChange,\n onComplete,\n ...boxProps\n}: FormRowProps<C>) {\n // TODO: Each input component handles values and events differently; the APIs should be adjusted.\n let handleChange = useCallback(\n (newValue: unknown) => {\n onChange(newValue, rowName);\n },\n [rowName, onChange],\n );\n\n let handleFinish = useCallback(\n (newValue: unknown) => {\n onComplete(newValue, rowName);\n },\n [rowName, onComplete],\n );\n\n let handleSelectFinish = useCallback(\n (item: {value: unknown}) => {\n onComplete(item.value, rowName);\n },\n [rowName, onComplete],\n );\n\n switch (config.type) {\n case 'text': {\n return (\n <TextInput\n key={String(rowName)}\n label={config.label ?? ''}\n validate={config.validate}\n value={value as string}\n focus={focus}\n isComplete={isComplete}\n onChange={handleChange}\n onSubmit={handleFinish}\n {...boxProps}\n />\n );\n }\n case 'select': {\n return (\n <SelectInput\n key={String(rowName)}\n label={config.label ?? ''}\n items={\n rows\n ? (\n (\n rows as {\n [key: string]: unknown;\n }\n )[rowName as string] as {choices: Array<{value: string; label: string}>}\n ).choices\n : []\n }\n focus={focus}\n isComplete={isComplete}\n onSelect={handleSelectFinish}\n {...boxProps}\n />\n );\n }\n default: {\n return null;\n }\n }\n}\n"],"names":["useCallback","SelectInput","TextInput","FormRow","rowName","config","rows","value","focus","isComplete","onChange","onComplete","boxProps","handleChange","newValue","handleFinish","handleSelectFinish","item","type","label","validate","onSubmit","String","items","choices","onSelect"],"mappings":";AACA,SAAQA,WAAW,QAAO,QAAQ;AAKlC,SAAQC,WAAW,QAAO,mBAAmB;AAC7C,SAAQC,SAAS,QAAO,iBAAiB;AAgCzC;;CAEC,GACD,OAAO,SAASC,QAA8B,EAC5CC,QAAO,EACPC,OAAM,EACNC,KAAI,EACJC,MAAK,EACLC,MAAK,EACLC,WAAU,EACVC,SAAQ,EACRC,WAAU,EACV,GAAGC,UACa;IAChB,iGAAiG;IACjG,IAAIC,eAAeb,YACjB,CAACc;QACCJ,SAASI,UAAUV;IACrB,GACA;QAACA;QAASM;KAAS;IAGrB,IAAIK,eAAef,YACjB,CAACc;QACCH,WAAWG,UAAUV;IACvB,GACA;QAACA;QAASO;KAAW;IAGvB,IAAIK,qBAAqBhB,YACvB,CAACiB;QACCN,WAAWM,KAAKV,OAAOH;IACzB,GACA;QAACA;QAASO;KAAW;IAGvB,OAAQN,OAAOa;QACb,KAAK;YAAQ;gBACX,qBACE,KAAChB;oBAECiB,OAAOd,OAAOc,SAAS;oBACvBC,UAAUf,OAAOe;oBACjBb,OAAOA;oBACPC,OAAOA;oBACPC,YAAYA;oBACZC,UAAUG;oBACVQ,UAAUN;oBACT,GAAGH,QAAQ;mBARPU,OAAOlB;YAWlB;QACA,KAAK;YAAU;gBACb,qBACE,KAACH;oBAECkB,OAAOd,OAAOc,SAAS;oBACvBI,OACEjB,OACI,AACE,AACEA,IAGD,CAACF,QAAkB,CACpBoB,UACF,EAAE;oBAERhB,OAAOA;oBACPC,YAAYA;oBACZgB,UAAUT;oBACT,GAAGJ,QAAQ;mBAhBPU,OAAOlB;YAmBlB;QACA;YAAS;gBACP,OAAO;YACT;IACF;AACF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Form row configuration.
3
+ */
4
+ export type FormRowConfig = {
5
+ type: 'confirm';
6
+ label?: string;
7
+ } | {
8
+ type: 'select';
9
+ label?: string;
10
+ } | {
11
+ type: 'text';
12
+ label?: string;
13
+ validate?: (value: string) => void;
14
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Form row configuration.
3
+ */ export { };
4
+
5
+ //# sourceMappingURL=FormRowConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/form/FormRowConfig.ts"],"sourcesContent":["/**\n * Form row configuration.\n */\nexport type FormRowConfig =\n | {\n type: 'confirm';\n label?: string;\n }\n | {\n type: 'select';\n label?: string;\n }\n | {\n type: 'text';\n label?: string;\n validate?: (value: string) => void;\n };\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WAaM"}
@@ -0,0 +1,5 @@
1
+ import { type FormRowConfig } from './FormRowConfig.js';
2
+ /**
3
+ * Form rows configuration.
4
+ */
5
+ export type FormRowsConfig = Record<string, FormRowConfig>;
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=FormRowsConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/form/FormRowsConfig.ts"],"sourcesContent":["import {type FormRowConfig} from './FormRowConfig.js';\n\n/**\n * Form rows configuration.\n */\nexport type FormRowsConfig = Record<string, FormRowConfig>;\n"],"names":[],"mappings":"AAAA,WAK2D"}
@@ -0,0 +1,9 @@
1
+ import { type FormRowConfig } from './FormRowConfig.js';
2
+ export type StringFormValue = {
3
+ value: string;
4
+ isComplete: boolean;
5
+ };
6
+ /**
7
+ * Form value.
8
+ */
9
+ export type FormValue<C extends FormRowConfig> = C['type'] extends 'text' ? StringFormValue : C['type'] extends 'select' ? StringFormValue : never;
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=FormValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/form/FormValue.ts"],"sourcesContent":["import {type FormRowConfig} from './FormRowConfig.js';\n\nexport type StringFormValue = {value: string; isComplete: boolean};\n\n/**\n * Form value.\n */\nexport type FormValue<C extends FormRowConfig> = C['type'] extends 'text'\n ? StringFormValue\n : C['type'] extends 'select'\n ? StringFormValue\n : never;\n"],"names":[],"mappings":"AAAA,WAWU"}
@@ -0,0 +1,8 @@
1
+ import { type FormConfig } from './FormConfig.js';
2
+ import { type FormValue } from './FormValue.js';
3
+ /**
4
+ * Form values.
5
+ */
6
+ export type FormValues<C extends FormConfig> = {
7
+ [P in keyof C['rows']]: FormValue<C['rows'][P]>;
8
+ };
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=FormValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/form/FormValues.ts"],"sourcesContent":["import {type FormConfig} from './FormConfig.js';\nimport {type FormValue} from './FormValue.js';\n\n/**\n * Form values.\n */\nexport type FormValues<C extends FormConfig> = {\n [P in keyof C['rows']]: FormValue<C['rows'][P]>;\n};\n"],"names":[],"mappings":"AAAA,WAQE"}
@@ -0,0 +1,29 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import { type BoxProps } from 'ink';
3
+ import { type SelectInputItem } from './SelectInputItem.js';
4
+ /**
5
+ * Select input component props.
6
+ */
7
+ type SelectInputProps = BoxProps & {
8
+ /** Text to display as a label. */
9
+ label: string;
10
+ /** Items to display in a list. */
11
+ items: SelectInputItem[];
12
+ /** Should component listen to Listen to user's input? Useful in case there are multiple input components at the same time and input must be "routed" to a specific component. */
13
+ focus?: boolean | undefined;
14
+ /** Index of initially selected item. */
15
+ initialIndex?: number | undefined;
16
+ /** Number of items to display. */
17
+ limit?: number | undefined;
18
+ /** Handler function that is called when item is selected. */
19
+ onSelect?: ((item: SelectInputItem) => void) | undefined;
20
+ /** Handler function that is called when item is highlighted. */
21
+ onHighlight?: ((item: SelectInputItem) => void) | undefined;
22
+ /** Indicates whether value has been accepted. Component then doesn't accept more input. */
23
+ isComplete?: boolean | undefined;
24
+ };
25
+ /**
26
+ * Select input component.
27
+ */
28
+ export declare function SelectInput({ label, items, focus, initialIndex, limit: customLimit, onSelect, onHighlight, marginTop, isComplete, ...boxProps }: SelectInputProps): JSX.Element;
29
+ export {};